@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.umd.js CHANGED
@@ -21,14 +21,13 @@
21
21
  /**
22
22
  * 16进制颜色转rgba
23
23
  *
24
- * #ff0000 rgba(123,123,123, 0.4)
24
+ * 例如:`#ff0000` 转为 `rgba(123,123,123, 0.4)`
25
25
  * @param hex
26
26
  * @param opacity
27
27
  */
28
28
  hexToRgba(hex, opacity) {
29
29
  if (!this.isHex(hex)) {
30
- // @ts-ignore
31
- throw new TypeError("输入错误的hex", hex);
30
+ throw new TypeError("输入错误的hex:" + hex);
32
31
  }
33
32
  return hex && hex.replace(/\s+/g, "").length === 7
34
33
  ? "rgba(" +
@@ -45,19 +44,16 @@
45
44
  /**
46
45
  * hex转rgb
47
46
  * @param str
48
- * @returns
49
47
  */
50
48
  hexToRgb(str) {
51
49
  if (!this.isHex(str)) {
52
- // @ts-ignore
53
- throw new TypeError("输入错误的hex", str);
50
+ throw new TypeError("输入错误的hex:" + str);
54
51
  }
55
52
  /* replace替换查找的到的字符串 */
56
53
  str = str.replace("#", "");
57
54
  /* match得到查询数组 */
58
55
  let hxs = str.match(/../g);
59
56
  for (let index = 0; index < 3; index++) {
60
- // @ts-ignore
61
57
  hxs[index] = parseInt(hxs[index], 16);
62
58
  }
63
59
  return hxs;
@@ -67,7 +63,6 @@
67
63
  * @param redValue
68
64
  * @param greenValue
69
65
  * @param blueValue
70
- * @returns
71
66
  */
72
67
  rgbToHex(redValue, greenValue, blueValue) {
73
68
  /* 验证输入的rgb值是否合法 */
@@ -76,11 +71,7 @@
76
71
  !validPattern.test(greenValue.toString()) ||
77
72
  !validPattern.test(blueValue.toString()))
78
73
  throw new TypeError("输入错误的rgb颜色值");
79
- let hexs = [
80
- redValue.toString(16),
81
- greenValue.toString(16),
82
- blueValue.toString(16),
83
- ];
74
+ let hexs = [redValue.toString(16), greenValue.toString(16), blueValue.toString(16)];
84
75
  for (let index = 0; index < 3; index++)
85
76
  if (hexs[index].length == 1)
86
77
  hexs[index] = "0" + hexs[index];
@@ -90,38 +81,30 @@
90
81
  * 获取颜色变暗或亮
91
82
  * @param color 颜色
92
83
  * @param level 0~1.0
93
- * @returns
94
84
  */
95
85
  getDarkColor(color, level) {
96
86
  if (!this.isHex(color)) {
97
- // @ts-ignore
98
- throw new TypeError("输入错误的hex", color);
87
+ throw new TypeError("输入错误的hex:" + color);
99
88
  }
100
89
  let rgbc = this.hexToRgb(color);
101
90
  for (let index = 0; index < 3; index++) {
102
- // @ts-ignore
103
91
  rgbc[index] = Math.floor(rgbc[index] * (1 - level));
104
92
  }
105
- // @ts-ignore
106
93
  return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
107
94
  }
108
95
  /**
109
96
  * 获取颜色变亮
110
97
  * @param color 颜色
111
98
  * @param level 0~1.0
112
- * @returns
113
99
  */
114
100
  getLightColor(color, level) {
115
101
  if (!this.isHex(color)) {
116
- // @ts-ignore
117
- throw new TypeError("输入错误的hex", color);
102
+ throw new TypeError("输入错误的hex:" + color);
118
103
  }
119
104
  let rgbc = this.hexToRgb(color);
120
105
  for (let index = 0; index < 3; index++) {
121
- // @ts-ignore
122
106
  rgbc[index] = Math.floor((255 - rgbc[index]) * level + rgbc[index]);
123
107
  }
124
- // @ts-ignore
125
108
  return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
126
109
  }
127
110
  }
@@ -136,10 +119,7 @@
136
119
  this.#data = dataText.match(/..../g);
137
120
  for (let i = 0x81; i <= 0xfe; i++) {
138
121
  for (let j = 0x40; j <= 0xfe; j++) {
139
- this.#U2Ghash[this.#data[index++]] = ("%" +
140
- i.toString(16) +
141
- "%" +
142
- j.toString(16)).toUpperCase();
122
+ this.#U2Ghash[this.#data[index++]] = ("%" + i.toString(16) + "%" + j.toString(16)).toUpperCase();
143
123
  }
144
124
  }
