@whitesev/utils 2.7.1 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/index.amd.js +260 -409
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +260 -409
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +260 -409
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +260 -409
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +260 -409
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +260 -409
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/ColorConversion.d.ts +3 -8
  14. package/dist/types/src/Dictionary.d.ts +21 -14
  15. package/dist/types/src/GBKEncoder.d.ts +1 -2
  16. package/dist/types/src/Hooks.d.ts +1 -2
  17. package/dist/types/src/Httpx.d.ts +45 -46
  18. package/dist/types/src/LockFunction.d.ts +1 -2
  19. package/dist/types/src/Log.d.ts +1 -2
  20. package/dist/types/src/Progress.d.ts +1 -2
  21. package/dist/types/src/Utils.d.ts +30 -2
  22. package/dist/types/src/UtilsGMMenu.d.ts +1 -2
  23. package/dist/types/src/WindowApi.d.ts +1 -2
  24. package/dist/types/src/indexedDB.d.ts +1 -2
  25. package/dist/types/src/types/Event.d.ts +1 -2
  26. package/dist/types/src/types/Httpx.d.ts +75 -86
  27. package/dist/types/src/types/ajaxHooker.d.ts +1 -5
  28. package/dist/types/src/types/env.d.ts +2 -0
  29. package/dist/types/src/types/global.d.ts +3 -0
  30. package/package.json +1 -1
  31. package/src/ColorConversion.ts +13 -37
  32. package/src/CommonUtil.ts +8 -31
  33. package/src/DOMUtils.ts +9 -24
  34. package/src/Dictionary.ts +37 -38
  35. package/src/GBKEncoder.ts +9 -18
  36. package/src/Hooks.ts +2 -7
  37. package/src/Httpx.ts +257 -412
  38. package/src/LockFunction.ts +1 -3
  39. package/src/Log.ts +8 -26
  40. package/src/Progress.ts +3 -13
  41. package/src/TryCatch.ts +4 -12
  42. package/src/Utils.ts +233 -595
  43. package/src/UtilsCommon.ts +5 -9
  44. package/src/UtilsGMCookie.ts +1 -4
  45. package/src/UtilsGMMenu.ts +29 -51
  46. package/src/Vue.ts +6 -18
  47. package/src/WindowApi.ts +2 -5
  48. package/src/indexedDB.ts +11 -20
  49. package/src/types/Event.d.ts +1 -2
  50. package/src/types/Httpx.d.ts +75 -86
  51. package/src/types/ajaxHooker.d.ts +1 -5
  52. package/src/types/env.d.ts +2 -0
  53. package/src/types/global.d.ts +3 -0
