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