@whitesev/utils 2.7.3 → 2.7.5

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.umd.js CHANGED
@@ -723,13 +723,13 @@
723
723
  // ==UserScript==
724
724
  // @name ajaxHooker
725
725
  // @author cxxjackie
726
- // @version 1.4.7
726
+ // @version 1.4.8
727
727
  // @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
728
728
  // @license GNU LGPL-3.0
729
729
  // ==/UserScript==
730
730
 
731
731
  const ajaxHooker = function () {
732
- const version = "1.4.7";
732
+ const version = "1.4.8";
733
733
  const hookInst = {
734
734
  hookFns: [],
735
735
  filters: [],
@@ -758,11 +758,7 @@
758
758
  const emptyFn = () => {};
759
759
  const errorFn = (e) => console.error(e);
760
760
  function isThenable(obj) {
761
- return (
762
- obj &&
763
- ["object", "function"].includes(typeof obj) &&
764
- typeof obj.then === "function"
765
- );
761
+ return obj && ["object", "function"].includes(typeof obj) && typeof obj.then === "function";
766
762
  }
767
763
  function catchError(fn, ...args) {
768
764
  try {
@@ -800,8 +796,7 @@
800
796
  const [header, value] = line.split(/(?<=^[^:]+)\s*:\s*/);
801
797
  if (!value) continue;
802
798
  const lheader = header.toLowerCase();
803
- headers[lheader] =
804
- lheader in headers ? `${headers[lheader]}, ${value}` : value;
799
+ headers[lheader] = lheader in headers ? `${headers[lheader]}, ${value}` : value;
805
800
  }
806
801
  break;
807
802
  case "[object Headers]":
@@ -839,11 +834,9 @@
839
834
  !filters.find((obj) => {
840
835
  switch (true) {
841
836
  case obj.type && obj.type !== type:
842
- case getType(obj.url) === "[object String]" &&
843
- !url.includes(obj.url):
837
+ case getType(obj.url) === "[object String]" && !url.includes(obj.url):
844
838
  case getType(obj.url) === "[object RegExp]" && !obj.url.test(url):
845
- case obj.method &&
846
- obj.method.toUpperCase() !== method.toUpperCase():
839
+ case obj.method && obj.method.toUpperCase() !== method.toUpperCase():
847
840
  case "async" in obj && obj.async !== async:
848
841
  return false;
849
842
  }
@@ -856,8 +849,7 @@
856
849
  win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
857
850
  if (this.shouldFilter(filters)) return;
858
851
  hookFns.forEach((fn) => {
859
- if (getType(fn) === "[object Function]")
860
- catchError(fn, this.request);
852
+ if (getType(fn) === "[object Function]") catchError(fn, this.request);
861
853
  });
862
854
  for (const key in this.request) {
863
855
  if (isThenable(this.request[key])) this._recoverRequestKey(key);
@@ -870,93 +862,72 @@
870
862
  win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
871
863
  if (this.shouldFilter(filters)) return;
872
864
  promises.push(
873
- Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(
874
- () => {
875
- const requestKeys = [];
876
- for (const key in this.request)
877
- !ignoreKeys.has(key) && requestKeys.push(key);
878
- return Promise.all(
879
- requestKeys.map((key) =>
880
- Promise.resolve(this.request[key]).then(
881
- (val) => (this.request[key] = val),
882
- () => this._recoverRequestKey(key)
883
- )
865
+ Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(() => {
866
+ const requestKeys = [];
867
+ for (const key in this.request) !ignoreKeys.has(key) && requestKeys.push(key);
868
+ return Promise.all(
869
+ requestKeys.map((key) =>
870
+ Promise.resolve(this.request[key]).then(
871
+ (val) => (this.request[key] = val),
872
+ () => this._recoverRequestKey(key)
884
873
  )
885
- );
886
- }
887
- )
874
+ )
875
+ );
876
+ })
888
877
  );
889
878
  });
890
879
  return Promise.all(promises);
891
880
  }
892
881
  waitForResponseKeys(response) {
893
- const responseKeys =
894
- this.request.type === "xhr" ? xhrResponses : fetchResponses;
882
+ const responseKeys = this.request.type === "xhr" ? xhrResponses : fetchResponses;
895
883
  if (!this.request.async) {
896
884
  if (getType(this.request.response) === "[object Function]") {
897
885
  catchError(this.request.response, response);
898
886
  responseKeys.forEach((key) => {
899
- if (
900
- "get" in getDescriptor(response, key) ||
901
- isThenable(response[key])
902
- ) {
887
+ if ("get" in getDescriptor(response, key) || isThenable(response[key])) {
903
888
  delete response[key];
904
889
  }
905
890
  });
906
891
  }
907
892
  return new SyncThenable();
908
893
  }
909
- return Promise.resolve(catchError(this.request.response, response)).then(
910
- () =>
911
- Promise.all(
912
- responseKeys.map((key) => {
913
- const descriptor = getDescriptor(response, key);
914
- if (descriptor && "value" in descriptor) {
915
- return Promise.resolve(descriptor.value).then(
916
- (val) => (response[key] = val),
917
- () => delete response[key]
918
- );
919
- } else {
920
- delete response[key];
921
- }
922
- })
923
- )
894
+ return Promise.resolve(catchError(this.request.response, response)).then(() =>
895
+ Promise.all(
896
+ responseKeys.map((key) => {
897
+ const descriptor = getDescriptor(response, key);
898
+ if (descriptor && "value" in descriptor) {
899
+ return Promise.resolve(descriptor.value).then(
900
+ (val) => (response[key] = val),
901
+ () => delete response[key]
902
+ );
903
+ } else {
904
+ delete response[key];
905
+ }
906
+ })
907
+ )
924
908
  );
925
909
  }
926
910
  }
927
911
  const proxyHandler = {
928
912
  get(target, prop) {
929
913
  const descriptor = getDescriptor(target, prop);
930
- if (
931
- descriptor &&
932
- !descriptor.configurable &&
933
- !descriptor.writable &&
934
- !descriptor.get
935
- )
914
+ if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.get)
936
915
  return target[prop];
937
916
  const ah = target.__ajaxHooker;
938
917
  if (ah && ah.proxyProps) {
939
918
  if (prop in ah.proxyProps) {
940
919
  const pDescriptor = ah.proxyProps[prop];
941
920
  if ("get" in pDescriptor) return pDescriptor.get();
942
- if (typeof pDescriptor.value === "function")
943
- return pDescriptor.value.bind(ah);
921
+ if (typeof pDescriptor.value === "function") return pDescriptor.value.bind(ah);
944
922
  return pDescriptor.value;
945
923
  }
946
- if (typeof target[prop] === "function")
947
- return target[prop].bind(target);
924
+ if (typeof target[prop] === "function") return target[prop].bind(target);
948
925
  }
949
926
  return target[prop];
950
927
  },
951
928
  set(target, prop, value) {
952
929
  const descriptor = getDescriptor(target, prop);
953
- if (
954
- descriptor &&
955
- !descriptor.configurable &&
956
- !descriptor.writable &&
957
- !descriptor.set
958
- )
959
- return true;
930
+ if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.set) return true;
960
931
  const ah = target.__ajaxHooker;
961
932
  if (ah && ah.proxyProps && prop in ah.proxyProps) {
962
933
  const pDescriptor = ah.proxyProps[prop];
@@ -978,11 +949,7 @@
978
949
  proxyEvents: {},
979
950
  });
980
951
  xhr.addEventListener("readystatechange", (e) => {
981
- if (
982
- ah.proxyXhr.readyState === 4 &&
983
- ah.request &&
984
- typeof ah.request.response === "function"
985
- ) {
952
+ if (ah.proxyXhr.readyState === 4 && ah.request && typeof ah.request.response === "function") {
986
953
  const response = {
987
954
  finalUrl: ah.proxyXhr.responseURL,
988
955
  status: ah.proxyXhr.status,
@@ -1005,18 +972,16 @@
1005
972
  }
1006
973
  );
1007
974
  }
1008
- ah.resThenable = new AHRequest(ah.request)
1009
- .waitForResponseKeys(response)
1010
- .then(() => {
1011
- for (const key of xhrResponses) {
1012
- ah.proxyProps[key] = {
1013
- get: () => {
1014
- if (!(key in response)) response[key] = tempValues[key];
1015
- return response[key];
1016
- },
1017
- };
1018
- }
1019
- });
975
+ ah.resThenable = new AHRequest(ah.request).waitForResponseKeys(response).then(() => {
976
+ for (const key of xhrResponses) {
977
+ ah.proxyProps[key] = {
978
+ get: () => {
979
+ if (!(key in response)) response[key] = tempValues[key];
980
+ return response[key];
981
+ },
982
+ };
983
+ }
984
+ });
1020
985
  }
1021
986
  ah.dispatchEvent(e);
1022
987
  });
@@ -1029,13 +994,7 @@
1029
994
  set: (val) => ah.addEvent(onEvt, val),
1030
995
  };
1031
996
  }
1032
- for (const method of [
1033
- "setRequestHeader",
1034
- "addEventListener",
1035
- "removeEventListener",
1036
- "open",
1037
- "send",
1038
- ]) {
997
+ for (const method of ["setRequestHeader", "addEventListener", "removeEventListener", "open", "send"]) {
1039
998
  ah.proxyProps[method] = { value: ah[method] };
1040
999
  }
1041
1000
  }
@@ -1044,8 +1003,7 @@
1044
1003
  if (type.startsWith("on")) {
1045
1004
  this.proxyEvents[type] = typeof event === "function" ? event : null;
1046
1005
  } else {
1047
- if (typeof event === "object" && event !== null)
1048
- event = event.handleEvent;
1006
+ if (typeof event === "object" && event !== null) event = event.handleEvent;
1049
1007
  if (typeof event !== "function") return;
1050
1008
  this.proxyEvents[type] = this.proxyEvents[type] || new Set();
1051
1009
  this.proxyEvents[type].add(event);
@@ -1055,8 +1013,7 @@
1055
1013
  if (type.startsWith("on")) {
1056
1014
  this.proxyEvents[type] = null;
1057
1015
  } else {
1058
- if (typeof event === "object" && event !== null)
1059
- event = event.handleEvent;
1016
+ if (typeof event === "object" && event !== null) event = event.handleEvent;
1060
1017
  this.proxyEvents[type] && this.proxyEvents[type].delete(event);
1061
1018
  }
1062
1019
  }
@@ -1067,9 +1024,7 @@
1067
1024
  defineProp(e, "srcElement", () => this.proxyXhr);
1068
1025
  this.proxyEvents[e.type] &&
1069
1026
  this.proxyEvents[e.type].forEach((fn) => {
1070
- this.resThenable.then(
1071
- () => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e)
1072
- );
1027
+ this.resThenable.then(() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e));
1073
1028
  });