@@ -18,14 +18,13 @@ var Utils = (function () {
18
18
  /**
19
19
  * 16进制颜色转rgba
20
20
  *
21
- * #ff0000 rgba(123,123,123, 0.4)
21
+ * 例如:`#ff0000` 转为 `rgba(123,123,123, 0.4)`
22
22
  * @param hex
23
23
  * @param opacity
24
24
  */
25
25
  hexToRgba(hex, opacity) {
26
26
  if (!this.isHex(hex)) {
27
- // @ts-ignore
28
- throw new TypeError("输入错误的hex", hex);
27
+ throw new TypeError("输入错误的hex:" + hex);
29
28
  }
30
29
  return hex && hex.replace(/\s+/g, "").length === 7
31
30
  ? "rgba(" +
@@ -42,19 +41,16 @@ var Utils = (function () {
42
41
  /**
43
42
  * hex转rgb
44
43
  * @param str
45
- * @returns
46
44
  */
47
45
  hexToRgb(str) {
48
46
  if (!this.isHex(str)) {
49
- // @ts-ignore
50
- throw new TypeError("输入错误的hex", str);
47
+ throw new TypeError("输入错误的hex:" + str);
51
48
  }
52
49
  /* replace替换查找的到的字符串 */
53
50
  str = str.replace("#", "");
54
51
  /* match得到查询数组 */
55
52
  let hxs = str.match(/../g);
56
53
  for (let index = 0; index < 3; index++) {
57
- // @ts-ignore
58
54
  hxs[index] = parseInt(hxs[index], 16);
59
55
  }
60
56
  return hxs;
@@ -64,7 +60,6 @@ var Utils = (function () {
64
60
  * @param redValue
65
61
  * @param greenValue
66
62
  * @param blueValue
67
- * @returns
68
63
  */
69
64
  rgbToHex(redValue, greenValue, blueValue) {
70
65
  /* 验证输入的rgb值是否合法 */
@@ -73,11 +68,7 @@ var Utils = (function () {
73
68
  !validPattern.test(greenValue.toString()) ||
74
69
  !validPattern.test(blueValue.toString()))
75
70
  throw new TypeError("输入错误的rgb颜色值");
76
- let hexs = [
77
- redValue.toString(16),
78
- greenValue.toString(16),
79
- blueValue.toString(16),
80
- ];
71
+ let hexs = [redValue.toString(16), greenValue.toString(16), blueValue.toString(16)];
81
72
  for (let index = 0; index < 3; index++)
82
73
  if (hexs[index].length == 1)
83
74
  hexs[index] = "0" + hexs[index];
@@ -87,38 +78,30 @@ var Utils = (function () {
87
78
  * 获取颜色变暗或亮
88
79
  * @param color 颜色
89
80
  * @param level 0~1.0
90
- * @returns
91
81
  */
92
82
  getDarkColor(color, level) {
93
83
  if (!this.isHex(color)) {
94
- // @ts-ignore
95
- throw new TypeError("输入错误的hex", color);
84
+ throw new TypeError("输入错误的hex:" + color);
96
85
  }
97
86
  let rgbc = this.hexToRgb(color);
98
87
  for (let index = 0; index < 3; index++) {
99
- // @ts-ignore
100
88
  rgbc[index] = Math.floor(rgbc[index] * (1 - level));
101
89
  }
102
- // @ts-ignore
103
90
  return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
104
91
  }
105
92
  /**
106
93
  * 获取颜色变亮
107
94
  * @param color 颜色
108
95
  * @param level 0~1.0
109
- * @returns
110
96
  */
111
97
  getLightColor(color, level) {
112
98
  if (!this.isHex(color)) {
113
- // @ts-ignore
114
- throw new TypeError("输入错误的hex", color);
99
+ throw new TypeError("输入错误的hex:" + color);
115
100
  }
116
101
  let rgbc = this.hexToRgb(color);
117
102
  for (let index = 0; index < 3; index++) {
118
- // @ts-ignore
119
103
  rgbc[index] = Math.floor((255 - rgbc[index]) * level + rgbc[index]);
120
104
  }
121
- // @ts-ignore
122
105
  return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
123
106
  }
124
107
  }
@@ -133,10 +116,7 @@ var Utils = (function () {
133
116
  this.#data = dataText.match(/..../g);
134
117
  for (let i = 0x81; i <= 0xfe; i++) {
135
118
  for (let j = 0x40; j <= 0xfe; j++) {
136
- this.#U2Ghash[this.#data[index++]] = ("%" +
137
- i.toString(16) +
138
- "%" +
139
- j.toString(16)).toUpperCase();
119
+ this.#U2Ghash[this.#data[index++]] = ("%" + i.toString(16) + "%" + j.toString(16)).toUpperCase();
140
120
  }
141
121
  }
142
122
  for (let key in this.#U2Ghash) {
@@ -206,20 +186,20 @@ var Utils = (function () {
206
186
  * @param str
207
187
  */
208
188
  decode(str) {
209
- var GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
210
- var UTFMatcher = /%[0-9A-F]{2}/;
211
- // @ts-ignore
212
- var utf = true;
213
- let that = this;
189
+ let GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
190
+ let UTFMatcher = /%[0-9A-F]{2}/;
191
+ // let gbk = true;
192
+ let utf = true;
193
+ const that = this;
214
194
  while (utf) {
215
195
  let gbkMatch = str.match(GBKMatcher);
216
196
  let utfMatch = str.match(UTFMatcher);
197
+ // gbk = Boolean(gbkMatch);
217
198
  utf = Boolean(utfMatch);
218
199
  if (gbkMatch && gbkMatch in that.#G2Uhash) {
219
200
  str = str.replace(gbkMatch, String.fromCharCode(("0x" + that.#G2Uhash[gbkMatch])));
220
201
  }
221
202
  else {
222
- // @ts-ignore
223
203
  str = str.replace(utfMatch, decodeURIComponent(utfMatch));
224
204
  }
225
205
  }
@@ -250,7 +230,6 @@ var Utils = (function () {
250
230
  * @param handler
251
231
  */
252
232
  error(handler) {
253
- // @ts-ignore
254
233
  handleError = handler;
255
234
  return TryCatchCore;
256
235
  },
@@ -265,7 +244,6 @@ var Utils = (function () {
265
244
  callbackFunction = callback;
266
245
  context = __context__ || this;
267
246
  let result = executeTryCatch(callbackFunction, handleError, context);
268
- // @ts-ignore
269
247
  return result !== void 0 ? result : TryCatchCore;
270
248
  },
271
249
  };
@@ -295,10 +273,7 @@ var Utils = (function () {
295
273
  }
296
274
  if (handleErrorFunc) {
297
275
  if (typeof handleErrorFunc === "string") {
298
- result = new Function(handleErrorFunc).apply(funcThis, [
299
- ...args,
300
- error,
301
- ]);
276
+ result = new Function(handleErrorFunc).apply(funcThis, [...args, error]);
302
277
  }
303
278
  else {
304
279
  result = handleErrorFunc.apply(funcThis, [...args, error]);
@@ -386,10 +361,7 @@ var Utils = (function () {
386
361
  itemResult = objItem === 0;
387
362
  break;
388
363
  case "string":
389
- itemResult =
390
- objItem.trim() === "" ||
391
- objItem === "null" ||
392
- objItem === "undefined";
364
+ itemResult = objItem.trim() === "" || objItem === "null" || objItem === "undefined";
393
365
  break;
394
366
  case "boolean":
395
367
  itemResult = !objItem;
@@ -430,8 +402,7 @@ var Utils = (function () {
430
402
  return null;
431
403
  let clone = obj instanceof Array ? [] : {};
432
404
  for (const [key, value] of Object.entries(obj)) {
433
- clone[key] =
434
- typeof value === "object" ? UtilsContext.deepClone(value) : value;
405
+ clone[key] = typeof value === "object" ? UtilsContext.deepClone(value) : value;
435
406
  }
436
407
  return clone;
437
408
  }
@@ -1950,35 +1921,30 @@ var Utils = (function () {
1950
1921
  let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
1951
1922
  /** 油猴菜单上显示的文本 */
1952
1923
  let showText = menuOption.showText(menuOption.text, defaultEnable);
1953
- // @ts-ignore
1954
- ({
1955
- /**
1956
- * 菜单的id
1957
- */
1958
- id: menuOption.id,
1959
- /**
1960
- * 点击菜单项后是否应关闭弹出菜单
1961
- */
1962
- autoClose: menuOption.autoClose,
1963
- /**
1964
- * 菜单项的可选访问键
1965
- */
1966
- accessKey: menuOption.accessKey,
1967
- /**
1968
- * 菜单项的鼠标悬浮上的工具提示
1969
- */
1970
- title: menuOption.title,
1971
- });
1924
+ // const GMMenuOptions = {
1925
+ // /**
1926
+ // * 菜单的id
1927
+ // */
1928
+ // id: menuOption.id,
1929
+ // /**
1930
+ // * 点击菜单项后是否应关闭弹出菜单
1931
+ // */
1932
+ // autoClose: menuOption.autoClose,
1933
+ // /**
1934
+ // * 菜单项的可选访问键
1935
+ // */
1936
+ // accessKey: menuOption.accessKey,
1937
+ // /**
1938
+ // * 菜单项的鼠标悬浮上的工具提示
1939
+ // */
1940
+ // title: menuOption.title,
1941
+ // };
1972
1942
  /* 点击菜单后触发callback后的网页是否刷新 */
1973
1943
  menuOption.autoReload =
1974
- typeof menuOption.autoReload !== "boolean"
1975
- ? this.$default.autoReload
1976
- : menuOption.autoReload;
1944
+ typeof menuOption.autoReload !== "boolean" ? this.$default.autoReload : menuOption.autoReload;
1977
1945
  /* 点击菜单后触发callback后的网页是否存储值 */
1978
1946
  menuOption.isStoreValue =
1979
- typeof menuOption.isStoreValue !== "boolean"
1980
- ? this.$default.isStoreValue
1981
- : menuOption.isStoreValue;
1947
+ typeof menuOption.isStoreValue !== "boolean" ? this.$default.isStoreValue : menuOption.isStoreValue;
1982
1948
  /**
1983
1949
  * 用户点击菜单后的回调函数
1984
1950
  * @param event
@@ -2031,8 +1997,7 @@ var Utils = (function () {
2031
1997
  * @param menuKey 菜单-键key
2032
1998
  */
2033
1999
  getMenuHandledOption(menuKey) {
2034
- return this.$data.data.find((item) => item.handleData.key === menuKey)
2035
- ?.handleData;
2000
+ return this.$data.data.find((item) => item.handleData.key === menuKey)?.handleData;
2036
2001
  },
2037
2002
  };
2038
2003
  constructor(details) {
@@ -2040,8 +2005,7 @@ var Utils = (function () {
2040
2005
  this.GM_Api.setValue = details.GM_setValue;
2041
2006
  this.GM_Api.registerMenuCommand = details.GM_registerMenuCommand;
2042
2007
  this.GM_Api.unregisterMenuCommand = details.GM_unregisterMenuCommand;
2043
- this.MenuHandle.$default.autoReload =
2044
- typeof details.autoReload === "boolean" ? details.autoReload : true;
2008
+ this.MenuHandle.$default.autoReload = typeof details.autoReload === "boolean" ? details.autoReload : true;
2045
2009
  for (const keyName of Object.keys(this.GM_Api)) {
2046
2010
  if (typeof this.GM_Api[keyName] !== "function") {
2047
2011
  throw new Error(`Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`);
@@ -2273,8 +2237,7 @@ var Utils = (function () {
2273
2237
  _context = context || window;
2274
2238
  _funcName = getFuncName(this);
2275
2239
  _context["realFunc_" + _funcName] = this;
2276
- if (_context[_funcName].prototype &&
2277
- _context[_funcName].prototype.isHooked) {
2240
+ if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
2278
2241
  console.log("Already has been hooked,unhook first");
2279
2242
  return false;
2280
2243
  }
@@ -2452,8 +2415,7 @@ var Utils = (function () {
2452
2415
  if (details.allowInterceptConfig != null) {
2453
2416
  // 配置存在
2454
2417
  // 细分处理是否拦截
2455
- if (typeof details.allowInterceptConfig.afterResponseSuccess ===
2456
- "boolean" &&
2418
+ if (typeof details.allowInterceptConfig.afterResponseSuccess === "boolean" &&
2457
2419
  !details.allowInterceptConfig.afterResponseSuccess) {
2458
2420
  // 设置了禁止拦截
2459
2421
  return details;
@@ -2488,8 +2450,7 @@ var Utils = (function () {
2488
2450
  if (data.details.allowInterceptConfig != null) {
2489
2451
  // 配置存在
2490
2452
  // 细分处理是否拦截
2491
- if (typeof data.details.allowInterceptConfig.afterResponseError ===
2492
- "boolean" &&
2453
+ if (typeof data.details.allowInterceptConfig.afterResponseError === "boolean" &&
2493
2454
  !data.details.allowInterceptConfig.afterResponseError) {
2494
2455
  // 设置了禁止拦截
2495
2456
  return data;
@@ -2546,7 +2507,9 @@ var Utils = (function () {
2546
2507
  * 对请求的参数进行合并处理
2547
2508
  */
2548
2509
  handleBeforeRequestOptionArgs(...args) {
2549
- let option = {};
2510
+ let option = {
2511
+ url: void 0,
2512
+ };
2550
2513
  if (typeof args[0] === "string") {
2551
2514
  /* 传入的是url,转为配置 */
2552
2515
  let url = args[0];
@@ -2570,7 +2533,7 @@ var Utils = (function () {
2570
2533
  * @param method 当前请求方法,默认get
2571
2534
  * @param userRequestOption 用户的请求配置
2572
2535
  * @param resolve promise回调
2573
- * @param reject 抛出错误回调
2536
+ * @param reject promise抛出错误回调
2574
2537
  */
2575
2538
  getRequestOption(method, userRequestOption, resolve, reject) {
2576
2539
  let that = this;
@@ -2589,64 +2552,51 @@ var Utils = (function () {
2589
2552
  let requestOption = {
2590
2553
  url: url,
2591
2554
  method: (method || "GET").toString().toUpperCase().trim(),
2592
- timeout: userRequestOption.timeout ||
2593
- this.context.#defaultRequestOption.timeout,
2594
- responseType: userRequestOption.responseType ||
2595
- this.context.#defaultRequestOption.responseType,
2555
+ timeout: userRequestOption.timeout || this.context.#defaultRequestOption.timeout,
2556
+ responseType: userRequestOption.responseType || this.context.#defaultRequestOption.responseType,
2596
2557
  /* 对象使用深拷贝 */
2597
2558
  headers: commonUtil.deepClone(this.context.#defaultRequestOption.headers),
2598
2559
  data: userRequestOption.data || this.context.#defaultRequestOption.data,
2599
- redirect: userRequestOption.redirect ||
2600
- this.context.#defaultRequestOption.redirect,
2560
+ redirect: userRequestOption.redirect || this.context.#defaultRequestOption.redirect,
2601
2561
  cookie: userRequestOption.cookie || this.context.#defaultRequestOption.cookie,
2602
- cookiePartition: userRequestOption.cookiePartition ||
2603
- this.context.#defaultRequestOption.cookiePartition,
2562
+ cookiePartition: userRequestOption.cookiePartition || this.context.#defaultRequestOption.cookiePartition,
2604
2563
  binary: userRequestOption.binary || this.context.#defaultRequestOption.binary,
2605
- nocache: userRequestOption.nocache ||
2606
- this.context.#defaultRequestOption.nocache,
2607
- revalidate: userRequestOption.revalidate ||
2608
- this.context.#defaultRequestOption.revalidate,
2564
+ nocache: userRequestOption.nocache || this.context.#defaultRequestOption.nocache,
2565
+ revalidate: userRequestOption.revalidate || this.context.#defaultRequestOption.revalidate,
2609
2566
  /* 对象使用深拷贝 */
2610
- context: commonUtil.deepClone(userRequestOption.context ||
2611
- this.context.#defaultRequestOption.context),
2612
- overrideMimeType: userRequestOption.overrideMimeType ||
2613
- this.context.#defaultRequestOption.overrideMimeType,
2614
- anonymous: userRequestOption.anonymous ||
2615
- this.context.#defaultRequestOption.anonymous,
2567
+ context: commonUtil.deepClone(userRequestOption.context || this.context.#defaultRequestOption.context),
2568
+ overrideMimeType: userRequestOption.overrideMimeType || this.context.#defaultRequestOption.overrideMimeType,
2569
+ anonymous: userRequestOption.anonymous || this.context.#defaultRequestOption.anonymous,
2616
2570
  fetch: userRequestOption.fetch || this.context.#defaultRequestOption.fetch,
2617
2571
  /* 对象使用深拷贝 */
2618
2572
  fetchInit: commonUtil.deepClone(this.context.#defaultRequestOption.fetchInit),
2619
2573
  allowInterceptConfig: {
2620
- beforeRequest: this.context.#defaultRequestOption
2621
- .allowInterceptConfig.beforeRequest,
2622
- afterResponseSuccess: this.context.#defaultRequestOption
2623
- .allowInterceptConfig.afterResponseSuccess,
2624
- afterResponseError: this.context.#defaultRequestOption
2625
- .allowInterceptConfig.afterResponseError,
2574
+ beforeRequest: this.context.#defaultRequestOption.allowInterceptConfig.beforeRequest,
2575
+ afterResponseSuccess: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseSuccess,
2576
+ afterResponseError: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseError,
2626
2577
  },
2627
2578
  user: userRequestOption.user || this.context.#defaultRequestOption.user,
2628
- password: userRequestOption.password ||
2629
- this.context.#defaultRequestOption.password,
2579
+ password: userRequestOption.password || this.context.#defaultRequestOption.password,
2630
2580
  onabort(...args) {
2631
- that.context.HttpxCallBack.onAbort(userRequestOption, resolve, reject, args);
2581
+ that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
2632
2582
  },
2633
2583
  onerror(...args) {
2634
- that.context.HttpxCallBack.onError(userRequestOption, resolve, reject, args);
2584
+ that.context.HttpxResponseCallBack.onError(userRequestOption, resolve, reject, args);
2635
2585
  },
2636
2586
  onloadstart(...args) {
2637
- that.context.HttpxCallBack.onLoadStart(userRequestOption, args);
2587
+ that.context.HttpxResponseCallBack.onLoadStart(userRequestOption, args);
2638
2588
  },
2639
2589
  onprogress(...args) {
2640
- that.context.HttpxCallBack.onProgress(userRequestOption, args);
2590
+ that.context.HttpxResponseCallBack.onProgress(userRequestOption, args);
2641
2591
  },
2642
2592
  onreadystatechange(...args) {
2643
- that.context.HttpxCallBack.onReadyStateChange(userRequestOption, args);
2593
+ that.context.HttpxResponseCallBack.onReadyStateChange(userRequestOption, args);
2644
2594
  },
2645
2595
  ontimeout(...args) {
2646
- that.context.HttpxCallBack.onTimeout(userRequestOption, resolve, reject, args);
2596
+ that.context.HttpxResponseCallBack.onTimeout(userRequestOption, resolve, reject, args);
2647
2597
  },
2648
2598
  onload(...args) {
2649
- that.context.HttpxCallBack.onLoad(userRequestOption, resolve, reject, args);
2599
+ that.context.HttpxResponseCallBack.onLoad(userRequestOption, resolve, reject, args);
2650
2600
  },
2651
2601
  };
2652
2602
  // 补全allowInterceptConfig参数
@@ -2674,14 +2624,12 @@ var Utils = (function () {
2674
2624
  if (typeof requestOption.headers === "object") {
2675
2625
  if (typeof userRequestOption.headers === "object") {
2676
2626
  Object.keys(userRequestOption.headers).forEach((keyName, index) => {
2677
- if (keyName in requestOption.headers &&
2678
- userRequestOption.headers?.[keyName] == null) {
2627
+ if (keyName in requestOption.headers && userRequestOption.headers?.[keyName] == null) {
2679
2628
  /* 在默认的header中存在,且设置它新的值为空,那么就是默认的值 */
2680
2629
  Reflect.deleteProperty(requestOption.headers, keyName);
2681
2630
  }
2682
2631
  else {
2683
- requestOption.headers[keyName] =
2684
- userRequestOption?.headers?.[keyName];
2632
+ requestOption.headers[keyName] = userRequestOption?.headers?.[keyName];
2685
2633
  }
2686
2634
  });
2687
2635
  }
@@ -2694,8 +2642,7 @@ var Utils = (function () {
2694
2642
  /* 使用assign替换且添加 */
2695
2643
  if (typeof userRequestOption.fetchInit === "object") {
2696
2644
  Object.keys(userRequestOption.fetchInit).forEach((keyName, index) => {
2697
- if (keyName in requestOption.fetchInit &&
2698
- userRequestOption.fetchInit[keyName] == null) {
2645
+ if (keyName in requestOption.fetchInit && userRequestOption.fetchInit[keyName] == null) {
2699
2646
  /* 在默认的fetchInit中存在,且设置它新的值为空,那么就是默认的值 */
2700
2647
  Reflect.deleteProperty(requestOption.fetchInit, keyName);
2701
2648
  }
@@ -2709,8 +2656,7 @@ var Utils = (function () {
2709
2656
  Reflect.set(requestOption, "fetchInit", userRequestOption.fetchInit);
2710
2657
  }
2711
2658
  // 处理新的cookiePartition
2712
- if (typeof requestOption.cookiePartition === "object" &&
2713
- requestOption.cookiePartition != null) {
2659
+ if (typeof requestOption.cookiePartition === "object" && requestOption.cookiePartition != null) {
2714
2660
  if (Reflect.has(requestOption.cookiePartition, "topLevelSite") &&
2715
2661
  typeof requestOption.cookiePartition.topLevelSite !== "string") {
2716
2662
  // topLevelSite必须是字符串
@@ -2732,8 +2678,7 @@ var Utils = (function () {
2732
2678
  }
2733
2679
  else {
2734
2680
  // 补充origin+/
2735
- requestOption.url =
2736
- globalThis.location.origin + "/" + requestOption.url;
2681
+ requestOption.url = globalThis.location.origin + "/" + requestOption.url;
2737
2682
  }
2738
2683
  }
2739
2684
  if (requestOption.fetchInit && !requestOption.fetch) {
@@ -2758,7 +2703,6 @@ var Utils = (function () {
2758
2703
  else if (typeof requestOption.data === "object") {
2759
2704
  isHandler = true;
2760
2705
  // URLSearchParams参数可以转普通的string:string,包括FormData
2761
- // @ts-ignore
2762
2706
  let searchParams = new URLSearchParams(requestOption.data);
2763
2707
  urlSearch = searchParams.toString();
2764
2708
  }
@@ -2813,9 +2757,7 @@ var Utils = (function () {
2813
2757
  else if (ContentType.includes("application/x-www-form-urlencoded")) {
2814
2758
  // application/x-www-form-urlencoded
2815
2759
  if (typeof requestOption.data === "object") {
2816
- requestOption.data = new URLSearchParams(
2817
- // @ts-ignore
2818
- requestOption.data).toString();
2760
+ requestOption.data = new URLSearchParams(requestOption.data).toString();
2819
2761
  }
2820
2762
  }
2821
2763
  else if (ContentType.includes("multipart/form-data")) {
@@ -2835,7 +2777,7 @@ var Utils = (function () {
2835
2777
  },
2836
2778
  /**
2837
2779
  * 处理发送请求的配置,去除值为undefined、空function的值
2838
- * @param option
2780
+ * @param option 请求配置
2839
2781
  */
2840
2782
  removeRequestNullOption(option) {
2841
2783
  Object.keys(option).forEach((keyName) => {
@@ -2847,21 +2789,20 @@ var Utils = (function () {
2847
2789
  }
2848
2790
  });
2849
2791
  if (commonUtil.isNull(option.url)) {
2850
- throw new TypeError(`Utils.Httpx 参数 url不符合要求: ${option.url}`);
2792
+ throw new TypeError(`Utils.Httpx 参数url不能为空:${option.url}`);
2851
2793
  }
2852
2794
  return option;
2853
2795
  },
2854
2796
  /**
2855
2797
  * 处理fetch的配置
2856
- * @param option
2798
+ * @param option 请求配置
2857
2799
  */
2858
2800
  handleFetchOption(option) {
2859
2801
  /**
2860
2802
  * fetch的请求配置
2861
2803
  **/
2862
2804
  let fetchRequestOption = {};
2863
- if ((option.method === "GET" || option.method === "HEAD") &&
2864
- option.data != null) {
2805
+ if ((option.method === "GET" || option.method === "HEAD") && option.data != null) {
2865
2806
  /* GET 或 HEAD 方法的请求不能包含 body 信息 */
2866
2807
  Reflect.deleteProperty(option, "data");
2867
2808
  }
@@ -2906,21 +2847,21 @@ var Utils = (function () {
2906
2847
  };
2907
2848
  },
2908
2849
  };
2909
- HttpxCallBack = {
2850
+ HttpxResponseCallBack = {
2910
2851
  context: this,
2911
2852
  /**
2912
2853
  * onabort请求被取消-触发
2913
2854
  * @param details 配置
2914
- * @param resolve 回调
2915
- * @param reject 抛出错误
2855
+ * @param resolve promise回调
2856
+ * @param reject promise抛出错误回调
2916
2857
  * @param argsResult 返回的参数列表
2917
2858
  */
2918
2859
  async onAbort(details, resolve, reject, argsResult) {
2919
2860
  // console.log(argsResult);
2920
- if ("onabort" in details) {
2861
+ if (typeof details?.onabort === "function") {
2921
2862
  details.onabort.apply(this, argsResult);
2922
2863
  }
2923
- else if ("onabort" in this.context.#defaultRequestOption) {
2864
+ else if (typeof this.context.#defaultRequestOption?.onabort === "function") {
2924
2865
  this.context.#defaultRequestOption.onabort.apply(this, argsResult);
2925
2866
  }
2926
2867
  let response = argsResult;
@@ -2929,11 +2870,11 @@ var Utils = (function () {
2929
2870
  }
2930
2871
  if ((await this.context.HttpxResponseHook.errorResponseCallBack({
2931
2872
  type: "onabort",
2932
- error: new TypeError("request canceled"),
2873
+ error: new Error("request canceled"),
2933
2874
  response: null,
2934
2875
  details: details,
2935
2876
  })) == null) {
2936
- // reject(new TypeError("response is intercept with onabort"));
2877
+ // reject(new Error("response is intercept with onabort"));
2937
2878
  return;
2938
2879
  }
2939
2880
  resolve({
@@ -2946,93 +2887,83 @@ var Utils = (function () {
2946
2887
  });
2947
2888
  },
2948
2889
  /**
2949
- * onerror请求异常-触发
2890
+ * ontimeout请求超时-触发
2950
2891
  * @param details 配置
2951
2892
  * @param resolve 回调
2952
2893
  * @param reject 抛出错误
2953
2894
  * @param argsResult 返回的参数列表
2954
2895
  */
2955
- async onError(details, resolve, reject, argsResult) {
2896
+ async onTimeout(details, resolve, reject, argsResult) {
2956
2897
  // console.log(argsResult);
2957
- if ("onerror" in details) {
2958
- details.onerror.apply(this, argsResult);
2898
+ if (typeof details?.ontimeout === "function") {
2899
+ // 执行配置中的ontime回调
2900
+ details.ontimeout.apply(this, argsResult);
2959
2901
  }
2960
- else if ("onerror" in this.context.#defaultRequestOption) {
2961
- this.context.#defaultRequestOption.onerror.apply(this, argsResult);
2902
+ else if (typeof this.context.#defaultRequestOption?.ontimeout === "function") {
2903
+ // 执行默认配置的ontime回调
2904
+ this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
2962
2905
  }
2906
+ // 获取响应结果
2963
2907
  let response = argsResult;
2964
2908
  if (response.length) {
2965
2909
  response = response[0];
2966
2910
  }
2911
+ // 执行错误回调的钩子
2967
2912
  if ((await this.context.HttpxResponseHook.errorResponseCallBack({
2968
- type: "onerror",
2969
- error: new TypeError("request error"),
2913
+ type: "ontimeout",
2914
+ error: new Error("request timeout"),
2970
2915
  response: response,
2971
2916
  details: details,
2972
2917
  })) == null) {
2973
- // reject(new TypeError("response is intercept with onerror"));
2918
+ // reject(new Error("response is intercept with ontimeout"));
2974
2919
  return;
2975
2920
  }
2976
2921
  resolve({
2977
2922
  data: response,
2978
2923
  details: details,
2979
- msg: "请求异常",
2924
+ msg: "请求超时",
2980
2925
  status: false,
2981
- statusCode: response["status"],
2982
- type: "onerror",
2926
+ statusCode: 0,
2927
+ type: "ontimeout",
2983
2928
  });
2984
2929
  },
2985
2930
  /**
2986
- * ontimeout请求超时-触发
2931
+ * onerror请求异常-触发
2987
2932
  * @param details 配置
2988
2933
  * @param resolve 回调
2989
2934
  * @param reject 抛出错误
2990
2935
  * @param argsResult 返回的参数列表
2991
2936
  */
2992
- async onTimeout(details, resolve, reject, argsResult) {
2937
+ async onError(details, resolve, reject, argsResult) {
2993
2938
  // console.log(argsResult);
2994
- if ("ontimeout" in details) {
2995
- details.ontimeout.apply(this, argsResult);
2939
+ if (typeof details?.onerror === "function") {
2940
+ details.onerror.apply(this, argsResult);
2996
2941
  }
2997
- else if ("ontimeout" in this.context.#defaultRequestOption) {
2998
- this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
2942
+ else if (typeof this.context.#defaultRequestOption?.onerror === "function") {
2943
+ this.context.#defaultRequestOption.onerror.apply(this, argsResult);
2999
2944
  }
3000
2945
  let response = argsResult;
3001
2946
  if (response.length) {
3002
2947
  response = response[0];
3003
2948
  }
3004
2949
  if ((await this.context.HttpxResponseHook.errorResponseCallBack({
3005
- type: "ontimeout",
3006
- error: new TypeError("request timeout"),
3007
- response: (argsResult || [null])[0],
2950
+ type: "onerror",
2951
+ error: new Error("request error"),
2952
+ response: response,
3008
2953
  details: details,
3009
2954
  })) == null) {
3010
- // reject(new TypeError("response is intercept with ontimeout"));
2955
+ // reject(new Error("response is intercept with onerror"));
3011
2956
  return;
3012
2957
  }
3013
2958
  resolve({
3014
2959
  data: response,
3015
2960
  details: details,
3016
- msg: "请求超时",
2961
+ msg: "请求异常",
3017
2962
  status: false,
3018
- statusCode: 0,
3019
- type: "ontimeout",
2963
+ statusCode: response["status"],
2964
+ type: "onerror",
3020
2965
  });
3021
2966
  },
3022
- /**
3023
- * onloadstart请求开始-触发
3024
- * @param details 配置
3025
- * @param argsResult 返回的参数列表
3026
- */
3027
- onLoadStart(details, argsResult) {
3028
- // console.log(argsResult);
3029
- if ("onloadstart" in details) {
3030
- details.onloadstart.apply(this, argsResult);
3031
- }
3032
- else if ("onloadstart" in this.context.#defaultRequestOption) {
3033
- this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
3034
- }
3035
- },
3036
2967
  /**
3037
2968
  * onload加载完毕-触发
3038
2969
  * @param details 请求的配置
@@ -3112,7 +3043,7 @@ var Utils = (function () {
3112
3043
  /* 状态码2xx都是成功的 */
3113
3044
  if (Math.floor(originResponse.status / 100) === 2) {
3114
3045
  if ((await this.context.HttpxResponseHook.successResponseCallBack(originResponse, details)) == null) {
3115
- // reject(new TypeError("response is intercept with onloada"));
3046
+ // reject(new Error("response is intercept with onloada"));
3116
3047
  return;
3117
3048
  }
3118
3049
  resolve({
@@ -3125,21 +3056,21 @@ var Utils = (function () {
3125
3056
  });
3126
3057
  }
3127
3058
  else {
3128
- this.context.HttpxCallBack.onError(details, resolve, reject, argsResult);
3059
+ this.context.HttpxResponseCallBack.onError(details, resolve, reject, argsResult);
3129
3060
  }
3130
3061
  },
3131
3062
  /**
3132
- * onprogress上传进度-触发
3063
+ * onloadstart请求开始-触发
3133
3064
  * @param details 配置
3134
3065
  * @param argsResult 返回的参数列表
3135
3066
  */
3136
- onProgress(details, argsResult) {
3067
+ onLoadStart(details, argsResult) {
3137
3068
  // console.log(argsResult);
3138
- if ("onprogress" in details) {
3139
- details.onprogress.apply(this, argsResult);
3069
+ if (typeof details?.onloadstart === "function") {
3070
+ details.onloadstart.apply(this, argsResult);
3140
3071
  }
3141
- else if ("onprogress" in this.context.#defaultRequestOption) {
3142
- this.context.#defaultRequestOption.onprogress.apply(this, argsResult);
3072
+ else if (typeof this.context.#defaultRequestOption?.onloadstart === "function") {
3073
+ this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
3143
3074
  }
3144
3075
  },
3145
3076
  /**
@@ -3149,13 +3080,27 @@ var Utils = (function () {
3149
3080
  */
3150
3081
  onReadyStateChange(details, argsResult) {
3151
3082
  // console.log(argsResult);
3152
- if ("onreadystatechange" in details) {
3083
+ if (typeof details?.onreadystatechange === "function") {
3153
3084
  details.onreadystatechange.apply(this, argsResult);
3154
3085
  }
3155
- else if ("onreadystatechange" in this.context.#defaultRequestOption) {
3086
+ else if (typeof this.context.#defaultRequestOption?.onreadystatechange === "function") {
3156
3087
  this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
3157
3088
  }
3158
3089
  },
3090
+ /**
3091
+ * onprogress上传进度-触发
3092
+ * @param details 配置
3093
+ * @param argsResult 返回的参数列表
3094
+ */
3095
+ onProgress(details, argsResult) {
3096
+ // console.log(argsResult);
3097
+ if (typeof details?.onprogress === "function") {
3098
+ details.onprogress.apply(this, argsResult);
3099
+ }
3100
+ else if (typeof this.context.#defaultRequestOption?.onprogress === "function") {
3101
+ this.context.#defaultRequestOption.onprogress.apply(this, argsResult);
3102
+ }
3103
+ },
3159
3104
  };
3160
3105
  HttpxRequest = {
3161
3106
  context: this,
@@ -3167,8 +3112,7 @@ var Utils = (function () {
3167
3112
  if (this.context.#defaultInitOption.logDetails) {
3168
3113
  console.log("[Httpx-HttpxRequest.request] 请求前的配置👇", details);
3169
3114
  }
3170
- if (typeof this.context.HttpxRequestHook.beforeRequestCallBack ===
3171
- "function") {
3115
+ if (typeof this.context.HttpxRequestHook.beforeRequestCallBack === "function") {
3172
3116
  let hookResult = await this.context.HttpxRequestHook.beforeRequestCallBack(details);
3173
3117
  if (hookResult == null) {
3174
3118
  return;
@@ -3205,15 +3149,12 @@ var Utils = (function () {
3205
3149
  isFetch: true,
3206
3150
  finalUrl: fetchResponse.url,
3207
3151
  readyState: 4,
3208
- // @ts-ignore
3209
3152
  status: fetchResponse.status,
3210
3153
  statusText: fetchResponse.statusText,
3211
- // @ts-ignore
3212
- response: void 0,
3154
+ response: "",
3213
3155
  responseFetchHeaders: fetchResponse.headers,
3214
3156
  responseHeaders: "",
3215
- // @ts-ignore
3216
- responseText: void 0,
3157
+ responseText: "",
3217
3158
  responseType: option.responseType,
3218
3159
  responseXML: void 0,
3219
3160
  };
@@ -3227,9 +3168,7 @@ var Utils = (function () {
3227
3168
  /* 如果需要stream,且获取到的是stream,那直接返回 */
3228
3169
  if (option.responseType === "stream" ||
3229
3170
  (fetchResponse.headers.has("Content-Type") &&
3230
- fetchResponse.headers
3231
- .get("Content-Type")
3232
- .includes("text/event-stream"))) {
3171
+ fetchResponse.headers.get("Content-Type").includes("text/event-stream"))) {
3233
3172
  Reflect.set(httpxResponse, "isStream", true);
3234
3173
  Reflect.set(httpxResponse, "response", fetchResponse.body);
3235
3174
  Reflect.deleteProperty(httpxResponse, "responseText");
@@ -3248,9 +3187,7 @@ var Utils = (function () {
3248
3187
  /** 数据编码 */
3249
3188
  let encoding = "utf-8";
3250
3189
  if (fetchResponse.headers.has("Content-Type")) {
3251
- let charsetMatched = fetchResponse.headers
3252
- .get("Content-Type")
3253
- ?.match(/charset=(.+)/);
3190
+ let charsetMatched = fetchResponse.headers.get("Content-Type")?.match(/charset=(.+)/);
3254
3191
  if (charsetMatched) {
3255
3192
  encoding = charsetMatched[1];
3256
3193
  encoding = encoding.toLowerCase();
@@ -3272,13 +3209,11 @@ var Utils = (function () {
3272
3209
  response = new Blob([arrayBuffer]);
3273
3210
  }
3274
3211
  else if (option.responseType === "json" ||
3275
- (typeof fetchResponseType === "string" &&
3276
- fetchResponseType.includes("application/json"))) {
3212
+ (typeof fetchResponseType === "string" && fetchResponseType.includes("application/json"))) {
3277
3213
  // response返回格式是JSON格式
3278
3214
  response = commonUtil.toJSON(responseText);
3279
3215
  }
3280
- else if (option.responseType === "document" ||
3281
- option.responseType == null) {
3216
+ else if (option.responseType === "document" || option.responseType == null) {
3282
3217
  // response返回格式是文档格式
3283
3218
  let parser = new DOMParser();
3284
3219
  response = parser.parseFromString(responseText, "text/html");
@@ -3286,9 +3221,9 @@ var Utils = (function () {
3286
3221
  // 转为XML结构
3287
3222
  let parser = new DOMParser();
3288
3223
  responseXML = parser.parseFromString(responseText, "text/xml");
3289
- Reflect.set(httpxResponse, "response", response);
3290
- Reflect.set(httpxResponse, "responseText", responseText);
3291
- Reflect.set(httpxResponse, "responseXML", responseXML);
3224
+ httpxResponse.response = response;
3225
+ httpxResponse.responseText = responseText;
3226
+ httpxResponse.responseXML = responseXML;
3292
3227
  // 执行回调
3293
3228
  option.onload(httpxResponse);
3294
3229
  })
@@ -3469,7 +3404,7 @@ var Utils = (function () {
3469
3404
  }
3470
3405
  /**
3471
3406
  * GET 请求
3472
- * @param url 网址
3407
+ * @param url 请求的url
3473
3408
  * @param details 配置
3474
3409
  */
3475
3410
  get(...args) {
@@ -3535,27 +3470,21 @@ var Utils = (function () {
3535
3470
  /** 取消请求 */
3536
3471
  let abortFn = null;
3537
3472
  let promise = new globalThis.Promise(async (resolve, reject) => {
3538
- let requestOption = this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject);
3473
+ let requestOption = (this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject));
3539
3474
  if (typeof beforeRequestOption === "function") {
3540
- // @ts-ignore
3541
3475
  beforeRequestOption(requestOption);
3542
3476
  }
3543
- // @ts-ignore
3544
- requestOption =
3545
- this.HttpxRequestOption.removeRequestNullOption(requestOption);
3477
+ requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
3546
3478
  const requestResult = await this.HttpxRequest.request(requestOption);
3547
- if (requestResult != null &&
3548
- typeof requestResult.abort === "function") {
3479
+ if (requestResult != null && typeof requestResult.abort === "function") {
3549
3480
  abortFn = requestResult.abort;
3550
3481
  }
3551
3482
  });
3552
- // @ts-ignore
3553
3483
  promise.abort = () => {
3554
3484
  if (typeof abortFn === "function") {
3555
3485
  abortFn();
3556
3486
  }
3557
3487
  };
3558
- // @ts-ignore
3559
3488
  return promise;
3560
3489
  }
3561
3490
  }
@@ -3565,8 +3494,7 @@ var Utils = (function () {
3565
3494
  #storeName;
3566
3495
  #dbVersion;
3567
3496
  /* websql的版本号,由于ios的问题,版本号的写法不一样 */
3568
- // @ts-ignore
3569
- #slqVersion = "1";
3497
+ // #slqVersion = "1";
3570
3498
  /* 监听IndexDB */
3571
3499
  #indexedDB = window.indexedDB ||
3572
3500
  window.mozIndexedDB ||
@@ -3574,8 +3502,7 @@ var Utils = (function () {
3574
3502
  window.msIndexedDB;
3575
3503
  /* 缓存数据库,避免同一个页面重复创建和销毁 */
3576
3504
  #db = {};
3577
- // @ts-ignore
3578
- #store = null;
3505
+ // #store: IDBObjectStore = null as any;
3579
3506
  /** 状态码 */
3580
3507
  #statusCode = {
3581
3508
  operationSuccess: {
@@ -3620,7 +3547,7 @@ var Utils = (function () {
3620
3547
  txn = this.#db[dbName].transaction(this.#storeName, "readwrite");
3621
3548
  /* IndexDB的读写权限 */
3622
3549
  store = txn.objectStore(this.#storeName);
3623
- this.#store = store;
3550
+ // this.#store = store;
3624
3551
  return store;
3625
3552
  }
3626
3553
  /**
@@ -4040,8 +3967,7 @@ var Utils = (function () {
4040
3967
  if (typeof __GM_info === "string") {
4041
3968
  this.tag = __GM_info;
4042
3969
  }
4043
- else if (typeof __GM_info === "object" &&
4044
- typeof __GM_info?.script?.name === "string") {
3970
+ else if (typeof __GM_info === "object" && typeof __GM_info?.script?.name === "string") {
4045
3971
  this.tag = __GM_info.script.name;
4046
3972
  }
4047
3973
  this.#console = console;
@@ -4097,8 +4023,7 @@ var Utils = (function () {
4097
4023
  */
4098
4024
  checkClearConsole() {
4099
4025
  this.#logCount++;
4100
- if (this.#details.autoClearConsole &&
4101
- this.#logCount > this.#details.logMaxCount) {
4026
+ if (this.#details.autoClearConsole && this.#logCount > this.#details.logMaxCount) {
4102
4027
  this.#console.clear();
4103
4028
  this.#logCount = 0;
4104
4029
  }
@@ -4345,12 +4270,40 @@ var Utils = (function () {
4345
4270
  }
4346
4271
 
4347
4272
  class UtilsDictionary {
4348
- items = {};
4273
+ items;
4349
4274
  constructor(key, value) {
4275
+ this.items = {};
4350
4276
  if (key != null) {
4351
4277
  this.set(key, value);
4352
4278
  }
4353
4279
  }
4280
+ /**
4281
+ * 获取字典的长度,同this.size
4282
+ */
4283
+ get length() {
4284
+ return this.size();
4285
+ }
4286
+ /**
4287
+ * 迭代器
4288
+ */
4289
+ get entries() {
4290
+ let that = this;
4291
+ return function* () {
4292
+ let itemKeys = Object.keys(that.getItems());
4293
+ for (const keyName of itemKeys) {
4294
+ yield [keyName, that.get(keyName)];
4295
+ }
4296
+ };
4297
+ }
4298
+ /**
4299
+ * 是否可遍历
4300
+ */
4301
+ get [Symbol.iterator]() {
4302
+ let that = this;
4303
+ return function () {
4304
+ return that.entries();
4305
+ };
4306
+ }
4354
4307
  /**
4355
4308
  * 检查是否有某一个键
4356
4309
  * @param key 键
@@ -4451,7 +4404,6 @@ var Utils = (function () {
4451
4404
  * 返回字典本身
4452
4405
  */
4453
4406
  getItems() {
4454
- // @ts-ignore
4455
4407
  return this.items;
4456
4408
  }
4457
4409
  /**
@@ -4461,38 +4413,15 @@ var Utils = (function () {
4461
4413
  concat(data) {
4462
4414
  this.items = commonUtil.assign(this.items, data.getItems());
4463
4415
  }
4416
+ /**
4417
+ * 迭代字典
4418
+ * @param callbackfn 回调函数
4419
+ */
4464
4420
  forEach(callbackfn) {
4465
4421
  for (const key in this.getItems()) {
4466
4422
  callbackfn(this.get(key), key, this.getItems());
4467
4423
  }
4468
4424
  }
4469
- /**
4470
- * 获取字典的长度,同this.size
4471
- */
4472
- get length() {
4473
- return this.size();
4474
- }
4475
- /**
4476
- * 迭代器
4477
- */
4478
- get entries() {
4479
- let that = this;
4480
- return function* () {
4481
- let itemKeys = Object.keys(that.getItems());
4482
- for (const keyName of itemKeys) {
4483
- yield [keyName, that.get(keyName)];
4484
- }
4485
- };
4486
- }
4487
- /**
4488
- * 是否可遍历
4489
- */
4490
- get [Symbol.iterator]() {
4491
- let that = this;
4492
- return function () {
4493
- return that.entries();
4494
- };
4495
- }
4496
4425
  }
4497
4426
 
4498
4427
  class WindowApi {
@@ -4518,7 +4447,6 @@ var Utils = (function () {
4518
4447
  if (!option) {
4519
4448
  option = Object.assign({}, this.defaultApi);
4520
4449
  }
4521
- // @ts-ignore
4522
4450
  this.api = Object.assign({}, option);
4523
4451
  }
4524
4452
  get document() {
@@ -4576,11 +4504,10 @@ var Utils = (function () {
4576
4504
  deps = [];
4577
4505
  active = true;
4578
4506
  fn;
4579
- // @ts-ignore
4580
- scheduler;
4507
+ // private scheduler;
4581
4508
  constructor(fn, scheduler) {
4582
4509
  this.fn = fn;
4583
- this.scheduler = scheduler;
4510
+ // this.scheduler = scheduler;
4584
4511
  }
4585
4512
  run(cb) {
4586
4513
  if (!this.active) {
@@ -4647,8 +4574,7 @@ var Utils = (function () {
4647
4574
  reactive(target) {
4648
4575
  const that = this;
4649
4576
  if (!(typeof target === "object" && target !== null)) {
4650
- // @ts-ignore
4651
- return;
4577
+ return void 0;
4652
4578
  }
4653
4579
  if (VueUtils.isReactive(target)) {
4654
4580
  return target;
@@ -4718,7 +4644,6 @@ var Utils = (function () {
4718
4644
  toRefs(object) {
4719
4645
  const result = VueUtils.isArray(object) ? new Array(object.length) : {};
4720
4646
  for (let key in object) {
4721
- // @ts-ignore
4722
4647
  result[key] = this.toRef(object, key);
4723
4648
  }
4724
4649
  return result;
@@ -5014,7 +4939,7 @@ var Utils = (function () {
5014
4939
  };
5015
4940
 
5016
4941
  // This is the minified and stringified code of the worker-timers-worker package.
5017
- const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),d=t(c);e.addUniqueNumber=d,e.generateUniqueNumber=c}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async({data:{id:a,method:i,params:u}})=>{const c=r[i];try{if(void 0===c)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===u?c():c(u);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const d=r instanceof Promise?await r:r;if(null===a){if(void 0!==d.result)throw s(i)}else{if(void 0===d.result)throw s(i);const{result:e,transferables:r=[]}=d;t.postMessage({id:a,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:a})}};var i=r(455);const u=new Map,c=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),o=(0,i.generateUniqueNumber)(u);return u.set(o,(()=>{n(),t.close(),u.delete(o)})),{result:o}},disconnect:({portId:e})=>{const r=u.get(e);if(void 0===r)throw(e=>o('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(e);return r(),{result:null}},isSupported:async()=>{if(await new Promise((e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])}))){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),d=(e,t,r=()=>!0)=>{const n=c(d,t,r),o=a(e,n);return e.addEventListener("message",o),()=>e.removeEventListener("message",o)},l=e=>t=>{const r=e.get(t);if(void 0===r)return Promise.resolve(!1);const[n,o]=r;return clearTimeout(n),e.delete(t),o(!1),Promise.resolve(!0)},f=(e,t,r)=>(n,o,s)=>{const{expected:a,remainingDelay:i}=e(n,o);return new Promise((e=>{t.set(s,[setTimeout(r,i,a,t,e,s),e])}))},m=(e,t)=>{const r=performance.now(),n=e+t-r-performance.timeOrigin;return{expected:r+n,remainingDelay:n}},p=(e,t,r,n)=>{const o=e-performance.now();o>0?t.set(n,[setTimeout(p,o,e,t,r,n),r]):(t.delete(n),r(!0))},h=new Map,v=l(h),w=new Map,g=l(w),M=f(m,h,p),y=f(m,w,p);d(self,{clear:async({timerId:e,timerType:t})=>({result:await("interval"===t?v(e):g(e))}),set:async({delay:e,now:t,timerId:r,timerType:n})=>({result:await("interval"===n?M:y)(e,t,r)})})})()})();`; // tslint:disable-line:max-line-length
4942
+ const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),l=t(c);e.addUniqueNumber=l,e.generateUniqueNumber=c}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async({data:{id:a,method:i,params:u}})=>{const c=r[i];try{if(void 0===c)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===u?c():c(u);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const l=r instanceof Promise?await r:r;if(null===a){if(void 0!==l.result)throw s(i)}else{if(void 0===l.result)throw s(i);const{result:e,transferables:r=[]}=l;t.postMessage({id:a,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:a})}};var i=r(455);const u=new Map,c=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),o=(0,i.generateUniqueNumber)(u);return u.set(o,(()=>{n(),t.close(),u.delete(o)})),{result:o}},disconnect:({portId:e})=>{const r=u.get(e);if(void 0===r)throw(e=>o('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(e);return r(),{result:null}},isSupported:async()=>{if(await new Promise((e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])}))){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),l=(e,t,r=()=>!0)=>{const n=c(l,t,r),o=a(e,n);return e.addEventListener("message",o),()=>e.removeEventListener("message",o)},d=(e,t)=>r=>{const n=t.get(r);if(void 0===n)return Promise.resolve(!1);const[o,s]=n;return e(o),t.delete(r),s(!1),Promise.resolve(!0)},f=(e,t,r,n)=>(o,s,a)=>{const i=o+s-t.timeOrigin,u=i-t.now();return new Promise((t=>{e.set(a,[r(n,u,i,e,t,a),t])}))},m=new Map,h=d(globalThis.clearTimeout,m),p=new Map,v=d(globalThis.clearTimeout,p),w=((e,t)=>{const r=(n,o,s,a)=>{const i=n-e.now();i>0?o.set(a,[t(r,i,n,o,s,a),s]):(o.delete(a),s(!0))};return r})(performance,globalThis.setTimeout),g=f(m,performance,globalThis.setTimeout,w),T=f(p,performance,globalThis.setTimeout,w);l(self,{clear:async({timerId:e,timerType:t})=>({result:await("interval"===t?h(e):v(e))}),set:async({delay:e,now:t,timerId:r,timerType:n})=>({result:await("interval"===n?g:T)(e,t,r)})})})()})();`; // tslint:disable-line:max-line-length
5018
4943
 
5019
4944
  const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
5020
4945
  const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
@@ -5446,7 +5371,6 @@ var Utils = (function () {
5446
5371
  let text = textMatch[2];
5447
5372
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
5448
5373
  return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
5449
- // @ts-ignore
5450
5374
  return ($ele?.textContent || $ele?.innerText)?.includes(text);
5451
5375
  });
5452
5376
  }
@@ -5464,7 +5388,6 @@ var Utils = (function () {
5464
5388
  let regexp = new RegExp(pattern, flags);
5465
5389
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
5466
5390
  return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
5467
- // @ts-ignore
5468
5391
  return Boolean(($ele?.textContent || $ele?.innerText)?.match(regexp));
5469
5392
  });
5470
5393
  }
@@ -5510,7 +5433,6 @@ var Utils = (function () {
5510
5433
  let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
5511
5434
  let text = textMatch[2];
5512
5435
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
5513
- // @ts-ignore
5514
5436
  let content = $el?.textContent || $el?.innerText;
5515
5437
  if (typeof content !== "string") {
5516
5438
  content = "";
@@ -5530,7 +5452,6 @@ var Utils = (function () {
5530
5452
  }
5531
5453
  let regexp = new RegExp(pattern, flags);
5532
5454
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
5533
- // @ts-ignore
5534
5455
  let content = $el?.textContent || $el?.innerText;
5535
5456
  if (typeof content !== "string") {
5536
5457
  content = "";
@@ -5561,7 +5482,6 @@ var Utils = (function () {
5561
5482
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
5562
5483
  let $closest = $el?.closest(selector);
5563
5484
  if ($closest) {
5564
- // @ts-ignore
5565
5485
  let content = $el?.textContent || $el?.innerText;
5566
5486
  if (typeof content === "string" && content.includes(text)) {
5567
5487
  return $closest;
@@ -5584,7 +5504,6 @@ var Utils = (function () {
5584
5504
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
5585
5505
  let $closest = $el?.closest(selector);
5586
5506
  if ($closest) {
5587
- // @ts-ignore
5588
5507
  let content = $el?.textContent || $el?.innerText;
5589
5508
  if (typeof content === "string" && content.match(regexp)) {
5590
5509
  return $closest;
@@ -5607,7 +5526,7 @@ var Utils = (function () {
5607
5526
  this.windowApi = new WindowApi(option);
5608
5527
  }
5609
5528
  /** 版本号 */
5610
- version = "2025.7.29";
5529
+ version = "2025.8.11";
5611
5530
  addStyle(cssText) {
5612
5531
  if (typeof cssText !== "string") {
5613
5532
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");
@@ -5704,7 +5623,7 @@ var Utils = (function () {
5704
5623
  return ajaxHooker();
5705
5624
  }
5706
5625
  };
5707
- canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = globalThis) {
5626
+ canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = this.windowApi.window) {
5708
5627
  if (!(canvasElement instanceof HTMLCanvasElement)) {
5709
5628
  throw new Error("Utils.canvasClickByPosition 参数canvasElement必须是canvas元素");
5710
5629
  }
@@ -5715,7 +5634,6 @@ var Utils = (function () {
5715
5634
  cancelable: true,
5716
5635
  clientX: clientX,
5717
5636
  clientY: clientY,
5718
- // @ts-ignore
5719
5637
  view: view,
5720
5638
  detail: 1,
5721
5639
  };
@@ -5731,13 +5649,9 @@ var Utils = (function () {
5731
5649
  let touchEvent = UtilsContext.windowApi.window.event;
5732
5650
  let $click = clickEvent?.composedPath()?.[0];
5733
5651
  // 点击的x坐标
5734
- let clickPosX = clickEvent?.clientX != null
5735
- ? clickEvent.clientX
5736
- : touchEvent.touches[0].clientX;
5652
+ let clickPosX = clickEvent?.clientX != null ? clickEvent.clientX : touchEvent.touches[0].clientX;
5737
5653
  // 点击的y坐标
5738
- let clickPosY = clickEvent?.clientY != null
5739
- ? clickEvent.clientY
5740
- : touchEvent.touches[0].clientY;
5654
+ let clickPosY = clickEvent?.clientY != null ? clickEvent.clientY : touchEvent.touches[0].clientY;
5741
5655
  let {
5742
5656
  /* 要检测的元素的相对屏幕的横坐标最左边 */
5743
5657
  left: elementPosXLeft,
@@ -5900,9 +5814,7 @@ var Utils = (function () {
5900
5814
  /* CODE FOR BROWSERS THAT SUPPORT window.find */
5901
5815
  let windowFind = this.windowApi.self.find;
5902
5816
  strFound = windowFind(str, caseSensitive, true, true, false);
5903
- if (strFound &&
5904
- this.windowApi.self.getSelection &&
5905
- !this.windowApi.self.getSelection().anchorNode) {
5817
+ if (strFound && this.windowApi.self.getSelection && !this.windowApi.self.getSelection().anchorNode) {
5906
5818
  strFound = windowFind(str, caseSensitive, true, true, false);
5907
5819
  }
5908
5820
  if (!strFound) {
@@ -6005,9 +5917,7 @@ var Utils = (function () {
6005
5917
  }
6006
5918
  }
6007
5919
  result = result.toFixed(2);
6008
- result = addType
6009
- ? result + resultType.toString()
6010
- : parseFloat(result.toString());
5920
+ result = addType ? result + resultType.toString() : parseFloat(result.toString());
6011
5921
  return result;
6012
5922
  }
6013
5923
  getNodeListValue(...args) {
@@ -6086,14 +5996,7 @@ var Utils = (function () {
6086
5996
  if (text.length === 8) {
6087
5997
  /* 该字符串只有时分秒 */
6088
5998
  let today = new Date();
6089
- text =
6090
- today.getFullYear() +
6091
- "-" +
6092
- (today.getMonth() + 1) +
6093
- "-" +
6094
- today.getDate() +
6095
- " " +
6096
- text;
5999
+ text = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate() + " " + text;
6097
6000
  }
6098
6001
  text = text.substring(0, 19);
6099
6002
  text = text.replace(/-/g, "/");
@@ -6114,25 +6017,13 @@ var Utils = (function () {
6114
6017
  * 获取 transitionend 的在各个浏览器的兼容名
6115
6018
  */
6116
6019
  getTransitionEndNameList() {
6117
- return [
6118
- "webkitTransitionEnd",
6119
- "mozTransitionEnd",
6120
- "MSTransitionEnd",
6121
- "otransitionend",
6122
- "transitionend",
6123
- ];
6020
+ return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
6124
6021
  }
6125
6022
  /**
6126
6023
  * 获取 animationend 的在各个浏览器的兼容名
6127
6024
  */
6128
6025
  getAnimationEndNameList() {
6129
- return [
6130
- "webkitAnimationEnd",
6131
- "mozAnimationEnd",
6132
- "MSAnimationEnd",
6133
- "oanimationend",
6134
- "animationend",
6135
- ];
6026
+ return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
6136
6027
  }
6137
6028
  getArrayLastValue(targetObj) {
6138
6029
  return targetObj[targetObj.length - 1];
@@ -6222,12 +6113,10 @@ var Utils = (function () {
6222
6113
  }
6223
6114
  getElementSelector(element) {
6224
6115
  let UtilsContext = this;
6225
- // @ts-ignore
6226
6116
  if (!element)
6227
- return;
6228
- // @ts-ignore
6117
+ return void 0;
6229
6118
  if (!element.parentElement)
6230
- return;
6119
+ return void 0;
6231
6120
  /* 如果元素有id属性,则直接返回id选择器 */
6232
6121
  if (element.id)
6233
6122
  return "#" + element.id;
@@ -6238,10 +6127,8 @@ var Utils = (function () {
6238
6127
  }
6239
6128
  /* 如果有多个相同类型的兄弟元素,则需要添加索引 */
6240
6129
  if (element.parentElement.querySelectorAll(element.tagName).length > 1) {
6241
- let index = Array.prototype.indexOf.call(element.parentElement.children, element) +
6242
- 1;
6243
- selector +=
6244
- " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
6130
+ let index = Array.prototype.indexOf.call(element.parentElement.children, element) + 1;
6131
+ selector += " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
6245
6132
  }
6246
6133
  else {
6247
6134
  selector += " > " + element.tagName.toLowerCase();
@@ -6258,13 +6145,10 @@ var Utils = (function () {
6258
6145
  let result = [...args];
6259
6146
  let newResult = [];
6260
6147
  if (result.length === 0) {
6261
- // @ts-ignore
6262
- return;
6148
+ return void 0;
6263
6149
  }
6264
6150
  if (result.length > 1) {
6265
- if (result.length === 2 &&
6266
- typeof result[0] === "object" &&
6267
- typeof result[1] === "function") {
6151
+ if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
6268
6152
  let data = result[0];
6269
6153
  let handleDataFunc = result[1];
6270
6154
  Object.keys(data).forEach((keyName) => {
@@ -6299,7 +6183,6 @@ var Utils = (function () {
6299
6183
  // 当前页面最大的z-index
6300
6184
  let zIndex = 0;
6301
6185
  // 当前的最大z-index的元素,调试使用
6302
- // @ts-ignore
6303
6186
  let maxZIndexNode = null;
6304
6187
  /**
6305
6188
  * 元素是否可见
@@ -6360,13 +6243,10 @@ var Utils = (function () {
6360
6243
  let result = [...args];
6361
6244
  let newResult = [];
6362
6245
  if (result.length === 0) {
6363
- // @ts-ignore
6364
- return;
6246
+ return void 0;
6365
6247
  }
6366
6248
  if (result.length > 1) {
6367
- if (result.length === 2 &&
6368
- typeof result[0] === "object" &&
6369
- typeof result[1] === "function") {
6249
+ if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
6370
6250
  let data = result[0];
6371
6251
  let handleDataFunc = result[1];
6372
6252
  Object.keys(data).forEach((keyName) => {
@@ -6456,12 +6336,10 @@ var Utils = (function () {
6456
6336
  getRandomValue(...args) {
6457
6337
  let result = [...args];
6458
6338
  if (result.length > 1) {
6459
- if (result.length === 2 &&
6460
- typeof result[0] === "number" &&
6461
- typeof result[1] === "number") {
6339
+ if (result.length === 2 && typeof result[0] === "number" && typeof result[1] === "number") {
6462
6340
  let leftNumber = result[0] > result[1] ? result[1] : result[0];
6463
6341
  let rightNumber = result[0] > result[1] ? result[0] : result[1];
6464
- return (Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber);
6342
+ return Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber;
6465
6343
  }
6466
6344
  else {
6467
6345
  return result[Math.floor(Math.random() * result.length)];
@@ -6472,8 +6350,7 @@ var Utils = (function () {
6472
6350
  if (Array.isArray(paramData)) {
6473
6351
  return paramData[Math.floor(Math.random() * paramData.length)];
6474
6352
  }
6475
- else if (typeof paramData === "object" &&
6476
- Object.keys(paramData).length > 0) {
6353
+ else if (typeof paramData === "object" && Object.keys(paramData).length > 0) {
6477
6354
  let paramObjDataKey = Object.keys(paramData)[Math.floor(Math.random() * Object.keys(paramData).length)];
6478
6355
  return paramData[paramObjDataKey];
6479
6356
  }
@@ -6780,11 +6657,9 @@ var Utils = (function () {
6780
6657
  let nearBottomHeight = 50;
6781
6658
  let checkWindow = () => {
6782
6659
  // 已滚动的距离
6783
- let scrollTop = this.windowApi.window.pageYOffset ||
6784
- this.windowApi.document.documentElement.scrollTop;
6660
+ let scrollTop = this.windowApi.window.pageYOffset || this.windowApi.document.documentElement.scrollTop;
6785
6661
  // 视窗高度
6786
- let viewportHeight = this.windowApi.window.innerHeight ||
6787
- this.windowApi.document.documentElement.clientHeight;
6662
+ let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
6788
6663
  // 最大滚动距离
6789
6664
  let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
6790
6665
  return scrollTop + viewportHeight >= maxScrollHeight;
@@ -6835,7 +6710,6 @@ var Utils = (function () {
6835
6710
  }
6836
6711
  isJQuery(target) {
6837
6712
  let result = false;
6838
- // @ts-ignore
6839
6713
  if (typeof jQuery === "object" && target instanceof jQuery) {
6840
6714
  result = true;
6841
6715
  }
@@ -7074,8 +6948,7 @@ var Utils = (function () {
7074
6948
  **/
7075
6949
  isNull = commonUtil.isNull.bind(commonUtil);
7076
6950
  isThemeDark() {
7077
- return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)")
7078
- .matches;
6951
+ return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
7079
6952
  }
7080
6953
  /**
7081
6954
  * 判断元素是否在页面中可见
@@ -7108,10 +6981,8 @@ var Utils = (function () {
7108
6981
  else {
7109
6982
  let domClientRect = domItem.getBoundingClientRect();
7110
6983
  if (inView) {
7111
- let viewportWidth = this.windowApi.window.innerWidth ||
7112
- this.windowApi.document.documentElement.clientWidth;
7113
- let viewportHeight = this.windowApi.window.innerHeight ||
7114
- this.windowApi.document.documentElement.clientHeight;
6984
+ let viewportWidth = this.windowApi.window.innerWidth || this.windowApi.document.documentElement.clientWidth;
6985
+ let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
7115
6986
  result = !(domClientRect.right < 0 ||
7116
6987
  domClientRect.left > viewportWidth ||
7117
6988
  domClientRect.bottom < 0 ||
@@ -7135,8 +7006,7 @@ var Utils = (function () {
7135
7006
  for (const key in Object.values(this.windowApi.top.window.via)) {
7136
7007
  if (Reflect.has(this.windowApi.top.window.via, key)) {
7137
7008
  let objValueFunc = this.windowApi.top.window.via[key];
7138
- if (typeof objValueFunc === "function" &&
7139
- UtilsContext.isNativeFunc(objValueFunc)) {
7009
+ if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
7140
7010
  result = true;
7141
7011
  }
7142
7012
  else {
@@ -7158,8 +7028,7 @@ var Utils = (function () {
7158
7028
  for (const key in Object.values(this.windowApi.top.window.mbrowser)) {
7159
7029
  if (Reflect.has(this.windowApi.top.window.mbrowser, key)) {
7160
7030
  let objValueFunc = this.windowApi.top.window.mbrowser[key];
7161
- if (typeof objValueFunc === "function" &&
7162
- UtilsContext.isNativeFunc(objValueFunc)) {
7031
+ if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
7163
7032
  result = true;
7164
7033
  }
7165
7034
  else {
@@ -7396,13 +7265,11 @@ var Utils = (function () {
7396
7265
  * 释放所有
7397
7266
  */
7398
7267
  function releaseAll() {
7399
- if (typeof UtilsContext.windowApi.window[needReleaseKey] !==
7400
- "undefined") {
7268
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] !== "undefined") {
7401
7269
  /* 已存在 */
7402
7270
  return;
7403
7271
  }
7404
- UtilsContext.windowApi.window[needReleaseKey] =
7405
- UtilsContext.deepClone(needReleaseObject);
7272
+ UtilsContext.windowApi.window[needReleaseKey] = UtilsContext.deepClone(needReleaseObject);
7406
7273
  Object.values(needReleaseObject).forEach((value) => {
7407
7274
  if (typeof value === "function") {
7408
7275
  needReleaseObject[value.name] = () => { };
@@ -7416,8 +7283,7 @@ var Utils = (function () {
7416
7283
  Array.from(functionNameList).forEach((item) => {
7417
7284
  Object.values(needReleaseObject).forEach((value) => {
7418
7285
  if (typeof value === "function") {
7419
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7420
- "undefined") {
7286
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7421
7287
  UtilsContext.windowApi.window[needReleaseKey] = {};
7422
7288
  }
7423
7289
  if (item === value.name) {
@@ -7432,8 +7298,7 @@ var Utils = (function () {
7432
7298
  * 恢复所有
7433
7299
  */
7434
7300
  function recoveryAll() {
7435
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7436
- "undefined") {
7301
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7437
7302
  /* 未存在 */
7438
7303
  return;
7439
7304
  }
@@ -7444,8 +7309,7 @@ var Utils = (function () {
7444
7309
  * 恢复单个
7445
7310
  */
7446
7311
  function recoveryOne() {
7447
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7448
- "undefined") {
7312
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7449
7313
  /* 未存在 */
7450
7314
  return;
7451
7315
  }
@@ -7453,8 +7317,7 @@ var Utils = (function () {
7453
7317
  if (UtilsContext.windowApi.window[needReleaseKey][item]) {
7454
7318
  needReleaseObject[item] = UtilsContext.windowApi.window[needReleaseKey][item];
7455
7319
  Reflect.deleteProperty(UtilsContext.windowApi.window[needReleaseKey], item);
7456
- if (Object.keys(UtilsContext.windowApi.window[needReleaseKey])
7457
- .length === 0) {
7320
+ if (Object.keys(UtilsContext.windowApi.window[needReleaseKey]).length === 0) {
7458
7321
  Reflect.deleteProperty(window, needReleaseKey);
7459
7322
  }
7460
7323
  }
@@ -7616,29 +7479,27 @@ var Utils = (function () {
7616
7479
  EventTarget.prototype.addEventListener = function (...args) {
7617
7480
  let type = args[0];
7618
7481
  let callback = args[1];
7619
- // @ts-ignore
7620
- args[2];
7482
+ // let options = args[2];
7621
7483
  if (filter(type)) {
7622
7484
  if (typeof callback === "function") {
7623
7485
  args[1] = function (event) {
7624
7486
  callback.call(this, trustEvent(event));
7625
7487
  };
7626
7488
  }
7627
- else if (typeof callback === "object" &&
7628
- "handleEvent" in callback) {
7489
+ else if (typeof callback === "object" && "handleEvent" in callback) {
7629
7490
  let oldHandleEvent = callback["handleEvent"];
7630
7491
  args[1]["handleEvent"] = function (event) {
7631
7492
  if (event == null) {
7632
7493
  return;
7633
7494
  }
7634
7495
  try {
7635
- /* Proxy对象使用instanceof会报错 */
7496
+ // Proxy对象使用instanceof会报错
7497
+ // 这里故意尝试一下,如果报错,则说明是Proxy对象
7636
7498
  event instanceof Proxy;
7637
7499
  oldHandleEvent.call(this, trustEvent(event));
7638
7500
  }
7639
7501
  catch (error) {
7640
- // @ts-ignore
7641
- event["isTrusted"] = isTrustValue;
7502
+ Reflect.set(event, "isTrusted", isTrustValue);
7642
7503
  }
7643
7504
  };
7644
7505
  }
@@ -7711,10 +7572,9 @@ var Utils = (function () {
7711
7572
  }
7712
7573
  async init() {
7713
7574
  let copyStatus = false;
7714
- // @ts-ignore
7715
- await this.requestClipboardPermission();
7716
- if (this.hasClipboard() &&
7717
- (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
7575
+ let requestPermissionStatus = await this.requestClipboardPermission();
7576
+ console.log(requestPermissionStatus);
7577
+ if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
7718
7578
  try {
7719
7579
  copyStatus = await this.copyDataByClipboard();
7720
7580
  }
@@ -7730,11 +7590,8 @@ var Utils = (function () {
7730
7590
  this.destroy();
7731
7591
  }
7732
7592
  destroy() {
7733
- // @ts-ignore
7734
7593
  this.#resolve = null;
7735
- // @ts-ignore
7736
7594
  this.#copyData = null;
7737
- // @ts-ignore
7738
7595
  this.#copyDataType = null;
7739
7596
  }
7740
7597
  isText() {
@@ -7778,7 +7635,6 @@ var Utils = (function () {
7778
7635
  if (navigator.permissions && navigator.permissions.query) {
7779
7636
  navigator.permissions
7780
7637
  .query({
7781
- // @ts-ignore
7782
7638
  name: "clipboard-write",
7783
7639
  })
7784
7640
  .then((permissionStatus) => {
@@ -7874,17 +7730,13 @@ var Utils = (function () {
7874
7730
  dragSlider(selector, offsetX = this.windowApi.window.innerWidth) {
7875
7731
  let UtilsContext = this;
7876
7732
  function initMouseEvent(eventName, offSetX, offSetY) {
7877
- // @ts-ignore
7878
7733
  let win = typeof unsafeWindow === "undefined" ? globalThis : unsafeWindow;
7879
7734
  let mouseEvent = UtilsContext.windowApi.document.createEvent("MouseEvents");
7880
7735
  mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
7881
7736
  return mouseEvent;
7882
7737
  }
7883
- let sliderElement = typeof selector === "string"
7884
- ? domUtils.selector(selector)
7885
- : selector;
7886
- if (!(sliderElement instanceof Node) ||
7887
- !(sliderElement instanceof Element)) {
7738
+ let sliderElement = typeof selector === "string" ? domUtils.selector(selector) : selector;
7739
+ if (!(sliderElement instanceof Node) || !(sliderElement instanceof Element)) {
7888
7740
  throw new Error("Utils.dragSlider 参数selector 必须为Node/Element类型");
7889
7741
  }
7890
7742
  let rect = sliderElement.getBoundingClientRect(), x0 = rect.x || rect.left, y0 = rect.y || rect.top, x1 = x0 + offsetX, y1 = y0;
@@ -7936,17 +7788,14 @@ var Utils = (function () {
7936
7788
  }
7937
7789
  sortListByProperty(data, getPropertyValueFunc, sortByDesc = true) {
7938
7790
  let UtilsContext = this;
7939
- if (typeof getPropertyValueFunc !== "function" &&
7940
- typeof getPropertyValueFunc !== "string") {
7791
+ if (typeof getPropertyValueFunc !== "function" && typeof getPropertyValueFunc !== "string") {
7941
7792
  throw new Error("Utils.sortListByProperty 参数 getPropertyValueFunc 必须为 function|string 类型");
7942
7793
  }
7943
7794
  if (typeof sortByDesc !== "boolean") {
7944
7795
  throw new Error("Utils.sortListByProperty 参数 sortByDesc 必须为 boolean 类型");
7945
7796
  }
7946
7797
  let getObjValue = function (obj) {
7947
- return typeof getPropertyValueFunc === "string"
7948
- ? obj[getPropertyValueFunc]
7949
- : getPropertyValueFunc(obj);
7798
+ return typeof getPropertyValueFunc === "string" ? obj[getPropertyValueFunc] : getPropertyValueFunc(obj);
7950
7799
  };
7951
7800
  /**
7952
7801
  * 排序方法
@@ -8021,8 +7870,7 @@ var Utils = (function () {
8021
7870
  if (Array.isArray(data)) {
8022
7871
  data.sort(sortFunc);
8023
7872
  }
8024
- else if (data instanceof NodeList ||
8025
- UtilsContext.isJQuery(data)) {
7873
+ else if (data instanceof NodeList || UtilsContext.isJQuery(data)) {
8026
7874
  sortNodeFunc(data, getDataFunc);
8027
7875
  result = getDataFunc();
8028
7876
  }
@@ -8033,7 +7881,6 @@ var Utils = (function () {
8033
7881
  }
8034
7882
  stringToRegular(targetString, flags = "ig") {
8035
7883
  let reg;
8036
- // @ts-ignore
8037
7884
  flags = flags.toLowerCase();
8038
7885
  if (typeof targetString === "string") {
8039
7886
  reg = new RegExp(targetString.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"), flags);
@@ -8126,10 +7973,8 @@ var Utils = (function () {
8126
7973
  */
8127
7974
  searchParamStrToObj(searhParamsStr) {
8128
7975
  if (typeof searhParamsStr !== "string") {
8129
- // @ts-ignore
8130
7976
  return {};
8131
7977
  }
8132
- // @ts-ignore
8133
7978
  return Object.fromEntries(new URLSearchParams(searhParamsStr));
8134
7979
  }
8135
7980
  /**
@@ -8218,9 +8063,7 @@ var Utils = (function () {
8218
8063
  let parent = UtilsContext.windowApi.document;
8219
8064
  // 超时时间
8220
8065
  let timeout = 0;
8221
- if (typeof args[0] !== "string" &&
8222
- !Array.isArray(args[0]) &&
8223
- typeof args[0] !== "function") {
8066
+ if (typeof args[0] !== "string" && !Array.isArray(args[0]) && typeof args[0] !== "function") {
8224
8067
  throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
8225
8068
  }
8226
8069
  if (args.length === 1) ;
@@ -8230,8 +8073,7 @@ var Utils = (function () {
8230
8073
  // "div",10000
8231
8074
  timeout = secondParam;
8232
8075
  }
8233
- else if (typeof secondParam === "object" &&
8234
- secondParam instanceof Node) {
8076
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8235
8077
  // "div",document
8236
8078
  parent = secondParam;
8237
8079
  }
@@ -8317,8 +8159,7 @@ var Utils = (function () {
8317
8159
  // "div",10000
8318
8160
  timeout = secondParam;
8319
8161
  }
8320
- else if (typeof secondParam === "object" &&
8321
- secondParam instanceof Node) {
8162
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8322
8163
  // "div",document
8323
8164
  parent = secondParam;
8324
8165
  }
@@ -8373,8 +8214,7 @@ var Utils = (function () {
8373
8214
  // "div",10000
8374
8215
  timeout = secondParam;
8375
8216
  }
8376
- else if (typeof secondParam === "object" &&
8377
- secondParam instanceof Node) {
8217
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8378
8218
  // "div",document
8379
8219
  parent = secondParam;
8380
8220
  }
@@ -8460,8 +8300,7 @@ var Utils = (function () {
8460
8300
  // "div",10000
8461
8301
  timeout = secondParam;
8462
8302
  }
8463
- else if (typeof secondParam === "object" &&
8464
- secondParam instanceof Node) {
8303
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8465
8304
  // "div",document
8466
8305
  parent = secondParam;
8467
8306
  }
@@ -8594,8 +8433,7 @@ var Utils = (function () {
8594
8433
  return flag;
8595
8434
  }
8596
8435
  watchObject(target, propertyName, getCallBack, setCallBack) {
8597
- if (typeof getCallBack !== "function" &&
8598
- typeof setCallBack !== "function") {
8436
+ if (typeof getCallBack !== "function" && typeof setCallBack !== "function") {
8599
8437
  return;
8600
8438
  }
8601
8439
  if (typeof getCallBack === "function") {
@@ -8647,13 +8485,27 @@ var Utils = (function () {
8647
8485
  return;
8648
8486
  }
8649
8487
  let handleResult = handler(target);
8650
- if (handleResult &&
8651
- typeof handleResult.isFind === "boolean" &&
8652
- handleResult.isFind) {
8488
+ if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
8653
8489
  return handleResult.data;
8654
8490
  }
8655
8491
  return this.queryProperty(handleResult.data, handler);
8656
8492
  }
8493
+ /**
8494
+ * 异步-深度获取对象属性
8495
+ * @param target 待获取的对象
8496
+ * @param handler 获取属性的回调
8497
+ */
8498
+ async asyncQueryProperty(target, handler) {
8499
+ if (target == null) {
8500
+ // @ts-ignore
8501
+ return;
8502
+ }
8503
+ let handleResult = await handler(target);
8504
+ if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
8505
+ return handleResult.data;
8506
+ }
8507
+ return await this.asyncQueryProperty(handleResult.data, handler);
8508
+ }
8657
8509
  /**
8658
8510
  * 创建一个新的Utils实例
8659
8511
  * @param option
@@ -8832,7 +8684,6 @@ var Utils = (function () {
8832
8684
  function requestPermissionsWithClipboard() {
8833
8685
  navigator.permissions
8834
8686
  .query({
8835
- // @ts-ignore
8836
8687
  name: "clipboard-read",
8837
8688
  })
8838
8689
  .then((permissionStatus) => {