@whitesev/utils 2.7.2 → 2.7.4

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 (42) hide show
  1. package/dist/index.amd.js +197 -350
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +197 -350
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +197 -350
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +197 -350
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +197 -350
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +197 -350
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/Utils.d.ts +30 -2
  14. package/dist/types/src/WindowApi.d.ts +4 -0
  15. package/dist/types/src/types/Event.d.ts +1 -2
  16. package/dist/types/src/types/Httpx.d.ts +4 -21
  17. package/dist/types/src/types/WindowApi.d.ts +4 -0
  18. package/dist/types/src/types/ajaxHooker.d.ts +1 -5
  19. package/package.json +1 -1
  20. package/src/ColorConversion.ts +5 -18
  21. package/src/CommonUtil.ts +8 -31
  22. package/src/DOMUtils.ts +9 -22
  23. package/src/Dictionary.ts +2 -7
  24. package/src/GBKEncoder.ts +1 -6
  25. package/src/Hooks.ts +1 -4
  26. package/src/Httpx.ts +102 -277
  27. package/src/LockFunction.ts +1 -3
  28. package/src/Log.ts +7 -23
  29. package/src/Progress.ts +2 -10
  30. package/src/TryCatch.ts +3 -11
  31. package/src/Utils.ts +213 -559
  32. package/src/UtilsCommon.ts +5 -9
  33. package/src/UtilsGMCookie.ts +1 -4
  34. package/src/UtilsGMMenu.ts +10 -29
  35. package/src/Vue.ts +2 -11
  36. package/src/WindowApi.ts +16 -0
  37. package/src/ajaxHooker/ajaxHooker.js +78 -142
  38. package/src/indexedDB.ts +3 -12
  39. package/src/types/Event.d.ts +1 -2
  40. package/src/types/Httpx.d.ts +4 -21
  41. package/src/types/WindowApi.d.ts +4 -0
  42. package/src/types/ajaxHooker.d.ts +1 -5
