@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.amd.js
CHANGED
|
@@ -67,11 +67,7 @@ define((function () { 'use strict';
|
|
|
67
67
|
!validPattern.test(greenValue.toString()) ||
|
|
68
68
|
!validPattern.test(blueValue.toString()))
|
|
69
69
|
throw new TypeError("输入错误的rgb颜色值");
|
|
70
|
-
let hexs = [
|
|
71
|
-
redValue.toString(16),
|
|
72
|
-
greenValue.toString(16),
|
|
73
|
-
blueValue.toString(16),
|
|
74
|
-
];
|
|
70
|
+
let hexs = [redValue.toString(16), greenValue.toString(16), blueValue.toString(16)];
|
|
75
71
|
for (let index = 0; index < 3; index++)
|
|
76
72
|
if (hexs[index].length == 1)
|
|
77
73
|
hexs[index] = "0" + hexs[index];
|
|
@@ -119,10 +115,7 @@ define((function () { 'use strict';
|
|
|
119
115
|
this.#data = dataText.match(/..../g);
|
|
120
116
|
for (let i = 0x81; i <= 0xfe; i++) {
|
|
121
117
|
for (let j = 0x40; j <= 0xfe; j++) {
|
|
122
|
-
this.#U2Ghash[this.#data[index++]] = ("%" +
|
|
123
|
-
i.toString(16) +
|
|
124
|
-
"%" +
|
|
125
|
-
j.toString(16)).toUpperCase();
|
|
118
|
+
this.#U2Ghash[this.#data[index++]] = ("%" + i.toString(16) + "%" + j.toString(16)).toUpperCase();
|
|
126
119
|
}
|
|
127
120
|
}
|
|
128
121
|
for (let key in this.#U2Ghash) {
|
|
@@ -250,9 +243,7 @@ define((function () { 'use strict';
|
|
|
250
243
|
callbackFunction = callback;
|
|
251
244
|
context = __context__ || this;
|
|
252
245
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
253
|
-
return result !== void 0
|
|
254
|
-
? result
|
|
255
|
-
: TryCatchCore;
|
|
246
|
+
return result !== void 0 ? result : TryCatchCore;
|
|
256
247
|
},
|
|
257
248
|
};
|
|
258
249
|
/**
|
|
@@ -281,10 +272,7 @@ define((function () { 'use strict';
|
|
|
281
272
|
}
|
|
282
273
|
if (handleErrorFunc) {
|
|
283
274
|
if (typeof handleErrorFunc === "string") {
|
|
284
|
-
result = new Function(handleErrorFunc).apply(funcThis, [
|
|
285
|
-
...args,
|
|
286
|
-
error,
|
|
287
|
-
]);
|
|
275
|
+
result = new Function(handleErrorFunc).apply(funcThis, [...args, error]);
|
|
288
276
|
}
|
|
289
277
|
else {
|
|
290
278
|
result = handleErrorFunc.apply(funcThis, [...args, error]);
|
|
@@ -372,10 +360,7 @@ define((function () { 'use strict';
|
|
|
372
360
|
itemResult = objItem === 0;
|
|
373
361
|
break;
|
|
374
362
|
case "string":
|
|
375
|
-
itemResult =
|
|
376
|
-
objItem.trim() === "" ||
|
|
377
|
-
objItem === "null" ||
|
|
378
|
-
objItem === "undefined";
|
|
363
|
+
itemResult = objItem.trim() === "" || objItem === "null" || objItem === "undefined";
|
|
379
364
|
break;
|
|
380
365
|
case "boolean":
|
|
381
366
|
itemResult = !objItem;
|
|
@@ -416,8 +401,7 @@ define((function () { 'use strict';
|
|
|
416
401
|
return null;
|
|
417
402
|
let clone = obj instanceof Array ? [] : {};
|
|
418
403
|
for (const [key, value] of Object.entries(obj)) {
|
|
419
|
-
clone[key] =
|
|
420
|
-
typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
404
|
+
clone[key] = typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
421
405
|
}
|
|
422
406
|
return clone;
|
|
423
407
|
}
|
|
@@ -735,13 +719,13 @@ define((function () { 'use strict';
|
|
|
735
719
|
// ==UserScript==
|
|
736
720
|
// @name ajaxHooker
|
|
737
721
|
// @author cxxjackie
|
|
738
|
-
// @version 1.4.
|
|
722
|
+
// @version 1.4.8
|
|
739
723
|
// @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
740
724
|
// @license GNU LGPL-3.0
|
|
741
725
|
// ==/UserScript==
|
|
742
726
|
|
|
743
727
|
const ajaxHooker = function () {
|
|
744
|
-
const version = "1.4.
|
|
728
|
+
const version = "1.4.8";
|
|
745
729
|
const hookInst = {
|
|
746
730
|
hookFns: [],
|
|
747
731
|
filters: [],
|
|
@@ -770,11 +754,7 @@ define((function () { 'use strict';
|
|
|
770
754
|
const emptyFn = () => {};
|
|
771
755
|
const errorFn = (e) => console.error(e);
|
|
772
756
|
function isThenable(obj) {
|
|
773
|
-
return (
|
|
774
|
-
obj &&
|
|
775
|
-
["object", "function"].includes(typeof obj) &&
|
|
776
|
-
typeof obj.then === "function"
|
|
777
|
-
);
|
|
757
|
+
return obj && ["object", "function"].includes(typeof obj) && typeof obj.then === "function";
|
|
778
758
|
}
|
|
779
759
|
function catchError(fn, ...args) {
|
|
780
760
|
try {
|
|
@@ -812,8 +792,7 @@ define((function () { 'use strict';
|
|
|
812
792
|
const [header, value] = line.split(/(?<=^[^:]+)\s*:\s*/);
|
|
813
793
|
if (!value) continue;
|
|
814
794
|
const lheader = header.toLowerCase();
|
|
815
|
-
headers[lheader] =
|
|
816
|
-
lheader in headers ? `${headers[lheader]}, ${value}` : value;
|
|
795
|
+
headers[lheader] = lheader in headers ? `${headers[lheader]}, ${value}` : value;
|
|
817
796
|
}
|
|
818
797
|
break;
|
|
819
798
|
case "[object Headers]":
|
|
@@ -851,11 +830,9 @@ define((function () { 'use strict';
|
|
|
851
830
|
!filters.find((obj) => {
|
|
852
831
|
switch (true) {
|
|
853
832
|
case obj.type && obj.type !== type:
|
|
854
|
-
case getType(obj.url) === "[object String]" &&
|
|
855
|
-
!url.includes(obj.url):
|
|
833
|
+
case getType(obj.url) === "[object String]" && !url.includes(obj.url):
|
|
856
834
|
case getType(obj.url) === "[object RegExp]" && !obj.url.test(url):
|
|
857
|
-
case obj.method &&
|
|
858
|
-
obj.method.toUpperCase() !== method.toUpperCase():
|
|
835
|
+
case obj.method && obj.method.toUpperCase() !== method.toUpperCase():
|
|
859
836
|
case "async" in obj && obj.async !== async:
|
|
860
837
|
return false;
|
|
861
838
|
}
|
|
@@ -868,8 +845,7 @@ define((function () { 'use strict';
|
|
|
868
845
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
869
846
|
if (this.shouldFilter(filters)) return;
|
|
870
847
|
hookFns.forEach((fn) => {
|
|
871
|
-
if (getType(fn) === "[object Function]")
|
|
872
|
-
catchError(fn, this.request);
|
|
848
|
+
if (getType(fn) === "[object Function]") catchError(fn, this.request);
|
|
873
849
|
});
|
|
874
850
|
for (const key in this.request) {
|
|
875
851
|
if (isThenable(this.request[key])) this._recoverRequestKey(key);
|
|
@@ -882,93 +858,72 @@ define((function () { 'use strict';
|
|
|
882
858
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
883
859
|
if (this.shouldFilter(filters)) return;
|
|
884
860
|
promises.push(
|
|
885
|
-
Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
(val) => (this.request[key] = val),
|
|
894
|
-
() => this._recoverRequestKey(key)
|
|
895
|
-
)
|
|
861
|
+
Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(() => {
|
|
862
|
+
const requestKeys = [];
|
|
863
|
+
for (const key in this.request) !ignoreKeys.has(key) && requestKeys.push(key);
|
|
864
|
+
return Promise.all(
|
|
865
|
+
requestKeys.map((key) =>
|
|
866
|
+
Promise.resolve(this.request[key]).then(
|
|
867
|
+
(val) => (this.request[key] = val),
|
|
868
|
+
() => this._recoverRequestKey(key)
|
|
896
869
|
)
|
|
897
|
-
)
|
|
898
|
-
|
|
899
|
-
)
|
|
870
|
+
)
|
|
871
|
+
);
|
|
872
|
+
})
|
|
900
873
|
);
|
|
901
874
|
});
|
|
902
875
|
return Promise.all(promises);
|
|
903
876
|
}
|
|
904
877
|
waitForResponseKeys(response) {
|
|
905
|
-
const responseKeys =
|
|
906
|
-
this.request.type === "xhr" ? xhrResponses : fetchResponses;
|
|
878
|
+
const responseKeys = this.request.type === "xhr" ? xhrResponses : fetchResponses;
|
|
907
879
|
if (!this.request.async) {
|
|
908
880
|
if (getType(this.request.response) === "[object Function]") {
|
|
909
881
|
catchError(this.request.response, response);
|
|
910
882
|
responseKeys.forEach((key) => {
|
|
911
|
-
if (
|
|
912
|
-
"get" in getDescriptor(response, key) ||
|
|
913
|
-
isThenable(response[key])
|
|
914
|
-
) {
|
|
883
|
+
if ("get" in getDescriptor(response, key) || isThenable(response[key])) {
|
|
915
884
|
delete response[key];
|
|
916
885
|
}
|
|
917
886
|
});
|
|
918
887
|
}
|
|
919
888
|
return new SyncThenable();
|
|
920
889
|
}
|
|
921
|
-
return Promise.resolve(catchError(this.request.response, response)).then(
|
|
922
|
-
(
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
)
|
|
890
|
+
return Promise.resolve(catchError(this.request.response, response)).then(() =>
|
|
891
|
+
Promise.all(
|
|
892
|
+
responseKeys.map((key) => {
|
|
893
|
+
const descriptor = getDescriptor(response, key);
|
|
894
|
+
if (descriptor && "value" in descriptor) {
|
|
895
|
+
return Promise.resolve(descriptor.value).then(
|
|
896
|
+
(val) => (response[key] = val),
|
|
897
|
+
() => delete response[key]
|
|
898
|
+
);
|
|
899
|
+
} else {
|
|
900
|
+
delete response[key];
|
|
901
|
+
}
|
|
902
|
+
})
|
|
903
|
+
)
|
|
936
904
|
);
|
|
937
905
|
}
|
|
938
906
|
}
|
|
939
907
|
const proxyHandler = {
|
|
940
908
|
get(target, prop) {
|
|
941
909
|
const descriptor = getDescriptor(target, prop);
|
|
942
|
-
if (
|
|
943
|
-
descriptor &&
|
|
944
|
-
!descriptor.configurable &&
|
|
945
|
-
!descriptor.writable &&
|
|
946
|
-
!descriptor.get
|
|
947
|
-
)
|
|
910
|
+
if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.get)
|
|
948
911
|
return target[prop];
|
|
949
912
|
const ah = target.__ajaxHooker;
|
|
950
913
|
if (ah && ah.proxyProps) {
|
|
951
914
|
if (prop in ah.proxyProps) {
|
|
952
915
|
const pDescriptor = ah.proxyProps[prop];
|
|
953
916
|
if ("get" in pDescriptor) return pDescriptor.get();
|
|
954
|
-
if (typeof pDescriptor.value === "function")
|
|
955
|
-
return pDescriptor.value.bind(ah);
|
|
917
|
+
if (typeof pDescriptor.value === "function") return pDescriptor.value.bind(ah);
|
|
956
918
|
return pDescriptor.value;
|
|
957
919
|
}
|
|
958
|
-
if (typeof target[prop] === "function")
|
|
959
|
-
return target[prop].bind(target);
|
|
920
|
+
if (typeof target[prop] === "function") return target[prop].bind(target);
|
|
960
921
|
}
|
|
961
922
|
return target[prop];
|
|
962
923
|
},
|
|
963
924
|
set(target, prop, value) {
|
|
964
925
|
const descriptor = getDescriptor(target, prop);
|
|
965
|
-
if (
|
|
966
|
-
descriptor &&
|
|
967
|
-
!descriptor.configurable &&
|
|
968
|
-
!descriptor.writable &&
|
|
969
|
-
!descriptor.set
|
|
970
|
-
)
|
|
971
|
-
return true;
|
|
926
|
+
if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.set) return true;
|
|
972
927
|
const ah = target.__ajaxHooker;
|
|
973
928
|
if (ah && ah.proxyProps && prop in ah.proxyProps) {
|
|
974
929
|
const pDescriptor = ah.proxyProps[prop];
|
|
@@ -990,11 +945,7 @@ define((function () { 'use strict';
|
|
|
990
945
|
proxyEvents: {},
|
|
991
946
|
});
|
|
992
947
|
xhr.addEventListener("readystatechange", (e) => {
|
|
993
|
-
if (
|
|
994
|
-
ah.proxyXhr.readyState === 4 &&
|
|
995
|
-
ah.request &&
|
|
996
|
-
typeof ah.request.response === "function"
|
|
997
|
-
) {
|
|
948
|
+
if (ah.proxyXhr.readyState === 4 && ah.request && typeof ah.request.response === "function") {
|
|
998
949
|
const response = {
|
|
999
950
|
finalUrl: ah.proxyXhr.responseURL,
|
|
1000
951
|
status: ah.proxyXhr.status,
|
|
@@ -1017,18 +968,16 @@ define((function () { 'use strict';
|
|
|
1017
968
|
}
|
|
1018
969
|
);
|
|
1019
970
|
}
|
|
1020
|
-
ah.resThenable = new AHRequest(ah.request)
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
}
|
|
1031
|
-
});
|
|
971
|
+
ah.resThenable = new AHRequest(ah.request).waitForResponseKeys(response).then(() => {
|
|
972
|
+
for (const key of xhrResponses) {
|
|
973
|
+
ah.proxyProps[key] = {
|
|
974
|
+
get: () => {
|
|
975
|
+
if (!(key in response)) response[key] = tempValues[key];
|
|
976
|
+
return response[key];
|
|
977
|
+
},
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
});
|
|
1032
981
|
}
|
|
1033
982
|
ah.dispatchEvent(e);
|
|
1034
983
|
});
|
|
@@ -1041,13 +990,7 @@ define((function () { 'use strict';
|
|
|
1041
990
|
set: (val) => ah.addEvent(onEvt, val),
|
|
1042
991
|
};
|
|
1043
992
|
}
|
|
1044
|
-
for (const method of [
|
|
1045
|
-
"setRequestHeader",
|
|
1046
|
-
"addEventListener",
|
|
1047
|
-
"removeEventListener",
|
|
1048
|
-
"open",
|
|
1049
|
-
"send",
|
|
1050
|
-
]) {
|
|
993
|
+
for (const method of ["setRequestHeader", "addEventListener", "removeEventListener", "open", "send"]) {
|
|
1051
994
|
ah.proxyProps[method] = { value: ah[method] };
|
|
1052
995
|
}
|
|
1053
996
|
}
|
|
@@ -1056,8 +999,7 @@ define((function () { 'use strict';
|
|
|
1056
999
|
if (type.startsWith("on")) {
|
|
1057
1000
|
this.proxyEvents[type] = typeof event === "function" ? event : null;
|
|
1058
1001
|
} else {
|
|
1059
|
-
if (typeof event === "object" && event !== null)
|
|
1060
|
-
event = event.handleEvent;
|
|
1002
|
+
if (typeof event === "object" && event !== null) event = event.handleEvent;
|
|
1061
1003
|
if (typeof event !== "function") return;
|
|
1062
1004
|
this.proxyEvents[type] = this.proxyEvents[type] || new Set();
|
|
1063
1005
|
this.proxyEvents[type].add(event);
|
|
@@ -1067,8 +1009,7 @@ define((function () { 'use strict';
|
|
|
1067
1009
|
if (type.startsWith("on")) {
|
|
1068
1010
|
this.proxyEvents[type] = null;
|
|
1069
1011
|
} else {
|
|
1070
|
-
if (typeof event === "object" && event !== null)
|
|
1071
|
-
event = event.handleEvent;
|
|
1012
|
+
if (typeof event === "object" && event !== null) event = event.handleEvent;
|
|
1072
1013
|
this.proxyEvents[type] && this.proxyEvents[type].delete(event);
|
|
1073
1014
|
}
|
|
1074
1015
|
}
|
|
@@ -1079,9 +1020,7 @@ define((function () { 'use strict';
|
|
|
1079
1020
|
defineProp(e, "srcElement", () => this.proxyXhr);
|
|
1080
1021
|
this.proxyEvents[e.type] &&
|
|
1081
1022
|
this.proxyEvents[e.type].forEach((fn) => {
|
|
1082
|
-
this.resThenable.then(
|
|
1083
|
-
() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e)
|
|
1084
|
-
);
|
|
1023
|
+
this.resThenable.then(() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e));
|
|
1085
1024
|
});
|
|
1086
1025
|
if (e.ajaxHooker_isStopped) return;
|
|
1087
1026
|
const onEvent = this.proxyEvents["on" + e.type];
|
|
@@ -1091,8 +1030,7 @@ define((function () { 'use strict';
|
|
|
1091
1030
|
this.originalXhr.setRequestHeader(header, value);
|
|
1092
1031
|
if (!this.request) return;
|
|
1093
1032
|
const headers = this.request.headers;
|
|
1094
|
-
headers[header] =
|
|
1095
|
-
header in headers ? `${headers[header]}, ${value}` : value;
|
|
1033
|
+
headers[header] = header in headers ? `${headers[header]}, ${value}` : value;
|
|
1096
1034
|
}
|
|
1097
1035
|
addEventListener(...args) {
|
|
1098
1036
|
if (xhrAsyncEvents.includes(args[0])) {
|
|
@@ -1121,13 +1059,7 @@ define((function () { 'use strict';
|
|
|
1121
1059
|
};
|
|
1122
1060
|
this.openArgs = args;
|
|
1123
1061
|
this.resThenable = new SyncThenable();
|
|
1124
|
-
[
|
|
1125
|
-
"responseURL",
|
|
1126
|
-
"readyState",
|
|
1127
|
-
"status",
|
|
1128
|
-
"statusText",
|
|
1129
|
-
...xhrResponses,
|
|
1130
|
-
].forEach((key) => {
|
|
1062
|
+
["responseURL", "readyState", "status", "statusText", ...xhrResponses].forEach((key) => {
|
|
1131
1063
|
delete this.proxyProps[key];
|
|
1132
1064
|
});
|
|
1133
1065
|
return this.originalXhr.open(method, url, async, ...args);
|
|
@@ -1164,15 +1096,12 @@ define((function () { 'use strict';
|
|
|
1164
1096
|
}
|
|
1165
1097
|
function fakeXHR() {
|
|
1166
1098
|
const xhr = new winAh.realXHR();
|
|
1167
|
-
if ("__ajaxHooker" in xhr)
|
|
1168
|
-
console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1099
|
+
if ("__ajaxHooker" in xhr) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1169
1100
|
xhr.__ajaxHooker = new XhrHooker(xhr);
|
|
1170
1101
|
return xhr.__ajaxHooker.proxyXhr;
|
|
1171
1102
|
}
|
|
1172
1103
|
fakeXHR.prototype = win.XMLHttpRequest.prototype;
|
|
1173
|
-
Object.keys(win.XMLHttpRequest).forEach(
|
|
1174
|
-
(key) => (fakeXHR[key] = win.XMLHttpRequest[key])
|
|
1175
|
-
);
|
|
1104
|
+
Object.keys(win.XMLHttpRequest).forEach((key) => (fakeXHR[key] = win.XMLHttpRequest[key]));
|
|
1176
1105
|
function fakeFetch(url, options = {}) {
|
|
1177
1106
|
if (!url) return winAh.realFetch.call(win, url, options);
|
|
1178
1107
|
return new Promise(async (resolve, reject) => {
|
|
@@ -1238,18 +1167,22 @@ define((function () { 'use strict';
|
|
|
1238
1167
|
status: res.status,
|
|
1239
1168
|
responseHeaders: parseHeaders(res.headers),
|
|
1240
1169
|
};
|
|
1241
|
-
|
|
1242
|
-
(
|
|
1243
|
-
(
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1170
|
+
if (res.ok) {
|
|
1171
|
+
fetchResponses.forEach(
|
|
1172
|
+
(key) =>
|
|
1173
|
+
(res[key] = function () {
|
|
1174
|
+
if (key in response) return Promise.resolve(response[key]);
|
|
1175
|
+
return resProto[key].call(this).then((val) => {
|
|
1176
|
+
response[key] = val;
|
|
1177
|
+
return req
|
|
1178
|
+
.waitForResponseKeys(response)
|
|
1179
|
+
.then(() => (key in response ? response[key] : val));
|
|
1180
|
+
});
|
|
1181
|
+
})
|
|
1182
|
+
);
|
|
1183
|
+
} else {
|
|
1184
|
+
catchError(request.response, response);
|
|
1185
|
+
}
|
|
1253
1186
|
}
|
|
1254
1187
|
resolve(res);
|
|
1255
1188
|
}, reject);
|
|
@@ -1271,8 +1204,7 @@ define((function () { 'use strict';
|
|
|
1271
1204
|
realFetchClone: resProto.clone,
|
|
1272
1205
|
hookInsts: new Set(),
|
|
1273
1206
|
};
|
|
1274
|
-
if (winAh.version !== version)
|
|
1275
|
-
console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1207
|
+
if (winAh.version !== version) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1276
1208
|
win.XMLHttpRequest = winAh.fakeXHR;
|
|
1277
1209
|
win.fetch = winAh.fakeFetch;
|
|
1278
1210
|
resProto.clone = winAh.fakeFetchClone;
|
|
@@ -1280,37 +1212,25 @@ define((function () { 'use strict';
|
|
|
1280
1212
|
// 针对头条、抖音 secsdk.umd.js 的兼容性处理
|
|
1281
1213
|
class AHFunction extends Function {
|
|
1282
1214
|
call(thisArg, ...args) {
|
|
1283
|
-
if (
|
|
1284
|
-
thisArg &&
|
|
1285
|
-
thisArg.__ajaxHooker &&
|
|
1286
|
-
thisArg.__ajaxHooker.proxyXhr === thisArg
|
|
1287
|
-
) {
|
|
1215
|
+
if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) {
|
|
1288
1216
|
thisArg = thisArg.__ajaxHooker.originalXhr;
|
|
1289
1217
|
}
|
|
1290
1218
|
return Reflect.apply(this, thisArg, args);
|
|
1291
1219
|
}
|
|
1292
1220
|
apply(thisArg, args) {
|
|
1293
|
-
if (
|
|
1294
|
-
thisArg &&
|
|
1295
|
-
thisArg.__ajaxHooker &&
|
|
1296
|
-
thisArg.__ajaxHooker.proxyXhr === thisArg
|
|
1297
|
-
) {
|
|
1221
|
+
if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) {
|
|
1298
1222
|
thisArg = thisArg.__ajaxHooker.originalXhr;
|
|
1299
1223
|
}
|
|
1300
1224
|
return Reflect.apply(this, thisArg, args || []);
|
|
1301
1225
|
}
|
|
1302
1226
|
}
|
|
1303
1227
|
function hookSecsdk(csrf) {
|
|
1304
|
-
Object.setPrototypeOf(
|
|
1305
|
-
csrf.nativeXMLHttpRequestSetRequestHeader,
|
|
1306
|
-
AHFunction.prototype
|
|
1307
|
-
);
|
|
1228
|
+
Object.setPrototypeOf(csrf.nativeXMLHttpRequestSetRequestHeader, AHFunction.prototype);
|
|
1308
1229
|
Object.setPrototypeOf(csrf.nativeXMLHttpRequestOpen, AHFunction.prototype);
|
|
1309
1230
|
Object.setPrototypeOf(csrf.nativeXMLHttpRequestSend, AHFunction.prototype);
|
|
1310
1231
|
}
|
|
1311
1232
|
if (win.secsdk) {
|
|
1312
|
-
if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen)
|
|
1313
|
-
hookSecsdk(win.secsdk.csrf);
|
|
1233
|
+
if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen) hookSecsdk(win.secsdk.csrf);
|
|
1314
1234
|
} else {
|
|
1315
1235
|
defineProp(win, "secsdk", emptyFn, (secsdk) => {
|
|
1316
1236
|
delete win.secsdk;
|
|
@@ -1956,14 +1876,10 @@ define((function () { 'use strict';
|
|
|
1956
1876
|
// };
|
|
1957
1877
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1958
1878
|
menuOption.autoReload =
|
|
1959
|
-
typeof menuOption.autoReload !== "boolean"
|
|
1960
|
-
? this.$default.autoReload
|
|
1961
|
-
: menuOption.autoReload;
|
|
1879
|
+
typeof menuOption.autoReload !== "boolean" ? this.$default.autoReload : menuOption.autoReload;
|
|
1962
1880
|
/* 点击菜单后触发callback后的网页是否存储值 */
|
|
1963
1881
|
menuOption.isStoreValue =
|
|
1964
|
-
typeof menuOption.isStoreValue !== "boolean"
|
|
1965
|
-
? this.$default.isStoreValue
|
|
1966
|
-
: menuOption.isStoreValue;
|
|
1882
|
+
typeof menuOption.isStoreValue !== "boolean" ? this.$default.isStoreValue : menuOption.isStoreValue;
|
|
1967
1883
|
/**
|
|
1968
1884
|
* 用户点击菜单后的回调函数
|
|
1969
1885
|
* @param event
|
|
@@ -2016,8 +1932,7 @@ define((function () { 'use strict';
|
|
|
2016
1932
|
* @param menuKey 菜单-键key
|
|
2017
1933
|
*/
|
|
2018
1934
|
getMenuHandledOption(menuKey) {
|
|
2019
|
-
return this.$data.data.find((item) => item.handleData.key === menuKey)
|
|
2020
|
-
?.handleData;
|
|
1935
|
+
return this.$data.data.find((item) => item.handleData.key === menuKey)?.handleData;
|
|
2021
1936
|
},
|
|
2022
1937
|
};
|
|
2023
1938
|
constructor(details) {
|
|
@@ -2025,8 +1940,7 @@ define((function () { 'use strict';
|
|
|
2025
1940
|
this.GM_Api.setValue = details.GM_setValue;
|
|
2026
1941
|
this.GM_Api.registerMenuCommand = details.GM_registerMenuCommand;
|
|
2027
1942
|
this.GM_Api.unregisterMenuCommand = details.GM_unregisterMenuCommand;
|
|
2028
|
-
this.MenuHandle.$default.autoReload =
|
|
2029
|
-
typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
1943
|
+
this.MenuHandle.$default.autoReload = typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
2030
1944
|
for (const keyName of Object.keys(this.GM_Api)) {
|
|
2031
1945
|
if (typeof this.GM_Api[keyName] !== "function") {
|
|
2032
1946
|
throw new Error(`Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`);
|
|
@@ -2258,8 +2172,7 @@ define((function () { 'use strict';
|
|
|
2258
2172
|
_context = context || window;
|
|
2259
2173
|
_funcName = getFuncName(this);
|
|
2260
2174
|
_context["realFunc_" + _funcName] = this;
|
|
2261
|
-
if (_context[_funcName].prototype &&
|
|
2262
|
-
_context[_funcName].prototype.isHooked) {
|
|
2175
|
+
if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
|
|
2263
2176
|
console.log("Already has been hooked,unhook first");
|
|
2264
2177
|
return false;
|
|
2265
2178
|
}
|
|
@@ -2437,8 +2350,7 @@ define((function () { 'use strict';
|
|
|
2437
2350
|
if (details.allowInterceptConfig != null) {
|
|
2438
2351
|
// 配置存在
|
|
2439
2352
|
// 细分处理是否拦截
|
|
2440
|
-
if (typeof details.allowInterceptConfig.afterResponseSuccess ===
|
|
2441
|
-
"boolean" &&
|
|
2353
|
+
if (typeof details.allowInterceptConfig.afterResponseSuccess === "boolean" &&
|
|
2442
2354
|
!details.allowInterceptConfig.afterResponseSuccess) {
|
|
2443
2355
|
// 设置了禁止拦截
|
|
2444
2356
|
return details;
|
|
@@ -2473,8 +2385,7 @@ define((function () { 'use strict';
|
|
|
2473
2385
|
if (data.details.allowInterceptConfig != null) {
|
|
2474
2386
|
// 配置存在
|
|
2475
2387
|
// 细分处理是否拦截
|
|
2476
|
-
if (typeof data.details.allowInterceptConfig.afterResponseError ===
|
|
2477
|
-
"boolean" &&
|
|
2388
|
+
if (typeof data.details.allowInterceptConfig.afterResponseError === "boolean" &&
|
|
2478
2389
|
!data.details.allowInterceptConfig.afterResponseError) {
|
|
2479
2390
|
// 设置了禁止拦截
|
|
2480
2391
|
return data;
|
|
@@ -2576,44 +2487,31 @@ define((function () { 'use strict';
|
|
|
2576
2487
|
let requestOption = {
|
|
2577
2488
|
url: url,
|
|
2578
2489
|
method: (method || "GET").toString().toUpperCase().trim(),
|
|
2579
|
-
timeout: userRequestOption.timeout ||
|
|
2580
|
-
|
|
2581
|
-
responseType: userRequestOption.responseType ||
|
|
2582
|
-
this.context.#defaultRequestOption.responseType,
|
|
2490
|
+
timeout: userRequestOption.timeout || this.context.#defaultRequestOption.timeout,
|
|
2491
|
+
responseType: userRequestOption.responseType || this.context.#defaultRequestOption.responseType,
|
|
2583
2492
|
/* 对象使用深拷贝 */
|
|
2584
2493
|
headers: commonUtil.deepClone(this.context.#defaultRequestOption.headers),
|
|
2585
2494
|
data: userRequestOption.data || this.context.#defaultRequestOption.data,
|
|
2586
|
-
redirect: userRequestOption.redirect ||
|
|
2587
|
-
this.context.#defaultRequestOption.redirect,
|
|
2495
|
+
redirect: userRequestOption.redirect || this.context.#defaultRequestOption.redirect,
|
|
2588
2496
|
cookie: userRequestOption.cookie || this.context.#defaultRequestOption.cookie,
|
|
2589
|
-
cookiePartition: userRequestOption.cookiePartition ||
|
|
2590
|
-
this.context.#defaultRequestOption.cookiePartition,
|
|
2497
|
+
cookiePartition: userRequestOption.cookiePartition || this.context.#defaultRequestOption.cookiePartition,
|
|
2591
2498
|
binary: userRequestOption.binary || this.context.#defaultRequestOption.binary,
|
|
2592
|
-
nocache: userRequestOption.nocache ||
|
|
2593
|
-
|
|
2594
|
-
revalidate: userRequestOption.revalidate ||
|
|
2595
|
-
this.context.#defaultRequestOption.revalidate,
|
|
2499
|
+
nocache: userRequestOption.nocache || this.context.#defaultRequestOption.nocache,
|
|
2500
|
+
revalidate: userRequestOption.revalidate || this.context.#defaultRequestOption.revalidate,
|
|
2596
2501
|
/* 对象使用深拷贝 */
|
|
2597
|
-
context: commonUtil.deepClone(userRequestOption.context ||
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
this.context.#defaultRequestOption.overrideMimeType,
|
|
2601
|
-
anonymous: userRequestOption.anonymous ||
|
|
2602
|
-
this.context.#defaultRequestOption.anonymous,
|
|
2502
|
+
context: commonUtil.deepClone(userRequestOption.context || this.context.#defaultRequestOption.context),
|
|
2503
|
+
overrideMimeType: userRequestOption.overrideMimeType || this.context.#defaultRequestOption.overrideMimeType,
|
|
2504
|
+
anonymous: userRequestOption.anonymous || this.context.#defaultRequestOption.anonymous,
|
|
2603
2505
|
fetch: userRequestOption.fetch || this.context.#defaultRequestOption.fetch,
|
|
2604
2506
|
/* 对象使用深拷贝 */
|
|
2605
2507
|
fetchInit: commonUtil.deepClone(this.context.#defaultRequestOption.fetchInit),
|
|
2606
2508
|
allowInterceptConfig: {
|
|
2607
|
-
beforeRequest: this.context.#defaultRequestOption
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
.allowInterceptConfig.afterResponseSuccess,
|
|
2611
|
-
afterResponseError: this.context.#defaultRequestOption
|
|
2612
|
-
.allowInterceptConfig.afterResponseError,
|
|
2509
|
+
beforeRequest: this.context.#defaultRequestOption.allowInterceptConfig.beforeRequest,
|
|
2510
|
+
afterResponseSuccess: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseSuccess,
|
|
2511
|
+
afterResponseError: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseError,
|
|
2613
2512
|
},
|
|
2614
2513
|
user: userRequestOption.user || this.context.#defaultRequestOption.user,
|
|
2615
|
-
password: userRequestOption.password ||
|
|
2616
|
-
this.context.#defaultRequestOption.password,
|
|
2514
|
+
password: userRequestOption.password || this.context.#defaultRequestOption.password,
|
|
2617
2515
|
onabort(...args) {
|
|
2618
2516
|
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2619
2517
|
},
|
|
@@ -2661,14 +2559,12 @@ define((function () { 'use strict';
|
|
|
2661
2559
|
if (typeof requestOption.headers === "object") {
|
|
2662
2560
|
if (typeof userRequestOption.headers === "object") {
|
|
2663
2561
|
Object.keys(userRequestOption.headers).forEach((keyName, index) => {
|
|
2664
|
-
if (keyName in requestOption.headers &&
|
|
2665
|
-
userRequestOption.headers?.[keyName] == null) {
|
|
2562
|
+
if (keyName in requestOption.headers && userRequestOption.headers?.[keyName] == null) {
|
|
2666
2563
|
/* 在默认的header中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2667
2564
|
Reflect.deleteProperty(requestOption.headers, keyName);
|
|
2668
2565
|
}
|
|
2669
2566
|
else {
|
|
2670
|
-
requestOption.headers[keyName] =
|
|
2671
|
-
userRequestOption?.headers?.[keyName];
|
|
2567
|
+
requestOption.headers[keyName] = userRequestOption?.headers?.[keyName];
|
|
2672
2568
|
}
|
|
2673
2569
|
});
|
|
2674
2570
|
}
|
|
@@ -2681,8 +2577,7 @@ define((function () { 'use strict';
|
|
|
2681
2577
|
/* 使用assign替换且添加 */
|
|
2682
2578
|
if (typeof userRequestOption.fetchInit === "object") {
|
|
2683
2579
|
Object.keys(userRequestOption.fetchInit).forEach((keyName, index) => {
|
|
2684
|
-
if (keyName in requestOption.fetchInit &&
|
|
2685
|
-
userRequestOption.fetchInit[keyName] == null) {
|
|
2580
|
+
if (keyName in requestOption.fetchInit && userRequestOption.fetchInit[keyName] == null) {
|
|
2686
2581
|
/* 在默认的fetchInit中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2687
2582
|
Reflect.deleteProperty(requestOption.fetchInit, keyName);
|
|
2688
2583
|
}
|
|
@@ -2696,8 +2591,7 @@ define((function () { 'use strict';
|
|
|
2696
2591
|
Reflect.set(requestOption, "fetchInit", userRequestOption.fetchInit);
|
|
2697
2592
|
}
|
|
2698
2593
|
// 处理新的cookiePartition
|
|
2699
|
-
if (typeof requestOption.cookiePartition === "object" &&
|
|
2700
|
-
requestOption.cookiePartition != null) {
|
|
2594
|
+
if (typeof requestOption.cookiePartition === "object" && requestOption.cookiePartition != null) {
|
|
2701
2595
|
if (Reflect.has(requestOption.cookiePartition, "topLevelSite") &&
|
|
2702
2596
|
typeof requestOption.cookiePartition.topLevelSite !== "string") {
|
|
2703
2597
|
// topLevelSite必须是字符串
|
|
@@ -2719,8 +2613,7 @@ define((function () { 'use strict';
|
|
|
2719
2613
|
}
|
|
2720
2614
|
else {
|
|
2721
2615
|
// 补充origin+/
|
|
2722
|
-
requestOption.url =
|
|
2723
|
-
globalThis.location.origin + "/" + requestOption.url;
|
|
2616
|
+
requestOption.url = globalThis.location.origin + "/" + requestOption.url;
|
|
2724
2617
|
}
|
|
2725
2618
|
}
|
|
2726
2619
|
if (requestOption.fetchInit && !requestOption.fetch) {
|
|
@@ -2844,8 +2737,7 @@ define((function () { 'use strict';
|
|
|
2844
2737
|
* fetch的请求配置
|
|
2845
2738
|
**/
|
|
2846
2739
|
let fetchRequestOption = {};
|
|
2847
|
-
if ((option.method === "GET" || option.method === "HEAD") &&
|
|
2848
|
-
option.data != null) {
|
|
2740
|
+
if ((option.method === "GET" || option.method === "HEAD") && option.data != null) {
|
|
2849
2741
|
/* GET 或 HEAD 方法的请求不能包含 body 信息 */
|
|
2850
2742
|
Reflect.deleteProperty(option, "data");
|
|
2851
2743
|
}
|
|
@@ -3126,8 +3018,7 @@ define((function () { 'use strict';
|
|
|
3126
3018
|
if (typeof details?.onreadystatechange === "function") {
|
|
3127
3019
|
details.onreadystatechange.apply(this, argsResult);
|
|
3128
3020
|
}
|
|
3129
|
-
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3130
|
-
"function") {
|
|
3021
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange === "function") {
|
|
3131
3022
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3132
3023
|
}
|
|
3133
3024
|
},
|
|
@@ -3156,8 +3047,7 @@ define((function () { 'use strict';
|
|
|
3156
3047
|
if (this.context.#defaultInitOption.logDetails) {
|
|
3157
3048
|
console.log("[Httpx-HttpxRequest.request] 请求前的配置👇", details);
|
|
3158
3049
|
}
|
|
3159
|
-
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack ===
|
|
3160
|
-
"function") {
|
|
3050
|
+
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack === "function") {
|
|
3161
3051
|
let hookResult = await this.context.HttpxRequestHook.beforeRequestCallBack(details);
|
|
3162
3052
|
if (hookResult == null) {
|
|
3163
3053
|
return;
|
|
@@ -3213,9 +3103,7 @@ define((function () { 'use strict';
|
|
|
3213
3103
|
/* 如果需要stream,且获取到的是stream,那直接返回 */
|
|
3214
3104
|
if (option.responseType === "stream" ||
|
|
3215
3105
|
(fetchResponse.headers.has("Content-Type") &&
|
|
3216
|
-
fetchResponse.headers
|
|
3217
|
-
.get("Content-Type")
|
|
3218
|
-
.includes("text/event-stream"))) {
|
|
3106
|
+
fetchResponse.headers.get("Content-Type").includes("text/event-stream"))) {
|
|
3219
3107
|
Reflect.set(httpxResponse, "isStream", true);
|
|
3220
3108
|
Reflect.set(httpxResponse, "response", fetchResponse.body);
|
|
3221
3109
|
Reflect.deleteProperty(httpxResponse, "responseText");
|
|
@@ -3234,9 +3122,7 @@ define((function () { 'use strict';
|
|
|
3234
3122
|
/** 数据编码 */
|
|
3235
3123
|
let encoding = "utf-8";
|
|
3236
3124
|
if (fetchResponse.headers.has("Content-Type")) {
|
|
3237
|
-
let charsetMatched = fetchResponse.headers
|
|
3238
|
-
.get("Content-Type")
|
|
3239
|
-
?.match(/charset=(.+)/);
|
|
3125
|
+
let charsetMatched = fetchResponse.headers.get("Content-Type")?.match(/charset=(.+)/);
|
|
3240
3126
|
if (charsetMatched) {
|
|
3241
3127
|
encoding = charsetMatched[1];
|
|
3242
3128
|
encoding = encoding.toLowerCase();
|
|
@@ -3258,13 +3144,11 @@ define((function () { 'use strict';
|
|
|
3258
3144
|
response = new Blob([arrayBuffer]);
|
|
3259
3145
|
}
|
|
3260
3146
|
else if (option.responseType === "json" ||
|
|
3261
|
-
(typeof fetchResponseType === "string" &&
|
|
3262
|
-
fetchResponseType.includes("application/json"))) {
|
|
3147
|
+
(typeof fetchResponseType === "string" && fetchResponseType.includes("application/json"))) {
|
|
3263
3148
|
// response返回格式是JSON格式
|
|
3264
3149
|
response = commonUtil.toJSON(responseText);
|
|
3265
3150
|
}
|
|
3266
|
-
else if (option.responseType === "document" ||
|
|
3267
|
-
option.responseType == null) {
|
|
3151
|
+
else if (option.responseType === "document" || option.responseType == null) {
|
|
3268
3152
|
// response返回格式是文档格式
|
|
3269
3153
|
let parser = new DOMParser();
|
|
3270
3154
|
response = parser.parseFromString(responseText, "text/html");
|
|
@@ -3527,8 +3411,7 @@ define((function () { 'use strict';
|
|
|
3527
3411
|
}
|
|
3528
3412
|
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3529
3413
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3530
|
-
if (requestResult != null &&
|
|
3531
|
-
typeof requestResult.abort === "function") {
|
|
3414
|
+
if (requestResult != null && typeof requestResult.abort === "function") {
|
|
3532
3415
|
abortFn = requestResult.abort;
|
|
3533
3416
|
}
|
|
3534
3417
|
});
|
|
@@ -4019,8 +3902,7 @@ define((function () { 'use strict';
|
|
|
4019
3902
|
if (typeof __GM_info === "string") {
|
|
4020
3903
|
this.tag = __GM_info;
|
|
4021
3904
|
}
|
|
4022
|
-
else if (typeof __GM_info === "object" &&
|
|
4023
|
-
typeof __GM_info?.script?.name === "string") {
|
|
3905
|
+
else if (typeof __GM_info === "object" && typeof __GM_info?.script?.name === "string") {
|
|
4024
3906
|
this.tag = __GM_info.script.name;
|
|
4025
3907
|
}
|
|
4026
3908
|
this.#console = console;
|
|
@@ -4076,8 +3958,7 @@ define((function () { 'use strict';
|
|
|
4076
3958
|
*/
|
|
4077
3959
|
checkClearConsole() {
|
|
4078
3960
|
this.#logCount++;
|
|
4079
|
-
if (this.#details.autoClearConsole &&
|
|
4080
|
-
this.#logCount > this.#details.logMaxCount) {
|
|
3961
|
+
if (this.#details.autoClearConsole && this.#logCount > this.#details.logMaxCount) {
|
|
4081
3962
|
this.#console.clear();
|
|
4082
3963
|
this.#logCount = 0;
|
|
4083
3964
|
}
|
|
@@ -4486,6 +4367,10 @@ define((function () { 'use strict';
|
|
|
4486
4367
|
globalThis: globalThis,
|
|
4487
4368
|
self: self,
|
|
4488
4369
|
top: top,
|
|
4370
|
+
setTimeout: globalThis.setTimeout,
|
|
4371
|
+
setInterval: globalThis.setInterval,
|
|
4372
|
+
clearTimeout: globalThis.clearTimeout,
|
|
4373
|
+
clearInterval: globalThis.clearInterval,
|
|
4489
4374
|
};
|
|
4490
4375
|
/** 使用的配置 */
|
|
4491
4376
|
api;
|
|
@@ -4518,6 +4403,18 @@ define((function () { 'use strict';
|
|
|
4518
4403
|
get top() {
|
|
4519
4404
|
return this.api.top;
|
|
4520
4405
|
}
|
|
4406
|
+
get setTimeout() {
|
|
4407
|
+
return this.api.setTimeout;
|
|
4408
|
+
}
|
|
4409
|
+
get setInterval() {
|
|
4410
|
+
return this.api.setInterval;
|
|
4411
|
+
}
|
|
4412
|
+
get clearTimeout() {
|
|
4413
|
+
return this.api.clearTimeout;
|
|
4414
|
+
}
|
|
4415
|
+
get clearInterval() {
|
|
4416
|
+
return this.api.clearInterval;
|
|
4417
|
+
}
|
|
4521
4418
|
}
|
|
4522
4419
|
|
|
4523
4420
|
const VueUtils = {
|
|
@@ -4993,7 +4890,7 @@ define((function () { 'use strict';
|
|
|
4993
4890
|
};
|
|
4994
4891
|
|
|
4995
4892
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
4996
|
-
const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),l=t(c);e.addUniqueNumber=l,e.generateUniqueNumber=c}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async({data:{id:a,method:i,params:u}})=>{const c=r[i];try{if(void 0===c)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===u?c():c(u);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const l=r instanceof Promise?await r:r;if(null===a){if(void 0!==l.result)throw s(i)}else{if(void 0===l.result)throw s(i);const{result:e,transferables:r=[]}=l;t.postMessage({id:a,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:a})}};var i=r(455);const u=new Map,c=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),o=(0,i.generateUniqueNumber)(u);return u.set(o,(
|
|
4893
|
+
const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),l=t(c);e.addUniqueNumber=l,e.generateUniqueNumber=c}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async({data:{id:a,method:i,params:u}})=>{const c=r[i];try{if(void 0===c)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===u?c():c(u);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const l=r instanceof Promise?await r:r;if(null===a){if(void 0!==l.result)throw s(i)}else{if(void 0===l.result)throw s(i);const{result:e,transferables:r=[]}=l;t.postMessage({id:a,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:a})}};var i=r(455);const u=new Map,c=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),o=(0,i.generateUniqueNumber)(u);return u.set(o,()=>{n(),t.close(),u.delete(o)}),{result:o}},disconnect:({portId:e})=>{const r=u.get(e);if(void 0===r)throw(e=>o('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(e);return r(),{result:null}},isSupported:async()=>{if(await new Promise(e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])})){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),l=(e,t,r=()=>!0)=>{const n=c(l,t,r),o=a(e,n);return e.addEventListener("message",o),()=>e.removeEventListener("message",o)},d=(e,t)=>r=>{const n=t.get(r);if(void 0===n)return Promise.resolve(!1);const[o,s]=n;return e(o),t.delete(r),s(!1),Promise.resolve(!0)},f=(e,t,r,n)=>(o,s,a)=>{const i=o+s-t.timeOrigin,u=i-t.now();return new Promise(t=>{e.set(a,[r(n,u,i,e,t,a),t])})},m=new Map,h=d(globalThis.clearTimeout,m),p=new Map,v=d(globalThis.clearTimeout,p),w=((e,t)=>{const r=(n,o,s,a)=>{const i=n-e.now();i>0?o.set(a,[t(r,i,n,o,s,a),s]):(o.delete(a),s(!0))};return r})(performance,globalThis.setTimeout),g=f(m,performance,globalThis.setTimeout,w),T=f(p,performance,globalThis.setTimeout,w);l(self,{clear:async({timerId:e,timerType:t})=>({result:await("interval"===t?h(e):v(e))}),set:async({delay:e,now:t,timerId:r,timerType:n})=>({result:await("interval"===n?g:T)(e,t,r)})})})()})();`; // tslint:disable-line:max-line-length
|
|
4997
4894
|
|
|
4998
4895
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
4999
4896
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -5580,7 +5477,7 @@ define((function () { 'use strict';
|
|
|
5580
5477
|
this.windowApi = new WindowApi(option);
|
|
5581
5478
|
}
|
|
5582
5479
|
/** 版本号 */
|
|
5583
|
-
version = "2025.
|
|
5480
|
+
version = "2025.8.21";
|
|
5584
5481
|
addStyle(cssText) {
|
|
5585
5482
|
if (typeof cssText !== "string") {
|
|
5586
5483
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5703,13 +5600,9 @@ define((function () { 'use strict';
|
|
|
5703
5600
|
let touchEvent = UtilsContext.windowApi.window.event;
|
|
5704
5601
|
let $click = clickEvent?.composedPath()?.[0];
|
|
5705
5602
|
// 点击的x坐标
|
|
5706
|
-
let clickPosX = clickEvent?.clientX != null
|
|
5707
|
-
? clickEvent.clientX
|
|
5708
|
-
: touchEvent.touches[0].clientX;
|
|
5603
|
+
let clickPosX = clickEvent?.clientX != null ? clickEvent.clientX : touchEvent.touches[0].clientX;
|
|
5709
5604
|
// 点击的y坐标
|
|
5710
|
-
let clickPosY = clickEvent?.clientY != null
|
|
5711
|
-
? clickEvent.clientY
|
|
5712
|
-
: touchEvent.touches[0].clientY;
|
|
5605
|
+
let clickPosY = clickEvent?.clientY != null ? clickEvent.clientY : touchEvent.touches[0].clientY;
|
|
5713
5606
|
let {
|
|
5714
5607
|
/* 要检测的元素的相对屏幕的横坐标最左边 */
|
|
5715
5608
|
left: elementPosXLeft,
|
|
@@ -5872,9 +5765,7 @@ define((function () { 'use strict';
|
|
|
5872
5765
|
/* CODE FOR BROWSERS THAT SUPPORT window.find */
|
|
5873
5766
|
let windowFind = this.windowApi.self.find;
|
|
5874
5767
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5875
|
-
if (strFound &&
|
|
5876
|
-
this.windowApi.self.getSelection &&
|
|
5877
|
-
!this.windowApi.self.getSelection().anchorNode) {
|
|
5768
|
+
if (strFound && this.windowApi.self.getSelection && !this.windowApi.self.getSelection().anchorNode) {
|
|
5878
5769
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5879
5770
|
}
|
|
5880
5771
|
if (!strFound) {
|
|
@@ -5977,9 +5868,7 @@ define((function () { 'use strict';
|
|
|
5977
5868
|
}
|
|
5978
5869
|
}
|
|
5979
5870
|
result = result.toFixed(2);
|
|
5980
|
-
result = addType
|
|
5981
|
-
? result + resultType.toString()
|
|
5982
|
-
: parseFloat(result.toString());
|
|
5871
|
+
result = addType ? result + resultType.toString() : parseFloat(result.toString());
|
|
5983
5872
|
return result;
|
|
5984
5873
|
}
|
|
5985
5874
|
getNodeListValue(...args) {
|
|
@@ -6058,14 +5947,7 @@ define((function () { 'use strict';
|
|
|
6058
5947
|
if (text.length === 8) {
|
|
6059
5948
|
/* 该字符串只有时分秒 */
|
|
6060
5949
|
let today = new Date();
|
|
6061
|
-
text =
|
|
6062
|
-
today.getFullYear() +
|
|
6063
|
-
"-" +
|
|
6064
|
-
(today.getMonth() + 1) +
|
|
6065
|
-
"-" +
|
|
6066
|
-
today.getDate() +
|
|
6067
|
-
" " +
|
|
6068
|
-
text;
|
|
5950
|
+
text = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate() + " " + text;
|
|
6069
5951
|
}
|
|
6070
5952
|
text = text.substring(0, 19);
|
|
6071
5953
|
text = text.replace(/-/g, "/");
|
|
@@ -6086,25 +5968,13 @@ define((function () { 'use strict';
|
|
|
6086
5968
|
* 获取 transitionend 的在各个浏览器的兼容名
|
|
6087
5969
|
*/
|
|
6088
5970
|
getTransitionEndNameList() {
|
|
6089
|
-
return [
|
|
6090
|
-
"webkitTransitionEnd",
|
|
6091
|
-
"mozTransitionEnd",
|
|
6092
|
-
"MSTransitionEnd",
|
|
6093
|
-
"otransitionend",
|
|
6094
|
-
"transitionend",
|
|
6095
|
-
];
|
|
5971
|
+
return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
|
|
6096
5972
|
}
|
|
6097
5973
|
/**
|
|
6098
5974
|
* 获取 animationend 的在各个浏览器的兼容名
|
|
6099
5975
|
*/
|
|
6100
5976
|
getAnimationEndNameList() {
|
|
6101
|
-
return [
|
|
6102
|
-
"webkitAnimationEnd",
|
|
6103
|
-
"mozAnimationEnd",
|
|
6104
|
-
"MSAnimationEnd",
|
|
6105
|
-
"oanimationend",
|
|
6106
|
-
"animationend",
|
|
6107
|
-
];
|
|
5977
|
+
return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
|
|
6108
5978
|
}
|
|
6109
5979
|
getArrayLastValue(targetObj) {
|
|
6110
5980
|
return targetObj[targetObj.length - 1];
|
|
@@ -6208,10 +6078,8 @@ define((function () { 'use strict';
|
|
|
6208
6078
|
}
|
|
6209
6079
|
/* 如果有多个相同类型的兄弟元素,则需要添加索引 */
|
|
6210
6080
|
if (element.parentElement.querySelectorAll(element.tagName).length > 1) {
|
|
6211
|
-
let index = Array.prototype.indexOf.call(element.parentElement.children, element) +
|
|
6212
|
-
|
|
6213
|
-
selector +=
|
|
6214
|
-
" > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6081
|
+
let index = Array.prototype.indexOf.call(element.parentElement.children, element) + 1;
|
|
6082
|
+
selector += " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6215
6083
|
}
|
|
6216
6084
|
else {
|
|
6217
6085
|
selector += " > " + element.tagName.toLowerCase();
|
|
@@ -6231,9 +6099,7 @@ define((function () { 'use strict';
|
|
|
6231
6099
|
return void 0;
|
|
6232
6100
|
}
|
|
6233
6101
|
if (result.length > 1) {
|
|
6234
|
-
if (result.length === 2 &&
|
|
6235
|
-
typeof result[0] === "object" &&
|
|
6236
|
-
typeof result[1] === "function") {
|
|
6102
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6237
6103
|
let data = result[0];
|
|
6238
6104
|
let handleDataFunc = result[1];
|
|
6239
6105
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6331,9 +6197,7 @@ define((function () { 'use strict';
|
|
|
6331
6197
|
return void 0;
|
|
6332
6198
|
}
|
|
6333
6199
|
if (result.length > 1) {
|
|
6334
|
-
if (result.length === 2 &&
|
|
6335
|
-
typeof result[0] === "object" &&
|
|
6336
|
-
typeof result[1] === "function") {
|
|
6200
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6337
6201
|
let data = result[0];
|
|
6338
6202
|
let handleDataFunc = result[1];
|
|
6339
6203
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6423,12 +6287,10 @@ define((function () { 'use strict';
|
|
|
6423
6287
|
getRandomValue(...args) {
|
|
6424
6288
|
let result = [...args];
|
|
6425
6289
|
if (result.length > 1) {
|
|
6426
|
-
if (result.length === 2 &&
|
|
6427
|
-
typeof result[0] === "number" &&
|
|
6428
|
-
typeof result[1] === "number") {
|
|
6290
|
+
if (result.length === 2 && typeof result[0] === "number" && typeof result[1] === "number") {
|
|
6429
6291
|
let leftNumber = result[0] > result[1] ? result[1] : result[0];
|
|
6430
6292
|
let rightNumber = result[0] > result[1] ? result[0] : result[1];
|
|
6431
|
-
return
|
|
6293
|
+
return Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber;
|
|
6432
6294
|
}
|
|
6433
6295
|
else {
|
|
6434
6296
|
return result[Math.floor(Math.random() * result.length)];
|
|
@@ -6439,8 +6301,7 @@ define((function () { 'use strict';
|
|
|
6439
6301
|
if (Array.isArray(paramData)) {
|
|
6440
6302
|
return paramData[Math.floor(Math.random() * paramData.length)];
|
|
6441
6303
|
}
|
|
6442
|
-
else if (typeof paramData === "object" &&
|
|
6443
|
-
Object.keys(paramData).length > 0) {
|
|
6304
|
+
else if (typeof paramData === "object" && Object.keys(paramData).length > 0) {
|
|
6444
6305
|
let paramObjDataKey = Object.keys(paramData)[Math.floor(Math.random() * Object.keys(paramData).length)];
|
|
6445
6306
|
return paramData[paramObjDataKey];
|
|
6446
6307
|
}
|
|
@@ -6747,11 +6608,9 @@ define((function () { 'use strict';
|
|
|
6747
6608
|
let nearBottomHeight = 50;
|
|
6748
6609
|
let checkWindow = () => {
|
|
6749
6610
|
// 已滚动的距离
|
|
6750
|
-
let scrollTop = this.windowApi.window.pageYOffset ||
|
|
6751
|
-
this.windowApi.document.documentElement.scrollTop;
|
|
6611
|
+
let scrollTop = this.windowApi.window.pageYOffset || this.windowApi.document.documentElement.scrollTop;
|
|
6752
6612
|
// 视窗高度
|
|
6753
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
6754
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6613
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
6755
6614
|
// 最大滚动距离
|
|
6756
6615
|
let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
|
|
6757
6616
|
return scrollTop + viewportHeight >= maxScrollHeight;
|
|
@@ -7040,8 +6899,7 @@ define((function () { 'use strict';
|
|
|
7040
6899
|
**/
|
|
7041
6900
|
isNull = commonUtil.isNull.bind(commonUtil);
|
|
7042
6901
|
isThemeDark() {
|
|
7043
|
-
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)")
|
|
7044
|
-
.matches;
|
|
6902
|
+
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
7045
6903
|
}
|
|
7046
6904
|
/**
|
|
7047
6905
|
* 判断元素是否在页面中可见
|
|
@@ -7074,10 +6932,8 @@ define((function () { 'use strict';
|
|
|
7074
6932
|
else {
|
|
7075
6933
|
let domClientRect = domItem.getBoundingClientRect();
|
|
7076
6934
|
if (inView) {
|
|
7077
|
-
let viewportWidth = this.windowApi.window.innerWidth ||
|
|
7078
|
-
|
|
7079
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
7080
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6935
|
+
let viewportWidth = this.windowApi.window.innerWidth || this.windowApi.document.documentElement.clientWidth;
|
|
6936
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
7081
6937
|
result = !(domClientRect.right < 0 ||
|
|
7082
6938
|
domClientRect.left > viewportWidth ||
|
|
7083
6939
|
domClientRect.bottom < 0 ||
|
|
@@ -7101,8 +6957,7 @@ define((function () { 'use strict';
|
|
|
7101
6957
|
for (const key in Object.values(this.windowApi.top.window.via)) {
|
|
7102
6958
|
if (Reflect.has(this.windowApi.top.window.via, key)) {
|
|
7103
6959
|
let objValueFunc = this.windowApi.top.window.via[key];
|
|
7104
|
-
if (typeof objValueFunc === "function" &&
|
|
7105
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
6960
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7106
6961
|
result = true;
|
|
7107
6962
|
}
|
|
7108
6963
|
else {
|
|
@@ -7124,8 +6979,7 @@ define((function () { 'use strict';
|
|
|
7124
6979
|
for (const key in Object.values(this.windowApi.top.window.mbrowser)) {
|
|
7125
6980
|
if (Reflect.has(this.windowApi.top.window.mbrowser, key)) {
|
|
7126
6981
|
let objValueFunc = this.windowApi.top.window.mbrowser[key];
|
|
7127
|
-
if (typeof objValueFunc === "function" &&
|
|
7128
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
6982
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7129
6983
|
result = true;
|
|
7130
6984
|
}
|
|
7131
6985
|
else {
|
|
@@ -7362,13 +7216,11 @@ define((function () { 'use strict';
|
|
|
7362
7216
|
* 释放所有
|
|
7363
7217
|
*/
|
|
7364
7218
|
function releaseAll() {
|
|
7365
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] !==
|
|
7366
|
-
"undefined") {
|
|
7219
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] !== "undefined") {
|
|
7367
7220
|
/* 已存在 */
|
|
7368
7221
|
return;
|
|
7369
7222
|
}
|
|
7370
|
-
UtilsContext.windowApi.window[needReleaseKey] =
|
|
7371
|
-
UtilsContext.deepClone(needReleaseObject);
|
|
7223
|
+
UtilsContext.windowApi.window[needReleaseKey] = UtilsContext.deepClone(needReleaseObject);
|
|
7372
7224
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7373
7225
|
if (typeof value === "function") {
|
|
7374
7226
|
needReleaseObject[value.name] = () => { };
|
|
@@ -7382,8 +7234,7 @@ define((function () { 'use strict';
|
|
|
7382
7234
|
Array.from(functionNameList).forEach((item) => {
|
|
7383
7235
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7384
7236
|
if (typeof value === "function") {
|
|
7385
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7386
|
-
"undefined") {
|
|
7237
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7387
7238
|
UtilsContext.windowApi.window[needReleaseKey] = {};
|
|
7388
7239
|
}
|
|
7389
7240
|
if (item === value.name) {
|
|
@@ -7398,8 +7249,7 @@ define((function () { 'use strict';
|
|
|
7398
7249
|
* 恢复所有
|
|
7399
7250
|
*/
|
|
7400
7251
|
function recoveryAll() {
|
|
7401
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7402
|
-
"undefined") {
|
|
7252
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7403
7253
|
/* 未存在 */
|
|
7404
7254
|
return;
|
|
7405
7255
|
}
|
|
@@ -7410,8 +7260,7 @@ define((function () { 'use strict';
|
|
|
7410
7260
|
* 恢复单个
|
|
7411
7261
|
*/
|
|
7412
7262
|
function recoveryOne() {
|
|
7413
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7414
|
-
"undefined") {
|
|
7263
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7415
7264
|
/* 未存在 */
|
|
7416
7265
|
return;
|
|
7417
7266
|
}
|
|
@@ -7419,8 +7268,7 @@ define((function () { 'use strict';
|
|
|
7419
7268
|
if (UtilsContext.windowApi.window[needReleaseKey][item]) {
|
|
7420
7269
|
needReleaseObject[item] = UtilsContext.windowApi.window[needReleaseKey][item];
|
|
7421
7270
|
Reflect.deleteProperty(UtilsContext.windowApi.window[needReleaseKey], item);
|
|
7422
|
-
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey])
|
|
7423
|
-
.length === 0) {
|
|
7271
|
+
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey]).length === 0) {
|
|
7424
7272
|
Reflect.deleteProperty(window, needReleaseKey);
|
|
7425
7273
|
}
|
|
7426
7274
|
}
|
|
@@ -7677,8 +7525,7 @@ define((function () { 'use strict';
|
|
|
7677
7525
|
let copyStatus = false;
|
|
7678
7526
|
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7679
7527
|
console.log(requestPermissionStatus);
|
|
7680
|
-
if (this.hasClipboard() &&
|
|
7681
|
-
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7528
|
+
if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7682
7529
|
try {
|
|
7683
7530
|
copyStatus = await this.copyDataByClipboard();
|
|
7684
7531
|
}
|
|
@@ -7839,11 +7686,8 @@ define((function () { 'use strict';
|
|
|
7839
7686
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
7840
7687
|
return mouseEvent;
|
|
7841
7688
|
}
|
|
7842
|
-
let sliderElement = typeof selector === "string"
|
|
7843
|
-
|
|
7844
|
-
: selector;
|
|
7845
|
-
if (!(sliderElement instanceof Node) ||
|
|
7846
|
-
!(sliderElement instanceof Element)) {
|
|
7689
|
+
let sliderElement = typeof selector === "string" ? domUtils.selector(selector) : selector;
|
|
7690
|
+
if (!(sliderElement instanceof Node) || !(sliderElement instanceof Element)) {
|
|
7847
7691
|
throw new Error("Utils.dragSlider 参数selector 必须为Node/Element类型");
|
|
7848
7692
|
}
|
|
7849
7693
|
let rect = sliderElement.getBoundingClientRect(), x0 = rect.x || rect.left, y0 = rect.y || rect.top, x1 = x0 + offsetX, y1 = y0;
|
|
@@ -7895,17 +7739,14 @@ define((function () { 'use strict';
|
|
|
7895
7739
|
}
|
|
7896
7740
|
sortListByProperty(data, getPropertyValueFunc, sortByDesc = true) {
|
|
7897
7741
|
let UtilsContext = this;
|
|
7898
|
-
if (typeof getPropertyValueFunc !== "function" &&
|
|
7899
|
-
typeof getPropertyValueFunc !== "string") {
|
|
7742
|
+
if (typeof getPropertyValueFunc !== "function" && typeof getPropertyValueFunc !== "string") {
|
|
7900
7743
|
throw new Error("Utils.sortListByProperty 参数 getPropertyValueFunc 必须为 function|string 类型");
|
|
7901
7744
|
}
|
|
7902
7745
|
if (typeof sortByDesc !== "boolean") {
|
|
7903
7746
|
throw new Error("Utils.sortListByProperty 参数 sortByDesc 必须为 boolean 类型");
|
|
7904
7747
|
}
|
|
7905
7748
|
let getObjValue = function (obj) {
|
|
7906
|
-
return typeof getPropertyValueFunc === "string"
|
|
7907
|
-
? obj[getPropertyValueFunc]
|
|
7908
|
-
: getPropertyValueFunc(obj);
|
|
7749
|
+
return typeof getPropertyValueFunc === "string" ? obj[getPropertyValueFunc] : getPropertyValueFunc(obj);
|
|
7909
7750
|
};
|
|
7910
7751
|
/**
|
|
7911
7752
|
* 排序方法
|
|
@@ -7980,8 +7821,7 @@ define((function () { 'use strict';
|
|
|
7980
7821
|
if (Array.isArray(data)) {
|
|
7981
7822
|
data.sort(sortFunc);
|
|
7982
7823
|
}
|
|
7983
|
-
else if (data instanceof NodeList ||
|
|
7984
|
-
UtilsContext.isJQuery(data)) {
|
|
7824
|
+
else if (data instanceof NodeList || UtilsContext.isJQuery(data)) {
|
|
7985
7825
|
sortNodeFunc(data, getDataFunc);
|
|
7986
7826
|
result = getDataFunc();
|
|
7987
7827
|
}
|
|
@@ -8174,9 +8014,7 @@ define((function () { 'use strict';
|
|
|
8174
8014
|
let parent = UtilsContext.windowApi.document;
|
|
8175
8015
|
// 超时时间
|
|
8176
8016
|
let timeout = 0;
|
|
8177
|
-
if (typeof args[0] !== "string" &&
|
|
8178
|
-
!Array.isArray(args[0]) &&
|
|
8179
|
-
typeof args[0] !== "function") {
|
|
8017
|
+
if (typeof args[0] !== "string" && !Array.isArray(args[0]) && typeof args[0] !== "function") {
|
|
8180
8018
|
throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
|
|
8181
8019
|
}
|
|
8182
8020
|
if (args.length === 1) ;
|
|
@@ -8186,8 +8024,7 @@ define((function () { 'use strict';
|
|
|
8186
8024
|
// "div",10000
|
|
8187
8025
|
timeout = secondParam;
|
|
8188
8026
|
}
|
|
8189
|
-
else if (typeof secondParam === "object" &&
|
|
8190
|
-
secondParam instanceof Node) {
|
|
8027
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8191
8028
|
// "div",document
|
|
8192
8029
|
parent = secondParam;
|
|
8193
8030
|
}
|
|
@@ -8273,8 +8110,7 @@ define((function () { 'use strict';
|
|
|
8273
8110
|
// "div",10000
|
|
8274
8111
|
timeout = secondParam;
|
|
8275
8112
|
}
|
|
8276
|
-
else if (typeof secondParam === "object" &&
|
|
8277
|
-
secondParam instanceof Node) {
|
|
8113
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8278
8114
|
// "div",document
|
|
8279
8115
|
parent = secondParam;
|
|
8280
8116
|
}
|
|
@@ -8329,8 +8165,7 @@ define((function () { 'use strict';
|
|
|
8329
8165
|
// "div",10000
|
|
8330
8166
|
timeout = secondParam;
|
|
8331
8167
|
}
|
|
8332
|
-
else if (typeof secondParam === "object" &&
|
|
8333
|
-
secondParam instanceof Node) {
|
|
8168
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8334
8169
|
// "div",document
|
|
8335
8170
|
parent = secondParam;
|
|
8336
8171
|
}
|
|
@@ -8416,8 +8251,7 @@ define((function () { 'use strict';
|
|
|
8416
8251
|
// "div",10000
|
|
8417
8252
|
timeout = secondParam;
|
|
8418
8253
|
}
|
|
8419
|
-
else if (typeof secondParam === "object" &&
|
|
8420
|
-
secondParam instanceof Node) {
|
|
8254
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8421
8255
|
// "div",document
|
|
8422
8256
|
parent = secondParam;
|
|
8423
8257
|
}
|
|
@@ -8550,8 +8384,7 @@ define((function () { 'use strict';
|
|
|
8550
8384
|
return flag;
|
|
8551
8385
|
}
|
|
8552
8386
|
watchObject(target, propertyName, getCallBack, setCallBack) {
|
|
8553
|
-
if (typeof getCallBack !== "function" &&
|
|
8554
|
-
typeof setCallBack !== "function") {
|
|
8387
|
+
if (typeof getCallBack !== "function" && typeof setCallBack !== "function") {
|
|
8555
8388
|
return;
|
|
8556
8389
|
}
|
|
8557
8390
|
if (typeof getCallBack === "function") {
|
|
@@ -8603,13 +8436,27 @@ define((function () { 'use strict';
|
|
|
8603
8436
|
return;
|
|
8604
8437
|
}
|
|
8605
8438
|
let handleResult = handler(target);
|
|
8606
|
-
if (handleResult &&
|
|
8607
|
-
typeof handleResult.isFind === "boolean" &&
|
|
8608
|
-
handleResult.isFind) {
|
|
8439
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8609
8440
|
return handleResult.data;
|
|
8610
8441
|
}
|
|
8611
8442
|
return this.queryProperty(handleResult.data, handler);
|
|
8612
8443
|
}
|
|
8444
|
+
/**
|
|
8445
|
+
* 异步-深度获取对象属性
|
|
8446
|
+
* @param target 待获取的对象
|
|
8447
|
+
* @param handler 获取属性的回调
|
|
8448
|
+
*/
|
|
8449
|
+
async asyncQueryProperty(target, handler) {
|
|
8450
|
+
if (target == null) {
|
|
8451
|
+
// @ts-ignore
|
|
8452
|
+
return;
|
|
8453
|
+
}
|
|
8454
|
+
let handleResult = await handler(target);
|
|
8455
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8456
|
+
return handleResult.data;
|
|
8457
|
+
}
|
|
8458
|
+
return await this.asyncQueryProperty(handleResult.data, handler);
|
|
8459
|
+
}
|
|
8613
8460
|
/**
|
|
8614
8461
|
* 创建一个新的Utils实例
|
|
8615
8462
|
* @param option
|
|
@@ -8714,7 +8561,7 @@ define((function () { 'use strict';
|
|
|
8714
8561
|
return setTimeout$1(callback, timeout);
|
|
8715
8562
|
}
|
|
8716
8563
|
catch (error) {
|
|
8717
|
-
return
|
|
8564
|
+
return this.windowApi.setTimeout(callback, timeout);
|
|
8718
8565
|
}
|
|
8719
8566
|
}
|
|
8720
8567
|
/**
|
|
@@ -8730,7 +8577,7 @@ define((function () { 'use strict';
|
|
|
8730
8577
|
catch (error) {
|
|
8731
8578
|
}
|
|
8732
8579
|
finally {
|
|
8733
|
-
|
|
8580
|
+
this.windowApi.clearTimeout(timeId);
|
|
8734
8581
|
}
|
|
8735
8582
|
}
|
|
8736
8583
|
/**
|
|
@@ -8743,7 +8590,7 @@ define((function () { 'use strict';
|
|
|
8743
8590
|
return setInterval(callback, timeout);
|
|
8744
8591
|
}
|
|
8745
8592
|
catch (error) {
|
|
8746
|
-
return
|
|
8593
|
+
return this.windowApi.setInterval(callback, timeout);
|
|
8747
8594
|
}
|
|
8748
8595
|
}
|
|
8749
8596
|
/**
|
|
@@ -8759,7 +8606,7 @@ define((function () { 'use strict';
|
|
|
8759
8606
|
catch (error) {
|
|
8760
8607
|
}
|
|
8761
8608
|
finally {
|
|
8762
|
-
|
|
8609
|
+
this.windowApi.clearInterval(timeId);
|
|
8763
8610
|
}
|
|
8764
8611
|
}
|
|
8765
8612
|
/**
|