@whitesev/utils 2.7.2 → 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 +197 -350
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +197 -350
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +197 -350
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +197 -350
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +197 -350
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +197 -350
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Utils.d.ts +30 -2
- package/dist/types/src/WindowApi.d.ts +4 -0
- package/dist/types/src/types/Event.d.ts +1 -2
- package/dist/types/src/types/Httpx.d.ts +4 -21
- package/dist/types/src/types/WindowApi.d.ts +4 -0
- package/dist/types/src/types/ajaxHooker.d.ts +1 -5
- package/package.json +1 -1
- package/src/ColorConversion.ts +5 -18
- package/src/CommonUtil.ts +8 -31
- package/src/DOMUtils.ts +9 -22
- package/src/Dictionary.ts +2 -7
- package/src/GBKEncoder.ts +1 -6
- package/src/Hooks.ts +1 -4
- package/src/Httpx.ts +102 -277
- package/src/LockFunction.ts +1 -3
- package/src/Log.ts +7 -23
- package/src/Progress.ts +2 -10
- package/src/TryCatch.ts +3 -11
- package/src/Utils.ts +213 -559
- package/src/UtilsCommon.ts +5 -9
- package/src/UtilsGMCookie.ts +1 -4
- package/src/UtilsGMMenu.ts +10 -29
- package/src/Vue.ts +2 -11
- package/src/WindowApi.ts +16 -0
- package/src/ajaxHooker/ajaxHooker.js +78 -142
- package/src/indexedDB.ts +3 -12
- package/src/types/Event.d.ts +1 -2
- package/src/types/Httpx.d.ts +4 -21
- package/src/types/WindowApi.d.ts +4 -0
- package/src/types/ajaxHooker.d.ts +1 -5
package/dist/index.system.js
CHANGED
|
@@ -70,11 +70,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
70
70
|
!validPattern.test(greenValue.toString()) ||
|
|
71
71
|
!validPattern.test(blueValue.toString()))
|
|
72
72
|
throw new TypeError("输入错误的rgb颜色值");
|
|
73
|
-
let hexs = [
|
|
74
|
-
redValue.toString(16),
|
|
75
|
-
greenValue.toString(16),
|
|
76
|
-
blueValue.toString(16),
|
|
77
|
-
];
|
|
73
|
+
let hexs = [redValue.toString(16), greenValue.toString(16), blueValue.toString(16)];
|
|
78
74
|
for (let index = 0; index < 3; index++)
|
|
79
75
|
if (hexs[index].length == 1)
|
|
80
76
|
hexs[index] = "0" + hexs[index];
|
|
@@ -122,10 +118,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
122
118
|
this.#data = dataText.match(/..../g);
|
|
123
119
|
for (let i = 0x81; i <= 0xfe; i++) {
|
|
124
120
|
for (let j = 0x40; j <= 0xfe; j++) {
|
|
125
|
-
this.#U2Ghash[this.#data[index++]] = ("%" +
|
|
126
|
-
i.toString(16) +
|
|
127
|
-
"%" +
|
|
128
|
-
j.toString(16)).toUpperCase();
|
|
121
|
+
this.#U2Ghash[this.#data[index++]] = ("%" + i.toString(16) + "%" + j.toString(16)).toUpperCase();
|
|
129
122
|
}
|
|
130
123
|
}
|
|
131
124
|
for (let key in this.#U2Ghash) {
|
|
@@ -253,9 +246,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
253
246
|
callbackFunction = callback;
|
|
254
247
|
context = __context__ || this;
|
|
255
248
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
256
|
-
return result !== void 0
|
|
257
|
-
? result
|
|
258
|
-
: TryCatchCore;
|
|
249
|
+
return result !== void 0 ? result : TryCatchCore;
|
|
259
250
|
},
|
|
260
251
|
};
|
|
261
252
|
/**
|
|
@@ -284,10 +275,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
284
275
|
}
|
|
285
276
|
if (handleErrorFunc) {
|
|
286
277
|
if (typeof handleErrorFunc === "string") {
|
|
287
|
-
result = new Function(handleErrorFunc).apply(funcThis, [
|
|
288
|
-
...args,
|
|
289
|
-
error,
|
|
290
|
-
]);
|
|
278
|
+
result = new Function(handleErrorFunc).apply(funcThis, [...args, error]);
|
|
291
279
|
}
|
|
292
280
|
else {
|
|
293
281
|
result = handleErrorFunc.apply(funcThis, [...args, error]);
|
|
@@ -375,10 +363,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
375
363
|
itemResult = objItem === 0;
|
|
376
364
|
break;
|
|
377
365
|
case "string":
|
|
378
|
-
itemResult =
|
|
379
|
-
objItem.trim() === "" ||
|
|
380
|
-
objItem === "null" ||
|
|
381
|
-
objItem === "undefined";
|
|
366
|
+
itemResult = objItem.trim() === "" || objItem === "null" || objItem === "undefined";
|
|
382
367
|
break;
|
|
383
368
|
case "boolean":
|
|
384
369
|
itemResult = !objItem;
|
|
@@ -419,8 +404,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
419
404
|
return null;
|
|
420
405
|
let clone = obj instanceof Array ? [] : {};
|
|
421
406
|
for (const [key, value] of Object.entries(obj)) {
|
|
422
|
-
clone[key] =
|
|
423
|
-
typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
407
|
+
clone[key] = typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
424
408
|
}
|
|
425
409
|
return clone;
|
|
426
410
|
}
|
|
@@ -738,13 +722,13 @@ System.register('Utils', [], (function (exports) {
|
|
|
738
722
|
// ==UserScript==
|
|
739
723
|
// @name ajaxHooker
|
|
740
724
|
// @author cxxjackie
|
|
741
|
-
// @version 1.4.
|
|
725
|
+
// @version 1.4.8
|
|
742
726
|
// @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
743
727
|
// @license GNU LGPL-3.0
|
|
744
728
|
// ==/UserScript==
|
|
745
729
|
|
|
746
730
|
const ajaxHooker = function () {
|
|
747
|
-
const version = "1.4.
|
|
731
|
+
const version = "1.4.8";
|
|
748
732
|
const hookInst = {
|
|
749
733
|
hookFns: [],
|
|
750
734
|
filters: [],
|
|
@@ -773,11 +757,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
773
757
|
const emptyFn = () => {};
|
|
774
758
|
const errorFn = (e) => console.error(e);
|
|
775
759
|
function isThenable(obj) {
|
|
776
|
-
return (
|
|
777
|
-
obj &&
|
|
778
|
-
["object", "function"].includes(typeof obj) &&
|
|
779
|
-
typeof obj.then === "function"
|
|
780
|
-
);
|
|
760
|
+
return obj && ["object", "function"].includes(typeof obj) && typeof obj.then === "function";
|
|
781
761
|
}
|
|
782
762
|
function catchError(fn, ...args) {
|
|
783
763
|
try {
|
|
@@ -815,8 +795,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
815
795
|
const [header, value] = line.split(/(?<=^[^:]+)\s*:\s*/);
|
|
816
796
|
if (!value) continue;
|
|
817
797
|
const lheader = header.toLowerCase();
|
|
818
|
-
headers[lheader] =
|
|
819
|
-
lheader in headers ? `${headers[lheader]}, ${value}` : value;
|
|
798
|
+
headers[lheader] = lheader in headers ? `${headers[lheader]}, ${value}` : value;
|
|
820
799
|
}
|
|
821
800
|
break;
|
|
822
801
|
case "[object Headers]":
|
|
@@ -854,11 +833,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
854
833
|
!filters.find((obj) => {
|
|
855
834
|
switch (true) {
|
|
856
835
|
case obj.type && obj.type !== type:
|
|
857
|
-
case getType(obj.url) === "[object String]" &&
|
|
858
|
-
!url.includes(obj.url):
|
|
836
|
+
case getType(obj.url) === "[object String]" && !url.includes(obj.url):
|
|
859
837
|
case getType(obj.url) === "[object RegExp]" && !obj.url.test(url):
|
|
860
|
-
case obj.method &&
|
|
861
|
-
obj.method.toUpperCase() !== method.toUpperCase():
|
|
838
|
+
case obj.method && obj.method.toUpperCase() !== method.toUpperCase():
|
|
862
839
|
case "async" in obj && obj.async !== async:
|
|
863
840
|
return false;
|
|
864
841
|
}
|
|
@@ -871,8 +848,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
871
848
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
872
849
|
if (this.shouldFilter(filters)) return;
|
|
873
850
|
hookFns.forEach((fn) => {
|
|
874
|
-
if (getType(fn) === "[object Function]")
|
|
875
|
-
catchError(fn, this.request);
|
|
851
|
+
if (getType(fn) === "[object Function]") catchError(fn, this.request);
|
|
876
852
|
});
|
|
877
853
|
for (const key in this.request) {
|
|
878
854
|
if (isThenable(this.request[key])) this._recoverRequestKey(key);
|
|
@@ -885,93 +861,72 @@ System.register('Utils', [], (function (exports) {
|
|
|
885
861
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
886
862
|
if (this.shouldFilter(filters)) return;
|
|
887
863
|
promises.push(
|
|
888
|
-
Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
(val) => (this.request[key] = val),
|
|
897
|
-
() => this._recoverRequestKey(key)
|
|
898
|
-
)
|
|
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)
|
|
899
872
|
)
|
|
900
|
-
)
|
|
901
|
-
|
|
902
|
-
)
|
|
873
|
+
)
|
|
874
|
+
);
|
|
875
|
+
})
|
|
903
876
|
);
|
|
904
877
|
});
|
|
905
878
|
return Promise.all(promises);
|
|
906
879
|
}
|
|
907
880
|
waitForResponseKeys(response) {
|
|
908
|
-
const responseKeys =
|
|
909
|
-
this.request.type === "xhr" ? xhrResponses : fetchResponses;
|
|
881
|
+
const responseKeys = this.request.type === "xhr" ? xhrResponses : fetchResponses;
|
|
910
882
|
if (!this.request.async) {
|
|
911
883
|
if (getType(this.request.response) === "[object Function]") {
|
|
912
884
|
catchError(this.request.response, response);
|
|
913
885
|
responseKeys.forEach((key) => {
|
|
914
|
-
if (
|
|
915
|
-
"get" in getDescriptor(response, key) ||
|
|
916
|
-
isThenable(response[key])
|
|
917
|
-
) {
|
|
886
|
+
if ("get" in getDescriptor(response, key) || isThenable(response[key])) {
|
|
918
887
|
delete response[key];
|
|
919
888
|
}
|
|
920
889
|
});
|
|
921
890
|
}
|
|
922
891
|
return new SyncThenable();
|
|
923
892
|
}
|
|
924
|
-
return Promise.resolve(catchError(this.request.response, response)).then(
|
|
925
|
-
(
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
)
|
|
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
|
+
)
|
|
939
907
|
);
|
|
940
908
|
}
|
|
941
909
|
}
|
|
942
910
|
const proxyHandler = {
|
|
943
911
|
get(target, prop) {
|
|
944
912
|
const descriptor = getDescriptor(target, prop);
|
|
945
|
-
if (
|
|
946
|
-
descriptor &&
|
|
947
|
-
!descriptor.configurable &&
|
|
948
|
-
!descriptor.writable &&
|
|
949
|
-
!descriptor.get
|
|
950
|
-
)
|
|
913
|
+
if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.get)
|
|
951
914
|
return target[prop];
|
|
952
915
|
const ah = target.__ajaxHooker;
|
|
953
916
|
if (ah && ah.proxyProps) {
|
|
954
917
|
if (prop in ah.proxyProps) {
|
|
955
918
|
const pDescriptor = ah.proxyProps[prop];
|
|
956
919
|
if ("get" in pDescriptor) return pDescriptor.get();
|
|
957
|
-
if (typeof pDescriptor.value === "function")
|
|
958
|
-
return pDescriptor.value.bind(ah);
|
|
920
|
+
if (typeof pDescriptor.value === "function") return pDescriptor.value.bind(ah);
|
|
959
921
|
return pDescriptor.value;
|
|
960
922
|
}
|
|
961
|
-
if (typeof target[prop] === "function")
|
|
962
|
-
return target[prop].bind(target);
|
|
923
|
+
if (typeof target[prop] === "function") return target[prop].bind(target);
|
|
963
924
|
}
|
|
964
925
|
return target[prop];
|
|
965
926
|
},
|
|
966
927
|
set(target, prop, value) {
|
|
967
928
|
const descriptor = getDescriptor(target, prop);
|
|
968
|
-
if (
|
|
969
|
-
descriptor &&
|
|
970
|
-
!descriptor.configurable &&
|
|
971
|
-
!descriptor.writable &&
|
|
972
|
-
!descriptor.set
|
|
973
|
-
)
|
|
974
|
-
return true;
|
|
929
|
+
if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.set) return true;
|
|
975
930
|
const ah = target.__ajaxHooker;
|
|
976
931
|
if (ah && ah.proxyProps && prop in ah.proxyProps) {
|
|
977
932
|
const pDescriptor = ah.proxyProps[prop];
|
|
@@ -993,11 +948,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
993
948
|
proxyEvents: {},
|
|
994
949
|
});
|
|
995
950
|
xhr.addEventListener("readystatechange", (e) => {
|
|
996
|
-
if (
|
|
997
|
-
ah.proxyXhr.readyState === 4 &&
|
|
998
|
-
ah.request &&
|
|
999
|
-
typeof ah.request.response === "function"
|
|
1000
|
-
) {
|
|
951
|
+
if (ah.proxyXhr.readyState === 4 && ah.request && typeof ah.request.response === "function") {
|
|
1001
952
|
const response = {
|
|
1002
953
|
finalUrl: ah.proxyXhr.responseURL,
|
|
1003
954
|
status: ah.proxyXhr.status,
|
|
@@ -1020,18 +971,16 @@ System.register('Utils', [], (function (exports) {
|
|
|
1020
971
|
}
|
|
1021
972
|
);
|
|
1022
973
|
}
|
|
1023
|
-
ah.resThenable = new AHRequest(ah.request)
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
}
|
|
1034
|
-
});
|
|
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
|
+
});
|
|
1035
984
|
}
|
|
1036
985
|
ah.dispatchEvent(e);
|
|
1037
986
|
});
|
|
@@ -1044,13 +993,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
1044
993
|
set: (val) => ah.addEvent(onEvt, val),
|
|
1045
994
|
};
|
|
1046
995
|
}
|
|
1047
|
-
for (const method of [
|
|
1048
|
-
"setRequestHeader",
|
|
1049
|
-
"addEventListener",
|
|
1050
|
-
"removeEventListener",
|
|
1051
|
-
"open",
|
|
1052
|
-
"send",
|
|
1053
|
-
]) {
|
|
996
|
+
for (const method of ["setRequestHeader", "addEventListener", "removeEventListener", "open", "send"]) {
|
|
1054
997
|
ah.proxyProps[method] = { value: ah[method] };
|
|
1055
998
|
}
|
|
1056
999
|
}
|
|
@@ -1059,8 +1002,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
1059
1002
|
if (type.startsWith("on")) {
|
|
1060
1003
|
this.proxyEvents[type] = typeof event === "function" ? event : null;
|
|
1061
1004
|
} else {
|
|
1062
|
-
if (typeof event === "object" && event !== null)
|
|
1063
|
-
event = event.handleEvent;
|
|
1005
|
+
if (typeof event === "object" && event !== null) event = event.handleEvent;
|
|
1064
1006
|
if (typeof event !== "function") return;
|
|
1065
1007
|
this.proxyEvents[type] = this.proxyEvents[type] || new Set();
|
|
1066
1008
|
this.proxyEvents[type].add(event);
|
|
@@ -1070,8 +1012,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
1070
1012
|
if (type.startsWith("on")) {
|
|
1071
1013
|
this.proxyEvents[type] = null;
|
|
1072
1014
|
} else {
|
|
1073
|
-
if (typeof event === "object" && event !== null)
|
|
1074
|
-
event = event.handleEvent;
|
|
1015
|
+
if (typeof event === "object" && event !== null) event = event.handleEvent;
|
|
1075
1016
|
this.proxyEvents[type] && this.proxyEvents[type].delete(event);
|
|
1076
1017
|
}
|
|
1077
1018
|
}
|
|
@@ -1082,9 +1023,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
1082
1023
|
defineProp(e, "srcElement", () => this.proxyXhr);
|
|
1083
1024
|
this.proxyEvents[e.type] &&
|
|
1084
1025
|
this.proxyEvents[e.type].forEach((fn) => {
|
|
1085
|
-
this.resThenable.then(
|
|
1086
|
-
() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e)
|
|
1087
|
-
);
|
|
1026
|
+
this.resThenable.then(() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e));
|
|
1088
1027
|
});
|
|
1089
1028
|
if (e.ajaxHooker_isStopped) return;
|
|
1090
1029
|
const onEvent = this.proxyEvents["on" + e.type];
|
|
@@ -1094,8 +1033,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
1094
1033
|
this.originalXhr.setRequestHeader(header, value);
|
|
1095
1034
|
if (!this.request) return;
|
|
1096
1035
|
const headers = this.request.headers;
|
|
1097
|
-
headers[header] =
|
|
1098
|
-
header in headers ? `${headers[header]}, ${value}` : value;
|
|
1036
|
+
headers[header] = header in headers ? `${headers[header]}, ${value}` : value;
|
|
1099
1037
|
}
|
|
1100
1038
|
addEventListener(...args) {
|
|
1101
1039
|
if (xhrAsyncEvents.includes(args[0])) {
|
|
@@ -1124,13 +1062,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
1124
1062
|
};
|
|
1125
1063
|
this.openArgs = args;
|
|
1126
1064
|
this.resThenable = new SyncThenable();
|
|
1127
|
-
[
|
|
1128
|
-
"responseURL",
|
|
1129
|
-
"readyState",
|
|
1130
|
-
"status",
|
|
1131
|
-
"statusText",
|
|
1132
|
-
...xhrResponses,
|
|
1133
|
-
].forEach((key) => {
|
|
1065
|
+
["responseURL", "readyState", "status", "statusText", ...xhrResponses].forEach((key) => {
|
|
1134
1066
|
delete this.proxyProps[key];
|
|
1135
1067
|
});
|
|
1136
1068
|
return this.originalXhr.open(method, url, async, ...args);
|
|
@@ -1167,15 +1099,12 @@ System.register('Utils', [], (function (exports) {
|
|
|
1167
1099
|
}
|
|
1168
1100
|
function fakeXHR() {
|
|
1169
1101
|
const xhr = new winAh.realXHR();
|
|
1170
|
-
if ("__ajaxHooker" in xhr)
|
|
1171
|
-
console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1102
|
+
if ("__ajaxHooker" in xhr) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1172
1103
|
xhr.__ajaxHooker = new XhrHooker(xhr);
|
|
1173
1104
|
return xhr.__ajaxHooker.proxyXhr;
|
|
1174
1105
|
}
|
|
1175
1106
|
fakeXHR.prototype = win.XMLHttpRequest.prototype;
|
|
1176
|
-
Object.keys(win.XMLHttpRequest).forEach(
|
|
1177
|
-
(key) => (fakeXHR[key] = win.XMLHttpRequest[key])
|
|
1178
|
-
);
|
|
1107
|
+
Object.keys(win.XMLHttpRequest).forEach((key) => (fakeXHR[key] = win.XMLHttpRequest[key]));
|
|
1179
1108
|
function fakeFetch(url, options = {}) {
|
|
1180
1109
|
if (!url) return winAh.realFetch.call(win, url, options);
|
|
1181
1110
|
return new Promise(async (resolve, reject) => {
|
|
@@ -1241,18 +1170,22 @@ System.register('Utils', [], (function (exports) {
|
|
|
1241
1170
|
status: res.status,
|
|
1242
1171
|
responseHeaders: parseHeaders(res.headers),
|
|
1243
1172
|
};
|
|
1244
|
-
|
|
1245
|
-
(
|
|
1246
|
-
(
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
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
|
+
}
|
|
1256
1189
|
}
|
|
1257
1190
|
resolve(res);
|
|
1258
1191
|
}, reject);
|
|
@@ -1274,8 +1207,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
1274
1207
|
realFetchClone: resProto.clone,
|
|
1275
1208
|
hookInsts: new Set(),
|
|
1276
1209
|
};
|
|
1277
|
-
if (winAh.version !== version)
|
|
1278
|
-
console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1210
|
+
if (winAh.version !== version) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1279
1211
|
win.XMLHttpRequest = winAh.fakeXHR;
|
|
1280
1212
|
win.fetch = winAh.fakeFetch;
|
|
1281
1213
|
resProto.clone = winAh.fakeFetchClone;
|
|
@@ -1283,37 +1215,25 @@ System.register('Utils', [], (function (exports) {
|
|
|
1283
1215
|
// 针对头条、抖音 secsdk.umd.js 的兼容性处理
|
|
1284
1216
|
class AHFunction extends Function {
|
|
1285
1217
|
call(thisArg, ...args) {
|
|
1286
|
-
if (
|
|
1287
|
-
thisArg &&
|
|
1288
|
-
thisArg.__ajaxHooker &&
|
|
1289
|
-
thisArg.__ajaxHooker.proxyXhr === thisArg
|
|
1290
|
-
) {
|
|
1218
|
+
if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) {
|
|
1291
1219
|
thisArg = thisArg.__ajaxHooker.originalXhr;
|
|
1292
1220
|
}
|
|
1293
1221
|
return Reflect.apply(this, thisArg, args);
|
|
1294
1222
|
}
|
|
1295
1223
|
apply(thisArg, args) {
|
|
1296
|
-
if (
|
|
1297
|
-
thisArg &&
|
|
1298
|
-
thisArg.__ajaxHooker &&
|
|
1299
|
-
thisArg.__ajaxHooker.proxyXhr === thisArg
|
|
1300
|
-
) {
|
|
1224
|
+
if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) {
|
|
1301
1225
|
thisArg = thisArg.__ajaxHooker.originalXhr;
|
|
1302
1226
|
}
|
|
1303
1227
|
return Reflect.apply(this, thisArg, args || []);
|
|
1304
1228
|
}
|
|
1305
1229
|
}
|
|
1306
1230
|
function hookSecsdk(csrf) {
|
|
1307
|
-
Object.setPrototypeOf(
|
|
1308
|
-
csrf.nativeXMLHttpRequestSetRequestHeader,
|
|
1309
|
-
AHFunction.prototype
|
|
1310
|
-
);
|
|
1231
|
+
Object.setPrototypeOf(csrf.nativeXMLHttpRequestSetRequestHeader, AHFunction.prototype);
|
|
1311
1232
|
Object.setPrototypeOf(csrf.nativeXMLHttpRequestOpen, AHFunction.prototype);
|
|
1312
1233
|
Object.setPrototypeOf(csrf.nativeXMLHttpRequestSend, AHFunction.prototype);
|
|
1313
1234
|
}
|
|
1314
1235
|
if (win.secsdk) {
|
|
1315
|
-
if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen)
|
|
1316
|
-
hookSecsdk(win.secsdk.csrf);
|
|
1236
|
+
if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen) hookSecsdk(win.secsdk.csrf);
|
|
1317
1237
|
} else {
|
|
1318
1238
|
defineProp(win, "secsdk", emptyFn, (secsdk) => {
|
|
1319
1239
|
delete win.secsdk;
|
|
@@ -1959,14 +1879,10 @@ System.register('Utils', [], (function (exports) {
|
|
|
1959
1879
|
// };
|
|
1960
1880
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1961
1881
|
menuOption.autoReload =
|
|
1962
|
-
typeof menuOption.autoReload !== "boolean"
|
|
1963
|
-
? this.$default.autoReload
|
|
1964
|
-
: menuOption.autoReload;
|
|
1882
|
+
typeof menuOption.autoReload !== "boolean" ? this.$default.autoReload : menuOption.autoReload;
|
|
1965
1883
|
/* 点击菜单后触发callback后的网页是否存储值 */
|
|
1966
1884
|
menuOption.isStoreValue =
|
|
1967
|
-
typeof menuOption.isStoreValue !== "boolean"
|
|
1968
|
-
? this.$default.isStoreValue
|
|
1969
|
-
: menuOption.isStoreValue;
|
|
1885
|
+
typeof menuOption.isStoreValue !== "boolean" ? this.$default.isStoreValue : menuOption.isStoreValue;
|
|
1970
1886
|
/**
|
|
1971
1887
|
* 用户点击菜单后的回调函数
|
|
1972
1888
|
* @param event
|
|
@@ -2019,8 +1935,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2019
1935
|
* @param menuKey 菜单-键key
|
|
2020
1936
|
*/
|
|
2021
1937
|
getMenuHandledOption(menuKey) {
|
|
2022
|
-
return this.$data.data.find((item) => item.handleData.key === menuKey)
|
|
2023
|
-
?.handleData;
|
|
1938
|
+
return this.$data.data.find((item) => item.handleData.key === menuKey)?.handleData;
|
|
2024
1939
|
},
|
|
2025
1940
|
};
|
|
2026
1941
|
constructor(details) {
|
|
@@ -2028,8 +1943,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2028
1943
|
this.GM_Api.setValue = details.GM_setValue;
|
|
2029
1944
|
this.GM_Api.registerMenuCommand = details.GM_registerMenuCommand;
|
|
2030
1945
|
this.GM_Api.unregisterMenuCommand = details.GM_unregisterMenuCommand;
|
|
2031
|
-
this.MenuHandle.$default.autoReload =
|
|
2032
|
-
typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
1946
|
+
this.MenuHandle.$default.autoReload = typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
2033
1947
|
for (const keyName of Object.keys(this.GM_Api)) {
|
|
2034
1948
|
if (typeof this.GM_Api[keyName] !== "function") {
|
|
2035
1949
|
throw new Error(`Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`);
|
|
@@ -2261,8 +2175,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2261
2175
|
_context = context || window;
|
|
2262
2176
|
_funcName = getFuncName(this);
|
|
2263
2177
|
_context["realFunc_" + _funcName] = this;
|
|
2264
|
-
if (_context[_funcName].prototype &&
|
|
2265
|
-
_context[_funcName].prototype.isHooked) {
|
|
2178
|
+
if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
|
|
2266
2179
|
console.log("Already has been hooked,unhook first");
|
|
2267
2180
|
return false;
|
|
2268
2181
|
}
|
|
@@ -2440,8 +2353,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2440
2353
|
if (details.allowInterceptConfig != null) {
|
|
2441
2354
|
// 配置存在
|
|
2442
2355
|
// 细分处理是否拦截
|
|
2443
|
-
if (typeof details.allowInterceptConfig.afterResponseSuccess ===
|
|
2444
|
-
"boolean" &&
|
|
2356
|
+
if (typeof details.allowInterceptConfig.afterResponseSuccess === "boolean" &&
|
|
2445
2357
|
!details.allowInterceptConfig.afterResponseSuccess) {
|
|
2446
2358
|
// 设置了禁止拦截
|
|
2447
2359
|
return details;
|
|
@@ -2476,8 +2388,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2476
2388
|
if (data.details.allowInterceptConfig != null) {
|
|
2477
2389
|
// 配置存在
|
|
2478
2390
|
// 细分处理是否拦截
|
|
2479
|
-
if (typeof data.details.allowInterceptConfig.afterResponseError ===
|
|
2480
|
-
"boolean" &&
|
|
2391
|
+
if (typeof data.details.allowInterceptConfig.afterResponseError === "boolean" &&
|
|
2481
2392
|
!data.details.allowInterceptConfig.afterResponseError) {
|
|
2482
2393
|
// 设置了禁止拦截
|
|
2483
2394
|
return data;
|
|
@@ -2579,44 +2490,31 @@ System.register('Utils', [], (function (exports) {
|
|
|
2579
2490
|
let requestOption = {
|
|
2580
2491
|
url: url,
|
|
2581
2492
|
method: (method || "GET").toString().toUpperCase().trim(),
|
|
2582
|
-
timeout: userRequestOption.timeout ||
|
|
2583
|
-
|
|
2584
|
-
responseType: userRequestOption.responseType ||
|
|
2585
|
-
this.context.#defaultRequestOption.responseType,
|
|
2493
|
+
timeout: userRequestOption.timeout || this.context.#defaultRequestOption.timeout,
|
|
2494
|
+
responseType: userRequestOption.responseType || this.context.#defaultRequestOption.responseType,
|
|
2586
2495
|
/* 对象使用深拷贝 */
|
|
2587
2496
|
headers: commonUtil.deepClone(this.context.#defaultRequestOption.headers),
|
|
2588
2497
|
data: userRequestOption.data || this.context.#defaultRequestOption.data,
|
|
2589
|
-
redirect: userRequestOption.redirect ||
|
|
2590
|
-
this.context.#defaultRequestOption.redirect,
|
|
2498
|
+
redirect: userRequestOption.redirect || this.context.#defaultRequestOption.redirect,
|
|
2591
2499
|
cookie: userRequestOption.cookie || this.context.#defaultRequestOption.cookie,
|
|
2592
|
-
cookiePartition: userRequestOption.cookiePartition ||
|
|
2593
|
-
this.context.#defaultRequestOption.cookiePartition,
|
|
2500
|
+
cookiePartition: userRequestOption.cookiePartition || this.context.#defaultRequestOption.cookiePartition,
|
|
2594
2501
|
binary: userRequestOption.binary || this.context.#defaultRequestOption.binary,
|
|
2595
|
-
nocache: userRequestOption.nocache ||
|
|
2596
|
-
|
|
2597
|
-
revalidate: userRequestOption.revalidate ||
|
|
2598
|
-
this.context.#defaultRequestOption.revalidate,
|
|
2502
|
+
nocache: userRequestOption.nocache || this.context.#defaultRequestOption.nocache,
|
|
2503
|
+
revalidate: userRequestOption.revalidate || this.context.#defaultRequestOption.revalidate,
|
|
2599
2504
|
/* 对象使用深拷贝 */
|
|
2600
|
-
context: commonUtil.deepClone(userRequestOption.context ||
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
this.context.#defaultRequestOption.overrideMimeType,
|
|
2604
|
-
anonymous: userRequestOption.anonymous ||
|
|
2605
|
-
this.context.#defaultRequestOption.anonymous,
|
|
2505
|
+
context: commonUtil.deepClone(userRequestOption.context || this.context.#defaultRequestOption.context),
|
|
2506
|
+
overrideMimeType: userRequestOption.overrideMimeType || this.context.#defaultRequestOption.overrideMimeType,
|
|
2507
|
+
anonymous: userRequestOption.anonymous || this.context.#defaultRequestOption.anonymous,
|
|
2606
2508
|
fetch: userRequestOption.fetch || this.context.#defaultRequestOption.fetch,
|
|
2607
2509
|
/* 对象使用深拷贝 */
|
|
2608
2510
|
fetchInit: commonUtil.deepClone(this.context.#defaultRequestOption.fetchInit),
|
|
2609
2511
|
allowInterceptConfig: {
|
|
2610
|
-
beforeRequest: this.context.#defaultRequestOption
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
.allowInterceptConfig.afterResponseSuccess,
|
|
2614
|
-
afterResponseError: this.context.#defaultRequestOption
|
|
2615
|
-
.allowInterceptConfig.afterResponseError,
|
|
2512
|
+
beforeRequest: this.context.#defaultRequestOption.allowInterceptConfig.beforeRequest,
|
|
2513
|
+
afterResponseSuccess: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseSuccess,
|
|
2514
|
+
afterResponseError: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseError,
|
|
2616
2515
|
},
|
|
2617
2516
|
user: userRequestOption.user || this.context.#defaultRequestOption.user,
|
|
2618
|
-
password: userRequestOption.password ||
|
|
2619
|
-
this.context.#defaultRequestOption.password,
|
|
2517
|
+
password: userRequestOption.password || this.context.#defaultRequestOption.password,
|
|
2620
2518
|
onabort(...args) {
|
|
2621
2519
|
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2622
2520
|
},
|
|
@@ -2664,14 +2562,12 @@ System.register('Utils', [], (function (exports) {
|
|
|
2664
2562
|
if (typeof requestOption.headers === "object") {
|
|
2665
2563
|
if (typeof userRequestOption.headers === "object") {
|
|
2666
2564
|
Object.keys(userRequestOption.headers).forEach((keyName, index) => {
|
|
2667
|
-
if (keyName in requestOption.headers &&
|
|
2668
|
-
userRequestOption.headers?.[keyName] == null) {
|
|
2565
|
+
if (keyName in requestOption.headers && userRequestOption.headers?.[keyName] == null) {
|
|
2669
2566
|
/* 在默认的header中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2670
2567
|
Reflect.deleteProperty(requestOption.headers, keyName);
|
|
2671
2568
|
}
|
|
2672
2569
|
else {
|
|
2673
|
-
requestOption.headers[keyName] =
|
|
2674
|
-
userRequestOption?.headers?.[keyName];
|
|
2570
|
+
requestOption.headers[keyName] = userRequestOption?.headers?.[keyName];
|
|
2675
2571
|
}
|
|
2676
2572
|
});
|
|
2677
2573
|
}
|
|
@@ -2684,8 +2580,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2684
2580
|
/* 使用assign替换且添加 */
|
|
2685
2581
|
if (typeof userRequestOption.fetchInit === "object") {
|
|
2686
2582
|
Object.keys(userRequestOption.fetchInit).forEach((keyName, index) => {
|
|
2687
|
-
if (keyName in requestOption.fetchInit &&
|
|
2688
|
-
userRequestOption.fetchInit[keyName] == null) {
|
|
2583
|
+
if (keyName in requestOption.fetchInit && userRequestOption.fetchInit[keyName] == null) {
|
|
2689
2584
|
/* 在默认的fetchInit中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2690
2585
|
Reflect.deleteProperty(requestOption.fetchInit, keyName);
|
|
2691
2586
|
}
|
|
@@ -2699,8 +2594,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2699
2594
|
Reflect.set(requestOption, "fetchInit", userRequestOption.fetchInit);
|
|
2700
2595
|
}
|
|
2701
2596
|
// 处理新的cookiePartition
|
|
2702
|
-
if (typeof requestOption.cookiePartition === "object" &&
|
|
2703
|
-
requestOption.cookiePartition != null) {
|
|
2597
|
+
if (typeof requestOption.cookiePartition === "object" && requestOption.cookiePartition != null) {
|
|
2704
2598
|
if (Reflect.has(requestOption.cookiePartition, "topLevelSite") &&
|
|
2705
2599
|
typeof requestOption.cookiePartition.topLevelSite !== "string") {
|
|
2706
2600
|
// topLevelSite必须是字符串
|
|
@@ -2722,8 +2616,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2722
2616
|
}
|
|
2723
2617
|
else {
|
|
2724
2618
|
// 补充origin+/
|
|
2725
|
-
requestOption.url =
|
|
2726
|
-
globalThis.location.origin + "/" + requestOption.url;
|
|
2619
|
+
requestOption.url = globalThis.location.origin + "/" + requestOption.url;
|
|
2727
2620
|
}
|
|
2728
2621
|
}
|
|
2729
2622
|
if (requestOption.fetchInit && !requestOption.fetch) {
|
|
@@ -2847,8 +2740,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2847
2740
|
* fetch的请求配置
|
|
2848
2741
|
**/
|
|
2849
2742
|
let fetchRequestOption = {};
|
|
2850
|
-
if ((option.method === "GET" || option.method === "HEAD") &&
|
|
2851
|
-
option.data != null) {
|
|
2743
|
+
if ((option.method === "GET" || option.method === "HEAD") && option.data != null) {
|
|
2852
2744
|
/* GET 或 HEAD 方法的请求不能包含 body 信息 */
|
|
2853
2745
|
Reflect.deleteProperty(option, "data");
|
|
2854
2746
|
}
|
|
@@ -3129,8 +3021,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3129
3021
|
if (typeof details?.onreadystatechange === "function") {
|
|
3130
3022
|
details.onreadystatechange.apply(this, argsResult);
|
|
3131
3023
|
}
|
|
3132
|
-
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3133
|
-
"function") {
|
|
3024
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange === "function") {
|
|
3134
3025
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3135
3026
|
}
|
|
3136
3027
|
},
|
|
@@ -3159,8 +3050,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3159
3050
|
if (this.context.#defaultInitOption.logDetails) {
|
|
3160
3051
|
console.log("[Httpx-HttpxRequest.request] 请求前的配置👇", details);
|
|
3161
3052
|
}
|
|
3162
|
-
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack ===
|
|
3163
|
-
"function") {
|
|
3053
|
+
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack === "function") {
|
|
3164
3054
|
let hookResult = await this.context.HttpxRequestHook.beforeRequestCallBack(details);
|
|
3165
3055
|
if (hookResult == null) {
|
|
3166
3056
|
return;
|
|
@@ -3216,9 +3106,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3216
3106
|
/* 如果需要stream,且获取到的是stream,那直接返回 */
|
|
3217
3107
|
if (option.responseType === "stream" ||
|
|
3218
3108
|
(fetchResponse.headers.has("Content-Type") &&
|
|
3219
|
-
fetchResponse.headers
|
|
3220
|
-
.get("Content-Type")
|
|
3221
|
-
.includes("text/event-stream"))) {
|
|
3109
|
+
fetchResponse.headers.get("Content-Type").includes("text/event-stream"))) {
|
|
3222
3110
|
Reflect.set(httpxResponse, "isStream", true);
|
|
3223
3111
|
Reflect.set(httpxResponse, "response", fetchResponse.body);
|
|
3224
3112
|
Reflect.deleteProperty(httpxResponse, "responseText");
|
|
@@ -3237,9 +3125,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3237
3125
|
/** 数据编码 */
|
|
3238
3126
|
let encoding = "utf-8";
|
|
3239
3127
|
if (fetchResponse.headers.has("Content-Type")) {
|
|
3240
|
-
let charsetMatched = fetchResponse.headers
|
|
3241
|
-
.get("Content-Type")
|
|
3242
|
-
?.match(/charset=(.+)/);
|
|
3128
|
+
let charsetMatched = fetchResponse.headers.get("Content-Type")?.match(/charset=(.+)/);
|
|
3243
3129
|
if (charsetMatched) {
|
|
3244
3130
|
encoding = charsetMatched[1];
|
|
3245
3131
|
encoding = encoding.toLowerCase();
|
|
@@ -3261,13 +3147,11 @@ System.register('Utils', [], (function (exports) {
|
|
|
3261
3147
|
response = new Blob([arrayBuffer]);
|
|
3262
3148
|
}
|
|
3263
3149
|
else if (option.responseType === "json" ||
|
|
3264
|
-
(typeof fetchResponseType === "string" &&
|
|
3265
|
-
fetchResponseType.includes("application/json"))) {
|
|
3150
|
+
(typeof fetchResponseType === "string" && fetchResponseType.includes("application/json"))) {
|
|
3266
3151
|
// response返回格式是JSON格式
|
|
3267
3152
|
response = commonUtil.toJSON(responseText);
|
|
3268
3153
|
}
|
|
3269
|
-
else if (option.responseType === "document" ||
|
|
3270
|
-
option.responseType == null) {
|
|
3154
|
+
else if (option.responseType === "document" || option.responseType == null) {
|
|
3271
3155
|
// response返回格式是文档格式
|
|
3272
3156
|
let parser = new DOMParser();
|
|
3273
3157
|
response = parser.parseFromString(responseText, "text/html");
|
|
@@ -3530,8 +3414,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3530
3414
|
}
|
|
3531
3415
|
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3532
3416
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3533
|
-
if (requestResult != null &&
|
|
3534
|
-
typeof requestResult.abort === "function") {
|
|
3417
|
+
if (requestResult != null && typeof requestResult.abort === "function") {
|
|
3535
3418
|
abortFn = requestResult.abort;
|
|
3536
3419
|
}
|
|
3537
3420
|
});
|
|
@@ -4022,8 +3905,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
4022
3905
|
if (typeof __GM_info === "string") {
|
|
4023
3906
|
this.tag = __GM_info;
|
|
4024
3907
|
}
|
|
4025
|
-
else if (typeof __GM_info === "object" &&
|
|
4026
|
-
typeof __GM_info?.script?.name === "string") {
|
|
3908
|
+
else if (typeof __GM_info === "object" && typeof __GM_info?.script?.name === "string") {
|
|
4027
3909
|
this.tag = __GM_info.script.name;
|
|
4028
3910
|
}
|
|
4029
3911
|
this.#console = console;
|
|
@@ -4079,8 +3961,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
4079
3961
|
*/
|
|
4080
3962
|
checkClearConsole() {
|
|
4081
3963
|
this.#logCount++;
|
|
4082
|
-
if (this.#details.autoClearConsole &&
|
|
4083
|
-
this.#logCount > this.#details.logMaxCount) {
|
|
3964
|
+
if (this.#details.autoClearConsole && this.#logCount > this.#details.logMaxCount) {
|
|
4084
3965
|
this.#console.clear();
|
|
4085
3966
|
this.#logCount = 0;
|
|
4086
3967
|
}
|
|
@@ -4489,6 +4370,10 @@ System.register('Utils', [], (function (exports) {
|
|
|
4489
4370
|
globalThis: globalThis,
|
|
4490
4371
|
self: self,
|
|
4491
4372
|
top: top,
|
|
4373
|
+
setTimeout: globalThis.setTimeout,
|
|
4374
|
+
setInterval: globalThis.setInterval,
|
|
4375
|
+
clearTimeout: globalThis.clearTimeout,
|
|
4376
|
+
clearInterval: globalThis.clearInterval,
|
|
4492
4377
|
};
|
|
4493
4378
|
/** 使用的配置 */
|
|
4494
4379
|
api;
|
|
@@ -4521,6 +4406,18 @@ System.register('Utils', [], (function (exports) {
|
|
|
4521
4406
|
get top() {
|
|
4522
4407
|
return this.api.top;
|
|
4523
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
|
+
}
|
|
4524
4421
|
}
|
|
4525
4422
|
|
|
4526
4423
|
const VueUtils = {
|
|
@@ -4996,7 +4893,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
4996
4893
|
};
|
|
4997
4894
|
|
|
4998
4895
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
4999
|
-
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
|
|
5000
4897
|
|
|
5001
4898
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
5002
4899
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -5583,7 +5480,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5583
5480
|
this.windowApi = new WindowApi(option);
|
|
5584
5481
|
}
|
|
5585
5482
|
/** 版本号 */
|
|
5586
|
-
version = "2025.
|
|
5483
|
+
version = "2025.8.21";
|
|
5587
5484
|
addStyle(cssText) {
|
|
5588
5485
|
if (typeof cssText !== "string") {
|
|
5589
5486
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5706,13 +5603,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
5706
5603
|
let touchEvent = UtilsContext.windowApi.window.event;
|
|
5707
5604
|
let $click = clickEvent?.composedPath()?.[0];
|
|
5708
5605
|
// 点击的x坐标
|
|
5709
|
-
let clickPosX = clickEvent?.clientX != null
|
|
5710
|
-
? clickEvent.clientX
|
|
5711
|
-
: touchEvent.touches[0].clientX;
|
|
5606
|
+
let clickPosX = clickEvent?.clientX != null ? clickEvent.clientX : touchEvent.touches[0].clientX;
|
|
5712
5607
|
// 点击的y坐标
|
|
5713
|
-
let clickPosY = clickEvent?.clientY != null
|
|
5714
|
-
? clickEvent.clientY
|
|
5715
|
-
: touchEvent.touches[0].clientY;
|
|
5608
|
+
let clickPosY = clickEvent?.clientY != null ? clickEvent.clientY : touchEvent.touches[0].clientY;
|
|
5716
5609
|
let {
|
|
5717
5610
|
/* 要检测的元素的相对屏幕的横坐标最左边 */
|
|
5718
5611
|
left: elementPosXLeft,
|
|
@@ -5875,9 +5768,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5875
5768
|
/* CODE FOR BROWSERS THAT SUPPORT window.find */
|
|
5876
5769
|
let windowFind = this.windowApi.self.find;
|
|
5877
5770
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5878
|
-
if (strFound &&
|
|
5879
|
-
this.windowApi.self.getSelection &&
|
|
5880
|
-
!this.windowApi.self.getSelection().anchorNode) {
|
|
5771
|
+
if (strFound && this.windowApi.self.getSelection && !this.windowApi.self.getSelection().anchorNode) {
|
|
5881
5772
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5882
5773
|
}
|
|
5883
5774
|
if (!strFound) {
|
|
@@ -5980,9 +5871,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5980
5871
|
}
|
|
5981
5872
|
}
|
|
5982
5873
|
result = result.toFixed(2);
|
|
5983
|
-
result = addType
|
|
5984
|
-
? result + resultType.toString()
|
|
5985
|
-
: parseFloat(result.toString());
|
|
5874
|
+
result = addType ? result + resultType.toString() : parseFloat(result.toString());
|
|
5986
5875
|
return result;
|
|
5987
5876
|
}
|
|
5988
5877
|
getNodeListValue(...args) {
|
|
@@ -6061,14 +5950,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
6061
5950
|
if (text.length === 8) {
|
|
6062
5951
|
/* 该字符串只有时分秒 */
|
|
6063
5952
|
let today = new Date();
|
|
6064
|
-
text =
|
|
6065
|
-
today.getFullYear() +
|
|
6066
|
-
"-" +
|
|
6067
|
-
(today.getMonth() + 1) +
|
|
6068
|
-
"-" +
|
|
6069
|
-
today.getDate() +
|
|
6070
|
-
" " +
|
|
6071
|
-
text;
|
|
5953
|
+
text = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate() + " " + text;
|
|
6072
5954
|
}
|
|
6073
5955
|
text = text.substring(0, 19);
|
|
6074
5956
|
text = text.replace(/-/g, "/");
|
|
@@ -6089,25 +5971,13 @@ System.register('Utils', [], (function (exports) {
|
|
|
6089
5971
|
* 获取 transitionend 的在各个浏览器的兼容名
|
|
6090
5972
|
*/
|
|
6091
5973
|
getTransitionEndNameList() {
|
|
6092
|
-
return [
|
|
6093
|
-
"webkitTransitionEnd",
|
|
6094
|
-
"mozTransitionEnd",
|
|
6095
|
-
"MSTransitionEnd",
|
|
6096
|
-
"otransitionend",
|
|
6097
|
-
"transitionend",
|
|
6098
|
-
];
|
|
5974
|
+
return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
|
|
6099
5975
|
}
|
|
6100
5976
|
/**
|
|
6101
5977
|
* 获取 animationend 的在各个浏览器的兼容名
|
|
6102
5978
|
*/
|
|
6103
5979
|
getAnimationEndNameList() {
|
|
6104
|
-
return [
|
|
6105
|
-
"webkitAnimationEnd",
|
|
6106
|
-
"mozAnimationEnd",
|
|
6107
|
-
"MSAnimationEnd",
|
|
6108
|
-
"oanimationend",
|
|
6109
|
-
"animationend",
|
|
6110
|
-
];
|
|
5980
|
+
return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
|
|
6111
5981
|
}
|
|
6112
5982
|
getArrayLastValue(targetObj) {
|
|
6113
5983
|
return targetObj[targetObj.length - 1];
|
|
@@ -6211,10 +6081,8 @@ System.register('Utils', [], (function (exports) {
|
|
|
6211
6081
|
}
|
|
6212
6082
|
/* 如果有多个相同类型的兄弟元素,则需要添加索引 */
|
|
6213
6083
|
if (element.parentElement.querySelectorAll(element.tagName).length > 1) {
|
|
6214
|
-
let index = Array.prototype.indexOf.call(element.parentElement.children, element) +
|
|
6215
|
-
|
|
6216
|
-
selector +=
|
|
6217
|
-
" > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6084
|
+
let index = Array.prototype.indexOf.call(element.parentElement.children, element) + 1;
|
|
6085
|
+
selector += " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6218
6086
|
}
|
|
6219
6087
|
else {
|
|
6220
6088
|
selector += " > " + element.tagName.toLowerCase();
|
|
@@ -6234,9 +6102,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
6234
6102
|
return void 0;
|
|
6235
6103
|
}
|
|
6236
6104
|
if (result.length > 1) {
|
|
6237
|
-
if (result.length === 2 &&
|
|
6238
|
-
typeof result[0] === "object" &&
|
|
6239
|
-
typeof result[1] === "function") {
|
|
6105
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6240
6106
|
let data = result[0];
|
|
6241
6107
|
let handleDataFunc = result[1];
|
|
6242
6108
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6334,9 +6200,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
6334
6200
|
return void 0;
|
|
6335
6201
|
}
|
|
6336
6202
|
if (result.length > 1) {
|
|
6337
|
-
if (result.length === 2 &&
|
|
6338
|
-
typeof result[0] === "object" &&
|
|
6339
|
-
typeof result[1] === "function") {
|
|
6203
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6340
6204
|
let data = result[0];
|
|
6341
6205
|
let handleDataFunc = result[1];
|
|
6342
6206
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6426,12 +6290,10 @@ System.register('Utils', [], (function (exports) {
|
|
|
6426
6290
|
getRandomValue(...args) {
|
|
6427
6291
|
let result = [...args];
|
|
6428
6292
|
if (result.length > 1) {
|
|
6429
|
-
if (result.length === 2 &&
|
|
6430
|
-
typeof result[0] === "number" &&
|
|
6431
|
-
typeof result[1] === "number") {
|
|
6293
|
+
if (result.length === 2 && typeof result[0] === "number" && typeof result[1] === "number") {
|
|
6432
6294
|
let leftNumber = result[0] > result[1] ? result[1] : result[0];
|
|
6433
6295
|
let rightNumber = result[0] > result[1] ? result[0] : result[1];
|
|
6434
|
-
return
|
|
6296
|
+
return Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber;
|
|
6435
6297
|
}
|
|
6436
6298
|
else {
|
|
6437
6299
|
return result[Math.floor(Math.random() * result.length)];
|
|
@@ -6442,8 +6304,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
6442
6304
|
if (Array.isArray(paramData)) {
|
|
6443
6305
|
return paramData[Math.floor(Math.random() * paramData.length)];
|
|
6444
6306
|
}
|
|
6445
|
-
else if (typeof paramData === "object" &&
|
|
6446
|
-
Object.keys(paramData).length > 0) {
|
|
6307
|
+
else if (typeof paramData === "object" && Object.keys(paramData).length > 0) {
|
|
6447
6308
|
let paramObjDataKey = Object.keys(paramData)[Math.floor(Math.random() * Object.keys(paramData).length)];
|
|
6448
6309
|
return paramData[paramObjDataKey];
|
|
6449
6310
|
}
|
|
@@ -6750,11 +6611,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
6750
6611
|
let nearBottomHeight = 50;
|
|
6751
6612
|
let checkWindow = () => {
|
|
6752
6613
|
// 已滚动的距离
|
|
6753
|
-
let scrollTop = this.windowApi.window.pageYOffset ||
|
|
6754
|
-
this.windowApi.document.documentElement.scrollTop;
|
|
6614
|
+
let scrollTop = this.windowApi.window.pageYOffset || this.windowApi.document.documentElement.scrollTop;
|
|
6755
6615
|
// 视窗高度
|
|
6756
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
6757
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6616
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
6758
6617
|
// 最大滚动距离
|
|
6759
6618
|
let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
|
|
6760
6619
|
return scrollTop + viewportHeight >= maxScrollHeight;
|
|
@@ -7043,8 +6902,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7043
6902
|
**/
|
|
7044
6903
|
isNull = commonUtil.isNull.bind(commonUtil);
|
|
7045
6904
|
isThemeDark() {
|
|
7046
|
-
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)")
|
|
7047
|
-
.matches;
|
|
6905
|
+
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
7048
6906
|
}
|
|
7049
6907
|
/**
|
|
7050
6908
|
* 判断元素是否在页面中可见
|
|
@@ -7077,10 +6935,8 @@ System.register('Utils', [], (function (exports) {
|
|
|
7077
6935
|
else {
|
|
7078
6936
|
let domClientRect = domItem.getBoundingClientRect();
|
|
7079
6937
|
if (inView) {
|
|
7080
|
-
let viewportWidth = this.windowApi.window.innerWidth ||
|
|
7081
|
-
|
|
7082
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
7083
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6938
|
+
let viewportWidth = this.windowApi.window.innerWidth || this.windowApi.document.documentElement.clientWidth;
|
|
6939
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
7084
6940
|
result = !(domClientRect.right < 0 ||
|
|
7085
6941
|
domClientRect.left > viewportWidth ||
|
|
7086
6942
|
domClientRect.bottom < 0 ||
|
|
@@ -7104,8 +6960,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7104
6960
|
for (const key in Object.values(this.windowApi.top.window.via)) {
|
|
7105
6961
|
if (Reflect.has(this.windowApi.top.window.via, key)) {
|
|
7106
6962
|
let objValueFunc = this.windowApi.top.window.via[key];
|
|
7107
|
-
if (typeof objValueFunc === "function" &&
|
|
7108
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
6963
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7109
6964
|
result = true;
|
|
7110
6965
|
}
|
|
7111
6966
|
else {
|
|
@@ -7127,8 +6982,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7127
6982
|
for (const key in Object.values(this.windowApi.top.window.mbrowser)) {
|
|
7128
6983
|
if (Reflect.has(this.windowApi.top.window.mbrowser, key)) {
|
|
7129
6984
|
let objValueFunc = this.windowApi.top.window.mbrowser[key];
|
|
7130
|
-
if (typeof objValueFunc === "function" &&
|
|
7131
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
6985
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7132
6986
|
result = true;
|
|
7133
6987
|
}
|
|
7134
6988
|
else {
|
|
@@ -7365,13 +7219,11 @@ System.register('Utils', [], (function (exports) {
|
|
|
7365
7219
|
* 释放所有
|
|
7366
7220
|
*/
|
|
7367
7221
|
function releaseAll() {
|
|
7368
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] !==
|
|
7369
|
-
"undefined") {
|
|
7222
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] !== "undefined") {
|
|
7370
7223
|
/* 已存在 */
|
|
7371
7224
|
return;
|
|
7372
7225
|
}
|
|
7373
|
-
UtilsContext.windowApi.window[needReleaseKey] =
|
|
7374
|
-
UtilsContext.deepClone(needReleaseObject);
|
|
7226
|
+
UtilsContext.windowApi.window[needReleaseKey] = UtilsContext.deepClone(needReleaseObject);
|
|
7375
7227
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7376
7228
|
if (typeof value === "function") {
|
|
7377
7229
|
needReleaseObject[value.name] = () => { };
|
|
@@ -7385,8 +7237,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7385
7237
|
Array.from(functionNameList).forEach((item) => {
|
|
7386
7238
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7387
7239
|
if (typeof value === "function") {
|
|
7388
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7389
|
-
"undefined") {
|
|
7240
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7390
7241
|
UtilsContext.windowApi.window[needReleaseKey] = {};
|
|
7391
7242
|
}
|
|
7392
7243
|
if (item === value.name) {
|
|
@@ -7401,8 +7252,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7401
7252
|
* 恢复所有
|
|
7402
7253
|
*/
|
|
7403
7254
|
function recoveryAll() {
|
|
7404
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7405
|
-
"undefined") {
|
|
7255
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7406
7256
|
/* 未存在 */
|
|
7407
7257
|
return;
|
|
7408
7258
|
}
|
|
@@ -7413,8 +7263,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7413
7263
|
* 恢复单个
|
|
7414
7264
|
*/
|
|
7415
7265
|
function recoveryOne() {
|
|
7416
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7417
|
-
"undefined") {
|
|
7266
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7418
7267
|
/* 未存在 */
|
|
7419
7268
|
return;
|
|
7420
7269
|
}
|
|
@@ -7422,8 +7271,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7422
7271
|
if (UtilsContext.windowApi.window[needReleaseKey][item]) {
|
|
7423
7272
|
needReleaseObject[item] = UtilsContext.windowApi.window[needReleaseKey][item];
|
|
7424
7273
|
Reflect.deleteProperty(UtilsContext.windowApi.window[needReleaseKey], item);
|
|
7425
|
-
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey])
|
|
7426
|
-
.length === 0) {
|
|
7274
|
+
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey]).length === 0) {
|
|
7427
7275
|
Reflect.deleteProperty(window, needReleaseKey);
|
|
7428
7276
|
}
|
|
7429
7277
|
}
|
|
@@ -7680,8 +7528,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7680
7528
|
let copyStatus = false;
|
|
7681
7529
|
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7682
7530
|
console.log(requestPermissionStatus);
|
|
7683
|
-
if (this.hasClipboard() &&
|
|
7684
|
-
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7531
|
+
if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7685
7532
|
try {
|
|
7686
7533
|
copyStatus = await this.copyDataByClipboard();
|
|
7687
7534
|
}
|
|
@@ -7842,11 +7689,8 @@ System.register('Utils', [], (function (exports) {
|
|
|
7842
7689
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
7843
7690
|
return mouseEvent;
|
|
7844
7691
|
}
|
|
7845
|
-
let sliderElement = typeof selector === "string"
|
|
7846
|
-
|
|
7847
|
-
: selector;
|
|
7848
|
-
if (!(sliderElement instanceof Node) ||
|
|
7849
|
-
!(sliderElement instanceof Element)) {
|
|
7692
|
+
let sliderElement = typeof selector === "string" ? domUtils.selector(selector) : selector;
|
|
7693
|
+
if (!(sliderElement instanceof Node) || !(sliderElement instanceof Element)) {
|
|
7850
7694
|
throw new Error("Utils.dragSlider 参数selector 必须为Node/Element类型");
|
|
7851
7695
|
}
|
|
7852
7696
|
let rect = sliderElement.getBoundingClientRect(), x0 = rect.x || rect.left, y0 = rect.y || rect.top, x1 = x0 + offsetX, y1 = y0;
|
|
@@ -7898,17 +7742,14 @@ System.register('Utils', [], (function (exports) {
|
|
|
7898
7742
|
}
|
|
7899
7743
|
sortListByProperty(data, getPropertyValueFunc, sortByDesc = true) {
|
|
7900
7744
|
let UtilsContext = this;
|
|
7901
|
-
if (typeof getPropertyValueFunc !== "function" &&
|
|
7902
|
-
typeof getPropertyValueFunc !== "string") {
|
|
7745
|
+
if (typeof getPropertyValueFunc !== "function" && typeof getPropertyValueFunc !== "string") {
|
|
7903
7746
|
throw new Error("Utils.sortListByProperty 参数 getPropertyValueFunc 必须为 function|string 类型");
|
|
7904
7747
|
}
|
|
7905
7748
|
if (typeof sortByDesc !== "boolean") {
|
|
7906
7749
|
throw new Error("Utils.sortListByProperty 参数 sortByDesc 必须为 boolean 类型");
|
|
7907
7750
|
}
|
|
7908
7751
|
let getObjValue = function (obj) {
|
|
7909
|
-
return typeof getPropertyValueFunc === "string"
|
|
7910
|
-
? obj[getPropertyValueFunc]
|
|
7911
|
-
: getPropertyValueFunc(obj);
|
|
7752
|
+
return typeof getPropertyValueFunc === "string" ? obj[getPropertyValueFunc] : getPropertyValueFunc(obj);
|
|
7912
7753
|
};
|
|
7913
7754
|
/**
|
|
7914
7755
|
* 排序方法
|
|
@@ -7983,8 +7824,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7983
7824
|
if (Array.isArray(data)) {
|
|
7984
7825
|
data.sort(sortFunc);
|
|
7985
7826
|
}
|
|
7986
|
-
else if (data instanceof NodeList ||
|
|
7987
|
-
UtilsContext.isJQuery(data)) {
|
|
7827
|
+
else if (data instanceof NodeList || UtilsContext.isJQuery(data)) {
|
|
7988
7828
|
sortNodeFunc(data, getDataFunc);
|
|
7989
7829
|
result = getDataFunc();
|
|
7990
7830
|
}
|
|
@@ -8177,9 +8017,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8177
8017
|
let parent = UtilsContext.windowApi.document;
|
|
8178
8018
|
// 超时时间
|
|
8179
8019
|
let timeout = 0;
|
|
8180
|
-
if (typeof args[0] !== "string" &&
|
|
8181
|
-
!Array.isArray(args[0]) &&
|
|
8182
|
-
typeof args[0] !== "function") {
|
|
8020
|
+
if (typeof args[0] !== "string" && !Array.isArray(args[0]) && typeof args[0] !== "function") {
|
|
8183
8021
|
throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
|
|
8184
8022
|
}
|
|
8185
8023
|
if (args.length === 1) ;
|
|
@@ -8189,8 +8027,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8189
8027
|
// "div",10000
|
|
8190
8028
|
timeout = secondParam;
|
|
8191
8029
|
}
|
|
8192
|
-
else if (typeof secondParam === "object" &&
|
|
8193
|
-
secondParam instanceof Node) {
|
|
8030
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8194
8031
|
// "div",document
|
|
8195
8032
|
parent = secondParam;
|
|
8196
8033
|
}
|
|
@@ -8276,8 +8113,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8276
8113
|
// "div",10000
|
|
8277
8114
|
timeout = secondParam;
|
|
8278
8115
|
}
|
|
8279
|
-
else if (typeof secondParam === "object" &&
|
|
8280
|
-
secondParam instanceof Node) {
|
|
8116
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8281
8117
|
// "div",document
|
|
8282
8118
|
parent = secondParam;
|
|
8283
8119
|
}
|
|
@@ -8332,8 +8168,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8332
8168
|
// "div",10000
|
|
8333
8169
|
timeout = secondParam;
|
|
8334
8170
|
}
|
|
8335
|
-
else if (typeof secondParam === "object" &&
|
|
8336
|
-
secondParam instanceof Node) {
|
|
8171
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8337
8172
|
// "div",document
|
|
8338
8173
|
parent = secondParam;
|
|
8339
8174
|
}
|
|
@@ -8419,8 +8254,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8419
8254
|
// "div",10000
|
|
8420
8255
|
timeout = secondParam;
|
|
8421
8256
|
}
|
|
8422
|
-
else if (typeof secondParam === "object" &&
|
|
8423
|
-
secondParam instanceof Node) {
|
|
8257
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8424
8258
|
// "div",document
|
|
8425
8259
|
parent = secondParam;
|
|
8426
8260
|
}
|
|
@@ -8553,8 +8387,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8553
8387
|
return flag;
|
|
8554
8388
|
}
|
|
8555
8389
|
watchObject(target, propertyName, getCallBack, setCallBack) {
|
|
8556
|
-
if (typeof getCallBack !== "function" &&
|
|
8557
|
-
typeof setCallBack !== "function") {
|
|
8390
|
+
if (typeof getCallBack !== "function" && typeof setCallBack !== "function") {
|
|
8558
8391
|
return;
|
|
8559
8392
|
}
|
|
8560
8393
|
if (typeof getCallBack === "function") {
|
|
@@ -8606,13 +8439,27 @@ System.register('Utils', [], (function (exports) {
|
|
|
8606
8439
|
return;
|
|
8607
8440
|
}
|
|
8608
8441
|
let handleResult = handler(target);
|
|
8609
|
-
if (handleResult &&
|
|
8610
|
-
typeof handleResult.isFind === "boolean" &&
|
|
8611
|
-
handleResult.isFind) {
|
|
8442
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8612
8443
|
return handleResult.data;
|
|
8613
8444
|
}
|
|
8614
8445
|
return this.queryProperty(handleResult.data, handler);
|
|
8615
8446
|
}
|
|
8447
|
+
/**
|
|
8448
|
+
* 异步-深度获取对象属性
|
|
8449
|
+
* @param target 待获取的对象
|
|
8450
|
+
* @param handler 获取属性的回调
|
|
8451
|
+
*/
|
|
8452
|
+
async asyncQueryProperty(target, handler) {
|
|
8453
|
+
if (target == null) {
|
|
8454
|
+
// @ts-ignore
|
|
8455
|
+
return;
|
|
8456
|
+
}
|
|
8457
|
+
let handleResult = await handler(target);
|
|
8458
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8459
|
+
return handleResult.data;
|
|
8460
|
+
}
|
|
8461
|
+
return await this.asyncQueryProperty(handleResult.data, handler);
|
|
8462
|
+
}
|
|
8616
8463
|
/**
|
|
8617
8464
|
* 创建一个新的Utils实例
|
|
8618
8465
|
* @param option
|
|
@@ -8717,7 +8564,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8717
8564
|
return setTimeout$1(callback, timeout);
|
|
8718
8565
|
}
|
|
8719
8566
|
catch (error) {
|
|
8720
|
-
return
|
|
8567
|
+
return this.windowApi.setTimeout(callback, timeout);
|
|
8721
8568
|
}
|
|
8722
8569
|
}
|
|
8723
8570
|
/**
|
|
@@ -8733,7 +8580,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8733
8580
|
catch (error) {
|
|
8734
8581
|
}
|
|
8735
8582
|
finally {
|
|
8736
|
-
|
|
8583
|
+
this.windowApi.clearTimeout(timeId);
|
|
8737
8584
|
}
|
|
8738
8585
|
}
|
|
8739
8586
|
/**
|
|
@@ -8746,7 +8593,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8746
8593
|
return setInterval(callback, timeout);
|
|
8747
8594
|
}
|
|
8748
8595
|
catch (error) {
|
|
8749
|
-
return
|
|
8596
|
+
return this.windowApi.setInterval(callback, timeout);
|
|
8750
8597
|
}
|
|
8751
8598
|
}
|
|
8752
8599
|
/**
|
|
@@ -8762,7 +8609,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8762
8609
|
catch (error) {
|
|
8763
8610
|
}
|
|
8764
8611
|
finally {
|
|
8765
|
-
|
|
8612
|
+
this.windowApi.clearInterval(timeId);
|
|
8766
8613
|
}
|
|
8767
8614
|
}
|
|
8768
8615
|
/**
|