@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.system.js
CHANGED
|
@@ -20,14 +20,13 @@ System.register('Utils', [], (function (exports) {
|
|
|
20
20
|
/**
|
|
21
21
|
* 16进制颜色转rgba
|
|
22
22
|
*
|
|
23
|
-
*
|
|
23
|
+
* 例如:`#ff0000` 转为 `rgba(123,123,123, 0.4)`
|
|
24
24
|
* @param hex
|
|
25
25
|
* @param opacity
|
|
26
26
|
*/
|
|
27
27
|
hexToRgba(hex, opacity) {
|
|
28
28
|
if (!this.isHex(hex)) {
|
|
29
|
-
|
|
30
|
-
throw new TypeError("输入错误的hex", hex);
|
|
29
|
+
throw new TypeError("输入错误的hex:" + hex);
|
|
31
30
|
}
|
|
32
31
|
return hex && hex.replace(/\s+/g, "").length === 7
|
|
33
32
|
? "rgba(" +
|
|
@@ -44,19 +43,16 @@ System.register('Utils', [], (function (exports) {
|
|
|
44
43
|
/**
|
|
45
44
|
* hex转rgb
|
|
46
45
|
* @param str
|
|
47
|
-
* @returns
|
|
48
46
|
*/
|
|
49
47
|
hexToRgb(str) {
|
|
50
48
|
if (!this.isHex(str)) {
|
|
51
|
-
|
|
52
|
-
throw new TypeError("输入错误的hex", str);
|
|
49
|
+
throw new TypeError("输入错误的hex:" + str);
|
|
53
50
|
}
|
|
54
51
|
/* replace替换查找的到的字符串 */
|
|
55
52
|
str = str.replace("#", "");
|
|
56
53
|
/* match得到查询数组 */
|
|
57
54
|
let hxs = str.match(/../g);
|
|
58
55
|
for (let index = 0; index < 3; index++) {
|
|
59
|
-
// @ts-ignore
|
|
60
56
|
hxs[index] = parseInt(hxs[index], 16);
|
|
61
57
|
}
|
|
62
58
|
return hxs;
|
|
@@ -66,7 +62,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
66
62
|
* @param redValue
|
|
67
63
|
* @param greenValue
|
|
68
64
|
* @param blueValue
|
|
69
|
-
* @returns
|
|
70
65
|
*/
|
|
71
66
|
rgbToHex(redValue, greenValue, blueValue) {
|
|
72
67
|
/* 验证输入的rgb值是否合法 */
|
|
@@ -89,38 +84,30 @@ System.register('Utils', [], (function (exports) {
|
|
|
89
84
|
* 获取颜色变暗或亮
|
|
90
85
|
* @param color 颜色
|
|
91
86
|
* @param level 0~1.0
|
|
92
|
-
* @returns
|
|
93
87
|
*/
|
|
94
88
|
getDarkColor(color, level) {
|
|
95
89
|
if (!this.isHex(color)) {
|
|
96
|
-
|
|
97
|
-
throw new TypeError("输入错误的hex", color);
|
|
90
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
98
91
|
}
|
|
99
92
|
let rgbc = this.hexToRgb(color);
|
|
100
93
|
for (let index = 0; index < 3; index++) {
|
|
101
|
-
// @ts-ignore
|
|
102
94
|
rgbc[index] = Math.floor(rgbc[index] * (1 - level));
|
|
103
95
|
}
|
|
104
|
-
// @ts-ignore
|
|
105
96
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
106
97
|
}
|
|
107
98
|
/**
|
|
108
99
|
* 获取颜色变亮
|
|
109
100
|
* @param color 颜色
|
|
110
101
|
* @param level 0~1.0
|
|
111
|
-
* @returns
|
|
112
102
|
*/
|
|
113
103
|
getLightColor(color, level) {
|
|
114
104
|
if (!this.isHex(color)) {
|
|
115
|
-
|
|
116
|
-
throw new TypeError("输入错误的hex", color);
|
|
105
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
117
106
|
}
|
|
118
107
|
let rgbc = this.hexToRgb(color);
|
|
119
108
|
for (let index = 0; index < 3; index++) {
|
|
120
|
-
// @ts-ignore
|
|
121
109
|
rgbc[index] = Math.floor((255 - rgbc[index]) * level + rgbc[index]);
|
|
122
110
|
}
|
|
123
|
-
// @ts-ignore
|
|
124
111
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
125
112
|
}
|
|
126
113
|
}
|
|
@@ -208,20 +195,20 @@ System.register('Utils', [], (function (exports) {
|
|
|
208
195
|
* @param str
|
|
209
196
|
*/
|
|
210
197
|
decode(str) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
//
|
|
214
|
-
|
|
215
|
-
|
|
198
|
+
let GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
|
|
199
|
+
let UTFMatcher = /%[0-9A-F]{2}/;
|
|
200
|
+
// let gbk = true;
|
|
201
|
+
let utf = true;
|
|
202
|
+
const that = this;
|
|
216
203
|
while (utf) {
|
|
217
204
|
let gbkMatch = str.match(GBKMatcher);
|
|
218
205
|
let utfMatch = str.match(UTFMatcher);
|
|
206
|
+
// gbk = Boolean(gbkMatch);
|
|
219
207
|
utf = Boolean(utfMatch);
|
|
220
208
|
if (gbkMatch && gbkMatch in that.#G2Uhash) {
|
|
221
209
|
str = str.replace(gbkMatch, String.fromCharCode(("0x" + that.#G2Uhash[gbkMatch])));
|
|
222
210
|
}
|
|
223
211
|
else {
|
|
224
|
-
// @ts-ignore
|
|
225
212
|
str = str.replace(utfMatch, decodeURIComponent(utfMatch));
|
|
226
213
|
}
|
|
227
214
|
}
|
|
@@ -252,7 +239,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
252
239
|
* @param handler
|
|
253
240
|
*/
|
|
254
241
|
error(handler) {
|
|
255
|
-
// @ts-ignore
|
|
256
242
|
handleError = handler;
|
|
257
243
|
return TryCatchCore;
|
|
258
244
|
},
|
|
@@ -267,8 +253,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
267
253
|
callbackFunction = callback;
|
|
268
254
|
context = __context__ || this;
|
|
269
255
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
270
|
-
|
|
271
|
-
|
|
256
|
+
return result !== void 0
|
|
257
|
+
? result
|
|
258
|
+
: TryCatchCore;
|
|
272
259
|
},
|
|
273
260
|
};
|
|
274
261
|
/**
|
|
@@ -1952,25 +1939,24 @@ System.register('Utils', [], (function (exports) {
|
|
|
1952
1939
|
let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
|
|
1953
1940
|
/** 油猴菜单上显示的文本 */
|
|
1954
1941
|
let showText = menuOption.showText(menuOption.text, defaultEnable);
|
|
1955
|
-
//
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
});
|
|
1942
|
+
// const GMMenuOptions = {
|
|
1943
|
+
// /**
|
|
1944
|
+
// * 菜单的id
|
|
1945
|
+
// */
|
|
1946
|
+
// id: menuOption.id,
|
|
1947
|
+
// /**
|
|
1948
|
+
// * 点击菜单项后是否应关闭弹出菜单
|
|
1949
|
+
// */
|
|
1950
|
+
// autoClose: menuOption.autoClose,
|
|
1951
|
+
// /**
|
|
1952
|
+
// * 菜单项的可选访问键
|
|
1953
|
+
// */
|
|
1954
|
+
// accessKey: menuOption.accessKey,
|
|
1955
|
+
// /**
|
|
1956
|
+
// * 菜单项的鼠标悬浮上的工具提示
|
|
1957
|
+
// */
|
|
1958
|
+
// title: menuOption.title,
|
|
1959
|
+
// };
|
|
1974
1960
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1975
1961
|
menuOption.autoReload =
|
|
1976
1962
|
typeof menuOption.autoReload !== "boolean"
|
|
@@ -2548,7 +2534,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
2548
2534
|
* 对请求的参数进行合并处理
|
|
2549
2535
|
*/
|
|
2550
2536
|
handleBeforeRequestOptionArgs(...args) {
|
|
2551
|
-
let option = {
|
|
2537
|
+
let option = {
|
|
2538
|
+
url: void 0,
|
|
2539
|
+
};
|
|
2552
2540
|
if (typeof args[0] === "string") {
|
|
2553
2541
|
/* 传入的是url,转为配置 */
|
|
2554
2542
|
let url = args[0];
|
|
@@ -2572,7 +2560,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2572
2560
|
* @param method 当前请求方法,默认get
|
|
2573
2561
|
* @param userRequestOption 用户的请求配置
|
|
2574
2562
|
* @param resolve promise回调
|
|
2575
|
-
* @param reject 抛出错误回调
|
|
2563
|
+
* @param reject promise抛出错误回调
|
|
2576
2564
|
*/
|
|
2577
2565
|
getRequestOption(method, userRequestOption, resolve, reject) {
|
|
2578
2566
|
let that = this;
|
|
@@ -2630,25 +2618,25 @@ System.register('Utils', [], (function (exports) {
|
|
|
2630
2618
|
password: userRequestOption.password ||
|
|
2631
2619
|
this.context.#defaultRequestOption.password,
|
|
2632
2620
|
onabort(...args) {
|
|
2633
|
-
that.context.
|
|
2621
|
+
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2634
2622
|
},
|
|
2635
2623
|
onerror(...args) {
|
|
2636
|
-
that.context.
|
|
2624
|
+
that.context.HttpxResponseCallBack.onError(userRequestOption, resolve, reject, args);
|
|
2637
2625
|
},
|
|
2638
2626
|
onloadstart(...args) {
|
|
2639
|
-
that.context.
|
|
2627
|
+
that.context.HttpxResponseCallBack.onLoadStart(userRequestOption, args);
|
|
2640
2628
|
},
|
|
2641
2629
|
onprogress(...args) {
|
|
2642
|
-
that.context.
|
|
2630
|
+
that.context.HttpxResponseCallBack.onProgress(userRequestOption, args);
|
|
2643
2631
|
},
|
|
2644
2632
|
onreadystatechange(...args) {
|
|
2645
|
-
that.context.
|
|
2633
|
+
that.context.HttpxResponseCallBack.onReadyStateChange(userRequestOption, args);
|
|
2646
2634
|
},
|
|
2647
2635
|
ontimeout(...args) {
|
|
2648
|
-
that.context.
|
|
2636
|
+
that.context.HttpxResponseCallBack.onTimeout(userRequestOption, resolve, reject, args);
|
|
2649
2637
|
},
|
|
2650
2638
|
onload(...args) {
|
|
2651
|
-
that.context.
|
|
2639
|
+
that.context.HttpxResponseCallBack.onLoad(userRequestOption, resolve, reject, args);
|
|
2652
2640
|
},
|
|
2653
2641
|
};
|
|
2654
2642
|
// 补全allowInterceptConfig参数
|
|
@@ -2760,7 +2748,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
2760
2748
|
else if (typeof requestOption.data === "object") {
|
|
2761
2749
|
isHandler = true;
|
|
2762
2750
|
// URLSearchParams参数可以转普通的string:string,包括FormData
|
|
2763
|
-
// @ts-ignore
|
|
2764
2751
|
let searchParams = new URLSearchParams(requestOption.data);
|
|
2765
2752
|
urlSearch = searchParams.toString();
|
|
2766
2753
|
}
|
|
@@ -2815,9 +2802,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2815
2802
|
else if (ContentType.includes("application/x-www-form-urlencoded")) {
|
|
2816
2803
|
// application/x-www-form-urlencoded
|
|
2817
2804
|
if (typeof requestOption.data === "object") {
|
|
2818
|
-
requestOption.data = new URLSearchParams(
|
|
2819
|
-
// @ts-ignore
|
|
2820
|
-
requestOption.data).toString();
|
|
2805
|
+
requestOption.data = new URLSearchParams(requestOption.data).toString();
|
|
2821
2806
|
}
|
|
2822
2807
|
}
|
|
2823
2808
|
else if (ContentType.includes("multipart/form-data")) {
|
|
@@ -2837,7 +2822,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2837
2822
|
},
|
|
2838
2823
|
/**
|
|
2839
2824
|
* 处理发送请求的配置,去除值为undefined、空function的值
|
|
2840
|
-
* @param option
|
|
2825
|
+
* @param option 请求配置
|
|
2841
2826
|
*/
|
|
2842
2827
|
removeRequestNullOption(option) {
|
|
2843
2828
|
Object.keys(option).forEach((keyName) => {
|
|
@@ -2849,13 +2834,13 @@ System.register('Utils', [], (function (exports) {
|
|
|
2849
2834
|
}
|
|
2850
2835
|
});
|
|
2851
2836
|
if (commonUtil.isNull(option.url)) {
|
|
2852
|
-
throw new TypeError(`Utils.Httpx 参数
|
|
2837
|
+
throw new TypeError(`Utils.Httpx 参数url不能为空:${option.url}`);
|
|
2853
2838
|
}
|
|
2854
2839
|
return option;
|
|
2855
2840
|
},
|
|
2856
2841
|
/**
|
|
2857
2842
|
* 处理fetch的配置
|
|
2858
|
-
* @param option
|
|
2843
|
+
* @param option 请求配置
|
|
2859
2844
|
*/
|
|
2860
2845
|
handleFetchOption(option) {
|
|
2861
2846
|
/**
|
|
@@ -2908,21 +2893,21 @@ System.register('Utils', [], (function (exports) {
|
|
|
2908
2893
|
};
|
|
2909
2894
|
},
|
|
2910
2895
|
};
|
|
2911
|
-
|
|
2896
|
+
HttpxResponseCallBack = {
|
|
2912
2897
|
context: this,
|
|
2913
2898
|
/**
|
|
2914
2899
|
* onabort请求被取消-触发
|
|
2915
2900
|
* @param details 配置
|
|
2916
|
-
* @param resolve 回调
|
|
2917
|
-
* @param reject
|
|
2901
|
+
* @param resolve promise回调
|
|
2902
|
+
* @param reject promise抛出错误回调
|
|
2918
2903
|
* @param argsResult 返回的参数列表
|
|
2919
2904
|
*/
|
|
2920
2905
|
async onAbort(details, resolve, reject, argsResult) {
|
|
2921
2906
|
// console.log(argsResult);
|
|
2922
|
-
if (
|
|
2907
|
+
if (typeof details?.onabort === "function") {
|
|
2923
2908
|
details.onabort.apply(this, argsResult);
|
|
2924
2909
|
}
|
|
2925
|
-
else if (
|
|
2910
|
+
else if (typeof this.context.#defaultRequestOption?.onabort === "function") {
|
|
2926
2911
|
this.context.#defaultRequestOption.onabort.apply(this, argsResult);
|
|
2927
2912
|
}
|
|
2928
2913
|
let response = argsResult;
|
|
@@ -2931,11 +2916,11 @@ System.register('Utils', [], (function (exports) {
|
|
|
2931
2916
|
}
|
|
2932
2917
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2933
2918
|
type: "onabort",
|
|
2934
|
-
error: new
|
|
2919
|
+
error: new Error("request canceled"),
|
|
2935
2920
|
response: null,
|
|
2936
2921
|
details: details,
|
|
2937
2922
|
})) == null) {
|
|
2938
|
-
// reject(new
|
|
2923
|
+
// reject(new Error("response is intercept with onabort"));
|
|
2939
2924
|
return;
|
|
2940
2925
|
}
|
|
2941
2926
|
resolve({
|
|
@@ -2948,93 +2933,83 @@ System.register('Utils', [], (function (exports) {
|
|
|
2948
2933
|
});
|
|
2949
2934
|
},
|
|
2950
2935
|
/**
|
|
2951
|
-
*
|
|
2936
|
+
* ontimeout请求超时-触发
|
|
2952
2937
|
* @param details 配置
|
|
2953
2938
|
* @param resolve 回调
|
|
2954
2939
|
* @param reject 抛出错误
|
|
2955
2940
|
* @param argsResult 返回的参数列表
|
|
2956
2941
|
*/
|
|
2957
|
-
async
|
|
2942
|
+
async onTimeout(details, resolve, reject, argsResult) {
|
|
2958
2943
|
// console.log(argsResult);
|
|
2959
|
-
if ("
|
|
2960
|
-
|
|
2944
|
+
if (typeof details?.ontimeout === "function") {
|
|
2945
|
+
// 执行配置中的ontime回调
|
|
2946
|
+
details.ontimeout.apply(this, argsResult);
|
|
2961
2947
|
}
|
|
2962
|
-
else if (
|
|
2963
|
-
|
|
2948
|
+
else if (typeof this.context.#defaultRequestOption?.ontimeout === "function") {
|
|
2949
|
+
// 执行默认配置的ontime回调
|
|
2950
|
+
this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
|
|
2964
2951
|
}
|
|
2952
|
+
// 获取响应结果
|
|
2965
2953
|
let response = argsResult;
|
|
2966
2954
|
if (response.length) {
|
|
2967
2955
|
response = response[0];
|
|
2968
2956
|
}
|
|
2957
|
+
// 执行错误回调的钩子
|
|
2969
2958
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2970
|
-
type: "
|
|
2971
|
-
error: new
|
|
2959
|
+
type: "ontimeout",
|
|
2960
|
+
error: new Error("request timeout"),
|
|
2972
2961
|
response: response,
|
|
2973
2962
|
details: details,
|
|
2974
2963
|
})) == null) {
|
|
2975
|
-
// reject(new
|
|
2964
|
+
// reject(new Error("response is intercept with ontimeout"));
|
|
2976
2965
|
return;
|
|
2977
2966
|
}
|
|
2978
2967
|
resolve({
|
|
2979
2968
|
data: response,
|
|
2980
2969
|
details: details,
|
|
2981
|
-
msg: "
|
|
2970
|
+
msg: "请求超时",
|
|
2982
2971
|
status: false,
|
|
2983
|
-
statusCode:
|
|
2984
|
-
type: "
|
|
2972
|
+
statusCode: 0,
|
|
2973
|
+
type: "ontimeout",
|
|
2985
2974
|
});
|
|
2986
2975
|
},
|
|
2987
2976
|
/**
|
|
2988
|
-
*
|
|
2977
|
+
* onerror请求异常-触发
|
|
2989
2978
|
* @param details 配置
|
|
2990
2979
|
* @param resolve 回调
|
|
2991
2980
|
* @param reject 抛出错误
|
|
2992
2981
|
* @param argsResult 返回的参数列表
|
|
2993
2982
|
*/
|
|
2994
|
-
async
|
|
2983
|
+
async onError(details, resolve, reject, argsResult) {
|
|
2995
2984
|
// console.log(argsResult);
|
|
2996
|
-
if ("
|
|
2997
|
-
details.
|
|
2985
|
+
if (typeof details?.onerror === "function") {
|
|
2986
|
+
details.onerror.apply(this, argsResult);
|
|
2998
2987
|
}
|
|
2999
|
-
else if (
|
|
3000
|
-
this.context.#defaultRequestOption.
|
|
2988
|
+
else if (typeof this.context.#defaultRequestOption?.onerror === "function") {
|
|
2989
|
+
this.context.#defaultRequestOption.onerror.apply(this, argsResult);
|
|
3001
2990
|
}
|
|
3002
2991
|
let response = argsResult;
|
|
3003
2992
|
if (response.length) {
|
|
3004
2993
|
response = response[0];
|
|
3005
2994
|
}
|
|
3006
2995
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
3007
|
-
type: "
|
|
3008
|
-
error: new
|
|
3009
|
-
response:
|
|
2996
|
+
type: "onerror",
|
|
2997
|
+
error: new Error("request error"),
|
|
2998
|
+
response: response,
|
|
3010
2999
|
details: details,
|
|
3011
3000
|
})) == null) {
|
|
3012
|
-
// reject(new
|
|
3001
|
+
// reject(new Error("response is intercept with onerror"));
|
|
3013
3002
|
return;
|
|
3014
3003
|
}
|
|
3015
3004
|
resolve({
|
|
3016
3005
|
data: response,
|
|
3017
3006
|
details: details,
|
|
3018
|
-
msg: "
|
|
3007
|
+
msg: "请求异常",
|
|
3019
3008
|
status: false,
|
|
3020
|
-
statusCode:
|
|
3021
|
-
type: "
|
|
3009
|
+
statusCode: response["status"],
|
|
3010
|
+
type: "onerror",
|
|
3022
3011
|
});
|
|
3023
3012
|
},
|
|
3024
|
-
/**
|
|
3025
|
-
* onloadstart请求开始-触发
|
|
3026
|
-
* @param details 配置
|
|
3027
|
-
* @param argsResult 返回的参数列表
|
|
3028
|
-
*/
|
|
3029
|
-
onLoadStart(details, argsResult) {
|
|
3030
|
-
// console.log(argsResult);
|
|
3031
|
-
if ("onloadstart" in details) {
|
|
3032
|
-
details.onloadstart.apply(this, argsResult);
|
|
3033
|
-
}
|
|
3034
|
-
else if ("onloadstart" in this.context.#defaultRequestOption) {
|
|
3035
|
-
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3036
|
-
}
|
|
3037
|
-
},
|
|
3038
3013
|
/**
|
|
3039
3014
|
* onload加载完毕-触发
|
|
3040
3015
|
* @param details 请求的配置
|
|
@@ -3114,7 +3089,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3114
3089
|
/* 状态码2xx都是成功的 */
|
|
3115
3090
|
if (Math.floor(originResponse.status / 100) === 2) {
|
|
3116
3091
|
if ((await this.context.HttpxResponseHook.successResponseCallBack(originResponse, details)) == null) {
|
|
3117
|
-
// reject(new
|
|
3092
|
+
// reject(new Error("response is intercept with onloada"));
|
|
3118
3093
|
return;
|
|
3119
3094
|
}
|
|
3120
3095
|
resolve({
|
|
@@ -3127,21 +3102,21 @@ System.register('Utils', [], (function (exports) {
|
|
|
3127
3102
|
});
|
|
3128
3103
|
}
|
|
3129
3104
|
else {
|
|
3130
|
-
this.context.
|
|
3105
|
+
this.context.HttpxResponseCallBack.onError(details, resolve, reject, argsResult);
|
|
3131
3106
|
}
|
|
3132
3107
|
},
|
|
3133
3108
|
/**
|
|
3134
|
-
*
|
|
3109
|
+
* onloadstart请求开始-触发
|
|
3135
3110
|
* @param details 配置
|
|
3136
3111
|
* @param argsResult 返回的参数列表
|
|
3137
3112
|
*/
|
|
3138
|
-
|
|
3113
|
+
onLoadStart(details, argsResult) {
|
|
3139
3114
|
// console.log(argsResult);
|
|
3140
|
-
if ("
|
|
3141
|
-
details.
|
|
3115
|
+
if (typeof details?.onloadstart === "function") {
|
|
3116
|
+
details.onloadstart.apply(this, argsResult);
|
|
3142
3117
|
}
|
|
3143
|
-
else if (
|
|
3144
|
-
this.context.#defaultRequestOption.
|
|
3118
|
+
else if (typeof this.context.#defaultRequestOption?.onloadstart === "function") {
|
|
3119
|
+
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3145
3120
|
}
|
|
3146
3121
|
},
|
|
3147
3122
|
/**
|
|
@@ -3151,13 +3126,28 @@ System.register('Utils', [], (function (exports) {
|
|
|
3151
3126
|
*/
|
|
3152
3127
|
onReadyStateChange(details, argsResult) {
|
|
3153
3128
|
// console.log(argsResult);
|
|
3154
|
-
if (
|
|
3129
|
+
if (typeof details?.onreadystatechange === "function") {
|
|
3155
3130
|
details.onreadystatechange.apply(this, argsResult);
|
|
3156
3131
|
}
|
|
3157
|
-
else if (
|
|
3132
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3133
|
+
"function") {
|
|
3158
3134
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3159
3135
|
}
|
|
3160
3136
|
},
|
|
3137
|
+
/**
|
|
3138
|
+
* onprogress上传进度-触发
|
|
3139
|
+
* @param details 配置
|
|
3140
|
+
* @param argsResult 返回的参数列表
|
|
3141
|
+
*/
|
|
3142
|
+
onProgress(details, argsResult) {
|
|
3143
|
+
// console.log(argsResult);
|
|
3144
|
+
if (typeof details?.onprogress === "function") {
|
|
3145
|
+
details.onprogress.apply(this, argsResult);
|
|
3146
|
+
}
|
|
3147
|
+
else if (typeof this.context.#defaultRequestOption?.onprogress === "function") {
|
|
3148
|
+
this.context.#defaultRequestOption.onprogress.apply(this, argsResult);
|
|
3149
|
+
}
|
|
3150
|
+
},
|
|
3161
3151
|
};
|
|
3162
3152
|
HttpxRequest = {
|
|
3163
3153
|
context: this,
|
|
@@ -3207,15 +3197,12 @@ System.register('Utils', [], (function (exports) {
|
|
|
3207
3197
|
isFetch: true,
|
|
3208
3198
|
finalUrl: fetchResponse.url,
|
|
3209
3199
|
readyState: 4,
|
|
3210
|
-
// @ts-ignore
|
|
3211
3200
|
status: fetchResponse.status,
|
|
3212
3201
|
statusText: fetchResponse.statusText,
|
|
3213
|
-
|
|
3214
|
-
response: void 0,
|
|
3202
|
+
response: "",
|
|
3215
3203
|
responseFetchHeaders: fetchResponse.headers,
|
|
3216
3204
|
responseHeaders: "",
|
|
3217
|
-
|
|
3218
|
-
responseText: void 0,
|
|
3205
|
+
responseText: "",
|
|
3219
3206
|
responseType: option.responseType,
|
|
3220
3207
|
responseXML: void 0,
|
|
3221
3208
|
};
|
|
@@ -3288,9 +3275,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
3288
3275
|
// 转为XML结构
|
|
3289
3276
|
let parser = new DOMParser();
|
|
3290
3277
|
responseXML = parser.parseFromString(responseText, "text/xml");
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3278
|
+
httpxResponse.response = response;
|
|
3279
|
+
httpxResponse.responseText = responseText;
|
|
3280
|
+
httpxResponse.responseXML = responseXML;
|
|
3294
3281
|
// 执行回调
|
|
3295
3282
|
option.onload(httpxResponse);
|
|
3296
3283
|
})
|
|
@@ -3471,7 +3458,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3471
3458
|
}
|
|
3472
3459
|
/**
|
|
3473
3460
|
* GET 请求
|
|
3474
|
-
* @param url
|
|
3461
|
+
* @param url 请求的url
|
|
3475
3462
|
* @param details 配置
|
|
3476
3463
|
*/
|
|
3477
3464
|
get(...args) {
|
|
@@ -3537,27 +3524,22 @@ System.register('Utils', [], (function (exports) {
|
|
|
3537
3524
|
/** 取消请求 */
|
|
3538
3525
|
let abortFn = null;
|
|
3539
3526
|
let promise = new globalThis.Promise(async (resolve, reject) => {
|
|
3540
|
-
let requestOption = this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject);
|
|
3527
|
+
let requestOption = (this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject));
|
|
3541
3528
|
if (typeof beforeRequestOption === "function") {
|
|
3542
|
-
// @ts-ignore
|
|
3543
3529
|
beforeRequestOption(requestOption);
|
|
3544
3530
|
}
|
|
3545
|
-
|
|
3546
|
-
requestOption =
|
|
3547
|
-
this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3531
|
+
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3548
3532
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3549
3533
|
if (requestResult != null &&
|
|
3550
3534
|
typeof requestResult.abort === "function") {
|
|
3551
3535
|
abortFn = requestResult.abort;
|
|
3552
3536
|
}
|
|
3553
3537
|
});
|
|
3554
|
-
// @ts-ignore
|
|
3555
3538
|
promise.abort = () => {
|
|
3556
3539
|
if (typeof abortFn === "function") {
|
|
3557
3540
|
abortFn();
|
|
3558
3541
|
}
|
|
3559
3542
|
};
|
|
3560
|
-
// @ts-ignore
|
|
3561
3543
|
return promise;
|
|
3562
3544
|
}
|
|
3563
3545
|
}
|
|
@@ -3567,8 +3549,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3567
3549
|
#storeName;
|
|
3568
3550
|
#dbVersion;
|
|
3569
3551
|
/* websql的版本号,由于ios的问题,版本号的写法不一样 */
|
|
3570
|
-
//
|
|
3571
|
-
#slqVersion = "1";
|
|
3552
|
+
// #slqVersion = "1";
|
|
3572
3553
|
/* 监听IndexDB */
|
|
3573
3554
|
#indexedDB = window.indexedDB ||
|
|
3574
3555
|
window.mozIndexedDB ||
|
|
@@ -3576,8 +3557,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3576
3557
|
window.msIndexedDB;
|
|
3577
3558
|
/* 缓存数据库,避免同一个页面重复创建和销毁 */
|
|
3578
3559
|
#db = {};
|
|
3579
|
-
//
|
|
3580
|
-
#store = null;
|
|
3560
|
+
// #store: IDBObjectStore = null as any;
|
|
3581
3561
|
/** 状态码 */
|
|
3582
3562
|
#statusCode = {
|
|
3583
3563
|
operationSuccess: {
|
|
@@ -3622,7 +3602,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3622
3602
|
txn = this.#db[dbName].transaction(this.#storeName, "readwrite");
|
|
3623
3603
|
/* IndexDB的读写权限 */
|
|
3624
3604
|
store = txn.objectStore(this.#storeName);
|
|
3625
|
-
this.#store = store;
|
|
3605
|
+
// this.#store = store;
|
|
3626
3606
|
return store;
|
|
3627
3607
|
}
|
|
3628
3608
|
/**
|
|
@@ -4347,12 +4327,40 @@ System.register('Utils', [], (function (exports) {
|
|
|
4347
4327
|
}
|
|
4348
4328
|
|
|
4349
4329
|
class UtilsDictionary {
|
|
4350
|
-
items
|
|
4330
|
+
items;
|
|
4351
4331
|
constructor(key, value) {
|
|
4332
|
+
this.items = {};
|
|
4352
4333
|
if (key != null) {
|
|
4353
4334
|
this.set(key, value);
|
|
4354
4335
|
}
|
|
4355
4336
|
}
|
|
4337
|
+
/**
|
|
4338
|
+
* 获取字典的长度,同this.size
|
|
4339
|
+
*/
|
|
4340
|
+
get length() {
|
|
4341
|
+
return this.size();
|
|
4342
|
+
}
|
|
4343
|
+
/**
|
|
4344
|
+
* 迭代器
|
|
4345
|
+
*/
|
|
4346
|
+
get entries() {
|
|
4347
|
+
let that = this;
|
|
4348
|
+
return function* () {
|
|
4349
|
+
let itemKeys = Object.keys(that.getItems());
|
|
4350
|
+
for (const keyName of itemKeys) {
|
|
4351
|
+
yield [keyName, that.get(keyName)];
|
|
4352
|
+
}
|
|
4353
|
+
};
|
|
4354
|
+
}
|
|
4355
|
+
/**
|
|
4356
|
+
* 是否可遍历
|
|
4357
|
+
*/
|
|
4358
|
+
get [Symbol.iterator]() {
|
|
4359
|
+
let that = this;
|
|
4360
|
+
return function () {
|
|
4361
|
+
return that.entries();
|
|
4362
|
+
};
|
|
4363
|
+
}
|
|
4356
4364
|
/**
|
|
4357
4365
|
* 检查是否有某一个键
|
|
4358
4366
|
* @param key 键
|
|
@@ -4453,7 +4461,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
4453
4461
|
* 返回字典本身
|
|
4454
4462
|
*/
|
|
4455
4463
|
getItems() {
|
|
4456
|
-
// @ts-ignore
|
|
4457
4464
|
return this.items;
|
|
4458
4465
|
}
|
|
4459
4466
|
/**
|
|
@@ -4463,38 +4470,15 @@ System.register('Utils', [], (function (exports) {
|
|
|
4463
4470
|
concat(data) {
|
|
4464
4471
|
this.items = commonUtil.assign(this.items, data.getItems());
|
|
4465
4472
|
}
|
|
4473
|
+
/**
|
|
4474
|
+
* 迭代字典
|
|
4475
|
+
* @param callbackfn 回调函数
|
|
4476
|
+
*/
|
|
4466
4477
|
forEach(callbackfn) {
|
|
4467
4478
|
for (const key in this.getItems()) {
|
|
4468
4479
|
callbackfn(this.get(key), key, this.getItems());
|
|
4469
4480
|
}
|
|
4470
4481
|
}
|
|
4471
|
-
/**
|
|
4472
|
-
* 获取字典的长度,同this.size
|
|
4473
|
-
*/
|
|
4474
|
-
get length() {
|
|
4475
|
-
return this.size();
|
|
4476
|
-
}
|
|
4477
|
-
/**
|
|
4478
|
-
* 迭代器
|
|
4479
|
-
*/
|
|
4480
|
-
get entries() {
|
|
4481
|
-
let that = this;
|
|
4482
|
-
return function* () {
|
|
4483
|
-
let itemKeys = Object.keys(that.getItems());
|
|
4484
|
-
for (const keyName of itemKeys) {
|
|
4485
|
-
yield [keyName, that.get(keyName)];
|
|
4486
|
-
}
|
|
4487
|
-
};
|
|
4488
|
-
}
|
|
4489
|
-
/**
|
|
4490
|
-
* 是否可遍历
|
|
4491
|
-
*/
|
|
4492
|
-
get [Symbol.iterator]() {
|
|
4493
|
-
let that = this;
|
|
4494
|
-
return function () {
|
|
4495
|
-
return that.entries();
|
|
4496
|
-
};
|
|
4497
|
-
}
|
|
4498
4482
|
}
|
|
4499
4483
|
|
|
4500
4484
|
class WindowApi {
|
|
@@ -4520,7 +4504,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
4520
4504
|
if (!option) {
|
|
4521
4505
|
option = Object.assign({}, this.defaultApi);
|
|
4522
4506
|
}
|
|
4523
|
-
// @ts-ignore
|
|
4524
4507
|
this.api = Object.assign({}, option);
|
|
4525
4508
|
}
|
|
4526
4509
|
get document() {
|
|
@@ -4578,11 +4561,10 @@ System.register('Utils', [], (function (exports) {
|
|
|
4578
4561
|
deps = [];
|
|
4579
4562
|
active = true;
|
|
4580
4563
|
fn;
|
|
4581
|
-
//
|
|
4582
|
-
scheduler;
|
|
4564
|
+
// private scheduler;
|
|
4583
4565
|
constructor(fn, scheduler) {
|
|
4584
4566
|
this.fn = fn;
|
|
4585
|
-
this.scheduler = scheduler;
|
|
4567
|
+
// this.scheduler = scheduler;
|
|
4586
4568
|
}
|
|
4587
4569
|
run(cb) {
|
|
4588
4570
|
if (!this.active) {
|
|
@@ -4649,8 +4631,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
4649
4631
|
reactive(target) {
|
|
4650
4632
|
const that = this;
|
|
4651
4633
|
if (!(typeof target === "object" && target !== null)) {
|
|
4652
|
-
|
|
4653
|
-
return;
|
|
4634
|
+
return void 0;
|
|
4654
4635
|
}
|
|
4655
4636
|
if (VueUtils.isReactive(target)) {
|
|
4656
4637
|
return target;
|
|
@@ -4720,7 +4701,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
4720
4701
|
toRefs(object) {
|
|
4721
4702
|
const result = VueUtils.isArray(object) ? new Array(object.length) : {};
|
|
4722
4703
|
for (let key in object) {
|
|
4723
|
-
// @ts-ignore
|
|
4724
4704
|
result[key] = this.toRef(object, key);
|
|
4725
4705
|
}
|
|
4726
4706
|
return result;
|
|
@@ -5016,7 +4996,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5016
4996
|
};
|
|
5017
4997
|
|
|
5018
4998
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
5019
|
-
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),
|
|
4999
|
+
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
|
|
5020
5000
|
|
|
5021
5001
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
5022
5002
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -5448,7 +5428,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
5448
5428
|
let text = textMatch[2];
|
|
5449
5429
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5450
5430
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5451
|
-
// @ts-ignore
|
|
5452
5431
|
return ($ele?.textContent || $ele?.innerText)?.includes(text);
|
|
5453
5432
|
});
|
|
5454
5433
|
}
|
|
@@ -5466,7 +5445,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
5466
5445
|
let regexp = new RegExp(pattern, flags);
|
|
5467
5446
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5468
5447
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5469
|
-
// @ts-ignore
|
|
5470
5448
|
return Boolean(($ele?.textContent || $ele?.innerText)?.match(regexp));
|
|
5471
5449
|
});
|
|
5472
5450
|
}
|
|
@@ -5512,7 +5490,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
5512
5490
|
let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
|
|
5513
5491
|
let text = textMatch[2];
|
|
5514
5492
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5515
|
-
// @ts-ignore
|
|
5516
5493
|
let content = $el?.textContent || $el?.innerText;
|
|
5517
5494
|
if (typeof content !== "string") {
|
|
5518
5495
|
content = "";
|
|
@@ -5532,7 +5509,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
5532
5509
|
}
|
|
5533
5510
|
let regexp = new RegExp(pattern, flags);
|
|
5534
5511
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5535
|
-
// @ts-ignore
|
|
5536
5512
|
let content = $el?.textContent || $el?.innerText;
|
|
5537
5513
|
if (typeof content !== "string") {
|
|
5538
5514
|
content = "";
|
|
@@ -5563,7 +5539,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
5563
5539
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5564
5540
|
let $closest = $el?.closest(selector);
|
|
5565
5541
|
if ($closest) {
|
|
5566
|
-
// @ts-ignore
|
|
5567
5542
|
let content = $el?.textContent || $el?.innerText;
|
|
5568
5543
|
if (typeof content === "string" && content.includes(text)) {
|
|
5569
5544
|
return $closest;
|
|
@@ -5586,7 +5561,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
5586
5561
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5587
5562
|
let $closest = $el?.closest(selector);
|
|
5588
5563
|
if ($closest) {
|
|
5589
|
-
// @ts-ignore
|
|
5590
5564
|
let content = $el?.textContent || $el?.innerText;
|
|
5591
5565
|
if (typeof content === "string" && content.match(regexp)) {
|
|
5592
5566
|
return $closest;
|
|
@@ -5706,7 +5680,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5706
5680
|
return ajaxHooker();
|
|
5707
5681
|
}
|
|
5708
5682
|
};
|
|
5709
|
-
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view =
|
|
5683
|
+
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = this.windowApi.window) {
|
|
5710
5684
|
if (!(canvasElement instanceof HTMLCanvasElement)) {
|
|
5711
5685
|
throw new Error("Utils.canvasClickByPosition 参数canvasElement必须是canvas元素");
|
|
5712
5686
|
}
|
|
@@ -5717,7 +5691,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
5717
5691
|
cancelable: true,
|
|
5718
5692
|
clientX: clientX,
|
|
5719
5693
|
clientY: clientY,
|
|
5720
|
-
// @ts-ignore
|
|
5721
5694
|
view: view,
|
|
5722
5695
|
detail: 1,
|
|
5723
5696
|
};
|
|
@@ -6224,12 +6197,10 @@ System.register('Utils', [], (function (exports) {
|
|
|
6224
6197
|
}
|
|
6225
6198
|
getElementSelector(element) {
|
|
6226
6199
|
let UtilsContext = this;
|
|
6227
|
-
// @ts-ignore
|
|
6228
6200
|
if (!element)
|
|
6229
|
-
return;
|
|
6230
|
-
// @ts-ignore
|
|
6201
|
+
return void 0;
|
|
6231
6202
|
if (!element.parentElement)
|
|
6232
|
-
return;
|
|
6203
|
+
return void 0;
|
|
6233
6204
|
/* 如果元素有id属性,则直接返回id选择器 */
|
|
6234
6205
|
if (element.id)
|
|
6235
6206
|
return "#" + element.id;
|
|
@@ -6260,8 +6231,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
6260
6231
|
let result = [...args];
|
|
6261
6232
|
let newResult = [];
|
|
6262
6233
|
if (result.length === 0) {
|
|
6263
|
-
|
|
6264
|
-
return;
|
|
6234
|
+
return void 0;
|
|
6265
6235
|
}
|
|
6266
6236
|
if (result.length > 1) {
|
|
6267
6237
|
if (result.length === 2 &&
|
|
@@ -6301,7 +6271,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
6301
6271
|
// 当前页面最大的z-index
|
|
6302
6272
|
let zIndex = 0;
|
|
6303
6273
|
// 当前的最大z-index的元素,调试使用
|
|
6304
|
-
// @ts-ignore
|
|
6305
6274
|
let maxZIndexNode = null;
|
|
6306
6275
|
/**
|
|
6307
6276
|
* 元素是否可见
|
|
@@ -6362,8 +6331,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
6362
6331
|
let result = [...args];
|
|
6363
6332
|
let newResult = [];
|
|
6364
6333
|
if (result.length === 0) {
|
|
6365
|
-
|
|
6366
|
-
return;
|
|
6334
|
+
return void 0;
|
|
6367
6335
|
}
|
|
6368
6336
|
if (result.length > 1) {
|
|
6369
6337
|
if (result.length === 2 &&
|
|
@@ -6837,7 +6805,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
6837
6805
|
}
|
|
6838
6806
|
isJQuery(target) {
|
|
6839
6807
|
let result = false;
|
|
6840
|
-
// @ts-ignore
|
|
6841
6808
|
if (typeof jQuery === "object" && target instanceof jQuery) {
|
|
6842
6809
|
result = true;
|
|
6843
6810
|
}
|
|
@@ -7618,29 +7585,27 @@ System.register('Utils', [], (function (exports) {
|
|
|
7618
7585
|
EventTarget.prototype.addEventListener = function (...args) {
|
|
7619
7586
|
let type = args[0];
|
|
7620
7587
|
let callback = args[1];
|
|
7621
|
-
//
|
|
7622
|
-
args[2];
|
|
7588
|
+
// let options = args[2];
|
|
7623
7589
|
if (filter(type)) {
|
|
7624
7590
|
if (typeof callback === "function") {
|
|
7625
7591
|
args[1] = function (event) {
|
|
7626
7592
|
callback.call(this, trustEvent(event));
|
|
7627
7593
|
};
|
|
7628
7594
|
}
|
|
7629
|
-
else if (typeof callback === "object" &&
|
|
7630
|
-
"handleEvent" in callback) {
|
|
7595
|
+
else if (typeof callback === "object" && "handleEvent" in callback) {
|
|
7631
7596
|
let oldHandleEvent = callback["handleEvent"];
|
|
7632
7597
|
args[1]["handleEvent"] = function (event) {
|
|
7633
7598
|
if (event == null) {
|
|
7634
7599
|
return;
|
|
7635
7600
|
}
|
|
7636
7601
|
try {
|
|
7637
|
-
|
|
7602
|
+
// Proxy对象使用instanceof会报错
|
|
7603
|
+
// 这里故意尝试一下,如果报错,则说明是Proxy对象
|
|
7638
7604
|
event instanceof Proxy;
|
|
7639
7605
|
oldHandleEvent.call(this, trustEvent(event));
|
|
7640
7606
|
}
|
|
7641
7607
|
catch (error) {
|
|
7642
|
-
|
|
7643
|
-
event["isTrusted"] = isTrustValue;
|
|
7608
|
+
Reflect.set(event, "isTrusted", isTrustValue);
|
|
7644
7609
|
}
|
|
7645
7610
|
};
|
|
7646
7611
|
}
|
|
@@ -7713,8 +7678,8 @@ System.register('Utils', [], (function (exports) {
|
|
|
7713
7678
|
}
|
|
7714
7679
|
async init() {
|
|
7715
7680
|
let copyStatus = false;
|
|
7716
|
-
|
|
7717
|
-
|
|
7681
|
+
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7682
|
+
console.log(requestPermissionStatus);
|
|
7718
7683
|
if (this.hasClipboard() &&
|
|
7719
7684
|
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7720
7685
|
try {
|
|
@@ -7732,11 +7697,8 @@ System.register('Utils', [], (function (exports) {
|
|
|
7732
7697
|
this.destroy();
|
|
7733
7698
|
}
|
|
7734
7699
|
destroy() {
|
|
7735
|
-
// @ts-ignore
|
|
7736
7700
|
this.#resolve = null;
|
|
7737
|
-
// @ts-ignore
|
|
7738
7701
|
this.#copyData = null;
|
|
7739
|
-
// @ts-ignore
|
|
7740
7702
|
this.#copyDataType = null;
|
|
7741
7703
|
}
|
|
7742
7704
|
isText() {
|
|
@@ -7780,7 +7742,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
7780
7742
|
if (navigator.permissions && navigator.permissions.query) {
|
|
7781
7743
|
navigator.permissions
|
|
7782
7744
|
.query({
|
|
7783
|
-
// @ts-ignore
|
|
7784
7745
|
name: "clipboard-write",
|
|
7785
7746
|
})
|
|
7786
7747
|
.then((permissionStatus) => {
|
|
@@ -7876,7 +7837,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
7876
7837
|
dragSlider(selector, offsetX = this.windowApi.window.innerWidth) {
|
|
7877
7838
|
let UtilsContext = this;
|
|
7878
7839
|
function initMouseEvent(eventName, offSetX, offSetY) {
|
|
7879
|
-
// @ts-ignore
|
|
7880
7840
|
let win = typeof unsafeWindow === "undefined" ? globalThis : unsafeWindow;
|
|
7881
7841
|
let mouseEvent = UtilsContext.windowApi.document.createEvent("MouseEvents");
|
|
7882
7842
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
@@ -8035,7 +7995,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
8035
7995
|
}
|
|
8036
7996
|
stringToRegular(targetString, flags = "ig") {
|
|
8037
7997
|
let reg;
|
|
8038
|
-
// @ts-ignore
|
|
8039
7998
|
flags = flags.toLowerCase();
|
|
8040
7999
|
if (typeof targetString === "string") {
|
|
8041
8000
|
reg = new RegExp(targetString.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"), flags);
|
|
@@ -8128,10 +8087,8 @@ System.register('Utils', [], (function (exports) {
|
|
|
8128
8087
|
*/
|
|
8129
8088
|
searchParamStrToObj(searhParamsStr) {
|
|
8130
8089
|
if (typeof searhParamsStr !== "string") {
|
|
8131
|
-
// @ts-ignore
|
|
8132
8090
|
return {};
|
|
8133
8091
|
}
|
|
8134
|
-
// @ts-ignore
|
|
8135
8092
|
return Object.fromEntries(new URLSearchParams(searhParamsStr));
|
|
8136
8093
|
}
|
|
8137
8094
|
/**
|
|
@@ -8834,7 +8791,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
8834
8791
|
function requestPermissionsWithClipboard() {
|
|
8835
8792
|
navigator.permissions
|
|
8836
8793
|
.query({
|
|
8837
|
-
// @ts-ignore
|
|
8838
8794
|
name: "clipboard-read",
|
|
8839
8795
|
})
|
|
8840
8796
|
.then((permissionStatus) => {
|