@whitesev/utils 2.7.3 → 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.
- 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.amd.js
CHANGED
|
@@ -719,13 +719,13 @@ define((function () { 'use strict';
|
|
|
719
719
|
// ==UserScript==
|
|
720
720
|
// @name ajaxHooker
|
|
721
721
|
// @author cxxjackie
|
|
722
|
-
// @version 1.4.
|
|
722
|
+
// @version 1.4.8
|
|
723
723
|
// @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
724
724
|
// @license GNU LGPL-3.0
|
|
725
725
|
// ==/UserScript==
|
|
726
726
|
|
|
727
727
|
const ajaxHooker = function () {
|
|
728
|
-
const version = "1.4.
|
|
728
|
+
const version = "1.4.8";
|
|
729
729
|
const hookInst = {
|
|
730
730
|
hookFns: [],
|
|
731
731
|
filters: [],
|
|
@@ -754,11 +754,7 @@ define((function () { 'use strict';
|
|
|
754
754
|
const emptyFn = () => {};
|
|
755
755
|
const errorFn = (e) => console.error(e);
|
|
756
756
|
function isThenable(obj) {
|
|
757
|
-
return (
|
|
758
|
-
obj &&
|
|
759
|
-
["object", "function"].includes(typeof obj) &&
|
|
760
|
-
typeof obj.then === "function"
|
|
761
|
-
);
|
|
757
|
+
return obj && ["object", "function"].includes(typeof obj) && typeof obj.then === "function";
|
|
762
758
|
}
|
|
763
759
|
function catchError(fn, ...args) {
|
|
764
760
|
try {
|
|
@@ -796,8 +792,7 @@ define((function () { 'use strict';
|
|
|
796
792
|
const [header, value] = line.split(/(?<=^[^:]+)\s*:\s*/);
|
|
797
793
|
if (!value) continue;
|
|
798
794
|
const lheader = header.toLowerCase();
|
|
799
|
-
headers[lheader] =
|
|
800
|
-
lheader in headers ? `${headers[lheader]}, ${value}` : value;
|
|
795
|
+
headers[lheader] = lheader in headers ? `${headers[lheader]}, ${value}` : value;
|
|
801
796
|
}
|
|
802
797
|
break;
|
|
803
798
|
case "[object Headers]":
|
|
@@ -835,11 +830,9 @@ define((function () { 'use strict';
|
|
|
835
830
|
!filters.find((obj) => {
|
|
836
831
|
switch (true) {
|
|
837
832
|
case obj.type && obj.type !== type:
|
|
838
|
-
case getType(obj.url) === "[object String]" &&
|
|
839
|
-
!url.includes(obj.url):
|
|
833
|
+
case getType(obj.url) === "[object String]" && !url.includes(obj.url):
|
|
840
834
|
case getType(obj.url) === "[object RegExp]" && !obj.url.test(url):
|
|
841
|
-
case obj.method &&
|
|
842
|
-
obj.method.toUpperCase() !== method.toUpperCase():
|
|
835
|
+
case obj.method && obj.method.toUpperCase() !== method.toUpperCase():
|
|
843
836
|
case "async" in obj && obj.async !== async:
|
|
844
837
|
return false;
|
|
845
838
|
}
|
|
@@ -852,8 +845,7 @@ define((function () { 'use strict';
|
|
|
852
845
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
853
846
|
if (this.shouldFilter(filters)) return;
|
|
854
847
|
hookFns.forEach((fn) => {
|
|
855
|
-
if (getType(fn) === "[object Function]")
|
|
856
|
-
catchError(fn, this.request);
|
|
848
|
+
if (getType(fn) === "[object Function]") catchError(fn, this.request);
|
|
857
849
|
});
|
|
858
850
|
for (const key in this.request) {
|
|
859
851
|
if (isThenable(this.request[key])) this._recoverRequestKey(key);
|
|
@@ -866,93 +858,72 @@ define((function () { 'use strict';
|
|
|
866
858
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
867
859
|
if (this.shouldFilter(filters)) return;
|
|
868
860
|
promises.push(
|
|
869
|
-
Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
(val) => (this.request[key] = val),
|
|
878
|
-
() => this._recoverRequestKey(key)
|
|
879
|
-
)
|
|
861
|
+
Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(() => {
|
|
862
|
+
const requestKeys = [];
|
|
863
|
+
for (const key in this.request) !ignoreKeys.has(key) && requestKeys.push(key);
|
|
864
|
+
return Promise.all(
|
|
865
|
+
requestKeys.map((key) =>
|
|
866
|
+
Promise.resolve(this.request[key]).then(
|
|
867
|
+
(val) => (this.request[key] = val),
|
|
868
|
+
() => this._recoverRequestKey(key)
|
|
880
869
|
)
|
|
881
|
-
)
|
|
882
|
-
|
|
883
|
-
)
|
|
870
|
+
)
|
|
871
|
+
);
|
|
872
|
+
})
|
|
884
873
|
);
|
|
885
874
|
});
|
|
886
875
|
return Promise.all(promises);
|
|
887
876
|
}
|
|
888
877
|
waitForResponseKeys(response) {
|
|
889
|
-
const responseKeys =
|
|
890
|
-
this.request.type === "xhr" ? xhrResponses : fetchResponses;
|
|
878
|
+
const responseKeys = this.request.type === "xhr" ? xhrResponses : fetchResponses;
|
|
891
879
|
if (!this.request.async) {
|
|
892
880
|
if (getType(this.request.response) === "[object Function]") {
|
|
893
881
|
catchError(this.request.response, response);
|
|
894
882
|
responseKeys.forEach((key) => {
|
|
895
|
-
if (
|
|
896
|
-
"get" in getDescriptor(response, key) ||
|
|
897
|
-
isThenable(response[key])
|
|
898
|
-
) {
|
|
883
|
+
if ("get" in getDescriptor(response, key) || isThenable(response[key])) {
|
|
899
884
|
delete response[key];
|
|
900
885
|
}
|
|
901
886
|
});
|
|
902
887
|
}
|
|
903
888
|
return new SyncThenable();
|
|
904
889
|
}
|
|
905
|
-
return Promise.resolve(catchError(this.request.response, response)).then(
|
|
906
|
-
(
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
)
|
|
890
|
+
return Promise.resolve(catchError(this.request.response, response)).then(() =>
|
|
891
|
+
Promise.all(
|
|
892
|
+
responseKeys.map((key) => {
|
|
893
|
+
const descriptor = getDescriptor(response, key);
|
|
894
|
+
if (descriptor && "value" in descriptor) {
|
|
895
|
+
return Promise.resolve(descriptor.value).then(
|
|
896
|
+
(val) => (response[key] = val),
|
|
897
|
+
() => delete response[key]
|
|
898
|
+
);
|
|
899
|
+
} else {
|
|
900
|
+
delete response[key];
|
|
901
|
+
}
|
|
902
|
+
})
|
|
903
|
+
)
|
|
920
904
|
);
|
|
921
905
|
}
|
|
922
906
|
}
|
|
923
907
|
const proxyHandler = {
|
|
924
908
|
get(target, prop) {
|
|
925
909
|
const descriptor = getDescriptor(target, prop);
|
|
926
|
-
if (
|
|
927
|
-
descriptor &&
|
|
928
|
-
!descriptor.configurable &&
|
|
929
|
-
!descriptor.writable &&
|
|
930
|
-
!descriptor.get
|
|
931
|
-
)
|
|
910
|
+
if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.get)
|
|
932
911
|
return target[prop];
|
|
933
912
|
const ah = target.__ajaxHooker;
|
|
934
913
|
if (ah && ah.proxyProps) {
|
|
935
914
|
if (prop in ah.proxyProps) {
|
|
936
915
|
const pDescriptor = ah.proxyProps[prop];
|
|
937
916
|
if ("get" in pDescriptor) return pDescriptor.get();
|
|
938
|
-
if (typeof pDescriptor.value === "function")
|
|
939
|
-
return pDescriptor.value.bind(ah);
|
|
917
|
+
if (typeof pDescriptor.value === "function") return pDescriptor.value.bind(ah);
|
|
940
918
|
return pDescriptor.value;
|
|
941
919
|
}
|
|
942
|
-
if (typeof target[prop] === "function")
|
|
943
|
-
return target[prop].bind(target);
|
|
920
|
+
if (typeof target[prop] === "function") return target[prop].bind(target);
|
|
944
921
|
}
|
|
945
922
|
return target[prop];
|
|
946
923
|
},
|
|
947
924
|
set(target, prop, value) {
|
|
948
925
|
const descriptor = getDescriptor(target, prop);
|
|
949
|
-
if (
|
|
950
|
-
descriptor &&
|
|
951
|
-
!descriptor.configurable &&
|
|
952
|
-
!descriptor.writable &&
|
|
953
|
-
!descriptor.set
|
|
954
|
-
)
|
|
955
|
-
return true;
|
|
926
|
+
if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.set) return true;
|
|
956
927
|
const ah = target.__ajaxHooker;
|
|
957
928
|
if (ah && ah.proxyProps && prop in ah.proxyProps) {
|
|
958
929
|
const pDescriptor = ah.proxyProps[prop];
|
|
@@ -974,11 +945,7 @@ define((function () { 'use strict';
|
|
|
974
945
|
proxyEvents: {},
|
|
975
946
|
});
|
|
976
947
|
xhr.addEventListener("readystatechange", (e) => {
|
|
977
|
-
if (
|
|
978
|
-
ah.proxyXhr.readyState === 4 &&
|
|
979
|
-
ah.request &&
|
|
980
|
-
typeof ah.request.response === "function"
|
|
981
|
-
) {
|
|
948
|
+
if (ah.proxyXhr.readyState === 4 && ah.request && typeof ah.request.response === "function") {
|
|
982
949
|
const response = {
|
|
983
950
|
finalUrl: ah.proxyXhr.responseURL,
|
|
984
951
|
status: ah.proxyXhr.status,
|
|
@@ -1001,18 +968,16 @@ define((function () { 'use strict';
|
|
|
1001
968
|
}
|
|
1002
969
|
);
|
|
1003
970
|
}
|
|
1004
|
-
ah.resThenable = new AHRequest(ah.request)
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
}
|
|
1015
|
-
});
|
|
971
|
+
ah.resThenable = new AHRequest(ah.request).waitForResponseKeys(response).then(() => {
|
|
972
|
+
for (const key of xhrResponses) {
|
|
973
|
+
ah.proxyProps[key] = {
|
|
974
|
+
get: () => {
|
|
975
|
+
if (!(key in response)) response[key] = tempValues[key];
|
|
976
|
+
return response[key];
|
|
977
|
+
},
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
});
|
|
1016
981
|
}
|
|
1017
982
|
ah.dispatchEvent(e);
|
|
1018
983
|
});
|
|
@@ -1025,13 +990,7 @@ define((function () { 'use strict';
|
|
|
1025
990
|
set: (val) => ah.addEvent(onEvt, val),
|
|
1026
991
|
};
|
|
1027
992
|
}
|
|
1028
|
-
for (const method of [
|
|
1029
|
-
"setRequestHeader",
|
|
1030
|
-
"addEventListener",
|
|
1031
|
-
"removeEventListener",
|
|
1032
|
-
"open",
|
|
1033
|
-
"send",
|
|
1034
|
-
]) {
|
|
993
|
+
for (const method of ["setRequestHeader", "addEventListener", "removeEventListener", "open", "send"]) {
|
|
1035
994
|
ah.proxyProps[method] = { value: ah[method] };
|
|
1036
995
|
}
|
|
1037
996
|
}
|
|
@@ -1040,8 +999,7 @@ define((function () { 'use strict';
|
|
|
1040
999
|
if (type.startsWith("on")) {
|
|
1041
1000
|
this.proxyEvents[type] = typeof event === "function" ? event : null;
|
|
1042
1001
|
} else {
|
|
1043
|
-
if (typeof event === "object" && event !== null)
|
|
1044
|
-
event = event.handleEvent;
|
|
1002
|
+
if (typeof event === "object" && event !== null) event = event.handleEvent;
|
|
1045
1003
|
if (typeof event !== "function") return;
|
|
1046
1004
|
this.proxyEvents[type] = this.proxyEvents[type] || new Set();
|
|
1047
1005
|
this.proxyEvents[type].add(event);
|
|
@@ -1051,8 +1009,7 @@ define((function () { 'use strict';
|
|
|
1051
1009
|
if (type.startsWith("on")) {
|
|
1052
1010
|
this.proxyEvents[type] = null;
|
|
1053
1011
|
} else {
|
|
1054
|
-
if (typeof event === "object" && event !== null)
|
|
1055
|
-
event = event.handleEvent;
|
|
1012
|
+
if (typeof event === "object" && event !== null) event = event.handleEvent;
|
|
1056
1013
|
this.proxyEvents[type] && this.proxyEvents[type].delete(event);
|
|
1057
1014
|
}
|
|
1058
1015
|
}
|
|
@@ -1063,9 +1020,7 @@ define((function () { 'use strict';
|
|
|
1063
1020
|
defineProp(e, "srcElement", () => this.proxyXhr);
|
|
1064
1021
|
this.proxyEvents[e.type] &&
|
|
1065
1022
|
this.proxyEvents[e.type].forEach((fn) => {
|
|
1066
|
-
this.resThenable.then(
|
|
1067
|
-
() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e)
|
|
1068
|
-
);
|
|
1023
|
+
this.resThenable.then(() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e));
|
|
1069
1024
|
});
|
|
1070
1025
|
if (e.ajaxHooker_isStopped) return;
|
|
1071
1026
|
const onEvent = this.proxyEvents["on" + e.type];
|
|
@@ -1075,8 +1030,7 @@ define((function () { 'use strict';
|
|
|
1075
1030
|
this.originalXhr.setRequestHeader(header, value);
|
|
1076
1031
|
if (!this.request) return;
|
|
1077
1032
|
const headers = this.request.headers;
|
|
1078
|
-
headers[header] =
|
|
1079
|
-
header in headers ? `${headers[header]}, ${value}` : value;
|
|
1033
|
+
headers[header] = header in headers ? `${headers[header]}, ${value}` : value;
|
|
1080
1034
|
}
|
|
1081
1035
|
addEventListener(...args) {
|
|
1082
1036
|
if (xhrAsyncEvents.includes(args[0])) {
|
|
@@ -1105,13 +1059,7 @@ define((function () { 'use strict';
|
|
|
1105
1059
|
};
|
|
1106
1060
|
this.openArgs = args;
|
|
1107
1061
|
this.resThenable = new SyncThenable();
|
|
1108
|
-
[
|
|
1109
|
-
"responseURL",
|
|
1110
|
-
"readyState",
|
|
1111
|
-
"status",
|
|
1112
|
-
"statusText",
|
|
1113
|
-
...xhrResponses,
|
|
1114
|
-
].forEach((key) => {
|
|
1062
|
+
["responseURL", "readyState", "status", "statusText", ...xhrResponses].forEach((key) => {
|
|
1115
1063
|
delete this.proxyProps[key];
|
|
1116
1064
|
});
|
|
1117
1065
|
return this.originalXhr.open(method, url, async, ...args);
|
|
@@ -1148,15 +1096,12 @@ define((function () { 'use strict';
|
|
|
1148
1096
|
}
|
|
1149
1097
|
function fakeXHR() {
|
|
1150
1098
|
const xhr = new winAh.realXHR();
|
|
1151
|
-
if ("__ajaxHooker" in xhr)
|
|
1152
|
-
console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1099
|
+
if ("__ajaxHooker" in xhr) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1153
1100
|
xhr.__ajaxHooker = new XhrHooker(xhr);
|
|
1154
1101
|
return xhr.__ajaxHooker.proxyXhr;
|
|
1155
1102
|
}
|
|
1156
1103
|
fakeXHR.prototype = win.XMLHttpRequest.prototype;
|
|
1157
|
-
Object.keys(win.XMLHttpRequest).forEach(
|
|
1158
|
-
(key) => (fakeXHR[key] = win.XMLHttpRequest[key])
|
|
1159
|
-
);
|
|
1104
|
+
Object.keys(win.XMLHttpRequest).forEach((key) => (fakeXHR[key] = win.XMLHttpRequest[key]));
|
|
1160
1105
|
function fakeFetch(url, options = {}) {
|
|
1161
1106
|
if (!url) return winAh.realFetch.call(win, url, options);
|
|
1162
1107
|
return new Promise(async (resolve, reject) => {
|
|
@@ -1222,18 +1167,22 @@ define((function () { 'use strict';
|
|
|
1222
1167
|
status: res.status,
|
|
1223
1168
|
responseHeaders: parseHeaders(res.headers),
|
|
1224
1169
|
};
|
|
1225
|
-
|
|
1226
|
-
(
|
|
1227
|
-
(
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1170
|
+
if (res.ok) {
|
|
1171
|
+
fetchResponses.forEach(
|
|
1172
|
+
(key) =>
|
|
1173
|
+
(res[key] = function () {
|
|
1174
|
+
if (key in response) return Promise.resolve(response[key]);
|
|
1175
|
+
return resProto[key].call(this).then((val) => {
|
|
1176
|
+
response[key] = val;
|
|
1177
|
+
return req
|
|
1178
|
+
.waitForResponseKeys(response)
|
|
1179
|
+
.then(() => (key in response ? response[key] : val));
|
|
1180
|
+
});
|
|
1181
|
+
})
|
|
1182
|
+
);
|
|
1183
|
+
} else {
|
|
1184
|
+
catchError(request.response, response);
|
|
1185
|
+
}
|
|
1237
1186
|
}
|
|
1238
1187
|
resolve(res);
|
|
1239
1188
|
}, reject);
|
|
@@ -1255,8 +1204,7 @@ define((function () { 'use strict';
|
|
|
1255
1204
|
realFetchClone: resProto.clone,
|
|
1256
1205
|
hookInsts: new Set(),
|
|
1257
1206
|
};
|
|
1258
|
-
if (winAh.version !== version)
|
|
1259
|
-
console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1207
|
+
if (winAh.version !== version) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1260
1208
|
win.XMLHttpRequest = winAh.fakeXHR;
|
|
1261
1209
|
win.fetch = winAh.fakeFetch;
|
|
1262
1210
|
resProto.clone = winAh.fakeFetchClone;
|
|
@@ -1264,37 +1212,25 @@ define((function () { 'use strict';
|
|
|
1264
1212
|
// 针对头条、抖音 secsdk.umd.js 的兼容性处理
|
|
1265
1213
|
class AHFunction extends Function {
|
|
1266
1214
|
call(thisArg, ...args) {
|
|
1267
|
-
if (
|
|
1268
|
-
thisArg &&
|
|
1269
|
-
thisArg.__ajaxHooker &&
|
|
1270
|
-
thisArg.__ajaxHooker.proxyXhr === thisArg
|
|
1271
|
-
) {
|
|
1215
|
+
if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) {
|
|
1272
1216
|
thisArg = thisArg.__ajaxHooker.originalXhr;
|
|
1273
1217
|
}
|
|
1274
1218
|
return Reflect.apply(this, thisArg, args);
|
|
1275
1219
|
}
|
|
1276
1220
|
apply(thisArg, args) {
|
|
1277
|
-
if (
|
|
1278
|
-
thisArg &&
|
|
1279
|
-
thisArg.__ajaxHooker &&
|
|
1280
|
-
thisArg.__ajaxHooker.proxyXhr === thisArg
|
|
1281
|
-
) {
|
|
1221
|
+
if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) {
|
|
1282
1222
|
thisArg = thisArg.__ajaxHooker.originalXhr;
|
|
1283
1223
|
}
|
|
1284
1224
|
return Reflect.apply(this, thisArg, args || []);
|
|
1285
1225
|
}
|
|
1286
1226
|
}
|
|
1287
1227
|
function hookSecsdk(csrf) {
|
|
1288
|
-
Object.setPrototypeOf(
|
|
1289
|
-
csrf.nativeXMLHttpRequestSetRequestHeader,
|
|
1290
|
-
AHFunction.prototype
|
|
1291
|
-
);
|
|
1228
|
+
Object.setPrototypeOf(csrf.nativeXMLHttpRequestSetRequestHeader, AHFunction.prototype);
|
|
1292
1229
|
Object.setPrototypeOf(csrf.nativeXMLHttpRequestOpen, AHFunction.prototype);
|
|
1293
1230
|
Object.setPrototypeOf(csrf.nativeXMLHttpRequestSend, AHFunction.prototype);
|
|
1294
1231
|
}
|
|
1295
1232
|
if (win.secsdk) {
|
|
1296
|
-
if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen)
|
|
1297
|
-
hookSecsdk(win.secsdk.csrf);
|
|
1233
|
+
if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen) hookSecsdk(win.secsdk.csrf);
|
|
1298
1234
|
} else {
|
|
1299
1235
|
defineProp(win, "secsdk", emptyFn, (secsdk) => {
|
|
1300
1236
|
delete win.secsdk;
|
|
@@ -4431,6 +4367,10 @@ define((function () { 'use strict';
|
|
|
4431
4367
|
globalThis: globalThis,
|
|
4432
4368
|
self: self,
|
|
4433
4369
|
top: top,
|
|
4370
|
+
setTimeout: globalThis.setTimeout,
|
|
4371
|
+
setInterval: globalThis.setInterval,
|
|
4372
|
+
clearTimeout: globalThis.clearTimeout,
|
|
4373
|
+
clearInterval: globalThis.clearInterval,
|
|
4434
4374
|
};
|
|
4435
4375
|
/** 使用的配置 */
|
|
4436
4376
|
api;
|
|
@@ -4463,6 +4403,18 @@ define((function () { 'use strict';
|
|
|
4463
4403
|
get top() {
|
|
4464
4404
|
return this.api.top;
|
|
4465
4405
|
}
|
|
4406
|
+
get setTimeout() {
|
|
4407
|
+
return this.api.setTimeout;
|
|
4408
|
+
}
|
|
4409
|
+
get setInterval() {
|
|
4410
|
+
return this.api.setInterval;
|
|
4411
|
+
}
|
|
4412
|
+
get clearTimeout() {
|
|
4413
|
+
return this.api.clearTimeout;
|
|
4414
|
+
}
|
|
4415
|
+
get clearInterval() {
|
|
4416
|
+
return this.api.clearInterval;
|
|
4417
|
+
}
|
|
4466
4418
|
}
|
|
4467
4419
|
|
|
4468
4420
|
const VueUtils = {
|
|
@@ -4938,7 +4890,7 @@ define((function () { 'use strict';
|
|
|
4938
4890
|
};
|
|
4939
4891
|
|
|
4940
4892
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
4941
|
-
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,(
|
|
4893
|
+
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
|
|
4942
4894
|
|
|
4943
4895
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
4944
4896
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -5525,7 +5477,7 @@ define((function () { 'use strict';
|
|
|
5525
5477
|
this.windowApi = new WindowApi(option);
|
|
5526
5478
|
}
|
|
5527
5479
|
/** 版本号 */
|
|
5528
|
-
version = "2025.8.
|
|
5480
|
+
version = "2025.8.21";
|
|
5529
5481
|
addStyle(cssText) {
|
|
5530
5482
|
if (typeof cssText !== "string") {
|
|
5531
5483
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -8609,7 +8561,7 @@ define((function () { 'use strict';
|
|
|
8609
8561
|
return setTimeout$1(callback, timeout);
|
|
8610
8562
|
}
|
|
8611
8563
|
catch (error) {
|
|
8612
|
-
return
|
|
8564
|
+
return this.windowApi.setTimeout(callback, timeout);
|
|
8613
8565
|
}
|
|
8614
8566
|
}
|
|
8615
8567
|
/**
|
|
@@ -8625,7 +8577,7 @@ define((function () { 'use strict';
|
|
|
8625
8577
|
catch (error) {
|
|
8626
8578
|
}
|
|
8627
8579
|
finally {
|
|
8628
|
-
|
|
8580
|
+
this.windowApi.clearTimeout(timeId);
|
|
8629
8581
|
}
|
|
8630
8582
|
}
|
|
8631
8583
|
/**
|
|
@@ -8638,7 +8590,7 @@ define((function () { 'use strict';
|
|
|
8638
8590
|
return setInterval(callback, timeout);
|
|
8639
8591
|
}
|
|
8640
8592
|
catch (error) {
|
|
8641
|
-
return
|
|
8593
|
+
return this.windowApi.setInterval(callback, timeout);
|
|
8642
8594
|
}
|
|
8643
8595
|
}
|
|
8644
8596
|
/**
|
|
@@ -8654,7 +8606,7 @@ define((function () { 'use strict';
|
|
|
8654
8606
|
catch (error) {
|
|
8655
8607
|
}
|
|
8656
8608
|
finally {
|
|
8657
|
-
|
|
8609
|
+
this.windowApi.clearInterval(timeId);
|
|
8658
8610
|
}
|
|
8659
8611
|
}
|
|
8660
8612
|
/**
|