145
125
  for (let key in this.#U2Ghash) {
@@ -209,20 +189,20 @@
209
189
  * @param str
210
190
  */
211
191
  decode(str) {
212
- var GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
213
- var UTFMatcher = /%[0-9A-F]{2}/;
214
- // @ts-ignore
215
- var utf = true;
216
- let that = this;
192
+ let GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
193
+ let UTFMatcher = /%[0-9A-F]{2}/;
194
+ // let gbk = true;
195
+ let utf = true;
196
+ const that = this;
217
197
  while (utf) {
218
198
  let gbkMatch = str.match(GBKMatcher);
219
199
  let utfMatch = str.match(UTFMatcher);
200
+ // gbk = Boolean(gbkMatch);
220
201
  utf = Boolean(utfMatch);
221
202
  if (gbkMatch && gbkMatch in that.#G2Uhash) {
222
203
  str = str.replace(gbkMatch, String.fromCharCode(("0x" + that.#G2Uhash[gbkMatch])));
223
204
  }
224
205
  else {
225
- // @ts-ignore
226
206
  str = str.replace(utfMatch, decodeURIComponent(utfMatch));
227
207
  }
228
208
  }
@@ -253,7 +233,6 @@
253
233
  * @param handler
254
234
  */
255
235
  error(handler) {
256
- // @ts-ignore
257
236
  handleError = handler;
258
237
  return TryCatchCore;
259
238
  },
@@ -268,7 +247,6 @@
268
247
  callbackFunction = callback;
269
248
  context = __context__ || this;
270
249
  let result = executeTryCatch(callbackFunction, handleError, context);
271
- // @ts-ignore
272
250
  return result !== void 0 ? result : TryCatchCore;
273
251
  },
274
252
  };
@@ -298,10 +276,7 @@
298
276
  }
299
277
  if (handleErrorFunc) {
300
278
  if (typeof handleErrorFunc === "string") {
301
- result = new Function(handleErrorFunc).apply(funcThis, [
302
- ...args,
303
- error,
304
- ]);
279
+ result = new Function(handleErrorFunc).apply(funcThis, [...args, error]);
305
280
  }
306
281
  else {
307
282
  result = handleErrorFunc.apply(funcThis, [...args, error]);
@@ -389,10 +364,7 @@
389
364
  itemResult = objItem === 0;
390
365
  break;
391
366
  case "string":
392
- itemResult =
393
- objItem.trim() === "" ||
394
- objItem === "null" ||
395
- objItem === "undefined";
367
+ itemResult = objItem.trim() === "" || objItem === "null" || objItem === "undefined";
396
368
  break;
397
369
  case "boolean":
398
370
  itemResult = !objItem;
@@ -433,8 +405,7 @@
433
405
  return null;
434
406
  let clone = obj instanceof Array ? [] : {};
435
407
  for (const [key, value] of Object.entries(obj)) {
436
- clone[key] =
437
- typeof value === "object" ? UtilsContext.deepClone(value) : value;
408
+ clone[key] = typeof value === "object" ? UtilsContext.deepClone(value) : value;
438
409
  }
439
410
  return clone;
440
411
  }
@@ -1953,35 +1924,30 @@
1953
1924
  let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
1954
1925
  /** 油猴菜单上显示的文本 */
1955
1926
  let showText = menuOption.showText(menuOption.text, defaultEnable);
1956
- // @ts-ignore
1957
- ({
1958
- /**
1959
- * 菜单的id
1960
- */
1961
- id: menuOption.id,
1962
- /**
1963
- * 点击菜单项后是否应关闭弹出菜单
1964
- */
1965
- autoClose: menuOption.autoClose,
1966
- /**
1967
- * 菜单项的可选访问键
1968
- */
1969
- accessKey: menuOption.accessKey,
1970
- /**
1971
- * 菜单项的鼠标悬浮上的工具提示
1972
- */
1973
- title: menuOption.title,
1974
- });
1927
+ // const GMMenuOptions = {
1928
+ // /**
1929
+ // * 菜单的id
1930
+ // */
1931
+ // id: menuOption.id,
1932
+ // /**
1933
+ // * 点击菜单项后是否应关闭弹出菜单
1934
+ // */
1935
+ // autoClose: menuOption.autoClose,
1936
+ // /**
1937
+ // * 菜单项的可选访问键
1938
+ // */
1939
+ // accessKey: menuOption.accessKey,
1940
+ // /**
1941
+ // * 菜单项的鼠标悬浮上的工具提示
1942
+ // */
1943
+ // title: menuOption.title,
1944
+ // };
1975
1945
  /* 点击菜单后触发callback后的网页是否刷新 */
1976
1946
  menuOption.autoReload =
1977
- typeof menuOption.autoReload !== "boolean"
1978
- ? this.$default.autoReload
1979
- : menuOption.autoReload;
1947
+ typeof menuOption.autoReload !== "boolean" ? this.$default.autoReload : menuOption.autoReload;
1980
1948
  /* 点击菜单后触发callback后的网页是否存储值 */
1981
1949
  menuOption.isStoreValue =
1982
- typeof menuOption.isStoreValue !== "boolean"
1983
- ? this.$default.isStoreValue
1984
- : menuOption.isStoreValue;
1950
+ typeof menuOption.isStoreValue !== "boolean" ? this.$default.isStoreValue : menuOption.isStoreValue;
1985
1951
  /**
1986
1952
  * 用户点击菜单后的回调函数
1987
1953
  * @param event
@@ -2034,8 +2000,7 @@
2034
2000
  * @param menuKey 菜单-键key
2035
2001
  */
2036
2002
  getMenuHandledOption(menuKey) {
2037
- return this.$data.data.find((item) => item.handleData.key === menuKey)
2038
- ?.handleData;
2003
+ return this.$data.data.find((item) => item.handleData.key === menuKey)?.handleData;
2039
2004
  },
2040
2005
  };
2041
2006
  constructor(details) {
@@ -2043,8 +2008,7 @@
2043
2008
  this.GM_Api.setValue = details.GM_setValue;
2044
2009
  this.GM_Api.registerMenuCommand = details.GM_registerMenuCommand;
2045
2010
  this.GM_Api.unregisterMenuCommand = details.GM_unregisterMenuCommand;
2046
- this.MenuHandle.$default.autoReload =
2047
- typeof details.autoReload === "boolean" ? details.autoReload : true;
2011
+ this.MenuHandle.$default.autoReload = typeof details.autoReload === "boolean" ? details.autoReload : true;
2048
2012
  for (const keyName of Object.keys(this.GM_Api)) {
2049
2013
  if (typeof this.GM_Api[keyName] !== "function") {
2050
2014
  throw new Error(`Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`);
@@ -2276,8 +2240,7 @@
2276
2240
  _context = context || window;
2277
2241
  _funcName = getFuncName(this);
2278
2242
  _context["realFunc_" + _funcName] = this;
2279
- if (_context[_funcName].prototype &&
2280
- _context[_funcName].prototype.isHooked) {
2243
+ if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
2281
2244
  console.log("Already has been hooked,unhook first");
2282
2245
  return false;
2283
2246
  }
@@ -2455,8 +2418,7 @@
2455
2418
  if (details.allowInterceptConfig != null) {
2456
2419
  // 配置存在
2457
2420
  // 细分处理是否拦截
2458
- if (typeof details.allowInterceptConfig.afterResponseSuccess ===
2459
- "boolean" &&
2421
+ if (typeof details.allowInterceptConfig.afterResponseSuccess === "boolean" &&
2460
2422
  !details.allowInterceptConfig.afterResponseSuccess) {
2461
2423
  // 设置了禁止拦截
2462
2424
  return details;
@@ -2491,8 +2453,7 @@
2491
2453
  if (data.details.allowInterceptConfig != null) {
2492
2454
  // 配置存在
2493
2455
  // 细分处理是否拦截
2494
- if (typeof data.details.allowInterceptConfig.afterResponseError ===
2495
- "boolean" &&
2456
+ if (typeof data.details.allowInterceptConfig.afterResponseError === "boolean" &&
2496
2457
  !data.details.allowInterceptConfig.afterResponseError) {
2497
2458
  // 设置了禁止拦截
2498
2459
  return data;
@@ -2549,7 +2510,9 @@
2549
2510
  * 对请求的参数进行合并处理
2550
2511
  */
2551
2512
  handleBeforeRequestOptionArgs(...args) {
2552
- let option = {};
2513
+ let option = {
2514
+ url: void 0,
2515
+ };
2553
2516
  if (typeof args[0] === "string") {
2554
2517
  /* 传入的是url,转为配置 */
2555
2518
  let url = args[0];
@@ -2573,7 +2536,7 @@
2573
2536
  * @param method 当前请求方法,默认get
2574
2537
  * @param userRequestOption 用户的请求配置
2575
2538
  * @param resolve promise回调
2576
- * @param reject 抛出错误回调
2539
+ * @param reject promise抛出错误回调
2577
2540
  */
2578
2541
  getRequestOption(method, userRequestOption, resolve, reject) {
2579
2542
  let that = this;
@@ -2592,64 +2555,51 @@
2592
2555
  let requestOption = {
2593
2556
  url: url,
2594
2557
  method: (method || "GET").toString().toUpperCase().trim(),
2595
- timeout: userRequestOption.timeout ||
2596
- this.context.#defaultRequestOption.timeout,
2597
- responseType: userRequestOption.responseType ||
2598
- this.context.#defaultRequestOption.responseType,
2558
+ timeout: userRequestOption.timeout || this.context.#defaultRequestOption.timeout,
2559
+ responseType: userRequestOption.responseType || this.context.#defaultRequestOption.responseType,
2599
2560
  /* 对象使用深拷贝 */
2600
2561
  headers: commonUtil.deepClone(this.context.#defaultRequestOption.headers),
2601
2562
  data: userRequestOption.data || this.context.#defaultRequestOption.data,
2602
- redirect: userRequestOption.redirect ||
2603
- this.context.#defaultRequestOption.redirect,
2563
+ redirect: userRequestOption.redirect || this.context.#defaultRequestOption.redirect,
2604
2564
  cookie: userRequestOption.cookie || this.context.#defaultRequestOption.cookie,
2605
- cookiePartition: userRequestOption.cookiePartition ||
2606
- this.context.#defaultRequestOption.cookiePartition,
2565
+ cookiePartition: userRequestOption.cookiePartition || this.context.#defaultRequestOption.cookiePartition,
2607
2566
  binary: userRequestOption.binary || this.context.#defaultRequestOption.binary,
2608
- nocache: userRequestOption.nocache ||
2609
- this.context.#defaultRequestOption.nocache,
2610
- revalidate: userRequestOption.revalidate ||
2611
- this.context.#defaultRequestOption.revalidate,
2567
+ nocache: userRequestOption.nocache || this.context.#defaultRequestOption.nocache,
2568
+ revalidate: userRequestOption.revalidate || this.context.#defaultRequestOption.revalidate,
2612
2569
  /* 对象使用深拷贝 */
2613
- context: commonUtil.deepClone(userRequestOption.context ||
2614
- this.context.#defaultRequestOption.context),
2615
- overrideMimeType: userRequestOption.overrideMimeType ||
2616
- this.context.#defaultRequestOption.overrideMimeType,
2617
- anonymous: userRequestOption.anonymous ||
2618
- this.context.#defaultRequestOption.anonymous,
2570
+ context: commonUtil.deepClone(userRequestOption.context || this.context.#defaultRequestOption.context),
2571
+ overrideMimeType: userRequestOption.overrideMimeType || this.context.#defaultRequestOption.overrideMimeType,
2572
+ anonymous: userRequestOption.anonymous || this.context.#defaultRequestOption.anonymous,
2619
2573
  fetch: userRequestOption.fetch || this.context.#defaultRequestOption.fetch,
2620
2574
  /* 对象使用深拷贝 */
2621
2575
  fetchInit: commonUtil.deepClone(this.context.#defaultRequestOption.fetchInit),
2622
2576
  allowInterceptConfig: {
2623
- beforeRequest: this.context.#defaultRequestOption
2624
- .allowInterceptConfig.beforeRequest,
2625
- afterResponseSuccess: this.context.#defaultRequestOption
2626
- .allowInterceptConfig.afterResponseSuccess,
2627
- afterResponseError: this.context.#defaultRequestOption
2628
- .allowInterceptConfig.afterResponseError,
2577
+ beforeRequest: this.context.#defaultRequestOption.allowInterceptConfig.beforeRequest,
2578
+ afterResponseSuccess: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseSuccess,
2579
+ afterResponseError: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseError,
2629
2580
  },
2630
2581
  user: userRequestOption.user || this.context.#defaultRequestOption.user,
2631
- password: userRequestOption.password ||
2632
- this.context.#defaultRequestOption.password,
2582
+ password: userRequestOption.password || this.context.#defaultRequestOption.password,
2633
2583
  onabort(...args) {
2634
- that.context.HttpxCallBack.onAbort(userRequestOption, resolve, reject, args);
2584
+ that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
2635
2585
  },
2636
2586
  onerror(...args) {
2637
- that.context.HttpxCallBack.onError(userRequestOption, resolve, reject, args);
2587
+ that.context.HttpxResponseCallBack.onError(userRequestOption, resolve, reject, args);
2638
2588
  },
2639
2589
  onloadstart(...args) {
2640
- that.context.HttpxCallBack.onLoadStart(userRequestOption, args);
2590
+ that.context.HttpxResponseCallBack.onLoadStart(userRequestOption, args);
2641
2591
  },
2642
2592
  onprogress(...args) {
2643
- that.context.HttpxCallBack.onProgress(userRequestOption, args);
2593
+ that.context.HttpxResponseCallBack.onProgress(userRequestOption, args);
2644
2594
  },
2645
2595
  onreadystatechange(...args) {
2646
- that.context.HttpxCallBack.onReadyStateChange(userRequestOption, args);
2596
+ that.context.HttpxResponseCallBack.onReadyStateChange(userRequestOption, args);
2647
2597
  },
2648
2598
  ontimeout(...args) {
2649
- that.context.HttpxCallBack.onTimeout(userRequestOption, resolve, reject, args);
2599
+ that.context.HttpxResponseCallBack.onTimeout(userRequestOption, resolve, reject, args);
2650
2600
  },
2651
2601
  onload(...args) {
2652
- that.context.HttpxCallBack.onLoad(userRequestOption, resolve, reject, args);
2602
+ that.context.HttpxResponseCallBack.onLoad(userRequestOption, resolve, reject, args);
2653
2603
  },
2654
2604
  };
2655
2605
  // 补全allowInterceptConfig参数
@@ -2677,14 +2627,12 @@
2677
2627
  if (typeof requestOption.headers === "object") {
2678
2628
  if (typeof userRequestOption.headers === "object") {
2679
2629
  Object.keys(userRequestOption.headers).forEach((keyName, index) => {
2680
- if (keyName in requestOption.headers &&
2681
- userRequestOption.headers?.[keyName] == null) {
2630
+ if (keyName in requestOption.headers && userRequestOption.headers?.[keyName] == null) {
2682
2631
  /* 在默认的header中存在,且设置它新的值为空,那么就是默认的值 */
2683
2632
  Reflect.deleteProperty(requestOption.headers, keyName);
2684
2633
  }
2685
2634
  else {
2686
- requestOption.headers[keyName] =
2687
- userRequestOption?.headers?.[keyName];
2635
+ requestOption.headers[keyName] = userRequestOption?.headers?.[keyName];
2688
2636
  }
2689
2637
  });
2690
2638
  }
@@ -2697,8 +2645,7 @@
2697
2645
  /* 使用assign替换且添加 */
2698
2646
  if (typeof userRequestOption.fetchInit === "object") {
2699
2647
  Object.keys(userRequestOption.fetchInit).forEach((keyName, index) => {
2700
- if (keyName in requestOption.fetchInit &&
2701
- userRequestOption.fetchInit[keyName] == null) {
2648
+ if (keyName in requestOption.fetchInit && userRequestOption.fetchInit[keyName] == null) {
2702
2649
  /* 在默认的fetchInit中存在,且设置它新的值为空,那么就是默认的值 */
2703
2650
  Reflect.deleteProperty(requestOption.fetchInit, keyName);
2704
2651
  }
@@ -2712,8 +2659,7 @@
2712
2659
  Reflect.set(requestOption, "fetchInit", userRequestOption.fetchInit);
2713
2660
  }
2714
2661
  // 处理新的cookiePartition
2715
- if (typeof requestOption.cookiePartition === "object" &&
2716
- requestOption.cookiePartition != null) {
2662
+ if (typeof requestOption.cookiePartition === "object" && requestOption.cookiePartition != null) {
2717
2663
  if (Reflect.has(requestOption.cookiePartition, "topLevelSite") &&
2718
2664
  typeof requestOption.cookiePartition.topLevelSite !== "string") {
2719
2665
  // topLevelSite必须是字符串
@@ -2735,8 +2681,7 @@
2735
2681
  }
2736
2682
  else {
2737
2683
  // 补充origin+/
2738
- requestOption.url =
2739
- globalThis.location.origin + "/" + requestOption.url;
2684
+ requestOption.url = globalThis.location.origin + "/" + requestOption.url;
2740
2685
  }
2741
2686
  }
2742
2687
  if (requestOption.fetchInit && !requestOption.fetch) {
@@ -2761,7 +2706,6 @@
2761
2706
  else if (typeof requestOption.data === "object") {
2762
2707
  isHandler = true;
2763
2708
  // URLSearchParams参数可以转普通的string:string,包括FormData
2764
- // @ts-ignore
2765
2709
  let searchParams = new URLSearchParams(requestOption.data);
2766
2710
  urlSearch = searchParams.toString();
2767
2711
  }
@@ -2816,9 +2760,7 @@
2816
2760
  else if (ContentType.includes("application/x-www-form-urlencoded")) {
2817
2761
  // application/x-www-form-urlencoded
2818
2762
  if (typeof requestOption.data === "object") {
2819
- requestOption.data = new URLSearchParams(
2820
- // @ts-ignore
2821
- requestOption.data).toString();
2763
+ requestOption.data = new URLSearchParams(requestOption.data).toString();
2822
2764
  }
2823
2765
  }
2824
2766
  else if (ContentType.includes("multipart/form-data")) {
@@ -2838,7 +2780,7 @@
2838
2780
  },
2839
2781
  /**
2840
2782
  * 处理发送请求的配置,去除值为undefined、空function的值
2841
- * @param option
2783
+ * @param option 请求配置
2842
2784
  */
2843
2785
  removeRequestNullOption(option) {
2844
2786
  Object.keys(option).forEach((keyName) => {
@@ -2850,21 +2792,20 @@
2850
2792
  }
2851
2793
  });
2852
2794
  if (commonUtil.isNull(option.url)) {
2853
- throw new TypeError(`Utils.Httpx 参数 url不符合要求: ${option.url}`);
2795
+ throw new TypeError(`Utils.Httpx 参数url不能为空:${option.url}`);
2854
2796
  }
2855
2797
  return option;
2856
2798
  },
2857
2799
  /**
2858
2800
  * 处理fetch的配置
2859
- * @param option
2801
+ * @param option 请求配置
2860
2802
  */
2861
2803
  handleFetchOption(option) {
2862
2804
  /**
2863
2805
  * fetch的请求配置
2864
2806
  **/
2865
2807
  let fetchRequestOption = {};
2866
- if ((option.method === "GET" || option.method === "HEAD") &&
2867
- option.data != null) {
2808
+ if ((option.method === "GET" || option.method === "HEAD") && option.data != null) {
2868
2809
  /* GET 或 HEAD 方法的请求不能包含 body 信息 */
2869
2810
  Reflect.deleteProperty(option, "data");
2870
2811
  }
@@ -2909,21 +2850,21 @@
2909
2850
  };
2910
2851
  },
2911
2852
  };
2912
- HttpxCallBack = {
2853
+ HttpxResponseCallBack = {
2913
2854
  context: this,
2914
2855
  /**
2915
2856
  * onabort请求被取消-触发
2916
2857
  * @param details 配置
2917
- * @param resolve 回调
2918
- * @param reject 抛出错误
2858
+ * @param resolve promise回调
2859
+ * @param reject promise抛出错误回调
2919
2860
  * @param argsResult 返回的参数列表
2920
2861
  */
2921
2862
  async onAbort(details, resolve, reject, argsResult) {
2922
2863
  // console.log(argsResult);
2923
- if ("onabort" in details) {
2864
+ if (typeof details?.onabort === "function") {
2924
2865
  details.onabort.apply(this, argsResult);
2925
2866
  }
2926
- else if ("onabort" in this.context.#defaultRequestOption) {
2867
+ else if (typeof this.context.#defaultRequestOption?.onabort === "function") {
2927
2868
  this.context.#defaultRequestOption.onabort.apply(this, argsResult);
2928
2869
  }
2929
2870
  let response = argsResult;
@@ -2932,11 +2873,11 @@
2932
2873
  }
2933
2874
  if ((await this.context.HttpxResponseHook.errorResponseCallBack({
2934
2875
  type: "onabort",
2935
- error: new TypeError("request canceled"),
2876
+ error: new Error("request canceled"),
2936
2877
  response: null,
2937
2878
  details: details,
2938
2879
  })) == null) {
2939
- // reject(new TypeError("response is intercept with onabort"));
2880
+ // reject(new Error("response is intercept with onabort"));
2940
2881
  return;
2941
2882
  }
2942
2883
  resolve({
@@ -2949,93 +2890,83 @@
2949
2890
  });
2950
2891
  },
2951
2892
  /**
2952
- * onerror请求异常-触发
2893
+ * ontimeout请求超时-触发
2953
2894
  * @param details 配置
2954
2895
  * @param resolve 回调
2955
2896
  * @param reject 抛出错误
2956
2897
  * @param argsResult 返回的参数列表
2957
2898
  */
2958
- async onError(details, resolve, reject, argsResult) {
2899
+ async onTimeout(details, resolve, reject, argsResult) {
2959
2900
  // console.log(argsResult);
2960
- if ("onerror" in details) {
2961
- details.onerror.apply(this, argsResult);
2901
+ if (typeof details?.ontimeout === "function") {
2902
+ // 执行配置中的ontime回调
2903
+ details.ontimeout.apply(this, argsResult);
2962
2904
  }
2963
- else if ("onerror" in this.context.#defaultRequestOption) {
2964
- this.context.#defaultRequestOption.onerror.apply(this, argsResult);
2905
+ else if (typeof this.context.#defaultRequestOption?.ontimeout === "function") {
2906
+ // 执行默认配置的ontime回调
2907
+ this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
2965
2908
  }
2909
+ // 获取响应结果
2966
2910
  let response = argsResult;
2967
2911
  if (response.length) {
2968
2912
  response = response[0];
2969
2913
  }
2914
+ // 执行错误回调的钩子
2970
2915
  if ((await this.context.HttpxResponseHook.errorResponseCallBack({
2971
- type: "onerror",
2972
- error: new TypeError("request error"),
2916
+ type: "ontimeout",
2917
+ error: new Error("request timeout"),
2973
2918
  response: response,
2974
2919
  details: details,
2975
2920
  })) == null) {
2976
- // reject(new TypeError("response is intercept with onerror"));
2921
+ // reject(new Error("response is intercept with ontimeout"));
2977
2922
  return;
2978
2923
  }
2979
2924
  resolve({
2980
2925
  data: response,
2981
2926
  details: details,
2982
- msg: "请求异常",
2927
+ msg: "请求超时",
2983
2928
  status: false,
2984
- statusCode: response["status"],
2985
- type: "onerror",
2929
+ statusCode: 0,
2930
+ type: "ontimeout",
2986
2931
  });
2987
2932
  },
2988
2933
  /**
2989
- * ontimeout请求超时-触发
2934
+ * onerror请求异常-触发
2990
2935
  * @param details 配置
2991
2936
  * @param resolve 回调
2992
2937
  * @param reject 抛出错误
2993
2938
  * @param argsResult 返回的参数列表
2994
2939
  */
2995
- async onTimeout(details, resolve, reject, argsResult) {
2940
+ async onError(details, resolve, reject, argsResult) {
2996
2941
  // console.log(argsResult);
2997
- if ("ontimeout" in details) {
2998
- details.ontimeout.apply(this, argsResult);
2942
+ if (typeof details?.onerror === "function") {
2943
+ details.onerror.apply(this, argsResult);
2999
2944
  }
3000
- else if ("ontimeout" in this.context.#defaultRequestOption) {
3001
- this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
2945
+ else if (typeof this.context.#defaultRequestOption?.onerror === "function") {
2946
+ this.context.#defaultRequestOption.onerror.apply(this, argsResult);
3002
2947
  }
3003
2948
  let response = argsResult;
3004
2949
  if (response.length) {
3005
2950
  response = response[0];
3006
2951
  }
3007
2952
  if ((await this.context.HttpxResponseHook.errorResponseCallBack({
3008
- type: "ontimeout",
3009
- error: new TypeError("request timeout"),
3010
- response: (argsResult || [null])[0],
2953
+ type: "onerror",
2954
+ error: new Error("request error"),
2955
+ response: response,
3011
2956
  details: details,
3012
2957
  })) == null) {
3013
- // reject(new TypeError("response is intercept with ontimeout"));
2958
+ // reject(new Error("response is intercept with onerror"));
3014
2959
  return;
3015
2960
  }
3016
2961
  resolve({
3017
2962
  data: response,
3018
2963
  details: details,
3019
- msg: "请求超时",
2964
+ msg: "请求异常",
3020
2965
  status: false,
3021
- statusCode: 0,
3022
- type: "ontimeout",
2966
+ statusCode: response["status"],
2967
+ type: "onerror",
3023
2968
  });
3024
2969
  },
3025
- /**
3026
- * onloadstart请求开始-触发
3027
- * @param details 配置
3028
- * @param argsResult 返回的参数列表
3029
- */
3030
- onLoadStart(details, argsResult) {
3031
- // console.log(argsResult);
3032
- if ("onloadstart" in details) {
3033
- details.onloadstart.apply(this, argsResult);
3034
- }
3035
- else if ("onloadstart" in this.context.#defaultRequestOption) {
3036
- this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
3037
- }
3038
- },
3039
2970
  /**
3040
2971
  * onload加载完毕-触发
3041
2972
  * @param details 请求的配置
@@ -3115,7 +3046,7 @@
3115
3046
  /* 状态码2xx都是成功的 */
3116
3047
  if (Math.floor(originResponse.status / 100) === 2) {
3117
3048
  if ((await this.context.HttpxResponseHook.successResponseCallBack(originResponse, details)) == null) {
3118
- // reject(new TypeError("response is intercept with onloada"));
3049
+ // reject(new Error("response is intercept with onloada"));
3119
3050
  return;
3120
3051
  }
3121
3052
  resolve({
@@ -3128,21 +3059,21 @@
3128
3059
  });
3129
3060
  }
3130
3061
  else {
3131
- this.context.HttpxCallBack.onError(details, resolve, reject, argsResult);
3062
+ this.context.HttpxResponseCallBack.onError(details, resolve, reject, argsResult);
3132
3063
  }
3133
3064
  },
3134
3065
  /**
3135
- * onprogress上传进度-触发
3066
+ * onloadstart请求开始-触发
3136
3067
  * @param details 配置
3137
3068
  * @param argsResult 返回的参数列表
3138
3069
  */
3139
- onProgress(details, argsResult) {
3070
+ onLoadStart(details, argsResult) {
3140
3071
  // console.log(argsResult);
3141
- if ("onprogress" in details) {
3142
- details.onprogress.apply(this, argsResult);
3072
+ if (typeof details?.onloadstart === "function") {
3073
+ details.onloadstart.apply(this, argsResult);
3143
3074
  }
3144
- else if ("onprogress" in this.context.#defaultRequestOption) {
3145
- this.context.#defaultRequestOption.onprogress.apply(this, argsResult);
3075
+ else if (typeof this.context.#defaultRequestOption?.onloadstart === "function") {
3076
+ this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
3146
3077
  }
3147
3078
  },
3148
3079
  /**
@@ -3152,13 +3083,27 @@
3152
3083
  */
3153
3084
  onReadyStateChange(details, argsResult) {
3154
3085
  // console.log(argsResult);
3155
- if ("onreadystatechange" in details) {
3086
+ if (typeof details?.onreadystatechange === "function") {
3156
3087
  details.onreadystatechange.apply(this, argsResult);
3157
3088
  }
3158
- else if ("onreadystatechange" in this.context.#defaultRequestOption) {
3089
+ else if (typeof this.context.#defaultRequestOption?.onreadystatechange === "function") {
3159
3090
  this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
3160
3091
  }
3161
3092
  },
3093
+ /**
3094
+ * onprogress上传进度-触发
3095
+ * @param details 配置
3096
+ * @param argsResult 返回的参数列表
3097
+ */
3098
+ onProgress(details, argsResult) {
3099
+ // console.log(argsResult);
3100
+ if (typeof details?.onprogress === "function") {
3101
+ details.onprogress.apply(this, argsResult);
3102
+ }
3103
+ else if (typeof this.context.#defaultRequestOption?.onprogress === "function") {
3104
+ this.context.#defaultRequestOption.onprogress.apply(this, argsResult);
3105
+ }
3106
+ },
3162
3107
  };
3163
3108
  HttpxRequest = {
3164
3109
  context: this,
@@ -3170,8 +3115,7 @@
3170
3115
  if (this.context.#defaultInitOption.logDetails) {
3171
3116
  console.log("[Httpx-HttpxRequest.request] 请求前的配置👇", details);
3172
3117
  }
3173
- if (typeof this.context.HttpxRequestHook.beforeRequestCallBack ===
3174
- "function") {
3118
+ if (typeof this.context.HttpxRequestHook.beforeRequestCallBack === "function") {
3175
3119
  let hookResult = await this.context.HttpxRequestHook.beforeRequestCallBack(details);
3176
3120
  if (hookResult == null) {
3177
3121
  return;
@@ -3208,15 +3152,12 @@
3208
3152
  isFetch: true,
3209
3153
  finalUrl: fetchResponse.url,
3210
3154
  readyState: 4,
3211
- // @ts-ignore
3212
3155
  status: fetchResponse.status,
3213
3156
  statusText: fetchResponse.statusText,
3214
- // @ts-ignore
3215
- response: void 0,
3157
+ response: "",
3216
3158
  responseFetchHeaders: fetchResponse.headers,
3217
3159
  responseHeaders: "",
3218
- // @ts-ignore
3219
- responseText: void 0,
3160
+ responseText: "",
3220
3161
  responseType: option.responseType,
3221
3162
  responseXML: void 0,
3222
3163
  };
@@ -3230,9 +3171,7 @@
3230
3171
  /* 如果需要stream,且获取到的是stream,那直接返回 */
3231
3172
  if (option.responseType === "stream" ||
3232
3173
  (fetchResponse.headers.has("Content-Type") &&
3233
- fetchResponse.headers
3234
- .get("Content-Type")
3235
- .includes("text/event-stream"))) {
3174
+ fetchResponse.headers.get("Content-Type").includes("text/event-stream"))) {
3236
3175
  Reflect.set(httpxResponse, "isStream", true);
3237
3176
  Reflect.set(httpxResponse, "response", fetchResponse.body);
3238
3177
  Reflect.deleteProperty(httpxResponse, "responseText");
@@ -3251,9 +3190,7 @@
3251
3190
  /** 数据编码 */
3252
3191
  let encoding = "utf-8";
3253
3192
  if (fetchResponse.headers.has("Content-Type")) {
3254
- let charsetMatched = fetchResponse.headers
3255
- .get("Content-Type")
3256
- ?.match(/charset=(.+)/);
3193
+ let charsetMatched = fetchResponse.headers.get("Content-Type")?.match(/charset=(.+)/);
3257
3194
  if (charsetMatched) {
3258
3195
  encoding = charsetMatched[1];
3259
3196
  encoding = encoding.toLowerCase();
@@ -3275,13 +3212,11 @@
3275
3212
  response = new Blob([arrayBuffer]);
3276
3213
  }
3277
3214
  else if (option.responseType === "json" ||
3278
- (typeof fetchResponseType === "string" &&
3279
- fetchResponseType.includes("application/json"))) {
3215
+ (typeof fetchResponseType === "string" && fetchResponseType.includes("application/json"))) {
3280
3216
  // response返回格式是JSON格式
3281
3217
  response = commonUtil.toJSON(responseText);
3282
3218
  }
3283
- else if (option.responseType === "document" ||
3284
- option.responseType == null) {
3219
+ else if (option.responseType === "document" || option.responseType == null) {
3285
3220
  // response返回格式是文档格式
3286
3221
  let parser = new DOMParser();
3287
3222
  response = parser.parseFromString(responseText, "text/html");
@@ -3289,9 +3224,9 @@
3289
3224
  // 转为XML结构
3290
3225
  let parser = new DOMParser();
3291
3226
  responseXML = parser.parseFromString(responseText, "text/xml");
3292
- Reflect.set(httpxResponse, "response", response);
3293
- Reflect.set(httpxResponse, "responseText", responseText);
3294
- Reflect.set(httpxResponse, "responseXML", responseXML);
3227
+ httpxResponse.response = response;
3228
+ httpxResponse.responseText = responseText;
3229
+ httpxResponse.responseXML = responseXML;
3295
3230
  // 执行回调
3296
3231
  option.onload(httpxResponse);
3297
3232
  })
@@ -3472,7 +3407,7 @@
3472
3407
  }
3473
3408
  /**
3474
3409
  * GET 请求
3475
- * @param url 网址
3410
+ * @param url 请求的url
3476
3411
  * @param details 配置
3477
3412
  */
3478
3413
  get(...args) {
@@ -3538,27 +3473,21 @@
3538
3473
  /** 取消请求 */
3539
3474
  let abortFn = null;
3540
3475
  let promise = new globalThis.Promise(async (resolve, reject) => {
3541
- let requestOption = this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject);
3476
+ let requestOption = (this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject));
3542
3477
  if (typeof beforeRequestOption === "function") {
3543
- // @ts-ignore
3544
3478
  beforeRequestOption(requestOption);
3545
3479
  }
3546
- // @ts-ignore
3547
- requestOption =
3548
- this.HttpxRequestOption.removeRequestNullOption(requestOption);
3480
+ requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
3549
3481
  const requestResult = await this.HttpxRequest.request(requestOption);
3550
- if (requestResult != null &&
3551
- typeof requestResult.abort === "function") {
3482
+ if (requestResult != null && typeof requestResult.abort === "function") {
3552
3483
  abortFn = requestResult.abort;
3553
3484
  }
3554
3485
  });
3555
- // @ts-ignore
3556
3486
  promise.abort = () => {
3557
3487
  if (typeof abortFn === "function") {
3558
3488
  abortFn();
3559
3489
  }
3560
3490
  };
3561
- // @ts-ignore
3562
3491
  return promise;
3563
3492
  }
3564
3493
  }
@@ -3568,8 +3497,7 @@
3568
3497
  #storeName;
3569
3498
  #dbVersion;
3570
3499
  /* websql的版本号,由于ios的问题,版本号的写法不一样 */
3571
- // @ts-ignore
3572
- #slqVersion = "1";
3500
+ // #slqVersion = "1";
3573
3501
  /* 监听IndexDB */
3574
3502
  #indexedDB = window.indexedDB ||
3575
3503
  window.mozIndexedDB ||
@@ -3577,8 +3505,7 @@
3577
3505
  window.msIndexedDB;
3578
3506
  /* 缓存数据库,避免同一个页面重复创建和销毁 */
3579
3507
  #db = {};
3580
- // @ts-ignore
3581
- #store = null;
3508
+ // #store: IDBObjectStore = null as any;
3582
3509
  /** 状态码 */
3583
3510
  #statusCode = {
3584
3511
  operationSuccess: {
@@ -3623,7 +3550,7 @@
3623
3550
  txn = this.#db[dbName].transaction(this.#storeName, "readwrite");
3624
3551
  /* IndexDB的读写权限 */
3625
3552
  store = txn.objectStore(this.#storeName);
3626
- this.#store = store;
3553
+ // this.#store = store;
3627
3554
  return store;
3628
3555
  }
3629
3556
  /**
@@ -4043,8 +3970,7 @@
4043
3970
  if (typeof __GM_info === "string") {
4044
3971
  this.tag = __GM_info;
4045
3972
  }
4046
- else if (typeof __GM_info === "object" &&
4047
- typeof __GM_info?.script?.name === "string") {
3973
+ else if (typeof __GM_info === "object" && typeof __GM_info?.script?.name === "string") {
4048
3974
  this.tag = __GM_info.script.name;
4049
3975
  }
4050
3976
  this.#console = console;
@@ -4100,8 +4026,7 @@
4100
4026
  */
4101
4027
  checkClearConsole() {
4102
4028
  this.#logCount++;
4103
- if (this.#details.autoClearConsole &&
4104
- this.#logCount > this.#details.logMaxCount) {
4029
+ if (this.#details.autoClearConsole && this.#logCount > this.#details.logMaxCount) {
4105
4030
  this.#console.clear();
4106
4031
  this.#logCount = 0;
4107
4032
  }
@@ -4348,12 +4273,40 @@
4348
4273
  }
4349
4274
 
4350
4275
  class UtilsDictionary {
4351
- items = {};
4276
+ items;
4352
4277
  constructor(key, value) {
4278
+ this.items = {};
4353
4279
  if (key != null) {
4354
4280
  this.set(key, value);
4355
4281
  }
4356
4282
  }
4283
+ /**
4284
+ * 获取字典的长度,同this.size
4285
+ */
4286
+ get length() {
4287
+ return this.size();
4288
+ }
4289
+ /**
4290
+ * 迭代器
4291
+ */
4292
+ get entries() {
4293
+ let that = this;
4294
+ return function* () {
4295
+ let itemKeys = Object.keys(that.getItems());
4296
+ for (const keyName of itemKeys) {
4297
+ yield [keyName, that.get(keyName)];
4298
+ }
4299
+ };
4300
+ }
4301
+ /**
4302
+ * 是否可遍历
4303
+ */
4304
+ get [Symbol.iterator]() {
4305
+ let that = this;
4306
+ return function () {
4307
+ return that.entries();
4308
+ };
4309
+ }
4357
4310
  /**
4358
4311
  * 检查是否有某一个键
4359
4312
  * @param key 键
@@ -4454,7 +4407,6 @@
4454
4407
  * 返回字典本身
4455
4408
  */
4456
4409
  getItems() {
4457
- // @ts-ignore
4458
4410
  return this.items;
4459
4411
  }
4460
4412
  /**
@@ -4464,38 +4416,15 @@
4464
4416
  concat(data) {
4465
4417
  this.items = commonUtil.assign(this.items, data.getItems());
4466
4418
  }
4419
+ /**
4420
+ * 迭代字典
4421
+ * @param callbackfn 回调函数
4422
+ */
4467
4423
  forEach(callbackfn) {
4468
4424
  for (const key in this.getItems()) {
4469
4425
  callbackfn(this.get(key), key, this.getItems());
4470
4426
  }
4471
4427
  }
4472
- /**
4473
- * 获取字典的长度,同this.size
4474
- */
4475
- get length() {
4476
- return this.size();
4477
- }
4478
- /**
4479
- * 迭代器
4480
- */
4481
- get entries() {
4482
- let that = this;
4483
- return function* () {
4484
- let itemKeys = Object.keys(that.getItems());
4485
- for (const keyName of itemKeys) {
4486
- yield [keyName, that.get(keyName)];
4487
- }
4488
- };
4489
- }
4490
- /**
4491
- * 是否可遍历
4492
- */
4493
- get [Symbol.iterator]() {
4494
- let that = this;
4495
- return function () {
4496
- return that.entries();
4497
- };
4498
- }
4499
4428
  }
4500
4429
 
4501
4430
  class WindowApi {
@@ -4521,7 +4450,6 @@
4521
4450
  if (!option) {
4522
4451
  option = Object.assign({}, this.defaultApi);
4523
4452
  }
4524
- // @ts-ignore
4525
4453
  this.api = Object.assign({}, option);
4526
4454
  }
4527
4455
  get document() {
@@ -4579,11 +4507,10 @@
4579
4507
  deps = [];
4580
4508
  active = true;
4581
4509
  fn;
4582
- // @ts-ignore
4583
- scheduler;
4510
+ // private scheduler;
4584
4511
  constructor(fn, scheduler) {
4585
4512
  this.fn = fn;
4586
- this.scheduler = scheduler;
4513
+ // this.scheduler = scheduler;
4587
4514
  }
4588
4515
  run(cb) {
4589
4516
  if (!this.active) {
@@ -4650,8 +4577,7 @@
4650
4577
  reactive(target) {
4651
4578
  const that = this;
4652
4579
  if (!(typeof target === "object" && target !== null)) {
4653
- // @ts-ignore
4654
- return;
4580
+ return void 0;
4655
4581
  }
4656
4582
  if (VueUtils.isReactive(target)) {
4657
4583
  return target;
@@ -4721,7 +4647,6 @@
4721
4647
  toRefs(object) {
4722
4648
  const result = VueUtils.isArray(object) ? new Array(object.length) : {};
4723
4649
  for (let key in object) {
4724
- // @ts-ignore
4725
4650
  result[key] = this.toRef(object, key);
4726
4651
  }
4727
4652
  return result;
@@ -5017,7 +4942,7 @@
5017
4942
  };
5018
4943
 
5019
4944
  // This is the minified and stringified code of the worker-timers-worker package.
5020
- 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
4945
+ 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
5021
4946
 
5022
4947
  const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
5023
4948
  const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
@@ -5449,7 +5374,6 @@
5449
5374
  let text = textMatch[2];
5450
5375
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
5451
5376
  return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
5452
- // @ts-ignore
5453
5377
  return ($ele?.textContent || $ele?.innerText)?.includes(text);
5454
5378
  });
5455
5379
  }
@@ -5467,7 +5391,6 @@
5467
5391
  let regexp = new RegExp(pattern, flags);
5468
5392
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
5469
5393
  return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
5470
- // @ts-ignore
5471
5394
  return Boolean(($ele?.textContent || $ele?.innerText)?.match(regexp));
5472
5395
  });
5473
5396
  }
@@ -5513,7 +5436,6 @@
5513
5436
  let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
5514
5437
  let text = textMatch[2];
5515
5438
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
5516
- // @ts-ignore
5517
5439
  let content = $el?.textContent || $el?.innerText;
5518
5440
  if (typeof content !== "string") {
5519
5441
  content = "";
@@ -5533,7 +5455,6 @@
5533
5455
  }
5534
5456
  let regexp = new RegExp(pattern, flags);
5535
5457
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
5536
- // @ts-ignore
5537
5458
  let content = $el?.textContent || $el?.innerText;
5538
5459
  if (typeof content !== "string") {
5539
5460
  content = "";
@@ -5564,7 +5485,6 @@
5564
5485
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
5565
5486
  let $closest = $el?.closest(selector);
5566
5487
  if ($closest) {
5567
- // @ts-ignore
5568
5488
  let content = $el?.textContent || $el?.innerText;
5569
5489
  if (typeof content === "string" && content.includes(text)) {
5570
5490
  return $closest;
@@ -5587,7 +5507,6 @@
5587
5507
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
5588
5508
  let $closest = $el?.closest(selector);
5589
5509
  if ($closest) {
5590
- // @ts-ignore
5591
5510
  let content = $el?.textContent || $el?.innerText;
5592
5511
  if (typeof content === "string" && content.match(regexp)) {
5593
5512
  return $closest;
@@ -5610,7 +5529,7 @@
5610
5529
  this.windowApi = new WindowApi(option);
5611
5530
  }
5612
5531
  /** 版本号 */
5613
- version = "2025.7.29";
5532
+ version = "2025.8.11";
5614
5533
  addStyle(cssText) {
5615
5534
  if (typeof cssText !== "string") {
5616
5535
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");
@@ -5707,7 +5626,7 @@
5707
5626
  return ajaxHooker();
5708
5627
  }
5709
5628
  };
5710
- canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = globalThis) {
5629
+ canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = this.windowApi.window) {
5711
5630
  if (!(canvasElement instanceof HTMLCanvasElement)) {
5712
5631
  throw new Error("Utils.canvasClickByPosition 参数canvasElement必须是canvas元素");
5713
5632
  }
@@ -5718,7 +5637,6 @@
5718
5637
  cancelable: true,
5719
5638
  clientX: clientX,
5720
5639
  clientY: clientY,
5721
- // @ts-ignore
5722
5640
  view: view,
5723
5641
  detail: 1,
5724
5642
  };
@@ -5734,13 +5652,9 @@
5734
5652
  let touchEvent = UtilsContext.windowApi.window.event;
5735
5653
  let $click = clickEvent?.composedPath()?.[0];
5736
5654
  // 点击的x坐标
5737
- let clickPosX = clickEvent?.clientX != null
5738
- ? clickEvent.clientX
5739
- : touchEvent.touches[0].clientX;
5655
+ let clickPosX = clickEvent?.clientX != null ? clickEvent.clientX : touchEvent.touches[0].clientX;
5740
5656
  // 点击的y坐标
5741
- let clickPosY = clickEvent?.clientY != null
5742
- ? clickEvent.clientY
5743
- : touchEvent.touches[0].clientY;
5657
+ let clickPosY = clickEvent?.clientY != null ? clickEvent.clientY : touchEvent.touches[0].clientY;
5744
5658
  let {
5745
5659
  /* 要检测的元素的相对屏幕的横坐标最左边 */
5746
5660
  left: elementPosXLeft,
@@ -5903,9 +5817,7 @@
5903
5817
  /* CODE FOR BROWSERS THAT SUPPORT window.find */
5904
5818
  let windowFind = this.windowApi.self.find;
5905
5819
  strFound = windowFind(str, caseSensitive, true, true, false);
5906
- if (strFound &&
5907
- this.windowApi.self.getSelection &&
5908
- !this.windowApi.self.getSelection().anchorNode) {
5820
+ if (strFound && this.windowApi.self.getSelection && !this.windowApi.self.getSelection().anchorNode) {
5909
5821
  strFound = windowFind(str, caseSensitive, true, true, false);
5910
5822
  }
5911
5823
  if (!strFound) {
@@ -6008,9 +5920,7 @@
6008
5920
  }
6009
5921
  }
6010
5922
  result = result.toFixed(2);
6011
- result = addType
6012
- ? result + resultType.toString()
6013
- : parseFloat(result.toString());
5923
+ result = addType ? result + resultType.toString() : parseFloat(result.toString());
6014
5924
  return result;
6015
5925
  }
6016
5926
  getNodeListValue(...args) {
@@ -6089,14 +5999,7 @@
6089
5999
  if (text.length === 8) {
6090
6000
  /* 该字符串只有时分秒 */
6091
6001
  let today = new Date();
6092
- text =
6093
- today.getFullYear() +
6094
- "-" +
6095
- (today.getMonth() + 1) +
6096
- "-" +
6097
- today.getDate() +
6098
- " " +
6099
- text;
6002
+ text = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate() + " " + text;
6100
6003
  }
6101
6004
  text = text.substring(0, 19);
6102
6005
  text = text.replace(/-/g, "/");
@@ -6117,25 +6020,13 @@
6117
6020
  * 获取 transitionend 的在各个浏览器的兼容名
6118
6021
  */
6119
6022
  getTransitionEndNameList() {
6120
- return [
6121
- "webkitTransitionEnd",
6122
- "mozTransitionEnd",
6123
- "MSTransitionEnd",
6124
- "otransitionend",
6125
- "transitionend",
6126
- ];
6023
+ return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
6127
6024
  }
6128
6025
  /**
6129
6026
  * 获取 animationend 的在各个浏览器的兼容名
6130
6027
  */
6131
6028
  getAnimationEndNameList() {
6132
- return [
6133
- "webkitAnimationEnd",
6134
- "mozAnimationEnd",
6135
- "MSAnimationEnd",
6136
- "oanimationend",
6137
- "animationend",
6138
- ];
6029
+ return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
6139
6030
  }
6140
6031
  getArrayLastValue(targetObj) {
6141
6032
  return targetObj[targetObj.length - 1];
@@ -6225,12 +6116,10 @@
6225
6116
  }
6226
6117
  getElementSelector(element) {
6227
6118
  let UtilsContext = this;
6228
- // @ts-ignore
6229
6119
  if (!element)
6230
- return;
6231
- // @ts-ignore
6120
+ return void 0;
6232
6121
  if (!element.parentElement)
6233
- return;
6122
+ return void 0;
6234
6123
  /* 如果元素有id属性,则直接返回id选择器 */
6235
6124
  if (element.id)
6236
6125
  return "#" + element.id;
@@ -6241,10 +6130,8 @@
6241
6130
  }
6242
6131
  /* 如果有多个相同类型的兄弟元素,则需要添加索引 */
6243
6132
  if (element.parentElement.querySelectorAll(element.tagName).length > 1) {
6244
- let index = Array.prototype.indexOf.call(element.parentElement.children, element) +
6245
- 1;
6246
- selector +=
6247
- " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
6133
+ let index = Array.prototype.indexOf.call(element.parentElement.children, element) + 1;
6134
+ selector += " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
6248
6135
  }
6249
6136
  else {
6250
6137
  selector += " > " + element.tagName.toLowerCase();
@@ -6261,13 +6148,10 @@
6261
6148
  let result = [...args];
6262
6149
  let newResult = [];
6263
6150
  if (result.length === 0) {
6264
- // @ts-ignore
6265
- return;
6151
+ return void 0;
6266
6152
  }
6267
6153
  if (result.length > 1) {
6268
- if (result.length === 2 &&
6269
- typeof result[0] === "object" &&
6270
- typeof result[1] === "function") {
6154
+ if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
6271
6155
  let data = result[0];
6272
6156
  let handleDataFunc = result[1];
6273
6157
  Object.keys(data).forEach((keyName) => {
@@ -6302,7 +6186,6 @@
6302
6186
  // 当前页面最大的z-index
6303
6187
  let zIndex = 0;
6304
6188
  // 当前的最大z-index的元素,调试使用
6305
- // @ts-ignore
6306
6189
  let maxZIndexNode = null;
6307
6190
  /**
6308
6191
  * 元素是否可见
@@ -6363,13 +6246,10 @@
6363
6246
  let result = [...args];
6364
6247
  let newResult = [];
6365
6248
  if (result.length === 0) {
6366
- // @ts-ignore
6367
- return;
6249
+ return void 0;
6368
6250
  }
6369
6251
  if (result.length > 1) {
6370
- if (result.length === 2 &&
6371
- typeof result[0] === "object" &&
6372
- typeof result[1] === "function") {
6252
+ if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
6373
6253
  let data = result[0];
6374
6254
  let handleDataFunc = result[1];
6375
6255
  Object.keys(data).forEach((keyName) => {
@@ -6459,12 +6339,10 @@
6459
6339
  getRandomValue(...args) {
6460
6340
  let result = [...args];
6461
6341
  if (result.length > 1) {
6462
- if (result.length === 2 &&
6463
- typeof result[0] === "number" &&
6464
- typeof result[1] === "number") {
6342
+ if (result.length === 2 && typeof result[0] === "number" && typeof result[1] === "number") {
6465
6343
  let leftNumber = result[0] > result[1] ? result[1] : result[0];
6466
6344
  let rightNumber = result[0] > result[1] ? result[0] : result[1];
6467
- return (Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber);
6345
+ return Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber;
6468
6346
  }
6469
6347
  else {
6470
6348
  return result[Math.floor(Math.random() * result.length)];
@@ -6475,8 +6353,7 @@
6475
6353
  if (Array.isArray(paramData)) {
6476
6354
  return paramData[Math.floor(Math.random() * paramData.length)];
6477
6355
  }
6478
- else if (typeof paramData === "object" &&
6479
- Object.keys(paramData).length > 0) {
6356
+ else if (typeof paramData === "object" && Object.keys(paramData).length > 0) {
6480
6357
  let paramObjDataKey = Object.keys(paramData)[Math.floor(Math.random() * Object.keys(paramData).length)];
6481
6358
  return paramData[paramObjDataKey];
6482
6359
  }
@@ -6783,11 +6660,9 @@
6783
6660
  let nearBottomHeight = 50;
6784
6661
  let checkWindow = () => {
6785
6662
  // 已滚动的距离
6786
- let scrollTop = this.windowApi.window.pageYOffset ||
6787
- this.windowApi.document.documentElement.scrollTop;
6663
+ let scrollTop = this.windowApi.window.pageYOffset || this.windowApi.document.documentElement.scrollTop;
6788
6664
  // 视窗高度
6789
- let viewportHeight = this.windowApi.window.innerHeight ||
6790
- this.windowApi.document.documentElement.clientHeight;
6665
+ let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
6791
6666
  // 最大滚动距离
6792
6667
  let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
6793
6668
  return scrollTop + viewportHeight >= maxScrollHeight;
@@ -6838,7 +6713,6 @@
6838
6713
  }
6839
6714
  isJQuery(target) {
6840
6715
  let result = false;
6841
- // @ts-ignore
6842
6716
  if (typeof jQuery === "object" && target instanceof jQuery) {
6843
6717
  result = true;
6844
6718
  }
@@ -7077,8 +6951,7 @@
7077
6951
  **/
7078
6952
  isNull = commonUtil.isNull.bind(commonUtil);
7079
6953
  isThemeDark() {
7080
- return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)")
7081
- .matches;
6954
+ return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
7082
6955
  }
7083
6956
  /**
7084
6957
  * 判断元素是否在页面中可见
@@ -7111,10 +6984,8 @@
7111
6984
  else {
7112
6985
  let domClientRect = domItem.getBoundingClientRect();
7113
6986
  if (inView) {
7114
- let viewportWidth = this.windowApi.window.innerWidth ||
7115
- this.windowApi.document.documentElement.clientWidth;
7116
- let viewportHeight = this.windowApi.window.innerHeight ||
7117
- this.windowApi.document.documentElement.clientHeight;
6987
+ let viewportWidth = this.windowApi.window.innerWidth || this.windowApi.document.documentElement.clientWidth;
6988
+ let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
7118
6989
  result = !(domClientRect.right < 0 ||
7119
6990
  domClientRect.left > viewportWidth ||
7120
6991
  domClientRect.bottom < 0 ||
@@ -7138,8 +7009,7 @@
7138
7009
  for (const key in Object.values(this.windowApi.top.window.via)) {
7139
7010
  if (Reflect.has(this.windowApi.top.window.via, key)) {
7140
7011
  let objValueFunc = this.windowApi.top.window.via[key];
7141
- if (typeof objValueFunc === "function" &&
7142
- UtilsContext.isNativeFunc(objValueFunc)) {
7012
+ if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
7143
7013
  result = true;
7144
7014
  }
7145
7015
  else {
@@ -7161,8 +7031,7 @@
7161
7031
  for (const key in Object.values(this.windowApi.top.window.mbrowser)) {
7162
7032
  if (Reflect.has(this.windowApi.top.window.mbrowser, key)) {
7163
7033
  let objValueFunc = this.windowApi.top.window.mbrowser[key];
7164
- if (typeof objValueFunc === "function" &&
7165
- UtilsContext.isNativeFunc(objValueFunc)) {
7034
+ if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
7166
7035
  result = true;
7167
7036
  }
7168
7037
  else {
@@ -7399,13 +7268,11 @@
7399
7268
  * 释放所有
7400
7269
  */
7401
7270
  function releaseAll() {
7402
- if (typeof UtilsContext.windowApi.window[needReleaseKey] !==
7403
- "undefined") {
7271
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] !== "undefined") {
7404
7272
  /* 已存在 */
7405
7273
  return;
7406
7274
  }
7407
- UtilsContext.windowApi.window[needReleaseKey] =
7408
- UtilsContext.deepClone(needReleaseObject);
7275
+ UtilsContext.windowApi.window[needReleaseKey] = UtilsContext.deepClone(needReleaseObject);
7409
7276
  Object.values(needReleaseObject).forEach((value) => {
7410
7277
  if (typeof value === "function") {
7411
7278
  needReleaseObject[value.name] = () => { };
@@ -7419,8 +7286,7 @@
7419
7286
  Array.from(functionNameList).forEach((item) => {
7420
7287
  Object.values(needReleaseObject).forEach((value) => {
7421
7288
  if (typeof value === "function") {
7422
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7423
- "undefined") {
7289
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7424
7290
  UtilsContext.windowApi.window[needReleaseKey] = {};
7425
7291
  }
7426
7292
  if (item === value.name) {
@@ -7435,8 +7301,7 @@
7435
7301
  * 恢复所有
7436
7302
  */
7437
7303
  function recoveryAll() {
7438
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7439
- "undefined") {
7304
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7440
7305
  /* 未存在 */
7441
7306
  return;
7442
7307
  }
@@ -7447,8 +7312,7 @@
7447
7312
  * 恢复单个
7448
7313
  */
7449
7314
  function recoveryOne() {
7450
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7451
- "undefined") {
7315
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7452
7316
  /* 未存在 */
7453
7317
  return;
7454
7318
  }
@@ -7456,8 +7320,7 @@
7456
7320
  if (UtilsContext.windowApi.window[needReleaseKey][item]) {
7457
7321
  needReleaseObject[item] = UtilsContext.windowApi.window[needReleaseKey][item];
7458
7322
  Reflect.deleteProperty(UtilsContext.windowApi.window[needReleaseKey], item);
7459
- if (Object.keys(UtilsContext.windowApi.window[needReleaseKey])
7460
- .length === 0) {
7323
+ if (Object.keys(UtilsContext.windowApi.window[needReleaseKey]).length === 0) {
7461
7324
  Reflect.deleteProperty(window, needReleaseKey);
7462
7325
  }
7463
7326
  }
@@ -7619,29 +7482,27 @@
7619
7482
  EventTarget.prototype.addEventListener = function (...args) {
7620
7483
  let type = args[0];
7621
7484
  let callback = args[1];
7622
- // @ts-ignore
7623
- args[2];
7485
+ // let options = args[2];
7624
7486
  if (filter(type)) {
7625
7487
  if (typeof callback === "function") {
7626
7488
  args[1] = function (event) {
7627
7489
  callback.call(this, trustEvent(event));
7628
7490
  };
7629
7491
  }
7630
- else if (typeof callback === "object" &&
7631
- "handleEvent" in callback) {
7492
+ else if (typeof callback === "object" && "handleEvent" in callback) {
7632
7493
  let oldHandleEvent = callback["handleEvent"];
7633
7494
  args[1]["handleEvent"] = function (event) {
7634
7495
  if (event == null) {
7635
7496
  return;
7636
7497
  }
7637
7498
  try {
7638
- /* Proxy对象使用instanceof会报错 */
7499
+ // Proxy对象使用instanceof会报错
7500
+ // 这里故意尝试一下,如果报错,则说明是Proxy对象
7639
7501
  event instanceof Proxy;
7640
7502
  oldHandleEvent.call(this, trustEvent(event));
7641
7503
  }
7642
7504
  catch (error) {
7643
- // @ts-ignore
7644
- event["isTrusted"] = isTrustValue;
7505
+ Reflect.set(event, "isTrusted", isTrustValue);
7645
7506
  }
7646
7507
  };
7647
7508
  }
@@ -7714,10 +7575,9 @@
7714
7575
  }
7715
7576
  async init() {
7716
7577
  let copyStatus = false;
7717
- // @ts-ignore
7718
- await this.requestClipboardPermission();
7719
- if (this.hasClipboard() &&
7720
- (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
7578
+ let requestPermissionStatus = await this.requestClipboardPermission();
7579
+ console.log(requestPermissionStatus);
7580
+ if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
7721
7581
  try {
7722
7582
  copyStatus = await this.copyDataByClipboard();
7723
7583
  }
@@ -7733,11 +7593,8 @@
7733
7593
  this.destroy();
7734
7594
  }
7735
7595
  destroy() {
7736
- // @ts-ignore
7737
7596
  this.#resolve = null;
7738
- // @ts-ignore
7739
7597
  this.#copyData = null;
7740
- // @ts-ignore
7741
7598
  this.#copyDataType = null;
7742
7599
  }
7743
7600
  isText() {
@@ -7781,7 +7638,6 @@
7781
7638
  if (navigator.permissions && navigator.permissions.query) {
7782
7639
  navigator.permissions
7783
7640
  .query({
7784
- // @ts-ignore
7785
7641
  name: "clipboard-write",
7786
7642
  })
7787
7643
  .then((permissionStatus) => {
@@ -7877,17 +7733,13 @@
7877
7733
  dragSlider(selector, offsetX = this.windowApi.window.innerWidth) {
7878
7734
  let UtilsContext = this;
7879
7735
  function initMouseEvent(eventName, offSetX, offSetY) {
7880
- // @ts-ignore
7881
7736
  let win = typeof unsafeWindow === "undefined" ? globalThis : unsafeWindow;
7882
7737
  let mouseEvent = UtilsContext.windowApi.document.createEvent("MouseEvents");
7883
7738
  mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
7884
7739
  return mouseEvent;
7885
7740
  }
7886
- let sliderElement = typeof selector === "string"
7887
- ? domUtils.selector(selector)
7888
- : selector;
7889
- if (!(sliderElement instanceof Node) ||
7890
- !(sliderElement instanceof Element)) {
7741
+ let sliderElement = typeof selector === "string" ? domUtils.selector(selector) : selector;
7742
+ if (!(sliderElement instanceof Node) || !(sliderElement instanceof Element)) {
7891
7743
  throw new Error("Utils.dragSlider 参数selector 必须为Node/Element类型");
7892
7744
  }
7893
7745
  let rect = sliderElement.getBoundingClientRect(), x0 = rect.x || rect.left, y0 = rect.y || rect.top, x1 = x0 + offsetX, y1 = y0;
@@ -7939,17 +7791,14 @@
7939
7791
  }
7940
7792
  sortListByProperty(data, getPropertyValueFunc, sortByDesc = true) {
7941
7793
  let UtilsContext = this;
7942
- if (typeof getPropertyValueFunc !== "function" &&
7943
- typeof getPropertyValueFunc !== "string") {
7794
+ if (typeof getPropertyValueFunc !== "function" && typeof getPropertyValueFunc !== "string") {
7944
7795
  throw new Error("Utils.sortListByProperty 参数 getPropertyValueFunc 必须为 function|string 类型");
7945
7796
  }
7946
7797
  if (typeof sortByDesc !== "boolean") {
7947
7798
  throw new Error("Utils.sortListByProperty 参数 sortByDesc 必须为 boolean 类型");
7948
7799
  }
7949
7800
  let getObjValue = function (obj) {
7950
- return typeof getPropertyValueFunc === "string"
7951
- ? obj[getPropertyValueFunc]
7952
- : getPropertyValueFunc(obj);
7801
+ return typeof getPropertyValueFunc === "string" ? obj[getPropertyValueFunc] : getPropertyValueFunc(obj);
7953
7802
  };
7954
7803
  /**
7955
7804
  * 排序方法
@@ -8024,8 +7873,7 @@
8024
7873
  if (Array.isArray(data)) {
8025
7874
  data.sort(sortFunc);
8026
7875
  }
8027
- else if (data instanceof NodeList ||
8028
- UtilsContext.isJQuery(data)) {
7876
+ else if (data instanceof NodeList || UtilsContext.isJQuery(data)) {
8029
7877
  sortNodeFunc(data, getDataFunc);
8030
7878
  result = getDataFunc();
8031
7879
  }
@@ -8036,7 +7884,6 @@
8036
7884
  }
8037
7885
  stringToRegular(targetString, flags = "ig") {
8038
7886
  let reg;
8039
- // @ts-ignore
8040
7887
  flags = flags.toLowerCase();
8041
7888
  if (typeof targetString === "string") {
8042
7889
  reg = new RegExp(targetString.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"), flags);
@@ -8129,10 +7976,8 @@
8129
7976
  */
8130
7977
  searchParamStrToObj(searhParamsStr) {
8131
7978
  if (typeof searhParamsStr !== "string") {
8132
- // @ts-ignore
8133
7979
  return {};
8134
7980
  }
8135
- // @ts-ignore
8136
7981
  return Object.fromEntries(new URLSearchParams(searhParamsStr));
8137
7982
  }
8138
7983
  /**
@@ -8221,9 +8066,7 @@
8221
8066
  let parent = UtilsContext.windowApi.document;
8222
8067
  // 超时时间
8223
8068
  let timeout = 0;
8224
- if (typeof args[0] !== "string" &&
8225
- !Array.isArray(args[0]) &&
8226
- typeof args[0] !== "function") {
8069
+ if (typeof args[0] !== "string" && !Array.isArray(args[0]) && typeof args[0] !== "function") {
8227
8070
  throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
8228
8071
  }
8229
8072
  if (args.length === 1) ;
@@ -8233,8 +8076,7 @@
8233
8076
  // "div",10000
8234
8077
  timeout = secondParam;
8235
8078
  }
8236
- else if (typeof secondParam === "object" &&
8237
- secondParam instanceof Node) {
8079
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8238
8080
  // "div",document
8239
8081
  parent = secondParam;
8240
8082
  }
@@ -8320,8 +8162,7 @@
8320
8162
  // "div",10000
8321
8163
  timeout = secondParam;
8322
8164
  }
8323
- else if (typeof secondParam === "object" &&
8324
- secondParam instanceof Node) {
8165
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8325
8166
  // "div",document
8326
8167
  parent = secondParam;
8327
8168
  }
@@ -8376,8 +8217,7 @@
8376
8217
  // "div",10000
8377
8218
  timeout = secondParam;
8378
8219
  }
8379
- else if (typeof secondParam === "object" &&
8380
- secondParam instanceof Node) {
8220
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8381
8221
  // "div",document
8382
8222
  parent = secondParam;
8383
8223
  }
@@ -8463,8 +8303,7 @@
8463
8303
  // "div",10000
8464
8304
  timeout = secondParam;
8465
8305
  }
8466
- else if (typeof secondParam === "object" &&
8467
- secondParam instanceof Node) {
8306
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8468
8307
  // "div",document
8469
8308
  parent = secondParam;
8470
8309
  }
@@ -8597,8 +8436,7 @@
8597
8436
  return flag;
8598
8437
  }
8599
8438
  watchObject(target, propertyName, getCallBack, setCallBack) {
8600
- if (typeof getCallBack !== "function" &&
8601
- typeof setCallBack !== "function") {
8439
+ if (typeof getCallBack !== "function" && typeof setCallBack !== "function") {
8602
8440
  return;
8603
8441
  }
8604
8442
  if (typeof getCallBack === "function") {
@@ -8650,13 +8488,27 @@
8650
8488
  return;
8651
8489
  }
8652
8490
  let handleResult = handler(target);
8653
- if (handleResult &&
8654
- typeof handleResult.isFind === "boolean" &&
8655
- handleResult.isFind) {
8491
+ if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
8656
8492
  return handleResult.data;
8657
8493
  }
8658
8494
  return this.queryProperty(handleResult.data, handler);
8659
8495
  }
8496
+ /**
8497
+ * 异步-深度获取对象属性
8498
+ * @param target 待获取的对象
8499
+ * @param handler 获取属性的回调
8500
+ */
8501
+ async asyncQueryProperty(target, handler) {
8502
+ if (target == null) {
8503
+ // @ts-ignore
8504
+ return;
8505
+ }
8506
+ let handleResult = await handler(target);
8507
+ if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
8508
+ return handleResult.data;
8509
+ }
8510
+ return await this.asyncQueryProperty(handleResult.data, handler);
8511
+ }
8660
8512
  /**
8661
8513
  * 创建一个新的Utils实例
8662
8514
  * @param option
@@ -8835,7 +8687,6 @@
8835
8687
  function requestPermissionsWithClipboard() {
8836
8688
  navigator.permissions
8837
8689
  .query({
8838
- // @ts-ignore
8839
8690
  name: "clipboard-read",
8840
8691
  })
8841
8692
  .then((permissionStatus) => {