@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.umd.js
CHANGED
|
@@ -21,14 +21,13 @@
|
|
|
21
21
|
/**
|
|
22
22
|
* 16进制颜色转rgba
|
|
23
23
|
*
|
|
24
|
-
*
|
|
24
|
+
* 例如:`#ff0000` 转为 `rgba(123,123,123, 0.4)`
|
|
25
25
|
* @param hex
|
|
26
26
|
* @param opacity
|
|
27
27
|
*/
|
|
28
28
|
hexToRgba(hex, opacity) {
|
|
29
29
|
if (!this.isHex(hex)) {
|
|
30
|
-
|
|
31
|
-
throw new TypeError("输入错误的hex", hex);
|
|
30
|
+
throw new TypeError("输入错误的hex:" + hex);
|
|
32
31
|
}
|
|
33
32
|
return hex && hex.replace(/\s+/g, "").length === 7
|
|
34
33
|
? "rgba(" +
|
|
@@ -45,19 +44,16 @@
|
|
|
45
44
|
/**
|
|
46
45
|
* hex转rgb
|
|
47
46
|
* @param str
|
|
48
|
-
* @returns
|
|
49
47
|
*/
|
|
50
48
|
hexToRgb(str) {
|
|
51
49
|
if (!this.isHex(str)) {
|
|
52
|
-
|
|
53
|
-
throw new TypeError("输入错误的hex", str);
|
|
50
|
+
throw new TypeError("输入错误的hex:" + str);
|
|
54
51
|
}
|
|
55
52
|
/* replace替换查找的到的字符串 */
|
|
56
53
|
str = str.replace("#", "");
|
|
57
54
|
/* match得到查询数组 */
|
|
58
55
|
let hxs = str.match(/../g);
|
|
59
56
|
for (let index = 0; index < 3; index++) {
|
|
60
|
-
// @ts-ignore
|
|
61
57
|
hxs[index] = parseInt(hxs[index], 16);
|
|
62
58
|
}
|
|
63
59
|
return hxs;
|
|
@@ -67,7 +63,6 @@
|
|
|
67
63
|
* @param redValue
|
|
68
64
|
* @param greenValue
|
|
69
65
|
* @param blueValue
|
|
70
|
-
* @returns
|
|
71
66
|
*/
|
|
72
67
|
rgbToHex(redValue, greenValue, blueValue) {
|
|
73
68
|
/* 验证输入的rgb值是否合法 */
|
|
@@ -90,38 +85,30 @@
|
|
|
90
85
|
* 获取颜色变暗或亮
|
|
91
86
|
* @param color 颜色
|
|
92
87
|
* @param level 0~1.0
|
|
93
|
-
* @returns
|
|
94
88
|
*/
|
|
95
89
|
getDarkColor(color, level) {
|
|
96
90
|
if (!this.isHex(color)) {
|
|
97
|
-
|
|
98
|
-
throw new TypeError("输入错误的hex", color);
|
|
91
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
99
92
|
}
|
|
100
93
|
let rgbc = this.hexToRgb(color);
|
|
101
94
|
for (let index = 0; index < 3; index++) {
|
|
102
|
-
// @ts-ignore
|
|
103
95
|
rgbc[index] = Math.floor(rgbc[index] * (1 - level));
|
|
104
96
|
}
|
|
105
|
-
// @ts-ignore
|
|
106
97
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
107
98
|
}
|
|
108
99
|
/**
|
|
109
100
|
* 获取颜色变亮
|
|
110
101
|
* @param color 颜色
|
|
111
102
|
* @param level 0~1.0
|
|
112
|
-
* @returns
|
|
113
103
|
*/
|
|
114
104
|
getLightColor(color, level) {
|
|
115
105
|
if (!this.isHex(color)) {
|
|
116
|
-
|
|
117
|
-
throw new TypeError("输入错误的hex", color);
|
|
106
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
118
107
|
}
|
|
119
108
|
let rgbc = this.hexToRgb(color);
|
|
120
109
|
for (let index = 0; index < 3; index++) {
|
|
121
|
-
// @ts-ignore
|
|
122
110
|
rgbc[index] = Math.floor((255 - rgbc[index]) * level + rgbc[index]);
|
|
123
111
|
}
|
|
124
|
-
// @ts-ignore
|
|
125
112
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
126
113
|
}
|
|
127
114
|
}
|
|
@@ -209,20 +196,20 @@
|
|
|
209
196
|
* @param str
|
|
210
197
|
*/
|
|
211
198
|
decode(str) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
|
|
199
|
+
let GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
|
|
200
|
+
let UTFMatcher = /%[0-9A-F]{2}/;
|
|
201
|
+
// let gbk = true;
|
|
202
|
+
let utf = true;
|
|
203
|
+
const that = this;
|
|
217
204
|
while (utf) {
|
|
218
205
|
let gbkMatch = str.match(GBKMatcher);
|
|
219
206
|
let utfMatch = str.match(UTFMatcher);
|
|
207
|
+
// gbk = Boolean(gbkMatch);
|
|
220
208
|
utf = Boolean(utfMatch);
|
|
221
209
|
if (gbkMatch && gbkMatch in that.#G2Uhash) {
|
|
222
210
|
str = str.replace(gbkMatch, String.fromCharCode(("0x" + that.#G2Uhash[gbkMatch])));
|
|
223
211
|
}
|
|
224
212
|
else {
|
|
225
|
-
// @ts-ignore
|
|
226
213
|
str = str.replace(utfMatch, decodeURIComponent(utfMatch));
|
|
227
214
|
}
|
|
228
215
|
}
|
|
@@ -253,7 +240,6 @@
|
|
|
253
240
|
* @param handler
|
|
254
241
|
*/
|
|
255
242
|
error(handler) {
|
|
256
|
-
// @ts-ignore
|
|
257
243
|
handleError = handler;
|
|
258
244
|
return TryCatchCore;
|
|
259
245
|
},
|
|
@@ -268,8 +254,9 @@
|
|
|
268
254
|
callbackFunction = callback;
|
|
269
255
|
context = __context__ || this;
|
|
270
256
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
271
|
-
|
|
272
|
-
|
|
257
|
+
return result !== void 0
|
|
258
|
+
? result
|
|
259
|
+
: TryCatchCore;
|
|
273
260
|
},
|
|
274
261
|
};
|
|
275
262
|
/**
|
|
@@ -752,13 +739,13 @@
|
|
|
752
739
|
// ==UserScript==
|
|
753
740
|
// @name ajaxHooker
|
|
754
741
|
// @author cxxjackie
|
|
755
|
-
// @version 1.4.
|
|
742
|
+
// @version 1.4.7
|
|
756
743
|
// @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
757
744
|
// @license GNU LGPL-3.0
|
|
758
745
|
// ==/UserScript==
|
|
759
746
|
|
|
760
747
|
const ajaxHooker = function () {
|
|
761
|
-
const version = "1.4.
|
|
748
|
+
const version = "1.4.7";
|
|
762
749
|
const hookInst = {
|
|
763
750
|
hookFns: [],
|
|
764
751
|
filters: [],
|
|
@@ -768,20 +755,18 @@
|
|
|
768
755
|
const resProto = win.Response.prototype;
|
|
769
756
|
const xhrResponses = ["response", "responseText", "responseXML"];
|
|
770
757
|
const fetchResponses = ["arrayBuffer", "blob", "formData", "json", "text"];
|
|
771
|
-
const
|
|
772
|
-
|
|
773
|
-
"headers",
|
|
774
|
-
"body",
|
|
775
|
-
"mode",
|
|
776
|
-
"credentials",
|
|
758
|
+
const xhrExtraProps = ["responseType", "timeout", "withCredentials"];
|
|
759
|
+
const fetchExtraProps = [
|
|
777
760
|
"cache",
|
|
761
|
+
"credentials",
|
|
762
|
+
"integrity",
|
|
763
|
+
"keepalive",
|
|
764
|
+
"mode",
|
|
765
|
+
"priority",
|
|
778
766
|
"redirect",
|
|
779
767
|
"referrer",
|
|
780
768
|
"referrerPolicy",
|
|
781
|
-
"integrity",
|
|
782
|
-
"keepalive",
|
|
783
769
|
"signal",
|
|
784
|
-
"priority",
|
|
785
770
|
];
|
|
786
771
|
const xhrAsyncEvents = ["readystatechange", "load", "loadend"];
|
|
787
772
|
const getType = {}.toString.call.bind({}.toString);
|
|
@@ -859,6 +844,10 @@
|
|
|
859
844
|
this.request = request;
|
|
860
845
|
this.requestClone = { ...this.request };
|
|
861
846
|
}
|
|
847
|
+
_recoverRequestKey(key) {
|
|
848
|
+
if (key in this.requestClone) this.request[key] = this.requestClone[key];
|
|
849
|
+
else delete this.request[key];
|
|
850
|
+
}
|
|
862
851
|
shouldFilter(filters) {
|
|
863
852
|
const { type, url, method, async } = this.request;
|
|
864
853
|
return (
|
|
@@ -879,7 +868,6 @@
|
|
|
879
868
|
);
|
|
880
869
|
}
|
|
881
870
|
waitForRequestKeys() {
|
|
882
|
-
const requestKeys = ["url", "method", "abort", "headers", "data"];
|
|
883
871
|
if (!this.request.async) {
|
|
884
872
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
885
873
|
if (this.shouldFilter(filters)) return;
|
|
@@ -887,27 +875,31 @@
|
|
|
887
875
|
if (getType(fn) === "[object Function]")
|
|
888
876
|
catchError(fn, this.request);
|
|
889
877
|
});
|
|
890
|
-
|
|
891
|
-
if (isThenable(this.request[key]))
|
|
892
|
-
|
|
893
|
-
});
|
|
878
|
+
for (const key in this.request) {
|
|
879
|
+
if (isThenable(this.request[key])) this._recoverRequestKey(key);
|
|
880
|
+
}
|
|
894
881
|
});
|
|
895
882
|
return new SyncThenable();
|
|
896
883
|
}
|
|
897
884
|
const promises = [];
|
|
885
|
+
const ignoreKeys = new Set(["type", "async", "response"]);
|
|
898
886
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
899
887
|
if (this.shouldFilter(filters)) return;
|
|
900
888
|
promises.push(
|
|
901
889
|
Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(
|
|
902
|
-
() =>
|
|
903
|
-
|
|
890
|
+
() => {
|
|
891
|
+
const requestKeys = [];
|
|
892
|
+
for (const key in this.request)
|
|
893
|
+
!ignoreKeys.has(key) && requestKeys.push(key);
|
|
894
|
+
return Promise.all(
|
|
904
895
|
requestKeys.map((key) =>
|
|
905
896
|
Promise.resolve(this.request[key]).then(
|
|
906
897
|
(val) => (this.request[key] = val),
|
|
907
|
-
() =>
|
|
898
|
+
() => this._recoverRequestKey(key)
|
|
908
899
|
)
|
|
909
900
|
)
|
|
910
|
-
)
|
|
901
|
+
);
|
|
902
|
+
}
|
|
911
903
|
)
|
|
912
904
|
);
|
|
913
905
|
});
|
|
@@ -1088,6 +1080,7 @@
|
|
|
1088
1080
|
e.stopImmediatePropagation = stopImmediatePropagation;
|
|
1089
1081
|
defineProp(e, "target", () => this.proxyXhr);
|
|
1090
1082
|
defineProp(e, "currentTarget", () => this.proxyXhr);
|
|
1083
|
+
defineProp(e, "srcElement", () => this.proxyXhr);
|
|
1091
1084
|
this.proxyEvents[e.type] &&
|
|
1092
1085
|
this.proxyEvents[e.type].forEach((fn) => {
|
|
1093
1086
|
this.resThenable.then(
|
|
@@ -1165,6 +1158,9 @@
|
|
|
1165
1158
|
for (const header in request.headers) {
|
|
1166
1159
|
xhr.setRequestHeader(header, request.headers[header]);
|
|
1167
1160
|
}
|
|
1161
|
+
for (const prop of xhrExtraProps) {
|
|
1162
|
+
if (prop in request) xhr[prop] = request[prop];
|
|
1163
|
+
}
|
|
1168
1164
|
xhr.send(request.data);
|
|
1169
1165
|
}
|
|
1170
1166
|
});
|
|
@@ -1186,8 +1182,10 @@
|
|
|
1186
1182
|
return new Promise(async (resolve, reject) => {
|
|
1187
1183
|
const init = {};
|
|
1188
1184
|
if (getType(url) === "[object Request]") {
|
|
1189
|
-
|
|
1185
|
+
init.method = url.method;
|
|
1186
|
+
init.headers = url.headers;
|
|
1190
1187
|
if (url.body) init.body = await url.arrayBuffer();
|
|
1188
|
+
for (const prop of fetchExtraProps) init[prop] = url[prop];
|
|
1191
1189
|
url = url.url;
|
|
1192
1190
|
}
|
|
1193
1191
|
url = url.toString();
|
|
@@ -1234,6 +1232,9 @@
|
|
|
1234
1232
|
init.method = request.method;
|
|
1235
1233
|
init.headers = request.headers;
|
|
1236
1234
|
init.body = request.data;
|
|
1235
|
+
for (const prop of fetchExtraProps) {
|
|
1236
|
+
if (prop in request) init[prop] = request[prop];
|
|
1237
|
+
}
|
|
1237
1238
|
winAh.realFetch.call(win, request.url, init).then((res) => {
|
|
1238
1239
|
if (typeof request.response === "function") {
|
|
1239
1240
|
const response = {
|
|
@@ -1939,25 +1940,24 @@
|
|
|
1939
1940
|
let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
|
|
1940
1941
|
/** 油猴菜单上显示的文本 */
|
|
1941
1942
|
let showText = menuOption.showText(menuOption.text, defaultEnable);
|
|
1942
|
-
//
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
});
|
|
1943
|
+
// const GMMenuOptions = {
|
|
1944
|
+
// /**
|
|
1945
|
+
// * 菜单的id
|
|
1946
|
+
// */
|
|
1947
|
+
// id: menuOption.id,
|
|
1948
|
+
// /**
|
|
1949
|
+
// * 点击菜单项后是否应关闭弹出菜单
|
|
1950
|
+
// */
|
|
1951
|
+
// autoClose: menuOption.autoClose,
|
|
1952
|
+
// /**
|
|
1953
|
+
// * 菜单项的可选访问键
|
|
1954
|
+
// */
|
|
1955
|
+
// accessKey: menuOption.accessKey,
|
|
1956
|
+
// /**
|
|
1957
|
+
// * 菜单项的鼠标悬浮上的工具提示
|
|
1958
|
+
// */
|
|
1959
|
+
// title: menuOption.title,
|
|
1960
|
+
// };
|
|
1961
1961
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1962
1962
|
menuOption.autoReload =
|
|
1963
1963
|
typeof menuOption.autoReload !== "boolean"
|
|
@@ -2535,7 +2535,9 @@
|
|
|
2535
2535
|
* 对请求的参数进行合并处理
|
|
2536
2536
|
*/
|
|
2537
2537
|
handleBeforeRequestOptionArgs(...args) {
|
|
2538
|
-
let option = {
|
|
2538
|
+
let option = {
|
|
2539
|
+
url: void 0,
|
|
2540
|
+
};
|
|
2539
2541
|
if (typeof args[0] === "string") {
|
|
2540
2542
|
/* 传入的是url,转为配置 */
|
|
2541
2543
|
let url = args[0];
|
|
@@ -2559,7 +2561,7 @@
|
|
|
2559
2561
|
* @param method 当前请求方法,默认get
|
|
2560
2562
|
* @param userRequestOption 用户的请求配置
|
|
2561
2563
|
* @param resolve promise回调
|
|
2562
|
-
* @param reject 抛出错误回调
|
|
2564
|
+
* @param reject promise抛出错误回调
|
|
2563
2565
|
*/
|
|
2564
2566
|
getRequestOption(method, userRequestOption, resolve, reject) {
|
|
2565
2567
|
let that = this;
|
|
@@ -2617,25 +2619,25 @@
|
|
|
2617
2619
|
password: userRequestOption.password ||
|
|
2618
2620
|
this.context.#defaultRequestOption.password,
|
|
2619
2621
|
onabort(...args) {
|
|
2620
|
-
that.context.
|
|
2622
|
+
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2621
2623
|
},
|
|
2622
2624
|
onerror(...args) {
|
|
2623
|
-
that.context.
|
|
2625
|
+
that.context.HttpxResponseCallBack.onError(userRequestOption, resolve, reject, args);
|
|
2624
2626
|
},
|
|
2625
2627
|
onloadstart(...args) {
|
|
2626
|
-
that.context.
|
|
2628
|
+
that.context.HttpxResponseCallBack.onLoadStart(userRequestOption, args);
|
|
2627
2629
|
},
|
|
2628
2630
|
onprogress(...args) {
|
|
2629
|
-
that.context.
|
|
2631
|
+
that.context.HttpxResponseCallBack.onProgress(userRequestOption, args);
|
|
2630
2632
|
},
|
|
2631
2633
|
onreadystatechange(...args) {
|
|
2632
|
-
that.context.
|
|
2634
|
+
that.context.HttpxResponseCallBack.onReadyStateChange(userRequestOption, args);
|
|
2633
2635
|
},
|
|
2634
2636
|
ontimeout(...args) {
|
|
2635
|
-
that.context.
|
|
2637
|
+
that.context.HttpxResponseCallBack.onTimeout(userRequestOption, resolve, reject, args);
|
|
2636
2638
|
},
|
|
2637
2639
|
onload(...args) {
|
|
2638
|
-
that.context.
|
|
2640
|
+
that.context.HttpxResponseCallBack.onLoad(userRequestOption, resolve, reject, args);
|
|
2639
2641
|
},
|
|
2640
2642
|
};
|
|
2641
2643
|
// 补全allowInterceptConfig参数
|
|
@@ -2747,7 +2749,6 @@
|
|
|
2747
2749
|
else if (typeof requestOption.data === "object") {
|
|
2748
2750
|
isHandler = true;
|
|
2749
2751
|
// URLSearchParams参数可以转普通的string:string,包括FormData
|
|
2750
|
-
// @ts-ignore
|
|
2751
2752
|
let searchParams = new URLSearchParams(requestOption.data);
|
|
2752
2753
|
urlSearch = searchParams.toString();
|
|
2753
2754
|
}
|
|
@@ -2802,9 +2803,7 @@
|
|
|
2802
2803
|
else if (ContentType.includes("application/x-www-form-urlencoded")) {
|
|
2803
2804
|
// application/x-www-form-urlencoded
|
|
2804
2805
|
if (typeof requestOption.data === "object") {
|
|
2805
|
-
requestOption.data = new URLSearchParams(
|
|
2806
|
-
// @ts-ignore
|
|
2807
|
-
requestOption.data).toString();
|
|
2806
|
+
requestOption.data = new URLSearchParams(requestOption.data).toString();
|
|
2808
2807
|
}
|
|
2809
2808
|
}
|
|
2810
2809
|
else if (ContentType.includes("multipart/form-data")) {
|
|
@@ -2824,7 +2823,7 @@
|
|
|
2824
2823
|
},
|
|
2825
2824
|
/**
|
|
2826
2825
|
* 处理发送请求的配置,去除值为undefined、空function的值
|
|
2827
|
-
* @param option
|
|
2826
|
+
* @param option 请求配置
|
|
2828
2827
|
*/
|
|
2829
2828
|
removeRequestNullOption(option) {
|
|
2830
2829
|
Object.keys(option).forEach((keyName) => {
|
|
@@ -2836,13 +2835,13 @@
|
|
|
2836
2835
|
}
|
|
2837
2836
|
});
|
|
2838
2837
|
if (commonUtil.isNull(option.url)) {
|
|
2839
|
-
throw new TypeError(`Utils.Httpx 参数
|
|
2838
|
+
throw new TypeError(`Utils.Httpx 参数url不能为空:${option.url}`);
|
|
2840
2839
|
}
|
|
2841
2840
|
return option;
|
|
2842
2841
|
},
|
|
2843
2842
|
/**
|
|
2844
2843
|
* 处理fetch的配置
|
|
2845
|
-
* @param option
|
|
2844
|
+
* @param option 请求配置
|
|
2846
2845
|
*/
|
|
2847
2846
|
handleFetchOption(option) {
|
|
2848
2847
|
/**
|
|
@@ -2895,21 +2894,21 @@
|
|
|
2895
2894
|
};
|
|
2896
2895
|
},
|
|
2897
2896
|
};
|
|
2898
|
-
|
|
2897
|
+
HttpxResponseCallBack = {
|
|
2899
2898
|
context: this,
|
|
2900
2899
|
/**
|
|
2901
2900
|
* onabort请求被取消-触发
|
|
2902
2901
|
* @param details 配置
|
|
2903
|
-
* @param resolve 回调
|
|
2904
|
-
* @param reject
|
|
2902
|
+
* @param resolve promise回调
|
|
2903
|
+
* @param reject promise抛出错误回调
|
|
2905
2904
|
* @param argsResult 返回的参数列表
|
|
2906
2905
|
*/
|
|
2907
2906
|
async onAbort(details, resolve, reject, argsResult) {
|
|
2908
2907
|
// console.log(argsResult);
|
|
2909
|
-
if (
|
|
2908
|
+
if (typeof details?.onabort === "function") {
|
|
2910
2909
|
details.onabort.apply(this, argsResult);
|
|
2911
2910
|
}
|
|
2912
|
-
else if (
|
|
2911
|
+
else if (typeof this.context.#defaultRequestOption?.onabort === "function") {
|
|
2913
2912
|
this.context.#defaultRequestOption.onabort.apply(this, argsResult);
|
|
2914
2913
|
}
|
|
2915
2914
|
let response = argsResult;
|
|
@@ -2918,11 +2917,11 @@
|
|
|
2918
2917
|
}
|
|
2919
2918
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2920
2919
|
type: "onabort",
|
|
2921
|
-
error: new
|
|
2920
|
+
error: new Error("request canceled"),
|
|
2922
2921
|
response: null,
|
|
2923
2922
|
details: details,
|
|
2924
2923
|
})) == null) {
|
|
2925
|
-
// reject(new
|
|
2924
|
+
// reject(new Error("response is intercept with onabort"));
|
|
2926
2925
|
return;
|
|
2927
2926
|
}
|
|
2928
2927
|
resolve({
|
|
@@ -2935,93 +2934,83 @@
|
|
|
2935
2934
|
});
|
|
2936
2935
|
},
|
|
2937
2936
|
/**
|
|
2938
|
-
*
|
|
2937
|
+
* ontimeout请求超时-触发
|
|
2939
2938
|
* @param details 配置
|
|
2940
2939
|
* @param resolve 回调
|
|
2941
2940
|
* @param reject 抛出错误
|
|
2942
2941
|
* @param argsResult 返回的参数列表
|
|
2943
2942
|
*/
|
|
2944
|
-
async
|
|
2943
|
+
async onTimeout(details, resolve, reject, argsResult) {
|
|
2945
2944
|
// console.log(argsResult);
|
|
2946
|
-
if ("
|
|
2947
|
-
|
|
2945
|
+
if (typeof details?.ontimeout === "function") {
|
|
2946
|
+
// 执行配置中的ontime回调
|
|
2947
|
+
details.ontimeout.apply(this, argsResult);
|
|
2948
2948
|
}
|
|
2949
|
-
else if (
|
|
2950
|
-
|
|
2949
|
+
else if (typeof this.context.#defaultRequestOption?.ontimeout === "function") {
|
|
2950
|
+
// 执行默认配置的ontime回调
|
|
2951
|
+
this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
|
|
2951
2952
|
}
|
|
2953
|
+
// 获取响应结果
|
|
2952
2954
|
let response = argsResult;
|
|
2953
2955
|
if (response.length) {
|
|
2954
2956
|
response = response[0];
|
|
2955
2957
|
}
|
|
2958
|
+
// 执行错误回调的钩子
|
|
2956
2959
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2957
|
-
type: "
|
|
2958
|
-
error: new
|
|
2960
|
+
type: "ontimeout",
|
|
2961
|
+
error: new Error("request timeout"),
|
|
2959
2962
|
response: response,
|
|
2960
2963
|
details: details,
|
|
2961
2964
|
})) == null) {
|
|
2962
|
-
// reject(new
|
|
2965
|
+
// reject(new Error("response is intercept with ontimeout"));
|
|
2963
2966
|
return;
|
|
2964
2967
|
}
|
|
2965
2968
|
resolve({
|
|
2966
2969
|
data: response,
|
|
2967
2970
|
details: details,
|
|
2968
|
-
msg: "
|
|
2971
|
+
msg: "请求超时",
|
|
2969
2972
|
status: false,
|
|
2970
|
-
statusCode:
|
|
2971
|
-
type: "
|
|
2973
|
+
statusCode: 0,
|
|
2974
|
+
type: "ontimeout",
|
|
2972
2975
|
});
|
|
2973
2976
|
},
|
|
2974
2977
|
/**
|
|
2975
|
-
*
|
|
2978
|
+
* onerror请求异常-触发
|
|
2976
2979
|
* @param details 配置
|
|
2977
2980
|
* @param resolve 回调
|
|
2978
2981
|
* @param reject 抛出错误
|
|
2979
2982
|
* @param argsResult 返回的参数列表
|
|
2980
2983
|
*/
|
|
2981
|
-
async
|
|
2984
|
+
async onError(details, resolve, reject, argsResult) {
|
|
2982
2985
|
// console.log(argsResult);
|
|
2983
|
-
if ("
|
|
2984
|
-
details.
|
|
2986
|
+
if (typeof details?.onerror === "function") {
|
|
2987
|
+
details.onerror.apply(this, argsResult);
|
|
2985
2988
|
}
|
|
2986
|
-
else if (
|
|
2987
|
-
this.context.#defaultRequestOption.
|
|
2989
|
+
else if (typeof this.context.#defaultRequestOption?.onerror === "function") {
|
|
2990
|
+
this.context.#defaultRequestOption.onerror.apply(this, argsResult);
|
|
2988
2991
|
}
|
|
2989
2992
|
let response = argsResult;
|
|
2990
2993
|
if (response.length) {
|
|
2991
2994
|
response = response[0];
|
|
2992
2995
|
}
|
|
2993
2996
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2994
|
-
type: "
|
|
2995
|
-
error: new
|
|
2996
|
-
response:
|
|
2997
|
+
type: "onerror",
|
|
2998
|
+
error: new Error("request error"),
|
|
2999
|
+
response: response,
|
|
2997
3000
|
details: details,
|
|
2998
3001
|
})) == null) {
|
|
2999
|
-
// reject(new
|
|
3002
|
+
// reject(new Error("response is intercept with onerror"));
|
|
3000
3003
|
return;
|
|
3001
3004
|
}
|
|
3002
3005
|
resolve({
|
|
3003
3006
|
data: response,
|
|
3004
3007
|
details: details,
|
|
3005
|
-
msg: "
|
|
3008
|
+
msg: "请求异常",
|
|
3006
3009
|
status: false,
|
|
3007
|
-
statusCode:
|
|
3008
|
-
type: "
|
|
3010
|
+
statusCode: response["status"],
|
|
3011
|
+
type: "onerror",
|
|
3009
3012
|
});
|
|
3010
3013
|
},
|
|
3011
|
-
/**
|
|
3012
|
-
* onloadstart请求开始-触发
|
|
3013
|
-
* @param details 配置
|
|
3014
|
-
* @param argsResult 返回的参数列表
|
|
3015
|
-
*/
|
|
3016
|
-
onLoadStart(details, argsResult) {
|
|
3017
|
-
// console.log(argsResult);
|
|
3018
|
-
if ("onloadstart" in details) {
|
|
3019
|
-
details.onloadstart.apply(this, argsResult);
|
|
3020
|
-
}
|
|
3021
|
-
else if ("onloadstart" in this.context.#defaultRequestOption) {
|
|
3022
|
-
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3023
|
-
}
|
|
3024
|
-
},
|
|
3025
3014
|
/**
|
|
3026
3015
|
* onload加载完毕-触发
|
|
3027
3016
|
* @param details 请求的配置
|
|
@@ -3101,7 +3090,7 @@
|
|
|
3101
3090
|
/* 状态码2xx都是成功的 */
|
|
3102
3091
|
if (Math.floor(originResponse.status / 100) === 2) {
|
|
3103
3092
|
if ((await this.context.HttpxResponseHook.successResponseCallBack(originResponse, details)) == null) {
|
|
3104
|
-
// reject(new
|
|
3093
|
+
// reject(new Error("response is intercept with onloada"));
|
|
3105
3094
|
return;
|
|
3106
3095
|
}
|
|
3107
3096
|
resolve({
|
|
@@ -3114,21 +3103,21 @@
|
|
|
3114
3103
|
});
|
|
3115
3104
|
}
|
|
3116
3105
|
else {
|
|
3117
|
-
this.context.
|
|
3106
|
+
this.context.HttpxResponseCallBack.onError(details, resolve, reject, argsResult);
|
|
3118
3107
|
}
|
|
3119
3108
|
},
|
|
3120
3109
|
/**
|
|
3121
|
-
*
|
|
3110
|
+
* onloadstart请求开始-触发
|
|
3122
3111
|
* @param details 配置
|
|
3123
3112
|
* @param argsResult 返回的参数列表
|
|
3124
3113
|
*/
|
|
3125
|
-
|
|
3114
|
+
onLoadStart(details, argsResult) {
|
|
3126
3115
|
// console.log(argsResult);
|
|
3127
|
-
if ("
|
|
3128
|
-
details.
|
|
3116
|
+
if (typeof details?.onloadstart === "function") {
|
|
3117
|
+
details.onloadstart.apply(this, argsResult);
|
|
3129
3118
|
}
|
|
3130
|
-
else if (
|
|
3131
|
-
this.context.#defaultRequestOption.
|
|
3119
|
+
else if (typeof this.context.#defaultRequestOption?.onloadstart === "function") {
|
|
3120
|
+
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3132
3121
|
}
|
|
3133
3122
|
},
|
|
3134
3123
|
/**
|
|
@@ -3138,13 +3127,28 @@
|
|
|
3138
3127
|
*/
|
|
3139
3128
|
onReadyStateChange(details, argsResult) {
|
|
3140
3129
|
// console.log(argsResult);
|
|
3141
|
-
if (
|
|
3130
|
+
if (typeof details?.onreadystatechange === "function") {
|
|
3142
3131
|
details.onreadystatechange.apply(this, argsResult);
|
|
3143
3132
|
}
|
|
3144
|
-
else if (
|
|
3133
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3134
|
+
"function") {
|
|
3145
3135
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3146
3136
|
}
|
|
3147
3137
|
},
|
|
3138
|
+
/**
|
|
3139
|
+
* onprogress上传进度-触发
|
|
3140
|
+
* @param details 配置
|
|
3141
|
+
* @param argsResult 返回的参数列表
|
|
3142
|
+
*/
|
|
3143
|
+
onProgress(details, argsResult) {
|
|
3144
|
+
// console.log(argsResult);
|
|
3145
|
+
if (typeof details?.onprogress === "function") {
|
|
3146
|
+
details.onprogress.apply(this, argsResult);
|
|
3147
|
+
}
|
|
3148
|
+
else if (typeof this.context.#defaultRequestOption?.onprogress === "function") {
|
|
3149
|
+
this.context.#defaultRequestOption.onprogress.apply(this, argsResult);
|
|
3150
|
+
}
|
|
3151
|
+
},
|
|
3148
3152
|
};
|
|
3149
3153
|
HttpxRequest = {
|
|
3150
3154
|
context: this,
|
|
@@ -3194,15 +3198,12 @@
|
|
|
3194
3198
|
isFetch: true,
|
|
3195
3199
|
finalUrl: fetchResponse.url,
|
|
3196
3200
|
readyState: 4,
|
|
3197
|
-
// @ts-ignore
|
|
3198
3201
|
status: fetchResponse.status,
|
|
3199
3202
|
statusText: fetchResponse.statusText,
|
|
3200
|
-
|
|
3201
|
-
response: void 0,
|
|
3203
|
+
response: "",
|
|
3202
3204
|
responseFetchHeaders: fetchResponse.headers,
|
|
3203
3205
|
responseHeaders: "",
|
|
3204
|
-
|
|
3205
|
-
responseText: void 0,
|
|
3206
|
+
responseText: "",
|
|
3206
3207
|
responseType: option.responseType,
|
|
3207
3208
|
responseXML: void 0,
|
|
3208
3209
|
};
|
|
@@ -3275,9 +3276,9 @@
|
|
|
3275
3276
|
// 转为XML结构
|
|
3276
3277
|
let parser = new DOMParser();
|
|
3277
3278
|
responseXML = parser.parseFromString(responseText, "text/xml");
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3279
|
+
httpxResponse.response = response;
|
|
3280
|
+
httpxResponse.responseText = responseText;
|
|
3281
|
+
httpxResponse.responseXML = responseXML;
|
|
3281
3282
|
// 执行回调
|
|
3282
3283
|
option.onload(httpxResponse);
|
|
3283
3284
|
})
|
|
@@ -3458,7 +3459,7 @@
|
|
|
3458
3459
|
}
|
|
3459
3460
|
/**
|
|
3460
3461
|
* GET 请求
|
|
3461
|
-
* @param url
|
|
3462
|
+
* @param url 请求的url
|
|
3462
3463
|
* @param details 配置
|
|
3463
3464
|
*/
|
|
3464
3465
|
get(...args) {
|
|
@@ -3524,27 +3525,22 @@
|
|
|
3524
3525
|
/** 取消请求 */
|
|
3525
3526
|
let abortFn = null;
|
|
3526
3527
|
let promise = new globalThis.Promise(async (resolve, reject) => {
|
|
3527
|
-
let requestOption = this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject);
|
|
3528
|
+
let requestOption = (this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject));
|
|
3528
3529
|
if (typeof beforeRequestOption === "function") {
|
|
3529
|
-
// @ts-ignore
|
|
3530
3530
|
beforeRequestOption(requestOption);
|
|
3531
3531
|
}
|
|
3532
|
-
|
|
3533
|
-
requestOption =
|
|
3534
|
-
this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3532
|
+
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3535
3533
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3536
3534
|
if (requestResult != null &&
|
|
3537
3535
|
typeof requestResult.abort === "function") {
|
|
3538
3536
|
abortFn = requestResult.abort;
|
|
3539
3537
|
}
|
|
3540
3538
|
});
|
|
3541
|
-
// @ts-ignore
|
|
3542
3539
|
promise.abort = () => {
|
|
3543
3540
|
if (typeof abortFn === "function") {
|
|
3544
3541
|
abortFn();
|
|
3545
3542
|
}
|
|
3546
3543
|
};
|
|
3547
|
-
// @ts-ignore
|
|
3548
3544
|
return promise;
|
|
3549
3545
|
}
|
|
3550
3546
|
}
|
|
@@ -3554,8 +3550,7 @@
|
|
|
3554
3550
|
#storeName;
|
|
3555
3551
|
#dbVersion;
|
|
3556
3552
|
/* websql的版本号,由于ios的问题,版本号的写法不一样 */
|
|
3557
|
-
//
|
|
3558
|
-
#slqVersion = "1";
|
|
3553
|
+
// #slqVersion = "1";
|
|
3559
3554
|
/* 监听IndexDB */
|
|
3560
3555
|
#indexedDB = window.indexedDB ||
|
|
3561
3556
|
window.mozIndexedDB ||
|
|
@@ -3563,8 +3558,7 @@
|
|
|
3563
3558
|
window.msIndexedDB;
|
|
3564
3559
|
/* 缓存数据库,避免同一个页面重复创建和销毁 */
|
|
3565
3560
|
#db = {};
|
|
3566
|
-
//
|
|
3567
|
-
#store = null;
|
|
3561
|
+
// #store: IDBObjectStore = null as any;
|
|
3568
3562
|
/** 状态码 */
|
|
3569
3563
|
#statusCode = {
|
|
3570
3564
|
operationSuccess: {
|
|
@@ -3609,7 +3603,7 @@
|
|
|
3609
3603
|
txn = this.#db[dbName].transaction(this.#storeName, "readwrite");
|
|
3610
3604
|
/* IndexDB的读写权限 */
|
|
3611
3605
|
store = txn.objectStore(this.#storeName);
|
|
3612
|
-
this.#store = store;
|
|
3606
|
+
// this.#store = store;
|
|
3613
3607
|
return store;
|
|
3614
3608
|
}
|
|
3615
3609
|
/**
|
|
@@ -4334,12 +4328,40 @@
|
|
|
4334
4328
|
}
|
|
4335
4329
|
|
|
4336
4330
|
class UtilsDictionary {
|
|
4337
|
-
items
|
|
4331
|
+
items;
|
|
4338
4332
|
constructor(key, value) {
|
|
4333
|
+
this.items = {};
|
|
4339
4334
|
if (key != null) {
|
|
4340
4335
|
this.set(key, value);
|
|
4341
4336
|
}
|
|
4342
4337
|
}
|
|
4338
|
+
/**
|
|
4339
|
+
* 获取字典的长度,同this.size
|
|
4340
|
+
*/
|
|
4341
|
+
get length() {
|
|
4342
|
+
return this.size();
|
|
4343
|
+
}
|
|
4344
|
+
/**
|
|
4345
|
+
* 迭代器
|
|
4346
|
+
*/
|
|
4347
|
+
get entries() {
|
|
4348
|
+
let that = this;
|
|
4349
|
+
return function* () {
|
|
4350
|
+
let itemKeys = Object.keys(that.getItems());
|
|
4351
|
+
for (const keyName of itemKeys) {
|
|
4352
|
+
yield [keyName, that.get(keyName)];
|
|
4353
|
+
}
|
|
4354
|
+
};
|
|
4355
|
+
}
|
|
4356
|
+
/**
|
|
4357
|
+
* 是否可遍历
|
|
4358
|
+
*/
|
|
4359
|
+
get [Symbol.iterator]() {
|
|
4360
|
+
let that = this;
|
|
4361
|
+
return function () {
|
|
4362
|
+
return that.entries();
|
|
4363
|
+
};
|
|
4364
|
+
}
|
|
4343
4365
|
/**
|
|
4344
4366
|
* 检查是否有某一个键
|
|
4345
4367
|
* @param key 键
|
|
@@ -4440,7 +4462,6 @@
|
|
|
4440
4462
|
* 返回字典本身
|
|
4441
4463
|
*/
|
|
4442
4464
|
getItems() {
|
|
4443
|
-
// @ts-ignore
|
|
4444
4465
|
return this.items;
|
|
4445
4466
|
}
|
|
4446
4467
|
/**
|
|
@@ -4450,38 +4471,15 @@
|
|
|
4450
4471
|
concat(data) {
|
|
4451
4472
|
this.items = commonUtil.assign(this.items, data.getItems());
|
|
4452
4473
|
}
|
|
4474
|
+
/**
|
|
4475
|
+
* 迭代字典
|
|
4476
|
+
* @param callbackfn 回调函数
|
|
4477
|
+
*/
|
|
4453
4478
|
forEach(callbackfn) {
|
|
4454
4479
|
for (const key in this.getItems()) {
|
|
4455
4480
|
callbackfn(this.get(key), key, this.getItems());
|
|
4456
4481
|
}
|
|
4457
4482
|
}
|
|
4458
|
-
/**
|
|
4459
|
-
* 获取字典的长度,同this.size
|
|
4460
|
-
*/
|
|
4461
|
-
get length() {
|
|
4462
|
-
return this.size();
|
|
4463
|
-
}
|
|
4464
|
-
/**
|
|
4465
|
-
* 迭代器
|
|
4466
|
-
*/
|
|
4467
|
-
get entries() {
|
|
4468
|
-
let that = this;
|
|
4469
|
-
return function* () {
|
|
4470
|
-
let itemKeys = Object.keys(that.getItems());
|
|
4471
|
-
for (const keyName of itemKeys) {
|
|
4472
|
-
yield [keyName, that.get(keyName)];
|
|
4473
|
-
}
|
|
4474
|
-
};
|
|
4475
|
-
}
|
|
4476
|
-
/**
|
|
4477
|
-
* 是否可遍历
|
|
4478
|
-
*/
|
|
4479
|
-
get [Symbol.iterator]() {
|
|
4480
|
-
let that = this;
|
|
4481
|
-
return function () {
|
|
4482
|
-
return that.entries();
|
|
4483
|
-
};
|
|
4484
|
-
}
|
|
4485
4483
|
}
|
|
4486
4484
|
|
|
4487
4485
|
class WindowApi {
|
|
@@ -4507,7 +4505,6 @@
|
|
|
4507
4505
|
if (!option) {
|
|
4508
4506
|
option = Object.assign({}, this.defaultApi);
|
|
4509
4507
|
}
|
|
4510
|
-
// @ts-ignore
|
|
4511
4508
|
this.api = Object.assign({}, option);
|
|
4512
4509
|
}
|
|
4513
4510
|
get document() {
|
|
@@ -4565,11 +4562,10 @@
|
|
|
4565
4562
|
deps = [];
|
|
4566
4563
|
active = true;
|
|
4567
4564
|
fn;
|
|
4568
|
-
//
|
|
4569
|
-
scheduler;
|
|
4565
|
+
// private scheduler;
|
|
4570
4566
|
constructor(fn, scheduler) {
|
|
4571
4567
|
this.fn = fn;
|
|
4572
|
-
this.scheduler = scheduler;
|
|
4568
|
+
// this.scheduler = scheduler;
|
|
4573
4569
|
}
|
|
4574
4570
|
run(cb) {
|
|
4575
4571
|
if (!this.active) {
|
|
@@ -4636,8 +4632,7 @@
|
|
|
4636
4632
|
reactive(target) {
|
|
4637
4633
|
const that = this;
|
|
4638
4634
|
if (!(typeof target === "object" && target !== null)) {
|
|
4639
|
-
|
|
4640
|
-
return;
|
|
4635
|
+
return void 0;
|
|
4641
4636
|
}
|
|
4642
4637
|
if (VueUtils.isReactive(target)) {
|
|
4643
4638
|
return target;
|
|
@@ -4707,7 +4702,6 @@
|
|
|
4707
4702
|
toRefs(object) {
|
|
4708
4703
|
const result = VueUtils.isArray(object) ? new Array(object.length) : {};
|
|
4709
4704
|
for (let key in object) {
|
|
4710
|
-
// @ts-ignore
|
|
4711
4705
|
result[key] = this.toRef(object, key);
|
|
4712
4706
|
}
|
|
4713
4707
|
return result;
|
|
@@ -5003,7 +4997,7 @@
|
|
|
5003
4997
|
};
|
|
5004
4998
|
|
|
5005
4999
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
5006
|
-
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),
|
|
5000
|
+
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
|
|
5007
5001
|
|
|
5008
5002
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
5009
5003
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -5435,7 +5429,6 @@
|
|
|
5435
5429
|
let text = textMatch[2];
|
|
5436
5430
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5437
5431
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5438
|
-
// @ts-ignore
|
|
5439
5432
|
return ($ele?.textContent || $ele?.innerText)?.includes(text);
|
|
5440
5433
|
});
|
|
5441
5434
|
}
|
|
@@ -5453,7 +5446,6 @@
|
|
|
5453
5446
|
let regexp = new RegExp(pattern, flags);
|
|
5454
5447
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5455
5448
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5456
|
-
// @ts-ignore
|
|
5457
5449
|
return Boolean(($ele?.textContent || $ele?.innerText)?.match(regexp));
|
|
5458
5450
|
});
|
|
5459
5451
|
}
|
|
@@ -5499,7 +5491,6 @@
|
|
|
5499
5491
|
let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
|
|
5500
5492
|
let text = textMatch[2];
|
|
5501
5493
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5502
|
-
// @ts-ignore
|
|
5503
5494
|
let content = $el?.textContent || $el?.innerText;
|
|
5504
5495
|
if (typeof content !== "string") {
|
|
5505
5496
|
content = "";
|
|
@@ -5519,7 +5510,6 @@
|
|
|
5519
5510
|
}
|
|
5520
5511
|
let regexp = new RegExp(pattern, flags);
|
|
5521
5512
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5522
|
-
// @ts-ignore
|
|
5523
5513
|
let content = $el?.textContent || $el?.innerText;
|
|
5524
5514
|
if (typeof content !== "string") {
|
|
5525
5515
|
content = "";
|
|
@@ -5550,7 +5540,6 @@
|
|
|
5550
5540
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5551
5541
|
let $closest = $el?.closest(selector);
|
|
5552
5542
|
if ($closest) {
|
|
5553
|
-
// @ts-ignore
|
|
5554
5543
|
let content = $el?.textContent || $el?.innerText;
|
|
5555
5544
|
if (typeof content === "string" && content.includes(text)) {
|
|
5556
5545
|
return $closest;
|
|
@@ -5573,7 +5562,6 @@
|
|
|
5573
5562
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5574
5563
|
let $closest = $el?.closest(selector);
|
|
5575
5564
|
if ($closest) {
|
|
5576
|
-
// @ts-ignore
|
|
5577
5565
|
let content = $el?.textContent || $el?.innerText;
|
|
5578
5566
|
if (typeof content === "string" && content.match(regexp)) {
|
|
5579
5567
|
return $closest;
|
|
@@ -5596,7 +5584,7 @@
|
|
|
5596
5584
|
this.windowApi = new WindowApi(option);
|
|
5597
5585
|
}
|
|
5598
5586
|
/** 版本号 */
|
|
5599
|
-
version = "2025.
|
|
5587
|
+
version = "2025.7.29";
|
|
5600
5588
|
addStyle(cssText) {
|
|
5601
5589
|
if (typeof cssText !== "string") {
|
|
5602
5590
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5680,7 +5668,7 @@
|
|
|
5680
5668
|
* ajax劫持库,支持xhr和fetch劫持。
|
|
5681
5669
|
* + 来源:https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
5682
5670
|
* + 作者:cxxjackie
|
|
5683
|
-
* + 版本:1.4.
|
|
5671
|
+
* + 版本:1.4.7
|
|
5684
5672
|
* + 旧版本:1.2.4
|
|
5685
5673
|
* + 文档:https://scriptcat.org/zh-CN/script-show-page/637/
|
|
5686
5674
|
* @param useOldVersion 是否使用旧版本,默认false
|
|
@@ -5693,7 +5681,7 @@
|
|
|
5693
5681
|
return ajaxHooker();
|
|
5694
5682
|
}
|
|
5695
5683
|
};
|
|
5696
|
-
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view =
|
|
5684
|
+
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = this.windowApi.window) {
|
|
5697
5685
|
if (!(canvasElement instanceof HTMLCanvasElement)) {
|
|
5698
5686
|
throw new Error("Utils.canvasClickByPosition 参数canvasElement必须是canvas元素");
|
|
5699
5687
|
}
|
|
@@ -5704,7 +5692,6 @@
|
|
|
5704
5692
|
cancelable: true,
|
|
5705
5693
|
clientX: clientX,
|
|
5706
5694
|
clientY: clientY,
|
|
5707
|
-
// @ts-ignore
|
|
5708
5695
|
view: view,
|
|
5709
5696
|
detail: 1,
|
|
5710
5697
|
};
|
|
@@ -6211,12 +6198,10 @@
|
|
|
6211
6198
|
}
|
|
6212
6199
|
getElementSelector(element) {
|
|
6213
6200
|
let UtilsContext = this;
|
|
6214
|
-
// @ts-ignore
|
|
6215
6201
|
if (!element)
|
|
6216
|
-
return;
|
|
6217
|
-
// @ts-ignore
|
|
6202
|
+
return void 0;
|
|
6218
6203
|
if (!element.parentElement)
|
|
6219
|
-
return;
|
|
6204
|
+
return void 0;
|
|
6220
6205
|
/* 如果元素有id属性,则直接返回id选择器 */
|
|
6221
6206
|
if (element.id)
|
|
6222
6207
|
return "#" + element.id;
|
|
@@ -6247,8 +6232,7 @@
|
|
|
6247
6232
|
let result = [...args];
|
|
6248
6233
|
let newResult = [];
|
|
6249
6234
|
if (result.length === 0) {
|
|
6250
|
-
|
|
6251
|
-
return;
|
|
6235
|
+
return void 0;
|
|
6252
6236
|
}
|
|
6253
6237
|
if (result.length > 1) {
|
|
6254
6238
|
if (result.length === 2 &&
|
|
@@ -6288,7 +6272,6 @@
|
|
|
6288
6272
|
// 当前页面最大的z-index
|
|
6289
6273
|
let zIndex = 0;
|
|
6290
6274
|
// 当前的最大z-index的元素,调试使用
|
|
6291
|
-
// @ts-ignore
|
|
6292
6275
|
let maxZIndexNode = null;
|
|
6293
6276
|
/**
|
|
6294
6277
|
* 元素是否可见
|
|
@@ -6349,8 +6332,7 @@
|
|
|
6349
6332
|
let result = [...args];
|
|
6350
6333
|
let newResult = [];
|
|
6351
6334
|
if (result.length === 0) {
|
|
6352
|
-
|
|
6353
|
-
return;
|
|
6335
|
+
return void 0;
|
|
6354
6336
|
}
|
|
6355
6337
|
if (result.length > 1) {
|
|
6356
6338
|
if (result.length === 2 &&
|
|
@@ -6824,7 +6806,6 @@
|
|
|
6824
6806
|
}
|
|
6825
6807
|
isJQuery(target) {
|
|
6826
6808
|
let result = false;
|
|
6827
|
-
// @ts-ignore
|
|
6828
6809
|
if (typeof jQuery === "object" && target instanceof jQuery) {
|
|
6829
6810
|
result = true;
|
|
6830
6811
|
}
|
|
@@ -7605,29 +7586,27 @@
|
|
|
7605
7586
|
EventTarget.prototype.addEventListener = function (...args) {
|
|
7606
7587
|
let type = args[0];
|
|
7607
7588
|
let callback = args[1];
|
|
7608
|
-
//
|
|
7609
|
-
args[2];
|
|
7589
|
+
// let options = args[2];
|
|
7610
7590
|
if (filter(type)) {
|
|
7611
7591
|
if (typeof callback === "function") {
|
|
7612
7592
|
args[1] = function (event) {
|
|
7613
7593
|
callback.call(this, trustEvent(event));
|
|
7614
7594
|
};
|
|
7615
7595
|
}
|
|
7616
|
-
else if (typeof callback === "object" &&
|
|
7617
|
-
"handleEvent" in callback) {
|
|
7596
|
+
else if (typeof callback === "object" && "handleEvent" in callback) {
|
|
7618
7597
|
let oldHandleEvent = callback["handleEvent"];
|
|
7619
7598
|
args[1]["handleEvent"] = function (event) {
|
|
7620
7599
|
if (event == null) {
|
|
7621
7600
|
return;
|
|
7622
7601
|
}
|
|
7623
7602
|
try {
|
|
7624
|
-
|
|
7603
|
+
// Proxy对象使用instanceof会报错
|
|
7604
|
+
// 这里故意尝试一下,如果报错,则说明是Proxy对象
|
|
7625
7605
|
event instanceof Proxy;
|
|
7626
7606
|
oldHandleEvent.call(this, trustEvent(event));
|
|
7627
7607
|
}
|
|
7628
7608
|
catch (error) {
|
|
7629
|
-
|
|
7630
|
-
event["isTrusted"] = isTrustValue;
|
|
7609
|
+
Reflect.set(event, "isTrusted", isTrustValue);
|
|
7631
7610
|
}
|
|
7632
7611
|
};
|
|
7633
7612
|
}
|
|
@@ -7700,8 +7679,8 @@
|
|
|
7700
7679
|
}
|
|
7701
7680
|
async init() {
|
|
7702
7681
|
let copyStatus = false;
|
|
7703
|
-
|
|
7704
|
-
|
|
7682
|
+
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7683
|
+
console.log(requestPermissionStatus);
|
|
7705
7684
|
if (this.hasClipboard() &&
|
|
7706
7685
|
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7707
7686
|
try {
|
|
@@ -7719,11 +7698,8 @@
|
|
|
7719
7698
|
this.destroy();
|
|
7720
7699
|
}
|
|
7721
7700
|
destroy() {
|
|
7722
|
-
// @ts-ignore
|
|
7723
7701
|
this.#resolve = null;
|
|
7724
|
-
// @ts-ignore
|
|
7725
7702
|
this.#copyData = null;
|
|
7726
|
-
// @ts-ignore
|
|
7727
7703
|
this.#copyDataType = null;
|
|
7728
7704
|
}
|
|
7729
7705
|
isText() {
|
|
@@ -7767,7 +7743,6 @@
|
|
|
7767
7743
|
if (navigator.permissions && navigator.permissions.query) {
|
|
7768
7744
|
navigator.permissions
|
|
7769
7745
|
.query({
|
|
7770
|
-
// @ts-ignore
|
|
7771
7746
|
name: "clipboard-write",
|
|
7772
7747
|
})
|
|
7773
7748
|
.then((permissionStatus) => {
|
|
@@ -7863,7 +7838,6 @@
|
|
|
7863
7838
|
dragSlider(selector, offsetX = this.windowApi.window.innerWidth) {
|
|
7864
7839
|
let UtilsContext = this;
|
|
7865
7840
|
function initMouseEvent(eventName, offSetX, offSetY) {
|
|
7866
|
-
// @ts-ignore
|
|
7867
7841
|
let win = typeof unsafeWindow === "undefined" ? globalThis : unsafeWindow;
|
|
7868
7842
|
let mouseEvent = UtilsContext.windowApi.document.createEvent("MouseEvents");
|
|
7869
7843
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
@@ -8022,7 +7996,6 @@
|
|
|
8022
7996
|
}
|
|
8023
7997
|
stringToRegular(targetString, flags = "ig") {
|
|
8024
7998
|
let reg;
|
|
8025
|
-
// @ts-ignore
|
|
8026
7999
|
flags = flags.toLowerCase();
|
|
8027
8000
|
if (typeof targetString === "string") {
|
|
8028
8001
|
reg = new RegExp(targetString.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"), flags);
|
|
@@ -8115,10 +8088,8 @@
|
|
|
8115
8088
|
*/
|
|
8116
8089
|
searchParamStrToObj(searhParamsStr) {
|
|
8117
8090
|
if (typeof searhParamsStr !== "string") {
|
|
8118
|
-
// @ts-ignore
|
|
8119
8091
|
return {};
|
|
8120
8092
|
}
|
|
8121
|
-
// @ts-ignore
|
|
8122
8093
|
return Object.fromEntries(new URLSearchParams(searhParamsStr));
|
|
8123
8094
|
}
|
|
8124
8095
|
/**
|
|
@@ -8821,7 +8792,6 @@
|
|
|
8821
8792
|
function requestPermissionsWithClipboard() {
|
|
8822
8793
|
navigator.permissions
|
|
8823
8794
|
.query({
|
|
8824
|
-
// @ts-ignore
|
|
8825
8795
|
name: "clipboard-read",
|
|
8826
8796
|
})
|
|
8827
8797
|
.then((permissionStatus) => {
|