@whitesev/utils 2.7.2 → 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.
package/dist/index.amd.js CHANGED
@@ -67,11 +67,7 @@ define((function () { 'use strict';
67
67
  !validPattern.test(greenValue.toString()) ||
68
68
  !validPattern.test(blueValue.toString()))
69
69
  throw new TypeError("输入错误的rgb颜色值");
70
- let hexs = [
71
- redValue.toString(16),
72
- greenValue.toString(16),
73
- blueValue.toString(16),
74
- ];
70
+ let hexs = [redValue.toString(16), greenValue.toString(16), blueValue.toString(16)];
75
71
  for (let index = 0; index < 3; index++)
76
72
  if (hexs[index].length == 1)
77
73
  hexs[index] = "0" + hexs[index];
@@ -119,10 +115,7 @@ define((function () { 'use strict';
119
115
  this.#data = dataText.match(/..../g);
120
116
  for (let i = 0x81; i <= 0xfe; i++) {
121
117
  for (let j = 0x40; j <= 0xfe; j++) {
122
- this.#U2Ghash[this.#data[index++]] = ("%" +
123
- i.toString(16) +
124
- "%" +
125
- j.toString(16)).toUpperCase();
118
+ this.#U2Ghash[this.#data[index++]] = ("%" + i.toString(16) + "%" + j.toString(16)).toUpperCase();
126
119
  }
127
120
  }
128
121
  for (let key in this.#U2Ghash) {
@@ -250,9 +243,7 @@ define((function () { 'use strict';
250
243
  callbackFunction = callback;
251
244
  context = __context__ || this;
252
245
  let result = executeTryCatch(callbackFunction, handleError, context);
253
- return result !== void 0
254
- ? result
255
- : TryCatchCore;
246
+ return result !== void 0 ? result : TryCatchCore;
256
247
  },
257
248
  };
258
249
  /**
@@ -281,10 +272,7 @@ define((function () { 'use strict';
281
272
  }
282
273
  if (handleErrorFunc) {
283
274
  if (typeof handleErrorFunc === "string") {
284
- result = new Function(handleErrorFunc).apply(funcThis, [
285
- ...args,
286
- error,
287
- ]);
275
+ result = new Function(handleErrorFunc).apply(funcThis, [...args, error]);
288
276
  }
289
277
  else {
290
278
  result = handleErrorFunc.apply(funcThis, [...args, error]);
@@ -372,10 +360,7 @@ define((function () { 'use strict';
372
360
  itemResult = objItem === 0;
373
361
  break;
374
362
  case "string":
375
- itemResult =
376
- objItem.trim() === "" ||
377
- objItem === "null" ||
378
- objItem === "undefined";
363
+ itemResult = objItem.trim() === "" || objItem === "null" || objItem === "undefined";
379
364
  break;
380
365
  case "boolean":
381
366
  itemResult = !objItem;
@@ -416,8 +401,7 @@ define((function () { 'use strict';
416
401
  return null;
417
402
  let clone = obj instanceof Array ? [] : {};
418
403
  for (const [key, value] of Object.entries(obj)) {
419
- clone[key] =
420
- typeof value === "object" ? UtilsContext.deepClone(value) : value;
404
+ clone[key] = typeof value === "object" ? UtilsContext.deepClone(value) : value;
421
405
  }
422
406
  return clone;
423
407
  }
@@ -1956,14 +1940,10 @@ define((function () { 'use strict';
1956
1940
  // };
1957
1941
  /* 点击菜单后触发callback后的网页是否刷新 */
1958
1942
  menuOption.autoReload =
1959
- typeof menuOption.autoReload !== "boolean"
1960
- ? this.$default.autoReload
1961
- : menuOption.autoReload;
1943
+ typeof menuOption.autoReload !== "boolean" ? this.$default.autoReload : menuOption.autoReload;
1962
1944
  /* 点击菜单后触发callback后的网页是否存储值 */
1963
1945
  menuOption.isStoreValue =
1964
- typeof menuOption.isStoreValue !== "boolean"
1965
- ? this.$default.isStoreValue
1966
- : menuOption.isStoreValue;
1946
+ typeof menuOption.isStoreValue !== "boolean" ? this.$default.isStoreValue : menuOption.isStoreValue;
1967
1947
  /**
1968
1948
  * 用户点击菜单后的回调函数
1969
1949
  * @param event
@@ -2016,8 +1996,7 @@ define((function () { 'use strict';
2016
1996
  * @param menuKey 菜单-键key
2017
1997
  */
2018
1998
  getMenuHandledOption(menuKey) {
2019
- return this.$data.data.find((item) => item.handleData.key === menuKey)
2020
- ?.handleData;
1999
+ return this.$data.data.find((item) => item.handleData.key === menuKey)?.handleData;
2021
2000
  },
2022
2001
  };
2023
2002
  constructor(details) {
@@ -2025,8 +2004,7 @@ define((function () { 'use strict';
2025
2004
  this.GM_Api.setValue = details.GM_setValue;
2026
2005
  this.GM_Api.registerMenuCommand = details.GM_registerMenuCommand;
2027
2006
  this.GM_Api.unregisterMenuCommand = details.GM_unregisterMenuCommand;
2028
- this.MenuHandle.$default.autoReload =
2029
- typeof details.autoReload === "boolean" ? details.autoReload : true;
2007
+ this.MenuHandle.$default.autoReload = typeof details.autoReload === "boolean" ? details.autoReload : true;
2030
2008
  for (const keyName of Object.keys(this.GM_Api)) {
2031
2009
  if (typeof this.GM_Api[keyName] !== "function") {
2032
2010
  throw new Error(`Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`);
@@ -2258,8 +2236,7 @@ define((function () { 'use strict';
2258
2236
  _context = context || window;
2259
2237
  _funcName = getFuncName(this);
2260
2238
  _context["realFunc_" + _funcName] = this;
2261
- if (_context[_funcName].prototype &&
2262
- _context[_funcName].prototype.isHooked) {
2239
+ if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
2263
2240
  console.log("Already has been hooked,unhook first");
2264
2241
  return false;
2265
2242
  }
@@ -2437,8 +2414,7 @@ define((function () { 'use strict';
2437
2414
  if (details.allowInterceptConfig != null) {
2438
2415
  // 配置存在
2439
2416
  // 细分处理是否拦截
2440
- if (typeof details.allowInterceptConfig.afterResponseSuccess ===
2441
- "boolean" &&
2417
+ if (typeof details.allowInterceptConfig.afterResponseSuccess === "boolean" &&
2442
2418
  !details.allowInterceptConfig.afterResponseSuccess) {
2443
2419
  // 设置了禁止拦截
2444
2420
  return details;
@@ -2473,8 +2449,7 @@ define((function () { 'use strict';
2473
2449
  if (data.details.allowInterceptConfig != null) {
2474
2450
  // 配置存在
2475
2451
  // 细分处理是否拦截
2476
- if (typeof data.details.allowInterceptConfig.afterResponseError ===
2477
- "boolean" &&
2452
+ if (typeof data.details.allowInterceptConfig.afterResponseError === "boolean" &&
2478
2453
  !data.details.allowInterceptConfig.afterResponseError) {
2479
2454
  // 设置了禁止拦截
2480
2455
  return data;
@@ -2576,44 +2551,31 @@ define((function () { 'use strict';
2576
2551
  let requestOption = {
2577
2552
  url: url,
2578
2553
  method: (method || "GET").toString().toUpperCase().trim(),
2579
- timeout: userRequestOption.timeout ||
2580
- this.context.#defaultRequestOption.timeout,
2581
- responseType: userRequestOption.responseType ||
2582
- this.context.#defaultRequestOption.responseType,
2554
+ timeout: userRequestOption.timeout || this.context.#defaultRequestOption.timeout,
2555
+ responseType: userRequestOption.responseType || this.context.#defaultRequestOption.responseType,
2583
2556
  /* 对象使用深拷贝 */
2584
2557
  headers: commonUtil.deepClone(this.context.#defaultRequestOption.headers),
2585
2558
  data: userRequestOption.data || this.context.#defaultRequestOption.data,
2586
- redirect: userRequestOption.redirect ||
2587
- this.context.#defaultRequestOption.redirect,
2559
+ redirect: userRequestOption.redirect || this.context.#defaultRequestOption.redirect,
2588
2560
  cookie: userRequestOption.cookie || this.context.#defaultRequestOption.cookie,
2589
- cookiePartition: userRequestOption.cookiePartition ||
2590
- this.context.#defaultRequestOption.cookiePartition,
2561
+ cookiePartition: userRequestOption.cookiePartition || this.context.#defaultRequestOption.cookiePartition,
2591
2562
  binary: userRequestOption.binary || this.context.#defaultRequestOption.binary,
2592
- nocache: userRequestOption.nocache ||
2593
- this.context.#defaultRequestOption.nocache,
2594
- revalidate: userRequestOption.revalidate ||
2595
- this.context.#defaultRequestOption.revalidate,
2563
+ nocache: userRequestOption.nocache || this.context.#defaultRequestOption.nocache,
2564
+ revalidate: userRequestOption.revalidate || this.context.#defaultRequestOption.revalidate,
2596
2565
  /* 对象使用深拷贝 */
2597
- context: commonUtil.deepClone(userRequestOption.context ||
2598
- this.context.#defaultRequestOption.context),
2599
- overrideMimeType: userRequestOption.overrideMimeType ||
2600
- this.context.#defaultRequestOption.overrideMimeType,
2601
- anonymous: userRequestOption.anonymous ||
2602
- this.context.#defaultRequestOption.anonymous,
2566
+ context: commonUtil.deepClone(userRequestOption.context || this.context.#defaultRequestOption.context),
2567
+ overrideMimeType: userRequestOption.overrideMimeType || this.context.#defaultRequestOption.overrideMimeType,
2568
+ anonymous: userRequestOption.anonymous || this.context.#defaultRequestOption.anonymous,
2603
2569
  fetch: userRequestOption.fetch || this.context.#defaultRequestOption.fetch,
2604
2570
  /* 对象使用深拷贝 */
2605
2571
  fetchInit: commonUtil.deepClone(this.context.#defaultRequestOption.fetchInit),
2606
2572
  allowInterceptConfig: {
2607
- beforeRequest: this.context.#defaultRequestOption
2608
- .allowInterceptConfig.beforeRequest,
2609
- afterResponseSuccess: this.context.#defaultRequestOption
2610
- .allowInterceptConfig.afterResponseSuccess,
2611
- afterResponseError: this.context.#defaultRequestOption
2612
- .allowInterceptConfig.afterResponseError,
2573
+ beforeRequest: this.context.#defaultRequestOption.allowInterceptConfig.beforeRequest,
2574
+ afterResponseSuccess: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseSuccess,
2575
+ afterResponseError: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseError,
2613
2576
  },
2614
2577
  user: userRequestOption.user || this.context.#defaultRequestOption.user,
2615
- password: userRequestOption.password ||
2616
- this.context.#defaultRequestOption.password,
2578
+ password: userRequestOption.password || this.context.#defaultRequestOption.password,
2617
2579
  onabort(...args) {
2618
2580
  that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
2619
2581
  },
@@ -2661,14 +2623,12 @@ define((function () { 'use strict';
2661
2623
  if (typeof requestOption.headers === "object") {
2662
2624
  if (typeof userRequestOption.headers === "object") {
2663
2625
  Object.keys(userRequestOption.headers).forEach((keyName, index) => {
2664
- if (keyName in requestOption.headers &&
2665
- userRequestOption.headers?.[keyName] == null) {
2626
+ if (keyName in requestOption.headers && userRequestOption.headers?.[keyName] == null) {
2666
2627
  /* 在默认的header中存在,且设置它新的值为空,那么就是默认的值 */
2667
2628
  Reflect.deleteProperty(requestOption.headers, keyName);
2668
2629
  }
2669
2630
  else {
2670
- requestOption.headers[keyName] =
2671
- userRequestOption?.headers?.[keyName];
2631
+ requestOption.headers[keyName] = userRequestOption?.headers?.[keyName];
2672
2632
  }
2673
2633
  });
2674
2634
  }
@@ -2681,8 +2641,7 @@ define((function () { 'use strict';
2681
2641
  /* 使用assign替换且添加 */
2682
2642
  if (typeof userRequestOption.fetchInit === "object") {
2683
2643
  Object.keys(userRequestOption.fetchInit).forEach((keyName, index) => {
2684
- if (keyName in requestOption.fetchInit &&
2685
- userRequestOption.fetchInit[keyName] == null) {
2644
+ if (keyName in requestOption.fetchInit && userRequestOption.fetchInit[keyName] == null) {
2686
2645
  /* 在默认的fetchInit中存在,且设置它新的值为空,那么就是默认的值 */
2687
2646
  Reflect.deleteProperty(requestOption.fetchInit, keyName);
2688
2647
  }
@@ -2696,8 +2655,7 @@ define((function () { 'use strict';
2696
2655
  Reflect.set(requestOption, "fetchInit", userRequestOption.fetchInit);
2697
2656
  }
2698
2657
  // 处理新的cookiePartition
2699
- if (typeof requestOption.cookiePartition === "object" &&
2700
- requestOption.cookiePartition != null) {
2658
+ if (typeof requestOption.cookiePartition === "object" && requestOption.cookiePartition != null) {
2701
2659
  if (Reflect.has(requestOption.cookiePartition, "topLevelSite") &&
2702
2660
  typeof requestOption.cookiePartition.topLevelSite !== "string") {
2703
2661
  // topLevelSite必须是字符串
@@ -2719,8 +2677,7 @@ define((function () { 'use strict';
2719
2677
  }
2720
2678
  else {
2721
2679
  // 补充origin+/
2722
- requestOption.url =
2723
- globalThis.location.origin + "/" + requestOption.url;
2680
+ requestOption.url = globalThis.location.origin + "/" + requestOption.url;
2724
2681
  }
2725
2682
  }
2726
2683
  if (requestOption.fetchInit && !requestOption.fetch) {
@@ -2844,8 +2801,7 @@ define((function () { 'use strict';
2844
2801
  * fetch的请求配置
2845
2802
  **/
2846
2803
  let fetchRequestOption = {};
2847
- if ((option.method === "GET" || option.method === "HEAD") &&
2848
- option.data != null) {
2804
+ if ((option.method === "GET" || option.method === "HEAD") && option.data != null) {
2849
2805
  /* GET 或 HEAD 方法的请求不能包含 body 信息 */
2850
2806
  Reflect.deleteProperty(option, "data");
2851
2807
  }
@@ -3126,8 +3082,7 @@ define((function () { 'use strict';
3126
3082
  if (typeof details?.onreadystatechange === "function") {
3127
3083
  details.onreadystatechange.apply(this, argsResult);
3128
3084
  }
3129
- else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
3130
- "function") {
3085
+ else if (typeof this.context.#defaultRequestOption?.onreadystatechange === "function") {
3131
3086
  this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
3132
3087
  }
3133
3088
  },
@@ -3156,8 +3111,7 @@ define((function () { 'use strict';
3156
3111
  if (this.context.#defaultInitOption.logDetails) {
3157
3112
  console.log("[Httpx-HttpxRequest.request] 请求前的配置👇", details);
3158
3113
  }
3159
- if (typeof this.context.HttpxRequestHook.beforeRequestCallBack ===
3160
- "function") {
3114
+ if (typeof this.context.HttpxRequestHook.beforeRequestCallBack === "function") {
3161
3115
  let hookResult = await this.context.HttpxRequestHook.beforeRequestCallBack(details);
3162
3116
  if (hookResult == null) {
3163
3117
  return;
@@ -3213,9 +3167,7 @@ define((function () { 'use strict';
3213
3167
  /* 如果需要stream,且获取到的是stream,那直接返回 */
3214
3168
  if (option.responseType === "stream" ||
3215
3169
  (fetchResponse.headers.has("Content-Type") &&
3216
- fetchResponse.headers
3217
- .get("Content-Type")
3218
- .includes("text/event-stream"))) {
3170
+ fetchResponse.headers.get("Content-Type").includes("text/event-stream"))) {
3219
3171
  Reflect.set(httpxResponse, "isStream", true);
3220
3172
  Reflect.set(httpxResponse, "response", fetchResponse.body);
3221
3173
  Reflect.deleteProperty(httpxResponse, "responseText");
@@ -3234,9 +3186,7 @@ define((function () { 'use strict';
3234
3186
  /** 数据编码 */
3235
3187
  let encoding = "utf-8";
3236
3188
  if (fetchResponse.headers.has("Content-Type")) {
3237
- let charsetMatched = fetchResponse.headers
3238
- .get("Content-Type")
3239
- ?.match(/charset=(.+)/);
3189
+ let charsetMatched = fetchResponse.headers.get("Content-Type")?.match(/charset=(.+)/);
3240
3190
  if (charsetMatched) {
3241
3191
  encoding = charsetMatched[1];
3242
3192
  encoding = encoding.toLowerCase();
@@ -3258,13 +3208,11 @@ define((function () { 'use strict';
3258
3208
  response = new Blob([arrayBuffer]);
3259
3209
  }
3260
3210
  else if (option.responseType === "json" ||
3261
- (typeof fetchResponseType === "string" &&
3262
- fetchResponseType.includes("application/json"))) {
3211
+ (typeof fetchResponseType === "string" && fetchResponseType.includes("application/json"))) {
3263
3212
  // response返回格式是JSON格式
3264
3213
  response = commonUtil.toJSON(responseText);
3265
3214
  }
3266
- else if (option.responseType === "document" ||
3267
- option.responseType == null) {
3215
+ else if (option.responseType === "document" || option.responseType == null) {
3268
3216
  // response返回格式是文档格式
3269
3217
  let parser = new DOMParser();
3270
3218
  response = parser.parseFromString(responseText, "text/html");
@@ -3527,8 +3475,7 @@ define((function () { 'use strict';
3527
3475
  }
3528
3476
  requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
3529
3477
  const requestResult = await this.HttpxRequest.request(requestOption);
3530
- if (requestResult != null &&
3531
- typeof requestResult.abort === "function") {
3478
+ if (requestResult != null && typeof requestResult.abort === "function") {
3532
3479
  abortFn = requestResult.abort;
3533
3480
  }
3534
3481
  });
@@ -4019,8 +3966,7 @@ define((function () { 'use strict';
4019
3966
  if (typeof __GM_info === "string") {
4020
3967
  this.tag = __GM_info;
4021
3968
  }
4022
- else if (typeof __GM_info === "object" &&
4023
- typeof __GM_info?.script?.name === "string") {
3969
+ else if (typeof __GM_info === "object" && typeof __GM_info?.script?.name === "string") {
4024
3970
  this.tag = __GM_info.script.name;
4025
3971
  }
4026
3972
  this.#console = console;
@@ -4076,8 +4022,7 @@ define((function () { 'use strict';
4076
4022
  */
4077
4023
  checkClearConsole() {
4078
4024
  this.#logCount++;
4079
- if (this.#details.autoClearConsole &&
4080
- this.#logCount > this.#details.logMaxCount) {
4025
+ if (this.#details.autoClearConsole && this.#logCount > this.#details.logMaxCount) {
4081
4026
  this.#console.clear();
4082
4027
  this.#logCount = 0;
4083
4028
  }
@@ -5580,7 +5525,7 @@ define((function () { 'use strict';
5580
5525
  this.windowApi = new WindowApi(option);
5581
5526
  }
5582
5527
  /** 版本号 */
5583
- version = "2025.7.29";
5528
+ version = "2025.8.11";
5584
5529
  addStyle(cssText) {
5585
5530
  if (typeof cssText !== "string") {
5586
5531
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");
@@ -5703,13 +5648,9 @@ define((function () { 'use strict';
5703
5648
  let touchEvent = UtilsContext.windowApi.window.event;
5704
5649
  let $click = clickEvent?.composedPath()?.[0];
5705
5650
  // 点击的x坐标
5706
- let clickPosX = clickEvent?.clientX != null
5707
- ? clickEvent.clientX
5708
- : touchEvent.touches[0].clientX;
5651
+ let clickPosX = clickEvent?.clientX != null ? clickEvent.clientX : touchEvent.touches[0].clientX;
5709
5652
  // 点击的y坐标
5710
- let clickPosY = clickEvent?.clientY != null
5711
- ? clickEvent.clientY
5712
- : touchEvent.touches[0].clientY;
5653
+ let clickPosY = clickEvent?.clientY != null ? clickEvent.clientY : touchEvent.touches[0].clientY;
5713
5654
  let {
5714
5655
  /* 要检测的元素的相对屏幕的横坐标最左边 */
5715
5656
  left: elementPosXLeft,
@@ -5872,9 +5813,7 @@ define((function () { 'use strict';
5872
5813
  /* CODE FOR BROWSERS THAT SUPPORT window.find */
5873
5814
  let windowFind = this.windowApi.self.find;
5874
5815
  strFound = windowFind(str, caseSensitive, true, true, false);
5875
- if (strFound &&
5876
- this.windowApi.self.getSelection &&
5877
- !this.windowApi.self.getSelection().anchorNode) {
5816
+ if (strFound && this.windowApi.self.getSelection && !this.windowApi.self.getSelection().anchorNode) {
5878
5817
  strFound = windowFind(str, caseSensitive, true, true, false);
5879
5818
  }
5880
5819
  if (!strFound) {
@@ -5977,9 +5916,7 @@ define((function () { 'use strict';
5977
5916
  }
5978
5917
  }
5979
5918
  result = result.toFixed(2);
5980
- result = addType
5981
- ? result + resultType.toString()
5982
- : parseFloat(result.toString());
5919
+ result = addType ? result + resultType.toString() : parseFloat(result.toString());
5983
5920
  return result;
5984
5921
  }
5985
5922
  getNodeListValue(...args) {
@@ -6058,14 +5995,7 @@ define((function () { 'use strict';
6058
5995
  if (text.length === 8) {
6059
5996
  /* 该字符串只有时分秒 */
6060
5997
  let today = new Date();
6061
- text =
6062
- today.getFullYear() +
6063
- "-" +
6064
- (today.getMonth() + 1) +
6065
- "-" +
6066
- today.getDate() +
6067
- " " +
6068
- text;
5998
+ text = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate() + " " + text;
6069
5999
  }
6070
6000
  text = text.substring(0, 19);
6071
6001
  text = text.replace(/-/g, "/");
@@ -6086,25 +6016,13 @@ define((function () { 'use strict';
6086
6016
  * 获取 transitionend 的在各个浏览器的兼容名
6087
6017
  */
6088
6018
  getTransitionEndNameList() {
6089
- return [
6090
- "webkitTransitionEnd",
6091
- "mozTransitionEnd",
6092
- "MSTransitionEnd",
6093
- "otransitionend",
6094
- "transitionend",
6095
- ];
6019
+ return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
6096
6020
  }
6097
6021
  /**
6098
6022
  * 获取 animationend 的在各个浏览器的兼容名
6099
6023
  */
6100
6024
  getAnimationEndNameList() {
6101
- return [
6102
- "webkitAnimationEnd",
6103
- "mozAnimationEnd",
6104
- "MSAnimationEnd",
6105
- "oanimationend",
6106
- "animationend",
6107
- ];
6025
+ return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
6108
6026
  }
6109
6027
  getArrayLastValue(targetObj) {
6110
6028
  return targetObj[targetObj.length - 1];
@@ -6208,10 +6126,8 @@ define((function () { 'use strict';
6208
6126
  }
6209
6127
  /* 如果有多个相同类型的兄弟元素,则需要添加索引 */
6210
6128
  if (element.parentElement.querySelectorAll(element.tagName).length > 1) {
6211
- let index = Array.prototype.indexOf.call(element.parentElement.children, element) +
6212
- 1;
6213
- selector +=
6214
- " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
6129
+ let index = Array.prototype.indexOf.call(element.parentElement.children, element) + 1;
6130
+ selector += " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
6215
6131
  }
6216
6132
  else {
6217
6133
  selector += " > " + element.tagName.toLowerCase();
@@ -6231,9 +6147,7 @@ define((function () { 'use strict';
6231
6147
  return void 0;
6232
6148
  }
6233
6149
  if (result.length > 1) {
6234
- if (result.length === 2 &&
6235
- typeof result[0] === "object" &&
6236
- typeof result[1] === "function") {
6150
+ if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
6237
6151
  let data = result[0];
6238
6152
  let handleDataFunc = result[1];
6239
6153
  Object.keys(data).forEach((keyName) => {
@@ -6331,9 +6245,7 @@ define((function () { 'use strict';
6331
6245
  return void 0;
6332
6246
  }
6333
6247
  if (result.length > 1) {
6334
- if (result.length === 2 &&
6335
- typeof result[0] === "object" &&
6336
- typeof result[1] === "function") {
6248
+ if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
6337
6249
  let data = result[0];
6338
6250
  let handleDataFunc = result[1];
6339
6251
  Object.keys(data).forEach((keyName) => {
@@ -6423,12 +6335,10 @@ define((function () { 'use strict';
6423
6335
  getRandomValue(...args) {
6424
6336
  let result = [...args];
6425
6337
  if (result.length > 1) {
6426
- if (result.length === 2 &&
6427
- typeof result[0] === "number" &&
6428
- typeof result[1] === "number") {
6338
+ if (result.length === 2 && typeof result[0] === "number" && typeof result[1] === "number") {
6429
6339
  let leftNumber = result[0] > result[1] ? result[1] : result[0];
6430
6340
  let rightNumber = result[0] > result[1] ? result[0] : result[1];
6431
- return (Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber);
6341
+ return Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber;
6432
6342
  }
6433
6343
  else {
6434
6344
  return result[Math.floor(Math.random() * result.length)];
@@ -6439,8 +6349,7 @@ define((function () { 'use strict';
6439
6349
  if (Array.isArray(paramData)) {
6440
6350
  return paramData[Math.floor(Math.random() * paramData.length)];
6441
6351
  }
6442
- else if (typeof paramData === "object" &&
6443
- Object.keys(paramData).length > 0) {
6352
+ else if (typeof paramData === "object" && Object.keys(paramData).length > 0) {
6444
6353
  let paramObjDataKey = Object.keys(paramData)[Math.floor(Math.random() * Object.keys(paramData).length)];
6445
6354
  return paramData[paramObjDataKey];
6446
6355
  }
@@ -6747,11 +6656,9 @@ define((function () { 'use strict';
6747
6656
  let nearBottomHeight = 50;
6748
6657
  let checkWindow = () => {
6749
6658
  // 已滚动的距离
6750
- let scrollTop = this.windowApi.window.pageYOffset ||
6751
- this.windowApi.document.documentElement.scrollTop;
6659
+ let scrollTop = this.windowApi.window.pageYOffset || this.windowApi.document.documentElement.scrollTop;
6752
6660
  // 视窗高度
6753
- let viewportHeight = this.windowApi.window.innerHeight ||
6754
- this.windowApi.document.documentElement.clientHeight;
6661
+ let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
6755
6662
  // 最大滚动距离
6756
6663
  let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
6757
6664
  return scrollTop + viewportHeight >= maxScrollHeight;
@@ -7040,8 +6947,7 @@ define((function () { 'use strict';
7040
6947
  **/
7041
6948
  isNull = commonUtil.isNull.bind(commonUtil);
7042
6949
  isThemeDark() {
7043
- return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)")
7044
- .matches;
6950
+ return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
7045
6951
  }
7046
6952
  /**
7047
6953
  * 判断元素是否在页面中可见
@@ -7074,10 +6980,8 @@ define((function () { 'use strict';
7074
6980
  else {
7075
6981
  let domClientRect = domItem.getBoundingClientRect();
7076
6982
  if (inView) {
7077
- let viewportWidth = this.windowApi.window.innerWidth ||
7078
- this.windowApi.document.documentElement.clientWidth;
7079
- let viewportHeight = this.windowApi.window.innerHeight ||
7080
- this.windowApi.document.documentElement.clientHeight;
6983
+ let viewportWidth = this.windowApi.window.innerWidth || this.windowApi.document.documentElement.clientWidth;
6984
+ let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
7081
6985
  result = !(domClientRect.right < 0 ||
7082
6986
  domClientRect.left > viewportWidth ||
7083
6987
  domClientRect.bottom < 0 ||
@@ -7101,8 +7005,7 @@ define((function () { 'use strict';
7101
7005
  for (const key in Object.values(this.windowApi.top.window.via)) {
7102
7006
  if (Reflect.has(this.windowApi.top.window.via, key)) {
7103
7007
  let objValueFunc = this.windowApi.top.window.via[key];
7104
- if (typeof objValueFunc === "function" &&
7105
- UtilsContext.isNativeFunc(objValueFunc)) {
7008
+ if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
7106
7009
  result = true;
7107
7010
  }
7108
7011
  else {
@@ -7124,8 +7027,7 @@ define((function () { 'use strict';
7124
7027
  for (const key in Object.values(this.windowApi.top.window.mbrowser)) {
7125
7028
  if (Reflect.has(this.windowApi.top.window.mbrowser, key)) {
7126
7029
  let objValueFunc = this.windowApi.top.window.mbrowser[key];
7127
- if (typeof objValueFunc === "function" &&
7128
- UtilsContext.isNativeFunc(objValueFunc)) {
7030
+ if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
7129
7031
  result = true;
7130
7032
  }
7131
7033
  else {
@@ -7362,13 +7264,11 @@ define((function () { 'use strict';
7362
7264
  * 释放所有
7363
7265
  */
7364
7266
  function releaseAll() {
7365
- if (typeof UtilsContext.windowApi.window[needReleaseKey] !==
7366
- "undefined") {
7267
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] !== "undefined") {
7367
7268
  /* 已存在 */
7368
7269
  return;
7369
7270
  }
7370
- UtilsContext.windowApi.window[needReleaseKey] =
7371
- UtilsContext.deepClone(needReleaseObject);
7271
+ UtilsContext.windowApi.window[needReleaseKey] = UtilsContext.deepClone(needReleaseObject);
7372
7272
  Object.values(needReleaseObject).forEach((value) => {
7373
7273
  if (typeof value === "function") {
7374
7274
  needReleaseObject[value.name] = () => { };
@@ -7382,8 +7282,7 @@ define((function () { 'use strict';
7382
7282
  Array.from(functionNameList).forEach((item) => {
7383
7283
  Object.values(needReleaseObject).forEach((value) => {
7384
7284
  if (typeof value === "function") {
7385
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7386
- "undefined") {
7285
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7387
7286
  UtilsContext.windowApi.window[needReleaseKey] = {};
7388
7287
  }
7389
7288
  if (item === value.name) {
@@ -7398,8 +7297,7 @@ define((function () { 'use strict';
7398
7297
  * 恢复所有
7399
7298
  */
7400
7299
  function recoveryAll() {
7401
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7402
- "undefined") {
7300
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7403
7301
  /* 未存在 */
7404
7302
  return;
7405
7303
  }
@@ -7410,8 +7308,7 @@ define((function () { 'use strict';
7410
7308
  * 恢复单个
7411
7309
  */
7412
7310
  function recoveryOne() {
7413
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7414
- "undefined") {
7311
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7415
7312
  /* 未存在 */
7416
7313
  return;
7417
7314
  }
@@ -7419,8 +7316,7 @@ define((function () { 'use strict';
7419
7316
  if (UtilsContext.windowApi.window[needReleaseKey][item]) {
7420
7317
  needReleaseObject[item] = UtilsContext.windowApi.window[needReleaseKey][item];
7421
7318
  Reflect.deleteProperty(UtilsContext.windowApi.window[needReleaseKey], item);
7422
- if (Object.keys(UtilsContext.windowApi.window[needReleaseKey])
7423
- .length === 0) {
7319
+ if (Object.keys(UtilsContext.windowApi.window[needReleaseKey]).length === 0) {
7424
7320
  Reflect.deleteProperty(window, needReleaseKey);
7425
7321
  }
7426
7322
  }
@@ -7677,8 +7573,7 @@ define((function () { 'use strict';
7677
7573
  let copyStatus = false;
7678
7574
  let requestPermissionStatus = await this.requestClipboardPermission();
7679
7575
  console.log(requestPermissionStatus);
7680
- if (this.hasClipboard() &&
7681
- (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
7576
+ if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
7682
7577
  try {
7683
7578
  copyStatus = await this.copyDataByClipboard();
7684
7579
  }
@@ -7839,11 +7734,8 @@ define((function () { 'use strict';
7839
7734
  mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
7840
7735
  return mouseEvent;
7841
7736
  }
7842
- let sliderElement = typeof selector === "string"
7843
- ? domUtils.selector(selector)
7844
- : selector;
7845
- if (!(sliderElement instanceof Node) ||
7846
- !(sliderElement instanceof Element)) {
7737
+ let sliderElement = typeof selector === "string" ? domUtils.selector(selector) : selector;
7738
+ if (!(sliderElement instanceof Node) || !(sliderElement instanceof Element)) {
7847
7739
  throw new Error("Utils.dragSlider 参数selector 必须为Node/Element类型");
7848
7740
  }
7849
7741
  let rect = sliderElement.getBoundingClientRect(), x0 = rect.x || rect.left, y0 = rect.y || rect.top, x1 = x0 + offsetX, y1 = y0;
@@ -7895,17 +7787,14 @@ define((function () { 'use strict';
7895
7787
  }
7896
7788
  sortListByProperty(data, getPropertyValueFunc, sortByDesc = true) {
7897
7789
  let UtilsContext = this;
7898
- if (typeof getPropertyValueFunc !== "function" &&
7899
- typeof getPropertyValueFunc !== "string") {
7790
+ if (typeof getPropertyValueFunc !== "function" && typeof getPropertyValueFunc !== "string") {
7900
7791
  throw new Error("Utils.sortListByProperty 参数 getPropertyValueFunc 必须为 function|string 类型");
7901
7792
  }
7902
7793
  if (typeof sortByDesc !== "boolean") {
7903
7794
  throw new Error("Utils.sortListByProperty 参数 sortByDesc 必须为 boolean 类型");
7904
7795
  }
7905
7796
  let getObjValue = function (obj) {
7906
- return typeof getPropertyValueFunc === "string"
7907
- ? obj[getPropertyValueFunc]
7908
- : getPropertyValueFunc(obj);
7797
+ return typeof getPropertyValueFunc === "string" ? obj[getPropertyValueFunc] : getPropertyValueFunc(obj);
7909
7798
  };
7910
7799
  /**
7911
7800
  * 排序方法
@@ -7980,8 +7869,7 @@ define((function () { 'use strict';
7980
7869
  if (Array.isArray(data)) {
7981
7870
  data.sort(sortFunc);
7982
7871
  }
7983
- else if (data instanceof NodeList ||
7984
- UtilsContext.isJQuery(data)) {
7872
+ else if (data instanceof NodeList || UtilsContext.isJQuery(data)) {
7985
7873
  sortNodeFunc(data, getDataFunc);
7986
7874
  result = getDataFunc();
7987
7875
  }
@@ -8174,9 +8062,7 @@ define((function () { 'use strict';
8174
8062
  let parent = UtilsContext.windowApi.document;
8175
8063
  // 超时时间
8176
8064
  let timeout = 0;
8177
- if (typeof args[0] !== "string" &&
8178
- !Array.isArray(args[0]) &&
8179
- typeof args[0] !== "function") {
8065
+ if (typeof args[0] !== "string" && !Array.isArray(args[0]) && typeof args[0] !== "function") {
8180
8066
  throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
8181
8067
  }
8182
8068
  if (args.length === 1) ;
@@ -8186,8 +8072,7 @@ define((function () { 'use strict';
8186
8072
  // "div",10000
8187
8073
  timeout = secondParam;
8188
8074
  }
8189
- else if (typeof secondParam === "object" &&
8190
- secondParam instanceof Node) {
8075
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8191
8076
  // "div",document
8192
8077
  parent = secondParam;
8193
8078
  }
@@ -8273,8 +8158,7 @@ define((function () { 'use strict';
8273
8158
  // "div",10000
8274
8159
  timeout = secondParam;
8275
8160
  }
8276
- else if (typeof secondParam === "object" &&
8277
- secondParam instanceof Node) {
8161
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8278
8162
  // "div",document
8279
8163
  parent = secondParam;
8280
8164
  }
@@ -8329,8 +8213,7 @@ define((function () { 'use strict';
8329
8213
  // "div",10000
8330
8214
  timeout = secondParam;
8331
8215
  }
8332
- else if (typeof secondParam === "object" &&
8333
- secondParam instanceof Node) {
8216
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8334
8217
  // "div",document
8335
8218
  parent = secondParam;
8336
8219
  }
@@ -8416,8 +8299,7 @@ define((function () { 'use strict';
8416
8299
  // "div",10000
8417
8300
  timeout = secondParam;
8418
8301
  }
8419
- else if (typeof secondParam === "object" &&
8420
- secondParam instanceof Node) {
8302
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8421
8303
  // "div",document
8422
8304
  parent = secondParam;
8423
8305
  }
@@ -8550,8 +8432,7 @@ define((function () { 'use strict';
8550
8432
  return flag;
8551
8433
  }
8552
8434
  watchObject(target, propertyName, getCallBack, setCallBack) {
8553
- if (typeof getCallBack !== "function" &&
8554
- typeof setCallBack !== "function") {
8435
+ if (typeof getCallBack !== "function" && typeof setCallBack !== "function") {
8555
8436
  return;
8556
8437
  }
8557
8438
  if (typeof getCallBack === "function") {
@@ -8603,13 +8484,27 @@ define((function () { 'use strict';
8603
8484
  return;
8604
8485
  }
8605
8486
  let handleResult = handler(target);
8606
- if (handleResult &&
8607
- typeof handleResult.isFind === "boolean" &&
8608
- handleResult.isFind) {
8487
+ if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
8609
8488
  return handleResult.data;
8610
8489
  }
8611
8490
  return this.queryProperty(handleResult.data, handler);
8612
8491
  }
8492
+ /**
8493
+ * 异步-深度获取对象属性
8494
+ * @param target 待获取的对象
8495
+ * @param handler 获取属性的回调
8496
+ */
8497
+ async asyncQueryProperty(target, handler) {
8498
+ if (target == null) {
8499
+ // @ts-ignore
8500
+ return;
8501
+ }
8502
+ let handleResult = await handler(target);
8503
+ if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
8504
+ return handleResult.data;
8505
+ }
8506
+ return await this.asyncQueryProperty(handleResult.data, handler);
8507
+ }
8613
8508
  /**
8614
8509
  * 创建一个新的Utils实例
8615
8510
  * @param option