1074
1029
  if (e.ajaxHooker_isStopped) return;
1075
1030
  const onEvent = this.proxyEvents["on" + e.type];
@@ -1079,8 +1034,7 @@
1079
1034
  this.originalXhr.setRequestHeader(header, value);
1080
1035
  if (!this.request) return;
1081
1036
  const headers = this.request.headers;
1082
- headers[header] =
1083
- header in headers ? `${headers[header]}, ${value}` : value;
1037
+ headers[header] = header in headers ? `${headers[header]}, ${value}` : value;
1084
1038
  }
1085
1039
  addEventListener(...args) {
1086
1040
  if (xhrAsyncEvents.includes(args[0])) {
@@ -1109,13 +1063,7 @@
1109
1063
  };
1110
1064
  this.openArgs = args;
1111
1065
  this.resThenable = new SyncThenable();
1112
- [
1113
- "responseURL",
1114
- "readyState",
1115
- "status",
1116
- "statusText",
1117
- ...xhrResponses,
1118
- ].forEach((key) => {
1066
+ ["responseURL", "readyState", "status", "statusText", ...xhrResponses].forEach((key) => {
1119
1067
  delete this.proxyProps[key];
1120
1068
  });
1121
1069
  return this.originalXhr.open(method, url, async, ...args);
@@ -1152,15 +1100,12 @@
1152
1100
  }
1153
1101
  function fakeXHR() {
1154
1102
  const xhr = new winAh.realXHR();
1155
- if ("__ajaxHooker" in xhr)
1156
- console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
1103
+ if ("__ajaxHooker" in xhr) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
1157
1104
  xhr.__ajaxHooker = new XhrHooker(xhr);
1158
1105
  return xhr.__ajaxHooker.proxyXhr;
1159
1106
  }
1160
1107
  fakeXHR.prototype = win.XMLHttpRequest.prototype;
1161
- Object.keys(win.XMLHttpRequest).forEach(
1162
- (key) => (fakeXHR[key] = win.XMLHttpRequest[key])
1163
- );
1108
+ Object.keys(win.XMLHttpRequest).forEach((key) => (fakeXHR[key] = win.XMLHttpRequest[key]));
1164
1109
  function fakeFetch(url, options = {}) {
1165
1110
  if (!url) return winAh.realFetch.call(win, url, options);
1166
1111
  return new Promise(async (resolve, reject) => {
@@ -1226,18 +1171,22 @@
1226
1171
  status: res.status,
1227
1172
  responseHeaders: parseHeaders(res.headers),
1228
1173
  };
1229
- fetchResponses.forEach(
1230
- (key) =>
1231
- (res[key] = function () {
1232
- if (key in response) return Promise.resolve(response[key]);
1233
- return resProto[key].call(this).then((val) => {
1234
- response[key] = val;
1235
- return req
1236
- .waitForResponseKeys(response)
1237
- .then(() => (key in response ? response[key] : val));
1238
- });
1239
- })
1240
- );
1174
+ if (res.ok) {
1175
+ fetchResponses.forEach(
1176
+ (key) =>
1177
+ (res[key] = function () {
1178
+ if (key in response) return Promise.resolve(response[key]);
1179
+ return resProto[key].call(this).then((val) => {
1180
+ response[key] = val;
1181
+ return req
1182
+ .waitForResponseKeys(response)
1183
+ .then(() => (key in response ? response[key] : val));
1184
+ });
1185
+ })
1186
+ );
1187
+ } else {
1188
+ catchError(request.response, response);
1189
+ }
1241
1190
  }
1242
1191
  resolve(res);
1243
1192
  }, reject);
@@ -1259,8 +1208,7 @@
1259
1208
  realFetchClone: resProto.clone,
1260
1209
  hookInsts: new Set(),
1261
1210
  };
