yapi-code-auto-generator

针对 YApi 系统的代码自动生成器

  1. // ==UserScript==
  2. // @name yapi-code-auto-generator
  3. // @namespace yapi-code-auto-generator
  4. // @version 0.1.0
  5. // @description 针对 YApi 系统的代码自动生成器
  6. // @match http://*/*
  7. // @match http://yapi.smart-xwork.cn/
  8. // @run-at document-start
  9. // @license MIT
  10. // ==/UserScript==
  11. (function () {
  12. 'use strict';
  13.  
  14. // xhr, options
  15. function defaultBeforeXMLHttpRequestOpen() {
  16. // console.log("%c Line:18 🍭 xhr", "color:#b03734", xhr);
  17. // console.log("%c Line:18 🥝 options", "color:#33a5ff", options);
  18. // 修改url
  19. // options.url = options.url.replace("wd=123", "wd=456");
  20. // 修改method
  21. // options.method = 'POST';
  22. }
  23.  
  24. // xhr, body
  25. function defaultBeforeXMLHttpRequestSend() {
  26. // console.log("before send", xhr);
  27. // console.log("%c Line:28 🍬 body", "color:#f5ce50", body);
  28. // 修改请求头
  29. // xhr.setRequestHeader("key1", "value1");
  30. }
  31.  
  32. // e
  33. function handleEvent() {
  34. // console.log("%c Line:77 🍐 e", "color:#b03734", e);
  35. // const log = `${e.type}: ${e.loaded} bytes transferred\n`;
  36. // console.log("%c Line:92 🥝 log", "color:#ea7e5c", log);
  37. }
  38. function addListenersOnXHR(xhr) {
  39. let handlers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  40. xhr.addEventListener("loadstart", handlers.onloadstart || handleEvent);
  41. xhr.addEventListener("load", handlers.onload || handleEvent);
  42. xhr.addEventListener("loadend", handlers.onloadend || handleEvent);
  43. xhr.addEventListener("progress", handlers.onprogress || handleEvent);
  44. xhr.addEventListener("error", handlers.onerror || handleEvent);
  45. xhr.addEventListener("abort", handlers.onabort || handleEvent);
  46. }
  47. function customXMLHttpRequest($options) {
  48. const options = {
  49. beforeXMLHttpRequestOpen: defaultBeforeXMLHttpRequestOpen,
  50. beforeXMLHttpRequestSend: defaultBeforeXMLHttpRequestSend,
  51. eventHandlers: {},
  52. ...$options
  53. };
  54.  
  55. /**
  56. * 重写open方法
  57. * https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest/open
  58. */
  59. XMLHttpRequest.prototype.origin_open = XMLHttpRequest.prototype.open;
  60. XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
  61. // 用对象便于修改参数
  62. var data = {
  63. method: method,
  64. url: url,
  65. async: async,
  66. user: user,
  67. password: password
  68. };
  69. if ("function" === typeof options.defaultBeforeXMLHttpRequestOpen) {
  70. options.defaultBeforeXMLHttpRequestOpen(this, options);
  71. }
  72. addListenersOnXHR(this, options.eventHandlers);
  73. this.origin_open(data.method, data.url, data.async);
  74. };
  75.  
  76. /**
  77. * 重写send方法
  78. * https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest/send
  79. */
  80. XMLHttpRequest.prototype.origin_send = XMLHttpRequest.prototype.send;
  81. XMLHttpRequest.prototype.send = function (body) {
  82. if ("function" === typeof options.defaultBeforeXMLHttpRequestSend) {
  83. options.defaultBeforeXMLHttpRequestSend(this, body);
  84. }
  85. this.origin_send(body);
  86. if (body instanceof FormData) {
  87. const params = [...body.keys()].reduce((prev, curr) => {
  88. prev[curr] = body.get(curr);
  89. return prev;
  90. }, {});
  91. console.log("%c Line:81 🍤 body", "color:#b03734", params);
  92. }
  93. };
  94. }
  95.  
  96. const config = {
  97. baseURL: "/cmp/v1",
  98. // 生成的函数是否需要 export
  99. isExport: true,
  100. showDocUrl: true,
  101. methodFields: {
  102. get: "GET",
  103. post: "POST",
  104. delete: "DELETE",
  105. put: "PUT",
  106. patch: "PATCH",
  107. // uppercase
  108. GET: "GET",
  109. POST: "POST",
  110. DELETE: "DELETE",
  111. PUT: "PUT",
  112. PATCH: "PATCH"
  113. }
  114. };
  115.  
  116. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  117.  
  118. var check = function (it) {
  119. return it && it.Math == Math && it;
  120. };
  121.  
  122. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  123. var global$e =
  124. // eslint-disable-next-line es/no-global-this -- safe
  125. check(typeof globalThis == 'object' && globalThis) ||
  126. check(typeof window == 'object' && window) ||
  127. // eslint-disable-next-line no-restricted-globals -- safe
  128. check(typeof self == 'object' && self) ||
  129. check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
  130. // eslint-disable-next-line no-new-func -- fallback
  131. (function () { return this; })() || Function('return this')();
  132.  
  133. var objectGetOwnPropertyDescriptor = {};
  134.  
  135. var fails$a = function (exec) {
  136. try {
  137. return !!exec();
  138. } catch (error) {
  139. return true;
  140. }
  141. };
  142.  
  143. var fails$9 = fails$a;
  144.  
  145. // Detect IE8's incomplete defineProperty implementation
  146. var descriptors = !fails$9(function () {
  147. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  148. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  149. });
  150.  
  151. var objectPropertyIsEnumerable = {};
  152.  
  153. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  154. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  155. var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
  156.  
  157. // Nashorn ~ JDK8 bug
  158. var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  159.  
  160. // `Object.prototype.propertyIsEnumerable` method implementation
  161. // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
  162. objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  163. var descriptor = getOwnPropertyDescriptor$1(this, V);
  164. return !!descriptor && descriptor.enumerable;
  165. } : $propertyIsEnumerable;
  166.  
  167. var createPropertyDescriptor$2 = function (bitmap, value) {
  168. return {
  169. enumerable: !(bitmap & 1),
  170. configurable: !(bitmap & 2),
  171. writable: !(bitmap & 4),
  172. value: value
  173. };
  174. };
  175.  
  176. var toString$4 = {}.toString;
  177.  
  178. var classofRaw$1 = function (it) {
  179. return toString$4.call(it).slice(8, -1);
  180. };
  181.  
  182. var fails$8 = fails$a;
  183. var classof$3 = classofRaw$1;
  184.  
  185. var split = ''.split;
  186.  
  187. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  188. var indexedObject = fails$8(function () {
  189. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  190. // eslint-disable-next-line no-prototype-builtins -- safe
  191. return !Object('z').propertyIsEnumerable(0);
  192. }) ? function (it) {
  193. return classof$3(it) == 'String' ? split.call(it, '') : Object(it);
  194. } : Object;
  195.  
  196. // `RequireObjectCoercible` abstract operation
  197. // https://tc39.es/ecma262/#sec-requireobjectcoercible
  198. var requireObjectCoercible$4 = function (it) {
  199. if (it == undefined) throw TypeError("Can't call method on " + it);
  200. return it;
  201. };
  202.  
  203. // toObject with fallback for non-array-like ES3 strings
  204. var IndexedObject = indexedObject;
  205. var requireObjectCoercible$3 = requireObjectCoercible$4;
  206.  
  207. var toIndexedObject$3 = function (it) {
  208. return IndexedObject(requireObjectCoercible$3(it));
  209. };
  210.  
  211. // `IsCallable` abstract operation
  212. // https://tc39.es/ecma262/#sec-iscallable
  213. var isCallable$c = function (argument) {
  214. return typeof argument === 'function';
  215. };
  216.  
  217. var isCallable$b = isCallable$c;
  218.  
  219. var isObject$5 = function (it) {
  220. return typeof it === 'object' ? it !== null : isCallable$b(it);
  221. };
  222.  
  223. var global$d = global$e;
  224. var isCallable$a = isCallable$c;
  225.  
  226. var aFunction = function (argument) {
  227. return isCallable$a(argument) ? argument : undefined;
  228. };
  229.  
  230. var getBuiltIn$4 = function (namespace, method) {
  231. return arguments.length < 2 ? aFunction(global$d[namespace]) : global$d[namespace] && global$d[namespace][method];
  232. };
  233.  
  234. var getBuiltIn$3 = getBuiltIn$4;
  235.  
  236. var engineUserAgent = getBuiltIn$3('navigator', 'userAgent') || '';
  237.  
  238. var global$c = global$e;
  239. var userAgent = engineUserAgent;
  240.  
  241. var process = global$c.process;
  242. var Deno = global$c.Deno;
  243. var versions = process && process.versions || Deno && Deno.version;
  244. var v8 = versions && versions.v8;
  245. var match, version;
  246.  
  247. if (v8) {
  248. match = v8.split('.');
  249. version = match[0] < 4 ? 1 : match[0] + match[1];
  250. } else if (userAgent) {
  251. match = userAgent.match(/Edge\/(\d+)/);
  252. if (!match || match[1] >= 74) {
  253. match = userAgent.match(/Chrome\/(\d+)/);
  254. if (match) version = match[1];
  255. }
  256. }
  257.  
  258. var engineV8Version = version && +version;
  259.  
  260. /* eslint-disable es/no-symbol -- required for testing */
  261.  
  262. var V8_VERSION = engineV8Version;
  263. var fails$7 = fails$a;
  264.  
  265. // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
  266. var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$7(function () {
  267. var symbol = Symbol();
  268. // Chrome 38 Symbol has incorrect toString conversion
  269. // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
  270. return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
  271. // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
  272. !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  273. });
  274.  
  275. /* eslint-disable es/no-symbol -- required for testing */
  276.  
  277. var NATIVE_SYMBOL$1 = nativeSymbol;
  278.  
  279. var useSymbolAsUid = NATIVE_SYMBOL$1
  280. && !Symbol.sham
  281. && typeof Symbol.iterator == 'symbol';
  282.  
  283. var isCallable$9 = isCallable$c;
  284. var getBuiltIn$2 = getBuiltIn$4;
  285. var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
  286.  
  287. var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
  288. return typeof it == 'symbol';
  289. } : function (it) {
  290. var $Symbol = getBuiltIn$2('Symbol');
  291. return isCallable$9($Symbol) && Object(it) instanceof $Symbol;
  292. };
  293.  
  294. var tryToString$1 = function (argument) {
  295. try {
  296. return String(argument);
  297. } catch (error) {
  298. return 'Object';
  299. }
  300. };
  301.  
  302. var isCallable$8 = isCallable$c;
  303. var tryToString = tryToString$1;
  304.  
  305. // `Assert: IsCallable(argument) is true`
  306. var aCallable$1 = function (argument) {
  307. if (isCallable$8(argument)) return argument;
  308. throw TypeError(tryToString(argument) + ' is not a function');
  309. };
  310.  
  311. var aCallable = aCallable$1;
  312.  
  313. // `GetMethod` abstract operation
  314. // https://tc39.es/ecma262/#sec-getmethod
  315. var getMethod$2 = function (V, P) {
  316. var func = V[P];
  317. return func == null ? undefined : aCallable(func);
  318. };
  319.  
  320. var isCallable$7 = isCallable$c;
  321. var isObject$4 = isObject$5;
  322.  
  323. // `OrdinaryToPrimitive` abstract operation
  324. // https://tc39.es/ecma262/#sec-ordinarytoprimitive
  325. var ordinaryToPrimitive$1 = function (input, pref) {
  326. var fn, val;
  327. if (pref === 'string' && isCallable$7(fn = input.toString) && !isObject$4(val = fn.call(input))) return val;
  328. if (isCallable$7(fn = input.valueOf) && !isObject$4(val = fn.call(input))) return val;
  329. if (pref !== 'string' && isCallable$7(fn = input.toString) && !isObject$4(val = fn.call(input))) return val;
  330. throw TypeError("Can't convert object to primitive value");
  331. };
  332.  
  333. var shared$4 = {exports: {}};
  334.  
  335. var global$b = global$e;
  336.  
  337. var setGlobal$3 = function (key, value) {
  338. try {
  339. // eslint-disable-next-line es/no-object-defineproperty -- safe
  340. Object.defineProperty(global$b, key, { value: value, configurable: true, writable: true });
  341. } catch (error) {
  342. global$b[key] = value;
  343. } return value;
  344. };
  345.  
  346. var global$a = global$e;
  347. var setGlobal$2 = setGlobal$3;
  348.  
  349. var SHARED = '__core-js_shared__';
  350. var store$3 = global$a[SHARED] || setGlobal$2(SHARED, {});
  351.  
  352. var sharedStore = store$3;
  353.  
  354. var store$2 = sharedStore;
  355.  
  356. (shared$4.exports = function (key, value) {
  357. return store$2[key] || (store$2[key] = value !== undefined ? value : {});
  358. })('versions', []).push({
  359. version: '3.18.3',
  360. mode: 'global',
  361. copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
  362. });
  363.  
  364. var requireObjectCoercible$2 = requireObjectCoercible$4;
  365.  
  366. // `ToObject` abstract operation
  367. // https://tc39.es/ecma262/#sec-toobject
  368. var toObject$2 = function (argument) {
  369. return Object(requireObjectCoercible$2(argument));
  370. };
  371.  
  372. var toObject$1 = toObject$2;
  373.  
  374. var hasOwnProperty = {}.hasOwnProperty;
  375.  
  376. // `HasOwnProperty` abstract operation
  377. // https://tc39.es/ecma262/#sec-hasownproperty
  378. var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
  379. return hasOwnProperty.call(toObject$1(it), key);
  380. };
  381.  
  382. var id = 0;
  383. var postfix = Math.random();
  384.  
  385. var uid$2 = function (key) {
  386. return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
  387. };
  388.  
  389. var global$9 = global$e;
  390. var shared$3 = shared$4.exports;
  391. var hasOwn$6 = hasOwnProperty_1;
  392. var uid$1 = uid$2;
  393. var NATIVE_SYMBOL = nativeSymbol;
  394. var USE_SYMBOL_AS_UID = useSymbolAsUid;
  395.  
  396. var WellKnownSymbolsStore = shared$3('wks');
  397. var Symbol$1 = global$9.Symbol;
  398. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
  399.  
  400. var wellKnownSymbol$5 = function (name) {
  401. if (!hasOwn$6(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
  402. if (NATIVE_SYMBOL && hasOwn$6(Symbol$1, name)) {
  403. WellKnownSymbolsStore[name] = Symbol$1[name];
  404. } else {
  405. WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
  406. }
  407. } return WellKnownSymbolsStore[name];
  408. };
  409.  
  410. var isObject$3 = isObject$5;
  411. var isSymbol$1 = isSymbol$2;
  412. var getMethod$1 = getMethod$2;
  413. var ordinaryToPrimitive = ordinaryToPrimitive$1;
  414. var wellKnownSymbol$4 = wellKnownSymbol$5;
  415.  
  416. var TO_PRIMITIVE = wellKnownSymbol$4('toPrimitive');
  417.  
  418. // `ToPrimitive` abstract operation
  419. // https://tc39.es/ecma262/#sec-toprimitive
  420. var toPrimitive$1 = function (input, pref) {
  421. if (!isObject$3(input) || isSymbol$1(input)) return input;
  422. var exoticToPrim = getMethod$1(input, TO_PRIMITIVE);
  423. var result;
  424. if (exoticToPrim) {
  425. if (pref === undefined) pref = 'default';
  426. result = exoticToPrim.call(input, pref);
  427. if (!isObject$3(result) || isSymbol$1(result)) return result;
  428. throw TypeError("Can't convert object to primitive value");
  429. }
  430. if (pref === undefined) pref = 'number';
  431. return ordinaryToPrimitive(input, pref);
  432. };
  433.  
  434. var toPrimitive = toPrimitive$1;
  435. var isSymbol = isSymbol$2;
  436.  
  437. // `ToPropertyKey` abstract operation
  438. // https://tc39.es/ecma262/#sec-topropertykey
  439. var toPropertyKey$2 = function (argument) {
  440. var key = toPrimitive(argument, 'string');
  441. return isSymbol(key) ? key : String(key);
  442. };
  443.  
  444. var global$8 = global$e;
  445. var isObject$2 = isObject$5;
  446.  
  447. var document$1 = global$8.document;
  448. // typeof document.createElement is 'object' in old IE
  449. var EXISTS$1 = isObject$2(document$1) && isObject$2(document$1.createElement);
  450.  
  451. var documentCreateElement$1 = function (it) {
  452. return EXISTS$1 ? document$1.createElement(it) : {};
  453. };
  454.  
  455. var DESCRIPTORS$5 = descriptors;
  456. var fails$6 = fails$a;
  457. var createElement = documentCreateElement$1;
  458.  
  459. // Thank's IE8 for his funny defineProperty
  460. var ie8DomDefine = !DESCRIPTORS$5 && !fails$6(function () {
  461. // eslint-disable-next-line es/no-object-defineproperty -- requied for testing
  462. return Object.defineProperty(createElement('div'), 'a', {
  463. get: function () { return 7; }
  464. }).a != 7;
  465. });
  466.  
  467. var DESCRIPTORS$4 = descriptors;
  468. var propertyIsEnumerableModule = objectPropertyIsEnumerable;
  469. var createPropertyDescriptor$1 = createPropertyDescriptor$2;
  470. var toIndexedObject$2 = toIndexedObject$3;
  471. var toPropertyKey$1 = toPropertyKey$2;
  472. var hasOwn$5 = hasOwnProperty_1;
  473. var IE8_DOM_DEFINE$1 = ie8DomDefine;
  474.  
  475. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  476. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  477.  
  478. // `Object.getOwnPropertyDescriptor` method
  479. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  480. objectGetOwnPropertyDescriptor.f = DESCRIPTORS$4 ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  481. O = toIndexedObject$2(O);
  482. P = toPropertyKey$1(P);
  483. if (IE8_DOM_DEFINE$1) try {
  484. return $getOwnPropertyDescriptor(O, P);
  485. } catch (error) { /* empty */ }
  486. if (hasOwn$5(O, P)) return createPropertyDescriptor$1(!propertyIsEnumerableModule.f.call(O, P), O[P]);
  487. };
  488.  
  489. var objectDefineProperty = {};
  490.  
  491. var isObject$1 = isObject$5;
  492.  
  493. // `Assert: Type(argument) is Object`
  494. var anObject$7 = function (argument) {
  495. if (isObject$1(argument)) return argument;
  496. throw TypeError(String(argument) + ' is not an object');
  497. };
  498.  
  499. var DESCRIPTORS$3 = descriptors;
  500. var IE8_DOM_DEFINE = ie8DomDefine;
  501. var anObject$6 = anObject$7;
  502. var toPropertyKey = toPropertyKey$2;
  503.  
  504. // eslint-disable-next-line es/no-object-defineproperty -- safe
  505. var $defineProperty = Object.defineProperty;
  506.  
  507. // `Object.defineProperty` method
  508. // https://tc39.es/ecma262/#sec-object.defineproperty
  509. objectDefineProperty.f = DESCRIPTORS$3 ? $defineProperty : function defineProperty(O, P, Attributes) {
  510. anObject$6(O);
  511. P = toPropertyKey(P);
  512. anObject$6(Attributes);
  513. if (IE8_DOM_DEFINE) try {
  514. return $defineProperty(O, P, Attributes);
  515. } catch (error) { /* empty */ }
  516. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  517. if ('value' in Attributes) O[P] = Attributes.value;
  518. return O;
  519. };
  520.  
  521. var DESCRIPTORS$2 = descriptors;
  522. var definePropertyModule$2 = objectDefineProperty;
  523. var createPropertyDescriptor = createPropertyDescriptor$2;
  524.  
  525. var createNonEnumerableProperty$4 = DESCRIPTORS$2 ? function (object, key, value) {
  526. return definePropertyModule$2.f(object, key, createPropertyDescriptor(1, value));
  527. } : function (object, key, value) {
  528. object[key] = value;
  529. return object;
  530. };
  531.  
  532. var redefine$2 = {exports: {}};
  533.  
  534. var isCallable$6 = isCallable$c;
  535. var store$1 = sharedStore;
  536.  
  537. var functionToString = Function.toString;
  538.  
  539. // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
  540. if (!isCallable$6(store$1.inspectSource)) {
  541. store$1.inspectSource = function (it) {
  542. return functionToString.call(it);
  543. };
  544. }
  545.  
  546. var inspectSource$2 = store$1.inspectSource;
  547.  
  548. var global$7 = global$e;
  549. var isCallable$5 = isCallable$c;
  550. var inspectSource$1 = inspectSource$2;
  551.  
  552. var WeakMap$1 = global$7.WeakMap;
  553.  
  554. var nativeWeakMap = isCallable$5(WeakMap$1) && /native code/.test(inspectSource$1(WeakMap$1));
  555.  
  556. var shared$2 = shared$4.exports;
  557. var uid = uid$2;
  558.  
  559. var keys = shared$2('keys');
  560.  
  561. var sharedKey$2 = function (key) {
  562. return keys[key] || (keys[key] = uid(key));
  563. };
  564.  
  565. var hiddenKeys$4 = {};
  566.  
  567. var NATIVE_WEAK_MAP = nativeWeakMap;
  568. var global$6 = global$e;
  569. var isObject = isObject$5;
  570. var createNonEnumerableProperty$3 = createNonEnumerableProperty$4;
  571. var hasOwn$4 = hasOwnProperty_1;
  572. var shared$1 = sharedStore;
  573. var sharedKey$1 = sharedKey$2;
  574. var hiddenKeys$3 = hiddenKeys$4;
  575.  
  576. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  577. var WeakMap = global$6.WeakMap;
  578. var set, get, has;
  579.  
  580. var enforce = function (it) {
  581. return has(it) ? get(it) : set(it, {});
  582. };
  583.  
  584. var getterFor = function (TYPE) {
  585. return function (it) {
  586. var state;
  587. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  588. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  589. } return state;
  590. };
  591. };
  592.  
  593. if (NATIVE_WEAK_MAP || shared$1.state) {
  594. var store = shared$1.state || (shared$1.state = new WeakMap());
  595. var wmget = store.get;
  596. var wmhas = store.has;
  597. var wmset = store.set;
  598. set = function (it, metadata) {
  599. if (wmhas.call(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
  600. metadata.facade = it;
  601. wmset.call(store, it, metadata);
  602. return metadata;
  603. };
  604. get = function (it) {
  605. return wmget.call(store, it) || {};
  606. };
  607. has = function (it) {
  608. return wmhas.call(store, it);
  609. };
  610. } else {
  611. var STATE = sharedKey$1('state');
  612. hiddenKeys$3[STATE] = true;
  613. set = function (it, metadata) {
  614. if (hasOwn$4(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
  615. metadata.facade = it;
  616. createNonEnumerableProperty$3(it, STATE, metadata);
  617. return metadata;
  618. };
  619. get = function (it) {
  620. return hasOwn$4(it, STATE) ? it[STATE] : {};
  621. };
  622. has = function (it) {
  623. return hasOwn$4(it, STATE);
  624. };
  625. }
  626.  
  627. var internalState = {
  628. set: set,
  629. get: get,
  630. has: has,
  631. enforce: enforce,
  632. getterFor: getterFor
  633. };
  634.  
  635. var DESCRIPTORS$1 = descriptors;
  636. var hasOwn$3 = hasOwnProperty_1;
  637.  
  638. var FunctionPrototype = Function.prototype;
  639. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  640. var getDescriptor = DESCRIPTORS$1 && Object.getOwnPropertyDescriptor;
  641.  
  642. var EXISTS = hasOwn$3(FunctionPrototype, 'name');
  643. // additional protection from minified / mangled / dropped function names
  644. var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
  645. var CONFIGURABLE = EXISTS && (!DESCRIPTORS$1 || (DESCRIPTORS$1 && getDescriptor(FunctionPrototype, 'name').configurable));
  646.  
  647. var functionName = {
  648. EXISTS: EXISTS,
  649. PROPER: PROPER,
  650. CONFIGURABLE: CONFIGURABLE
  651. };
  652.  
  653. var global$5 = global$e;
  654. var isCallable$4 = isCallable$c;
  655. var hasOwn$2 = hasOwnProperty_1;
  656. var createNonEnumerableProperty$2 = createNonEnumerableProperty$4;
  657. var setGlobal$1 = setGlobal$3;
  658. var inspectSource = inspectSource$2;
  659. var InternalStateModule = internalState;
  660. var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
  661.  
  662. var getInternalState$1 = InternalStateModule.get;
  663. var enforceInternalState = InternalStateModule.enforce;
  664. var TEMPLATE = String(String).split('String');
  665.  
  666. (redefine$2.exports = function (O, key, value, options) {
  667. var unsafe = options ? !!options.unsafe : false;
  668. var simple = options ? !!options.enumerable : false;
  669. var noTargetGet = options ? !!options.noTargetGet : false;
  670. var name = options && options.name !== undefined ? options.name : key;
  671. var state;
  672. if (isCallable$4(value)) {
  673. if (String(name).slice(0, 7) === 'Symbol(') {
  674. name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
  675. }
  676. if (!hasOwn$2(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
  677. createNonEnumerableProperty$2(value, 'name', name);
  678. }
  679. state = enforceInternalState(value);
  680. if (!state.source) {
  681. state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
  682. }
  683. }
  684. if (O === global$5) {
  685. if (simple) O[key] = value;
  686. else setGlobal$1(key, value);
  687. return;
  688. } else if (!unsafe) {
  689. delete O[key];
  690. } else if (!noTargetGet && O[key]) {
  691. simple = true;
  692. }
  693. if (simple) O[key] = value;
  694. else createNonEnumerableProperty$2(O, key, value);
  695. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  696. })(Function.prototype, 'toString', function toString() {
  697. return isCallable$4(this) && getInternalState$1(this).source || inspectSource(this);
  698. });
  699.  
  700. var objectGetOwnPropertyNames = {};
  701.  
  702. var ceil = Math.ceil;
  703. var floor$1 = Math.floor;
  704.  
  705. // `ToIntegerOrInfinity` abstract operation
  706. // https://tc39.es/ecma262/#sec-tointegerorinfinity
  707. var toIntegerOrInfinity$4 = function (argument) {
  708. var number = +argument;
  709. // eslint-disable-next-line no-self-compare -- safe
  710. return number !== number || number === 0 ? 0 : (number > 0 ? floor$1 : ceil)(number);
  711. };
  712.  
  713. var toIntegerOrInfinity$3 = toIntegerOrInfinity$4;
  714.  
  715. var max$1 = Math.max;
  716. var min$2 = Math.min;
  717.  
  718. // Helper for a popular repeating case of the spec:
  719. // Let integer be ? ToInteger(index).
  720. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  721. var toAbsoluteIndex$1 = function (index, length) {
  722. var integer = toIntegerOrInfinity$3(index);
  723. return integer < 0 ? max$1(integer + length, 0) : min$2(integer, length);
  724. };
  725.  
  726. var toIntegerOrInfinity$2 = toIntegerOrInfinity$4;
  727.  
  728. var min$1 = Math.min;
  729.  
  730. // `ToLength` abstract operation
  731. // https://tc39.es/ecma262/#sec-tolength
  732. var toLength$2 = function (argument) {
  733. return argument > 0 ? min$1(toIntegerOrInfinity$2(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  734. };
  735.  
  736. var toLength$1 = toLength$2;
  737.  
  738. // `LengthOfArrayLike` abstract operation
  739. // https://tc39.es/ecma262/#sec-lengthofarraylike
  740. var lengthOfArrayLike$1 = function (obj) {
  741. return toLength$1(obj.length);
  742. };
  743.  
  744. var toIndexedObject$1 = toIndexedObject$3;
  745. var toAbsoluteIndex = toAbsoluteIndex$1;
  746. var lengthOfArrayLike = lengthOfArrayLike$1;
  747.  
  748. // `Array.prototype.{ indexOf, includes }` methods implementation
  749. var createMethod$1 = function (IS_INCLUDES) {
  750. return function ($this, el, fromIndex) {
  751. var O = toIndexedObject$1($this);
  752. var length = lengthOfArrayLike(O);
  753. var index = toAbsoluteIndex(fromIndex, length);
  754. var value;
  755. // Array#includes uses SameValueZero equality algorithm
  756. // eslint-disable-next-line no-self-compare -- NaN check
  757. if (IS_INCLUDES && el != el) while (length > index) {
  758. value = O[index++];
  759. // eslint-disable-next-line no-self-compare -- NaN check
  760. if (value != value) return true;
  761. // Array#indexOf ignores holes, Array#includes - not
  762. } else for (;length > index; index++) {
  763. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  764. } return !IS_INCLUDES && -1;
  765. };
  766. };
  767.  
  768. var arrayIncludes = {
  769. // `Array.prototype.includes` method
  770. // https://tc39.es/ecma262/#sec-array.prototype.includes
  771. includes: createMethod$1(true),
  772. // `Array.prototype.indexOf` method
  773. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  774. indexOf: createMethod$1(false)
  775. };
  776.  
  777. var hasOwn$1 = hasOwnProperty_1;
  778. var toIndexedObject = toIndexedObject$3;
  779. var indexOf = arrayIncludes.indexOf;
  780. var hiddenKeys$2 = hiddenKeys$4;
  781.  
  782. var objectKeysInternal = function (object, names) {
  783. var O = toIndexedObject(object);
  784. var i = 0;
  785. var result = [];
  786. var key;
  787. for (key in O) !hasOwn$1(hiddenKeys$2, key) && hasOwn$1(O, key) && result.push(key);
  788. // Don't enum bug & hidden keys
  789. while (names.length > i) if (hasOwn$1(O, key = names[i++])) {
  790. ~indexOf(result, key) || result.push(key);
  791. }
  792. return result;
  793. };
  794.  
  795. // IE8- don't enum bug keys
  796. var enumBugKeys$3 = [
  797. 'constructor',
  798. 'hasOwnProperty',
  799. 'isPrototypeOf',
  800. 'propertyIsEnumerable',
  801. 'toLocaleString',
  802. 'toString',
  803. 'valueOf'
  804. ];
  805.  
  806. var internalObjectKeys$1 = objectKeysInternal;
  807. var enumBugKeys$2 = enumBugKeys$3;
  808.  
  809. var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype');
  810.  
  811. // `Object.getOwnPropertyNames` method
  812. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  813. // eslint-disable-next-line es/no-object-getownpropertynames -- safe
  814. objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  815. return internalObjectKeys$1(O, hiddenKeys$1);
  816. };
  817.  
  818. var objectGetOwnPropertySymbols = {};
  819.  
  820. // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
  821. objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
  822.  
  823. var getBuiltIn$1 = getBuiltIn$4;
  824. var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
  825. var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
  826. var anObject$5 = anObject$7;
  827.  
  828. // all object keys, includes non-enumerable and symbols
  829. var ownKeys$1 = getBuiltIn$1('Reflect', 'ownKeys') || function ownKeys(it) {
  830. var keys = getOwnPropertyNamesModule.f(anObject$5(it));
  831. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  832. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  833. };
  834.  
  835. var hasOwn = hasOwnProperty_1;
  836. var ownKeys = ownKeys$1;
  837. var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
  838. var definePropertyModule$1 = objectDefineProperty;
  839.  
  840. var copyConstructorProperties$1 = function (target, source) {
  841. var keys = ownKeys(source);
  842. var defineProperty = definePropertyModule$1.f;
  843. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  844. for (var i = 0; i < keys.length; i++) {
  845. var key = keys[i];
  846. if (!hasOwn(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  847. }
  848. };
  849.  
  850. var fails$5 = fails$a;
  851. var isCallable$3 = isCallable$c;
  852.  
  853. var replacement = /#|\.prototype\./;
  854.  
  855. var isForced$1 = function (feature, detection) {
  856. var value = data[normalize(feature)];
  857. return value == POLYFILL ? true
  858. : value == NATIVE ? false
  859. : isCallable$3(detection) ? fails$5(detection)
  860. : !!detection;
  861. };
  862.  
  863. var normalize = isForced$1.normalize = function (string) {
  864. return String(string).replace(replacement, '.').toLowerCase();
  865. };
  866.  
  867. var data = isForced$1.data = {};
  868. var NATIVE = isForced$1.NATIVE = 'N';
  869. var POLYFILL = isForced$1.POLYFILL = 'P';
  870.  
  871. var isForced_1 = isForced$1;
  872.  
  873. var global$4 = global$e;
  874. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  875. var createNonEnumerableProperty$1 = createNonEnumerableProperty$4;
  876. var redefine$1 = redefine$2.exports;
  877. var setGlobal = setGlobal$3;
  878. var copyConstructorProperties = copyConstructorProperties$1;
  879. var isForced = isForced_1;
  880.  
  881. /*
  882. options.target - name of the target object
  883. options.global - target is the global object
  884. options.stat - export as static methods of target
  885. options.proto - export as prototype methods of target
  886. options.real - real prototype method for the `pure` version
  887. options.forced - export even if the native feature is available
  888. options.bind - bind methods to the target, required for the `pure` version
  889. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  890. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  891. options.sham - add a flag to not completely full polyfills
  892. options.enumerable - export as enumerable property
  893. options.noTargetGet - prevent calling a getter on target
  894. options.name - the .name of the function if it does not match the key
  895. */
  896. var _export = function (options, source) {
  897. var TARGET = options.target;
  898. var GLOBAL = options.global;
  899. var STATIC = options.stat;
  900. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  901. if (GLOBAL) {
  902. target = global$4;
  903. } else if (STATIC) {
  904. target = global$4[TARGET] || setGlobal(TARGET, {});
  905. } else {
  906. target = (global$4[TARGET] || {}).prototype;
  907. }
  908. if (target) for (key in source) {
  909. sourceProperty = source[key];
  910. if (options.noTargetGet) {
  911. descriptor = getOwnPropertyDescriptor(target, key);
  912. targetProperty = descriptor && descriptor.value;
  913. } else targetProperty = target[key];
  914. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  915. // contained in target
  916. if (!FORCED && targetProperty !== undefined) {
  917. if (typeof sourceProperty === typeof targetProperty) continue;
  918. copyConstructorProperties(sourceProperty, targetProperty);
  919. }
  920. // add a flag to not completely full polyfills
  921. if (options.sham || (targetProperty && targetProperty.sham)) {
  922. createNonEnumerableProperty$1(sourceProperty, 'sham', true);
  923. }
  924. // extend global
  925. redefine$1(target, key, sourceProperty, options);
  926. }
  927. };
  928.  
  929. var wellKnownSymbol$3 = wellKnownSymbol$5;
  930.  
  931. var TO_STRING_TAG$1 = wellKnownSymbol$3('toStringTag');
  932. var test = {};
  933.  
  934. test[TO_STRING_TAG$1] = 'z';
  935.  
  936. var toStringTagSupport = String(test) === '[object z]';
  937.  
  938. var TO_STRING_TAG_SUPPORT = toStringTagSupport;
  939. var isCallable$2 = isCallable$c;
  940. var classofRaw = classofRaw$1;
  941. var wellKnownSymbol$2 = wellKnownSymbol$5;
  942.  
  943. var TO_STRING_TAG = wellKnownSymbol$2('toStringTag');
  944. // ES3 wrong here
  945. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  946.  
  947. // fallback for IE11 Script Access Denied error
  948. var tryGet = function (it, key) {
  949. try {
  950. return it[key];
  951. } catch (error) { /* empty */ }
  952. };
  953.  
  954. // getting tag from ES6+ `Object.prototype.toString`
  955. var classof$2 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  956. var O, tag, result;
  957. return it === undefined ? 'Undefined' : it === null ? 'Null'
  958. // @@toStringTag case
  959. : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
  960. // builtinTag case
  961. : CORRECT_ARGUMENTS ? classofRaw(O)
  962. // ES3 arguments fallback
  963. : (result = classofRaw(O)) == 'Object' && isCallable$2(O.callee) ? 'Arguments' : result;
  964. };
  965.  
  966. var classof$1 = classof$2;
  967.  
  968. var toString$3 = function (argument) {
  969. if (classof$1(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
  970. return String(argument);
  971. };
  972.  
  973. var anObject$4 = anObject$7;
  974.  
  975. // `RegExp.prototype.flags` getter implementation
  976. // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
  977. var regexpFlags$1 = function () {
  978. var that = anObject$4(this);
  979. var result = '';
  980. if (that.global) result += 'g';
  981. if (that.ignoreCase) result += 'i';
  982. if (that.multiline) result += 'm';
  983. if (that.dotAll) result += 's';
  984. if (that.unicode) result += 'u';
  985. if (that.sticky) result += 'y';
  986. return result;
  987. };
  988.  
  989. var regexpStickyHelpers = {};
  990.  
  991. var fails$4 = fails$a;
  992. var global$3 = global$e;
  993.  
  994. // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
  995. var $RegExp$2 = global$3.RegExp;
  996.  
  997. regexpStickyHelpers.UNSUPPORTED_Y = fails$4(function () {
  998. var re = $RegExp$2('a', 'y');
  999. re.lastIndex = 2;
  1000. return re.exec('abcd') != null;
  1001. });
  1002.  
  1003. regexpStickyHelpers.BROKEN_CARET = fails$4(function () {
  1004. // https://bugzilla.mozilla.org/show_bug.cgi?id=773687
  1005. var re = $RegExp$2('^r', 'gy');
  1006. re.lastIndex = 2;
  1007. return re.exec('str') != null;
  1008. });
  1009.  
  1010. var internalObjectKeys = objectKeysInternal;
  1011. var enumBugKeys$1 = enumBugKeys$3;
  1012.  
  1013. // `Object.keys` method
  1014. // https://tc39.es/ecma262/#sec-object.keys
  1015. // eslint-disable-next-line es/no-object-keys -- safe
  1016. var objectKeys$1 = Object.keys || function keys(O) {
  1017. return internalObjectKeys(O, enumBugKeys$1);
  1018. };
  1019.  
  1020. var DESCRIPTORS = descriptors;
  1021. var definePropertyModule = objectDefineProperty;
  1022. var anObject$3 = anObject$7;
  1023. var objectKeys = objectKeys$1;
  1024.  
  1025. // `Object.defineProperties` method
  1026. // https://tc39.es/ecma262/#sec-object.defineproperties
  1027. // eslint-disable-next-line es/no-object-defineproperties -- safe
  1028. var objectDefineProperties = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
  1029. anObject$3(O);
  1030. var keys = objectKeys(Properties);
  1031. var length = keys.length;
  1032. var index = 0;
  1033. var key;
  1034. while (length > index) definePropertyModule.f(O, key = keys[index++], Properties[key]);
  1035. return O;
  1036. };
  1037.  
  1038. var getBuiltIn = getBuiltIn$4;
  1039.  
  1040. var html$1 = getBuiltIn('document', 'documentElement');
  1041.  
  1042. /* global ActiveXObject -- old IE, WSH */
  1043.  
  1044. var anObject$2 = anObject$7;
  1045. var defineProperties = objectDefineProperties;
  1046. var enumBugKeys = enumBugKeys$3;
  1047. var hiddenKeys = hiddenKeys$4;
  1048. var html = html$1;
  1049. var documentCreateElement = documentCreateElement$1;
  1050. var sharedKey = sharedKey$2;
  1051.  
  1052. var GT = '>';
  1053. var LT = '<';
  1054. var PROTOTYPE = 'prototype';
  1055. var SCRIPT = 'script';
  1056. var IE_PROTO = sharedKey('IE_PROTO');
  1057.  
  1058. var EmptyConstructor = function () { /* empty */ };
  1059.  
  1060. var scriptTag = function (content) {
  1061. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  1062. };
  1063.  
  1064. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  1065. var NullProtoObjectViaActiveX = function (activeXDocument) {
  1066. activeXDocument.write(scriptTag(''));
  1067. activeXDocument.close();
  1068. var temp = activeXDocument.parentWindow.Object;
  1069. activeXDocument = null; // avoid memory leak
  1070. return temp;
  1071. };
  1072.  
  1073. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  1074. var NullProtoObjectViaIFrame = function () {
  1075. // Thrash, waste and sodomy: IE GC bug
  1076. var iframe = documentCreateElement('iframe');
  1077. var JS = 'java' + SCRIPT + ':';
  1078. var iframeDocument;
  1079. iframe.style.display = 'none';
  1080. html.appendChild(iframe);
  1081. // https://github.com/zloirock/core-js/issues/475
  1082. iframe.src = String(JS);
  1083. iframeDocument = iframe.contentWindow.document;
  1084. iframeDocument.open();
  1085. iframeDocument.write(scriptTag('document.F=Object'));
  1086. iframeDocument.close();
  1087. return iframeDocument.F;
  1088. };
  1089.  
  1090. // Check for document.domain and active x support
  1091. // No need to use active x approach when document.domain is not set
  1092. // see https://github.com/es-shims/es5-shim/issues/150
  1093. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  1094. // avoid IE GC bug
  1095. var activeXDocument;
  1096. var NullProtoObject = function () {
  1097. try {
  1098. activeXDocument = new ActiveXObject('htmlfile');
  1099. } catch (error) { /* ignore */ }
  1100. NullProtoObject = typeof document != 'undefined'
  1101. ? document.domain && activeXDocument
  1102. ? NullProtoObjectViaActiveX(activeXDocument) // old IE
  1103. : NullProtoObjectViaIFrame()
  1104. : NullProtoObjectViaActiveX(activeXDocument); // WSH
  1105. var length = enumBugKeys.length;
  1106. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  1107. return NullProtoObject();
  1108. };
  1109.  
  1110. hiddenKeys[IE_PROTO] = true;
  1111.  
  1112. // `Object.create` method
  1113. // https://tc39.es/ecma262/#sec-object.create
  1114. var objectCreate = Object.create || function create(O, Properties) {
  1115. var result;
  1116. if (O !== null) {
  1117. EmptyConstructor[PROTOTYPE] = anObject$2(O);
  1118. result = new EmptyConstructor();
  1119. EmptyConstructor[PROTOTYPE] = null;
  1120. // add "__proto__" for Object.getPrototypeOf polyfill
  1121. result[IE_PROTO] = O;
  1122. } else result = NullProtoObject();
  1123. return Properties === undefined ? result : defineProperties(result, Properties);
  1124. };
  1125.  
  1126. var fails$3 = fails$a;
  1127. var global$2 = global$e;
  1128.  
  1129. // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
  1130. var $RegExp$1 = global$2.RegExp;
  1131.  
  1132. var regexpUnsupportedDotAll = fails$3(function () {
  1133. var re = $RegExp$1('.', 's');
  1134. return !(re.dotAll && re.exec('\n') && re.flags === 's');
  1135. });
  1136.  
  1137. var fails$2 = fails$a;
  1138. var global$1 = global$e;
  1139.  
  1140. // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError
  1141. var $RegExp = global$1.RegExp;
  1142.  
  1143. var regexpUnsupportedNcg = fails$2(function () {
  1144. var re = $RegExp('(?<a>b)', 'g');
  1145. return re.exec('b').groups.a !== 'b' ||
  1146. 'b'.replace(re, '$<a>c') !== 'bc';
  1147. });
  1148.  
  1149. /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
  1150. /* eslint-disable regexp/no-useless-quantifier -- testing */
  1151. var toString$2 = toString$3;
  1152. var regexpFlags = regexpFlags$1;
  1153. var stickyHelpers = regexpStickyHelpers;
  1154. var shared = shared$4.exports;
  1155. var create = objectCreate;
  1156. var getInternalState = internalState.get;
  1157. var UNSUPPORTED_DOT_ALL = regexpUnsupportedDotAll;
  1158. var UNSUPPORTED_NCG = regexpUnsupportedNcg;
  1159.  
  1160. var nativeExec = RegExp.prototype.exec;
  1161. var nativeReplace = shared('native-string-replace', String.prototype.replace);
  1162.  
  1163. var patchedExec = nativeExec;
  1164.  
  1165. var UPDATES_LAST_INDEX_WRONG = (function () {
  1166. var re1 = /a/;
  1167. var re2 = /b*/g;
  1168. nativeExec.call(re1, 'a');
  1169. nativeExec.call(re2, 'a');
  1170. return re1.lastIndex !== 0 || re2.lastIndex !== 0;
  1171. })();
  1172.  
  1173. var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y || stickyHelpers.BROKEN_CARET;
  1174.  
  1175. // nonparticipating capturing group, copied from es5-shim's String#split patch.
  1176. var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
  1177.  
  1178. var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG;
  1179.  
  1180. if (PATCH) {
  1181. // eslint-disable-next-line max-statements -- TODO
  1182. patchedExec = function exec(string) {
  1183. var re = this;
  1184. var state = getInternalState(re);
  1185. var str = toString$2(string);
  1186. var raw = state.raw;
  1187. var result, reCopy, lastIndex, match, i, object, group;
  1188.  
  1189. if (raw) {
  1190. raw.lastIndex = re.lastIndex;
  1191. result = patchedExec.call(raw, str);
  1192. re.lastIndex = raw.lastIndex;
  1193. return result;
  1194. }
  1195.  
  1196. var groups = state.groups;
  1197. var sticky = UNSUPPORTED_Y && re.sticky;
  1198. var flags = regexpFlags.call(re);
  1199. var source = re.source;
  1200. var charsAdded = 0;
  1201. var strCopy = str;
  1202.  
  1203. if (sticky) {
  1204. flags = flags.replace('y', '');
  1205. if (flags.indexOf('g') === -1) {
  1206. flags += 'g';
  1207. }
  1208.  
  1209. strCopy = str.slice(re.lastIndex);
  1210. // Support anchored sticky behavior.
  1211. if (re.lastIndex > 0 && (!re.multiline || re.multiline && str.charAt(re.lastIndex - 1) !== '\n')) {
  1212. source = '(?: ' + source + ')';
  1213. strCopy = ' ' + strCopy;
  1214. charsAdded++;
  1215. }
  1216. // ^(? + rx + ) is needed, in combination with some str slicing, to
  1217. // simulate the 'y' flag.
  1218. reCopy = new RegExp('^(?:' + source + ')', flags);
  1219. }
  1220.  
  1221. if (NPCG_INCLUDED) {
  1222. reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
  1223. }
  1224. if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
  1225.  
  1226. match = nativeExec.call(sticky ? reCopy : re, strCopy);
  1227.  
  1228. if (sticky) {
  1229. if (match) {
  1230. match.input = match.input.slice(charsAdded);
  1231. match[0] = match[0].slice(charsAdded);
  1232. match.index = re.lastIndex;
  1233. re.lastIndex += match[0].length;
  1234. } else re.lastIndex = 0;
  1235. } else if (UPDATES_LAST_INDEX_WRONG && match) {
  1236. re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
  1237. }
  1238. if (NPCG_INCLUDED && match && match.length > 1) {
  1239. // Fix browsers whose `exec` methods don't consistently return `undefined`
  1240. // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
  1241. nativeReplace.call(match[0], reCopy, function () {
  1242. for (i = 1; i < arguments.length - 2; i++) {
  1243. if (arguments[i] === undefined) match[i] = undefined;
  1244. }
  1245. });
  1246. }
  1247.  
  1248. if (match && groups) {
  1249. match.groups = object = create(null);
  1250. for (i = 0; i < groups.length; i++) {
  1251. group = groups[i];
  1252. object[group[0]] = match[group[1]];
  1253. }
  1254. }
  1255.  
  1256. return match;
  1257. };
  1258. }
  1259.  
  1260. var regexpExec$2 = patchedExec;
  1261.  
  1262. var $$1 = _export;
  1263. var exec = regexpExec$2;
  1264.  
  1265. // `RegExp.prototype.exec` method
  1266. // https://tc39.es/ecma262/#sec-regexp.prototype.exec
  1267. $$1({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, {
  1268. exec: exec
  1269. });
  1270.  
  1271. // TODO: Remove from `core-js@4` since it's moved to entry points
  1272.  
  1273. var redefine = redefine$2.exports;
  1274. var regexpExec$1 = regexpExec$2;
  1275. var fails$1 = fails$a;
  1276. var wellKnownSymbol$1 = wellKnownSymbol$5;
  1277. var createNonEnumerableProperty = createNonEnumerableProperty$4;
  1278.  
  1279. var SPECIES = wellKnownSymbol$1('species');
  1280. var RegExpPrototype = RegExp.prototype;
  1281.  
  1282. var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) {
  1283. var SYMBOL = wellKnownSymbol$1(KEY);
  1284.  
  1285. var DELEGATES_TO_SYMBOL = !fails$1(function () {
  1286. // String methods call symbol-named RegEp methods
  1287. var O = {};
  1288. O[SYMBOL] = function () { return 7; };
  1289. return ''[KEY](O) != 7;
  1290. });
  1291.  
  1292. var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails$1(function () {
  1293. // Symbol-named RegExp methods call .exec
  1294. var execCalled = false;
  1295. var re = /a/;
  1296.  
  1297. if (KEY === 'split') {
  1298. // We can't use real regex here since it causes deoptimization
  1299. // and serious performance degradation in V8
  1300. // https://github.com/zloirock/core-js/issues/306
  1301. re = {};
  1302. // RegExp[@@split] doesn't call the regex's exec method, but first creates
  1303. // a new one. We need to return the patched regex when creating the new one.
  1304. re.constructor = {};
  1305. re.constructor[SPECIES] = function () { return re; };
  1306. re.flags = '';
  1307. re[SYMBOL] = /./[SYMBOL];
  1308. }
  1309.  
  1310. re.exec = function () { execCalled = true; return null; };
  1311.  
  1312. re[SYMBOL]('');
  1313. return !execCalled;
  1314. });
  1315.  
  1316. if (
  1317. !DELEGATES_TO_SYMBOL ||
  1318. !DELEGATES_TO_EXEC ||
  1319. FORCED
  1320. ) {
  1321. var nativeRegExpMethod = /./[SYMBOL];
  1322. var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
  1323. var $exec = regexp.exec;
  1324. if ($exec === regexpExec$1 || $exec === RegExpPrototype.exec) {
  1325. if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
  1326. // The native String method already delegates to @@method (this
  1327. // polyfilled function), leasing to infinite recursion.
  1328. // We avoid it by directly calling the native @@method method.
  1329. return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
  1330. }
  1331. return { done: true, value: nativeMethod.call(str, regexp, arg2) };
  1332. }
  1333. return { done: false };
  1334. });
  1335.  
  1336. redefine(String.prototype, KEY, methods[0]);
  1337. redefine(RegExpPrototype, SYMBOL, methods[1]);
  1338. }
  1339.  
  1340. if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
  1341. };
  1342.  
  1343. var toIntegerOrInfinity$1 = toIntegerOrInfinity$4;
  1344. var toString$1 = toString$3;
  1345. var requireObjectCoercible$1 = requireObjectCoercible$4;
  1346.  
  1347. var createMethod = function (CONVERT_TO_STRING) {
  1348. return function ($this, pos) {
  1349. var S = toString$1(requireObjectCoercible$1($this));
  1350. var position = toIntegerOrInfinity$1(pos);
  1351. var size = S.length;
  1352. var first, second;
  1353. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  1354. first = S.charCodeAt(position);
  1355. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  1356. || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF
  1357. ? CONVERT_TO_STRING ? S.charAt(position) : first
  1358. : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  1359. };
  1360. };
  1361.  
  1362. var stringMultibyte = {
  1363. // `String.prototype.codePointAt` method
  1364. // https://tc39.es/ecma262/#sec-string.prototype.codepointat
  1365. codeAt: createMethod(false),
  1366. // `String.prototype.at` method
  1367. // https://github.com/mathiasbynens/String.prototype.at
  1368. charAt: createMethod(true)
  1369. };
  1370.  
  1371. var charAt = stringMultibyte.charAt;
  1372.  
  1373. // `AdvanceStringIndex` abstract operation
  1374. // https://tc39.es/ecma262/#sec-advancestringindex
  1375. var advanceStringIndex$1 = function (S, index, unicode) {
  1376. return index + (unicode ? charAt(S, index).length : 1);
  1377. };
  1378.  
  1379. var toObject = toObject$2;
  1380.  
  1381. var floor = Math.floor;
  1382. var replace = ''.replace;
  1383. var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g;
  1384. var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g;
  1385.  
  1386. // `GetSubstitution` abstract operation
  1387. // https://tc39.es/ecma262/#sec-getsubstitution
  1388. var getSubstitution$1 = function (matched, str, position, captures, namedCaptures, replacement) {
  1389. var tailPos = position + matched.length;
  1390. var m = captures.length;
  1391. var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
  1392. if (namedCaptures !== undefined) {
  1393. namedCaptures = toObject(namedCaptures);
  1394. symbols = SUBSTITUTION_SYMBOLS;
  1395. }
  1396. return replace.call(replacement, symbols, function (match, ch) {
  1397. var capture;
  1398. switch (ch.charAt(0)) {
  1399. case '$': return '$';
  1400. case '&': return matched;
  1401. case '`': return str.slice(0, position);
  1402. case "'": return str.slice(tailPos);
  1403. case '<':
  1404. capture = namedCaptures[ch.slice(1, -1)];
  1405. break;
  1406. default: // \d\d?
  1407. var n = +ch;
  1408. if (n === 0) return match;
  1409. if (n > m) {
  1410. var f = floor(n / 10);
  1411. if (f === 0) return match;
  1412. if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
  1413. return match;
  1414. }
  1415. capture = captures[n - 1];
  1416. }
  1417. return capture === undefined ? '' : capture;
  1418. });
  1419. };
  1420.  
  1421. var anObject$1 = anObject$7;
  1422. var isCallable$1 = isCallable$c;
  1423. var classof = classofRaw$1;
  1424. var regexpExec = regexpExec$2;
  1425.  
  1426. // `RegExpExec` abstract operation
  1427. // https://tc39.es/ecma262/#sec-regexpexec
  1428. var regexpExecAbstract = function (R, S) {
  1429. var exec = R.exec;
  1430. if (isCallable$1(exec)) {
  1431. var result = exec.call(R, S);
  1432. if (result !== null) anObject$1(result);
  1433. return result;
  1434. }
  1435. if (classof(R) === 'RegExp') return regexpExec.call(R, S);
  1436. throw TypeError('RegExp#exec called on incompatible receiver');
  1437. };
  1438.  
  1439. var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
  1440. var fails = fails$a;
  1441. var anObject = anObject$7;
  1442. var isCallable = isCallable$c;
  1443. var toIntegerOrInfinity = toIntegerOrInfinity$4;
  1444. var toLength = toLength$2;
  1445. var toString = toString$3;
  1446. var requireObjectCoercible = requireObjectCoercible$4;
  1447. var advanceStringIndex = advanceStringIndex$1;
  1448. var getMethod = getMethod$2;
  1449. var getSubstitution = getSubstitution$1;
  1450. var regExpExec = regexpExecAbstract;
  1451. var wellKnownSymbol = wellKnownSymbol$5;
  1452.  
  1453. var REPLACE = wellKnownSymbol('replace');
  1454. var max = Math.max;
  1455. var min = Math.min;
  1456.  
  1457. var maybeToString = function (it) {
  1458. return it === undefined ? it : String(it);
  1459. };
  1460.  
  1461. // IE <= 11 replaces $0 with the whole match, as if it was $&
  1462. // https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0
  1463. var REPLACE_KEEPS_$0 = (function () {
  1464. // eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing
  1465. return 'a'.replace(/./, '$0') === '$0';
  1466. })();
  1467.  
  1468. // Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string
  1469. var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () {
  1470. if (/./[REPLACE]) {
  1471. return /./[REPLACE]('a', '$0') === '';
  1472. }
  1473. return false;
  1474. })();
  1475.  
  1476. var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
  1477. var re = /./;
  1478. re.exec = function () {
  1479. var result = [];
  1480. result.groups = { a: '7' };
  1481. return result;
  1482. };
  1483. // eslint-disable-next-line regexp/no-useless-dollar-replacements -- false positive
  1484. return ''.replace(re, '$<a>') !== '7';
  1485. });
  1486.  
  1487. // @@replace logic
  1488. fixRegExpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNative) {
  1489. var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0';
  1490.  
  1491. return [
  1492. // `String.prototype.replace` method
  1493. // https://tc39.es/ecma262/#sec-string.prototype.replace
  1494. function replace(searchValue, replaceValue) {
  1495. var O = requireObjectCoercible(this);
  1496. var replacer = searchValue == undefined ? undefined : getMethod(searchValue, REPLACE);
  1497. return replacer
  1498. ? replacer.call(searchValue, O, replaceValue)
  1499. : nativeReplace.call(toString(O), searchValue, replaceValue);
  1500. },
  1501. // `RegExp.prototype[@@replace]` method
  1502. // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace
  1503. function (string, replaceValue) {
  1504. var rx = anObject(this);
  1505. var S = toString(string);
  1506.  
  1507. if (
  1508. typeof replaceValue === 'string' &&
  1509. replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1 &&
  1510. replaceValue.indexOf('$<') === -1
  1511. ) {
  1512. var res = maybeCallNative(nativeReplace, rx, S, replaceValue);
  1513. if (res.done) return res.value;
  1514. }
  1515.  
  1516. var functionalReplace = isCallable(replaceValue);
  1517. if (!functionalReplace) replaceValue = toString(replaceValue);
  1518.  
  1519. var global = rx.global;
  1520. if (global) {
  1521. var fullUnicode = rx.unicode;
  1522. rx.lastIndex = 0;
  1523. }
  1524. var results = [];
  1525. while (true) {
  1526. var result = regExpExec(rx, S);
  1527. if (result === null) break;
  1528.  
  1529. results.push(result);
  1530. if (!global) break;
  1531.  
  1532. var matchStr = toString(result[0]);
  1533. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  1534. }
  1535.  
  1536. var accumulatedResult = '';
  1537. var nextSourcePosition = 0;
  1538. for (var i = 0; i < results.length; i++) {
  1539. result = results[i];
  1540.  
  1541. var matched = toString(result[0]);
  1542. var position = max(min(toIntegerOrInfinity(result.index), S.length), 0);
  1543. var captures = [];
  1544. // NOTE: This is equivalent to
  1545. // captures = result.slice(1).map(maybeToString)
  1546. // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
  1547. // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
  1548. // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
  1549. for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
  1550. var namedCaptures = result.groups;
  1551. if (functionalReplace) {
  1552. var replacerArgs = [matched].concat(captures, position, S);
  1553. if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
  1554. var replacement = toString(replaceValue.apply(undefined, replacerArgs));
  1555. } else {
  1556. replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
  1557. }
  1558. if (position >= nextSourcePosition) {
  1559. accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
  1560. nextSourcePosition = position + matched.length;
  1561. }
  1562. }
  1563. return accumulatedResult + S.slice(nextSourcePosition);
  1564. }
  1565. ];
  1566. }, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE);
  1567.  
  1568. const baseURL = config.baseURL;
  1569. const $ = function (selector) {
  1570. return document.querySelector(selector);
  1571. };
  1572. const $$ = function (selector) {
  1573. return document.querySelectorAll(selector);
  1574. };
  1575.  
  1576. /**
  1577. * 把
  1578. * @param {*} newNode
  1579. * @param {*} existingNode
  1580. */
  1581. function insertAfter(newNode, existingNode) {
  1582. existingNode.parentNode.insertBefore(newNode, existingNode.nextSibling);
  1583. }
  1584. function addStyle(css) {
  1585. var style = document.createElement("style");
  1586. style.textContent = css;
  1587. document.head.appendChild(style);
  1588. }
  1589. function copyText(text) {
  1590. if (navigator.clipboard) {
  1591. // clipboard api 复制
  1592. navigator.clipboard.writeText(text);
  1593. } else {
  1594. var textarea = document.createElement("textarea");
  1595. document.body.appendChild(textarea);
  1596. // 隐藏此输入框
  1597. textarea.style.position = "fixed";
  1598. textarea.style.clip = "rect(0 0 0 0)";
  1599. textarea.style.top = "10px";
  1600. // 赋值
  1601. textarea.value = text;
  1602. // 选中
  1603. textarea.select();
  1604. // 复制
  1605. document.execCommand("copy", true);
  1606. // 移除输入框
  1607. document.body.removeChild(textarea);
  1608. }
  1609. }
  1610.  
  1611. /**
  1612. * 根据请求路径和请求方法构建一个函数名称
  1613. * @param {String} url
  1614. * @param {String} method
  1615. * @returns 函数名称
  1616. */
  1617. function generateFnNameByUrl(url, method) {
  1618. /* 处理 url 中类似 {id} 的部分*/
  1619. // 如果 url 中出现了 - 也要去掉
  1620. const wordAry = url.replace(/{(.+)}/g, "by/$1").replace("-", "/").split("/").map(word => {
  1621. return word.replace(word.charAt(0), word.charAt(0).toUpperCase());
  1622. });
  1623. if (method.toUpperCase() === "GET") {
  1624. return "get" + wordAry.join("");
  1625. } else {
  1626. // 其他类型的请求,一般会把动词放在最后
  1627. // 所以把动词提到最前面
  1628. const action = wordAry.pop();
  1629. wordAry.unshift(action.toLowerCase());
  1630. return wordAry.join("");
  1631. }
  1632. }
  1633. function buildFunction(url, method, desc) {
  1634. console.log("%c Line:65 🍡 url", "color:#ea7e5c", url);
  1635. url = url.replace(baseURL, "");
  1636. const fnName = generateFnNameByUrl(url, method);
  1637. const {
  1638. url: $url,
  1639. params
  1640. } = parseUrl(url);
  1641. let paramsStr = "data";
  1642. if (params.length > 0) {
  1643. paramsStr = "(" + [...params, "data"].join(", ") + ")";
  1644. }
  1645. console.log("%c Line:85 🎂 config.methodFields", "color:#ea7e5c", config.methodFields);
  1646. return `
  1647. // ${desc}${"\n// 接口文档:" + location.href }
  1648. ${"export " }const ${fnName} = ${paramsStr} => ${config.methodFields[method]}(${$url}, data)
  1649. `;
  1650. }
  1651. function parseUrl(url) {
  1652. var reg = /{([^{]+)}/g;
  1653. const ret = url.match(reg);
  1654. const params = ret ? ret.map(curr => curr.replace(/{|}/g, "")) : [];
  1655. return {
  1656. url: "`" + url.replace("{", "${") + "`",
  1657. params
  1658. };
  1659. }
  1660.  
  1661. function appendDom(baseURL, fnString) {
  1662. const div = document.createElement("div");
  1663. const divClassName = "yapi-script-dom";
  1664. div.classList.add(divClassName);
  1665. // 判断已经有这个 div 了,如果有先删除
  1666. const self = $("." + divClassName);
  1667. if (self) {
  1668. self.parentElement.removeChild(self);
  1669. }
  1670. addStyle(`
  1671. pre,
  1672. .${divClassName} pre {
  1673. margin-bottom: 0;
  1674. position: relative;
  1675. }
  1676. pre code,
  1677. .${divClassName} pre code {
  1678. overflow-x: auto;
  1679. color: #525252;
  1680. white-space: pre;
  1681. padding: 1.2em 1.4em;
  1682. font-size: 1em;
  1683. line-height: inherit;
  1684. display: block;
  1685. padding: 1em;
  1686. overflow: auto;
  1687. background-color: #f6f8fa;
  1688. border-radius: 6px;
  1689. }
  1690. .icon {
  1691. position: absolute;
  1692. top: 2em;
  1693. right: 1em;
  1694. display: inline-block;
  1695. width: 2em;
  1696. height: 2em;
  1697. background-repeat: no-repeat;
  1698. z-index: 10;
  1699. }
  1700. .icon-hide {
  1701. display: none;
  1702. }
  1703. .icon-copy {
  1704. background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0NDggNTEyIj4gPHBhdGggZmlsbD0iIzVBNjE2QSIgZD0iTTQzMy45NDEgNjUuOTQxbC01MS44ODItNTEuODgyQTQ4IDQ4IDAgMCAwIDM0OC4xMTggMEgxNzZjLTI2LjUxIDAtNDggMjEuNDktNDggNDh2NDhINDhjLTI2LjUxIDAtNDggMjEuNDktNDggNDh2MzIwYzAgMjYuNTEgMjEuNDkgNDggNDggNDhoMjI0YzI2LjUxIDAgNDgtMjEuNDkgNDgtNDh2LTQ4aDgwYzI2LjUxIDAgNDgtMjEuNDkgNDgtNDhWOTkuODgyYTQ4IDQ4IDAgMCAwLTE0LjA1OS0zMy45NDF6TTI2NiA0NjRINTRhNiA2IDAgMCAxLTYtNlYxNTBhNiA2IDAgMCAxIDYtNmg3NHYyMjRjMCAyNi41MSAyMS40OSA0OCA0OCA0OGg5NnY0MmE2IDYgMCAwIDEtNiA2em0xMjgtOTZIMTgyYTYgNiAwIDAgMS02LTZWNTRhNiA2IDAgMCAxIDYtNmgxMDZ2ODhjMCAxMy4yNTUgMTAuNzQ1IDI0IDI0IDI0aDg4djIwMmE2IDYgMCAwIDEtNiA2em02LTI1NmgtNjRWNDhoOS42MzJjMS41OTEgMCAzLjExNy42MzIgNC4yNDMgMS43NTdsNDguMzY4IDQ4LjM2OGE2IDYgMCAwIDEgMS43NTcgNC4yNDNWMTEyeiI+PC9wYXRoPiA8L3N2Zz4=);
  1705. cursor: pointer;
  1706. transition: all .3s ease-in-out;
  1707. }
  1708. .icon-copy:hover {
  1709. transform: scale(1.2);
  1710. }
  1711. .icon-check {
  1712. background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj4gPHBhdGggZD0iTTE3My44OTggNDM5LjQwNGwtMTY2LjQtMTY2LjRjLTkuOTk3LTkuOTk3LTkuOTk3LTI2LjIwNiAwLTM2LjIwNGwzNi4yMDMtMzYuMjA0YzkuOTk3LTkuOTk4IDI2LjIwNy05Ljk5OCAzNi4yMDQgMEwxOTIgMzEyLjY5IDQzMi4wOTUgNzIuNTk2YzkuOTk3LTkuOTk3IDI2LjIwNy05Ljk5NyAzNi4yMDQgMGwzNi4yMDMgMzYuMjA0YzkuOTk3IDkuOTk3IDkuOTk3IDI2LjIwNiAwIDM2LjIwNGwtMjk0LjQgMjk0LjQwMWMtOS45OTggOS45OTctMjYuMjA3IDkuOTk3LTM2LjIwNC0uMDAxeiI+PC9wYXRoPiA8L3N2Zz4=);
  1713. }
  1714. `);
  1715. div.innerHTML = `
  1716. <h2 class="interface-title" style="margin-top: 0; margin-left: -16px;">生成的代码</h2>
  1717. <div class="">
  1718. 当前 baseURL 为: <code style="background-color: #f6f8fa; padding: 2px; border-radius: 2px;">${baseURL}</code>
  1719. </div>
  1720. <div>
  1721. <pre>
  1722. <code>${fnString}</code>
  1723. <i class="icon icon-copy js-copy-btn" data-code="${fnString}"></i>
  1724. <i class="icon icon-check icon-hide"></i>
  1725. </pre>
  1726. </div>
  1727. `;
  1728. insertAfter(div, $(".panel-view"));
  1729. }
  1730. function enableCopy() {
  1731. $$(".js-copy-btn").forEach(btn => {
  1732. btn.addEventListener("click", e => {
  1733. copyCode(e);
  1734. });
  1735. });
  1736. }
  1737. function copyCode(e) {
  1738. console.log("%c Line:75 🧀 e", "color:#465975", e);
  1739. const code = e.target.getAttribute("data-code");
  1740. copyText(code);
  1741. e.target.classList.add("icon-hide");
  1742. e.target.nextElementSibling.classList.remove("icon-hide");
  1743. setTimeout(() => {
  1744. e.target.classList.remove("icon-hide");
  1745. e.target.nextElementSibling.classList.add("icon-hide");
  1746. }, 800);
  1747. }
  1748. function tableColumns(columns) {
  1749. const div = document.createElement("div");
  1750. const divClassName = "yapi-script-columns-dom";
  1751. div.classList.add(divClassName);
  1752. // 判断已经有这个 div 了,如果有先删除
  1753. const self = $("." + divClassName);
  1754. if (self) {
  1755. self.parentElement.removeChild(self);
  1756. }
  1757. if (columns === "") {
  1758. return;
  1759. }
  1760. const code = "export const columns = " + JSON.stringify(columns, null, 2);
  1761. console.log("%c Line:92 🍉 code", "color:#2eafb0", code);
  1762. div.innerHTML = `
  1763. <h2 class="interface-title" style="margin-top: 0; margin-left: -16px;">
  1764. 表格 columns
  1765. <span style="font-size: 10px; color: rgba(13,27,62,.65);">powered by
  1766. <a target="_blank">YApi-code-auto-generator</a>
  1767. </span>
  1768. </h2>
  1769. <div>
  1770. 根据「返回数据」中的 <code>data</code> 字段生成表格的 <code>columns</code> 数据,请根据实际需求进行调整使用。
  1771. </div>
  1772.  
  1773. <div>
  1774. <pre>
  1775. <code>${code}</code>
  1776. <i class="icon icon-copy js-copy-btn" data-code='${code}'></i>
  1777. <i class="icon icon-check icon-hide"></i>
  1778. </pre>
  1779. </div>
  1780. `;
  1781. $(".caseContainer").append(div);
  1782. }
  1783.  
  1784. // import style from './styles/global.module.css'
  1785. customXMLHttpRequest({
  1786. eventHandlers: {
  1787. onloadend(e) {
  1788. const xhr = e.target;
  1789. if (xhr.readyState === 4 && xhr.responseURL.includes("api/interface/get?") && xhr.status === 200) {
  1790. const res = JSON.parse(e.target.response).data;
  1791. console.log("%c Line:61 🍋 res", "color:#3f7cff", res);
  1792. const data = {
  1793. desc: res.title,
  1794. path: res.path,
  1795. method: res.method,
  1796. // req_body: JSON.parse(res.req_body_other),
  1797. res_body: JSON.parse(res.res_body)
  1798. };
  1799. console.log("%c Line:58 🥕 data", "color:#33a5ff", data);
  1800. const resBody = JSON.parse(res.res_body)?.properties?.data?.items?.properties;
  1801. if (resBody) {
  1802. // console.log("%c Line:68 🍧 resBody", "color:#93c0a4", resBody);
  1803. const columns = Object.keys(resBody).map(key => {
  1804. const desc = resBody[key].description;
  1805. return {
  1806. title: desc || key,
  1807. dataIndex: key
  1808. // type: resBody[key].type,
  1809. };
  1810. });
  1811.  
  1812. console.log("%c Line:71 🌰 columns", "color:#33a5ff", JSON.stringify(columns, null, 2));
  1813. tableColumns(columns);
  1814. } else {
  1815. tableColumns("");
  1816. }
  1817. const fnString = buildFunction(data.path, data.method, data.desc);
  1818. // 具体的接口页面
  1819. appendDom(config.baseURL, fnString);
  1820. enableCopy();
  1821. }
  1822. }
  1823. }
  1824. });
  1825.  
  1826. })();
  1827. //# sourceMappingURL=main.dev.user.js.map