@@ -68,11 +68,7 @@ var Utils = (function () {
68
68
  !validPattern.test(greenValue.toString()) ||
69
69
  !validPattern.test(blueValue.toString()))
70
70
  throw new TypeError("输入错误的rgb颜色值");
71
- let hexs = [
72
- redValue.toString(16),
73
- greenValue.toString(16),
74
- blueValue.toString(16),
75
- ];
71
+ let hexs = [redValue.toString(16), greenValue.toString(16), blueValue.toString(16)];
76
72
  for (let index = 0; index < 3; index++)
77
73
  if (hexs[index].length == 1)
78
74
  hexs[index] = "0" + hexs[index];
@@ -120,10 +116,7 @@ var Utils = (function () {
120
116
  this.#data = dataText.match(/..../g);
121
117
  for (let i = 0x81; i <= 0xfe; i++) {
122
118
  for (let j = 0x40; j <= 0xfe; j++) {
123
- this.#U2Ghash[this.#data[index++]] = ("%" +
124
- i.toString(16) +
125
- "%" +
126
- j.toString(16)).toUpperCase();
119
+ this.#U2Ghash[this.#data[index++]] = ("%" + i.toString(16) + "%" + j.toString(16)).toUpperCase();
127
120
  }
128
121
  }
129
122
  for (let key in this.#U2Ghash) {
@@ -251,9 +244,7 @@ var Utils = (function () {
251
244
  callbackFunction = callback;
252
245
  context = __context__ || this;
253
246
  let result = executeTryCatch(callbackFunction, handleError, context);
254
- return result !== void 0
255
- ? result
256
- : TryCatchCore;
247
+ return result !== void 0 ? result : TryCatchCore;
257
248
  },
258
249
  };
259
250
  /**
@@ -282,10 +273,7 @@ var Utils = (function () {
282
273
  }
283
274
  if (handleErrorFunc) {
284
275
  if (typeof handleErrorFunc === "string") {
285
- result = new Function(handleErrorFunc).apply(funcThis, [
286
- ...args,
287
- error,
288
- ]);
276
+ result = new Function(handleErrorFunc).apply(funcThis, [...args, error]);
289
277
  }
290
278
  else {
291
279
  result = handleErrorFunc.apply(funcThis, [...args, error]);
@@ -373,10 +361,7 @@ var Utils = (function () {
373
361
  itemResult = objItem === 0;
374
362
  break;
375
363
  case "string":
376
- itemResult =
377
- objItem.trim() === "" ||
378
- objItem === "null" ||
379
- objItem === "undefined";
364
+ itemResult = objItem.trim() === "" || objItem === "null" || objItem === "undefined";
380
365
  break;
381
366
  case "boolean":
382
367
  itemResult = !objItem;
@@ -417,8 +402,7 @@ var Utils = (function () {
417
402
  return null;
418
403
  let clone = obj instanceof Array ? [] : {};
419
404
  for (const [key, value] of Object.entries(obj)) {
420
- clone[key] =
421
- typeof value === "object" ? UtilsContext.deepClone(value) : value;
405
+ clone[key] = typeof value === "object" ? UtilsContext.deepClone(value) : value;
422
406
  }
423
407
  return clone;
424
408
  }
@@ -736,13 +720,13 @@ var Utils = (function () {
736
720
  // ==UserScript==
737
721
  // @name ajaxHooker
738
722
  // @author cxxjackie
739
- // @version 1.4.7
723
+ // @version 1.4.8
740
724
  // @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
741
725
  // @license GNU LGPL-3.0
742
726
  // ==/UserScript==
743
727
 
744
728
  const ajaxHooker = function () {
745
- const version = "1.4.7";
729
+ const version = "1.4.8";
746
730
  const hookInst = {
747
731
  hookFns: [],
748
732
  filters: [],
@@ -771,11 +755,7 @@ var Utils = (function () {
771
755
  const emptyFn = () => {};
772
756
  const errorFn = (e) => console.error(e);
773
757
  function isThenable(obj) {
774
- return (
775
- obj &&
776
- ["object", "function"].includes(typeof obj) &&
777
- typeof obj.then === "function"
778
- );
758
+ return obj && ["object", "function"].includes(typeof obj) && typeof obj.then === "function";
779
759
  }
780
760
  function catchError(fn, ...args) {
781
761
  try {
@@ -813,8 +793,7 @@ var Utils = (function () {
813
793
  const [header, value] = line.split(/(?<=^[^:]+)\s*:\s*/);
814
794
  if (!value) continue;
815
795
  const lheader = header.toLowerCase();
816
- headers[lheader] =
817
- lheader in headers ? `${headers[lheader]}, ${value}` : value;
796
+ headers[lheader] = lheader in headers ? `${headers[lheader]}, ${value}` : value;
818
797
  }
819
798
  break;
820
799
  case "[object Headers]":
@@ -852,11 +831,9 @@ var Utils = (function () {
852
831
  !filters.find((obj) => {
853
832
  switch (true) {
854
833
  case obj.type && obj.type !== type:
855
- case getType(obj.url) === "[object String]" &&
856
- !url.includes(obj.url):
834
+ case getType(obj.url) === "[object String]" && !url.includes(obj.url):
857
835
  case getType(obj.url) === "[object RegExp]" && !obj.url.test(url):
858
- case obj.method &&
859
- obj.method.toUpperCase() !== method.toUpperCase():
836
+ case obj.method && obj.method.toUpperCase() !== method.toUpperCase():
860
837
  case "async" in obj && obj.async !== async:
861
838
  return false;
862
839
  }
@@ -869,8 +846,7 @@ var Utils = (function () {
869
846
  win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
870
847
  if (this.shouldFilter(filters)) return;
871
848
  hookFns.forEach((fn) => {
872
- if (getType(fn) === "[object Function]")
873
- catchError(fn, this.request);
849
+ if (getType(fn) === "[object Function]") catchError(fn, this.request);
874
850
  });
875
851
  for (const key in this.request) {
876
852
  if (isThenable(this.request[key])) this._recoverRequestKey(key);
@@ -883,93 +859,72 @@ var Utils = (function () {
883
859
  win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
884
860
  if (this.shouldFilter(filters)) return;
885
861
  promises.push(
886
- Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(
887
- () => {
888
- const requestKeys = [];
889
- for (const key in this.request)
890
- !ignoreKeys.has(key) && requestKeys.push(key);
891
- return Promise.all(
892
- requestKeys.map((key) =>
893
- Promise.resolve(this.request[key]).then(
894
- (val) => (this.request[key] = val),
895
- () => this._recoverRequestKey(key)
896
- )
862
+ Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(() => {
863
+ const requestKeys = [];
864
+ for (const key in this.request) !ignoreKeys.has(key) && requestKeys.push(key);
865
+ return Promise.all(
866
+ requestKeys.map((key) =>
867
+ Promise.resolve(this.request[key]).then(
868
+ (val) => (this.request[key] = val),
869
+ () => this._recoverRequestKey(key)
897
870
  )
898
- );
899
- }
900
- )
871
+ )
872
+ );
873
+ })
901
874
  );
902
875
  });
903
876
  return Promise.all(promises);
904
877
  }
905
878
  waitForResponseKeys(response) {
906
- const responseKeys =
907
- this.request.type === "xhr" ? xhrResponses : fetchResponses;
879
+ const responseKeys = this.request.type === "xhr" ? xhrResponses : fetchResponses;
908
880
  if (!this.request.async) {
909
881
  if (getType(this.request.response) === "[object Function]") {
910
882
  catchError(this.request.response, response);
911
883
  responseKeys.forEach((key) => {
912
- if (
913
- "get" in getDescriptor(response, key) ||
914
- isThenable(response[key])
915
- ) {
884
+ if ("get" in getDescriptor(response, key) || isThenable(response[key])) {
916
885
  delete response[key];
917
886
  }
918
887
  });
919
888
  }
920
889
  return new SyncThenable();
921
890
  }
922
- return Promise.resolve(catchError(this.request.response, response)).then(
923
- () =>
924
- Promise.all(
925
- responseKeys.map((key) => {
926
- const descriptor = getDescriptor(response, key);
927
- if (descriptor && "value" in descriptor) {
928
- return Promise.resolve(descriptor.value).then(
929
- (val) => (response[key] = val),
930
- () => delete response[key]
931
- );
932
- } else {
933
- delete response[key];
934
- }
935
- })
936
- )
891
+ return Promise.resolve(catchError(this.request.response, response)).then(() =>
892
+ Promise.all(
893
+ responseKeys.map((key) => {
894
+ const descriptor = getDescriptor(response, key);
895
+ if (descriptor && "value" in descriptor) {
896
+ return Promise.resolve(descriptor.value).then(
897
+ (val) => (response[key] = val),
898
+ () => delete response[key]
899
+ );
900
+ } else {
901
+ delete response[key];
902
+ }
903
+ })
904
+ )
937
905
  );
938
906
  }
939
907
  }
940
908
  const proxyHandler = {
941
909
  get(target, prop) {
942
910
  const descriptor = getDescriptor(target, prop);
943
- if (
944
- descriptor &&
945
- !descriptor.configurable &&
946
- !descriptor.writable &&
947
- !descriptor.get
948
- )
911
+ if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.get)
949
912
  return target[prop];
950
913
  const ah = target.__ajaxHooker;
951
914
  if (ah && ah.proxyProps) {
952
915
  if (prop in ah.proxyProps) {
953
916
  const pDescriptor = ah.proxyProps[prop];
954
917
  if ("get" in pDescriptor) return pDescriptor.get();
955
- if (typeof pDescriptor.value === "function")
956
- return pDescriptor.value.bind(ah);
918
+ if (typeof pDescriptor.value === "function") return pDescriptor.value.bind(ah);
957
919
  return pDescriptor.value;
958
920
  }
959
- if (typeof target[prop] === "function")
960
- return target[prop].bind(target);
921
+ if (typeof target[prop] === "function") return target[prop].bind(target);
961
922
  }
962
923
  return target[prop];
963
924
  },
964
925
  set(target, prop, value) {
965
926
  const descriptor = getDescriptor(target, prop);
966
- if (
967
- descriptor &&
968
- !descriptor.configurable &&
969
- !descriptor.writable &&
970
- !descriptor.set
971
- )
972
- return true;
927
+ if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.set) return true;
973
928
  const ah = target.__ajaxHooker;
974
929
  if (ah && ah.proxyProps && prop in ah.proxyProps) {
975
930
  const pDescriptor = ah.proxyProps[prop];
@@ -991,11 +946,7 @@ var Utils = (function () {
991
946
  proxyEvents: {},
992
947
  });
993
948
  xhr.addEventListener("readystatechange", (e) => {
994
- if (
995
- ah.proxyXhr.readyState === 4 &&
996
- ah.request &&
997
- typeof ah.request.response === "function"
998
- ) {
949
+ if (ah.proxyXhr.readyState === 4 && ah.request && typeof ah.request.response === "function") {
999
950
  const response = {
1000
951
  finalUrl: ah.proxyXhr.responseURL,
1001
952
  status: ah.proxyXhr.status,
@@ -1018,18 +969,16 @@ var Utils = (function () {
1018
969
  }
1019
970
  );
1020
971
  }
1021
- ah.resThenable = new AHRequest(ah.request)
1022
- .waitForResponseKeys(response)
1023
- .then(() => {
1024
- for (const key of xhrResponses) {
1025
- ah.proxyProps[key] = {
1026
- get: () => {
1027
- if (!(key in response)) response[key] = tempValues[key];
1028
- return response[key];
1029
- },
1030
- };
1031
- }
1032
- });
972
+ ah.resThenable = new AHRequest(ah.request).waitForResponseKeys(response).then(() => {
973
+ for (const key of xhrResponses) {
974
+ ah.proxyProps[key] = {
975
+ get: () => {
976
+ if (!(key in response)) response[key] = tempValues[key];
977
+ return response[key];
978
+ },
979
+ };
980
+ }
981
+ });
1033
982
  }
1034
983
  ah.dispatchEvent(e);
1035
984
  });
@@ -1042,13 +991,7 @@ var Utils = (function () {
1042
991
  set: (val) => ah.addEvent(onEvt, val),
1043
992
  };
1044
993
  }
1045
- for (const method of [
1046
- "setRequestHeader",
1047
- "addEventListener",
1048
- "removeEventListener",
1049
- "open",
1050
- "send",
1051
- ]) {
994
+ for (const method of ["setRequestHeader", "addEventListener", "removeEventListener", "open", "send"]) {
1052
995
  ah.proxyProps[method] = { value: ah[method] };
1053
996
  }
1054
997
  }
@@ -1057,8 +1000,7 @@ var Utils = (function () {
1057
1000
  if (type.startsWith("on")) {
1058
1001
  this.proxyEvents[type] = typeof event === "function" ? event : null;
1059
1002
  } else {
1060
- if (typeof event === "object" && event !== null)
1061
- event = event.handleEvent;
1003
+ if (typeof event === "object" && event !== null) event = event.handleEvent;
1062
1004
  if (typeof event !== "function") return;
1063
1005
  this.proxyEvents[type] = this.proxyEvents[type] || new Set();
1064
1006
  this.proxyEvents[type].add(event);
@@ -1068,8 +1010,7 @@ var Utils = (function () {
1068
1010
  if (type.startsWith("on")) {
1069
1011
  this.proxyEvents[type] = null;
1070
1012
  } else {
1071
- if (typeof event === "object" && event !== null)
1072
- event = event.handleEvent;
1013
+ if (typeof event === "object" && event !== null) event = event.handleEvent;
1073
1014
  this.proxyEvents[type] && this.proxyEvents[type].delete(event);
1074
1015
  }
1075
1016
  }
@@ -1080,9 +1021,7 @@ var Utils = (function () {
1080
1021
  defineProp(e, "srcElement", () => this.proxyXhr);
1081
1022
  this.proxyEvents[e.type] &&
1082
1023
  this.proxyEvents[e.type].forEach((fn) => {
1083
- this.resThenable.then(
1084
- () => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e)
1085
- );
1024
+ this.resThenable.then(() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e));
1086
1025
  });
1087
1026
  if (e.ajaxHooker_isStopped) return;
1088
1027
  const onEvent = this.proxyEvents["on" + e.type];
@@ -1092,8 +1031,7 @@ var Utils = (function () {
1092
1031
  this.originalXhr.setRequestHeader(header, value);
1093
1032
  if (!this.request) return;
1094
1033
  const headers = this.request.headers;
1095
- headers[header] =
1096
- header in headers ? `${headers[header]}, ${value}` : value;
1034
+ headers[header] = header in headers ? `${headers[header]}, ${value}` : value;
1097
1035
  }
1098
1036
  addEventListener(...args) {
1099
1037
  if (xhrAsyncEvents.includes(args[0])) {
@@ -1122,13 +1060,7 @@ var Utils = (function () {
1122
1060
  };
1123
1061
  this.openArgs = args;
1124
1062
  this.resThenable = new SyncThenable();
1125
- [
1126
- "responseURL",
1127
- "readyState",
1128
- "status",
1129
- "statusText",
1130
- ...xhrResponses,
1131
- ].forEach((key) => {
1063
+ ["responseURL", "readyState", "status", "statusText", ...xhrResponses].forEach((key) => {
1132
1064
  delete this.proxyProps[key];
1133
1065
  });
1134
1066
  return this.originalXhr.open(method, url, async, ...args);
@@ -1165,15 +1097,12 @@ var Utils = (function () {
1165
1097
  }
1166
1098
  function fakeXHR() {
1167
1099
  const xhr = new winAh.realXHR();
1168
- if ("__ajaxHooker" in xhr)
1169
- console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
1100
+ if ("__ajaxHooker" in xhr) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
1170
1101
  xhr.__ajaxHooker = new XhrHooker(xhr);
1171
1102
  return xhr.__ajaxHooker.proxyXhr;
1172
1103
  }
1173
1104
  fakeXHR.prototype = win.XMLHttpRequest.prototype;
1174
- Object.keys(win.XMLHttpRequest).forEach(
1175
- (key) => (fakeXHR[key] = win.XMLHttpRequest[key])
1176
- );
1105
+ Object.keys(win.XMLHttpRequest).forEach((key) => (fakeXHR[key] = win.XMLHttpRequest[key]));
1177
1106
  function fakeFetch(url, options = {}) {
1178
1107
  if (!url) return winAh.realFetch.call(win, url, options);
1179
1108
  return new Promise(async (resolve, reject) => {
@@ -1239,18 +1168,22 @@ var Utils = (function () {
1239
1168
  status: res.status,
1240
1169
  responseHeaders: parseHeaders(res.headers),
1241
1170
  };
1242
- fetchResponses.forEach(
1243
- (key) =>
1244
- (res[key] = function () {
1245
- if (key in response) return Promise.resolve(response[key]);
1246
- return resProto[key].call(this).then((val) => {
1247
- response[key] = val;
1248
- return req
1249
- .waitForResponseKeys(response)
1250
- .then(() => (key in response ? response[key] : val));
1251
- });
1252
- })
1253
- );
1171
+ if (res.ok) {
1172
+ fetchResponses.forEach(
1173
+ (key) =>
1174
+ (res[key] = function () {
1175
+ if (key in response) return Promise.resolve(response[key]);
1176
+ return resProto[key].call(this).then((val) => {
1177
+ response[key] = val;
1178
+ return req
1179
+ .waitForResponseKeys(response)
1180
+ .then(() => (key in response ? response[key] : val));
1181
+ });
1182
+ })
1183
+ );
1184
+ } else {
1185
+ catchError(request.response, response);
1186
+ }
1254
1187
  }
1255
1188
  resolve(res);
1256
1189
  }, reject);
@@ -1272,8 +1205,7 @@ var Utils = (function () {
1272
1205
  realFetchClone: resProto.clone,
1273
1206
  hookInsts: new Set(),
1274
1207
  };
1275
- if (winAh.version !== version)
1276
- console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
1208
+ if (winAh.version !== version) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
1277
1209
  win.XMLHttpRequest = winAh.fakeXHR;
1278
1210
  win.fetch = winAh.fakeFetch;
1279
1211
  resProto.clone = winAh.fakeFetchClone;
@@ -1281,37 +1213,25 @@ var Utils = (function () {
1281
1213
  // 针对头条、抖音 secsdk.umd.js 的兼容性处理
1282
1214
  class AHFunction extends Function {
1283
1215
  call(thisArg, ...args) {
1284
- if (
1285
- thisArg &&
1286
- thisArg.__ajaxHooker &&
1287
- thisArg.__ajaxHooker.proxyXhr === thisArg
1288
- ) {
1216
+ if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) {
1289
1217
  thisArg = thisArg.__ajaxHooker.originalXhr;
1290
1218
  }
1291
1219
  return Reflect.apply(this, thisArg, args);
1292
1220
  }
1293
1221
  apply(thisArg, args) {
1294
- if (
1295
- thisArg &&
1296
- thisArg.__ajaxHooker &&
1297
- thisArg.__ajaxHooker.proxyXhr === thisArg
1298
- ) {
1222
+ if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) {
1299
1223
  thisArg = thisArg.__ajaxHooker.originalXhr;
1300
1224
  }
1301
1225
  return Reflect.apply(this, thisArg, args || []);
1302
1226
  }
1303
1227
  }
1304
1228
  function hookSecsdk(csrf) {
1305
- Object.setPrototypeOf(
1306
- csrf.nativeXMLHttpRequestSetRequestHeader,
1307
- AHFunction.prototype
1308
- );
1229
+ Object.setPrototypeOf(csrf.nativeXMLHttpRequestSetRequestHeader, AHFunction.prototype);
1309
1230
  Object.setPrototypeOf(csrf.nativeXMLHttpRequestOpen, AHFunction.prototype);
1310
1231
  Object.setPrototypeOf(csrf.nativeXMLHttpRequestSend, AHFunction.prototype);
1311
1232
  }
1312
1233
  if (win.secsdk) {
1313
- if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen)
1314
- hookSecsdk(win.secsdk.csrf);
1234
+ if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen) hookSecsdk(win.secsdk.csrf);
1315
1235
  } else {
1316
1236
  defineProp(win, "secsdk", emptyFn, (secsdk) => {
1317
1237
  delete win.secsdk;
@@ -1957,14 +1877,10 @@ var Utils = (function () {
1957
1877
  // };
1958
1878
  /* 点击菜单后触发callback后的网页是否刷新 */
1959
1879
  menuOption.autoReload =
1960
- typeof menuOption.autoReload !== "boolean"
1961
- ? this.$default.autoReload
1962
- : menuOption.autoReload;
1880
+ typeof menuOption.autoReload !== "boolean" ? this.$default.autoReload : menuOption.autoReload;
1963
1881
  /* 点击菜单后触发callback后的网页是否存储值 */
1964
1882
  menuOption.isStoreValue =
1965
- typeof menuOption.isStoreValue !== "boolean"
1966
- ? this.$default.isStoreValue
1967
- : menuOption.isStoreValue;
1883
+ typeof menuOption.isStoreValue !== "boolean" ? this.$default.isStoreValue : menuOption.isStoreValue;
1968
1884
  /**
1969
1885
  * 用户点击菜单后的回调函数
1970
1886
  * @param event
@@ -2017,8 +1933,7 @@ var Utils = (function () {
2017
1933
  * @param menuKey 菜单-键key
2018
1934
  */
2019
1935
  getMenuHandledOption(menuKey) {
2020
- return this.$data.data.find((item) => item.handleData.key === menuKey)
2021
- ?.handleData;
1936
+ return this.$data.data.find((item) => item.handleData.key === menuKey)?.handleData;
2022
1937
  },
2023
1938
  };
2024
1939
  constructor(details) {
@@ -2026,8 +1941,7 @@ var Utils = (function () {
2026
1941
  this.GM_Api.setValue = details.GM_setValue;
2027
1942
  this.GM_Api.registerMenuCommand = details.GM_registerMenuCommand;
2028
1943
  this.GM_Api.unregisterMenuCommand = details.GM_unregisterMenuCommand;
2029
- this.MenuHandle.$default.autoReload =
2030
- typeof details.autoReload === "boolean" ? details.autoReload : true;
1944
+ this.MenuHandle.$default.autoReload = typeof details.autoReload === "boolean" ? details.autoReload : true;
2031
1945
  for (const keyName of Object.keys(this.GM_Api)) {
2032
1946
  if (typeof this.GM_Api[keyName] !== "function") {
2033
1947
  throw new Error(`Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`);
@@ -2259,8 +2173,7 @@ var Utils = (function () {
2259
2173
  _context = context || window;
2260
2174
  _funcName = getFuncName(this);
2261
2175
  _context["realFunc_" + _funcName] = this;
2262
- if (_context[_funcName].prototype &&
2263
- _context[_funcName].prototype.isHooked) {
2176
+ if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
2264
2177
  console.log("Already has been hooked,unhook first");
2265
2178
  return false;
2266
2179
  }
@@ -2438,8 +2351,7 @@ var Utils = (function () {
2438
2351
  if (details.allowInterceptConfig != null) {
2439
2352
  // 配置存在
2440
2353
  // 细分处理是否拦截
2441
- if (typeof details.allowInterceptConfig.afterResponseSuccess ===
2442
- "boolean" &&
2354
+ if (typeof details.allowInterceptConfig.afterResponseSuccess === "boolean" &&
2443
2355
  !details.allowInterceptConfig.afterResponseSuccess) {
2444
2356
  // 设置了禁止拦截
2445
2357
  return details;
@@ -2474,8 +2386,7 @@ var Utils = (function () {
2474
2386
  if (data.details.allowInterceptConfig != null) {
2475
2387
  // 配置存在
2476
2388
  // 细分处理是否拦截
2477
- if (typeof data.details.allowInterceptConfig.afterResponseError ===
2478
- "boolean" &&
2389
+ if (typeof data.details.allowInterceptConfig.afterResponseError === "boolean" &&
2479
2390
  !data.details.allowInterceptConfig.afterResponseError) {
2480
2391
  // 设置了禁止拦截
2481
2392
  return data;
@@ -2577,44 +2488,31 @@ var Utils = (function () {
2577
2488
  let requestOption = {
2578
2489
  url: url,
2579
2490
  method: (method || "GET").toString().toUpperCase().trim(),
2580
- timeout: userRequestOption.timeout ||
2581
- this.context.#defaultRequestOption.timeout,
2582
- responseType: userRequestOption.responseType ||
2583
- this.context.#defaultRequestOption.responseType,
2491
+ timeout: userRequestOption.timeout || this.context.#defaultRequestOption.timeout,
2492
+ responseType: userRequestOption.responseType || this.context.#defaultRequestOption.responseType,
2584
2493
  /* 对象使用深拷贝 */
2585
2494
  headers: commonUtil.deepClone(this.context.#defaultRequestOption.headers),
2586
2495
  data: userRequestOption.data || this.context.#defaultRequestOption.data,
2587
- redirect: userRequestOption.redirect ||
2588
- this.context.#defaultRequestOption.redirect,
2496
+ redirect: userRequestOption.redirect || this.context.#defaultRequestOption.redirect,
2589
2497
  cookie: userRequestOption.cookie || this.context.#defaultRequestOption.cookie,
2590
- cookiePartition: userRequestOption.cookiePartition ||
2591
- this.context.#defaultRequestOption.cookiePartition,
2498
+ cookiePartition: userRequestOption.cookiePartition || this.context.#defaultRequestOption.cookiePartition,
2592
2499
  binary: userRequestOption.binary || this.context.#defaultRequestOption.binary,
2593
- nocache: userRequestOption.nocache ||
2594
- this.context.#defaultRequestOption.nocache,
2595
- revalidate: userRequestOption.revalidate ||
2596
- this.context.#defaultRequestOption.revalidate,
2500
+ nocache: userRequestOption.nocache || this.context.#defaultRequestOption.nocache,
2501
+ revalidate: userRequestOption.revalidate || this.context.#defaultRequestOption.revalidate,
2597
2502
  /* 对象使用深拷贝 */
2598
- context: commonUtil.deepClone(userRequestOption.context ||
2599
- this.context.#defaultRequestOption.context),
2600
- overrideMimeType: userRequestOption.overrideMimeType ||
2601
- this.context.#defaultRequestOption.overrideMimeType,
2602
- anonymous: userRequestOption.anonymous ||
2603
- this.context.#defaultRequestOption.anonymous,
2503
+ context: commonUtil.deepClone(userRequestOption.context || this.context.#defaultRequestOption.context),
2504
+ overrideMimeType: userRequestOption.overrideMimeType || this.context.#defaultRequestOption.overrideMimeType,
2505
+ anonymous: userRequestOption.anonymous || this.context.#defaultRequestOption.anonymous,
2604
2506
  fetch: userRequestOption.fetch || this.context.#defaultRequestOption.fetch,
2605
2507
  /* 对象使用深拷贝 */
2606
2508
  fetchInit: commonUtil.deepClone(this.context.#defaultRequestOption.fetchInit),
2607
2509
  allowInterceptConfig: {
2608
- beforeRequest: this.context.#defaultRequestOption
2609
- .allowInterceptConfig.beforeRequest,
2610
- afterResponseSuccess: this.context.#defaultRequestOption
2611
- .allowInterceptConfig.afterResponseSuccess,
2612
- afterResponseError: this.context.#defaultRequestOption
2613
- .allowInterceptConfig.afterResponseError,
2510
+ beforeRequest: this.context.#defaultRequestOption.allowInterceptConfig.beforeRequest,
2511
+ afterResponseSuccess: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseSuccess,
2512
+ afterResponseError: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseError,
2614
2513
  },
2615
2514
  user: userRequestOption.user || this.context.#defaultRequestOption.user,
2616
- password: userRequestOption.password ||
2617
- this.context.#defaultRequestOption.password,
2515
+ password: userRequestOption.password || this.context.#defaultRequestOption.password,
2618
2516
  onabort(...args) {
2619
2517
  that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
2620
2518
  },
@@ -2662,14 +2560,12 @@ var Utils = (function () {
2662
2560
  if (typeof requestOption.headers === "object") {
2663
2561
  if (typeof userRequestOption.headers === "object") {
2664
2562
  Object.keys(userRequestOption.headers).forEach((keyName, index) => {
2665
- if (keyName in requestOption.headers &&
2666
- userRequestOption.headers?.[keyName] == null) {
2563
+ if (keyName in requestOption.headers && userRequestOption.headers?.[keyName] == null) {
2667
2564
  /* 在默认的header中存在,且设置它新的值为空,那么就是默认的值 */
2668
2565
  Reflect.deleteProperty(requestOption.headers, keyName);
2669
2566
  }
2670
2567
  else {
2671
- requestOption.headers[keyName] =
2672
- userRequestOption?.headers?.[keyName];
2568
+ requestOption.headers[keyName] = userRequestOption?.headers?.[keyName];
2673
2569
  }
2674
2570
  });
2675
2571
  }
@@ -2682,8 +2578,7 @@ var Utils = (function () {
2682
2578
  /* 使用assign替换且添加 */
2683
2579
  if (typeof userRequestOption.fetchInit === "object") {
2684
2580
  Object.keys(userRequestOption.fetchInit).forEach((keyName, index) => {
2685
- if (keyName in requestOption.fetchInit &&
2686
- userRequestOption.fetchInit[keyName] == null) {
2581
+ if (keyName in requestOption.fetchInit && userRequestOption.fetchInit[keyName] == null) {
2687
2582
  /* 在默认的fetchInit中存在,且设置它新的值为空,那么就是默认的值 */
2688
2583
  Reflect.deleteProperty(requestOption.fetchInit, keyName);
2689
2584
  }
@@ -2697,8 +2592,7 @@ var Utils = (function () {
2697
2592
  Reflect.set(requestOption, "fetchInit", userRequestOption.fetchInit);
2698
2593
  }
2699
2594
  // 处理新的cookiePartition
2700
- if (typeof requestOption.cookiePartition === "object" &&
2701
- requestOption.cookiePartition != null) {
2595
+ if (typeof requestOption.cookiePartition === "object" && requestOption.cookiePartition != null) {
2702
2596
  if (Reflect.has(requestOption.cookiePartition, "topLevelSite") &&
2703
2597
  typeof requestOption.cookiePartition.topLevelSite !== "string") {
2704
2598
  // topLevelSite必须是字符串
@@ -2720,8 +2614,7 @@ var Utils = (function () {
2720
2614
  }
2721
2615
  else {
2722
2616
  // 补充origin+/
2723
- requestOption.url =
2724
- globalThis.location.origin + "/" + requestOption.url;
2617
+ requestOption.url = globalThis.location.origin + "/" + requestOption.url;
2725
2618
  }
2726
2619
  }
2727
2620
  if (requestOption.fetchInit && !requestOption.fetch) {
@@ -2845,8 +2738,7 @@ var Utils = (function () {
2845
2738
  * fetch的请求配置
2846
2739
  **/
2847
2740
  let fetchRequestOption = {};
2848
- if ((option.method === "GET" || option.method === "HEAD") &&
2849
- option.data != null) {
2741
+ if ((option.method === "GET" || option.method === "HEAD") && option.data != null) {
2850
2742
  /* GET 或 HEAD 方法的请求不能包含 body 信息 */
2851
2743
  Reflect.deleteProperty(option, "data");
2852
2744
  }
@@ -3127,8 +3019,7 @@ var Utils = (function () {
3127
3019
  if (typeof details?.onreadystatechange === "function") {
3128
3020
  details.onreadystatechange.apply(this, argsResult);
3129
3021
  }
3130
- else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
3131
- "function") {
3022
+ else if (typeof this.context.#defaultRequestOption?.onreadystatechange === "function") {
3132
3023
  this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
3133
3024
  }
3134
3025
  },
@@ -3157,8 +3048,7 @@ var Utils = (function () {
3157
3048
  if (this.context.#defaultInitOption.logDetails) {
3158
3049
  console.log("[Httpx-HttpxRequest.request] 请求前的配置👇", details);
3159
3050
  }
3160
- if (typeof this.context.HttpxRequestHook.beforeRequestCallBack ===
3161
- "function") {
3051
+ if (typeof this.context.HttpxRequestHook.beforeRequestCallBack === "function") {
3162
3052
  let hookResult = await this.context.HttpxRequestHook.beforeRequestCallBack(details);
3163
3053
  if (hookResult == null) {
3164
3054
  return;
@@ -3214,9 +3104,7 @@ var Utils = (function () {
3214
3104
  /* 如果需要stream,且获取到的是stream,那直接返回 */
3215
3105
  if (option.responseType === "stream" ||
3216
3106
  (fetchResponse.headers.has("Content-Type") &&
3217
- fetchResponse.headers
3218
- .get("Content-Type")
3219
- .includes("text/event-stream"))) {
3107
+ fetchResponse.headers.get("Content-Type").includes("text/event-stream"))) {
3220
3108
  Reflect.set(httpxResponse, "isStream", true);
3221
3109
  Reflect.set(httpxResponse, "response", fetchResponse.body);
3222
3110
  Reflect.deleteProperty(httpxResponse, "responseText");
@@ -3235,9 +3123,7 @@ var Utils = (function () {
3235
3123
  /** 数据编码 */
3236
3124
  let encoding = "utf-8";
3237
3125
  if (fetchResponse.headers.has("Content-Type")) {
3238
- let charsetMatched = fetchResponse.headers
3239
- .get("Content-Type")
3240
- ?.match(/charset=(.+)/);
3126
+ let charsetMatched = fetchResponse.headers.get("Content-Type")?.match(/charset=(.+)/);
3241
3127
  if (charsetMatched) {
3242
3128
  encoding = charsetMatched[1];
3243
3129
  encoding = encoding.toLowerCase();
@@ -3259,13 +3145,11 @@ var Utils = (function () {
3259
3145
  response = new Blob([arrayBuffer]);
3260
3146
  }
3261
3147
  else if (option.responseType === "json" ||
3262
- (typeof fetchResponseType === "string" &&
3263
- fetchResponseType.includes("application/json"))) {
3148
+ (typeof fetchResponseType === "string" && fetchResponseType.includes("application/json"))) {
3264
3149
  // response返回格式是JSON格式
3265
3150
  response = commonUtil.toJSON(responseText);
3266
3151
  }
3267
- else if (option.responseType === "document" ||
3268
- option.responseType == null) {
3152
+ else if (option.responseType === "document" || option.responseType == null) {
3269
3153
  // response返回格式是文档格式
3270
3154
  let parser = new DOMParser();
3271
3155
  response = parser.parseFromString(responseText, "text/html");
@@ -3528,8 +3412,7 @@ var Utils = (function () {
3528
3412
  }
3529
3413
  requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
3530
3414
  const requestResult = await this.HttpxRequest.request(requestOption);
3531
- if (requestResult != null &&
3532
- typeof requestResult.abort === "function") {
3415
+ if (requestResult != null && typeof requestResult.abort === "function") {
3533
3416
  abortFn = requestResult.abort;
3534
3417
  }
3535
3418
  });
@@ -4020,8 +3903,7 @@ var Utils = (function () {
4020
3903
  if (typeof __GM_info === "string") {
4021
3904
  this.tag = __GM_info;
4022
3905
  }
4023
- else if (typeof __GM_info === "object" &&
4024
- typeof __GM_info?.script?.name === "string") {
3906
+ else if (typeof __GM_info === "object" && typeof __GM_info?.script?.name === "string") {
4025
3907
  this.tag = __GM_info.script.name;
4026
3908
  }
4027
3909
  this.#console = console;
@@ -4077,8 +3959,7 @@ var Utils = (function () {
4077
3959
  */
4078
3960
  checkClearConsole() {
4079
3961
  this.#logCount++;
4080
- if (this.#details.autoClearConsole &&
4081
- this.#logCount > this.#details.logMaxCount) {
3962
+ if (this.#details.autoClearConsole && this.#logCount > this.#details.logMaxCount) {
4082
3963
  this.#console.clear();
4083
3964
  this.#logCount = 0;
4084
3965
  }
@@ -4487,6 +4368,10 @@ var Utils = (function () {
4487
4368
  globalThis: globalThis,
4488
4369
  self: self,
4489
4370
  top: top,
4371
+ setTimeout: globalThis.setTimeout,
4372
+ setInterval: globalThis.setInterval,
4373
+ clearTimeout: globalThis.clearTimeout,
4374
+ clearInterval: globalThis.clearInterval,
4490
4375
  };
4491
4376
  /** 使用的配置 */
4492
4377
  api;
@@ -4519,6 +4404,18 @@ var Utils = (function () {
4519
4404
  get top() {
4520
4405
  return this.api.top;
4521
4406
  }
4407
+ get setTimeout() {
4408
+ return this.api.setTimeout;
4409
+ }
4410
+ get setInterval() {
4411
+ return this.api.setInterval;
4412
+ }
4413
+ get clearTimeout() {
4414
+ return this.api.clearTimeout;
4415
+ }
4416
+ get clearInterval() {
4417
+ return this.api.clearInterval;
4418
+ }
4522
4419
  }
4523
4420
 
4524
4421
  const VueUtils = {
@@ -4994,7 +4891,7 @@ var Utils = (function () {
4994
4891
  };
4995
4892
 
4996
4893
  // This is the minified and stringified code of the worker-timers-worker package.
4997
- 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
4894
+ 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
4998
4895
 
4999
4896
  const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
5000
4897
  const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
@@ -5581,7 +5478,7 @@ var Utils = (function () {
5581
5478
  this.windowApi = new WindowApi(option);
5582
5479
  }
5583
5480
  /** 版本号 */
5584
- version = "2025.7.29";
5481
+ version = "2025.8.21";
5585
5482
  addStyle(cssText) {
5586
5483
  if (typeof cssText !== "string") {
5587
5484
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");
@@ -5704,13 +5601,9 @@ var Utils = (function () {
5704
5601
  let touchEvent = UtilsContext.windowApi.window.event;
5705
5602
  let $click = clickEvent?.composedPath()?.[0];
5706
5603
  // 点击的x坐标
5707
- let clickPosX = clickEvent?.clientX != null
5708
- ? clickEvent.clientX
5709
- : touchEvent.touches[0].clientX;
5604
+ let clickPosX = clickEvent?.clientX != null ? clickEvent.clientX : touchEvent.touches[0].clientX;
5710
5605
  // 点击的y坐标
5711
- let clickPosY = clickEvent?.clientY != null
5712
- ? clickEvent.clientY
5713
- : touchEvent.touches[0].clientY;
5606
+ let clickPosY = clickEvent?.clientY != null ? clickEvent.clientY : touchEvent.touches[0].clientY;
5714
5607
  let {
5715
5608
  /* 要检测的元素的相对屏幕的横坐标最左边 */
5716
5609
  left: elementPosXLeft,
@@ -5873,9 +5766,7 @@ var Utils = (function () {
5873
5766
  /* CODE FOR BROWSERS THAT SUPPORT window.find */
5874
5767
  let windowFind = this.windowApi.self.find;
5875
5768
  strFound = windowFind(str, caseSensitive, true, true, false);
5876
- if (strFound &&
5877
- this.windowApi.self.getSelection &&
5878
- !this.windowApi.self.getSelection().anchorNode) {
5769
+ if (strFound && this.windowApi.self.getSelection && !this.windowApi.self.getSelection().anchorNode) {
5879
5770
  strFound = windowFind(str, caseSensitive, true, true, false);
5880
5771
  }
5881
5772
  if (!strFound) {
@@ -5978,9 +5869,7 @@ var Utils = (function () {
5978
5869
  }
5979
5870
  }
5980
5871
  result = result.toFixed(2);
5981
- result = addType
5982
- ? result + resultType.toString()
5983
- : parseFloat(result.toString());
5872
+ result = addType ? result + resultType.toString() : parseFloat(result.toString());
5984
5873
  return result;
5985
5874
  }
5986
5875
  getNodeListValue(...args) {
@@ -6059,14 +5948,7 @@ var Utils = (function () {
6059
5948
  if (text.length === 8) {
6060
5949
  /* 该字符串只有时分秒 */
6061
5950
  let today = new Date();
6062
- text =
6063
- today.getFullYear() +
6064
- "-" +
6065
- (today.getMonth() + 1) +
6066
- "-" +
6067
- today.getDate() +
6068
- " " +
6069
- text;
5951
+ text = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate() + " " + text;
6070
5952
  }
6071
5953
  text = text.substring(0, 19);
6072
5954
  text = text.replace(/-/g, "/");
@@ -6087,25 +5969,13 @@ var Utils = (function () {
6087
5969
  * 获取 transitionend 的在各个浏览器的兼容名
6088
5970
  */
6089
5971
  getTransitionEndNameList() {
6090
- return [
6091
- "webkitTransitionEnd",
6092
- "mozTransitionEnd",
6093
- "MSTransitionEnd",
6094
- "otransitionend",
6095
- "transitionend",
6096
- ];
5972
+ return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
6097
5973
  }
6098
5974
  /**
6099
5975
  * 获取 animationend 的在各个浏览器的兼容名
6100
5976
  */
6101
5977
  getAnimationEndNameList() {
6102
- return [
6103
- "webkitAnimationEnd",
6104
- "mozAnimationEnd",
6105
- "MSAnimationEnd",
6106
- "oanimationend",
6107
- "animationend",
6108
- ];
5978
+ return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
6109
5979
  }
6110
5980
  getArrayLastValue(targetObj) {
6111
5981
  return targetObj[targetObj.length - 1];
@@ -6209,10 +6079,8 @@ var Utils = (function () {
6209
6079
  }
6210
6080
  /* 如果有多个相同类型的兄弟元素,则需要添加索引 */
6211
6081
  if (element.parentElement.querySelectorAll(element.tagName).length > 1) {
6212
- let index = Array.prototype.indexOf.call(element.parentElement.children, element) +
6213
- 1;
6214
- selector +=
6215
- " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
6082
+ let index = Array.prototype.indexOf.call(element.parentElement.children, element) + 1;
6083
+ selector += " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
6216
6084
  }
6217
6085
  else {
6218
6086
  selector += " > " + element.tagName.toLowerCase();
@@ -6232,9 +6100,7 @@ var Utils = (function () {
6232
6100
  return void 0;
6233
6101
  }
6234
6102
  if (result.length > 1) {
6235
- if (result.length === 2 &&
6236
- typeof result[0] === "object" &&
6237
- typeof result[1] === "function") {
6103
+ if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
6238
6104
  let data = result[0];
6239
6105
  let handleDataFunc = result[1];
6240
6106
  Object.keys(data).forEach((keyName) => {
@@ -6332,9 +6198,7 @@ var Utils = (function () {
6332
6198
  return void 0;
6333
6199
  }
6334
6200
  if (result.length > 1) {
6335
- if (result.length === 2 &&
6336
- typeof result[0] === "object" &&
6337
- typeof result[1] === "function") {
6201
+ if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
6338
6202
  let data = result[0];
6339
6203
  let handleDataFunc = result[1];
6340
6204
  Object.keys(data).forEach((keyName) => {
@@ -6424,12 +6288,10 @@ var Utils = (function () {
6424
6288
  getRandomValue(...args) {
6425
6289
  let result = [...args];
6426
6290
  if (result.length > 1) {
6427
- if (result.length === 2 &&
6428
- typeof result[0] === "number" &&
6429
- typeof result[1] === "number") {
6291
+ if (result.length === 2 && typeof result[0] === "number" && typeof result[1] === "number") {
6430
6292
  let leftNumber = result[0] > result[1] ? result[1] : result[0];
6431
6293
  let rightNumber = result[0] > result[1] ? result[0] : result[1];
6432
- return (Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber);
6294
+ return Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber;
6433
6295
  }
6434
6296
  else {
6435
6297
  return result[Math.floor(Math.random() * result.length)];
@@ -6440,8 +6302,7 @@ var Utils = (function () {
6440
6302
  if (Array.isArray(paramData)) {
6441
6303
  return paramData[Math.floor(Math.random() * paramData.length)];
6442
6304
  }
6443
- else if (typeof paramData === "object" &&
6444
- Object.keys(paramData).length > 0) {
6305
+ else if (typeof paramData === "object" && Object.keys(paramData).length > 0) {
6445
6306
  let paramObjDataKey = Object.keys(paramData)[Math.floor(Math.random() * Object.keys(paramData).length)];
6446
6307
  return paramData[paramObjDataKey];
6447
6308
  }
@@ -6748,11 +6609,9 @@ var Utils = (function () {
6748
6609
  let nearBottomHeight = 50;
6749
6610
  let checkWindow = () => {
6750
6611
  // 已滚动的距离
6751
- let scrollTop = this.windowApi.window.pageYOffset ||
6752
- this.windowApi.document.documentElement.scrollTop;
6612
+ let scrollTop = this.windowApi.window.pageYOffset || this.windowApi.document.documentElement.scrollTop;
6753
6613
  // 视窗高度
6754
- let viewportHeight = this.windowApi.window.innerHeight ||
6755
- this.windowApi.document.documentElement.clientHeight;
6614
+ let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
6756
6615
  // 最大滚动距离
6757
6616
  let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
6758
6617
  return scrollTop + viewportHeight >= maxScrollHeight;
@@ -7041,8 +6900,7 @@ var Utils = (function () {
7041
6900
  **/
7042
6901
  isNull = commonUtil.isNull.bind(commonUtil);
7043
6902
  isThemeDark() {
7044
- return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)")
7045
- .matches;
6903
+ return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
7046
6904
  }
7047
6905
  /**
7048
6906
  * 判断元素是否在页面中可见
@@ -7075,10 +6933,8 @@ var Utils = (function () {
7075
6933
  else {
7076
6934
  let domClientRect = domItem.getBoundingClientRect();
7077
6935
  if (inView) {
7078
- let viewportWidth = this.windowApi.window.innerWidth ||
7079
- this.windowApi.document.documentElement.clientWidth;
7080
- let viewportHeight = this.windowApi.window.innerHeight ||
7081
- this.windowApi.document.documentElement.clientHeight;
6936
+ let viewportWidth = this.windowApi.window.innerWidth || this.windowApi.document.documentElement.clientWidth;
6937
+ let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
7082
6938
  result = !(domClientRect.right < 0 ||
7083
6939
  domClientRect.left > viewportWidth ||
7084
6940
  domClientRect.bottom < 0 ||
@@ -7102,8 +6958,7 @@ var Utils = (function () {
7102
6958
  for (const key in Object.values(this.windowApi.top.window.via)) {
7103
6959
  if (Reflect.has(this.windowApi.top.window.via, key)) {
7104
6960
  let objValueFunc = this.windowApi.top.window.via[key];
7105
- if (typeof objValueFunc === "function" &&
7106
- UtilsContext.isNativeFunc(objValueFunc)) {
6961
+ if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
7107
6962
  result = true;
7108
6963
  }
7109
6964
  else {
@@ -7125,8 +6980,7 @@ var Utils = (function () {
7125
6980
  for (const key in Object.values(this.windowApi.top.window.mbrowser)) {
7126
6981
  if (Reflect.has(this.windowApi.top.window.mbrowser, key)) {
7127
6982
  let objValueFunc = this.windowApi.top.window.mbrowser[key];
7128
- if (typeof objValueFunc === "function" &&
7129
- UtilsContext.isNativeFunc(objValueFunc)) {
6983
+ if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
7130
6984
  result = true;
7131
6985
  }
7132
6986
  else {
@@ -7363,13 +7217,11 @@ var Utils = (function () {
7363
7217
  * 释放所有
7364
7218
  */
7365
7219
  function releaseAll() {
7366
- if (typeof UtilsContext.windowApi.window[needReleaseKey] !==
7367
- "undefined") {
7220
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] !== "undefined") {
7368
7221
  /* 已存在 */
7369
7222
  return;
7370
7223
  }
7371
- UtilsContext.windowApi.window[needReleaseKey] =
7372
- UtilsContext.deepClone(needReleaseObject);
7224
+ UtilsContext.windowApi.window[needReleaseKey] = UtilsContext.deepClone(needReleaseObject);
7373
7225
  Object.values(needReleaseObject).forEach((value) => {
7374
7226
  if (typeof value === "function") {
7375
7227
  needReleaseObject[value.name] = () => { };
@@ -7383,8 +7235,7 @@ var Utils = (function () {
7383
7235
  Array.from(functionNameList).forEach((item) => {
7384
7236
  Object.values(needReleaseObject).forEach((value) => {
7385
7237
  if (typeof value === "function") {
7386
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7387
- "undefined") {
7238
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7388
7239
  UtilsContext.windowApi.window[needReleaseKey] = {};
7389
7240
  }
7390
7241
  if (item === value.name) {
@@ -7399,8 +7250,7 @@ var Utils = (function () {
7399
7250
  * 恢复所有
7400
7251
  */
7401
7252
  function recoveryAll() {
7402
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7403
- "undefined") {
7253
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7404
7254
  /* 未存在 */
7405
7255
  return;
7406
7256
  }
@@ -7411,8 +7261,7 @@ var Utils = (function () {
7411
7261
  * 恢复单个
7412
7262
  */
7413
7263
  function recoveryOne() {
7414
- if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
7415
- "undefined") {
7264
+ if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7416
7265
  /* 未存在 */
7417
7266
  return;
7418
7267
  }
@@ -7420,8 +7269,7 @@ var Utils = (function () {
7420
7269
  if (UtilsContext.windowApi.window[needReleaseKey][item]) {
7421
7270
  needReleaseObject[item] = UtilsContext.windowApi.window[needReleaseKey][item];
7422
7271
  Reflect.deleteProperty(UtilsContext.windowApi.window[needReleaseKey], item);
7423
- if (Object.keys(UtilsContext.windowApi.window[needReleaseKey])
7424
- .length === 0) {
7272
+ if (Object.keys(UtilsContext.windowApi.window[needReleaseKey]).length === 0) {
7425
7273
  Reflect.deleteProperty(window, needReleaseKey);
7426
7274
  }
7427
7275
  }
@@ -7678,8 +7526,7 @@ var Utils = (function () {
7678
7526
  let copyStatus = false;
7679
7527
  let requestPermissionStatus = await this.requestClipboardPermission();
7680
7528
  console.log(requestPermissionStatus);
7681
- if (this.hasClipboard() &&
7682
- (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
7529
+ if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
7683
7530
  try {
7684
7531
  copyStatus = await this.copyDataByClipboard();
7685
7532
  }
@@ -7840,11 +7687,8 @@ var Utils = (function () {
7840
7687
  mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
7841
7688
  return mouseEvent;
7842
7689
  }
7843
- let sliderElement = typeof selector === "string"
7844
- ? domUtils.selector(selector)
7845
- : selector;
7846
- if (!(sliderElement instanceof Node) ||
7847
- !(sliderElement instanceof Element)) {
7690
+ let sliderElement = typeof selector === "string" ? domUtils.selector(selector) : selector;
7691
+ if (!(sliderElement instanceof Node) || !(sliderElement instanceof Element)) {
7848
7692
  throw new Error("Utils.dragSlider 参数selector 必须为Node/Element类型");
7849
7693
  }
7850
7694
  let rect = sliderElement.getBoundingClientRect(), x0 = rect.x || rect.left, y0 = rect.y || rect.top, x1 = x0 + offsetX, y1 = y0;
@@ -7896,17 +7740,14 @@ var Utils = (function () {
7896
7740
  }
7897
7741
  sortListByProperty(data, getPropertyValueFunc, sortByDesc = true) {
7898
7742
  let UtilsContext = this;
7899
- if (typeof getPropertyValueFunc !== "function" &&
7900
- typeof getPropertyValueFunc !== "string") {
7743
+ if (typeof getPropertyValueFunc !== "function" && typeof getPropertyValueFunc !== "string") {
7901
7744
  throw new Error("Utils.sortListByProperty 参数 getPropertyValueFunc 必须为 function|string 类型");
7902
7745
  }
7903
7746
  if (typeof sortByDesc !== "boolean") {
7904
7747
  throw new Error("Utils.sortListByProperty 参数 sortByDesc 必须为 boolean 类型");
7905
7748
  }
7906
7749
  let getObjValue = function (obj) {
7907
- return typeof getPropertyValueFunc === "string"
7908
- ? obj[getPropertyValueFunc]
7909
- : getPropertyValueFunc(obj);
7750
+ return typeof getPropertyValueFunc === "string" ? obj[getPropertyValueFunc] : getPropertyValueFunc(obj);
7910
7751
  };
7911
7752
  /**
7912
7753
  * 排序方法
@@ -7981,8 +7822,7 @@ var Utils = (function () {
7981
7822
  if (Array.isArray(data)) {
7982
7823
  data.sort(sortFunc);
7983
7824
  }
7984
- else if (data instanceof NodeList ||
7985
- UtilsContext.isJQuery(data)) {
7825
+ else if (data instanceof NodeList || UtilsContext.isJQuery(data)) {
7986
7826
  sortNodeFunc(data, getDataFunc);
7987
7827
  result = getDataFunc();
7988
7828
  }
@@ -8175,9 +8015,7 @@ var Utils = (function () {
8175
8015
  let parent = UtilsContext.windowApi.document;
8176
8016
  // 超时时间
8177
8017
  let timeout = 0;
8178
- if (typeof args[0] !== "string" &&
8179
- !Array.isArray(args[0]) &&
8180
- typeof args[0] !== "function") {
8018
+ if (typeof args[0] !== "string" && !Array.isArray(args[0]) && typeof args[0] !== "function") {
8181
8019
  throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
8182
8020
  }
8183
8021
  if (args.length === 1) ;
@@ -8187,8 +8025,7 @@ var Utils = (function () {
8187
8025
  // "div",10000
8188
8026
  timeout = secondParam;
8189
8027
  }
8190
- else if (typeof secondParam === "object" &&
8191
- secondParam instanceof Node) {
8028
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8192
8029
  // "div",document
8193
8030
  parent = secondParam;
8194
8031
  }
@@ -8274,8 +8111,7 @@ var Utils = (function () {
8274
8111
  // "div",10000
8275
8112
  timeout = secondParam;
8276
8113
  }
8277
- else if (typeof secondParam === "object" &&
8278
- secondParam instanceof Node) {
8114
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8279
8115
  // "div",document
8280
8116
  parent = secondParam;
8281
8117
  }
@@ -8330,8 +8166,7 @@ var Utils = (function () {
8330
8166
  // "div",10000
8331
8167
  timeout = secondParam;
8332
8168
  }
8333
- else if (typeof secondParam === "object" &&
8334
- secondParam instanceof Node) {
8169
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8335
8170
  // "div",document
8336
8171
  parent = secondParam;
8337
8172
  }
@@ -8417,8 +8252,7 @@ var Utils = (function () {
8417
8252
  // "div",10000
8418
8253
  timeout = secondParam;
8419
8254
  }
8420
- else if (typeof secondParam === "object" &&
8421
- secondParam instanceof Node) {
8255
+ else if (typeof secondParam === "object" && secondParam instanceof Node) {
8422
8256
  // "div",document
8423
8257
  parent = secondParam;
8424
8258
  }
@@ -8551,8 +8385,7 @@ var Utils = (function () {
8551
8385
  return flag;
8552
8386
  }
8553
8387
  watchObject(target, propertyName, getCallBack, setCallBack) {
8554
- if (typeof getCallBack !== "function" &&
8555
- typeof setCallBack !== "function") {
8388
+ if (typeof getCallBack !== "function" && typeof setCallBack !== "function") {
8556
8389
  return;
8557
8390
  }
8558
8391
  if (typeof getCallBack === "function") {
@@ -8604,13 +8437,27 @@ var Utils = (function () {
8604
8437
  return;
8605
8438
  }
8606
8439
  let handleResult = handler(target);
8607
- if (handleResult &&
8608
- typeof handleResult.isFind === "boolean" &&
8609
- handleResult.isFind) {
8440
+ if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
8610
8441
  return handleResult.data;
8611
8442
  }
8612
8443
  return this.queryProperty(handleResult.data, handler);
8613
8444
  }
8445
+ /**
8446
+ * 异步-深度获取对象属性
8447
+ * @param target 待获取的对象
8448
+ * @param handler 获取属性的回调
8449
+ */
8450
+ async asyncQueryProperty(target, handler) {
8451
+ if (target == null) {
8452
+ // @ts-ignore
8453
+ return;
8454
+ }
8455
+ let handleResult = await handler(target);
8456
+ if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
8457
+ return handleResult.data;
8458
+ }
8459
+ return await this.asyncQueryProperty(handleResult.data, handler);
8460
+ }
8614
8461
  /**
8615
8462
  * 创建一个新的Utils实例
8616
8463
  * @param option
@@ -8715,7 +8562,7 @@ var Utils = (function () {
8715
8562
  return setTimeout$1(callback, timeout);
8716
8563
  }
8717
8564
  catch (error) {
8718
- return globalThis.setTimeout(callback, timeout);
8565
+ return this.windowApi.setTimeout(callback, timeout);
8719
8566
  }
8720
8567
  }
8721
8568
  /**
@@ -8731,7 +8578,7 @@ var Utils = (function () {
8731
8578
  catch (error) {
8732
8579
  }
8733
8580
  finally {
8734
- globalThis.clearTimeout(timeId);
8581
+ this.windowApi.clearTimeout(timeId);
8735
8582
  }
8736
8583
  }
8737
8584
  /**
@@ -8744,7 +8591,7 @@ var Utils = (function () {
8744
8591
  return setInterval(callback, timeout);
8745
8592
  }
8746
8593
  catch (error) {
8747
- return globalThis.setInterval(callback, timeout);
8594
+ return this.windowApi.setInterval(callback, timeout);
8748
8595
  }
8749
8596
  }
8750
8597
  /**
@@ -8760,7 +8607,7 @@ var Utils = (function () {
8760
8607
  catch (error) {
8761
8608
  }
8762
8609
  finally {
8763
- globalThis.clearInterval(timeId);
8610
+ this.windowApi.clearInterval(timeId);
8764
8611
  }
8765
8612
  }
8766
8613
  /**