1262
- if (winAh.version !== version)
1263
- console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
1211
+ if (winAh.version !== version) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
1264
1212
  win.XMLHttpRequest = winAh.fakeXHR;
1265
1213
  win.fetch = winAh.fakeFetch;
1266
1214
  resProto.clone = winAh.fakeFetchClone;
@@ -1268,37 +1216,25 @@
1268
1216
  // 针对头条、抖音 secsdk.umd.js 的兼容性处理
1269
1217
  class AHFunction extends Function {
1270
1218
  call(thisArg, ...args) {
1271
- if (
1272
- thisArg &&
1273
- thisArg.__ajaxHooker &&
1274
- thisArg.__ajaxHooker.proxyXhr === thisArg
1275
- ) {
1219
+ if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) {
1276
1220
  thisArg = thisArg.__ajaxHooker.originalXhr;
1277
1221
  }
1278
1222
  return Reflect.apply(this, thisArg, args);
1279
1223
  }
1280
1224
  apply(thisArg, args) {
1281
- if (
1282
- thisArg &&
1283
- thisArg.__ajaxHooker &&
1284
- thisArg.__ajaxHooker.proxyXhr === thisArg
1285
- ) {
1225
+ if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) {
1286
1226
  thisArg = thisArg.__ajaxHooker.originalXhr;
1287
1227
  }
1288
1228
  return Reflect.apply(this, thisArg, args || []);
1289
1229
  }
1290
1230
  }
