@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.amd.js +100 -148
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +100 -148
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +100 -148
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +100 -148
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +100 -148
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +100 -148
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/WindowApi.d.ts +4 -0
- package/dist/types/src/types/WindowApi.d.ts +4 -0
- package/package.json +1 -1
- package/src/Utils.ts +5 -5
- package/src/WindowApi.ts +16 -0
- package/src/ajaxHooker/ajaxHooker.js +78 -142
- package/src/types/WindowApi.d.ts +4 -0
package/dist/index.esm.js
CHANGED
|
@@ -717,13 +717,13 @@ class UtilsGMCookie {
|
|
|
717
717
|
// ==UserScript==
|
|
718
718
|
// @name ajaxHooker
|
|
719
719
|
// @author cxxjackie
|
|
720
|
-
// @version 1.4.
|
|
720
|
+
// @version 1.4.8
|
|
721
721
|
// @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
722
722
|
// @license GNU LGPL-3.0
|
|
723
723
|
// ==/UserScript==
|
|
724
724
|
|
|
725
725
|
const ajaxHooker = function () {
|
|
726
|
-
const version = "1.4.
|
|
726
|
+
const version = "1.4.8";
|
|
727
727
|
const hookInst = {
|
|
728
728
|
hookFns: [],
|
|
729
729
|
filters: [],
|
|
@@ -752,11 +752,7 @@ const ajaxHooker = function () {
|
|
|
752
752
|
const emptyFn = () => {};
|
|
753
753
|
const errorFn = (e) => console.error(e);
|
|
754
754
|
function isThenable(obj) {
|
|
755
|
-
return (
|
|
756
|
-
obj &&
|
|
757
|
-
["object", "function"].includes(typeof obj) &&
|
|
758
|
-
typeof obj.then === "function"
|
|
759
|
-
);
|
|
755
|
+
return obj && ["object", "function"].includes(typeof obj) && typeof obj.then === "function";
|
|
760
756
|
}
|
|
761
757
|
function catchError(fn, ...args) {
|
|
762
758
|
try {
|
|
@@ -794,8 +790,7 @@ const ajaxHooker = function () {
|
|
|
794
790
|
const [header, value] = line.split(/(?<=^[^:]+)\s*:\s*/);
|
|
795
791
|
if (!value) continue;
|
|
796
792
|
const lheader = header.toLowerCase();
|
|
797
|
-
headers[lheader] =
|
|
798
|
-
lheader in headers ? `${headers[lheader]}, ${value}` : value;
|
|
793
|
+
headers[lheader] = lheader in headers ? `${headers[lheader]}, ${value}` : value;
|
|
799
794
|
}
|
|
800
795
|
break;
|
|
801
796
|
case "[object Headers]":
|
|
@@ -833,11 +828,9 @@ const ajaxHooker = function () {
|
|
|
833
828
|
!filters.find((obj) => {
|
|
834
829
|
switch (true) {
|
|
835
830
|
case obj.type && obj.type !== type:
|
|
836
|
-
case getType(obj.url) === "[object String]" &&
|
|
837
|
-
!url.includes(obj.url):
|
|
831
|
+
case getType(obj.url) === "[object String]" && !url.includes(obj.url):
|
|
838
832
|
case getType(obj.url) === "[object RegExp]" && !obj.url.test(url):
|
|
839
|
-
case obj.method &&
|
|
840
|
-
obj.method.toUpperCase() !== method.toUpperCase():
|
|
833
|
+
case obj.method && obj.method.toUpperCase() !== method.toUpperCase():
|
|
841
834
|
case "async" in obj && obj.async !== async:
|
|
842
835
|
return false;
|
|
843
836
|
}
|
|
@@ -850,8 +843,7 @@ const ajaxHooker = function () {
|
|
|
850
843
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
851
844
|
if (this.shouldFilter(filters)) return;
|
|
852
845
|
hookFns.forEach((fn) => {
|
|
853
|
-
if (getType(fn) === "[object Function]")
|
|
854
|
-
catchError(fn, this.request);
|
|
846
|
+
if (getType(fn) === "[object Function]") catchError(fn, this.request);
|
|
855
847
|
});
|
|
856
848
|
for (const key in this.request) {
|
|
857
849
|
if (isThenable(this.request[key])) this._recoverRequestKey(key);
|
|
@@ -864,93 +856,72 @@ const ajaxHooker = function () {
|
|
|
864
856
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
865
857
|
if (this.shouldFilter(filters)) return;
|
|
866
858
|
promises.push(
|
|
867
|
-
Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
(val) => (this.request[key] = val),
|
|
876
|
-
() => this._recoverRequestKey(key)
|
|
877
|
-
)
|
|
859
|
+
Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(() => {
|
|
860
|
+
const requestKeys = [];
|
|
861
|
+
for (const key in this.request) !ignoreKeys.has(key) && requestKeys.push(key);
|
|
862
|
+
return Promise.all(
|
|
863
|
+
requestKeys.map((key) =>
|
|
864
|
+
Promise.resolve(this.request[key]).then(
|
|
865
|
+
(val) => (this.request[key] = val),
|
|
866
|
+
() => this._recoverRequestKey(key)
|
|
878
867
|
)
|
|
879
|
-
)
|
|
880
|
-
|
|
881
|
-
)
|
|
868
|
+
)
|
|
869
|
+
);
|
|
870
|
+
})
|
|
882
871
|
);
|
|
883
872
|
});
|
|
884
873
|
return Promise.all(promises);
|
|
885
874
|
}
|
|
886
875
|
waitForResponseKeys(response) {
|
|
887
|
-
const responseKeys =
|
|
888
|
-
this.request.type === "xhr" ? xhrResponses : fetchResponses;
|
|
876
|
+
const responseKeys = this.request.type === "xhr" ? xhrResponses : fetchResponses;
|
|
889
877
|
if (!this.request.async) {
|
|
890
878
|
if (getType(this.request.response) === "[object Function]") {
|
|
891
879
|
catchError(this.request.response, response);
|
|
892
880
|
responseKeys.forEach((key) => {
|
|
893
|
-
if (
|
|
894
|
-
"get" in getDescriptor(response, key) ||
|
|
895
|
-
isThenable(response[key])
|
|
896
|
-
) {
|
|
881
|
+
if ("get" in getDescriptor(response, key) || isThenable(response[key])) {
|
|
897
882
|
delete response[key];
|
|
898
883
|
}
|
|
899
884
|
});
|
|
900
885
|
}
|
|
901
886
|
return new SyncThenable();
|
|
902
887
|
}
|
|
903
|
-
return Promise.resolve(catchError(this.request.response, response)).then(
|
|
904
|
-
(
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
)
|
|
888
|
+
return Promise.resolve(catchError(this.request.response, response)).then(() =>
|
|
889
|
+
Promise.all(
|
|
890
|
+
responseKeys.map((key) => {
|
|
891
|
+
const descriptor = getDescriptor(response, key);
|
|
892
|
+
if (descriptor && "value" in descriptor) {
|
|
893
|
+
return Promise.resolve(descriptor.value).then(
|
|
894
|
+
(val) => (response[key] = val),
|
|
895
|
+
() => delete response[key]
|
|
896
|
+
);
|
|
897
|
+
} else {
|
|
898
|
+
delete response[key];
|
|
899
|
+
}
|
|
900
|
+
})
|
|
901
|
+
)
|
|
918
902
|
);
|
|
919
903
|
}
|
|
920
904
|
}
|
|
921
905
|
const proxyHandler = {
|
|
922
906
|
get(target, prop) {
|
|
923
907
|
const descriptor = getDescriptor(target, prop);
|
|
924
|
-
if (
|
|
925
|
-
descriptor &&
|
|
926
|
-
!descriptor.configurable &&
|
|
927
|
-
!descriptor.writable &&
|
|
928
|
-
!descriptor.get
|
|
929
|
-
)
|
|
908
|
+
if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.get)
|
|
930
909
|
return target[prop];
|
|
931
910
|
const ah = target.__ajaxHooker;
|
|
932
911
|
if (ah && ah.proxyProps) {
|
|
933
912
|
if (prop in ah.proxyProps) {
|
|
934
913
|
const pDescriptor = ah.proxyProps[prop];
|
|
935
914
|
if ("get" in pDescriptor) return pDescriptor.get();
|
|
936
|
-
if (typeof pDescriptor.value === "function")
|
|
937
|
-
return pDescriptor.value.bind(ah);
|
|
915
|
+
if (typeof pDescriptor.value === "function") return pDescriptor.value.bind(ah);
|
|
938
916
|
return pDescriptor.value;
|
|
939
917
|
}
|
|
940
|
-
if (typeof target[prop] === "function")
|
|
941
|
-
return target[prop].bind(target);
|
|
918
|
+
if (typeof target[prop] === "function") return target[prop].bind(target);
|
|
942
919
|
}
|
|
943
920
|
return target[prop];
|
|
944
921
|
},
|
|
945
922
|
set(target, prop, value) {
|
|
946
923
|
const descriptor = getDescriptor(target, prop);
|
|
947
|
-
if (
|
|
948
|
-
descriptor &&
|
|
949
|
-
!descriptor.configurable &&
|
|
950
|
-
!descriptor.writable &&
|
|
951
|
-
!descriptor.set
|
|
952
|
-
)
|
|
953
|
-
return true;
|
|
924
|
+
if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.set) return true;
|
|
954
925
|
const ah = target.__ajaxHooker;
|
|
955
926
|
if (ah && ah.proxyProps && prop in ah.proxyProps) {
|
|
956
927
|
const pDescriptor = ah.proxyProps[prop];
|
|
@@ -972,11 +943,7 @@ const ajaxHooker = function () {
|
|
|
972
943
|
proxyEvents: {},
|
|
973
944
|
});
|
|
974
945
|
xhr.addEventListener("readystatechange", (e) => {
|
|
975
|
-
if (
|
|
976
|
-
ah.proxyXhr.readyState === 4 &&
|
|
977
|
-
ah.request &&
|
|
978
|
-
typeof ah.request.response === "function"
|
|
979
|
-
) {
|
|
946
|
+
if (ah.proxyXhr.readyState === 4 && ah.request && typeof ah.request.response === "function") {
|
|
980
947
|
const response = {
|
|
981
948
|
finalUrl: ah.proxyXhr.responseURL,
|
|
982
949
|
status: ah.proxyXhr.status,
|
|
@@ -999,18 +966,16 @@ const ajaxHooker = function () {
|
|
|
999
966
|
}
|
|
1000
967
|
);
|
|
1001
968
|
}
|
|
1002
|
-
ah.resThenable = new AHRequest(ah.request)
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
}
|
|
1013
|
-
});
|
|
969
|
+
ah.resThenable = new AHRequest(ah.request).waitForResponseKeys(response).then(() => {
|
|
970
|
+
for (const key of xhrResponses) {
|
|
971
|
+
ah.proxyProps[key] = {
|
|
972
|
+
get: () => {
|
|
973
|
+
if (!(key in response)) response[key] = tempValues[key];
|
|
974
|
+
return response[key];
|
|
975
|
+
},
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
});
|
|
1014
979
|
}
|
|
1015
980
|
ah.dispatchEvent(e);
|
|
1016
981
|
});
|
|
@@ -1023,13 +988,7 @@ const ajaxHooker = function () {
|
|
|
1023
988
|
set: (val) => ah.addEvent(onEvt, val),
|
|
1024
989
|
};
|
|
1025
990
|
}
|
|
1026
|
-
for (const method of [
|
|
1027
|
-
"setRequestHeader",
|
|
1028
|
-
"addEventListener",
|
|
1029
|
-
"removeEventListener",
|
|
1030
|
-
"open",
|
|
1031
|
-
"send",
|
|
1032
|
-
]) {
|
|
991
|
+
for (const method of ["setRequestHeader", "addEventListener", "removeEventListener", "open", "send"]) {
|
|
1033
992
|
ah.proxyProps[method] = { value: ah[method] };
|
|
1034
993
|
}
|
|
1035
994
|
}
|
|
@@ -1038,8 +997,7 @@ const ajaxHooker = function () {
|
|
|
1038
997
|
if (type.startsWith("on")) {
|
|
1039
998
|
this.proxyEvents[type] = typeof event === "function" ? event : null;
|
|
1040
999
|
} else {
|
|
1041
|
-
if (typeof event === "object" && event !== null)
|
|
1042
|
-
event = event.handleEvent;
|
|
1000
|
+
if (typeof event === "object" && event !== null) event = event.handleEvent;
|
|
1043
1001
|
if (typeof event !== "function") return;
|
|
1044
1002
|
this.proxyEvents[type] = this.proxyEvents[type] || new Set();
|
|
1045
1003
|
this.proxyEvents[type].add(event);
|
|
@@ -1049,8 +1007,7 @@ const ajaxHooker = function () {
|
|
|
1049
1007
|
if (type.startsWith("on")) {
|
|
1050
1008
|
this.proxyEvents[type] = null;
|
|
1051
1009
|
} else {
|
|
1052
|
-
if (typeof event === "object" && event !== null)
|
|
1053
|
-
event = event.handleEvent;
|
|
1010
|
+
if (typeof event === "object" && event !== null) event = event.handleEvent;
|
|
1054
1011
|
this.proxyEvents[type] && this.proxyEvents[type].delete(event);
|
|
1055
1012
|
}
|
|
1056
1013
|
}
|
|
@@ -1061,9 +1018,7 @@ const ajaxHooker = function () {
|
|
|
1061
1018
|
defineProp(e, "srcElement", () => this.proxyXhr);
|
|
1062
1019
|
this.proxyEvents[e.type] &&
|
|
1063
1020
|
this.proxyEvents[e.type].forEach((fn) => {
|
|
1064
|
-
this.resThenable.then(
|
|
1065
|
-
() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e)
|
|
1066
|
-
);
|
|
1021
|
+
this.resThenable.then(() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e));
|
|
1067
1022
|
});
|
|
1068
1023
|
if (e.ajaxHooker_isStopped) return;
|
|
1069
1024
|
const onEvent = this.proxyEvents["on" + e.type];
|
|
@@ -1073,8 +1028,7 @@ const ajaxHooker = function () {
|
|
|
1073
1028
|
this.originalXhr.setRequestHeader(header, value);
|
|
1074
1029
|
if (!this.request) return;
|
|
1075
1030
|
const headers = this.request.headers;
|
|
1076
|
-
headers[header] =
|
|
1077
|
-
header in headers ? `${headers[header]}, ${value}` : value;
|
|
1031
|
+
headers[header] = header in headers ? `${headers[header]}, ${value}` : value;
|
|
1078
1032
|
}
|
|
1079
1033
|
addEventListener(...args) {
|
|
1080
1034
|
if (xhrAsyncEvents.includes(args[0])) {
|
|
@@ -1103,13 +1057,7 @@ const ajaxHooker = function () {
|
|
|
1103
1057
|
};
|
|
1104
1058
|
this.openArgs = args;
|
|
1105
1059
|
this.resThenable = new SyncThenable();
|
|
1106
|
-
[
|
|
1107
|
-
"responseURL",
|
|
1108
|
-
"readyState",
|
|
1109
|
-
"status",
|
|
1110
|
-
"statusText",
|
|
1111
|
-
...xhrResponses,
|
|
1112
|
-
].forEach((key) => {
|
|
1060
|
+
["responseURL", "readyState", "status", "statusText", ...xhrResponses].forEach((key) => {
|
|
1113
1061
|
delete this.proxyProps[key];
|
|
1114
1062
|
});
|
|
1115
1063
|
return this.originalXhr.open(method, url, async, ...args);
|
|
@@ -1146,15 +1094,12 @@ const ajaxHooker = function () {
|
|
|
1146
1094
|
}
|
|
1147
1095
|
function fakeXHR() {
|
|
1148
1096
|
const xhr = new winAh.realXHR();
|
|
1149
|
-
if ("__ajaxHooker" in xhr)
|
|
1150
|
-
console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1097
|
+
if ("__ajaxHooker" in xhr) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1151
1098
|
xhr.__ajaxHooker = new XhrHooker(xhr);
|
|
1152
1099
|
return xhr.__ajaxHooker.proxyXhr;
|
|
1153
1100
|
}
|
|
1154
1101
|
fakeXHR.prototype = win.XMLHttpRequest.prototype;
|
|
1155
|
-
Object.keys(win.XMLHttpRequest).forEach(
|
|
1156
|
-
(key) => (fakeXHR[key] = win.XMLHttpRequest[key])
|
|
1157
|
-
);
|
|
1102
|
+
Object.keys(win.XMLHttpRequest).forEach((key) => (fakeXHR[key] = win.XMLHttpRequest[key]));
|
|
1158
1103
|
function fakeFetch(url, options = {}) {
|
|
1159
1104
|
if (!url) return winAh.realFetch.call(win, url, options);
|
|
1160
1105
|
return new Promise(async (resolve, reject) => {
|
|
@@ -1220,18 +1165,22 @@ const ajaxHooker = function () {
|
|
|
1220
1165
|
status: res.status,
|
|
1221
1166
|
responseHeaders: parseHeaders(res.headers),
|
|
1222
1167
|
};
|
|
1223
|
-
|
|
1224
|
-
(
|
|
1225
|
-
(
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1168
|
+
if (res.ok) {
|
|
1169
|
+
fetchResponses.forEach(
|
|
1170
|
+
(key) =>
|
|
1171
|
+
(res[key] = function () {
|
|
1172
|
+
if (key in response) return Promise.resolve(response[key]);
|
|
1173
|
+
return resProto[key].call(this).then((val) => {
|
|
1174
|
+
response[key] = val;
|
|
1175
|
+
return req
|
|
1176
|
+
.waitForResponseKeys(response)
|
|
1177
|
+
.then(() => (key in response ? response[key] : val));
|
|
1178
|
+
});
|
|
1179
|
+
})
|
|
1180
|
+
);
|
|
1181
|
+
} else {
|
|
1182
|
+
catchError(request.response, response);
|
|
1183
|
+
}
|
|
1235
1184
|
}
|
|
1236
1185
|
resolve(res);
|
|
1237
1186
|
}, reject);
|
|
@@ -1253,8 +1202,7 @@ const ajaxHooker = function () {
|
|
|
1253
1202
|
realFetchClone: resProto.clone,
|
|
1254
1203
|
hookInsts: new Set(),
|
|
1255
1204
|
};
|
|
1256
|
-
if (winAh.version !== version)
|
|
1257
|
-
console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1205
|
+
if (winAh.version !== version) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1258
1206
|
win.XMLHttpRequest = winAh.fakeXHR;
|
|
1259
1207
|
win.fetch = winAh.fakeFetch;
|
|
1260
1208
|
resProto.clone = winAh.fakeFetchClone;
|
|
@@ -1262,37 +1210,25 @@ const ajaxHooker = function () {
|
|
|
1262
1210
|
// 针对头条、抖音 secsdk.umd.js 的兼容性处理
|
|
1263
1211
|
class AHFunction extends Function {
|
|
1264
1212
|
call(thisArg, ...args) {
|
|
1265
|
-
if (
|
|
1266
|
-
thisArg &&
|
|
1267
|
-
thisArg.__ajaxHooker &&
|
|
1268
|
-
thisArg.__ajaxHooker.proxyXhr === thisArg
|
|
1269
|
-
) {
|
|
1213
|
+
if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) {
|
|
1270
1214
|
thisArg = thisArg.__ajaxHooker.originalXhr;
|
|
1271
1215
|
}
|
|
1272
1216
|
return Reflect.apply(this, thisArg, args);
|
|
1273
1217
|
}
|
|
1274
1218
|
apply(thisArg, args) {
|
|
1275
|
-
if (
|
|
1276
|
-
thisArg &&
|
|
1277
|
-
thisArg.__ajaxHooker &&
|
|
1278
|
-
thisArg.__ajaxHooker.proxyXhr === thisArg
|
|
1279
|
-
) {
|
|
1219
|
+
if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) {
|
|
1280
1220
|
thisArg = thisArg.__ajaxHooker.originalXhr;
|
|
1281
1221
|
}
|
|
1282
1222
|
return Reflect.apply(this, thisArg, args || []);
|
|
1283
1223
|
}
|
|
1284
1224
|
}
|
|
1285
1225
|
function hookSecsdk(csrf) {
|
|
1286
|
-
Object.setPrototypeOf(
|
|
1287
|
-
csrf.nativeXMLHttpRequestSetRequestHeader,
|
|
1288
|
-
AHFunction.prototype
|
|
1289
|
-
);
|
|
1226
|
+
Object.setPrototypeOf(csrf.nativeXMLHttpRequestSetRequestHeader, AHFunction.prototype);
|
|
1290
1227
|
Object.setPrototypeOf(csrf.nativeXMLHttpRequestOpen, AHFunction.prototype);
|
|
1291
1228
|
Object.setPrototypeOf(csrf.nativeXMLHttpRequestSend, AHFunction.prototype);
|
|
1292
1229
|
}
|
|
1293
1230
|
if (win.secsdk) {
|
|
1294
|
-
if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen)
|
|
1295
|
-
hookSecsdk(win.secsdk.csrf);
|
|
1231
|
+
if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen) hookSecsdk(win.secsdk.csrf);
|
|
1296
1232
|
} else {
|
|
1297
1233
|
defineProp(win, "secsdk", emptyFn, (secsdk) => {
|
|
1298
1234
|
delete win.secsdk;
|
|
@@ -4429,6 +4365,10 @@ class WindowApi {
|
|
|
4429
4365
|
globalThis: globalThis,
|
|
4430
4366
|
self: self,
|
|
4431
4367
|
top: top,
|
|
4368
|
+
setTimeout: globalThis.setTimeout.bind(globalThis),
|
|
4369
|
+
setInterval: globalThis.setInterval.bind(globalThis),
|
|
4370
|
+
clearTimeout: globalThis.clearTimeout.bind(globalThis),
|
|
4371
|
+
clearInterval: globalThis.clearInterval.bind(globalThis),
|
|
4432
4372
|
};
|
|
4433
4373
|
/** 使用的配置 */
|
|
4434
4374
|
api;
|
|
@@ -4461,6 +4401,18 @@ class WindowApi {
|
|
|
4461
4401
|
get top() {
|
|
4462
4402
|
return this.api.top;
|
|
4463
4403
|
}
|
|
4404
|
+
get setTimeout() {
|
|
4405
|
+
return this.api.setTimeout;
|
|
4406
|
+
}
|
|
4407
|
+
get setInterval() {
|
|
4408
|
+
return this.api.setInterval;
|
|
4409
|
+
}
|
|
4410
|
+
get clearTimeout() {
|
|
4411
|
+
return this.api.clearTimeout;
|
|
4412
|
+
}
|
|
4413
|
+
get clearInterval() {
|
|
4414
|
+
return this.api.clearInterval;
|
|
4415
|
+
}
|
|
4464
4416
|
}
|
|
4465
4417
|
|
|
4466
4418
|
const VueUtils = {
|
|
@@ -4936,7 +4888,7 @@ const createLoadOrReturnBroker = (loadBroker, worker) => {
|
|
|
4936
4888
|
};
|
|
4937
4889
|
|
|
4938
4890
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
4939
|
-
const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),l=t(c);e.addUniqueNumber=l,e.generateUniqueNumber=c}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async({data:{id:a,method:i,params:u}})=>{const c=r[i];try{if(void 0===c)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===u?c():c(u);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const l=r instanceof Promise?await r:r;if(null===a){if(void 0!==l.result)throw s(i)}else{if(void 0===l.result)throw s(i);const{result:e,transferables:r=[]}=l;t.postMessage({id:a,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:a})}};var i=r(455);const u=new Map,c=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),o=(0,i.generateUniqueNumber)(u);return u.set(o,(
|
|
4891
|
+
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
|
|
4940
4892
|
|
|
4941
4893
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
4942
4894
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -5523,7 +5475,7 @@ class Utils {
|
|
|
5523
5475
|
this.windowApi = new WindowApi(option);
|
|
5524
5476
|
}
|
|
5525
5477
|
/** 版本号 */
|
|
5526
|
-
version = "2025.8.
|
|
5478
|
+
version = "2025.8.21";
|
|
5527
5479
|
addStyle(cssText) {
|
|
5528
5480
|
if (typeof cssText !== "string") {
|
|
5529
5481
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -8607,7 +8559,7 @@ class Utils {
|
|
|
8607
8559
|
return setTimeout$1(callback, timeout);
|
|
8608
8560
|
}
|
|
8609
8561
|
catch (error) {
|
|
8610
|
-
return
|
|
8562
|
+
return this.windowApi.setTimeout(callback, timeout);
|
|
8611
8563
|
}
|
|
8612
8564
|
}
|
|
8613
8565
|
/**
|
|
@@ -8623,7 +8575,7 @@ class Utils {
|
|
|
8623
8575
|
catch (error) {
|
|
8624
8576
|
}
|
|
8625
8577
|
finally {
|
|
8626
|
-
|
|
8578
|
+
this.windowApi.clearTimeout(timeId);
|
|
8627
8579
|
}
|
|
8628
8580
|
}
|
|
8629
8581
|
/**
|
|
@@ -8636,7 +8588,7 @@ class Utils {
|
|
|
8636
8588
|
return setInterval(callback, timeout);
|
|
8637
8589
|
}
|
|
8638
8590
|
catch (error) {
|
|
8639
|
-
return
|
|
8591
|
+
return this.windowApi.setInterval(callback, timeout);
|
|
8640
8592
|
}
|
|
8641
8593
|
}
|
|
8642
8594
|
/**
|
|
@@ -8652,7 +8604,7 @@ class Utils {
|
|
|
8652
8604
|
catch (error) {
|
|
8653
8605
|
}
|
|
8654
8606
|
finally {
|
|
8655
|
-
|
|
8607
|
+
this.windowApi.clearInterval(timeId);
|
|
8656
8608
|
}
|
|
8657
8609
|
}
|
|
8658
8610
|
/**
|