@whitesev/utils 2.7.0 → 2.7.2
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/README.md +19 -19
- package/dist/index.amd.js +205 -235
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +205 -235
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +205 -235
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +205 -235
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +205 -235
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +205 -235
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/ColorConversion.d.ts +3 -8
- package/dist/types/src/Dictionary.d.ts +21 -14
- package/dist/types/src/GBKEncoder.d.ts +1 -2
- package/dist/types/src/Hooks.d.ts +1 -2
- package/dist/types/src/Httpx.d.ts +45 -46
- package/dist/types/src/LockFunction.d.ts +1 -2
- package/dist/types/src/Log.d.ts +1 -2
- package/dist/types/src/Progress.d.ts +1 -2
- package/dist/types/src/Utils.d.ts +1 -1
- package/dist/types/src/UtilsGMMenu.d.ts +1 -2
- package/dist/types/src/WindowApi.d.ts +1 -2
- package/dist/types/src/indexedDB.d.ts +1 -2
- package/dist/types/src/types/Httpx.d.ts +73 -67
- package/dist/types/src/types/env.d.ts +2 -0
- package/dist/types/src/types/global.d.ts +3 -0
- package/package.json +1 -1
- package/src/ColorConversion.ts +14 -25
- package/src/DOMUtils.ts +14 -16
- package/src/Dictionary.ts +39 -35
- package/src/GBKEncoder.ts +8 -12
- package/src/Hooks.ts +1 -3
- package/src/Httpx.ts +194 -174
- package/src/LockFunction.ts +3 -3
- package/src/Log.ts +1 -3
- package/src/Progress.ts +1 -3
- package/src/TryCatch.ts +4 -4
- package/src/Utils.ts +29 -45
- package/src/UtilsGMMenu.ts +19 -22
- package/src/Vue.ts +4 -7
- package/src/WindowApi.ts +2 -5
- package/src/ajaxHooker/ajaxHooker.js +35 -21
- package/src/indexedDB.ts +8 -8
- package/src/types/Httpx.d.ts +73 -67
- package/src/types/env.d.ts +2 -0
- package/src/types/global.d.ts +3 -0
package/dist/index.iife.js
CHANGED
|
@@ -18,14 +18,13 @@ var Utils = (function () {
|
|
|
18
18
|
/**
|
|
19
19
|
* 16进制颜色转rgba
|
|
20
20
|
*
|
|
21
|
-
*
|
|
21
|
+
* 例如:`#ff0000` 转为 `rgba(123,123,123, 0.4)`
|
|
22
22
|
* @param hex
|
|
23
23
|
* @param opacity
|
|
24
24
|
*/
|
|
25
25
|
hexToRgba(hex, opacity) {
|
|
26
26
|
if (!this.isHex(hex)) {
|
|
27
|
-
|
|
28
|
-
throw new TypeError("输入错误的hex", hex);
|
|
27
|
+
throw new TypeError("输入错误的hex:" + hex);
|
|
29
28
|
}
|
|
30
29
|
return hex && hex.replace(/\s+/g, "").length === 7
|
|
31
30
|
? "rgba(" +
|
|
@@ -42,19 +41,16 @@ var Utils = (function () {
|
|
|
42
41
|
/**
|
|
43
42
|
* hex转rgb
|
|
44
43
|
* @param str
|
|
45
|
-
* @returns
|
|
46
44
|
*/
|
|
47
45
|
hexToRgb(str) {
|
|
48
46
|
if (!this.isHex(str)) {
|
|
49
|
-
|
|
50
|
-
throw new TypeError("输入错误的hex", str);
|
|
47
|
+
throw new TypeError("输入错误的hex:" + str);
|
|
51
48
|
}
|
|
52
49
|
/* replace替换查找的到的字符串 */
|
|
53
50
|
str = str.replace("#", "");
|
|
54
51
|
/* match得到查询数组 */
|
|
55
52
|
let hxs = str.match(/../g);
|
|
56
53
|
for (let index = 0; index < 3; index++) {
|
|
57
|
-
// @ts-ignore
|
|
58
54
|
hxs[index] = parseInt(hxs[index], 16);
|
|
59
55
|
}
|
|
60
56
|
return hxs;
|
|
@@ -64,7 +60,6 @@ var Utils = (function () {
|
|
|
64
60
|
* @param redValue
|
|
65
61
|
* @param greenValue
|
|
66
62
|
* @param blueValue
|
|
67
|
-
* @returns
|
|
68
63
|
*/
|
|
69
64
|
rgbToHex(redValue, greenValue, blueValue) {
|
|
70
65
|
/* 验证输入的rgb值是否合法 */
|
|
@@ -87,38 +82,30 @@ var Utils = (function () {
|
|
|
87
82
|
* 获取颜色变暗或亮
|
|
88
83
|
* @param color 颜色
|
|
89
84
|
* @param level 0~1.0
|
|
90
|
-
* @returns
|
|
91
85
|
*/
|
|
92
86
|
getDarkColor(color, level) {
|
|
93
87
|
if (!this.isHex(color)) {
|
|
94
|
-
|
|
95
|
-
throw new TypeError("输入错误的hex", color);
|
|
88
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
96
89
|
}
|
|
97
90
|
let rgbc = this.hexToRgb(color);
|
|
98
91
|
for (let index = 0; index < 3; index++) {
|
|
99
|
-
// @ts-ignore
|
|
100
92
|
rgbc[index] = Math.floor(rgbc[index] * (1 - level));
|
|
101
93
|
}
|
|
102
|
-
// @ts-ignore
|
|
103
94
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
104
95
|
}
|
|
105
96
|
/**
|
|
106
97
|
* 获取颜色变亮
|
|
107
98
|
* @param color 颜色
|
|
108
99
|
* @param level 0~1.0
|
|
109
|
-
* @returns
|
|
110
100
|
*/
|
|
111
101
|
getLightColor(color, level) {
|
|
112
102
|
if (!this.isHex(color)) {
|
|
113
|
-
|
|
114
|
-
throw new TypeError("输入错误的hex", color);
|
|
103
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
115
104
|
}
|
|
116
105
|
let rgbc = this.hexToRgb(color);
|
|
117
106
|
for (let index = 0; index < 3; index++) {
|
|
118
|
-
// @ts-ignore
|
|
119
107
|
rgbc[index] = Math.floor((255 - rgbc[index]) * level + rgbc[index]);
|
|
120
108
|
}
|
|
121
|
-
// @ts-ignore
|
|
122
109
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
123
110
|
}
|
|
124
111
|
}
|
|
@@ -206,20 +193,20 @@ var Utils = (function () {
|
|
|
206
193
|
* @param str
|
|
207
194
|
*/
|
|
208
195
|
decode(str) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
//
|
|
212
|
-
|
|
213
|
-
|
|
196
|
+
let GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
|
|
197
|
+
let UTFMatcher = /%[0-9A-F]{2}/;
|
|
198
|
+
// let gbk = true;
|
|
199
|
+
let utf = true;
|
|
200
|
+
const that = this;
|
|
214
201
|
while (utf) {
|
|
215
202
|
let gbkMatch = str.match(GBKMatcher);
|
|
216
203
|
let utfMatch = str.match(UTFMatcher);
|
|
204
|
+
// gbk = Boolean(gbkMatch);
|
|
217
205
|
utf = Boolean(utfMatch);
|
|
218
206
|
if (gbkMatch && gbkMatch in that.#G2Uhash) {
|
|
219
207
|
str = str.replace(gbkMatch, String.fromCharCode(("0x" + that.#G2Uhash[gbkMatch])));
|
|
220
208
|
}
|
|
221
209
|
else {
|
|
222
|
-
// @ts-ignore
|
|
223
210
|
str = str.replace(utfMatch, decodeURIComponent(utfMatch));
|
|
224
211
|
}
|
|
225
212
|
}
|
|
@@ -250,7 +237,6 @@ var Utils = (function () {
|
|
|
250
237
|
* @param handler
|
|
251
238
|
*/
|
|
252
239
|
error(handler) {
|
|
253
|
-
// @ts-ignore
|
|
254
240
|
handleError = handler;
|
|
255
241
|
return TryCatchCore;
|
|
256
242
|
},
|
|
@@ -265,8 +251,9 @@ var Utils = (function () {
|
|
|
265
251
|
callbackFunction = callback;
|
|
266
252
|
context = __context__ || this;
|
|
267
253
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
268
|
-
|
|
269
|
-
|
|
254
|
+
return result !== void 0
|
|
255
|
+
? result
|
|
256
|
+
: TryCatchCore;
|
|
270
257
|
},
|
|
271
258
|
};
|
|
272
259
|
/**
|
|
@@ -749,13 +736,13 @@ var Utils = (function () {
|
|
|
749
736
|
// ==UserScript==
|
|
750
737
|
// @name ajaxHooker
|
|
751
738
|
// @author cxxjackie
|
|
752
|
-
// @version 1.4.
|
|
739
|
+
// @version 1.4.7
|
|
753
740
|
// @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
754
741
|
// @license GNU LGPL-3.0
|
|
755
742
|
// ==/UserScript==
|
|
756
743
|
|
|
757
744
|
const ajaxHooker = function () {
|
|
758
|
-
const version = "1.4.
|
|
745
|
+
const version = "1.4.7";
|
|
759
746
|
const hookInst = {
|
|
760
747
|
hookFns: [],
|
|
761
748
|
filters: [],
|
|
@@ -765,20 +752,18 @@ var Utils = (function () {
|
|
|
765
752
|
const resProto = win.Response.prototype;
|
|
766
753
|
const xhrResponses = ["response", "responseText", "responseXML"];
|
|
767
754
|
const fetchResponses = ["arrayBuffer", "blob", "formData", "json", "text"];
|
|
768
|
-
const
|
|
769
|
-
|
|
770
|
-
"headers",
|
|
771
|
-
"body",
|
|
772
|
-
"mode",
|
|
773
|
-
"credentials",
|
|
755
|
+
const xhrExtraProps = ["responseType", "timeout", "withCredentials"];
|
|
756
|
+
const fetchExtraProps = [
|
|
774
757
|
"cache",
|
|
758
|
+
"credentials",
|
|
759
|
+
"integrity",
|
|
760
|
+
"keepalive",
|
|
761
|
+
"mode",
|
|
762
|
+
"priority",
|
|
775
763
|
"redirect",
|
|
776
764
|
"referrer",
|
|
777
765
|
"referrerPolicy",
|
|
778
|
-
"integrity",
|
|
779
|
-
"keepalive",
|
|
780
766
|
"signal",
|
|
781
|
-
"priority",
|
|
782
767
|
];
|
|
783
768
|
const xhrAsyncEvents = ["readystatechange", "load", "loadend"];
|
|
784
769
|
const getType = {}.toString.call.bind({}.toString);
|
|
@@ -856,6 +841,10 @@ var Utils = (function () {
|
|
|
856
841
|
this.request = request;
|
|
857
842
|
this.requestClone = { ...this.request };
|
|
858
843
|
}
|
|
844
|
+
_recoverRequestKey(key) {
|
|
845
|
+
if (key in this.requestClone) this.request[key] = this.requestClone[key];
|
|
846
|
+
else delete this.request[key];
|
|
847
|
+
}
|
|
859
848
|
shouldFilter(filters) {
|
|
860
849
|
const { type, url, method, async } = this.request;
|
|
861
850
|
return (
|
|
@@ -876,7 +865,6 @@ var Utils = (function () {
|
|
|
876
865
|
);
|
|
877
866
|
}
|
|
878
867
|
waitForRequestKeys() {
|
|
879
|
-
const requestKeys = ["url", "method", "abort", "headers", "data"];
|
|
880
868
|
if (!this.request.async) {
|
|
881
869
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
882
870
|
if (this.shouldFilter(filters)) return;
|
|
@@ -884,27 +872,31 @@ var Utils = (function () {
|
|
|
884
872
|
if (getType(fn) === "[object Function]")
|
|
885
873
|
catchError(fn, this.request);
|
|
886
874
|
});
|
|
887
|
-
|
|
888
|
-
if (isThenable(this.request[key]))
|
|
889
|
-
|
|
890
|
-
});
|
|
875
|
+
for (const key in this.request) {
|
|
876
|
+
if (isThenable(this.request[key])) this._recoverRequestKey(key);
|
|
877
|
+
}
|
|
891
878
|
});
|
|
892
879
|
return new SyncThenable();
|
|
893
880
|
}
|
|
894
881
|
const promises = [];
|
|
882
|
+
const ignoreKeys = new Set(["type", "async", "response"]);
|
|
895
883
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
896
884
|
if (this.shouldFilter(filters)) return;
|
|
897
885
|
promises.push(
|
|
898
886
|
Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(
|
|
899
|
-
() =>
|
|
900
|
-
|
|
887
|
+
() => {
|
|
888
|
+
const requestKeys = [];
|
|
889
|
+
for (const key in this.request)
|
|
890
|
+
!ignoreKeys.has(key) && requestKeys.push(key);
|
|
891
|
+
return Promise.all(
|
|
901
892
|
requestKeys.map((key) =>
|
|
902
893
|
Promise.resolve(this.request[key]).then(
|
|
903
894
|
(val) => (this.request[key] = val),
|
|
904
|
-
() =>
|
|
895
|
+
() => this._recoverRequestKey(key)
|
|
905
896
|
)
|
|
906
897
|
)
|
|
907
|
-
)
|
|
898
|
+
);
|
|
899
|
+
}
|
|
908
900
|
)
|
|
909
901
|
);
|
|
910
902
|
});
|
|
@@ -1085,6 +1077,7 @@ var Utils = (function () {
|
|
|
1085
1077
|
e.stopImmediatePropagation = stopImmediatePropagation;
|
|
1086
1078
|
defineProp(e, "target", () => this.proxyXhr);
|
|
1087
1079
|
defineProp(e, "currentTarget", () => this.proxyXhr);
|
|
1080
|
+
defineProp(e, "srcElement", () => this.proxyXhr);
|
|
1088
1081
|
this.proxyEvents[e.type] &&
|
|
1089
1082
|
this.proxyEvents[e.type].forEach((fn) => {
|
|
1090
1083
|
this.resThenable.then(
|
|
@@ -1162,6 +1155,9 @@ var Utils = (function () {
|
|
|
1162
1155
|
for (const header in request.headers) {
|
|
1163
1156
|
xhr.setRequestHeader(header, request.headers[header]);
|
|
1164
1157
|
}
|
|
1158
|
+
for (const prop of xhrExtraProps) {
|
|
1159
|
+
if (prop in request) xhr[prop] = request[prop];
|
|
1160
|
+
}
|
|
1165
1161
|
xhr.send(request.data);
|
|
1166
1162
|
}
|
|
1167
1163
|
});
|
|
@@ -1183,8 +1179,10 @@ var Utils = (function () {
|
|
|
1183
1179
|
return new Promise(async (resolve, reject) => {
|
|
1184
1180
|
const init = {};
|
|
1185
1181
|
if (getType(url) === "[object Request]") {
|
|
1186
|
-
|
|
1182
|
+
init.method = url.method;
|
|
1183
|
+
init.headers = url.headers;
|
|
1187
1184
|
if (url.body) init.body = await url.arrayBuffer();
|
|
1185
|
+
for (const prop of fetchExtraProps) init[prop] = url[prop];
|
|
1188
1186
|
url = url.url;
|
|
1189
1187
|
}
|
|
1190
1188
|
url = url.toString();
|
|
@@ -1231,6 +1229,9 @@ var Utils = (function () {
|
|
|
1231
1229
|
init.method = request.method;
|
|
1232
1230
|
init.headers = request.headers;
|
|
1233
1231
|
init.body = request.data;
|
|
1232
|
+
for (const prop of fetchExtraProps) {
|
|
1233
|
+
if (prop in request) init[prop] = request[prop];
|
|
1234
|
+
}
|
|
1234
1235
|
winAh.realFetch.call(win, request.url, init).then((res) => {
|
|
1235
1236
|
if (typeof request.response === "function") {
|
|
1236
1237
|
const response = {
|
|
@@ -1936,25 +1937,24 @@ var Utils = (function () {
|
|
|
1936
1937
|
let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
|
|
1937
1938
|
/** 油猴菜单上显示的文本 */
|
|
1938
1939
|
let showText = menuOption.showText(menuOption.text, defaultEnable);
|
|
1939
|
-
//
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
});
|
|
1940
|
+
// const GMMenuOptions = {
|
|
1941
|
+
// /**
|
|
1942
|
+
// * 菜单的id
|
|
1943
|
+
// */
|
|
1944
|
+
// id: menuOption.id,
|
|
1945
|
+
// /**
|
|
1946
|
+
// * 点击菜单项后是否应关闭弹出菜单
|
|
1947
|
+
// */
|
|
1948
|
+
// autoClose: menuOption.autoClose,
|
|
1949
|
+
// /**
|
|
1950
|
+
// * 菜单项的可选访问键
|
|
1951
|
+
// */
|
|
1952
|
+
// accessKey: menuOption.accessKey,
|
|
1953
|
+
// /**
|
|
1954
|
+
// * 菜单项的鼠标悬浮上的工具提示
|
|
1955
|
+
// */
|
|
1956
|
+
// title: menuOption.title,
|
|
1957
|
+
// };
|
|
1958
1958
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1959
1959
|
menuOption.autoReload =
|
|
1960
1960
|
typeof menuOption.autoReload !== "boolean"
|
|
@@ -2532,7 +2532,9 @@ var Utils = (function () {
|
|
|
2532
2532
|
* 对请求的参数进行合并处理
|
|
2533
2533
|
*/
|
|
2534
2534
|
handleBeforeRequestOptionArgs(...args) {
|
|
2535
|
-
let option = {
|
|
2535
|
+
let option = {
|
|
2536
|
+
url: void 0,
|
|
2537
|
+
};
|
|
2536
2538
|
if (typeof args[0] === "string") {
|
|
2537
2539
|
/* 传入的是url,转为配置 */
|
|
2538
2540
|
let url = args[0];
|
|
@@ -2556,7 +2558,7 @@ var Utils = (function () {
|
|
|
2556
2558
|
* @param method 当前请求方法,默认get
|
|
2557
2559
|
* @param userRequestOption 用户的请求配置
|
|
2558
2560
|
* @param resolve promise回调
|
|
2559
|
-
* @param reject 抛出错误回调
|
|
2561
|
+
* @param reject promise抛出错误回调
|
|
2560
2562
|
*/
|
|
2561
2563
|
getRequestOption(method, userRequestOption, resolve, reject) {
|
|
2562
2564
|
let that = this;
|
|
@@ -2614,25 +2616,25 @@ var Utils = (function () {
|
|
|
2614
2616
|
password: userRequestOption.password ||
|
|
2615
2617
|
this.context.#defaultRequestOption.password,
|
|
2616
2618
|
onabort(...args) {
|
|
2617
|
-
that.context.
|
|
2619
|
+
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2618
2620
|
},
|
|
2619
2621
|
onerror(...args) {
|
|
2620
|
-
that.context.
|
|
2622
|
+
that.context.HttpxResponseCallBack.onError(userRequestOption, resolve, reject, args);
|
|
2621
2623
|
},
|
|
2622
2624
|
onloadstart(...args) {
|
|
2623
|
-
that.context.
|
|
2625
|
+
that.context.HttpxResponseCallBack.onLoadStart(userRequestOption, args);
|
|
2624
2626
|
},
|
|
2625
2627
|
onprogress(...args) {
|
|
2626
|
-
that.context.
|
|
2628
|
+
that.context.HttpxResponseCallBack.onProgress(userRequestOption, args);
|
|
2627
2629
|
},
|
|
2628
2630
|
onreadystatechange(...args) {
|
|
2629
|
-
that.context.
|
|
2631
|
+
that.context.HttpxResponseCallBack.onReadyStateChange(userRequestOption, args);
|
|
2630
2632
|
},
|
|
2631
2633
|
ontimeout(...args) {
|
|
2632
|
-
that.context.
|
|
2634
|
+
that.context.HttpxResponseCallBack.onTimeout(userRequestOption, resolve, reject, args);
|
|
2633
2635
|
},
|
|
2634
2636
|
onload(...args) {
|
|
2635
|
-
that.context.
|
|
2637
|
+
that.context.HttpxResponseCallBack.onLoad(userRequestOption, resolve, reject, args);
|
|
2636
2638
|
},
|
|
2637
2639
|
};
|
|
2638
2640
|
// 补全allowInterceptConfig参数
|
|
@@ -2744,7 +2746,6 @@ var Utils = (function () {
|
|
|
2744
2746
|
else if (typeof requestOption.data === "object") {
|
|
2745
2747
|
isHandler = true;
|
|
2746
2748
|
// URLSearchParams参数可以转普通的string:string,包括FormData
|
|
2747
|
-
// @ts-ignore
|
|
2748
2749
|
let searchParams = new URLSearchParams(requestOption.data);
|
|
2749
2750
|
urlSearch = searchParams.toString();
|
|
2750
2751
|
}
|
|
@@ -2799,9 +2800,7 @@ var Utils = (function () {
|
|
|
2799
2800
|
else if (ContentType.includes("application/x-www-form-urlencoded")) {
|
|
2800
2801
|
// application/x-www-form-urlencoded
|
|
2801
2802
|
if (typeof requestOption.data === "object") {
|
|
2802
|
-
requestOption.data = new URLSearchParams(
|
|
2803
|
-
// @ts-ignore
|
|
2804
|
-
requestOption.data).toString();
|
|
2803
|
+
requestOption.data = new URLSearchParams(requestOption.data).toString();
|
|
2805
2804
|
}
|
|
2806
2805
|
}
|
|
2807
2806
|
else if (ContentType.includes("multipart/form-data")) {
|
|
@@ -2821,7 +2820,7 @@ var Utils = (function () {
|
|
|
2821
2820
|
},
|
|
2822
2821
|
/**
|
|
2823
2822
|
* 处理发送请求的配置,去除值为undefined、空function的值
|
|
2824
|
-
* @param option
|
|
2823
|
+
* @param option 请求配置
|
|
2825
2824
|
*/
|
|
2826
2825
|
removeRequestNullOption(option) {
|
|
2827
2826
|
Object.keys(option).forEach((keyName) => {
|
|
@@ -2833,13 +2832,13 @@ var Utils = (function () {
|
|
|
2833
2832
|
}
|
|
2834
2833
|
});
|
|
2835
2834
|
if (commonUtil.isNull(option.url)) {
|
|
2836
|
-
throw new TypeError(`Utils.Httpx 参数
|
|
2835
|
+
throw new TypeError(`Utils.Httpx 参数url不能为空:${option.url}`);
|
|
2837
2836
|
}
|
|
2838
2837
|
return option;
|
|
2839
2838
|
},
|
|
2840
2839
|
/**
|
|
2841
2840
|
* 处理fetch的配置
|
|
2842
|
-
* @param option
|
|
2841
|
+
* @param option 请求配置
|
|
2843
2842
|
*/
|
|
2844
2843
|
handleFetchOption(option) {
|
|
2845
2844
|
/**
|
|
@@ -2892,21 +2891,21 @@ var Utils = (function () {
|
|
|
2892
2891
|
};
|
|
2893
2892
|
},
|
|
2894
2893
|
};
|
|
2895
|
-
|
|
2894
|
+
HttpxResponseCallBack = {
|
|
2896
2895
|
context: this,
|
|
2897
2896
|
/**
|
|
2898
2897
|
* onabort请求被取消-触发
|
|
2899
2898
|
* @param details 配置
|
|
2900
|
-
* @param resolve 回调
|
|
2901
|
-
* @param reject
|
|
2899
|
+
* @param resolve promise回调
|
|
2900
|
+
* @param reject promise抛出错误回调
|
|
2902
2901
|
* @param argsResult 返回的参数列表
|
|
2903
2902
|
*/
|
|
2904
2903
|
async onAbort(details, resolve, reject, argsResult) {
|
|
2905
2904
|
// console.log(argsResult);
|
|
2906
|
-
if (
|
|
2905
|
+
if (typeof details?.onabort === "function") {
|
|
2907
2906
|
details.onabort.apply(this, argsResult);
|
|
2908
2907
|
}
|
|
2909
|
-
else if (
|
|
2908
|
+
else if (typeof this.context.#defaultRequestOption?.onabort === "function") {
|
|
2910
2909
|
this.context.#defaultRequestOption.onabort.apply(this, argsResult);
|
|
2911
2910
|
}
|
|
2912
2911
|
let response = argsResult;
|
|
@@ -2915,11 +2914,11 @@ var Utils = (function () {
|
|
|
2915
2914
|
}
|
|
2916
2915
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2917
2916
|
type: "onabort",
|
|
2918
|
-
error: new
|
|
2917
|
+
error: new Error("request canceled"),
|
|
2919
2918
|
response: null,
|
|
2920
2919
|
details: details,
|
|
2921
2920
|
})) == null) {
|
|
2922
|
-
// reject(new
|
|
2921
|
+
// reject(new Error("response is intercept with onabort"));
|
|
2923
2922
|
return;
|
|
2924
2923
|
}
|
|
2925
2924
|
resolve({
|
|
@@ -2932,93 +2931,83 @@ var Utils = (function () {
|
|
|
2932
2931
|
});
|
|
2933
2932
|
},
|
|
2934
2933
|
/**
|
|
2935
|
-
*
|
|
2934
|
+
* ontimeout请求超时-触发
|
|
2936
2935
|
* @param details 配置
|
|
2937
2936
|
* @param resolve 回调
|
|
2938
2937
|
* @param reject 抛出错误
|
|
2939
2938
|
* @param argsResult 返回的参数列表
|
|
2940
2939
|
*/
|
|
2941
|
-
async
|
|
2940
|
+
async onTimeout(details, resolve, reject, argsResult) {
|
|
2942
2941
|
// console.log(argsResult);
|
|
2943
|
-
if ("
|
|
2944
|
-
|
|
2942
|
+
if (typeof details?.ontimeout === "function") {
|
|
2943
|
+
// 执行配置中的ontime回调
|
|
2944
|
+
details.ontimeout.apply(this, argsResult);
|
|
2945
2945
|
}
|
|
2946
|
-
else if (
|
|
2947
|
-
|
|
2946
|
+
else if (typeof this.context.#defaultRequestOption?.ontimeout === "function") {
|
|
2947
|
+
// 执行默认配置的ontime回调
|
|
2948
|
+
this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
|
|
2948
2949
|
}
|
|
2950
|
+
// 获取响应结果
|
|
2949
2951
|
let response = argsResult;
|
|
2950
2952
|
if (response.length) {
|
|
2951
2953
|
response = response[0];
|
|
2952
2954
|
}
|
|
2955
|
+
// 执行错误回调的钩子
|
|
2953
2956
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2954
|
-
type: "
|
|
2955
|
-
error: new
|
|
2957
|
+
type: "ontimeout",
|
|
2958
|
+
error: new Error("request timeout"),
|
|
2956
2959
|
response: response,
|
|
2957
2960
|
details: details,
|
|
2958
2961
|
})) == null) {
|
|
2959
|
-
// reject(new
|
|
2962
|
+
// reject(new Error("response is intercept with ontimeout"));
|
|
2960
2963
|
return;
|
|
2961
2964
|
}
|
|
2962
2965
|
resolve({
|
|
2963
2966
|
data: response,
|
|
2964
2967
|
details: details,
|
|
2965
|
-
msg: "
|
|
2968
|
+
msg: "请求超时",
|
|
2966
2969
|
status: false,
|
|
2967
|
-
statusCode:
|
|
2968
|
-
type: "
|
|
2970
|
+
statusCode: 0,
|
|
2971
|
+
type: "ontimeout",
|
|
2969
2972
|
});
|
|
2970
2973
|
},
|
|
2971
2974
|
/**
|
|
2972
|
-
*
|
|
2975
|
+
* onerror请求异常-触发
|
|
2973
2976
|
* @param details 配置
|
|
2974
2977
|
* @param resolve 回调
|
|
2975
2978
|
* @param reject 抛出错误
|
|
2976
2979
|
* @param argsResult 返回的参数列表
|
|
2977
2980
|
*/
|
|
2978
|
-
async
|
|
2981
|
+
async onError(details, resolve, reject, argsResult) {
|
|
2979
2982
|
// console.log(argsResult);
|
|
2980
|
-
if ("
|
|
2981
|
-
details.
|
|
2983
|
+
if (typeof details?.onerror === "function") {
|
|
2984
|
+
details.onerror.apply(this, argsResult);
|
|
2982
2985
|
}
|
|
2983
|
-
else if (
|
|
2984
|
-
this.context.#defaultRequestOption.
|
|
2986
|
+
else if (typeof this.context.#defaultRequestOption?.onerror === "function") {
|
|
2987
|
+
this.context.#defaultRequestOption.onerror.apply(this, argsResult);
|
|
2985
2988
|
}
|
|
2986
2989
|
let response = argsResult;
|
|
2987
2990
|
if (response.length) {
|
|
2988
2991
|
response = response[0];
|
|
2989
2992
|
}
|
|
2990
2993
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2991
|
-
type: "
|
|
2992
|
-
error: new
|
|
2993
|
-
response:
|
|
2994
|
+
type: "onerror",
|
|
2995
|
+
error: new Error("request error"),
|
|
2996
|
+
response: response,
|
|
2994
2997
|
details: details,
|
|
2995
2998
|
})) == null) {
|
|
2996
|
-
// reject(new
|
|
2999
|
+
// reject(new Error("response is intercept with onerror"));
|
|
2997
3000
|
return;
|
|
2998
3001
|
}
|
|
2999
3002
|
resolve({
|
|
3000
3003
|
data: response,
|
|
3001
3004
|
details: details,
|
|
3002
|
-
msg: "
|
|
3005
|
+
msg: "请求异常",
|
|
3003
3006
|
status: false,
|
|
3004
|
-
statusCode:
|
|
3005
|
-
type: "
|
|
3007
|
+
statusCode: response["status"],
|
|
3008
|
+
type: "onerror",
|
|
3006
3009
|
});
|
|
3007
3010
|
},
|
|
3008
|
-
/**
|
|
3009
|
-
* onloadstart请求开始-触发
|
|
3010
|
-
* @param details 配置
|
|
3011
|
-
* @param argsResult 返回的参数列表
|
|
3012
|
-
*/
|
|
3013
|
-
onLoadStart(details, argsResult) {
|
|
3014
|
-
// console.log(argsResult);
|
|
3015
|
-
if ("onloadstart" in details) {
|
|
3016
|
-
details.onloadstart.apply(this, argsResult);
|
|
3017
|
-
}
|
|
3018
|
-
else if ("onloadstart" in this.context.#defaultRequestOption) {
|
|
3019
|
-
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3020
|
-
}
|
|
3021
|
-
},
|
|
3022
3011
|
/**
|
|
3023
3012
|
* onload加载完毕-触发
|
|
3024
3013
|
* @param details 请求的配置
|
|
@@ -3098,7 +3087,7 @@ var Utils = (function () {
|
|
|
3098
3087
|
/* 状态码2xx都是成功的 */
|
|
3099
3088
|
if (Math.floor(originResponse.status / 100) === 2) {
|
|
3100
3089
|
if ((await this.context.HttpxResponseHook.successResponseCallBack(originResponse, details)) == null) {
|
|
3101
|
-
// reject(new
|
|
3090
|
+
// reject(new Error("response is intercept with onloada"));
|
|
3102
3091
|
return;
|
|
3103
3092
|
}
|
|
3104
3093
|
resolve({
|
|
@@ -3111,21 +3100,21 @@ var Utils = (function () {
|
|
|
3111
3100
|
});
|
|
3112
3101
|
}
|
|
3113
3102
|
else {
|
|
3114
|
-
this.context.
|
|
3103
|
+
this.context.HttpxResponseCallBack.onError(details, resolve, reject, argsResult);
|
|
3115
3104
|
}
|
|
3116
3105
|
},
|
|
3117
3106
|
/**
|
|
3118
|
-
*
|
|
3107
|
+
* onloadstart请求开始-触发
|
|
3119
3108
|
* @param details 配置
|
|
3120
3109
|
* @param argsResult 返回的参数列表
|
|
3121
3110
|
*/
|
|
3122
|
-
|
|
3111
|
+
onLoadStart(details, argsResult) {
|
|
3123
3112
|
// console.log(argsResult);
|
|
3124
|
-
if ("
|
|
3125
|
-
details.
|
|
3113
|
+
if (typeof details?.onloadstart === "function") {
|
|
3114
|
+
details.onloadstart.apply(this, argsResult);
|
|
3126
3115
|
}
|
|
3127
|
-
else if (
|
|
3128
|
-
this.context.#defaultRequestOption.
|
|
3116
|
+
else if (typeof this.context.#defaultRequestOption?.onloadstart === "function") {
|
|
3117
|
+
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3129
3118
|
}
|
|
3130
3119
|
},
|
|
3131
3120
|
/**
|
|
@@ -3135,13 +3124,28 @@ var Utils = (function () {
|
|
|
3135
3124
|
*/
|
|
3136
3125
|
onReadyStateChange(details, argsResult) {
|
|
3137
3126
|
// console.log(argsResult);
|
|
3138
|
-
if (
|
|
3127
|
+
if (typeof details?.onreadystatechange === "function") {
|
|
3139
3128
|
details.onreadystatechange.apply(this, argsResult);
|
|
3140
3129
|
}
|
|
3141
|
-
else if (
|
|
3130
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3131
|
+
"function") {
|
|
3142
3132
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3143
3133
|
}
|
|
3144
3134
|
},
|
|
3135
|
+
/**
|
|
3136
|
+
* onprogress上传进度-触发
|
|
3137
|
+
* @param details 配置
|
|
3138
|
+
* @param argsResult 返回的参数列表
|
|
3139
|
+
*/
|
|
3140
|
+
onProgress(details, argsResult) {
|
|
3141
|
+
// console.log(argsResult);
|
|
3142
|
+
if (typeof details?.onprogress === "function") {
|
|
3143
|
+
details.onprogress.apply(this, argsResult);
|
|
3144
|
+
}
|
|
3145
|
+
else if (typeof this.context.#defaultRequestOption?.onprogress === "function") {
|
|
3146
|
+
this.context.#defaultRequestOption.onprogress.apply(this, argsResult);
|
|
3147
|
+
}
|
|
3148
|
+
},
|
|
3145
3149
|
};
|
|
3146
3150
|
HttpxRequest = {
|
|
3147
3151
|
context: this,
|
|
@@ -3191,15 +3195,12 @@ var Utils = (function () {
|
|
|
3191
3195
|
isFetch: true,
|
|
3192
3196
|
finalUrl: fetchResponse.url,
|
|
3193
3197
|
readyState: 4,
|
|
3194
|
-
// @ts-ignore
|
|
3195
3198
|
status: fetchResponse.status,
|
|
3196
3199
|
statusText: fetchResponse.statusText,
|
|
3197
|
-
|
|
3198
|
-
response: void 0,
|
|
3200
|
+
response: "",
|
|
3199
3201
|
responseFetchHeaders: fetchResponse.headers,
|
|
3200
3202
|
responseHeaders: "",
|
|
3201
|
-
|
|
3202
|
-
responseText: void 0,
|
|
3203
|
+
responseText: "",
|
|
3203
3204
|
responseType: option.responseType,
|
|
3204
3205
|
responseXML: void 0,
|
|
3205
3206
|
};
|
|
@@ -3272,9 +3273,9 @@ var Utils = (function () {
|
|
|
3272
3273
|
// 转为XML结构
|
|
3273
3274
|
let parser = new DOMParser();
|
|
3274
3275
|
responseXML = parser.parseFromString(responseText, "text/xml");
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3276
|
+
httpxResponse.response = response;
|
|
3277
|
+
httpxResponse.responseText = responseText;
|
|
3278
|
+
httpxResponse.responseXML = responseXML;
|
|
3278
3279
|
// 执行回调
|
|
3279
3280
|
option.onload(httpxResponse);
|
|
3280
3281
|
})
|
|
@@ -3455,7 +3456,7 @@ var Utils = (function () {
|
|
|
3455
3456
|
}
|
|
3456
3457
|
/**
|
|
3457
3458
|
* GET 请求
|
|
3458
|
-
* @param url
|
|
3459
|
+
* @param url 请求的url
|
|
3459
3460
|
* @param details 配置
|
|
3460
3461
|
*/
|
|
3461
3462
|
get(...args) {
|
|
@@ -3521,27 +3522,22 @@ var Utils = (function () {
|
|
|
3521
3522
|
/** 取消请求 */
|
|
3522
3523
|
let abortFn = null;
|
|
3523
3524
|
let promise = new globalThis.Promise(async (resolve, reject) => {
|
|
3524
|
-
let requestOption = this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject);
|
|
3525
|
+
let requestOption = (this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject));
|
|
3525
3526
|
if (typeof beforeRequestOption === "function") {
|
|
3526
|
-
// @ts-ignore
|
|
3527
3527
|
beforeRequestOption(requestOption);
|
|
3528
3528
|
}
|
|
3529
|
-
|
|
3530
|
-
requestOption =
|
|
3531
|
-
this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3529
|
+
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3532
3530
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3533
3531
|
if (requestResult != null &&
|
|
3534
3532
|
typeof requestResult.abort === "function") {
|
|
3535
3533
|
abortFn = requestResult.abort;
|
|
3536
3534
|
}
|
|
3537
3535
|
});
|
|
3538
|
-
// @ts-ignore
|
|
3539
3536
|
promise.abort = () => {
|
|
3540
3537
|
if (typeof abortFn === "function") {
|
|
3541
3538
|
abortFn();
|
|
3542
3539
|
}
|
|
3543
3540
|
};
|
|
3544
|
-
// @ts-ignore
|
|
3545
3541
|
return promise;
|
|
3546
3542
|
}
|
|
3547
3543
|
}
|
|
@@ -3551,8 +3547,7 @@ var Utils = (function () {
|
|
|
3551
3547
|
#storeName;
|
|
3552
3548
|
#dbVersion;
|
|
3553
3549
|
/* websql的版本号,由于ios的问题,版本号的写法不一样 */
|
|
3554
|
-
//
|
|
3555
|
-
#slqVersion = "1";
|
|
3550
|
+
// #slqVersion = "1";
|
|
3556
3551
|
/* 监听IndexDB */
|
|
3557
3552
|
#indexedDB = window.indexedDB ||
|
|
3558
3553
|
window.mozIndexedDB ||
|
|
@@ -3560,8 +3555,7 @@ var Utils = (function () {
|
|
|
3560
3555
|
window.msIndexedDB;
|
|
3561
3556
|
/* 缓存数据库,避免同一个页面重复创建和销毁 */
|
|
3562
3557
|
#db = {};
|
|
3563
|
-
//
|
|
3564
|
-
#store = null;
|
|
3558
|
+
// #store: IDBObjectStore = null as any;
|
|
3565
3559
|
/** 状态码 */
|
|
3566
3560
|
#statusCode = {
|
|
3567
3561
|
operationSuccess: {
|
|
@@ -3606,7 +3600,7 @@ var Utils = (function () {
|
|
|
3606
3600
|
txn = this.#db[dbName].transaction(this.#storeName, "readwrite");
|
|
3607
3601
|
/* IndexDB的读写权限 */
|
|
3608
3602
|
store = txn.objectStore(this.#storeName);
|
|
3609
|
-
this.#store = store;
|
|
3603
|
+
// this.#store = store;
|
|
3610
3604
|
return store;
|
|
3611
3605
|
}
|
|
3612
3606
|
/**
|
|
@@ -4331,12 +4325,40 @@ var Utils = (function () {
|
|
|
4331
4325
|
}
|
|
4332
4326
|
|
|
4333
4327
|
class UtilsDictionary {
|
|
4334
|
-
items
|
|
4328
|
+
items;
|
|
4335
4329
|
constructor(key, value) {
|
|
4330
|
+
this.items = {};
|
|
4336
4331
|
if (key != null) {
|
|
4337
4332
|
this.set(key, value);
|
|
4338
4333
|
}
|
|
4339
4334
|
}
|
|
4335
|
+
/**
|
|
4336
|
+
* 获取字典的长度,同this.size
|
|
4337
|
+
*/
|
|
4338
|
+
get length() {
|
|
4339
|
+
return this.size();
|
|
4340
|
+
}
|
|
4341
|
+
/**
|
|
4342
|
+
* 迭代器
|
|
4343
|
+
*/
|
|
4344
|
+
get entries() {
|
|
4345
|
+
let that = this;
|
|
4346
|
+
return function* () {
|
|
4347
|
+
let itemKeys = Object.keys(that.getItems());
|
|
4348
|
+
for (const keyName of itemKeys) {
|
|
4349
|
+
yield [keyName, that.get(keyName)];
|
|
4350
|
+
}
|
|
4351
|
+
};
|
|
4352
|
+
}
|
|
4353
|
+
/**
|
|
4354
|
+
* 是否可遍历
|
|
4355
|
+
*/
|
|
4356
|
+
get [Symbol.iterator]() {
|
|
4357
|
+
let that = this;
|
|
4358
|
+
return function () {
|
|
4359
|
+
return that.entries();
|
|
4360
|
+
};
|
|
4361
|
+
}
|
|
4340
4362
|
/**
|
|
4341
4363
|
* 检查是否有某一个键
|
|
4342
4364
|
* @param key 键
|
|
@@ -4437,7 +4459,6 @@ var Utils = (function () {
|
|
|
4437
4459
|
* 返回字典本身
|
|
4438
4460
|
*/
|
|
4439
4461
|
getItems() {
|
|
4440
|
-
// @ts-ignore
|
|
4441
4462
|
return this.items;
|
|
4442
4463
|
}
|
|
4443
4464
|
/**
|
|
@@ -4447,38 +4468,15 @@ var Utils = (function () {
|
|
|
4447
4468
|
concat(data) {
|
|
4448
4469
|
this.items = commonUtil.assign(this.items, data.getItems());
|
|
4449
4470
|
}
|
|
4471
|
+
/**
|
|
4472
|
+
* 迭代字典
|
|
4473
|
+
* @param callbackfn 回调函数
|
|
4474
|
+
*/
|
|
4450
4475
|
forEach(callbackfn) {
|
|
4451
4476
|
for (const key in this.getItems()) {
|
|
4452
4477
|
callbackfn(this.get(key), key, this.getItems());
|
|
4453
4478
|
}
|
|
4454
4479
|
}
|
|
4455
|
-
/**
|
|
4456
|
-
* 获取字典的长度,同this.size
|
|
4457
|
-
*/
|
|
4458
|
-
get length() {
|
|
4459
|
-
return this.size();
|
|
4460
|
-
}
|
|
4461
|
-
/**
|
|
4462
|
-
* 迭代器
|
|
4463
|
-
*/
|
|
4464
|
-
get entries() {
|
|
4465
|
-
let that = this;
|
|
4466
|
-
return function* () {
|
|
4467
|
-
let itemKeys = Object.keys(that.getItems());
|
|
4468
|
-
for (const keyName of itemKeys) {
|
|
4469
|
-
yield [keyName, that.get(keyName)];
|
|
4470
|
-
}
|
|
4471
|
-
};
|
|
4472
|
-
}
|
|
4473
|
-
/**
|
|
4474
|
-
* 是否可遍历
|
|
4475
|
-
*/
|
|
4476
|
-
get [Symbol.iterator]() {
|
|
4477
|
-
let that = this;
|
|
4478
|
-
return function () {
|
|
4479
|
-
return that.entries();
|
|
4480
|
-
};
|
|
4481
|
-
}
|
|
4482
4480
|
}
|
|
4483
4481
|
|
|
4484
4482
|
class WindowApi {
|
|
@@ -4504,7 +4502,6 @@ var Utils = (function () {
|
|
|
4504
4502
|
if (!option) {
|
|
4505
4503
|
option = Object.assign({}, this.defaultApi);
|
|
4506
4504
|
}
|
|
4507
|
-
// @ts-ignore
|
|
4508
4505
|
this.api = Object.assign({}, option);
|
|
4509
4506
|
}
|
|
4510
4507
|
get document() {
|
|
@@ -4562,11 +4559,10 @@ var Utils = (function () {
|
|
|
4562
4559
|
deps = [];
|
|
4563
4560
|
active = true;
|
|
4564
4561
|
fn;
|
|
4565
|
-
//
|
|
4566
|
-
scheduler;
|
|
4562
|
+
// private scheduler;
|
|
4567
4563
|
constructor(fn, scheduler) {
|
|
4568
4564
|
this.fn = fn;
|
|
4569
|
-
this.scheduler = scheduler;
|
|
4565
|
+
// this.scheduler = scheduler;
|
|
4570
4566
|
}
|
|
4571
4567
|
run(cb) {
|
|
4572
4568
|
if (!this.active) {
|
|
@@ -4633,8 +4629,7 @@ var Utils = (function () {
|
|
|
4633
4629
|
reactive(target) {
|
|
4634
4630
|
const that = this;
|
|
4635
4631
|
if (!(typeof target === "object" && target !== null)) {
|
|
4636
|
-
|
|
4637
|
-
return;
|
|
4632
|
+
return void 0;
|
|
4638
4633
|
}
|
|
4639
4634
|
if (VueUtils.isReactive(target)) {
|
|
4640
4635
|
return target;
|
|
@@ -4704,7 +4699,6 @@ var Utils = (function () {
|
|
|
4704
4699
|
toRefs(object) {
|
|
4705
4700
|
const result = VueUtils.isArray(object) ? new Array(object.length) : {};
|
|
4706
4701
|
for (let key in object) {
|
|
4707
|
-
// @ts-ignore
|
|
4708
4702
|
result[key] = this.toRef(object, key);
|
|
4709
4703
|
}
|
|
4710
4704
|
return result;
|
|
@@ -5000,7 +4994,7 @@ var Utils = (function () {
|
|
|
5000
4994
|
};
|
|
5001
4995
|
|
|
5002
4996
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
5003
|
-
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),
|
|
4997
|
+
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
|
|
5004
4998
|
|
|
5005
4999
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
5006
5000
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -5432,7 +5426,6 @@ var Utils = (function () {
|
|
|
5432
5426
|
let text = textMatch[2];
|
|
5433
5427
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5434
5428
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5435
|
-
// @ts-ignore
|
|
5436
5429
|
return ($ele?.textContent || $ele?.innerText)?.includes(text);
|
|
5437
5430
|
});
|
|
5438
5431
|
}
|
|
@@ -5450,7 +5443,6 @@ var Utils = (function () {
|
|
|
5450
5443
|
let regexp = new RegExp(pattern, flags);
|
|
5451
5444
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5452
5445
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5453
|
-
// @ts-ignore
|
|
5454
5446
|
return Boolean(($ele?.textContent || $ele?.innerText)?.match(regexp));
|
|
5455
5447
|
});
|
|
5456
5448
|
}
|
|
@@ -5496,7 +5488,6 @@ var Utils = (function () {
|
|
|
5496
5488
|
let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
|
|
5497
5489
|
let text = textMatch[2];
|
|
5498
5490
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5499
|
-
// @ts-ignore
|
|
5500
5491
|
let content = $el?.textContent || $el?.innerText;
|
|
5501
5492
|
if (typeof content !== "string") {
|
|
5502
5493
|
content = "";
|
|
@@ -5516,7 +5507,6 @@ var Utils = (function () {
|
|
|
5516
5507
|
}
|
|
5517
5508
|
let regexp = new RegExp(pattern, flags);
|
|
5518
5509
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5519
|
-
// @ts-ignore
|
|
5520
5510
|
let content = $el?.textContent || $el?.innerText;
|
|
5521
5511
|
if (typeof content !== "string") {
|
|
5522
5512
|
content = "";
|
|
@@ -5547,7 +5537,6 @@ var Utils = (function () {
|
|
|
5547
5537
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5548
5538
|
let $closest = $el?.closest(selector);
|
|
5549
5539
|
if ($closest) {
|
|
5550
|
-
// @ts-ignore
|
|
5551
5540
|
let content = $el?.textContent || $el?.innerText;
|
|
5552
5541
|
if (typeof content === "string" && content.includes(text)) {
|
|
5553
5542
|
return $closest;
|
|
@@ -5570,7 +5559,6 @@ var Utils = (function () {
|
|
|
5570
5559
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5571
5560
|
let $closest = $el?.closest(selector);
|
|
5572
5561
|
if ($closest) {
|
|
5573
|
-
// @ts-ignore
|
|
5574
5562
|
let content = $el?.textContent || $el?.innerText;
|
|
5575
5563
|
if (typeof content === "string" && content.match(regexp)) {
|
|
5576
5564
|
return $closest;
|
|
@@ -5593,7 +5581,7 @@ var Utils = (function () {
|
|
|
5593
5581
|
this.windowApi = new WindowApi(option);
|
|
5594
5582
|
}
|
|
5595
5583
|
/** 版本号 */
|
|
5596
|
-
version = "2025.
|
|
5584
|
+
version = "2025.7.29";
|
|
5597
5585
|
addStyle(cssText) {
|
|
5598
5586
|
if (typeof cssText !== "string") {
|
|
5599
5587
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5677,7 +5665,7 @@ var Utils = (function () {
|
|
|
5677
5665
|
* ajax劫持库,支持xhr和fetch劫持。
|
|
5678
5666
|
* + 来源:https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
5679
5667
|
* + 作者:cxxjackie
|
|
5680
|
-
* + 版本:1.4.
|
|
5668
|
+
* + 版本:1.4.7
|
|
5681
5669
|
* + 旧版本:1.2.4
|
|
5682
5670
|
* + 文档:https://scriptcat.org/zh-CN/script-show-page/637/
|
|
5683
5671
|
* @param useOldVersion 是否使用旧版本,默认false
|
|
@@ -5690,7 +5678,7 @@ var Utils = (function () {
|
|
|
5690
5678
|
return ajaxHooker();
|
|
5691
5679
|
}
|
|
5692
5680
|
};
|
|
5693
|
-
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view =
|
|
5681
|
+
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = this.windowApi.window) {
|
|
5694
5682
|
if (!(canvasElement instanceof HTMLCanvasElement)) {
|
|
5695
5683
|
throw new Error("Utils.canvasClickByPosition 参数canvasElement必须是canvas元素");
|
|
5696
5684
|
}
|
|
@@ -5701,7 +5689,6 @@ var Utils = (function () {
|
|
|
5701
5689
|
cancelable: true,
|
|
5702
5690
|
clientX: clientX,
|
|
5703
5691
|
clientY: clientY,
|
|
5704
|
-
// @ts-ignore
|
|
5705
5692
|
view: view,
|
|
5706
5693
|
detail: 1,
|
|
5707
5694
|
};
|
|
@@ -6208,12 +6195,10 @@ var Utils = (function () {
|
|
|
6208
6195
|
}
|
|
6209
6196
|
getElementSelector(element) {
|
|
6210
6197
|
let UtilsContext = this;
|
|
6211
|
-
// @ts-ignore
|
|
6212
6198
|
if (!element)
|
|
6213
|
-
return;
|
|
6214
|
-
// @ts-ignore
|
|
6199
|
+
return void 0;
|
|
6215
6200
|
if (!element.parentElement)
|
|
6216
|
-
return;
|
|
6201
|
+
return void 0;
|
|
6217
6202
|
/* 如果元素有id属性,则直接返回id选择器 */
|
|
6218
6203
|
if (element.id)
|
|
6219
6204
|
return "#" + element.id;
|
|
@@ -6244,8 +6229,7 @@ var Utils = (function () {
|
|
|
6244
6229
|
let result = [...args];
|
|
6245
6230
|
let newResult = [];
|
|
6246
6231
|
if (result.length === 0) {
|
|
6247
|
-
|
|
6248
|
-
return;
|
|
6232
|
+
return void 0;
|
|
6249
6233
|
}
|
|
6250
6234
|
if (result.length > 1) {
|
|
6251
6235
|
if (result.length === 2 &&
|
|
@@ -6285,7 +6269,6 @@ var Utils = (function () {
|
|
|
6285
6269
|
// 当前页面最大的z-index
|
|
6286
6270
|
let zIndex = 0;
|
|
6287
6271
|
// 当前的最大z-index的元素,调试使用
|
|
6288
|
-
// @ts-ignore
|
|
6289
6272
|
let maxZIndexNode = null;
|
|
6290
6273
|
/**
|
|
6291
6274
|
* 元素是否可见
|
|
@@ -6346,8 +6329,7 @@ var Utils = (function () {
|
|
|
6346
6329
|
let result = [...args];
|
|
6347
6330
|
let newResult = [];
|
|
6348
6331
|
if (result.length === 0) {
|
|
6349
|
-
|
|
6350
|
-
return;
|
|
6332
|
+
return void 0;
|
|
6351
6333
|
}
|
|
6352
6334
|
if (result.length > 1) {
|
|
6353
6335
|
if (result.length === 2 &&
|
|
@@ -6821,7 +6803,6 @@ var Utils = (function () {
|
|
|
6821
6803
|
}
|
|
6822
6804
|
isJQuery(target) {
|
|
6823
6805
|
let result = false;
|
|
6824
|
-
// @ts-ignore
|
|
6825
6806
|
if (typeof jQuery === "object" && target instanceof jQuery) {
|
|
6826
6807
|
result = true;
|
|
6827
6808
|
}
|
|
@@ -7602,29 +7583,27 @@ var Utils = (function () {
|
|
|
7602
7583
|
EventTarget.prototype.addEventListener = function (...args) {
|
|
7603
7584
|
let type = args[0];
|
|
7604
7585
|
let callback = args[1];
|
|
7605
|
-
//
|
|
7606
|
-
args[2];
|
|
7586
|
+
// let options = args[2];
|
|
7607
7587
|
if (filter(type)) {
|
|
7608
7588
|
if (typeof callback === "function") {
|
|
7609
7589
|
args[1] = function (event) {
|
|
7610
7590
|
callback.call(this, trustEvent(event));
|
|
7611
7591
|
};
|
|
7612
7592
|
}
|
|
7613
|
-
else if (typeof callback === "object" &&
|
|
7614
|
-
"handleEvent" in callback) {
|
|
7593
|
+
else if (typeof callback === "object" && "handleEvent" in callback) {
|
|
7615
7594
|
let oldHandleEvent = callback["handleEvent"];
|
|
7616
7595
|
args[1]["handleEvent"] = function (event) {
|
|
7617
7596
|
if (event == null) {
|
|
7618
7597
|
return;
|
|
7619
7598
|
}
|
|
7620
7599
|
try {
|
|
7621
|
-
|
|
7600
|
+
// Proxy对象使用instanceof会报错
|
|
7601
|
+
// 这里故意尝试一下,如果报错,则说明是Proxy对象
|
|
7622
7602
|
event instanceof Proxy;
|
|
7623
7603
|
oldHandleEvent.call(this, trustEvent(event));
|
|
7624
7604
|
}
|
|
7625
7605
|
catch (error) {
|
|
7626
|
-
|
|
7627
|
-
event["isTrusted"] = isTrustValue;
|
|
7606
|
+
Reflect.set(event, "isTrusted", isTrustValue);
|
|
7628
7607
|
}
|
|
7629
7608
|
};
|
|
7630
7609
|
}
|
|
@@ -7697,8 +7676,8 @@ var Utils = (function () {
|
|
|
7697
7676
|
}
|
|
7698
7677
|
async init() {
|
|
7699
7678
|
let copyStatus = false;
|
|
7700
|
-
|
|
7701
|
-
|
|
7679
|
+
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7680
|
+
console.log(requestPermissionStatus);
|
|
7702
7681
|
if (this.hasClipboard() &&
|
|
7703
7682
|
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7704
7683
|
try {
|
|
@@ -7716,11 +7695,8 @@ var Utils = (function () {
|
|
|
7716
7695
|
this.destroy();
|
|
7717
7696
|
}
|
|
7718
7697
|
destroy() {
|
|
7719
|
-
// @ts-ignore
|
|
7720
7698
|
this.#resolve = null;
|
|
7721
|
-
// @ts-ignore
|
|
7722
7699
|
this.#copyData = null;
|
|
7723
|
-
// @ts-ignore
|
|
7724
7700
|
this.#copyDataType = null;
|
|
7725
7701
|
}
|
|
7726
7702
|
isText() {
|
|
@@ -7764,7 +7740,6 @@ var Utils = (function () {
|
|
|
7764
7740
|
if (navigator.permissions && navigator.permissions.query) {
|
|
7765
7741
|
navigator.permissions
|
|
7766
7742
|
.query({
|
|
7767
|
-
// @ts-ignore
|
|
7768
7743
|
name: "clipboard-write",
|
|
7769
7744
|
})
|
|
7770
7745
|
.then((permissionStatus) => {
|
|
@@ -7860,7 +7835,6 @@ var Utils = (function () {
|
|
|
7860
7835
|
dragSlider(selector, offsetX = this.windowApi.window.innerWidth) {
|
|
7861
7836
|
let UtilsContext = this;
|
|
7862
7837
|
function initMouseEvent(eventName, offSetX, offSetY) {
|
|
7863
|
-
// @ts-ignore
|
|
7864
7838
|
let win = typeof unsafeWindow === "undefined" ? globalThis : unsafeWindow;
|
|
7865
7839
|
let mouseEvent = UtilsContext.windowApi.document.createEvent("MouseEvents");
|
|
7866
7840
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
@@ -8019,7 +7993,6 @@ var Utils = (function () {
|
|
|
8019
7993
|
}
|
|
8020
7994
|
stringToRegular(targetString, flags = "ig") {
|
|
8021
7995
|
let reg;
|
|
8022
|
-
// @ts-ignore
|
|
8023
7996
|
flags = flags.toLowerCase();
|
|
8024
7997
|
if (typeof targetString === "string") {
|
|
8025
7998
|
reg = new RegExp(targetString.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"), flags);
|
|
@@ -8112,10 +8085,8 @@ var Utils = (function () {
|
|
|
8112
8085
|
*/
|
|
8113
8086
|
searchParamStrToObj(searhParamsStr) {
|
|
8114
8087
|
if (typeof searhParamsStr !== "string") {
|
|
8115
|
-
// @ts-ignore
|
|
8116
8088
|
return {};
|
|
8117
8089
|
}
|
|
8118
|
-
// @ts-ignore
|
|
8119
8090
|
return Object.fromEntries(new URLSearchParams(searhParamsStr));
|
|
8120
8091
|
}
|
|
8121
8092
|
/**
|
|
@@ -8818,7 +8789,6 @@ var Utils = (function () {
|
|
|
8818
8789
|
function requestPermissionsWithClipboard() {
|
|
8819
8790
|
navigator.permissions
|
|
8820
8791
|
.query({
|
|
8821
|
-
// @ts-ignore
|
|
8822
8792
|
name: "clipboard-read",
|
|
8823
8793
|
})
|
|
8824
8794
|
.then((permissionStatus) => {
|