@whitesev/utils 2.7.1 → 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/dist/index.amd.js +168 -212
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +168 -212
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +168 -212
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +168 -212
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +168 -212
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +168 -212
- 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/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 +27 -43
- package/src/UtilsGMMenu.ts +19 -22
- package/src/Vue.ts +4 -7
- package/src/WindowApi.ts +2 -5
- 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.cjs.js
CHANGED
|
@@ -17,14 +17,13 @@ class ColorConversion {
|
|
|
17
17
|
/**
|
|
18
18
|
* 16进制颜色转rgba
|
|
19
19
|
*
|
|
20
|
-
*
|
|
20
|
+
* 例如:`#ff0000` 转为 `rgba(123,123,123, 0.4)`
|
|
21
21
|
* @param hex
|
|
22
22
|
* @param opacity
|
|
23
23
|
*/
|
|
24
24
|
hexToRgba(hex, opacity) {
|
|
25
25
|
if (!this.isHex(hex)) {
|
|
26
|
-
|
|
27
|
-
throw new TypeError("输入错误的hex", hex);
|
|
26
|
+
throw new TypeError("输入错误的hex:" + hex);
|
|
28
27
|
}
|
|
29
28
|
return hex && hex.replace(/\s+/g, "").length === 7
|
|
30
29
|
? "rgba(" +
|
|
@@ -41,19 +40,16 @@ class ColorConversion {
|
|
|
41
40
|
/**
|
|
42
41
|
* hex转rgb
|
|
43
42
|
* @param str
|
|
44
|
-
* @returns
|
|
45
43
|
*/
|
|
46
44
|
hexToRgb(str) {
|
|
47
45
|
if (!this.isHex(str)) {
|
|
48
|
-
|
|
49
|
-
throw new TypeError("输入错误的hex", str);
|
|
46
|
+
throw new TypeError("输入错误的hex:" + str);
|
|
50
47
|
}
|
|
51
48
|
/* replace替换查找的到的字符串 */
|
|
52
49
|
str = str.replace("#", "");
|
|
53
50
|
/* match得到查询数组 */
|
|
54
51
|
let hxs = str.match(/../g);
|
|
55
52
|
for (let index = 0; index < 3; index++) {
|
|
56
|
-
// @ts-ignore
|
|
57
53
|
hxs[index] = parseInt(hxs[index], 16);
|
|
58
54
|
}
|
|
59
55
|
return hxs;
|
|
@@ -63,7 +59,6 @@ class ColorConversion {
|
|
|
63
59
|
* @param redValue
|
|
64
60
|
* @param greenValue
|
|
65
61
|
* @param blueValue
|
|
66
|
-
* @returns
|
|
67
62
|
*/
|
|
68
63
|
rgbToHex(redValue, greenValue, blueValue) {
|
|
69
64
|
/* 验证输入的rgb值是否合法 */
|
|
@@ -86,38 +81,30 @@ class ColorConversion {
|
|
|
86
81
|
* 获取颜色变暗或亮
|
|
87
82
|
* @param color 颜色
|
|
88
83
|
* @param level 0~1.0
|
|
89
|
-
* @returns
|
|
90
84
|
*/
|
|
91
85
|
getDarkColor(color, level) {
|
|
92
86
|
if (!this.isHex(color)) {
|
|
93
|
-
|
|
94
|
-
throw new TypeError("输入错误的hex", color);
|
|
87
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
95
88
|
}
|
|
96
89
|
let rgbc = this.hexToRgb(color);
|
|
97
90
|
for (let index = 0; index < 3; index++) {
|
|
98
|
-
// @ts-ignore
|
|
99
91
|
rgbc[index] = Math.floor(rgbc[index] * (1 - level));
|
|
100
92
|
}
|
|
101
|
-
// @ts-ignore
|
|
102
93
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
103
94
|
}
|
|
104
95
|
/**
|
|
105
96
|
* 获取颜色变亮
|
|
106
97
|
* @param color 颜色
|
|
107
98
|
* @param level 0~1.0
|
|
108
|
-
* @returns
|
|
109
99
|
*/
|
|
110
100
|
getLightColor(color, level) {
|
|
111
101
|
if (!this.isHex(color)) {
|
|
112
|
-
|
|
113
|
-
throw new TypeError("输入错误的hex", color);
|
|
102
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
114
103
|
}
|
|
115
104
|
let rgbc = this.hexToRgb(color);
|
|
116
105
|
for (let index = 0; index < 3; index++) {
|
|
117
|
-
// @ts-ignore
|
|
118
106
|
rgbc[index] = Math.floor((255 - rgbc[index]) * level + rgbc[index]);
|
|
119
107
|
}
|
|
120
|
-
// @ts-ignore
|
|
121
108
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
122
109
|
}
|
|
123
110
|
}
|
|
@@ -205,20 +192,20 @@ class GBKEncoder {
|
|
|
205
192
|
* @param str
|
|
206
193
|
*/
|
|
207
194
|
decode(str) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
|
|
195
|
+
let GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
|
|
196
|
+
let UTFMatcher = /%[0-9A-F]{2}/;
|
|
197
|
+
// let gbk = true;
|
|
198
|
+
let utf = true;
|
|
199
|
+
const that = this;
|
|
213
200
|
while (utf) {
|
|
214
201
|
let gbkMatch = str.match(GBKMatcher);
|
|
215
202
|
let utfMatch = str.match(UTFMatcher);
|
|
203
|
+
// gbk = Boolean(gbkMatch);
|
|
216
204
|
utf = Boolean(utfMatch);
|
|
217
205
|
if (gbkMatch && gbkMatch in that.#G2Uhash) {
|
|
218
206
|
str = str.replace(gbkMatch, String.fromCharCode(("0x" + that.#G2Uhash[gbkMatch])));
|
|
219
207
|
}
|
|
220
208
|
else {
|
|
221
|
-
// @ts-ignore
|
|
222
209
|
str = str.replace(utfMatch, decodeURIComponent(utfMatch));
|
|
223
210
|
}
|
|
224
211
|
}
|
|
@@ -249,7 +236,6 @@ const TryCatch = function (...args) {
|
|
|
249
236
|
* @param handler
|
|
250
237
|
*/
|
|
251
238
|
error(handler) {
|
|
252
|
-
// @ts-ignore
|
|
253
239
|
handleError = handler;
|
|
254
240
|
return TryCatchCore;
|
|
255
241
|
},
|
|
@@ -264,8 +250,9 @@ const TryCatch = function (...args) {
|
|
|
264
250
|
callbackFunction = callback;
|
|
265
251
|
context = __context__ || this;
|
|
266
252
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
267
|
-
|
|
268
|
-
|
|
253
|
+
return result !== void 0
|
|
254
|
+
? result
|
|
255
|
+
: TryCatchCore;
|
|
269
256
|
},
|
|
270
257
|
};
|
|
271
258
|
/**
|
|
@@ -1949,25 +1936,24 @@ class GMMenu {
|
|
|
1949
1936
|
let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
|
|
1950
1937
|
/** 油猴菜单上显示的文本 */
|
|
1951
1938
|
let showText = menuOption.showText(menuOption.text, defaultEnable);
|
|
1952
|
-
//
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
});
|
|
1939
|
+
// const GMMenuOptions = {
|
|
1940
|
+
// /**
|
|
1941
|
+
// * 菜单的id
|
|
1942
|
+
// */
|
|
1943
|
+
// id: menuOption.id,
|
|
1944
|
+
// /**
|
|
1945
|
+
// * 点击菜单项后是否应关闭弹出菜单
|
|
1946
|
+
// */
|
|
1947
|
+
// autoClose: menuOption.autoClose,
|
|
1948
|
+
// /**
|
|
1949
|
+
// * 菜单项的可选访问键
|
|
1950
|
+
// */
|
|
1951
|
+
// accessKey: menuOption.accessKey,
|
|
1952
|
+
// /**
|
|
1953
|
+
// * 菜单项的鼠标悬浮上的工具提示
|
|
1954
|
+
// */
|
|
1955
|
+
// title: menuOption.title,
|
|
1956
|
+
// };
|
|
1971
1957
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1972
1958
|
menuOption.autoReload =
|
|
1973
1959
|
typeof menuOption.autoReload !== "boolean"
|
|
@@ -2545,7 +2531,9 @@ class Httpx {
|
|
|
2545
2531
|
* 对请求的参数进行合并处理
|
|
2546
2532
|
*/
|
|
2547
2533
|
handleBeforeRequestOptionArgs(...args) {
|
|
2548
|
-
let option = {
|
|
2534
|
+
let option = {
|
|
2535
|
+
url: void 0,
|
|
2536
|
+
};
|
|
2549
2537
|
if (typeof args[0] === "string") {
|
|
2550
2538
|
/* 传入的是url,转为配置 */
|
|
2551
2539
|
let url = args[0];
|
|
@@ -2569,7 +2557,7 @@ class Httpx {
|
|
|
2569
2557
|
* @param method 当前请求方法,默认get
|
|
2570
2558
|
* @param userRequestOption 用户的请求配置
|
|
2571
2559
|
* @param resolve promise回调
|
|
2572
|
-
* @param reject 抛出错误回调
|
|
2560
|
+
* @param reject promise抛出错误回调
|
|
2573
2561
|
*/
|
|
2574
2562
|
getRequestOption(method, userRequestOption, resolve, reject) {
|
|
2575
2563
|
let that = this;
|
|
@@ -2627,25 +2615,25 @@ class Httpx {
|
|
|
2627
2615
|
password: userRequestOption.password ||
|
|
2628
2616
|
this.context.#defaultRequestOption.password,
|
|
2629
2617
|
onabort(...args) {
|
|
2630
|
-
that.context.
|
|
2618
|
+
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2631
2619
|
},
|
|
2632
2620
|
onerror(...args) {
|
|
2633
|
-
that.context.
|
|
2621
|
+
that.context.HttpxResponseCallBack.onError(userRequestOption, resolve, reject, args);
|
|
2634
2622
|
},
|
|
2635
2623
|
onloadstart(...args) {
|
|
2636
|
-
that.context.
|
|
2624
|
+
that.context.HttpxResponseCallBack.onLoadStart(userRequestOption, args);
|
|
2637
2625
|
},
|
|
2638
2626
|
onprogress(...args) {
|
|
2639
|
-
that.context.
|
|
2627
|
+
that.context.HttpxResponseCallBack.onProgress(userRequestOption, args);
|
|
2640
2628
|
},
|
|
2641
2629
|
onreadystatechange(...args) {
|
|
2642
|
-
that.context.
|
|
2630
|
+
that.context.HttpxResponseCallBack.onReadyStateChange(userRequestOption, args);
|
|
2643
2631
|
},
|
|
2644
2632
|
ontimeout(...args) {
|
|
2645
|
-
that.context.
|
|
2633
|
+
that.context.HttpxResponseCallBack.onTimeout(userRequestOption, resolve, reject, args);
|
|
2646
2634
|
},
|
|
2647
2635
|
onload(...args) {
|
|
2648
|
-
that.context.
|
|
2636
|
+
that.context.HttpxResponseCallBack.onLoad(userRequestOption, resolve, reject, args);
|
|
2649
2637
|
},
|
|
2650
2638
|
};
|
|
2651
2639
|
// 补全allowInterceptConfig参数
|
|
@@ -2757,7 +2745,6 @@ class Httpx {
|
|
|
2757
2745
|
else if (typeof requestOption.data === "object") {
|
|
2758
2746
|
isHandler = true;
|
|
2759
2747
|
// URLSearchParams参数可以转普通的string:string,包括FormData
|
|
2760
|
-
// @ts-ignore
|
|
2761
2748
|
let searchParams = new URLSearchParams(requestOption.data);
|
|
2762
2749
|
urlSearch = searchParams.toString();
|
|
2763
2750
|
}
|
|
@@ -2812,9 +2799,7 @@ class Httpx {
|
|
|
2812
2799
|
else if (ContentType.includes("application/x-www-form-urlencoded")) {
|
|
2813
2800
|
// application/x-www-form-urlencoded
|
|
2814
2801
|
if (typeof requestOption.data === "object") {
|
|
2815
|
-
requestOption.data = new URLSearchParams(
|
|
2816
|
-
// @ts-ignore
|
|
2817
|
-
requestOption.data).toString();
|
|
2802
|
+
requestOption.data = new URLSearchParams(requestOption.data).toString();
|
|
2818
2803
|
}
|
|
2819
2804
|
}
|
|
2820
2805
|
else if (ContentType.includes("multipart/form-data")) {
|
|
@@ -2834,7 +2819,7 @@ class Httpx {
|
|
|
2834
2819
|
},
|
|
2835
2820
|
/**
|
|
2836
2821
|
* 处理发送请求的配置,去除值为undefined、空function的值
|
|
2837
|
-
* @param option
|
|
2822
|
+
* @param option 请求配置
|
|
2838
2823
|
*/
|
|
2839
2824
|
removeRequestNullOption(option) {
|
|
2840
2825
|
Object.keys(option).forEach((keyName) => {
|
|
@@ -2846,13 +2831,13 @@ class Httpx {
|
|
|
2846
2831
|
}
|
|
2847
2832
|
});
|
|
2848
2833
|
if (commonUtil.isNull(option.url)) {
|
|
2849
|
-
throw new TypeError(`Utils.Httpx 参数
|
|
2834
|
+
throw new TypeError(`Utils.Httpx 参数url不能为空:${option.url}`);
|
|
2850
2835
|
}
|
|
2851
2836
|
return option;
|
|
2852
2837
|
},
|
|
2853
2838
|
/**
|
|
2854
2839
|
* 处理fetch的配置
|
|
2855
|
-
* @param option
|
|
2840
|
+
* @param option 请求配置
|
|
2856
2841
|
*/
|
|
2857
2842
|
handleFetchOption(option) {
|
|
2858
2843
|
/**
|
|
@@ -2905,21 +2890,21 @@ class Httpx {
|
|
|
2905
2890
|
};
|
|
2906
2891
|
},
|
|
2907
2892
|
};
|
|
2908
|
-
|
|
2893
|
+
HttpxResponseCallBack = {
|
|
2909
2894
|
context: this,
|
|
2910
2895
|
/**
|
|
2911
2896
|
* onabort请求被取消-触发
|
|
2912
2897
|
* @param details 配置
|
|
2913
|
-
* @param resolve 回调
|
|
2914
|
-
* @param reject
|
|
2898
|
+
* @param resolve promise回调
|
|
2899
|
+
* @param reject promise抛出错误回调
|
|
2915
2900
|
* @param argsResult 返回的参数列表
|
|
2916
2901
|
*/
|
|
2917
2902
|
async onAbort(details, resolve, reject, argsResult) {
|
|
2918
2903
|
// console.log(argsResult);
|
|
2919
|
-
if (
|
|
2904
|
+
if (typeof details?.onabort === "function") {
|
|
2920
2905
|
details.onabort.apply(this, argsResult);
|
|
2921
2906
|
}
|
|
2922
|
-
else if (
|
|
2907
|
+
else if (typeof this.context.#defaultRequestOption?.onabort === "function") {
|
|
2923
2908
|
this.context.#defaultRequestOption.onabort.apply(this, argsResult);
|
|
2924
2909
|
}
|
|
2925
2910
|
let response = argsResult;
|
|
@@ -2928,11 +2913,11 @@ class Httpx {
|
|
|
2928
2913
|
}
|
|
2929
2914
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2930
2915
|
type: "onabort",
|
|
2931
|
-
error: new
|
|
2916
|
+
error: new Error("request canceled"),
|
|
2932
2917
|
response: null,
|
|
2933
2918
|
details: details,
|
|
2934
2919
|
})) == null) {
|
|
2935
|
-
// reject(new
|
|
2920
|
+
// reject(new Error("response is intercept with onabort"));
|
|
2936
2921
|
return;
|
|
2937
2922
|
}
|
|
2938
2923
|
resolve({
|
|
@@ -2945,93 +2930,83 @@ class Httpx {
|
|
|
2945
2930
|
});
|
|
2946
2931
|
},
|
|
2947
2932
|
/**
|
|
2948
|
-
*
|
|
2933
|
+
* ontimeout请求超时-触发
|
|
2949
2934
|
* @param details 配置
|
|
2950
2935
|
* @param resolve 回调
|
|
2951
2936
|
* @param reject 抛出错误
|
|
2952
2937
|
* @param argsResult 返回的参数列表
|
|
2953
2938
|
*/
|
|
2954
|
-
async
|
|
2939
|
+
async onTimeout(details, resolve, reject, argsResult) {
|
|
2955
2940
|
// console.log(argsResult);
|
|
2956
|
-
if ("
|
|
2957
|
-
|
|
2941
|
+
if (typeof details?.ontimeout === "function") {
|
|
2942
|
+
// 执行配置中的ontime回调
|
|
2943
|
+
details.ontimeout.apply(this, argsResult);
|
|
2958
2944
|
}
|
|
2959
|
-
else if (
|
|
2960
|
-
|
|
2945
|
+
else if (typeof this.context.#defaultRequestOption?.ontimeout === "function") {
|
|
2946
|
+
// 执行默认配置的ontime回调
|
|
2947
|
+
this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
|
|
2961
2948
|
}
|
|
2949
|
+
// 获取响应结果
|
|
2962
2950
|
let response = argsResult;
|
|
2963
2951
|
if (response.length) {
|
|
2964
2952
|
response = response[0];
|
|
2965
2953
|
}
|
|
2954
|
+
// 执行错误回调的钩子
|
|
2966
2955
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2967
|
-
type: "
|
|
2968
|
-
error: new
|
|
2956
|
+
type: "ontimeout",
|
|
2957
|
+
error: new Error("request timeout"),
|
|
2969
2958
|
response: response,
|
|
2970
2959
|
details: details,
|
|
2971
2960
|
})) == null) {
|
|
2972
|
-
// reject(new
|
|
2961
|
+
// reject(new Error("response is intercept with ontimeout"));
|
|
2973
2962
|
return;
|
|
2974
2963
|
}
|
|
2975
2964
|
resolve({
|
|
2976
2965
|
data: response,
|
|
2977
2966
|
details: details,
|
|
2978
|
-
msg: "
|
|
2967
|
+
msg: "请求超时",
|
|
2979
2968
|
status: false,
|
|
2980
|
-
statusCode:
|
|
2981
|
-
type: "
|
|
2969
|
+
statusCode: 0,
|
|
2970
|
+
type: "ontimeout",
|
|
2982
2971
|
});
|
|
2983
2972
|
},
|
|
2984
2973
|
/**
|
|
2985
|
-
*
|
|
2974
|
+
* onerror请求异常-触发
|
|
2986
2975
|
* @param details 配置
|
|
2987
2976
|
* @param resolve 回调
|
|
2988
2977
|
* @param reject 抛出错误
|
|
2989
2978
|
* @param argsResult 返回的参数列表
|
|
2990
2979
|
*/
|
|
2991
|
-
async
|
|
2980
|
+
async onError(details, resolve, reject, argsResult) {
|
|
2992
2981
|
// console.log(argsResult);
|
|
2993
|
-
if ("
|
|
2994
|
-
details.
|
|
2982
|
+
if (typeof details?.onerror === "function") {
|
|
2983
|
+
details.onerror.apply(this, argsResult);
|
|
2995
2984
|
}
|
|
2996
|
-
else if (
|
|
2997
|
-
this.context.#defaultRequestOption.
|
|
2985
|
+
else if (typeof this.context.#defaultRequestOption?.onerror === "function") {
|
|
2986
|
+
this.context.#defaultRequestOption.onerror.apply(this, argsResult);
|
|
2998
2987
|
}
|
|
2999
2988
|
let response = argsResult;
|
|
3000
2989
|
if (response.length) {
|
|
3001
2990
|
response = response[0];
|
|
3002
2991
|
}
|
|
3003
2992
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
3004
|
-
type: "
|
|
3005
|
-
error: new
|
|
3006
|
-
response:
|
|
2993
|
+
type: "onerror",
|
|
2994
|
+
error: new Error("request error"),
|
|
2995
|
+
response: response,
|
|
3007
2996
|
details: details,
|
|
3008
2997
|
})) == null) {
|
|
3009
|
-
// reject(new
|
|
2998
|
+
// reject(new Error("response is intercept with onerror"));
|
|
3010
2999
|
return;
|
|
3011
3000
|
}
|
|
3012
3001
|
resolve({
|
|
3013
3002
|
data: response,
|
|
3014
3003
|
details: details,
|
|
3015
|
-
msg: "
|
|
3004
|
+
msg: "请求异常",
|
|
3016
3005
|
status: false,
|
|
3017
|
-
statusCode:
|
|
3018
|
-
type: "
|
|
3006
|
+
statusCode: response["status"],
|
|
3007
|
+
type: "onerror",
|
|
3019
3008
|
});
|
|
3020
3009
|
},
|
|
3021
|
-
/**
|
|
3022
|
-
* onloadstart请求开始-触发
|
|
3023
|
-
* @param details 配置
|
|
3024
|
-
* @param argsResult 返回的参数列表
|
|
3025
|
-
*/
|
|
3026
|
-
onLoadStart(details, argsResult) {
|
|
3027
|
-
// console.log(argsResult);
|
|
3028
|
-
if ("onloadstart" in details) {
|
|
3029
|
-
details.onloadstart.apply(this, argsResult);
|
|
3030
|
-
}
|
|
3031
|
-
else if ("onloadstart" in this.context.#defaultRequestOption) {
|
|
3032
|
-
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3033
|
-
}
|
|
3034
|
-
},
|
|
3035
3010
|
/**
|
|
3036
3011
|
* onload加载完毕-触发
|
|
3037
3012
|
* @param details 请求的配置
|
|
@@ -3111,7 +3086,7 @@ class Httpx {
|
|
|
3111
3086
|
/* 状态码2xx都是成功的 */
|
|
3112
3087
|
if (Math.floor(originResponse.status / 100) === 2) {
|
|
3113
3088
|
if ((await this.context.HttpxResponseHook.successResponseCallBack(originResponse, details)) == null) {
|
|
3114
|
-
// reject(new
|
|
3089
|
+
// reject(new Error("response is intercept with onloada"));
|
|
3115
3090
|
return;
|
|
3116
3091
|
}
|
|
3117
3092
|
resolve({
|
|
@@ -3124,21 +3099,21 @@ class Httpx {
|
|
|
3124
3099
|
});
|
|
3125
3100
|
}
|
|
3126
3101
|
else {
|
|
3127
|
-
this.context.
|
|
3102
|
+
this.context.HttpxResponseCallBack.onError(details, resolve, reject, argsResult);
|
|
3128
3103
|
}
|
|
3129
3104
|
},
|
|
3130
3105
|
/**
|
|
3131
|
-
*
|
|
3106
|
+
* onloadstart请求开始-触发
|
|
3132
3107
|
* @param details 配置
|
|
3133
3108
|
* @param argsResult 返回的参数列表
|
|
3134
3109
|
*/
|
|
3135
|
-
|
|
3110
|
+
onLoadStart(details, argsResult) {
|
|
3136
3111
|
// console.log(argsResult);
|
|
3137
|
-
if ("
|
|
3138
|
-
details.
|
|
3112
|
+
if (typeof details?.onloadstart === "function") {
|
|
3113
|
+
details.onloadstart.apply(this, argsResult);
|
|
3139
3114
|
}
|
|
3140
|
-
else if (
|
|
3141
|
-
this.context.#defaultRequestOption.
|
|
3115
|
+
else if (typeof this.context.#defaultRequestOption?.onloadstart === "function") {
|
|
3116
|
+
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3142
3117
|
}
|
|
3143
3118
|
},
|
|
3144
3119
|
/**
|
|
@@ -3148,13 +3123,28 @@ class Httpx {
|
|
|
3148
3123
|
*/
|
|
3149
3124
|
onReadyStateChange(details, argsResult) {
|
|
3150
3125
|
// console.log(argsResult);
|
|
3151
|
-
if (
|
|
3126
|
+
if (typeof details?.onreadystatechange === "function") {
|
|
3152
3127
|
details.onreadystatechange.apply(this, argsResult);
|
|
3153
3128
|
}
|
|
3154
|
-
else if (
|
|
3129
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3130
|
+
"function") {
|
|
3155
3131
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3156
3132
|
}
|
|
3157
3133
|
},
|
|
3134
|
+
/**
|
|
3135
|
+
* onprogress上传进度-触发
|
|
3136
|
+
* @param details 配置
|
|
3137
|
+
* @param argsResult 返回的参数列表
|
|
3138
|
+
*/
|
|
3139
|
+
onProgress(details, argsResult) {
|
|
3140
|
+
// console.log(argsResult);
|
|
3141
|
+
if (typeof details?.onprogress === "function") {
|
|
3142
|
+
details.onprogress.apply(this, argsResult);
|
|
3143
|
+
}
|
|
3144
|
+
else if (typeof this.context.#defaultRequestOption?.onprogress === "function") {
|
|
3145
|
+
this.context.#defaultRequestOption.onprogress.apply(this, argsResult);
|
|
3146
|
+
}
|
|
3147
|
+
},
|
|
3158
3148
|
};
|
|
3159
3149
|
HttpxRequest = {
|
|
3160
3150
|
context: this,
|
|
@@ -3204,15 +3194,12 @@ class Httpx {
|
|
|
3204
3194
|
isFetch: true,
|
|
3205
3195
|
finalUrl: fetchResponse.url,
|
|
3206
3196
|
readyState: 4,
|
|
3207
|
-
// @ts-ignore
|
|
3208
3197
|
status: fetchResponse.status,
|
|
3209
3198
|
statusText: fetchResponse.statusText,
|
|
3210
|
-
|
|
3211
|
-
response: void 0,
|
|
3199
|
+
response: "",
|
|
3212
3200
|
responseFetchHeaders: fetchResponse.headers,
|
|
3213
3201
|
responseHeaders: "",
|
|
3214
|
-
|
|
3215
|
-
responseText: void 0,
|
|
3202
|
+
responseText: "",
|
|
3216
3203
|
responseType: option.responseType,
|
|
3217
3204
|
responseXML: void 0,
|
|
3218
3205
|
};
|
|
@@ -3285,9 +3272,9 @@ class Httpx {
|
|
|
3285
3272
|
// 转为XML结构
|
|
3286
3273
|
let parser = new DOMParser();
|
|
3287
3274
|
responseXML = parser.parseFromString(responseText, "text/xml");
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3275
|
+
httpxResponse.response = response;
|
|
3276
|
+
httpxResponse.responseText = responseText;
|
|
3277
|
+
httpxResponse.responseXML = responseXML;
|
|
3291
3278
|
// 执行回调
|
|
3292
3279
|
option.onload(httpxResponse);
|
|
3293
3280
|
})
|
|
@@ -3468,7 +3455,7 @@ class Httpx {
|
|
|
3468
3455
|
}
|
|
3469
3456
|
/**
|
|
3470
3457
|
* GET 请求
|
|
3471
|
-
* @param url
|
|
3458
|
+
* @param url 请求的url
|
|
3472
3459
|
* @param details 配置
|
|
3473
3460
|
*/
|
|
3474
3461
|
get(...args) {
|
|
@@ -3534,27 +3521,22 @@ class Httpx {
|
|
|
3534
3521
|
/** 取消请求 */
|
|
3535
3522
|
let abortFn = null;
|
|
3536
3523
|
let promise = new globalThis.Promise(async (resolve, reject) => {
|
|
3537
|
-
let requestOption = this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject);
|
|
3524
|
+
let requestOption = (this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject));
|
|
3538
3525
|
if (typeof beforeRequestOption === "function") {
|
|
3539
|
-
// @ts-ignore
|
|
3540
3526
|
beforeRequestOption(requestOption);
|
|
3541
3527
|
}
|
|
3542
|
-
|
|
3543
|
-
requestOption =
|
|
3544
|
-
this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3528
|
+
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3545
3529
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3546
3530
|
if (requestResult != null &&
|
|
3547
3531
|
typeof requestResult.abort === "function") {
|
|
3548
3532
|
abortFn = requestResult.abort;
|
|
3549
3533
|
}
|
|
3550
3534
|
});
|
|
3551
|
-
// @ts-ignore
|
|
3552
3535
|
promise.abort = () => {
|
|
3553
3536
|
if (typeof abortFn === "function") {
|
|
3554
3537
|
abortFn();
|
|
3555
3538
|
}
|
|
3556
3539
|
};
|
|
3557
|
-
// @ts-ignore
|
|
3558
3540
|
return promise;
|
|
3559
3541
|
}
|
|
3560
3542
|
}
|
|
@@ -3564,8 +3546,7 @@ class indexedDB {
|
|
|
3564
3546
|
#storeName;
|
|
3565
3547
|
#dbVersion;
|
|
3566
3548
|
/* websql的版本号,由于ios的问题,版本号的写法不一样 */
|
|
3567
|
-
//
|
|
3568
|
-
#slqVersion = "1";
|
|
3549
|
+
// #slqVersion = "1";
|
|
3569
3550
|
/* 监听IndexDB */
|
|
3570
3551
|
#indexedDB = window.indexedDB ||
|
|
3571
3552
|
window.mozIndexedDB ||
|
|
@@ -3573,8 +3554,7 @@ class indexedDB {
|
|
|
3573
3554
|
window.msIndexedDB;
|
|
3574
3555
|
/* 缓存数据库,避免同一个页面重复创建和销毁 */
|
|
3575
3556
|
#db = {};
|
|
3576
|
-
//
|
|
3577
|
-
#store = null;
|
|
3557
|
+
// #store: IDBObjectStore = null as any;
|
|
3578
3558
|
/** 状态码 */
|
|
3579
3559
|
#statusCode = {
|
|
3580
3560
|
operationSuccess: {
|
|
@@ -3619,7 +3599,7 @@ class indexedDB {
|
|
|
3619
3599
|
txn = this.#db[dbName].transaction(this.#storeName, "readwrite");
|
|
3620
3600
|
/* IndexDB的读写权限 */
|
|
3621
3601
|
store = txn.objectStore(this.#storeName);
|
|
3622
|
-
this.#store = store;
|
|
3602
|
+
// this.#store = store;
|
|
3623
3603
|
return store;
|
|
3624
3604
|
}
|
|
3625
3605
|
/**
|
|
@@ -4344,12 +4324,40 @@ class Progress {
|
|
|
4344
4324
|
}
|
|
4345
4325
|
|
|
4346
4326
|
class UtilsDictionary {
|
|
4347
|
-
items
|
|
4327
|
+
items;
|
|
4348
4328
|
constructor(key, value) {
|
|
4329
|
+
this.items = {};
|
|
4349
4330
|
if (key != null) {
|
|
4350
4331
|
this.set(key, value);
|
|
4351
4332
|
}
|
|
4352
4333
|
}
|
|
4334
|
+
/**
|
|
4335
|
+
* 获取字典的长度,同this.size
|
|
4336
|
+
*/
|
|
4337
|
+
get length() {
|
|
4338
|
+
return this.size();
|
|
4339
|
+
}
|
|
4340
|
+
/**
|
|
4341
|
+
* 迭代器
|
|
4342
|
+
*/
|
|
4343
|
+
get entries() {
|
|
4344
|
+
let that = this;
|
|
4345
|
+
return function* () {
|
|
4346
|
+
let itemKeys = Object.keys(that.getItems());
|
|
4347
|
+
for (const keyName of itemKeys) {
|
|
4348
|
+
yield [keyName, that.get(keyName)];
|
|
4349
|
+
}
|
|
4350
|
+
};
|
|
4351
|
+
}
|
|
4352
|
+
/**
|
|
4353
|
+
* 是否可遍历
|
|
4354
|
+
*/
|
|
4355
|
+
get [Symbol.iterator]() {
|
|
4356
|
+
let that = this;
|
|
4357
|
+
return function () {
|
|
4358
|
+
return that.entries();
|
|
4359
|
+
};
|
|
4360
|
+
}
|
|
4353
4361
|
/**
|
|
4354
4362
|
* 检查是否有某一个键
|
|
4355
4363
|
* @param key 键
|
|
@@ -4450,7 +4458,6 @@ class UtilsDictionary {
|
|
|
4450
4458
|
* 返回字典本身
|
|
4451
4459
|
*/
|
|
4452
4460
|
getItems() {
|
|
4453
|
-
// @ts-ignore
|
|
4454
4461
|
return this.items;
|
|
4455
4462
|
}
|
|
4456
4463
|
/**
|
|
@@ -4460,38 +4467,15 @@ class UtilsDictionary {
|
|
|
4460
4467
|
concat(data) {
|
|
4461
4468
|
this.items = commonUtil.assign(this.items, data.getItems());
|
|
4462
4469
|
}
|
|
4470
|
+
/**
|
|
4471
|
+
* 迭代字典
|
|
4472
|
+
* @param callbackfn 回调函数
|
|
4473
|
+
*/
|
|
4463
4474
|
forEach(callbackfn) {
|
|
4464
4475
|
for (const key in this.getItems()) {
|
|
4465
4476
|
callbackfn(this.get(key), key, this.getItems());
|
|
4466
4477
|
}
|
|
4467
4478
|
}
|
|
4468
|
-
/**
|
|
4469
|
-
* 获取字典的长度,同this.size
|
|
4470
|
-
*/
|
|
4471
|
-
get length() {
|
|
4472
|
-
return this.size();
|
|
4473
|
-
}
|
|
4474
|
-
/**
|
|
4475
|
-
* 迭代器
|
|
4476
|
-
*/
|
|
4477
|
-
get entries() {
|
|
4478
|
-
let that = this;
|
|
4479
|
-
return function* () {
|
|
4480
|
-
let itemKeys = Object.keys(that.getItems());
|
|
4481
|
-
for (const keyName of itemKeys) {
|
|
4482
|
-
yield [keyName, that.get(keyName)];
|
|
4483
|
-
}
|
|
4484
|
-
};
|
|
4485
|
-
}
|
|
4486
|
-
/**
|
|
4487
|
-
* 是否可遍历
|
|
4488
|
-
*/
|
|
4489
|
-
get [Symbol.iterator]() {
|
|
4490
|
-
let that = this;
|
|
4491
|
-
return function () {
|
|
4492
|
-
return that.entries();
|
|
4493
|
-
};
|
|
4494
|
-
}
|
|
4495
4479
|
}
|
|
4496
4480
|
|
|
4497
4481
|
class WindowApi {
|
|
@@ -4517,7 +4501,6 @@ class WindowApi {
|
|
|
4517
4501
|
if (!option) {
|
|
4518
4502
|
option = Object.assign({}, this.defaultApi);
|
|
4519
4503
|
}
|
|
4520
|
-
// @ts-ignore
|
|
4521
4504
|
this.api = Object.assign({}, option);
|
|
4522
4505
|
}
|
|
4523
4506
|
get document() {
|
|
@@ -4575,11 +4558,10 @@ class ReactiveEffect {
|
|
|
4575
4558
|
deps = [];
|
|
4576
4559
|
active = true;
|
|
4577
4560
|
fn;
|
|
4578
|
-
//
|
|
4579
|
-
scheduler;
|
|
4561
|
+
// private scheduler;
|
|
4580
4562
|
constructor(fn, scheduler) {
|
|
4581
4563
|
this.fn = fn;
|
|
4582
|
-
this.scheduler = scheduler;
|
|
4564
|
+
// this.scheduler = scheduler;
|
|
4583
4565
|
}
|
|
4584
4566
|
run(cb) {
|
|
4585
4567
|
if (!this.active) {
|
|
@@ -4646,8 +4628,7 @@ class Vue {
|
|
|
4646
4628
|
reactive(target) {
|
|
4647
4629
|
const that = this;
|
|
4648
4630
|
if (!(typeof target === "object" && target !== null)) {
|
|
4649
|
-
|
|
4650
|
-
return;
|
|
4631
|
+
return void 0;
|
|
4651
4632
|
}
|
|
4652
4633
|
if (VueUtils.isReactive(target)) {
|
|
4653
4634
|
return target;
|
|
@@ -4717,7 +4698,6 @@ class Vue {
|
|
|
4717
4698
|
toRefs(object) {
|
|
4718
4699
|
const result = VueUtils.isArray(object) ? new Array(object.length) : {};
|
|
4719
4700
|
for (let key in object) {
|
|
4720
|
-
// @ts-ignore
|
|
4721
4701
|
result[key] = this.toRef(object, key);
|
|
4722
4702
|
}
|
|
4723
4703
|
return result;
|
|
@@ -5013,7 +4993,7 @@ const createLoadOrReturnBroker = (loadBroker, worker) => {
|
|
|
5013
4993
|
};
|
|
5014
4994
|
|
|
5015
4995
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
5016
|
-
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),
|
|
4996
|
+
const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),l=t(c);e.addUniqueNumber=l,e.generateUniqueNumber=c}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async({data:{id:a,method:i,params:u}})=>{const c=r[i];try{if(void 0===c)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===u?c():c(u);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const l=r instanceof Promise?await r:r;if(null===a){if(void 0!==l.result)throw s(i)}else{if(void 0===l.result)throw s(i);const{result:e,transferables:r=[]}=l;t.postMessage({id:a,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:a})}};var i=r(455);const u=new Map,c=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),o=(0,i.generateUniqueNumber)(u);return u.set(o,(()=>{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
|
|
5017
4997
|
|
|
5018
4998
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
5019
4999
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -5445,7 +5425,6 @@ class DOMUtils {
|
|
|
5445
5425
|
let text = textMatch[2];
|
|
5446
5426
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5447
5427
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5448
|
-
// @ts-ignore
|
|
5449
5428
|
return ($ele?.textContent || $ele?.innerText)?.includes(text);
|
|
5450
5429
|
});
|
|
5451
5430
|
}
|
|
@@ -5463,7 +5442,6 @@ class DOMUtils {
|
|
|
5463
5442
|
let regexp = new RegExp(pattern, flags);
|
|
5464
5443
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5465
5444
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5466
|
-
// @ts-ignore
|
|
5467
5445
|
return Boolean(($ele?.textContent || $ele?.innerText)?.match(regexp));
|
|
5468
5446
|
});
|
|
5469
5447
|
}
|
|
@@ -5509,7 +5487,6 @@ class DOMUtils {
|
|
|
5509
5487
|
let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
|
|
5510
5488
|
let text = textMatch[2];
|
|
5511
5489
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5512
|
-
// @ts-ignore
|
|
5513
5490
|
let content = $el?.textContent || $el?.innerText;
|
|
5514
5491
|
if (typeof content !== "string") {
|
|
5515
5492
|
content = "";
|
|
@@ -5529,7 +5506,6 @@ class DOMUtils {
|
|
|
5529
5506
|
}
|
|
5530
5507
|
let regexp = new RegExp(pattern, flags);
|
|
5531
5508
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5532
|
-
// @ts-ignore
|
|
5533
5509
|
let content = $el?.textContent || $el?.innerText;
|
|
5534
5510
|
if (typeof content !== "string") {
|
|
5535
5511
|
content = "";
|
|
@@ -5560,7 +5536,6 @@ class DOMUtils {
|
|
|
5560
5536
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5561
5537
|
let $closest = $el?.closest(selector);
|
|
5562
5538
|
if ($closest) {
|
|
5563
|
-
// @ts-ignore
|
|
5564
5539
|
let content = $el?.textContent || $el?.innerText;
|
|
5565
5540
|
if (typeof content === "string" && content.includes(text)) {
|
|
5566
5541
|
return $closest;
|
|
@@ -5583,7 +5558,6 @@ class DOMUtils {
|
|
|
5583
5558
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5584
5559
|
let $closest = $el?.closest(selector);
|
|
5585
5560
|
if ($closest) {
|
|
5586
|
-
// @ts-ignore
|
|
5587
5561
|
let content = $el?.textContent || $el?.innerText;
|
|
5588
5562
|
if (typeof content === "string" && content.match(regexp)) {
|
|
5589
5563
|
return $closest;
|
|
@@ -5703,7 +5677,7 @@ class Utils {
|
|
|
5703
5677
|
return ajaxHooker();
|
|
5704
5678
|
}
|
|
5705
5679
|
};
|
|
5706
|
-
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view =
|
|
5680
|
+
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = this.windowApi.window) {
|
|
5707
5681
|
if (!(canvasElement instanceof HTMLCanvasElement)) {
|
|
5708
5682
|
throw new Error("Utils.canvasClickByPosition 参数canvasElement必须是canvas元素");
|
|
5709
5683
|
}
|
|
@@ -5714,7 +5688,6 @@ class Utils {
|
|
|
5714
5688
|
cancelable: true,
|
|
5715
5689
|
clientX: clientX,
|
|
5716
5690
|
clientY: clientY,
|
|
5717
|
-
// @ts-ignore
|
|
5718
5691
|
view: view,
|
|
5719
5692
|
detail: 1,
|
|
5720
5693
|
};
|
|
@@ -6221,12 +6194,10 @@ class Utils {
|
|
|
6221
6194
|
}
|
|
6222
6195
|
getElementSelector(element) {
|
|
6223
6196
|
let UtilsContext = this;
|
|
6224
|
-
// @ts-ignore
|
|
6225
6197
|
if (!element)
|
|
6226
|
-
return;
|
|
6227
|
-
// @ts-ignore
|
|
6198
|
+
return void 0;
|
|
6228
6199
|
if (!element.parentElement)
|
|
6229
|
-
return;
|
|
6200
|
+
return void 0;
|
|
6230
6201
|
/* 如果元素有id属性,则直接返回id选择器 */
|
|
6231
6202
|
if (element.id)
|
|
6232
6203
|
return "#" + element.id;
|
|
@@ -6257,8 +6228,7 @@ class Utils {
|
|
|
6257
6228
|
let result = [...args];
|
|
6258
6229
|
let newResult = [];
|
|
6259
6230
|
if (result.length === 0) {
|
|
6260
|
-
|
|
6261
|
-
return;
|
|
6231
|
+
return void 0;
|
|
6262
6232
|
}
|
|
6263
6233
|
if (result.length > 1) {
|
|
6264
6234
|
if (result.length === 2 &&
|
|
@@ -6298,7 +6268,6 @@ class Utils {
|
|
|
6298
6268
|
// 当前页面最大的z-index
|
|
6299
6269
|
let zIndex = 0;
|
|
6300
6270
|
// 当前的最大z-index的元素,调试使用
|
|
6301
|
-
// @ts-ignore
|
|
6302
6271
|
let maxZIndexNode = null;
|
|
6303
6272
|
/**
|
|
6304
6273
|
* 元素是否可见
|
|
@@ -6359,8 +6328,7 @@ class Utils {
|
|
|
6359
6328
|
let result = [...args];
|
|
6360
6329
|
let newResult = [];
|
|
6361
6330
|
if (result.length === 0) {
|
|
6362
|
-
|
|
6363
|
-
return;
|
|
6331
|
+
return void 0;
|
|
6364
6332
|
}
|
|
6365
6333
|
if (result.length > 1) {
|
|
6366
6334
|
if (result.length === 2 &&
|
|
@@ -6834,7 +6802,6 @@ class Utils {
|
|
|
6834
6802
|
}
|
|
6835
6803
|
isJQuery(target) {
|
|
6836
6804
|
let result = false;
|
|
6837
|
-
// @ts-ignore
|
|
6838
6805
|
if (typeof jQuery === "object" && target instanceof jQuery) {
|
|
6839
6806
|
result = true;
|
|
6840
6807
|
}
|
|
@@ -7615,29 +7582,27 @@ class Utils {
|
|
|
7615
7582
|
EventTarget.prototype.addEventListener = function (...args) {
|
|
7616
7583
|
let type = args[0];
|
|
7617
7584
|
let callback = args[1];
|
|
7618
|
-
//
|
|
7619
|
-
args[2];
|
|
7585
|
+
// let options = args[2];
|
|
7620
7586
|
if (filter(type)) {
|
|
7621
7587
|
if (typeof callback === "function") {
|
|
7622
7588
|
args[1] = function (event) {
|
|
7623
7589
|
callback.call(this, trustEvent(event));
|
|
7624
7590
|
};
|
|
7625
7591
|
}
|
|
7626
|
-
else if (typeof callback === "object" &&
|
|
7627
|
-
"handleEvent" in callback) {
|
|
7592
|
+
else if (typeof callback === "object" && "handleEvent" in callback) {
|
|
7628
7593
|
let oldHandleEvent = callback["handleEvent"];
|
|
7629
7594
|
args[1]["handleEvent"] = function (event) {
|
|
7630
7595
|
if (event == null) {
|
|
7631
7596
|
return;
|
|
7632
7597
|
}
|
|
7633
7598
|
try {
|
|
7634
|
-
|
|
7599
|
+
// Proxy对象使用instanceof会报错
|
|
7600
|
+
// 这里故意尝试一下,如果报错,则说明是Proxy对象
|
|
7635
7601
|
event instanceof Proxy;
|
|
7636
7602
|
oldHandleEvent.call(this, trustEvent(event));
|
|
7637
7603
|
}
|
|
7638
7604
|
catch (error) {
|
|
7639
|
-
|
|
7640
|
-
event["isTrusted"] = isTrustValue;
|
|
7605
|
+
Reflect.set(event, "isTrusted", isTrustValue);
|
|
7641
7606
|
}
|
|
7642
7607
|
};
|
|
7643
7608
|
}
|
|
@@ -7710,8 +7675,8 @@ class Utils {
|
|
|
7710
7675
|
}
|
|
7711
7676
|
async init() {
|
|
7712
7677
|
let copyStatus = false;
|
|
7713
|
-
|
|
7714
|
-
|
|
7678
|
+
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7679
|
+
console.log(requestPermissionStatus);
|
|
7715
7680
|
if (this.hasClipboard() &&
|
|
7716
7681
|
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7717
7682
|
try {
|
|
@@ -7729,11 +7694,8 @@ class Utils {
|
|
|
7729
7694
|
this.destroy();
|
|
7730
7695
|
}
|
|
7731
7696
|
destroy() {
|
|
7732
|
-
// @ts-ignore
|
|
7733
7697
|
this.#resolve = null;
|
|
7734
|
-
// @ts-ignore
|
|
7735
7698
|
this.#copyData = null;
|
|
7736
|
-
// @ts-ignore
|
|
7737
7699
|
this.#copyDataType = null;
|
|
7738
7700
|
}
|
|
7739
7701
|
isText() {
|
|
@@ -7777,7 +7739,6 @@ class Utils {
|
|
|
7777
7739
|
if (navigator.permissions && navigator.permissions.query) {
|
|
7778
7740
|
navigator.permissions
|
|
7779
7741
|
.query({
|
|
7780
|
-
// @ts-ignore
|
|
7781
7742
|
name: "clipboard-write",
|
|
7782
7743
|
})
|
|
7783
7744
|
.then((permissionStatus) => {
|
|
@@ -7873,7 +7834,6 @@ class Utils {
|
|
|
7873
7834
|
dragSlider(selector, offsetX = this.windowApi.window.innerWidth) {
|
|
7874
7835
|
let UtilsContext = this;
|
|
7875
7836
|
function initMouseEvent(eventName, offSetX, offSetY) {
|
|
7876
|
-
// @ts-ignore
|
|
7877
7837
|
let win = typeof unsafeWindow === "undefined" ? globalThis : unsafeWindow;
|
|
7878
7838
|
let mouseEvent = UtilsContext.windowApi.document.createEvent("MouseEvents");
|
|
7879
7839
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
@@ -8032,7 +7992,6 @@ class Utils {
|
|
|
8032
7992
|
}
|
|
8033
7993
|
stringToRegular(targetString, flags = "ig") {
|
|
8034
7994
|
let reg;
|
|
8035
|
-
// @ts-ignore
|
|
8036
7995
|
flags = flags.toLowerCase();
|
|
8037
7996
|
if (typeof targetString === "string") {
|
|
8038
7997
|
reg = new RegExp(targetString.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"), flags);
|
|
@@ -8125,10 +8084,8 @@ class Utils {
|
|
|
8125
8084
|
*/
|
|
8126
8085
|
searchParamStrToObj(searhParamsStr) {
|
|
8127
8086
|
if (typeof searhParamsStr !== "string") {
|
|
8128
|
-
// @ts-ignore
|
|
8129
8087
|
return {};
|
|
8130
8088
|
}
|
|
8131
|
-
// @ts-ignore
|
|
8132
8089
|
return Object.fromEntries(new URLSearchParams(searhParamsStr));
|
|
8133
8090
|
}
|
|
8134
8091
|
/**
|
|
@@ -8831,7 +8788,6 @@ class Utils {
|
|
|
8831
8788
|
function requestPermissionsWithClipboard() {
|
|
8832
8789
|
navigator.permissions
|
|
8833
8790
|
.query({
|
|
8834
|
-
// @ts-ignore
|
|
8835
8791
|
name: "clipboard-read",
|
|
8836
8792
|
})
|
|
8837
8793
|
.then((permissionStatus) => {
|