1291
1231
  function hookSecsdk(csrf) {
1292
- Object.setPrototypeOf(
1293
- csrf.nativeXMLHttpRequestSetRequestHeader,
1294
- AHFunction.prototype
1295
- );
1232
+ Object.setPrototypeOf(csrf.nativeXMLHttpRequestSetRequestHeader, AHFunction.prototype);
1296
1233
  Object.setPrototypeOf(csrf.nativeXMLHttpRequestOpen, AHFunction.prototype);
1297
1234
  Object.setPrototypeOf(csrf.nativeXMLHttpRequestSend, AHFunction.prototype);
1298
1235
  }
1299
1236
  if (win.secsdk) {
1300
- if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen)
1301
- hookSecsdk(win.secsdk.csrf);
1237
+ if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen) hookSecsdk(win.secsdk.csrf);
1302
1238
  } else {
1303
1239
  defineProp(win, "secsdk", emptyFn, (secsdk) => {
1304
1240
  delete win.secsdk;
@@ -4435,6 +4371,10 @@
4435
4371
  globalThis: globalThis,
4436
4372
  self: self,
4437
4373
  top: top,
4374
+ setTimeout: globalThis.setTimeout.bind(globalThis),
4375
+ setInterval: globalThis.setInterval.bind(globalThis),
4376
+ clearTimeout: globalThis.clearTimeout.bind(globalThis),
4377
+ clearInterval: globalThis.clearInterval.bind(globalThis),
4438
4378
  };
4439
4379
  /** 使用的配置 */
4440
4380
  api;
@@ -4467,6 +4407,18 @@
4467
4407
  get top() {
4468
4408
  return this.api.top;
4469
4409
  }
4410
+ get setTimeout() {
4411
+ return this.api.setTimeout;
4412
+ }
4413
+ get setInterval() {
4414
+ return this.api.setInterval;
4415
+ }
4416
+ get clearTimeout() {
4417
+ return this.api.clearTimeout;
4418
+ }
4419
+ get clearInterval() {
4420
+ return this.api.clearInterval;
4421
+ }
4470
4422
  }
4471
4423
 
4472
4424
  const VueUtils = {
@@ -4942,7 +4894,7 @@
4942
4894
  };
4943
4895
 
4944
4896
  // This is the minified and stringified code of the worker-timers-worker package.
4945
- const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),l=t(c);e.addUniqueNumber=l,e.generateUniqueNumber=c}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async({data:{id:a,method:i,params:u}})=>{const c=r[i];try{if(void 0===c)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===u?c():c(u);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const l=r instanceof Promise?await r:r;if(null===a){if(void 0!==l.result)throw s(i)}else{if(void 0===l.result)throw s(i);const{result:e,transferables:r=[]}=l;t.postMessage({id:a,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:a})}};var i=r(455);const u=new Map,c=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),o=(0,i.generateUniqueNumber)(u);return u.set(o,(()=>{n(),t.close(),u.delete(o)})),{result:o}},disconnect:({portId:e})=>{const r=u.get(e);if(void 0===r)throw(e=>o('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(e);return r(),{result:null}},isSupported:async()=>{if(await new Promise((e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])}))){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),l=(e,t,r=()=>!0)=>{const n=c(l,t,r),o=a(e,n);return e.addEventListener("message",o),()=>e.removeEventListener("message",o)},d=(e,t)=>r=>{const n=t.get(r);if(void 0===n)return Promise.resolve(!1);const[o,s]=n;return e(o),t.delete(r),s(!1),Promise.resolve(!0)},f=(e,t,r,n)=>(o,s,a)=>{const i=o+s-t.timeOrigin,u=i-t.now();return new Promise((t=>{e.set(a,[r(n,u,i,e,t,a),t])}))},m=new Map,h=d(globalThis.clearTimeout,m),p=new Map,v=d(globalThis.clearTimeout,p),w=((e,t)=>{const r=(n,o,s,a)=>{const i=n-e.now();i>0?o.set(a,[t(r,i,n,o,s,a),s]):(o.delete(a),s(!0))};return r})(performance,globalThis.setTimeout),g=f(m,performance,globalThis.setTimeout,w),T=f(p,performance,globalThis.setTimeout,w);l(self,{clear:async({timerId:e,timerType:t})=>({result:await("interval"===t?h(e):v(e))}),set:async({delay:e,now:t,timerId:r,timerType:n})=>({result:await("interval"===n?g:T)(e,t,r)})})})()})();`; // tslint:disable-line:max-line-length
4897
+ 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
4946
4898
 
4947
4899
  const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
4948
4900
  const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
@@ -5529,7 +5481,7 @@
5529
5481
  this.windowApi = new WindowApi(option);
5530
5482
  }
5531
5483
  /** 版本号 */
5532
- version = "2025.8.11";
5484
+ version = "2025.8.21";
5533
5485
  addStyle(cssText) {
5534
5486
  if (typeof cssText !== "string") {
5535
5487
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");
@@ -8613,7 +8565,7 @@
8613
8565
  return setTimeout$1(callback, timeout);
8614
8566
  }
8615
8567
  catch (error) {
8616
- return globalThis.setTimeout(callback, timeout);
8568
+ return this.windowApi.setTimeout(callback, timeout);
8617
8569
  }
8618
8570
  }
8619
8571
  /**
@@ -8629,7 +8581,7 @@
8629
8581
  catch (error) {
8630
8582
  }
8631
8583
  finally {
8632
- globalThis.clearTimeout(timeId);
8584
+ this.windowApi.clearTimeout(timeId);
8633
8585
  }
8634
8586
  }
8635
8587
  /**
@@ -8642,7 +8594,7 @@
8642
8594
  return setInterval(callback, timeout);
8643
8595
  }
8644
8596
  catch (error) {
8645
- return globalThis.setInterval(callback, timeout);
8597
+ return this.windowApi.setInterval(callback, timeout);
8646
8598
  }
8647
8599
  }
8648
8600
  /**
@@ -8658,7 +8610,7 @@
8658
8610
  catch (error) {
8659
8611
  }
8660
8612
  finally {
8661
- globalThis.clearInterval(timeId);
8613
+ this.windowApi.clearInterval(timeId);
8662
8614
  }
8663
8615
  }
8664
8616
  /**