@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
package/dist/index.esm.js CHANGED
@@ -15,14 +15,13 @@ class ColorConversion {
15
15
  /**
16
16
  * 16进制颜色转rgba
17
17
  *
18
- * #ff0000 rgba(123,123,123, 0.4)
18
+ * 例如:`#ff0000` 转为 `rgba(123,123,123, 0.4)`
19
19
  * @param hex
20
20
  * @param opacity
21
21
  */
22
22
  hexToRgba(hex, opacity) {
23
23
  if (!this.isHex(hex)) {
24
- // @ts-ignore
25
- throw new TypeError("输入错误的hex", hex);
24
+ throw new TypeError("输入错误的hex:" + hex);
26
25
  }
27
26
  return hex && hex.replace(/\s+/g, "").length === 7
28
27
  ? "rgba(" +
@@ -39,19 +38,16 @@ class ColorConversion {
39
38
  /**
40
39
  * hex转rgb
41
40
  * @param str
42
- * @returns
43
41
  */
44
42
  hexToRgb(str) {
45
43
  if (!this.isHex(str)) {
46
- // @ts-ignore
47
- throw new TypeError("输入错误的hex", str);
44
+ throw new TypeError("输入错误的hex:" + str);
48
45
  }
49
46
  /* replace替换查找的到的字符串 */
50
47
  str = str.replace("#", "");
51
48
  /* match得到查询数组 */
52
49
  let hxs = str.match(/../g);
53
50
  for (let index = 0; index < 3; index++) {
54
- // @ts-ignore
55
51
  hxs[index] = parseInt(hxs[index], 16);
56
52
  }
57
53
  return hxs;
@@ -61,7 +57,6 @@ class ColorConversion {
61
57
  * @param redValue
62
58
  * @param greenValue
63
59
  * @param blueValue
64
- * @returns
65
60
  */
66
61
  rgbToHex(redValue, greenValue, blueValue) {
67
62
  /* 验证输入的rgb值是否合法 */
@@ -70,11 +65,7 @@ class ColorConversion {
70
65
  !validPattern.test(greenValue.toString()) ||
71
66
  !validPattern.test(blueValue.toString()))
72
67
  throw new TypeError("输入错误的rgb颜色值");
73
- let hexs = [
74
- redValue.toString(16),
75
- greenValue.toString(16),
76
- blueValue.toString(16),
77
- ];
68
+ let hexs = [redValue.toString(16), greenValue.toString(16), blueValue.toString(16)];
78
69
  for (let index = 0; index < 3; index++)
79
70
  if (hexs[index].length == 1)
80
71
  hexs[index] = "0" + hexs[index];
@@ -84,38 +75,30 @@ class ColorConversion {
84
75
  * 获取颜色变暗或亮
85
76
  * @param color 颜色
86
77
  * @param level 0~1.0
87
- * @returns
88
78
  */
89
79
  getDarkColor(color, level) {
90
80
  if (!this.isHex(color)) {
91
- // @ts-ignore
92
- throw new TypeError("输入错误的hex", color);
81
+ throw new TypeError("输入错误的hex:" + color);
93
82
  }
94
83
  let rgbc = this.hexToRgb(color);
95
84
  for (let index = 0; index < 3; index++) {
96
- // @ts-ignore
97
85
  rgbc[index] = Math.floor(rgbc[index] * (1 - level));
98
86
  }
99
- // @ts-ignore
100
87
  return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
101
88
  }
102
89
  /**
103
90
  * 获取颜色变亮
104
91
  * @param color 颜色
105
92
  * @param level 0~1.0
106
- * @returns
107
93
  */
108
94
  getLightColor(color, level) {
109
95
  if (!this.isHex(color)) {
110
- // @ts-ignore
111
- throw new TypeError("输入错误的hex", color);
96
+ throw new TypeError("输入错误的hex:" + color);
112
97
  }
113
98
  let rgbc = this.hexToRgb(color);
114
99
  for (let index = 0; index < 3; index++) {
115
- // @ts-ignore
116
100
  rgbc[index] = Math.floor((255 - rgbc[index]) * level + rgbc[index]);
117
101
  }
118
- // @ts-ignore
119
102
  return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
120
103
  }
121
104
  }
@@ -130,10 +113,7 @@ class GBKEncoder {
130
113
  this.#data = dataText.match(/..../g);
131
114
  for (let i = 0x81; i <= 0xfe; i++) {
132
115
  for (let j = 0x40; j <= 0xfe; j++) {
133
- this.#U2Ghash[this.#data[index++]] = ("%" +
134
- i.toString(16) +
135
- "%" +
136
- j.toString(16)).toUpperCase();
116
+ this.#U2Ghash[this.#data[index++]] = ("%" + i.toString(16) + "%" + j.toString(16)).toUpperCase();
137
117
  }
138
118
  }
139
119
  for (let key in this.#U2Ghash) {
@@ -203,20 +183,20 @@ class GBKEncoder {
203
183
  * @param str
204
184
  */
205
185
  decode(str) {
206
- var GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
207
- var UTFMatcher = /%[0-9A-F]{2}/;
208
- // @ts-ignore
209
- var utf = true;
210
- let that = this;
186
+ let GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
187
+ let UTFMatcher = /%[0-9A-F]{2}/;
188
+ // let gbk = true;
189
+ let utf = true;
190
+ const that = this;
211
191
  while (utf) {
212
192
  let gbkMatch = str.match(GBKMatcher);
213
193
  let utfMatch = str.match(UTFMatcher);
194
+ // gbk = Boolean(gbkMatch);
214
195
  utf = Boolean(utfMatch);
215
196
  if (gbkMatch && gbkMatch in that.#G2Uhash) {
216
197
  str = str.replace(gbkMatch, String.fromCharCode(("0x" + that.#G2Uhash[gbkMatch])));
217
198
  }
218
199
  else {
219
- // @ts-ignore
220
200
  str = str.replace(utfMatch, decodeURIComponent(utfMatch));
221
201
  }
222
202
  }
@@ -247,7 +227,6 @@ const TryCatch = function (...args) {
247
227
  * @param handler
248
228
  */
249
229
  error(handler) {
250
- // @ts-ignore
251
230
  handleError = handler;
252
231
  return TryCatchCore;
253
232
  },
@@ -262,7 +241,6 @@ const TryCatch = function (...args) {
262
241
  callbackFunction = callback;
263
242
  context = __context__ || this;
264
243
  let result = executeTryCatch(callbackFunction, handleError, context);
265
- // @ts-ignore
266
244
  return result !== void 0 ? result : TryCatchCore;
267
245
  },
268
246
  };
@@ -292,10 +270,7 @@ const TryCatch = function (...args) {
292
270
  }
293
271
  if (handleErrorFunc) {
294
272
  if (typeof handleErrorFunc === "string") {
295
- result = new Function(handleErrorFunc).apply(funcThis, [
296
- ...args,
297
- error,
298
- ]);
273
+ result = new Function(handleErrorFunc).apply(funcThis, [...args, error]);
299
274
  }
300
275
  else {
301
276
  result = handleErrorFunc.apply(funcThis, [...args, error]);
@@ -383,10 +358,7 @@ class CommonUtil {
383
358
  itemResult = objItem === 0;
384
359
  break;
385
360
  case "string":
386
- itemResult =
387
- objItem.trim() === "" ||
388
- objItem === "null" ||
389
- objItem === "undefined";
361
+ itemResult = objItem.trim() === "" || objItem === "null" || objItem === "undefined";
390
362
  break;
391
363
  case "boolean":
392
364
  itemResult = !objItem;
@@ -427,8 +399,7 @@ class CommonUtil {
427
399
  return null;
428
400
  let clone = obj instanceof Array ? [] : {};
429
401
  for (const [key, value] of Object.entries(obj)) {
430
- clone[key] =
431
- typeof value === "object" ? UtilsContext.deepClone(value) : value;
402
+ clone[key] = typeof value === "object" ? UtilsContext.deepClone(value) : value;
432
403
  }
433
404
  return clone;
434
405
  }
@@ -1947,35 +1918,30 @@ class GMMenu {
1947
1918
  let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
1948
1919
  /** 油猴菜单上显示的文本 */
1949
1920
  let showText = menuOption.showText(menuOption.text, defaultEnable);
1950
- // @ts-ignore
1951
- ({
1952
- /**
1953
- * 菜单的id
1954
- */
1955
- id: menuOption.id,
1956
- /**
1957
- * 点击菜单项后是否应关闭弹出菜单
1958
- */
1959
- autoClose: menuOption.autoClose,
1960
- /**
1961
- * 菜单项的可选访问键
1962
- */
1963
- accessKey: menuOption.accessKey,
1964
- /**
1965
- * 菜单项的鼠标悬浮上的工具提示
1966
- */
1967
- title: menuOption.title,
1968
- });
1921
+ // const GMMenuOptions = {
1922
+ // /**
1923
+ // * 菜单的id
1924
+ // */
1925
+ // id: menuOption.id,
1926
+ // /**
1927
+ // * 点击菜单项后是否应关闭弹出菜单
1928
+ // */
1929
+ // autoClose: menuOption.autoClose,
1930
+ // /**
1931
+ // * 菜单项的可选访问键
1932
+ // */
1933
+ // accessKey: menuOption.accessKey,
1934
+ // /**
1935
+ // * 菜单项的鼠标悬浮上的工具提示
1936
+ // */
1937
+ // title: menuOption.title,
1938
+ // };
1969
1939
  /* 点击菜单后触发callback后的网页是否刷新 */
1970
1940
  menuOption.autoReload =
1971
- typeof menuOption.autoReload !== "boolean"
1972
- ? this.$default.autoReload
1973
- : menuOption.autoReload;
1941
+ typeof menuOption.autoReload !== "boolean" ? this.$default.autoReload : menuOption.autoReload;
1974
1942
  /* 点击菜单后触发callback后的网页是否存储值 */
1975
1943
  menuOption.isStoreValue =
1976
- typeof menuOption.isStoreValue !== "boolean"
1977
- ? this.$default.isStoreValue
1978
- : menuOption.isStoreValue;
1944
+ typeof menuOption.isStoreValue !== "boolean" ? this.$default.isStoreValue : menuOption.isStoreValue;
1979
1945
  /**
1980
1946
  * 用户点击菜单后的回调函数
1981
1947
  * @param event
@@ -2028,8 +1994,7 @@ class GMMenu {
2028
1994
  * @param menuKey 菜单-键key
2029
1995
  */
2030
1996
  getMenuHandledOption(menuKey) {
2031
- return this.$data.data.find((item) => item.handleData.key === menuKey)
2032
- ?.handleData;
1997
+ return this.$data.data.find((item) => item.handleData.key === menuKey)?.handleData;
2033
1998
  },
2034
1999
  };
2035
2000
  constructor(details) {
@@ -2037,8 +2002,7 @@ class GMMenu {
2037
2002
  this.GM_Api.setValue = details.GM_setValue;
2038
2003
  this.GM_Api.registerMenuCommand = details.GM_registerMenuCommand;
2039
2004
  this.GM_Api.unregisterMenuCommand = details.GM_unregisterMenuCommand;
2040
- this.MenuHandle.$default.autoReload =
2041
- typeof details.autoReload === "boolean" ? details.autoReload : true;
2005
+ this.MenuHandle.$default.autoReload = typeof details.autoReload === "boolean" ? details.autoReload : true;
2042
2006
  for (const keyName of Object.keys(this.GM_Api)) {
2043
2007
  if (typeof this.GM_Api[keyName] !== "function") {
2044
2008
  throw new Error(`Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`);
@@ -2270,8 +2234,7 @@ class Hooks {
2270
2234
  _context = context || window;
2271
2235
  _funcName = getFuncName(this);
2272
2236
  _context["realFunc_" + _funcName] = this;
2273
- if (_context[_funcName].prototype &&
2274
- _context[_funcName].prototype.isHooked) {
2237
+ if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
2275
2238
  console.log("Already has been hooked,unhook first");
2276
2239
  return false;
2277
2240
  }
@@ -2449,8 +2412,7 @@ class Httpx {
2449
2412
  if (details.allowInterceptConfig != null) {
2450
2413
  // 配置存在
2451
2414
  // 细分处理是否拦截
2452
- if (typeof details.allowInterceptConfig.afterResponseSuccess ===
2453
- "boolean" &&
2415
+ if (typeof details.allowInterceptConfig.afterResponseSuccess === "boolean" &&
2454
2416
  !details.allowInterceptConfig.afterResponseSuccess) {
2455
2417
  // 设置了禁止拦截
2456
2418
  return details;
@@ -2485,8 +2447,7 @@ class Httpx {
2485
2447
  if (data.details.allowInterceptConfig != null) {
2486
2448
  // 配置存在
2487
2449
  // 细分处理是否拦截
2488
- if (typeof data.details.allowInterceptConfig.afterResponseError ===
2489
- "boolean" &&
2450
+ if (typeof data.details.allowInterceptConfig.afterResponseError === "boolean" &&
2490
2451
  !data.details.allowInterceptConfig.afterResponseError) {
2491
2452
  // 设置了禁止拦截
2492
2453
  return data;
@@ -2543,7 +2504,9 @@ class Httpx {
2543
2504
  * 对请求的参数进行合并处理
2544
2505
  */
2545
2506
  handleBeforeRequestOptionArgs(...args) {
2546
- let option = {};
2507
+ let option = {
2508
+ url: void 0,
2509
+ };
2547
2510
  if (typeof args[0] === "string") {
2548
2511
  /* 传入的是url,转为配置 */
2549
2512
  let url = args[0];
@@ -2567,7 +2530,7 @@ class Httpx {
2567
2530
  * @param method 当前请求方法,默认get
2568
2531
  * @param userRequestOption 用户的请求配置
2569
2532
  * @param resolve promise回调
2570
- * @param reject 抛出错误回调
2533
+ * @param reject promise抛出错误回调
2571
2534
  */
2572
2535
  getRequestOption(method, userRequestOption, resolve, reject) {
2573
2536
  let that = this;
@@ -2586,64 +2549,51 @@ class Httpx {
2586
2549
  let requestOption = {
2587
2550
  url: url,
2588
2551
  method: (method || "GET").toString().toUpperCase().trim(),
2589
- timeout: userRequestOption.timeout ||
2590
- this.context.#defaultRequestOption.timeout,
2591
- responseType: userRequestOption.responseType ||
2592
- this.context.#defaultRequestOption.responseType,
2552
+ timeout: userRequestOption.timeout || this.context.#defaultRequestOption.timeout,
2553
+ responseType: userRequestOption.responseType || this.context.#defaultRequestOption.responseType,
2593
2554
  /* 对象使用深拷贝 */
2594
2555
  headers: commonUtil.deepClone(this.context.#defaultRequestOption.headers),
2595
2556
  data: userRequestOption.data || this.context.#defaultRequestOption.data,
2596
- redirect: userRequestOption.redirect ||
2597
- this.context.#defaultRequestOption.redirect,
2557
+ redirect: userRequestOption.redirect || this.context.#defaultRequestOption.redirect,
2598
2558
  cookie: userRequestOption.cookie || this.context.#defaultRequestOption.cookie,
2599
- cookiePartition: userRequestOption.cookiePartition ||
2600
- this.context.#defaultRequestOption.cookiePartition,
2559
+ cookiePartition: userRequestOption.cookiePartition || this.context.#defaultRequestOption.cookiePartition,
2601
2560
  binary: userRequestOption.binary || this.context.#defaultRequestOption.binary,
2602
- nocache: userRequestOption.nocache ||
2603
- this.context.#defaultRequestOption.nocache,
2604
- revalidate: userRequestOption.revalidate ||
2605
- this.context.#defaultRequestOption.revalidate,
2561
+ nocache: userRequestOption.nocache || this.context.#defaultRequestOption.nocache,
2562
+ revalidate: userRequestOption.revalidate || this.context.#defaultRequestOption.revalidate,
2606
2563
  /* 对象使用深拷贝 */
2607
- context: commonUtil.deepClone(userRequestOption.context ||
2608
- this.context.#defaultRequestOption.context),
2609
- overrideMimeType: userRequestOption.overrideMimeType ||
2610
- this.context.#defaultRequestOption.overrideMimeType,
2611
- anonymous: userRequestOption.anonymous ||
2612
- this.context.#defaultRequestOption.anonymous,
2564
+ context: commonUtil.deepClone(userRequestOption.context || this.context.#defaultRequestOption.context),
2565
+ overrideMimeType: userRequestOption.overrideMimeType || this.context.#defaultRequestOption.overrideMimeType,
2566
+ anonymous: userRequestOption.anonymous || this.context.#defaultRequestOption.anonymous,
2613
2567
  fetch: userRequestOption.fetch || this.context.#defaultRequestOption.fetch,
2614
2568
  /* 对象使用深拷贝 */
2615
2569
  fetchInit: commonUtil.deepClone(this.context.#defaultRequestOption.fetchInit),
2616
2570
  allowInterceptConfig: {
2617
- beforeRequest: this.context.#defaultRequestOption
2618
- .allowInterceptConfig.beforeRequest,
2619
- afterResponseSuccess: this.context.#defaultRequestOption
2620
- .allowInterceptConfig.afterResponseSuccess,
2621
- afterResponseError: this.context.#defaultRequestOption
2622
- .allowInterceptConfig.afterResponseError,
2571
+ beforeRequest: this.context.#defaultRequestOption.allowInterceptConfig.beforeRequest,
2572
+ afterResponseSuccess: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseSuccess,
2573
+ afterResponseError: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseError,
2623
2574
  },
2624
2575
  user: userRequestOption.user || this.context.#defaultRequestOption.user,
2625
- password: userRequestOption.password ||
2626
- this.context.#defaultRequestOption.password,
2576
+ password: userRequestOption.password || this.context.#defaultRequestOption.password,
2627
2577
  onabort(...args) {
2628
- that.context.HttpxCallBack.onAbort(userRequestOption, resolve, reject, args);
2578
+ that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
2629
2579
  },
2630
2580
  onerror(...args) {
2631
- that.context.HttpxCallBack.onError(userRequestOption, resolve, reject, args);
2581
+ that.context.HttpxResponseCallBack.onError(userRequestOption, resolve, reject, args);
2632
2582
  },
2633
2583
  onloadstart(...args) {
2634
- that.context.HttpxCallBack.onLoadStart(userRequestOption, args);
2584
+ that.context.HttpxResponseCallBack.onLoadStart(userRequestOption, args);
2635
2585
  },
2636
2586
  onprogress(...args) {
2637
- that.context.HttpxCallBack.onProgress(userRequestOption, args);
2587
+ that.context.HttpxResponseCallBack.onProgress(userRequestOption, args);
2638
2588
  },
2639
2589
  onreadystatechange(...args) {
2640
- that.context.HttpxCallBack.onReadyStateChange(userRequestOption, args);
2590
+ that.context.HttpxResponseCallBack.onReadyStateChange(userRequestOption, args);
2641
2591
  },
2642
2592
  ontimeout(...args) {
2643
- that.context.HttpxCallBack.onTimeout(userRequestOption, resolve, reject, args);
2593
+ that.context.HttpxResponseCallBack.onTimeout(userRequestOption, resolve, reject, args);
2644
2594
  },
2645
2595
  onload(...args) {
2646
- that.context.HttpxCallBack.onLoad(userRequestOption, resolve, reject, args);
2596
+ that.context.HttpxResponseCallBack.onLoad(userRequestOption, resolve, reject, args);
2647
2597
  },
2648
2598
  };
2649
2599
  // 补全allowInterceptConfig参数
@@ -2671,14 +2621,12 @@ class Httpx {
2671
2621
  if (typeof requestOption.headers === "object") {
2672
2622
  if (typeof userRequestOption.headers === "object") {
2673
2623
  Object.keys(userRequestOption.headers).forEach((keyName, index) => {
2674
- if (keyName in requestOption.headers &&
2675
- userRequestOption.headers?.[keyName] == null) {
2624
+ if (keyName in requestOption.headers && userRequestOption.headers?.[keyName] == null) {
2676
2625
  /* 在默认的header中存在,且设置它新的值为空,那么就是默认的值 */
2677
2626
  Reflect.deleteProperty(requestOption.headers, keyName);
2678
2627
  }
2679
2628
  else {
2680
- requestOption.headers[keyName] =
2681
- userRequestOption?.headers?.[keyName];
2629
+ requestOption.headers[keyName] = userRequestOption?.headers?.[keyName];
2682
2630
  }
2683
2631
  });
2684
2632
  }
@@ -2691,8 +2639,7 @@ class Httpx {
2691
2639
  /* 使用assign替换且添加 */
2692
2640
  if (typeof userRequestOption.fetchInit === "object") {
2693
2641
  Object.keys(userRequestOption.fetchInit).forEach((keyName, index) => {
2694
- if (keyName in requestOption.fetchInit &&
2695
- userRequestOption.fetchInit[keyName] == null) {
2642
+ if (keyName in requestOption.fetchInit && userRequestOption.fetchInit[keyName] == null) {
2696
2643
  /* 在默认的fetchInit中存在,且设置它新的值为空,那么就是默认的值 */
2697
2644
  Reflect.deleteProperty(requestOption.fetchInit, keyName);
2698
2645
  }
@@ -2706,8 +2653,7 @@ class Httpx {
2706
2653
  Reflect.set(requestOption, "fetchInit", userRequestOption.fetchInit);
2707
2654
  }
2708
2655
  // 处理新的cookiePartition
2709
- if (typeof requestOption.cookiePartition === "object" &&
2710
- requestOption.cookiePartition != null) {
2656
+ if (typeof requestOption.cookiePartition === "object" && requestOption.cookiePartition != null) {
2711
2657
  if (Reflect.has(requestOption.cookiePartition, "topLevelSite") &&
2712
2658
  typeof requestOption.cookiePartition.topLevelSite !== "string") {
2713
2659
  // topLevelSite必须是字符串
@@ -2729,8 +2675,7 @@ class Httpx {
2729
2675
  }
2730
2676
  else {
2731
2677
  // 补充origin+/
2732
- requestOption.url =
2733
- globalThis.location.origin + "/" + requestOption.url;
2678
+ requestOption.url = globalThis.location.origin + "/" + requestOption.url;
2734
2679
  }
2735
2680
  }
2736
2681
  if (requestOption.fetchInit && !requestOption.fetch) {
@@ -2755,7 +2700,6 @@ class Httpx {
2755
2700
  else if (typeof requestOption.data === "object") {
2756
2701
  isHandler = true;
2757
2702
  // URLSearchParams参数可以转普通的string:string,包括FormData
2758
- // @ts-ignore
2759
2703
  let searchParams = new URLSearchParams(requestOption.data);
2760
2704
  urlSearch = searchParams.toString();
2761
2705
  }
@@ -2810,9 +2754,7 @@ class Httpx {
2810
2754
  else if (ContentType.includes("application/x-www-form-urlencoded")) {
2811
2755
  // application/x-www-form-urlencoded
2812
2756
  if (typeof requestOption.data === "object") {
2813
- requestOption.data = new URLSearchParams(
2814
- // @ts-ignore
2815
- requestOption.data).toString();
2757
+ requestOption.data = new URLSearchParams(requestOption.data).toString();
2816
2758
  }
2817
2759
  }
2818
2760
  else if (ContentType.includes("multipart/form-data")) {
@@ -2832,7 +2774,7 @@ class Httpx {
2832
2774
  },
2833
2775
  /**
2834
2776
  * 处理发送请求的配置,去除值为undefined、空function的值
2835
- * @param option
2777
+ * @param option 请求配置
2836
2778
  */
2837
2779
  removeRequestNullOption(option) {
2838
2780
  Object.keys(option).forEach((keyName) => {
@@ -2844,21 +2786,20 @@ class Httpx {
2844
2786
  }
2845
2787
  });
2846
2788
  if (commonUtil.isNull(option.url)) {
2847
- throw new TypeError(`Utils.Httpx 参数 url不符合要求: ${option.url}`);
2789
+ throw new TypeError(`Utils.Httpx 参数url不能为空:${option.url}`);
2848
2790
  }
2849
2791
  return option;
2850
2792
  },
2851
2793
  /**
2852
2794
  * 处理fetch的配置
2853
- * @param option
2795
+ * @param option 请求配置
2854
2796
  */
2855
2797
  handleFetchOption(option) {
2856
2798
  /**
2857
2799
  * fetch的请求配置
2858
2800
  **/
2859
2801
  let fetchRequestOption = {};
2860
- if ((option.method === "GET" || option.method === "HEAD") &&
2861
- option.data != null) {
2802
+ if ((option.method === "GET" || option.method === "HEAD") && option.data != null) {
2862
2803
  /* GET 或 HEAD 方法的请求不能包含 body 信息 */
2863
2804
  Reflect.deleteProperty(option, "data");
2864
2805
  }
@@ -2903,21 +2844,21 @@ class Httpx {
2903
2844
  };
2904
2845
  },
2905
2846
  };
2906
- HttpxCallBack = {
2847
+ HttpxResponseCallBack = {
2907
2848
  context: this,
2908
2849
  /**
2909
2850
  * onabort请求被取消-触发
2910
2851
  * @param details 配置
2911
- * @param resolve 回调
2912
- * @param reject 抛出错误
2852
+ * @param resolve promise回调
2853
+ * @param reject promise抛出错误回调
2913
2854
  * @param argsResult 返回的参数列表
2914
2855
  */
2915
2856
  async onAbort(details, resolve, reject, argsResult) {
2916
2857
  // console.log(argsResult);
2917
- if ("onabort" in details) {
2858
+ if (typeof details?.onabort === "function") {
2918
2859
  details.onabort.apply(this, argsResult);
2919
2860
  }
2920
- else if ("onabort" in this.context.#defaultRequestOption) {
2861
+ else if (typeof this.context.#defaultRequestOption?.onabort === "function") {
2921
2862
  this.context.#defaultRequestOption.onabort.apply(this, argsResult);
2922
2863
  }
2923
2864
  let response = argsResult;
@@ -2926,11 +2867,11 @@ class Httpx {
2926
2867
  }
2927
2868
  if ((await this.context.HttpxResponseHook.errorResponseCallBack({
2928
2869
  type: "onabort",
2929
- error: new TypeError("request canceled"),
2870
+ error: new Error("request canceled"),
2930
2871
  response: null,
2931
2872
  details: details,
2932
2873
  })) == null) {
2933
- // reject(new TypeError("response is intercept with onabort"));
2874
+ // reject(new Error("response is intercept with onabort"));
2934
2875
  return;
2935
2876
  }
2936
2877
  resolve({
@@ -2943,93 +2884,83 @@ class Httpx {
2943
2884
  });
2944
2885
  },
2945
2886
  /**
2946
- * onerror请求异常-触发
2887
+ * ontimeout请求超时-触发
2947
2888
  * @param details 配置
2948
2889
  * @param resolve 回调
2949
2890
  * @param reject 抛出错误
2950
2891
  * @param argsResult 返回的参数列表
2951
2892
  */
2952
- async onError(details, resolve, reject, argsResult) {
2893
+ async onTimeout(details, resolve, reject, argsResult) {
2953
2894
  // console.log(argsResult);
2954
- if ("onerror" in details) {
2955
- details.onerror.apply(this, argsResult);
2895
+ if (typeof details?.ontimeout === "function") {
2896
+ // 执行配置中的ontime回调
2897
+ details.ontimeout.apply(this, argsResult);
2956
2898
  }
2957
- else if ("onerror" in this.context.#defaultRequestOption) {
2958
- this.context.#defaultRequestOption.onerror.apply(this, argsResult);
2899
+ else if (typeof this.context.#defaultRequestOption?.ontimeout === "function") {
2900
+ // 执行默认配置的ontime回调
2901
+ this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
2959
2902
  }
2903
+ // 获取响应结果
2960
2904
  let response = argsResult;
2961
2905
  if (response.length) {
2962
2906
  response = response[0];
2963
2907
  }
2908
+ // 执行错误回调的钩子
2964
2909
  if ((await this.context.HttpxResponseHook.errorResponseCallBack({
2965
- type: "onerror",
2966
- error: new TypeError("request error"),
2910
+ type: "ontimeout",
2911
+ error: new Error("request timeout"),
2967
2912
  response: response,
2968
2913
  details: details,
2969
2914
  })) == null) {
2970
- // reject(new TypeError("response is intercept with onerror"));
2915
+ // reject(new Error("response is intercept with ontimeout"));
2971
2916
  return;
2972
2917
  }
2973
2918
  resolve({
2974
2919
  data: response,
2975
2920
  details: details,
2976
- msg: "请求异常",
2921
+ msg: "请求超时",
2977
2922
  status: false,
2978
- statusCode: response["status"],
2979
- type: "onerror",
2923
+ statusCode: 0,
2924
+ type: "ontimeout",
2980
2925
  });
2981
2926
  },
2982
2927
  /**
2983
- * ontimeout请求超时-触发
2928
+ * onerror请求异常-触发
2984
2929
  * @param details 配置
2985
2930
  * @param resolve 回调
2986
2931
  * @param reject 抛出错误
2987
2932
  * @param argsResult 返回的参数列表
2988
2933
  */
2989
- async onTimeout(details, resolve, reject, argsResult) {
2934
+ async onError(details, resolve, reject, argsResult) {
2990
2935
  // console.log(argsResult);
2991
- if ("ontimeout" in details) {
2992
- details.ontimeout.apply(this, argsResult);
2936
+ if (typeof details?.onerror === "function") {
2937
+ details.onerror.apply(this, argsResult);
2993
2938
  }
2994
- else if ("ontimeout" in this.context.#defaultRequestOption) {
2995
- this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
2939
+ else if (typeof this.context.#defaultRequestOption?.onerror === "function") {
2940
+ this.context.#defaultRequestOption.onerror.apply(this, argsResult);
2996
2941
  }
2997
2942
  let response = argsResult;
2998
2943
  if (response.length) {
2999
2944
  response = response[0];
3000
2945
  }
3001
2946
  if ((await this.context.HttpxResponseHook.errorResponseCallBack({
3002
- type: "ontimeout",
3003
- error: new TypeError("request timeout"),
3004
- response: (argsResult || [null])[0],
2947
+ type: "onerror",
2948
+ error: new Error("request error"),
2949
+ response: response,
3005
2950
  details: details,
3006
2951
  })) == null) {
3007
- // reject(new TypeError("response is intercept with ontimeout"));
2952
+ // reject(new Error("response is intercept with onerror"));
3008
2953
  return;
3009
2954
  }
3010
2955
  resolve({
3011
2956
  data: response,
3012
2957
  details: details,
3013
- msg: "请求超时",
2958
+ msg: "请求异常",
3014
2959
  status: false,
3015
- statusCode: 0,
3016
- type: "ontimeout",
2960
+ statusCode: response["status"],
2961
+ type: "onerror",
3017
2962
  });
3018
2963
  },
3019
- /**
3020
- * onloadstart请求开始-触发
3021
- * @param details 配置
3022
- * @param argsResult 返回的参数列表
3023
- */
3024
- onLoadStart(details, argsResult) {
3025
- // console.log(argsResult);
3026
- if ("onloadstart" in details) {
3027
- details.onloadstart.apply(this, argsResult);
3028
- }
3029
- else if ("onloadstart" in this.context.#defaultRequestOption) {
3030
- this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
3031
- }
3032
- },
3033
2964
  /**
3034
2965
  * onload加载完毕-触发
3035
2966
  * @param details 请求的配置
@@ -3109,7 +3040,7 @@ class Httpx {
3109
3040
  /* 状态码2xx都是成功的 */
3110
3041
  if (Math.floor(originResponse.status / 100) === 2) {
3111
3042
  if ((await this.context.HttpxResponseHook.successResponseCallBack(originResponse, details)) == null) {
3112
- // reject(new TypeError("response is intercept with onloada"));
3043
+ // reject(new Error("response is intercept with onloada"));
3113
3044
  return;
3114
3045
  }
3115
3046
  resolve({
@@ -3122,21 +3053,21 @@ class Httpx {
3122
3053
  });
3123
3054
  }
3124
3055
  else {
3125
- this.context.HttpxCallBack.onError(details, resolve, reject, argsResult);
3056
+ this.context.HttpxResponseCallBack.onError(details, resolve, reject, argsResult);
3126
3057
  }
3127
3058
  },
3128
3059
  /**
3129
- * onprogress上传进度-触发
3060
+ * onloadstart请求开始-触发
3130
3061
  * @param details 配置
3131
3062
  * @param argsResult 返回的参数列表
3132
3063
  */
3133
- onProgress(details, argsResult) {
3064
+ onLoadStart(details, argsResult) {
3134
3065
  // console.log(argsResult);
3135
- if ("onprogress" in details) {
3136
- details.onprogress.apply(this, argsResult);
3066
+ if (typeof details?.onloadstart === "function") {
3067
+ details.onloadstart.apply(this, argsResult);
3137
3068
  }
3138
- else if ("onprogress" in this.context.#defaultRequestOption) {
3139
- this.context.#defaultRequestOption.onprogress.apply(this, argsResult);
3069
+ else if (typeof this.context.#defaultRequestOption?.onloadstart === "function") {
3070
+ this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
3140
3071
  }
3141
3072
  },
3142
3073
  /**
@@ -3146,13 +3077,27 @@ class Httpx {
3146
3077
  */
3147
3078
  onReadyStateChange(details, argsResult) {
3148
3079
  // console.log(argsResult);
3149
- if ("onreadystatechange" in details) {
3080
+ if (typeof details?.onreadystatechange === "function") {
3150
3081
  details.onreadystatechange.apply(this, argsResult);
3151
3082
  }
3152
- else if ("onreadystatechange" in this.context.#defaultRequestOption) {
3083
+ else if (typeof this.context.#defaultRequestOption?.onreadystatechange === "function") {
3153
3084
  this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
3154
3085
  }
3155
3086
  },
3087
+ /**
3088
+ * onprogress上传进度-触发
3089
+ * @param details 配置
3090
+ * @param argsResult 返回的参数列表
3091
+ */
3092
+ onProgress(details, argsResult) {
3093
+ // console.log(argsResult);
3094
+ if (typeof details?.onprogress === "function") {
3095
+ details.onprogress.apply(this, argsResult);
3096
+ }
3097
+ else if (typeof this.context.#defaultRequestOption?.onprogress === "function") {
3098
+ this.context.#defaultRequestOption.onprogress.apply(this, argsResult);
3099
+ }
3100
+ },
3156
3101
  };
3157
3102
  HttpxRequest = {
3158
3103
  context: this,
@@ -3164,8 +3109,7 @@ class Httpx {
3164
3109
  if (this.context.#defaultInitOption.logDetails) {
3165
3110
  console.log("[Httpx-HttpxRequest.request] 请求前的配置👇", details);
3166
3111
  }
3167
- if (typeof this.context.HttpxRequestHook.beforeRequestCallBack ===
3168
- "function") {
3112
+ if (typeof this.context.HttpxRequestHook.beforeRequestCallBack === "function") {
3169
3113
  let hookResult = await this.context.HttpxRequestHook.beforeRequestCallBack(details);
3170
3114
  if (hookResult == null) {
3171
3115
  return;
@@ -3202,15 +3146,12 @@ class Httpx {
3202
3146
  isFetch: true,
3203
3147
  finalUrl: fetchResponse.url,
3204
3148
  readyState: 4,
3205
- // @ts-ignore
3206
3149
  status: fetchResponse.status,
3207
3150
  statusText: fetchResponse.statusText,
3208
- // @ts-ignore
3209
- response: void 0,
3151
+ response: "",
3210
3152
  responseFetchHeaders: fetchResponse.headers,
3211
3153
  responseHeaders: "",
3212
- // @ts-ignore
3213
- responseText: void 0,
3154
+ responseText: "",
3214
3155
  responseType: option.responseType,
3215
3156
  responseXML: void 0,
3216
3157
  };
@@ -3224,9 +3165,7 @@ class Httpx {
3224
3165
  /* 如果需要stream,且获取到的是stream,那直接返回 */
3225
3166
  if (option.responseType === "stream" ||
3226
3167
  (fetchResponse.headers.has("Content-Type") &&
3227
- fetchResponse.headers
3228
- .get("Content-Type")
3229
- .includes("text/event-stream"))) {
3168
+ fetchResponse.headers.get("Content-Type").includes("text/event-stream"))) {
3230
3169
  Reflect.set(httpxResponse, "isStream", true);
3231
3170
  Reflect.set(httpxResponse, "response", fetchResponse.body);
3232
3171
  Reflect.deleteProperty(httpxResponse, "responseText");
@@ -3245,9 +3184,7 @@ class Httpx {
3245
3184
  /** 数据编码 */
3246
3185
  let encoding = "utf-8";
3247
3186
  if (fetchResponse.headers.has("Content-Type")) {
3248
- let charsetMatched = fetchResponse.headers
3249
- .get("Content-Type")
3250
- ?.match(/charset=(.+)/);
3187
+ let charsetMatched = fetchResponse.headers.get("Content-Type")?.match(/charset=(.+)/);
3251
3188
  if (charsetMatched) {
3252
3189
  encoding = charsetMatched[1];
3253
3190
  encoding = encoding.toLowerCase();
@@ -3269,13 +3206,11 @@ class Httpx {
3269
3206
  response = new Blob([arrayBuffer]);
3270
3207
  }
3271
3208
  else if (option.responseType === "json" ||
3272
- (typeof fetchResponseType === "string" &&
3273
- fetchResponseType.includes("application/json"))) {
3209
+ (typeof fetchResponseType === "string" && fetchResponseType.includes("application/json"))) {
3274
3210
  // response返回格式是JSON格式
3275
3211
  response = commonUtil.toJSON(responseText);
3276
3212
  }
3277
- else if (option.responseType === "document" ||
3278
- option.responseType == null) {
3213
+ else if (option.responseType === "document" || option.responseType == null) {
3279
3214
  // response返回格式是文档格式
3280
3215
  let parser = new DOMParser();
3281
3216
  response = parser.parseFromString(responseText, "text/html");
@@ -3283,9 +3218,9 @@ class Httpx {
3283
3218
  // 转为XML结构
3284
3219
  let parser = new DOMParser();
3285
3220
  responseXML = parser.parseFromString(responseText, "text/xml");
3286
- Reflect.set(httpxResponse, "response", response);
3287
- Reflect.set(httpxResponse, "responseText", responseText);
3288
- Reflect.set(httpxResponse, "responseXML", responseXML);
3221
+ httpxResponse.response = response;
3222
+ httpxResponse.responseText = responseText;
3223
+ httpxResponse.responseXML = responseXML;
3289
3224
  // 执行回调
3290
3225
  option.onload(httpxResponse);
3291
3226
  })
@@ -3466,7 +3401,7 @@ class Httpx {
3466
3401
  }
3467
3402
  /**
3468
3403
  * GET 请求
3469
- * @param url 网址
3404
+ * @param url 请求的url
3470
3405
  * @param details 配置
3471
3406
  */
3472
3407
  get(...args) {
@@ -3532,27 +3467,21 @@ class Httpx {
3532
3467
  /** 取消请求 */
3533
3468
  let abortFn = null;
3534
3469
  let promise = new globalThis.Promise(async (resolve, reject) => {
3535
- let requestOption = this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject);
3470
+ let requestOption = (this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject));
3536
3471
  if (typeof beforeRequestOption === "function") {
3537
- // @ts-ignore
3538
3472
  beforeRequestOption(requestOption);
3539
3473
  }
3540
- // @ts-ignore
3541
- requestOption =
3542
- this.HttpxRequestOption.removeRequestNullOption(requestOption);
3474
+ requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
3543
3475
  const requestResult = await this.HttpxRequest.request(requestOption);
3544
- if (requestResult != null &&
3545
- typeof requestResult.abort === "function") {
3476
+ if (requestResult != null && typeof requestResult.abort === "function") {
3546
3477
  abortFn = requestResult.abort;
3547
3478
  }
3548
3479
  });
3549
- // @ts-ignore
3550
3480
  promise.abort = () => {
3551
3481
  if (typeof abortFn === "function") {
3552
3482
  abortFn();
3553
3483
  }
3554
3484
  };
3555
- // @ts-ignore
3556
3485
  return promise;
3557
3486
  }
3558
3487
  }
@@ -3562,8 +3491,7 @@ class indexedDB {
3562
3491
  #storeName;
3563
3492
  #dbVersion;
3564
3493
  /* websql的版本号,由于ios的问题,版本号的写法不一样 */
3565
- // @ts-ignore
3566
- #slqVersion = "1";
3494
+ // #slqVersion = "1";
3567
3495
  /* 监听IndexDB */
3568
3496
  #indexedDB = window.indexedDB ||
3569
3497
  window.mozIndexedDB ||
@@ -3571,8 +3499,7 @@ class indexedDB {
3571
3499
  window.msIndexedDB;
3572
3500
  /* 缓存数据库,避免同一个页面重复创建和销毁 */
3573
3501
  #db = {};
3574
- // @ts-ignore
3575
- #store = null;
3502
+ // #store: IDBObjectStore = null as any;
3576
3503
  /** 状态码 */
3577
3504
  #statusCode = {
3578
3505
  operationSuccess: {
@@ -3617,7 +3544,7 @@ class indexedDB {
3617
3544
  txn = this.#db[dbName].transaction(this.#storeName, "readwrite");
3618
3545
  /* IndexDB的读写权限 */
3619
3546
  store = txn.objectStore(this.#storeName);
3620
- this.#store = store;
3547
+ // this.#store = store;
3621
3548
  return store;
3622
3549
  }
3623
3550
  /**
@@ -4037,8 +3964,7 @@ class Log {
4037
3964
  if (typeof __GM_info === "string") {
4038
3965
  this.tag = __GM_info;
4039
3966
  }
4040
- else if (typeof __GM_info === "object" &&
4041
- typeof __GM_info?.script?.name === "string") {
3967
+ else if (typeof __GM_info === "object" && typeof __GM_info?.script?.name === "string") {
4042
3968
  this.tag = __GM_info.script.name;
4043
3969
  }
4044
3970
  this.#console = console;
@@ -4094,8 +4020,7 @@ class Log {
4094
4020
  */
4095
4021
  checkClearConsole() {
4096
4022
  this.#logCount++;
4097
- if (this.#details.autoClearConsole &&
4098
- this.#logCount > this.#details.logMaxCount) {
4023
+ if (this.#details.autoClearConsole && this.#logCount > this.#details.logMaxCount) {
4099
4024
  this.#console.clear();
4100
4025
  this.#logCount = 0;
4101
4026
  }
@@ -4342,12 +4267,40 @@ class Progress {
4342
4267
  }
4343
4268
 
4344
4269
  class UtilsDictionary {
4345
- items = {};
4270
+ items;
4346
4271
  constructor(key, value) {
4272
+ this.items = {};
4347
4273
  if (key != null) {
4348
4274
  this.set(key, value);
4349
4275
  }
4350
4276
  }
4277
+ /**
4278
+ * 获取字典的长度,同this.size
4279
+ */
4280
+ get length() {
4281
+ return this.size();
4282
+ }
4283
+ /**
4284
+ * 迭代器
4285
+ */
4286
+ get entries() {
4287
+ let that = this;
4288
+ return function* () {
4289
+ let itemKeys = Object.keys(that.getItems());
4290
+ for (const keyName of itemKeys) {
4291
+ yield [keyName, that.get(keyName)];
4292
+ }
4293
+ };
4294
+ }
4295
+ /**
4296
+ * 是否可遍历
4297
+ */
4298
+ get [Symbol.iterator]() {
4299
+ let that = this;
4300
+ return function () {
4301
+ return that.entries();
4302
+ };
4303
+ }
4351
4304
  /**
4352
4305
  * 检查是否有某一个键
4353
4306
  * @param key 键
@@ -4448,7 +4401,6 @@ class UtilsDictionary {
4448
4401
  * 返回字典本身
4449
4402
  */
4450
4403
  getItems() {
4451
- // @ts-ignore
4452
4404
  return this.items;
4453
4405
  }
4454
4406
  /**
@@ -4458,38 +4410,15 @@ class UtilsDictionary {
4458
4410
  concat(data) {
4459
4411
  this.items = commonUtil.assign(this.items, data.getItems());
4460
4412
  }
4413
+ /**
4414
+ * 迭代字典
4415
+ * @param callbackfn 回调函数
4416
+ */
4461
4417
  forEach(callbackfn) {
4462
4418
  for (const key in this.getItems()) {
4463
4419
  callbackfn(this.get(key), key, this.getItems());
4464
4420
  }
4465
4421
  }
4466
- /**
4467
- * 获取字典的长度,同this.size
4468
- */
4469
- get length() {
4470
- return this.size();
4471
- }
4472
- /**
4473
- * 迭代器
4474
- */
4475
- get entries() {
4476
- let that = this;
4477
- return function* () {
4478
- let itemKeys = Object.keys(that.getItems());
4479
- for (const keyName of itemKeys) {
4480
- yield [keyName, that.get(keyName)];
4481
- }
4482
- };
4483
- }
4484
- /**
4485
- * 是否可遍历
4486
- */
4487
- get [Symbol.iterator]() {
4488
- let that = this;
4489
- return function () {
4490
- return that.entries();
4491
- };
4492
- }
4493
4422
  }
4494
4423
 
4495
4424
  class WindowApi {
@@ -4515,7 +4444,6 @@ class WindowApi {
4515
4444
  if (!option) {
4516
4445
  option = Object.assign({}, this.defaultApi);
4517
4446
  }
4518
- // @ts-ignore
4519
4447
  this.api = Object.assign({}, option);
4520
4448
  }
4521
4449
  get document() {
@@ -4573,11 +4501,10 @@ class ReactiveEffect {
4573
4501
  deps = [];
4574
4502
  active = true;
4575
4503
  fn;
4576
- // @ts-ignore
4577
- scheduler;
4504
+ // private scheduler;
4578
4505
  constructor(fn, scheduler) {
4579
4506
  this.fn = fn;
4580
- this.scheduler = scheduler;
4507
+ // this.scheduler = scheduler;
4581
4508
  }
4582
4509
  run(cb) {
4583
4510
  if (!this.active) {
@@ -4644,8 +4571,7 @@ class Vue {
4644
4571
  reactive(target) {
4645
4572
  const that = this;
4646
4573
  if (!(typeof target === "object" && target !== null)) {
4647
- // @ts-ignore
4648
- return;
4574
+ return void 0;
4649
4575
  }
4650
4576
  if (VueUtils.isReactive(target)) {
4651
4577
  return target;
@@ -4715,7 +4641,6 @@ class Vue {
4715
4641
  toRefs(object) {
4716
4642
  const result = VueUtils.isArray(object) ? new Array(object.length) : {};
4717
4643
  for (let key in object) {
4718
- // @ts-ignore
4719
4644
  result[key] = this.toRef(object, key);
4720
4645
  }
4721
4646
  return result;
@@ -5011,7 +4936,7 @@ const createLoadOrReturnBroker = (loadBroker, worker) => {
5011
4936
  };
5012
4937
 
5013
4938
  // This is the minified and stringified code of the worker-timers-worker package.
5014
- 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
4939
+ 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
5015
4940
 
5016
4941
  const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
5017
4942
  const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
@@ -5443,7 +5368,6 @@ class DOMUtils {
5443
5368
  let text = textMatch[2];
5444
5369
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
5445
5370
  return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
5446
- // @ts-ignore
5447
5371
  return ($ele?.textContent || $ele?.innerText)?.includes(text);
5448
5372
  });
5449
5373
  }
@@ -5461,7 +5385,6 @@ class DOMUtils {
5461
5385
  let regexp = new RegExp(pattern, flags);
5462
5386
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
5463
5387
  return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
5464
- // @ts-ignore
5465
5388
  return Boolean(($ele?.textContent || $ele?.innerText)?.match(regexp));
5466
5389
  });
5467
5390
  }
@@ -5507,7 +5430,6 @@ class DOMUtils {
5507
5430
  let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
5508
5431
  let text = textMatch[2];
5509
5432
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
5510
- // @ts-ignore
5511
5433
  let content = $el?.textContent || $el?.innerText;
5512
5434
  if (typeof content !== "string") {
5513
5435
  content = "";
@@ -5527,7 +5449,6 @@ class DOMUtils {
5527
5449
  }
5528
5450
  let regexp = new RegExp(pattern, flags);
5529
5451
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
5530
- // @ts-ignore
5531
5452
  let content = $el?.textContent || $el?.innerText;
5532
5453
  if (typeof content !== "string") {
5533
5454
  content = "";
@@ -5558,7 +5479,6 @@ class DOMUtils {
5558
5479
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
5559
5480
  let $closest = $el?.closest(selector);
5560
5481
  if ($closest) {
5561
- // @ts-ignore
5562
5482
  let content = $el?.textContent || $el?.innerText;
5563
5483
  if (typeof content === "string" && content.includes(text)) {
5564
5484
  return $closest;
@@ -5581,7 +5501,6 @@ class DOMUtils {
5581
5501
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
5582
5502
  let $closest = $el?.closest(selector);
5583
5503
  if ($closest) {
5584
- // @ts-ignore
5585
5504
  let content = $el?.textContent || $el?.innerText;
5586
5505
  if (typeof content === "string" && content.match(regexp)) {
5587
5506
  return $closest;
@@ -5604,7 +5523,7 @@ class Utils {
5604
5523
  this.windowApi = new WindowApi(option);
5605
5524
  }
5606
5525
  /** 版本号 */
5607
- version = "2025.7.29";
5526
+ version = "2025.8.11";
5608
5527
  addStyle(cssText) {
5609
5528
  if (typeof cssText !== "string") {
5610
5529
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");
@@ -5701,7 +5620,7 @@ class Utils {
5701
5620
  return ajaxHooker();
5702
5621
  }
5703
5622
  };
5704
- canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = globalThis) {
5623
+ canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = this.windowApi.window) {
5705
5624
  if (!(canvasElement instanceof HTMLCanvasElement)) {
5706
5625
  throw new Error("Utils.canvasClickByPosition 参数canvasElement必须是canvas元素");
5707
5626
  }
@@ -5712,7 +5631,6 @@ class Utils {
5712
5631
  cancelable: true,
5713
5632
  clientX: clientX,
5714
5633
  clientY: clientY,
5715
- // @ts-ignore
5716
5634
  view: view,
5717
5635
  detail: 1,
5718
5636
  };
@@ -5728,13 +5646,9 @@ class Utils {
5728
5646
  let touchEvent = UtilsContext.windowApi.window.event;
5729
5647
  let $click = clickEvent?.composedPath()?.[0];
5730
5648
  // 点击的x坐标
5731
- let clickPosX = clickEvent?.clientX != null
5732
- ? clickEvent.clientX
5733
- : touchEvent.touches[0].clientX;
5649
+ let clickPosX = clickEvent?.clientX != null ? clickEvent.clientX : touchEvent.touches[0].clientX;
5734
5650
  // 点击的y坐标
5735
- let clickPosY = clickEvent?.clientY != null
5736
- ? clickEvent.clientY
5737
- : touchEvent.touches[0].clientY;
5651
+ let clickPosY = clickEvent?.clientY != null ? clickEvent.clientY : touchEvent.touches[0].clientY;
5738
5652
  let {
5739
5653
  /* 要检测的元素的相对屏幕的横坐标最左边 */
5740
5654
  left: elementPosXLeft,
@@ -5897,9 +5811,7 @@ class Utils {
5897
5811
  /* CODE FOR BROWSERS THAT SUPPORT window.find */
5898
5812
  let windowFind = this.windowApi.self.find;
5899
5813
  strFound = windowFind(str, caseSensitive, true, true, false);
5900
- if (strFound &&
5901
- this.windowApi.self.getSelection &&
5902
- !this.windowApi.self.getSelection().anchorNode) {
5814
+ if (strFound && this.windowApi.self.getSelection && !this.windowApi.self.getSelection().anchorNode) {
5903
5815
  strFound = windowFind(str, caseSensitive, true, true, false);
5904
5816
  }
5905
5817
  if (!strFound) {
@@ -6002,9 +5914,7 @@ class Utils {
6002
5914
  }
6003
5915
  }
6004
5916
  result = result.toFixed(2);
6005
- result = addType
6006
- ? result + resultType.toString()
6007
- : parseFloat(result.toString());
5917
+ result = addType ? result + resultType.toString() : parseFloat(result.toString());
6008
5918
  return result;
6009
5919
  }
6010
5920
  getNodeListValue(...args) {
@@ -6083,14 +5993,7 @@ class Utils {
6083
5993
  if (text.length === 8) {
6084
5994
  /* 该字符串只有时分秒 */
6085
5995
  let today = new Date();
6086
- text =
6087
- today.getFullYear() +
6088
- "-" +
6089
- (today.getMonth() + 1) +
6090
- "-" +
6091
- today.getDate() +
6092
- " " +
6093
- text;
5996
+ text = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate() + " " + text;
6094
5997
  }
6095
5998
  text = text.substring(0, 19);
6096
5999
  text = text.replace(/-/g, "/");
@@ -6111,25 +6014,13 @@ class Utils {
6111
6014
  * 获取 transitionend 的在各个浏览器的兼容名
6112
6015
  */
6113
6016
  getTransitionEndNameList() {
6114
- return [
6115
- "webkitTransitionEnd",
6116
- "mozTransitionEnd",
6117
- "MSTransitionEnd",
6118
- "otransitionend",
6119
- "transitionend",
6120
- ];
6017
+ return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
6121
6018
  }
6122
6019
  /**
6123
6020
  * 获取 animationend 的在各个浏览器的兼容名
6124
6021
  */
6125
6022
  getAnimationEndNameList() {
6126
- return [
6127
- "webkitAnimationEnd",
6128
- "mozAnimationEnd",
6129
- "MSAnimationEnd",
6130
- "oanimationend",
6131
- "animationend",
6132
- ];
6023
+ return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
6133
6024
  }
6134
6025
  getArrayLastValue(targetObj) {
6135
6026
  return targetObj[targetObj.length - 1];
@@ -6219,12 +6110,10 @@ class Utils {
6219
6110
  }
6220
6111
  getElementSelector(element) {
6221
6112
  let UtilsContext = this;
6222
- // @ts-ignore
6223
6113
  if (!element)
6224
- return;
6225
- // @ts-ignore
6114
+ return void 0;
6226
6115
  if (!element.parentElement)
6227
- return;
6116
+ return void 0;
6228
6117
  /* 如果元素有id属性,则直接返回id选择器 */
6229
6118
  if (element.id)
6230
6119
  return "#" + element.id;
@@ -6235,10 +6124,8 @@ class Utils {
6235
6124
  }
6236
6125
  /* 如果有多个相同类型的兄弟元素,则需要添加索引 */
6237
6126
  if (element.parentElement.querySelectorAll(element.tagName).length > 1) {
6238
- let index = Array.prototype.indexOf.call(element.parentElement.children, element) +
6239
- 1;
6240
- selector +=
6241
- " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
6127
+ let index = Array.prototype.indexOf.call(element.parentElement.children, element) + 1;
6128
+ selector += " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
6242
6129
  }
6243
6130
  else {
6244
6131
  selector += " > " + element.tagName.toLowerCase();
@@ -6255,13 +6142,10 @@ class Utils {
6255
6142
  let result = [...args];
6256
6143
  let newResult = [];
6257
6144
  if (result.length === 0) {
6258
- // @ts-ignore
6259
- return;
6145
+ return void 0;
6260
6146
  }
6261
6147
  if (result.length > 1) {
6262
- if (result.length === 2 &&
6263
- typeof result[0] === "object" &&
6264
- typeof result[1] === "function") {
6148
+ if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
6265
6149
  let data = result[0];
6266
6150
  let handleDataFunc = result[1];
6267
6151
  Object.keys(data).forEach((keyName) => {
@@ -6296,7 +6180,6 @@ class Utils {
6296
6180
  // 当前页面最大的z-index
6297
6181
  let zIndex = 0;
6298
6182
  // 当前的最大z-index的元素,调试使用
6299
- // @ts-ignore
6300
6183
  let maxZIndexNode = null;
6301
6184
  /**
6302
6185
  * 元素是否可见
@@ -6357,13 +6240,10 @@ class Utils {
6357
6240
  let result = [...args];
6358
6241
  let newResult = [];
6359
6242
  if (result.length === 0) {
6360
- // @ts-ignore
6361
- return;
6243
+ return void 0;
6362
6244
  }
6363
6245
  if (result.length > 1) {
6364
- if (result.length === 2 &&
6365
- typeof result[0] === "object" &&
6366
- typeof result[1] === "function") {
6246
+ if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
6367
6247
  let data = result[0];
6368
6248
  let handleDataFunc = result[1];
6369
6249
  Object.keys(data).forEach((keyName) => {
@@ -6453,12 +6333,10 @@ class Utils {
6453
6333
  getRandomValue(...args) {
6454
6334
  let result = [...args];
6455
6335
  if (result.length > 1) {
6456
- if (result.length === 2 &&
6457
- typeof result[0] === "number" &&
6458
- typeof result[1] === "number") {
6336
+ if (result.length === 2 && typeof result[0] === "number" && typeof result[1] === "number") {
6459
6337
  let leftNumber = result[0] > result[1] ? result[1] : result[0];
6460
6338
  let rightNumber = result[0] > result[1] ? result[0] : result[1];
6461
- return (Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber);
6339
+ return Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber;
6462
6340
  }
6463
6341
  else {
6464
6342
  return result[Math.floor(Math.random() * result.length)];
@@ -6469,8 +6347,7 @@ class Utils {
6469
6347
  if (Array.isArray(paramData)) {
6470
6348
  return paramData[Math.floor(Math.random() * paramData.length)];
6471
6349
  }
6472
- else if (typeof paramData === "object" &&
6473
- Object.keys(paramData).length > 0) {
6350
+ else if (typeof paramData === "object" && Object.keys(paramData).length > 0) {
6474
6351
  let paramObjDataKey = Object.keys(paramData)[Math.floor(Math.random() * Object.keys(paramData).length)];
6475
6352
  return paramData[paramObjDataKey];
6476
6353
  }
@@ -6777,11 +6654,9 @@ class Utils {
6777
6654
  let nearBottomHeight = 50;
6778
6655
  let checkWindow = () => {
6779
6656
  // 已滚动的距离
6780
- let scrollTop = this.windowApi.window.pageYOffset ||
6781
- this.windowApi.document.documentElement.scrollTop;
6657
+ let scrollTop = this.windowApi.window.pageYOffset || this.windowApi.document.documentElement.scrollTop;
6782
6658
  // 视窗高度
6783
- let viewportHeight = this.windowApi.window.innerHeight ||
6784
- this.windowApi.document.documentElement.clientHeight;
6659
+ let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
6785
6660
  // 最大滚动距离
6786
6661
  let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
6787
6662
  return scrollTop + viewportHeight >= maxScrollHeight;
@@ -6832,7 +6707,6 @@ class Utils {
6832
6707
  }
6833
6708
  isJQuery(target) {
6834
6709
  let result = false;
6835
- // @ts-ignore
6836
6710
  if (typeof jQuery === "object" && target instanceof jQuery) {
6837
6711
  result = true;
6838
6712
  }
@@ -7071,8 +6945,7 @@ class Utils {
7071
6945
  **/
7072
6946
  isNull = commonUtil.isNull.bind(commonUtil);
7073
6947
  isThemeDark() {
7074
- return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)")
7075
- .matches;
6948
+ return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
7076
6949
  }
7077
6950
  /**
7078
6951
  * 判断元素是否在页面中可见
@@ -7105,10 +6978,8 @@ class Utils {
7105
6978
  else {
7106
6979
  let domClientRect = domItem.getBoundingClientRect();
7107
6980
  if (inView) {
7108
- let viewportWidth = this.windowApi.window.innerWidth ||
7109
- this.windowApi.document.documentElement.clientWidth;
7110
- let viewportHeight = this.windowApi.window.innerHeight ||
7111
- this.windowApi.document.documentElement.clientHeight;
6981
+ let viewportWidth = this.windowApi.window.innerWidth || this.windowApi.document.documentElement.clientWidth;
6982
+ let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
7112
6983
  result = !(domClientRect.right < 0 ||
7113
6984
  domClientRect.left > viewportWidth ||
7114
6985
  domClientRect.bottom < 0 ||
@@ -7132,8 +7003,7 @@ class Utils {
7132
7003
  for (const key in Object.values(this.windowApi.top.window.via)) {
7133
7004
  if (Reflect.has(this.windowApi.top.window.via, key)) {
7134
7005
  let objValueFunc = this.windowApi.top.window.via[key];
7135
- if (typeof objValueFunc === "function" &&
7136
- UtilsContext.isNativeFunc(objValueFunc)) {
7006
+ if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
7137
7007
  result = true;
7138
7008
  }
7139
7009
  else {
@@ -7155,8 +7025,7 @@ class Utils {
7155
7025
  for (const key in Object.values(this.windowApi.top.window.mbrowser)) {
7156
7026
  if (Reflect.has(this.windowApi.top.window.mbrowser, key)) {
7157
7027
  let objValueFunc = this.windowApi.top.window.mbrowser[key];
7158
- if (typeof objValueFunc === "function" &&
7159
- UtilsContext.isNativeFunc(objValueFunc)) {
7028
+ if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
7160
7029
  result = true;
7161
7030
  }
7162
7031
  else {
@@ -7393,13 +7262,11 @@ class Utils {
7393
7262
  * 释放所有
7394
7263
  */
7395
7264
  function releaseAll() {
7396
- if (typeof UtilsContext.windowApi.window[needReleaseKey] !==
7397
- "undefined") {
7265
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] !== "undefined") {
7398
7266
  /* 已存在 */
7399
7267
  return;
7400
7268
  }
7401
- UtilsContext.windowApi.window[needReleaseKey] =
7402
- UtilsContext.deepClone(needReleaseObject);
7269
+ UtilsContext.windowApi.window[needReleaseKey] = UtilsContext.deepClone(needReleaseObject);
7403
7270
  Object.values(needReleaseObject).forEach((value) => {
7404
7271
  if (typeof value === "function") {
7405
7272
  needReleaseObject[value.name] = () => { };
@@ -7413,8 +7280,7 @@ class Utils {
7413
7280
  Array.from(functionNameList).forEach((item) => {
7414
7281
  Object.values(needReleaseObject).forEach((value) => {
7415
7282
  if (typeof value === "function") {
7416
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7417
- "undefined") {
7283
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7418
7284
  UtilsContext.windowApi.window[needReleaseKey] = {};
7419
7285
  }
7420
7286
  if (item === value.name) {
@@ -7429,8 +7295,7 @@ class Utils {
7429
7295
  * 恢复所有
7430
7296
  */
7431
7297
  function recoveryAll() {
7432
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7433
- "undefined") {
7298
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7434
7299
  /* 未存在 */
7435
7300
  return;
7436
7301
  }
@@ -7441,8 +7306,7 @@ class Utils {
7441
7306
  * 恢复单个
7442
7307
  */
7443
7308
  function recoveryOne() {
7444
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7445
- "undefined") {
7309
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7446
7310
  /* 未存在 */
7447
7311
  return;
7448
7312
  }
@@ -7450,8 +7314,7 @@ class Utils {
7450
7314
  if (UtilsContext.windowApi.window[needReleaseKey][item]) {
7451
7315
  needReleaseObject[item] = UtilsContext.windowApi.window[needReleaseKey][item];
7452
7316
  Reflect.deleteProperty(UtilsContext.windowApi.window[needReleaseKey], item);
7453
- if (Object.keys(UtilsContext.windowApi.window[needReleaseKey])
7454
- .length === 0) {
7317
+ if (Object.keys(UtilsContext.windowApi.window[needReleaseKey]).length === 0) {
7455
7318
  Reflect.deleteProperty(window, needReleaseKey);
7456
7319
  }
7457
7320
  }
@@ -7613,29 +7476,27 @@ class Utils {
7613
7476
  EventTarget.prototype.addEventListener = function (...args) {
7614
7477
  let type = args[0];
7615
7478
  let callback = args[1];
7616
- // @ts-ignore
7617
- args[2];
7479
+ // let options = args[2];
7618
7480
  if (filter(type)) {
7619
7481
  if (typeof callback === "function") {
7620
7482
  args[1] = function (event) {
7621
7483
  callback.call(this, trustEvent(event));
7622
7484
  };
7623
7485
  }
7624
- else if (typeof callback === "object" &&
7625
- "handleEvent" in callback) {
7486
+ else if (typeof callback === "object" && "handleEvent" in callback) {
7626
7487
  let oldHandleEvent = callback["handleEvent"];
7627
7488
  args[1]["handleEvent"] = function (event) {
7628
7489
  if (event == null) {
7629
7490
  return;
7630
7491
  }
7631
7492
  try {
7632
- /* Proxy对象使用instanceof会报错 */
7493
+ // Proxy对象使用instanceof会报错
7494
+ // 这里故意尝试一下,如果报错,则说明是Proxy对象
7633
7495
  event instanceof Proxy;
7634
7496
  oldHandleEvent.call(this, trustEvent(event));
7635
7497
  }
7636
7498
  catch (error) {
7637
- // @ts-ignore
7638
- event["isTrusted"] = isTrustValue;
7499
+ Reflect.set(event, "isTrusted", isTrustValue);
7639
7500
  }
7640
7501
  };
7641
7502
  }
@@ -7708,10 +7569,9 @@ class Utils {
7708
7569
  }
7709
7570
  async init() {
7710
7571
  let copyStatus = false;
7711
- // @ts-ignore
7712
- await this.requestClipboardPermission();
7713
- if (this.hasClipboard() &&
7714
- (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
7572
+ let requestPermissionStatus = await this.requestClipboardPermission();
7573
+ console.log(requestPermissionStatus);
7574
+ if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
7715
7575
  try {
7716
7576
  copyStatus = await this.copyDataByClipboard();
7717
7577
  }
@@ -7727,11 +7587,8 @@ class Utils {
7727
7587
  this.destroy();
7728
7588
  }
7729
7589
  destroy() {
7730
- // @ts-ignore
7731
7590
  this.#resolve = null;
7732
- // @ts-ignore
7733
7591
  this.#copyData = null;
7734
- // @ts-ignore
7735
7592
  this.#copyDataType = null;
7736
7593
  }
7737
7594
  isText() {
@@ -7775,7 +7632,6 @@ class Utils {
7775
7632
  if (navigator.permissions && navigator.permissions.query) {
7776
7633
  navigator.permissions
7777
7634
  .query({
7778
- // @ts-ignore
7779
7635
  name: "clipboard-write",
7780
7636
  })
7781
7637
  .then((permissionStatus) => {
@@ -7871,17 +7727,13 @@ class Utils {
7871
7727
  dragSlider(selector, offsetX = this.windowApi.window.innerWidth) {
7872
7728
  let UtilsContext = this;
7873
7729
  function initMouseEvent(eventName, offSetX, offSetY) {
7874
- // @ts-ignore
7875
7730
  let win = typeof unsafeWindow === "undefined" ? globalThis : unsafeWindow;
7876
7731
  let mouseEvent = UtilsContext.windowApi.document.createEvent("MouseEvents");
7877
7732
  mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
7878
7733
  return mouseEvent;
7879
7734
  }
7880
- let sliderElement = typeof selector === "string"
7881
- ? domUtils.selector(selector)
7882
- : selector;
7883
- if (!(sliderElement instanceof Node) ||
7884
- !(sliderElement instanceof Element)) {
7735
+ let sliderElement = typeof selector === "string" ? domUtils.selector(selector) : selector;
7736
+ if (!(sliderElement instanceof Node) || !(sliderElement instanceof Element)) {
7885
7737
  throw new Error("Utils.dragSlider 参数selector 必须为Node/Element类型");
7886
7738
  }
7887
7739
  let rect = sliderElement.getBoundingClientRect(), x0 = rect.x || rect.left, y0 = rect.y || rect.top, x1 = x0 + offsetX, y1 = y0;
@@ -7933,17 +7785,14 @@ class Utils {
7933
7785
  }
7934
7786
  sortListByProperty(data, getPropertyValueFunc, sortByDesc = true) {
7935
7787
  let UtilsContext = this;
7936
- if (typeof getPropertyValueFunc !== "function" &&
7937
- typeof getPropertyValueFunc !== "string") {
7788
+ if (typeof getPropertyValueFunc !== "function" && typeof getPropertyValueFunc !== "string") {
7938
7789
  throw new Error("Utils.sortListByProperty 参数 getPropertyValueFunc 必须为 function|string 类型");
7939
7790
  }
7940
7791
  if (typeof sortByDesc !== "boolean") {
7941
7792
  throw new Error("Utils.sortListByProperty 参数 sortByDesc 必须为 boolean 类型");
7942
7793
  }
7943
7794
  let getObjValue = function (obj) {
7944
- return typeof getPropertyValueFunc === "string"
7945
- ? obj[getPropertyValueFunc]
7946
- : getPropertyValueFunc(obj);
7795
+ return typeof getPropertyValueFunc === "string" ? obj[getPropertyValueFunc] : getPropertyValueFunc(obj);
7947
7796
  };
7948
7797
  /**
7949
7798
  * 排序方法
@@ -8018,8 +7867,7 @@ class Utils {
8018
7867
  if (Array.isArray(data)) {
8019
7868
  data.sort(sortFunc);
8020
7869
  }
8021
- else if (data instanceof NodeList ||
8022
- UtilsContext.isJQuery(data)) {
7870
+ else if (data instanceof NodeList || UtilsContext.isJQuery(data)) {
8023
7871
  sortNodeFunc(data, getDataFunc);
8024
7872
  result = getDataFunc();
8025
7873
  }
@@ -8030,7 +7878,6 @@ class Utils {
8030
7878
  }
8031
7879
  stringToRegular(targetString, flags = "ig") {
8032
7880
  let reg;
8033
- // @ts-ignore
8034
7881
  flags = flags.toLowerCase();
8035
7882
  if (typeof targetString === "string") {
8036
7883
  reg = new RegExp(targetString.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"), flags);
@@ -8123,10 +7970,8 @@ class Utils {
8123
7970
  */
8124
7971
  searchParamStrToObj(searhParamsStr) {
8125
7972
  if (typeof searhParamsStr !== "string") {
8126
- // @ts-ignore
8127
7973
  return {};
8128
7974
  }
8129
- // @ts-ignore
8130
7975
  return Object.fromEntries(new URLSearchParams(searhParamsStr));
8131
7976
  }
8132
7977
  /**
@@ -8215,9 +8060,7 @@ class Utils {
8215
8060
  let parent = UtilsContext.windowApi.document;
8216
8061
  // 超时时间
8217
8062
  let timeout = 0;
8218
- if (typeof args[0] !== "string" &&
8219
- !Array.isArray(args[0]) &&
8220
- typeof args[0] !== "function") {
8063
+ if (typeof args[0] !== "string" && !Array.isArray(args[0]) && typeof args[0] !== "function") {
8221
8064
  throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
8222
8065
  }
8223
8066
  if (args.length === 1) ;
@@ -8227,8 +8070,7 @@ class Utils {
8227
8070
  // "div",10000
8228
8071
  timeout = secondParam;
8229
8072
  }
8230
- else if (typeof secondParam === "object" &&
8231
- secondParam instanceof Node) {
8073
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8232
8074
  // "div",document
8233
8075
  parent = secondParam;
8234
8076
  }
@@ -8314,8 +8156,7 @@ class Utils {
8314
8156
  // "div",10000
8315
8157
  timeout = secondParam;
8316
8158
  }
8317
- else if (typeof secondParam === "object" &&
8318
- secondParam instanceof Node) {
8159
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8319
8160
  // "div",document
8320
8161
  parent = secondParam;
8321
8162
  }
@@ -8370,8 +8211,7 @@ class Utils {
8370
8211
  // "div",10000
8371
8212
  timeout = secondParam;
8372
8213
  }
8373
- else if (typeof secondParam === "object" &&
8374
- secondParam instanceof Node) {
8214
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8375
8215
  // "div",document
8376
8216
  parent = secondParam;
8377
8217
  }
@@ -8457,8 +8297,7 @@ class Utils {
8457
8297
  // "div",10000
8458
8298
  timeout = secondParam;
8459
8299
  }
8460
- else if (typeof secondParam === "object" &&
8461
- secondParam instanceof Node) {
8300
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8462
8301
  // "div",document
8463
8302
  parent = secondParam;
8464
8303
  }
@@ -8591,8 +8430,7 @@ class Utils {
8591
8430
  return flag;
8592
8431
  }
8593
8432
  watchObject(target, propertyName, getCallBack, setCallBack) {
8594
- if (typeof getCallBack !== "function" &&
8595
- typeof setCallBack !== "function") {
8433
+ if (typeof getCallBack !== "function" && typeof setCallBack !== "function") {
8596
8434
  return;
8597
8435
  }
8598
8436
  if (typeof getCallBack === "function") {
@@ -8644,13 +8482,27 @@ class Utils {
8644
8482
  return;
8645
8483
  }
8646
8484
  let handleResult = handler(target);
8647
- if (handleResult &&
8648
- typeof handleResult.isFind === "boolean" &&
8649
- handleResult.isFind) {
8485
+ if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
8650
8486
  return handleResult.data;
8651
8487
  }
8652
8488
  return this.queryProperty(handleResult.data, handler);
8653
8489
  }
8490
+ /**
8491
+ * 异步-深度获取对象属性
8492
+ * @param target 待获取的对象
8493
+ * @param handler 获取属性的回调
8494
+ */
8495
+ async asyncQueryProperty(target, handler) {
8496
+ if (target == null) {
8497
+ // @ts-ignore
8498
+ return;
8499
+ }
8500
+ let handleResult = await handler(target);
8501
+ if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
8502
+ return handleResult.data;
8503
+ }
8504
+ return await this.asyncQueryProperty(handleResult.data, handler);
8505
+ }
8654
8506
  /**
8655
8507
  * 创建一个新的Utils实例
8656
8508
  * @param option
@@ -8829,7 +8681,6 @@ class Utils {
8829
8681
  function requestPermissionsWithClipboard() {
8830
8682
  navigator.permissions
8831
8683
  .query({
8832
- // @ts-ignore
8833
8684
  name: "clipboard-read",
8834
8685
  })
8835
8686
  .then((permissionStatus) => {