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