@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.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
|
/**
|
|
@@ -1950,25 +1937,24 @@ var Utils = (function () {
|
|
|
1950
1937
|
let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
|
|
1951
1938
|
/** 油猴菜单上显示的文本 */
|
|
1952
1939
|
let showText = menuOption.showText(menuOption.text, defaultEnable);
|
|
1953
|
-
//
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
});
|
|
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
|
+
// };
|
|
1972
1958
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1973
1959
|
menuOption.autoReload =
|
|
1974
1960
|
typeof menuOption.autoReload !== "boolean"
|
|
@@ -2546,7 +2532,9 @@ var Utils = (function () {
|
|
|
2546
2532
|
* 对请求的参数进行合并处理
|
|
2547
2533
|
*/
|
|
2548
2534
|
handleBeforeRequestOptionArgs(...args) {
|
|
2549
|
-
let option = {
|
|
2535
|
+
let option = {
|
|
2536
|
+
url: void 0,
|
|
2537
|
+
};
|
|
2550
2538
|
if (typeof args[0] === "string") {
|
|
2551
2539
|
/* 传入的是url,转为配置 */
|
|
2552
2540
|
let url = args[0];
|
|
@@ -2570,7 +2558,7 @@ var Utils = (function () {
|
|
|
2570
2558
|
* @param method 当前请求方法,默认get
|
|
2571
2559
|
* @param userRequestOption 用户的请求配置
|
|
2572
2560
|
* @param resolve promise回调
|
|
2573
|
-
* @param reject 抛出错误回调
|
|
2561
|
+
* @param reject promise抛出错误回调
|
|
2574
2562
|
*/
|
|
2575
2563
|
getRequestOption(method, userRequestOption, resolve, reject) {
|
|
2576
2564
|
let that = this;
|
|
@@ -2628,25 +2616,25 @@ var Utils = (function () {
|
|
|
2628
2616
|
password: userRequestOption.password ||
|
|
2629
2617
|
this.context.#defaultRequestOption.password,
|
|
2630
2618
|
onabort(...args) {
|
|
2631
|
-
that.context.
|
|
2619
|
+
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2632
2620
|
},
|
|
2633
2621
|
onerror(...args) {
|
|
2634
|
-
that.context.
|
|
2622
|
+
that.context.HttpxResponseCallBack.onError(userRequestOption, resolve, reject, args);
|
|
2635
2623
|
},
|
|
2636
2624
|
onloadstart(...args) {
|
|
2637
|
-
that.context.
|
|
2625
|
+
that.context.HttpxResponseCallBack.onLoadStart(userRequestOption, args);
|
|
2638
2626
|
},
|
|
2639
2627
|
onprogress(...args) {
|
|
2640
|
-
that.context.
|
|
2628
|
+
that.context.HttpxResponseCallBack.onProgress(userRequestOption, args);
|
|
2641
2629
|
},
|
|
2642
2630
|
onreadystatechange(...args) {
|
|
2643
|
-
that.context.
|
|
2631
|
+
that.context.HttpxResponseCallBack.onReadyStateChange(userRequestOption, args);
|
|
2644
2632
|
},
|
|
2645
2633
|
ontimeout(...args) {
|
|
2646
|
-
that.context.
|
|
2634
|
+
that.context.HttpxResponseCallBack.onTimeout(userRequestOption, resolve, reject, args);
|
|
2647
2635
|
},
|
|
2648
2636
|
onload(...args) {
|
|
2649
|
-
that.context.
|
|
2637
|
+
that.context.HttpxResponseCallBack.onLoad(userRequestOption, resolve, reject, args);
|
|
2650
2638
|
},
|
|
2651
2639
|
};
|
|
2652
2640
|
// 补全allowInterceptConfig参数
|
|
@@ -2758,7 +2746,6 @@ var Utils = (function () {
|
|
|
2758
2746
|
else if (typeof requestOption.data === "object") {
|
|
2759
2747
|
isHandler = true;
|
|
2760
2748
|
// URLSearchParams参数可以转普通的string:string,包括FormData
|
|
2761
|
-
// @ts-ignore
|
|
2762
2749
|
let searchParams = new URLSearchParams(requestOption.data);
|
|
2763
2750
|
urlSearch = searchParams.toString();
|
|
2764
2751
|
}
|
|
@@ -2813,9 +2800,7 @@ var Utils = (function () {
|
|
|
2813
2800
|
else if (ContentType.includes("application/x-www-form-urlencoded")) {
|
|
2814
2801
|
// application/x-www-form-urlencoded
|
|
2815
2802
|
if (typeof requestOption.data === "object") {
|
|
2816
|
-
requestOption.data = new URLSearchParams(
|
|
2817
|
-
// @ts-ignore
|
|
2818
|
-
requestOption.data).toString();
|
|
2803
|
+
requestOption.data = new URLSearchParams(requestOption.data).toString();
|
|
2819
2804
|
}
|
|
2820
2805
|
}
|
|
2821
2806
|
else if (ContentType.includes("multipart/form-data")) {
|
|
@@ -2835,7 +2820,7 @@ var Utils = (function () {
|
|
|
2835
2820
|
},
|
|
2836
2821
|
/**
|
|
2837
2822
|
* 处理发送请求的配置,去除值为undefined、空function的值
|
|
2838
|
-
* @param option
|
|
2823
|
+
* @param option 请求配置
|
|
2839
2824
|
*/
|
|
2840
2825
|
removeRequestNullOption(option) {
|
|
2841
2826
|
Object.keys(option).forEach((keyName) => {
|
|
@@ -2847,13 +2832,13 @@ var Utils = (function () {
|
|
|
2847
2832
|
}
|
|
2848
2833
|
});
|
|
2849
2834
|
if (commonUtil.isNull(option.url)) {
|
|
2850
|
-
throw new TypeError(`Utils.Httpx 参数
|
|
2835
|
+
throw new TypeError(`Utils.Httpx 参数url不能为空:${option.url}`);
|
|
2851
2836
|
}
|
|
2852
2837
|
return option;
|
|
2853
2838
|
},
|
|
2854
2839
|
/**
|
|
2855
2840
|
* 处理fetch的配置
|
|
2856
|
-
* @param option
|
|
2841
|
+
* @param option 请求配置
|
|
2857
2842
|
*/
|
|
2858
2843
|
handleFetchOption(option) {
|
|
2859
2844
|
/**
|
|
@@ -2906,21 +2891,21 @@ var Utils = (function () {
|
|
|
2906
2891
|
};
|
|
2907
2892
|
},
|
|
2908
2893
|
};
|
|
2909
|
-
|
|
2894
|
+
HttpxResponseCallBack = {
|
|
2910
2895
|
context: this,
|
|
2911
2896
|
/**
|
|
2912
2897
|
* onabort请求被取消-触发
|
|
2913
2898
|
* @param details 配置
|
|
2914
|
-
* @param resolve 回调
|
|
2915
|
-
* @param reject
|
|
2899
|
+
* @param resolve promise回调
|
|
2900
|
+
* @param reject promise抛出错误回调
|
|
2916
2901
|
* @param argsResult 返回的参数列表
|
|
2917
2902
|
*/
|
|
2918
2903
|
async onAbort(details, resolve, reject, argsResult) {
|
|
2919
2904
|
// console.log(argsResult);
|
|
2920
|
-
if (
|
|
2905
|
+
if (typeof details?.onabort === "function") {
|
|
2921
2906
|
details.onabort.apply(this, argsResult);
|
|
2922
2907
|
}
|
|
2923
|
-
else if (
|
|
2908
|
+
else if (typeof this.context.#defaultRequestOption?.onabort === "function") {
|
|
2924
2909
|
this.context.#defaultRequestOption.onabort.apply(this, argsResult);
|
|
2925
2910
|
}
|
|
2926
2911
|
let response = argsResult;
|
|
@@ -2929,11 +2914,11 @@ var Utils = (function () {
|
|
|
2929
2914
|
}
|
|
2930
2915
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2931
2916
|
type: "onabort",
|
|
2932
|
-
error: new
|
|
2917
|
+
error: new Error("request canceled"),
|
|
2933
2918
|
response: null,
|
|
2934
2919
|
details: details,
|
|
2935
2920
|
})) == null) {
|
|
2936
|
-
// reject(new
|
|
2921
|
+
// reject(new Error("response is intercept with onabort"));
|
|
2937
2922
|
return;
|
|
2938
2923
|
}
|
|
2939
2924
|
resolve({
|
|
@@ -2946,93 +2931,83 @@ var Utils = (function () {
|
|
|
2946
2931
|
});
|
|
2947
2932
|
},
|
|
2948
2933
|
/**
|
|
2949
|
-
*
|
|
2934
|
+
* ontimeout请求超时-触发
|
|
2950
2935
|
* @param details 配置
|
|
2951
2936
|
* @param resolve 回调
|
|
2952
2937
|
* @param reject 抛出错误
|
|
2953
2938
|
* @param argsResult 返回的参数列表
|
|
2954
2939
|
*/
|
|
2955
|
-
async
|
|
2940
|
+
async onTimeout(details, resolve, reject, argsResult) {
|
|
2956
2941
|
// console.log(argsResult);
|
|
2957
|
-
if ("
|
|
2958
|
-
|
|
2942
|
+
if (typeof details?.ontimeout === "function") {
|
|
2943
|
+
// 执行配置中的ontime回调
|
|
2944
|
+
details.ontimeout.apply(this, argsResult);
|
|
2959
2945
|
}
|
|
2960
|
-
else if (
|
|
2961
|
-
|
|
2946
|
+
else if (typeof this.context.#defaultRequestOption?.ontimeout === "function") {
|
|
2947
|
+
// 执行默认配置的ontime回调
|
|
2948
|
+
this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
|
|
2962
2949
|
}
|
|
2950
|
+
// 获取响应结果
|
|
2963
2951
|
let response = argsResult;
|
|
2964
2952
|
if (response.length) {
|
|
2965
2953
|
response = response[0];
|
|
2966
2954
|
}
|
|
2955
|
+
// 执行错误回调的钩子
|
|
2967
2956
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2968
|
-
type: "
|
|
2969
|
-
error: new
|
|
2957
|
+
type: "ontimeout",
|
|
2958
|
+
error: new Error("request timeout"),
|
|
2970
2959
|
response: response,
|
|
2971
2960
|
details: details,
|
|
2972
2961
|
})) == null) {
|
|
2973
|
-
// reject(new
|
|
2962
|
+
// reject(new Error("response is intercept with ontimeout"));
|
|
2974
2963
|
return;
|
|
2975
2964
|
}
|
|
2976
2965
|
resolve({
|
|
2977
2966
|
data: response,
|
|
2978
2967
|
details: details,
|
|
2979
|
-
msg: "
|
|
2968
|
+
msg: "请求超时",
|
|
2980
2969
|
status: false,
|
|
2981
|
-
statusCode:
|
|
2982
|
-
type: "
|
|
2970
|
+
statusCode: 0,
|
|
2971
|
+
type: "ontimeout",
|
|
2983
2972
|
});
|
|
2984
2973
|
},
|
|
2985
2974
|
/**
|
|
2986
|
-
*
|
|
2975
|
+
* onerror请求异常-触发
|
|
2987
2976
|
* @param details 配置
|
|
2988
2977
|
* @param resolve 回调
|
|
2989
2978
|
* @param reject 抛出错误
|
|
2990
2979
|
* @param argsResult 返回的参数列表
|
|
2991
2980
|
*/
|
|
2992
|
-
async
|
|
2981
|
+
async onError(details, resolve, reject, argsResult) {
|
|
2993
2982
|
// console.log(argsResult);
|
|
2994
|
-
if ("
|
|
2995
|
-
details.
|
|
2983
|
+
if (typeof details?.onerror === "function") {
|
|
2984
|
+
details.onerror.apply(this, argsResult);
|
|
2996
2985
|
}
|
|
2997
|
-
else if (
|
|
2998
|
-
this.context.#defaultRequestOption.
|
|
2986
|
+
else if (typeof this.context.#defaultRequestOption?.onerror === "function") {
|
|
2987
|
+
this.context.#defaultRequestOption.onerror.apply(this, argsResult);
|
|
2999
2988
|
}
|
|
3000
2989
|
let response = argsResult;
|
|
3001
2990
|
if (response.length) {
|
|
3002
2991
|
response = response[0];
|
|
3003
2992
|
}
|
|
3004
2993
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
3005
|
-
type: "
|
|
3006
|
-
error: new
|
|
3007
|
-
response:
|
|
2994
|
+
type: "onerror",
|
|
2995
|
+
error: new Error("request error"),
|
|
2996
|
+
response: response,
|
|
3008
2997
|
details: details,
|
|
3009
2998
|
})) == null) {
|
|
3010
|
-
// reject(new
|
|
2999
|
+
// reject(new Error("response is intercept with onerror"));
|
|
3011
3000
|
return;
|
|
3012
3001
|
}
|
|
3013
3002
|
resolve({
|
|
3014
3003
|
data: response,
|
|
3015
3004
|
details: details,
|
|
3016
|
-
msg: "
|
|
3005
|
+
msg: "请求异常",
|
|
3017
3006
|
status: false,
|
|
3018
|
-
statusCode:
|
|
3019
|
-
type: "
|
|
3007
|
+
statusCode: response["status"],
|
|
3008
|
+
type: "onerror",
|
|
3020
3009
|
});
|
|
3021
3010
|
},
|
|
3022
|
-
/**
|
|
3023
|
-
* onloadstart请求开始-触发
|
|
3024
|
-
* @param details 配置
|
|
3025
|
-
* @param argsResult 返回的参数列表
|
|
3026
|
-
*/
|
|
3027
|
-
onLoadStart(details, argsResult) {
|
|
3028
|
-
// console.log(argsResult);
|
|
3029
|
-
if ("onloadstart" in details) {
|
|
3030
|
-
details.onloadstart.apply(this, argsResult);
|
|
3031
|
-
}
|
|
3032
|
-
else if ("onloadstart" in this.context.#defaultRequestOption) {
|
|
3033
|
-
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3034
|
-
}
|
|
3035
|
-
},
|
|
3036
3011
|
/**
|
|
3037
3012
|
* onload加载完毕-触发
|
|
3038
3013
|
* @param details 请求的配置
|
|
@@ -3112,7 +3087,7 @@ var Utils = (function () {
|
|
|
3112
3087
|
/* 状态码2xx都是成功的 */
|
|
3113
3088
|
if (Math.floor(originResponse.status / 100) === 2) {
|
|
3114
3089
|
if ((await this.context.HttpxResponseHook.successResponseCallBack(originResponse, details)) == null) {
|
|
3115
|
-
// reject(new
|
|
3090
|
+
// reject(new Error("response is intercept with onloada"));
|
|
3116
3091
|
return;
|
|
3117
3092
|
}
|
|
3118
3093
|
resolve({
|
|
@@ -3125,21 +3100,21 @@ var Utils = (function () {
|
|
|
3125
3100
|
});
|
|
3126
3101
|
}
|
|
3127
3102
|
else {
|
|
3128
|
-
this.context.
|
|
3103
|
+
this.context.HttpxResponseCallBack.onError(details, resolve, reject, argsResult);
|
|
3129
3104
|
}
|
|
3130
3105
|
},
|
|
3131
3106
|
/**
|
|
3132
|
-
*
|
|
3107
|
+
* onloadstart请求开始-触发
|
|
3133
3108
|
* @param details 配置
|
|
3134
3109
|
* @param argsResult 返回的参数列表
|
|
3135
3110
|
*/
|
|
3136
|
-
|
|
3111
|
+
onLoadStart(details, argsResult) {
|
|
3137
3112
|
// console.log(argsResult);
|
|
3138
|
-
if ("
|
|
3139
|
-
details.
|
|
3113
|
+
if (typeof details?.onloadstart === "function") {
|
|
3114
|
+
details.onloadstart.apply(this, argsResult);
|
|
3140
3115
|
}
|
|
3141
|
-
else if (
|
|
3142
|
-
this.context.#defaultRequestOption.
|
|
3116
|
+
else if (typeof this.context.#defaultRequestOption?.onloadstart === "function") {
|
|
3117
|
+
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3143
3118
|
}
|
|
3144
3119
|
},
|
|
3145
3120
|
/**
|
|
@@ -3149,13 +3124,28 @@ var Utils = (function () {
|
|
|
3149
3124
|
*/
|
|
3150
3125
|
onReadyStateChange(details, argsResult) {
|
|
3151
3126
|
// console.log(argsResult);
|
|
3152
|
-
if (
|
|
3127
|
+
if (typeof details?.onreadystatechange === "function") {
|
|
3153
3128
|
details.onreadystatechange.apply(this, argsResult);
|
|
3154
3129
|
}
|
|
3155
|
-
else if (
|
|
3130
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3131
|
+
"function") {
|
|
3156
3132
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3157
3133
|
}
|
|
3158
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
|
+
},
|
|
3159
3149
|
};
|
|
3160
3150
|
HttpxRequest = {
|
|
3161
3151
|
context: this,
|
|
@@ -3205,15 +3195,12 @@ var Utils = (function () {
|
|
|
3205
3195
|
isFetch: true,
|
|
3206
3196
|
finalUrl: fetchResponse.url,
|
|
3207
3197
|
readyState: 4,
|
|
3208
|
-
// @ts-ignore
|
|
3209
3198
|
status: fetchResponse.status,
|
|
3210
3199
|
statusText: fetchResponse.statusText,
|
|
3211
|
-
|
|
3212
|
-
response: void 0,
|
|
3200
|
+
response: "",
|
|
3213
3201
|
responseFetchHeaders: fetchResponse.headers,
|
|
3214
3202
|
responseHeaders: "",
|
|
3215
|
-
|
|
3216
|
-
responseText: void 0,
|
|
3203
|
+
responseText: "",
|
|
3217
3204
|
responseType: option.responseType,
|
|
3218
3205
|
responseXML: void 0,
|
|
3219
3206
|
};
|
|
@@ -3286,9 +3273,9 @@ var Utils = (function () {
|
|
|
3286
3273
|
// 转为XML结构
|
|
3287
3274
|
let parser = new DOMParser();
|
|
3288
3275
|
responseXML = parser.parseFromString(responseText, "text/xml");
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3276
|
+
httpxResponse.response = response;
|
|
3277
|
+
httpxResponse.responseText = responseText;
|
|
3278
|
+
httpxResponse.responseXML = responseXML;
|
|
3292
3279
|
// 执行回调
|
|
3293
3280
|
option.onload(httpxResponse);
|
|
3294
3281
|
})
|
|
@@ -3469,7 +3456,7 @@ var Utils = (function () {
|
|
|
3469
3456
|
}
|
|
3470
3457
|
/**
|
|
3471
3458
|
* GET 请求
|
|
3472
|
-
* @param url
|
|
3459
|
+
* @param url 请求的url
|
|
3473
3460
|
* @param details 配置
|
|
3474
3461
|
*/
|
|
3475
3462
|
get(...args) {
|
|
@@ -3535,27 +3522,22 @@ var Utils = (function () {
|
|
|
3535
3522
|
/** 取消请求 */
|
|
3536
3523
|
let abortFn = null;
|
|
3537
3524
|
let promise = new globalThis.Promise(async (resolve, reject) => {
|
|
3538
|
-
let requestOption = this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject);
|
|
3525
|
+
let requestOption = (this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject));
|
|
3539
3526
|
if (typeof beforeRequestOption === "function") {
|
|
3540
|
-
// @ts-ignore
|
|
3541
3527
|
beforeRequestOption(requestOption);
|
|
3542
3528
|
}
|
|
3543
|
-
|
|
3544
|
-
requestOption =
|
|
3545
|
-
this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3529
|
+
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3546
3530
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3547
3531
|
if (requestResult != null &&
|
|
3548
3532
|
typeof requestResult.abort === "function") {
|
|
3549
3533
|
abortFn = requestResult.abort;
|
|
3550
3534
|
}
|
|
3551
3535
|
});
|
|
3552
|
-
// @ts-ignore
|
|
3553
3536
|
promise.abort = () => {
|
|
3554
3537
|
if (typeof abortFn === "function") {
|
|
3555
3538
|
abortFn();
|
|
3556
3539
|
}
|
|
3557
3540
|
};
|
|
3558
|
-
// @ts-ignore
|
|
3559
3541
|
return promise;
|
|
3560
3542
|
}
|
|
3561
3543
|
}
|
|
@@ -3565,8 +3547,7 @@ var Utils = (function () {
|
|
|
3565
3547
|
#storeName;
|
|
3566
3548
|
#dbVersion;
|
|
3567
3549
|
/* websql的版本号,由于ios的问题,版本号的写法不一样 */
|
|
3568
|
-
//
|
|
3569
|
-
#slqVersion = "1";
|
|
3550
|
+
// #slqVersion = "1";
|
|
3570
3551
|
/* 监听IndexDB */
|
|
3571
3552
|
#indexedDB = window.indexedDB ||
|
|
3572
3553
|
window.mozIndexedDB ||
|
|
@@ -3574,8 +3555,7 @@ var Utils = (function () {
|
|
|
3574
3555
|
window.msIndexedDB;
|
|
3575
3556
|
/* 缓存数据库,避免同一个页面重复创建和销毁 */
|
|
3576
3557
|
#db = {};
|
|
3577
|
-
//
|
|
3578
|
-
#store = null;
|
|
3558
|
+
// #store: IDBObjectStore = null as any;
|
|
3579
3559
|
/** 状态码 */
|
|
3580
3560
|
#statusCode = {
|
|
3581
3561
|
operationSuccess: {
|
|
@@ -3620,7 +3600,7 @@ var Utils = (function () {
|
|
|
3620
3600
|
txn = this.#db[dbName].transaction(this.#storeName, "readwrite");
|
|
3621
3601
|
/* IndexDB的读写权限 */
|
|
3622
3602
|
store = txn.objectStore(this.#storeName);
|
|
3623
|
-
this.#store = store;
|
|
3603
|
+
// this.#store = store;
|
|
3624
3604
|
return store;
|
|
3625
3605
|
}
|
|
3626
3606
|
/**
|
|
@@ -4345,12 +4325,40 @@ var Utils = (function () {
|
|
|
4345
4325
|
}
|
|
4346
4326
|
|
|
4347
4327
|
class UtilsDictionary {
|
|
4348
|
-
items
|
|
4328
|
+
items;
|
|
4349
4329
|
constructor(key, value) {
|
|
4330
|
+
this.items = {};
|
|
4350
4331
|
if (key != null) {
|
|
4351
4332
|
this.set(key, value);
|
|
4352
4333
|
}
|
|
4353
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
|
+
}
|
|
4354
4362
|
/**
|
|
4355
4363
|
* 检查是否有某一个键
|
|
4356
4364
|
* @param key 键
|
|
@@ -4451,7 +4459,6 @@ var Utils = (function () {
|
|
|
4451
4459
|
* 返回字典本身
|
|
4452
4460
|
*/
|
|
4453
4461
|
getItems() {
|
|
4454
|
-
// @ts-ignore
|
|
4455
4462
|
return this.items;
|
|
4456
4463
|
}
|
|
4457
4464
|
/**
|
|
@@ -4461,38 +4468,15 @@ var Utils = (function () {
|
|
|
4461
4468
|
concat(data) {
|
|
4462
4469
|
this.items = commonUtil.assign(this.items, data.getItems());
|
|
4463
4470
|
}
|
|
4471
|
+
/**
|
|
4472
|
+
* 迭代字典
|
|
4473
|
+
* @param callbackfn 回调函数
|
|
4474
|
+
*/
|
|
4464
4475
|
forEach(callbackfn) {
|
|
4465
4476
|
for (const key in this.getItems()) {
|
|
4466
4477
|
callbackfn(this.get(key), key, this.getItems());
|
|
4467
4478
|
}
|
|
4468
4479
|
}
|
|
4469
|
-
/**
|
|
4470
|
-
* 获取字典的长度,同this.size
|
|
4471
|
-
*/
|
|
4472
|
-
get length() {
|
|
4473
|
-
return this.size();
|
|
4474
|
-
}
|
|
4475
|
-
/**
|
|
4476
|
-
* 迭代器
|
|
4477
|
-
*/
|
|
4478
|
-
get entries() {
|
|
4479
|
-
let that = this;
|
|
4480
|
-
return function* () {
|
|
4481
|
-
let itemKeys = Object.keys(that.getItems());
|
|
4482
|
-
for (const keyName of itemKeys) {
|
|
4483
|
-
yield [keyName, that.get(keyName)];
|
|
4484
|
-
}
|
|
4485
|
-
};
|
|
4486
|
-
}
|
|
4487
|
-
/**
|
|
4488
|
-
* 是否可遍历
|
|
4489
|
-
*/
|
|
4490
|
-
get [Symbol.iterator]() {
|
|
4491
|
-
let that = this;
|
|
4492
|
-
return function () {
|
|
4493
|
-
return that.entries();
|
|
4494
|
-
};
|
|
4495
|
-
}
|
|
4496
4480
|
}
|
|
4497
4481
|
|
|
4498
4482
|
class WindowApi {
|
|
@@ -4518,7 +4502,6 @@ var Utils = (function () {
|
|
|
4518
4502
|
if (!option) {
|
|
4519
4503
|
option = Object.assign({}, this.defaultApi);
|
|
4520
4504
|
}
|
|
4521
|
-
// @ts-ignore
|
|
4522
4505
|
this.api = Object.assign({}, option);
|
|
4523
4506
|
}
|
|
4524
4507
|
get document() {
|
|
@@ -4576,11 +4559,10 @@ var Utils = (function () {
|
|
|
4576
4559
|
deps = [];
|
|
4577
4560
|
active = true;
|
|
4578
4561
|
fn;
|
|
4579
|
-
//
|
|
4580
|
-
scheduler;
|
|
4562
|
+
// private scheduler;
|
|
4581
4563
|
constructor(fn, scheduler) {
|
|
4582
4564
|
this.fn = fn;
|
|
4583
|
-
this.scheduler = scheduler;
|
|
4565
|
+
// this.scheduler = scheduler;
|
|
4584
4566
|
}
|
|
4585
4567
|
run(cb) {
|
|
4586
4568
|
if (!this.active) {
|
|
@@ -4647,8 +4629,7 @@ var Utils = (function () {
|
|
|
4647
4629
|
reactive(target) {
|
|
4648
4630
|
const that = this;
|
|
4649
4631
|
if (!(typeof target === "object" && target !== null)) {
|
|
4650
|
-
|
|
4651
|
-
return;
|
|
4632
|
+
return void 0;
|
|
4652
4633
|
}
|
|
4653
4634
|
if (VueUtils.isReactive(target)) {
|
|
4654
4635
|
return target;
|
|
@@ -4718,7 +4699,6 @@ var Utils = (function () {
|
|
|
4718
4699
|
toRefs(object) {
|
|
4719
4700
|
const result = VueUtils.isArray(object) ? new Array(object.length) : {};
|
|
4720
4701
|
for (let key in object) {
|
|
4721
|
-
// @ts-ignore
|
|
4722
4702
|
result[key] = this.toRef(object, key);
|
|
4723
4703
|
}
|
|
4724
4704
|
return result;
|
|
@@ -5014,7 +4994,7 @@ var Utils = (function () {
|
|
|
5014
4994
|
};
|
|
5015
4995
|
|
|
5016
4996
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
5017
|
-
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
|
|
5018
4998
|
|
|
5019
4999
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
5020
5000
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -5446,7 +5426,6 @@ var Utils = (function () {
|
|
|
5446
5426
|
let text = textMatch[2];
|
|
5447
5427
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5448
5428
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5449
|
-
// @ts-ignore
|
|
5450
5429
|
return ($ele?.textContent || $ele?.innerText)?.includes(text);
|
|
5451
5430
|
});
|
|
5452
5431
|
}
|
|
@@ -5464,7 +5443,6 @@ var Utils = (function () {
|
|
|
5464
5443
|
let regexp = new RegExp(pattern, flags);
|
|
5465
5444
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5466
5445
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5467
|
-
// @ts-ignore
|
|
5468
5446
|
return Boolean(($ele?.textContent || $ele?.innerText)?.match(regexp));
|
|
5469
5447
|
});
|
|
5470
5448
|
}
|
|
@@ -5510,7 +5488,6 @@ var Utils = (function () {
|
|
|
5510
5488
|
let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
|
|
5511
5489
|
let text = textMatch[2];
|
|
5512
5490
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5513
|
-
// @ts-ignore
|
|
5514
5491
|
let content = $el?.textContent || $el?.innerText;
|
|
5515
5492
|
if (typeof content !== "string") {
|
|
5516
5493
|
content = "";
|
|
@@ -5530,7 +5507,6 @@ var Utils = (function () {
|
|
|
5530
5507
|
}
|
|
5531
5508
|
let regexp = new RegExp(pattern, flags);
|
|
5532
5509
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5533
|
-
// @ts-ignore
|
|
5534
5510
|
let content = $el?.textContent || $el?.innerText;
|
|
5535
5511
|
if (typeof content !== "string") {
|
|
5536
5512
|
content = "";
|
|
@@ -5561,7 +5537,6 @@ var Utils = (function () {
|
|
|
5561
5537
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5562
5538
|
let $closest = $el?.closest(selector);
|
|
5563
5539
|
if ($closest) {
|
|
5564
|
-
// @ts-ignore
|
|
5565
5540
|
let content = $el?.textContent || $el?.innerText;
|
|
5566
5541
|
if (typeof content === "string" && content.includes(text)) {
|
|
5567
5542
|
return $closest;
|
|
@@ -5584,7 +5559,6 @@ var Utils = (function () {
|
|
|
5584
5559
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5585
5560
|
let $closest = $el?.closest(selector);
|
|
5586
5561
|
if ($closest) {
|
|
5587
|
-
// @ts-ignore
|
|
5588
5562
|
let content = $el?.textContent || $el?.innerText;
|
|
5589
5563
|
if (typeof content === "string" && content.match(regexp)) {
|
|
5590
5564
|
return $closest;
|
|
@@ -5704,7 +5678,7 @@ var Utils = (function () {
|
|
|
5704
5678
|
return ajaxHooker();
|
|
5705
5679
|
}
|
|
5706
5680
|
};
|
|
5707
|
-
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view =
|
|
5681
|
+
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = this.windowApi.window) {
|
|
5708
5682
|
if (!(canvasElement instanceof HTMLCanvasElement)) {
|
|
5709
5683
|
throw new Error("Utils.canvasClickByPosition 参数canvasElement必须是canvas元素");
|
|
5710
5684
|
}
|
|
@@ -5715,7 +5689,6 @@ var Utils = (function () {
|
|
|
5715
5689
|
cancelable: true,
|
|
5716
5690
|
clientX: clientX,
|
|
5717
5691
|
clientY: clientY,
|
|
5718
|
-
// @ts-ignore
|
|
5719
5692
|
view: view,
|
|
5720
5693
|
detail: 1,
|
|
5721
5694
|
};
|
|
@@ -6222,12 +6195,10 @@ var Utils = (function () {
|
|
|
6222
6195
|
}
|
|
6223
6196
|
getElementSelector(element) {
|
|
6224
6197
|
let UtilsContext = this;
|
|
6225
|
-
// @ts-ignore
|
|
6226
6198
|
if (!element)
|
|
6227
|
-
return;
|
|
6228
|
-
// @ts-ignore
|
|
6199
|
+
return void 0;
|
|
6229
6200
|
if (!element.parentElement)
|
|
6230
|
-
return;
|
|
6201
|
+
return void 0;
|
|
6231
6202
|
/* 如果元素有id属性,则直接返回id选择器 */
|
|
6232
6203
|
if (element.id)
|
|
6233
6204
|
return "#" + element.id;
|
|
@@ -6258,8 +6229,7 @@ var Utils = (function () {
|
|
|
6258
6229
|
let result = [...args];
|
|
6259
6230
|
let newResult = [];
|
|
6260
6231
|
if (result.length === 0) {
|
|
6261
|
-
|
|
6262
|
-
return;
|
|
6232
|
+
return void 0;
|
|
6263
6233
|
}
|
|
6264
6234
|
if (result.length > 1) {
|
|
6265
6235
|
if (result.length === 2 &&
|
|
@@ -6299,7 +6269,6 @@ var Utils = (function () {
|
|
|
6299
6269
|
// 当前页面最大的z-index
|
|
6300
6270
|
let zIndex = 0;
|
|
6301
6271
|
// 当前的最大z-index的元素,调试使用
|
|
6302
|
-
// @ts-ignore
|
|
6303
6272
|
let maxZIndexNode = null;
|
|
6304
6273
|
/**
|
|
6305
6274
|
* 元素是否可见
|
|
@@ -6360,8 +6329,7 @@ var Utils = (function () {
|
|
|
6360
6329
|
let result = [...args];
|
|
6361
6330
|
let newResult = [];
|
|
6362
6331
|
if (result.length === 0) {
|
|
6363
|
-
|
|
6364
|
-
return;
|
|
6332
|
+
return void 0;
|
|
6365
6333
|
}
|
|
6366
6334
|
if (result.length > 1) {
|
|
6367
6335
|
if (result.length === 2 &&
|
|
@@ -6835,7 +6803,6 @@ var Utils = (function () {
|
|
|
6835
6803
|
}
|
|
6836
6804
|
isJQuery(target) {
|
|
6837
6805
|
let result = false;
|
|
6838
|
-
// @ts-ignore
|
|
6839
6806
|
if (typeof jQuery === "object" && target instanceof jQuery) {
|
|
6840
6807
|
result = true;
|
|
6841
6808
|
}
|
|
@@ -7616,29 +7583,27 @@ var Utils = (function () {
|
|
|
7616
7583
|
EventTarget.prototype.addEventListener = function (...args) {
|
|
7617
7584
|
let type = args[0];
|
|
7618
7585
|
let callback = args[1];
|
|
7619
|
-
//
|
|
7620
|
-
args[2];
|
|
7586
|
+
// let options = args[2];
|
|
7621
7587
|
if (filter(type)) {
|
|
7622
7588
|
if (typeof callback === "function") {
|
|
7623
7589
|
args[1] = function (event) {
|
|
7624
7590
|
callback.call(this, trustEvent(event));
|
|
7625
7591
|
};
|
|
7626
7592
|
}
|
|
7627
|
-
else if (typeof callback === "object" &&
|
|
7628
|
-
"handleEvent" in callback) {
|
|
7593
|
+
else if (typeof callback === "object" && "handleEvent" in callback) {
|
|
7629
7594
|
let oldHandleEvent = callback["handleEvent"];
|
|
7630
7595
|
args[1]["handleEvent"] = function (event) {
|
|
7631
7596
|
if (event == null) {
|
|
7632
7597
|
return;
|
|
7633
7598
|
}
|
|
7634
7599
|
try {
|
|
7635
|
-
|
|
7600
|
+
// Proxy对象使用instanceof会报错
|
|
7601
|
+
// 这里故意尝试一下,如果报错,则说明是Proxy对象
|
|
7636
7602
|
event instanceof Proxy;
|
|
7637
7603
|
oldHandleEvent.call(this, trustEvent(event));
|
|
7638
7604
|
}
|
|
7639
7605
|
catch (error) {
|
|
7640
|
-
|
|
7641
|
-
event["isTrusted"] = isTrustValue;
|
|
7606
|
+
Reflect.set(event, "isTrusted", isTrustValue);
|
|
7642
7607
|
}
|
|
7643
7608
|
};
|
|
7644
7609
|
}
|
|
@@ -7711,8 +7676,8 @@ var Utils = (function () {
|
|
|
7711
7676
|
}
|
|
7712
7677
|
async init() {
|
|
7713
7678
|
let copyStatus = false;
|
|
7714
|
-
|
|
7715
|
-
|
|
7679
|
+
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7680
|
+
console.log(requestPermissionStatus);
|
|
7716
7681
|
if (this.hasClipboard() &&
|
|
7717
7682
|
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7718
7683
|
try {
|
|
@@ -7730,11 +7695,8 @@ var Utils = (function () {
|
|
|
7730
7695
|
this.destroy();
|
|
7731
7696
|
}
|
|
7732
7697
|
destroy() {
|
|
7733
|
-
// @ts-ignore
|
|
7734
7698
|
this.#resolve = null;
|
|
7735
|
-
// @ts-ignore
|
|
7736
7699
|
this.#copyData = null;
|
|
7737
|
-
// @ts-ignore
|
|
7738
7700
|
this.#copyDataType = null;
|
|
7739
7701
|
}
|
|
7740
7702
|
isText() {
|
|
@@ -7778,7 +7740,6 @@ var Utils = (function () {
|
|
|
7778
7740
|
if (navigator.permissions && navigator.permissions.query) {
|
|
7779
7741
|
navigator.permissions
|
|
7780
7742
|
.query({
|
|
7781
|
-
// @ts-ignore
|
|
7782
7743
|
name: "clipboard-write",
|
|
7783
7744
|
})
|
|
7784
7745
|
.then((permissionStatus) => {
|
|
@@ -7874,7 +7835,6 @@ var Utils = (function () {
|
|
|
7874
7835
|
dragSlider(selector, offsetX = this.windowApi.window.innerWidth) {
|
|
7875
7836
|
let UtilsContext = this;
|
|
7876
7837
|
function initMouseEvent(eventName, offSetX, offSetY) {
|
|
7877
|
-
// @ts-ignore
|
|
7878
7838
|
let win = typeof unsafeWindow === "undefined" ? globalThis : unsafeWindow;
|
|
7879
7839
|
let mouseEvent = UtilsContext.windowApi.document.createEvent("MouseEvents");
|
|
7880
7840
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
@@ -8033,7 +7993,6 @@ var Utils = (function () {
|
|
|
8033
7993
|
}
|
|
8034
7994
|
stringToRegular(targetString, flags = "ig") {
|
|
8035
7995
|
let reg;
|
|
8036
|
-
// @ts-ignore
|
|
8037
7996
|
flags = flags.toLowerCase();
|
|
8038
7997
|
if (typeof targetString === "string") {
|
|
8039
7998
|
reg = new RegExp(targetString.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"), flags);
|
|
@@ -8126,10 +8085,8 @@ var Utils = (function () {
|
|
|
8126
8085
|
*/
|
|
8127
8086
|
searchParamStrToObj(searhParamsStr) {
|
|
8128
8087
|
if (typeof searhParamsStr !== "string") {
|
|
8129
|
-
// @ts-ignore
|
|
8130
8088
|
return {};
|
|
8131
8089
|
}
|
|
8132
|
-
// @ts-ignore
|
|
8133
8090
|
return Object.fromEntries(new URLSearchParams(searhParamsStr));
|
|
8134
8091
|
}
|
|
8135
8092
|
/**
|
|
@@ -8832,7 +8789,6 @@ var Utils = (function () {
|
|
|
8832
8789
|
function requestPermissionsWithClipboard() {
|
|
8833
8790
|
navigator.permissions
|
|
8834
8791
|
.query({
|
|
8835
|
-
// @ts-ignore
|
|
8836
8792
|
name: "clipboard-read",
|
|
8837
8793
|
})
|
|
8838
8794
|
.then((permissionStatus) => {
|