@whitesev/utils 2.7.1 → 2.7.3
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 +260 -409
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +260 -409
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +260 -409
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +260 -409
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +260 -409
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +260 -409
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/ColorConversion.d.ts +3 -8
- package/dist/types/src/Dictionary.d.ts +21 -14
- package/dist/types/src/GBKEncoder.d.ts +1 -2
- package/dist/types/src/Hooks.d.ts +1 -2
- package/dist/types/src/Httpx.d.ts +45 -46
- package/dist/types/src/LockFunction.d.ts +1 -2
- package/dist/types/src/Log.d.ts +1 -2
- package/dist/types/src/Progress.d.ts +1 -2
- package/dist/types/src/Utils.d.ts +30 -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/Event.d.ts +1 -2
- package/dist/types/src/types/Httpx.d.ts +75 -86
- package/dist/types/src/types/ajaxHooker.d.ts +1 -5
- 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 +13 -37
- package/src/CommonUtil.ts +8 -31
- package/src/DOMUtils.ts +9 -24
- package/src/Dictionary.ts +37 -38
- package/src/GBKEncoder.ts +9 -18
- package/src/Hooks.ts +2 -7
- package/src/Httpx.ts +257 -412
- package/src/LockFunction.ts +1 -3
- package/src/Log.ts +8 -26
- package/src/Progress.ts +3 -13
- package/src/TryCatch.ts +4 -12
- package/src/Utils.ts +233 -595
- package/src/UtilsCommon.ts +5 -9
- package/src/UtilsGMCookie.ts +1 -4
- package/src/UtilsGMMenu.ts +29 -51
- package/src/Vue.ts +6 -18
- package/src/WindowApi.ts +2 -5
- package/src/indexedDB.ts +11 -20
- package/src/types/Event.d.ts +1 -2
- package/src/types/Httpx.d.ts +75 -86
- package/src/types/ajaxHooker.d.ts +1 -5
- 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值是否合法 */
|
|
@@ -75,11 +70,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
75
70
|
!validPattern.test(greenValue.toString()) ||
|
|
76
71
|
!validPattern.test(blueValue.toString()))
|
|
77
72
|
throw new TypeError("输入错误的rgb颜色值");
|
|
78
|
-
let hexs = [
|
|
79
|
-
redValue.toString(16),
|
|
80
|
-
greenValue.toString(16),
|
|
81
|
-
blueValue.toString(16),
|
|
82
|
-
];
|
|
73
|
+
let hexs = [redValue.toString(16), greenValue.toString(16), blueValue.toString(16)];
|
|
83
74
|
for (let index = 0; index < 3; index++)
|
|
84
75
|
if (hexs[index].length == 1)
|
|
85
76
|
hexs[index] = "0" + hexs[index];
|
|
@@ -89,38 +80,30 @@ System.register('Utils', [], (function (exports) {
|
|
|
89
80
|
* 获取颜色变暗或亮
|
|
90
81
|
* @param color 颜色
|
|
91
82
|
* @param level 0~1.0
|
|
92
|
-
* @returns
|
|
93
83
|
*/
|
|
94
84
|
getDarkColor(color, level) {
|
|
95
85
|
if (!this.isHex(color)) {
|
|
96
|
-
|
|
97
|
-
throw new TypeError("输入错误的hex", color);
|
|
86
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
98
87
|
}
|
|
99
88
|
let rgbc = this.hexToRgb(color);
|
|
100
89
|
for (let index = 0; index < 3; index++) {
|
|
101
|
-
// @ts-ignore
|
|
102
90
|
rgbc[index] = Math.floor(rgbc[index] * (1 - level));
|
|
103
91
|
}
|
|
104
|
-
// @ts-ignore
|
|
105
92
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
106
93
|
}
|
|
107
94
|
/**
|
|
108
95
|
* 获取颜色变亮
|
|
109
96
|
* @param color 颜色
|
|
110
97
|
* @param level 0~1.0
|
|
111
|
-
* @returns
|
|
112
98
|
*/
|
|
113
99
|
getLightColor(color, level) {
|
|
114
100
|
if (!this.isHex(color)) {
|
|
115
|
-
|
|
116
|
-
throw new TypeError("输入错误的hex", color);
|
|
101
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
117
102
|
}
|
|
118
103
|
let rgbc = this.hexToRgb(color);
|
|
119
104
|
for (let index = 0; index < 3; index++) {
|
|
120
|
-
// @ts-ignore
|
|
121
105
|
rgbc[index] = Math.floor((255 - rgbc[index]) * level + rgbc[index]);
|
|
122
106
|
}
|
|
123
|
-
// @ts-ignore
|
|
124
107
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
125
108
|
}
|
|
126
109
|
}
|
|
@@ -135,10 +118,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
135
118
|
this.#data = dataText.match(/..../g);
|
|
136
119
|
for (let i = 0x81; i <= 0xfe; i++) {
|
|
137
120
|
for (let j = 0x40; j <= 0xfe; j++) {
|
|
138
|
-
this.#U2Ghash[this.#data[index++]] = ("%" +
|
|
139
|
-
i.toString(16) +
|
|
140
|
-
"%" +
|
|
141
|
-
j.toString(16)).toUpperCase();
|
|
121
|
+
this.#U2Ghash[this.#data[index++]] = ("%" + i.toString(16) + "%" + j.toString(16)).toUpperCase();
|
|
142
122
|
}
|
|
143
123
|
}
|
|
144
124
|
for (let key in this.#U2Ghash) {
|
|
@@ -208,20 +188,20 @@ System.register('Utils', [], (function (exports) {
|
|
|
208
188
|
* @param str
|
|
209
189
|
*/
|
|
210
190
|
decode(str) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
//
|
|
214
|
-
|
|
215
|
-
|
|
191
|
+
let GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
|
|
192
|
+
let UTFMatcher = /%[0-9A-F]{2}/;
|
|
193
|
+
// let gbk = true;
|
|
194
|
+
let utf = true;
|
|
195
|
+
const that = this;
|
|
216
196
|
while (utf) {
|
|
217
197
|
let gbkMatch = str.match(GBKMatcher);
|
|
218
198
|
let utfMatch = str.match(UTFMatcher);
|
|
199
|
+
// gbk = Boolean(gbkMatch);
|
|
219
200
|
utf = Boolean(utfMatch);
|
|
220
201
|
if (gbkMatch && gbkMatch in that.#G2Uhash) {
|
|
221
202
|
str = str.replace(gbkMatch, String.fromCharCode(("0x" + that.#G2Uhash[gbkMatch])));
|
|
222
203
|
}
|
|
223
204
|
else {
|
|
224
|
-
// @ts-ignore
|
|
225
205
|
str = str.replace(utfMatch, decodeURIComponent(utfMatch));
|
|
226
206
|
}
|
|
227
207
|
}
|
|
@@ -252,7 +232,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
252
232
|
* @param handler
|
|
253
233
|
*/
|
|
254
234
|
error(handler) {
|
|
255
|
-
// @ts-ignore
|
|
256
235
|
handleError = handler;
|
|
257
236
|
return TryCatchCore;
|
|
258
237
|
},
|
|
@@ -267,7 +246,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
267
246
|
callbackFunction = callback;
|
|
268
247
|
context = __context__ || this;
|
|
269
248
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
270
|
-
// @ts-ignore
|
|
271
249
|
return result !== void 0 ? result : TryCatchCore;
|
|
272
250
|
},
|
|
273
251
|
};
|
|
@@ -297,10 +275,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
297
275
|
}
|
|
298
276
|
if (handleErrorFunc) {
|
|
299
277
|
if (typeof handleErrorFunc === "string") {
|
|
300
|
-
result = new Function(handleErrorFunc).apply(funcThis, [
|
|
301
|
-
...args,
|
|
302
|
-
error,
|
|
303
|
-
]);
|
|
278
|
+
result = new Function(handleErrorFunc).apply(funcThis, [...args, error]);
|
|
304
279
|
}
|
|
305
280
|
else {
|
|
306
281
|
result = handleErrorFunc.apply(funcThis, [...args, error]);
|
|
@@ -388,10 +363,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
388
363
|
itemResult = objItem === 0;
|
|
389
364
|
break;
|
|
390
365
|
case "string":
|
|
391
|
-
itemResult =
|
|
392
|
-
objItem.trim() === "" ||
|
|
393
|
-
objItem === "null" ||
|
|
394
|
-
objItem === "undefined";
|
|
366
|
+
itemResult = objItem.trim() === "" || objItem === "null" || objItem === "undefined";
|
|
395
367
|
break;
|
|
396
368
|
case "boolean":
|
|
397
369
|
itemResult = !objItem;
|
|
@@ -432,8 +404,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
432
404
|
return null;
|
|
433
405
|
let clone = obj instanceof Array ? [] : {};
|
|
434
406
|
for (const [key, value] of Object.entries(obj)) {
|
|
435
|
-
clone[key] =
|
|
436
|
-
typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
407
|
+
clone[key] = typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
437
408
|
}
|
|
438
409
|
return clone;
|
|
439
410
|
}
|
|
@@ -1952,35 +1923,30 @@ System.register('Utils', [], (function (exports) {
|
|
|
1952
1923
|
let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
|
|
1953
1924
|
/** 油猴菜单上显示的文本 */
|
|
1954
1925
|
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
|
-
});
|
|
1926
|
+
// const GMMenuOptions = {
|
|
1927
|
+
// /**
|
|
1928
|
+
// * 菜单的id
|
|
1929
|
+
// */
|
|
1930
|
+
// id: menuOption.id,
|
|
1931
|
+
// /**
|
|
1932
|
+
// * 点击菜单项后是否应关闭弹出菜单
|
|
1933
|
+
// */
|
|
1934
|
+
// autoClose: menuOption.autoClose,
|
|
1935
|
+
// /**
|
|
1936
|
+
// * 菜单项的可选访问键
|
|
1937
|
+
// */
|
|
1938
|
+
// accessKey: menuOption.accessKey,
|
|
1939
|
+
// /**
|
|
1940
|
+
// * 菜单项的鼠标悬浮上的工具提示
|
|
1941
|
+
// */
|
|
1942
|
+
// title: menuOption.title,
|
|
1943
|
+
// };
|
|
1974
1944
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1975
1945
|
menuOption.autoReload =
|
|
1976
|
-
typeof menuOption.autoReload !== "boolean"
|
|
1977
|
-
? this.$default.autoReload
|
|
1978
|
-
: menuOption.autoReload;
|
|
1946
|
+
typeof menuOption.autoReload !== "boolean" ? this.$default.autoReload : menuOption.autoReload;
|
|
1979
1947
|
/* 点击菜单后触发callback后的网页是否存储值 */
|
|
1980
1948
|
menuOption.isStoreValue =
|
|
1981
|
-
typeof menuOption.isStoreValue !== "boolean"
|
|
1982
|
-
? this.$default.isStoreValue
|
|
1983
|
-
: menuOption.isStoreValue;
|
|
1949
|
+
typeof menuOption.isStoreValue !== "boolean" ? this.$default.isStoreValue : menuOption.isStoreValue;
|
|
1984
1950
|
/**
|
|
1985
1951
|
* 用户点击菜单后的回调函数
|
|
1986
1952
|
* @param event
|
|
@@ -2033,8 +1999,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2033
1999
|
* @param menuKey 菜单-键key
|
|
2034
2000
|
*/
|
|
2035
2001
|
getMenuHandledOption(menuKey) {
|
|
2036
|
-
return this.$data.data.find((item) => item.handleData.key === menuKey)
|
|
2037
|
-
?.handleData;
|
|
2002
|
+
return this.$data.data.find((item) => item.handleData.key === menuKey)?.handleData;
|
|
2038
2003
|
},
|
|
2039
2004
|
};
|
|
2040
2005
|
constructor(details) {
|
|
@@ -2042,8 +2007,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2042
2007
|
this.GM_Api.setValue = details.GM_setValue;
|
|
2043
2008
|
this.GM_Api.registerMenuCommand = details.GM_registerMenuCommand;
|
|
2044
2009
|
this.GM_Api.unregisterMenuCommand = details.GM_unregisterMenuCommand;
|
|
2045
|
-
this.MenuHandle.$default.autoReload =
|
|
2046
|
-
typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
2010
|
+
this.MenuHandle.$default.autoReload = typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
2047
2011
|
for (const keyName of Object.keys(this.GM_Api)) {
|
|
2048
2012
|
if (typeof this.GM_Api[keyName] !== "function") {
|
|
2049
2013
|
throw new Error(`Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`);
|
|
@@ -2275,8 +2239,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2275
2239
|
_context = context || window;
|
|
2276
2240
|
_funcName = getFuncName(this);
|
|
2277
2241
|
_context["realFunc_" + _funcName] = this;
|
|
2278
|
-
if (_context[_funcName].prototype &&
|
|
2279
|
-
_context[_funcName].prototype.isHooked) {
|
|
2242
|
+
if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
|
|
2280
2243
|
console.log("Already has been hooked,unhook first");
|
|
2281
2244
|
return false;
|
|
2282
2245
|
}
|
|
@@ -2454,8 +2417,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2454
2417
|
if (details.allowInterceptConfig != null) {
|
|
2455
2418
|
// 配置存在
|
|
2456
2419
|
// 细分处理是否拦截
|
|
2457
|
-
if (typeof details.allowInterceptConfig.afterResponseSuccess ===
|
|
2458
|
-
"boolean" &&
|
|
2420
|
+
if (typeof details.allowInterceptConfig.afterResponseSuccess === "boolean" &&
|
|
2459
2421
|
!details.allowInterceptConfig.afterResponseSuccess) {
|
|
2460
2422
|
// 设置了禁止拦截
|
|
2461
2423
|
return details;
|
|
@@ -2490,8 +2452,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2490
2452
|
if (data.details.allowInterceptConfig != null) {
|
|
2491
2453
|
// 配置存在
|
|
2492
2454
|
// 细分处理是否拦截
|
|
2493
|
-
if (typeof data.details.allowInterceptConfig.afterResponseError ===
|
|
2494
|
-
"boolean" &&
|
|
2455
|
+
if (typeof data.details.allowInterceptConfig.afterResponseError === "boolean" &&
|
|
2495
2456
|
!data.details.allowInterceptConfig.afterResponseError) {
|
|
2496
2457
|
// 设置了禁止拦截
|
|
2497
2458
|
return data;
|
|
@@ -2548,7 +2509,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
2548
2509
|
* 对请求的参数进行合并处理
|
|
2549
2510
|
*/
|
|
2550
2511
|
handleBeforeRequestOptionArgs(...args) {
|
|
2551
|
-
let option = {
|
|
2512
|
+
let option = {
|
|
2513
|
+
url: void 0,
|
|
2514
|
+
};
|
|
2552
2515
|
if (typeof args[0] === "string") {
|
|
2553
2516
|
/* 传入的是url,转为配置 */
|
|
2554
2517
|
let url = args[0];
|
|
@@ -2572,7 +2535,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2572
2535
|
* @param method 当前请求方法,默认get
|
|
2573
2536
|
* @param userRequestOption 用户的请求配置
|
|
2574
2537
|
* @param resolve promise回调
|
|
2575
|
-
* @param reject 抛出错误回调
|
|
2538
|
+
* @param reject promise抛出错误回调
|
|
2576
2539
|
*/
|
|
2577
2540
|
getRequestOption(method, userRequestOption, resolve, reject) {
|
|
2578
2541
|
let that = this;
|
|
@@ -2591,64 +2554,51 @@ System.register('Utils', [], (function (exports) {
|
|
|
2591
2554
|
let requestOption = {
|
|
2592
2555
|
url: url,
|
|
2593
2556
|
method: (method || "GET").toString().toUpperCase().trim(),
|
|
2594
|
-
timeout: userRequestOption.timeout ||
|
|
2595
|
-
|
|
2596
|
-
responseType: userRequestOption.responseType ||
|
|
2597
|
-
this.context.#defaultRequestOption.responseType,
|
|
2557
|
+
timeout: userRequestOption.timeout || this.context.#defaultRequestOption.timeout,
|
|
2558
|
+
responseType: userRequestOption.responseType || this.context.#defaultRequestOption.responseType,
|
|
2598
2559
|
/* 对象使用深拷贝 */
|
|
2599
2560
|
headers: commonUtil.deepClone(this.context.#defaultRequestOption.headers),
|
|
2600
2561
|
data: userRequestOption.data || this.context.#defaultRequestOption.data,
|
|
2601
|
-
redirect: userRequestOption.redirect ||
|
|
2602
|
-
this.context.#defaultRequestOption.redirect,
|
|
2562
|
+
redirect: userRequestOption.redirect || this.context.#defaultRequestOption.redirect,
|
|
2603
2563
|
cookie: userRequestOption.cookie || this.context.#defaultRequestOption.cookie,
|
|
2604
|
-
cookiePartition: userRequestOption.cookiePartition ||
|
|
2605
|
-
this.context.#defaultRequestOption.cookiePartition,
|
|
2564
|
+
cookiePartition: userRequestOption.cookiePartition || this.context.#defaultRequestOption.cookiePartition,
|
|
2606
2565
|
binary: userRequestOption.binary || this.context.#defaultRequestOption.binary,
|
|
2607
|
-
nocache: userRequestOption.nocache ||
|
|
2608
|
-
|
|
2609
|
-
revalidate: userRequestOption.revalidate ||
|
|
2610
|
-
this.context.#defaultRequestOption.revalidate,
|
|
2566
|
+
nocache: userRequestOption.nocache || this.context.#defaultRequestOption.nocache,
|
|
2567
|
+
revalidate: userRequestOption.revalidate || this.context.#defaultRequestOption.revalidate,
|
|
2611
2568
|
/* 对象使用深拷贝 */
|
|
2612
|
-
context: commonUtil.deepClone(userRequestOption.context ||
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
this.context.#defaultRequestOption.overrideMimeType,
|
|
2616
|
-
anonymous: userRequestOption.anonymous ||
|
|
2617
|
-
this.context.#defaultRequestOption.anonymous,
|
|
2569
|
+
context: commonUtil.deepClone(userRequestOption.context || this.context.#defaultRequestOption.context),
|
|
2570
|
+
overrideMimeType: userRequestOption.overrideMimeType || this.context.#defaultRequestOption.overrideMimeType,
|
|
2571
|
+
anonymous: userRequestOption.anonymous || this.context.#defaultRequestOption.anonymous,
|
|
2618
2572
|
fetch: userRequestOption.fetch || this.context.#defaultRequestOption.fetch,
|
|
2619
2573
|
/* 对象使用深拷贝 */
|
|
2620
2574
|
fetchInit: commonUtil.deepClone(this.context.#defaultRequestOption.fetchInit),
|
|
2621
2575
|
allowInterceptConfig: {
|
|
2622
|
-
beforeRequest: this.context.#defaultRequestOption
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
.allowInterceptConfig.afterResponseSuccess,
|
|
2626
|
-
afterResponseError: this.context.#defaultRequestOption
|
|
2627
|
-
.allowInterceptConfig.afterResponseError,
|
|
2576
|
+
beforeRequest: this.context.#defaultRequestOption.allowInterceptConfig.beforeRequest,
|
|
2577
|
+
afterResponseSuccess: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseSuccess,
|
|
2578
|
+
afterResponseError: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseError,
|
|
2628
2579
|
},
|
|
2629
2580
|
user: userRequestOption.user || this.context.#defaultRequestOption.user,
|
|
2630
|
-
password: userRequestOption.password ||
|
|
2631
|
-
this.context.#defaultRequestOption.password,
|
|
2581
|
+
password: userRequestOption.password || this.context.#defaultRequestOption.password,
|
|
2632
2582
|
onabort(...args) {
|
|
2633
|
-
that.context.
|
|
2583
|
+
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2634
2584
|
},
|
|
2635
2585
|
onerror(...args) {
|
|
2636
|
-
that.context.
|
|
2586
|
+
that.context.HttpxResponseCallBack.onError(userRequestOption, resolve, reject, args);
|
|
2637
2587
|
},
|
|
2638
2588
|
onloadstart(...args) {
|
|
2639
|
-
that.context.
|
|
2589
|
+
that.context.HttpxResponseCallBack.onLoadStart(userRequestOption, args);
|
|
2640
2590
|
},
|
|
2641
2591
|
onprogress(...args) {
|
|
2642
|
-
that.context.
|
|
2592
|
+
that.context.HttpxResponseCallBack.onProgress(userRequestOption, args);
|
|
2643
2593
|
},
|
|
2644
2594
|
onreadystatechange(...args) {
|
|
2645
|
-
that.context.
|
|
2595
|
+
that.context.HttpxResponseCallBack.onReadyStateChange(userRequestOption, args);
|
|
2646
2596
|
},
|
|
2647
2597
|
ontimeout(...args) {
|
|
2648
|
-
that.context.
|
|
2598
|
+
that.context.HttpxResponseCallBack.onTimeout(userRequestOption, resolve, reject, args);
|
|
2649
2599
|
},
|
|
2650
2600
|
onload(...args) {
|
|
2651
|
-
that.context.
|
|
2601
|
+
that.context.HttpxResponseCallBack.onLoad(userRequestOption, resolve, reject, args);
|
|
2652
2602
|
},
|
|
2653
2603
|
};
|
|
2654
2604
|
// 补全allowInterceptConfig参数
|
|
@@ -2676,14 +2626,12 @@ System.register('Utils', [], (function (exports) {
|
|
|
2676
2626
|
if (typeof requestOption.headers === "object") {
|
|
2677
2627
|
if (typeof userRequestOption.headers === "object") {
|
|
2678
2628
|
Object.keys(userRequestOption.headers).forEach((keyName, index) => {
|
|
2679
|
-
if (keyName in requestOption.headers &&
|
|
2680
|
-
userRequestOption.headers?.[keyName] == null) {
|
|
2629
|
+
if (keyName in requestOption.headers && userRequestOption.headers?.[keyName] == null) {
|
|
2681
2630
|
/* 在默认的header中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2682
2631
|
Reflect.deleteProperty(requestOption.headers, keyName);
|
|
2683
2632
|
}
|
|
2684
2633
|
else {
|
|
2685
|
-
requestOption.headers[keyName] =
|
|
2686
|
-
userRequestOption?.headers?.[keyName];
|
|
2634
|
+
requestOption.headers[keyName] = userRequestOption?.headers?.[keyName];
|
|
2687
2635
|
}
|
|
2688
2636
|
});
|
|
2689
2637
|
}
|
|
@@ -2696,8 +2644,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2696
2644
|
/* 使用assign替换且添加 */
|
|
2697
2645
|
if (typeof userRequestOption.fetchInit === "object") {
|
|
2698
2646
|
Object.keys(userRequestOption.fetchInit).forEach((keyName, index) => {
|
|
2699
|
-
if (keyName in requestOption.fetchInit &&
|
|
2700
|
-
userRequestOption.fetchInit[keyName] == null) {
|
|
2647
|
+
if (keyName in requestOption.fetchInit && userRequestOption.fetchInit[keyName] == null) {
|
|
2701
2648
|
/* 在默认的fetchInit中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2702
2649
|
Reflect.deleteProperty(requestOption.fetchInit, keyName);
|
|
2703
2650
|
}
|
|
@@ -2711,8 +2658,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2711
2658
|
Reflect.set(requestOption, "fetchInit", userRequestOption.fetchInit);
|
|
2712
2659
|
}
|
|
2713
2660
|
// 处理新的cookiePartition
|
|
2714
|
-
if (typeof requestOption.cookiePartition === "object" &&
|
|
2715
|
-
requestOption.cookiePartition != null) {
|
|
2661
|
+
if (typeof requestOption.cookiePartition === "object" && requestOption.cookiePartition != null) {
|
|
2716
2662
|
if (Reflect.has(requestOption.cookiePartition, "topLevelSite") &&
|
|
2717
2663
|
typeof requestOption.cookiePartition.topLevelSite !== "string") {
|
|
2718
2664
|
// topLevelSite必须是字符串
|
|
@@ -2734,8 +2680,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2734
2680
|
}
|
|
2735
2681
|
else {
|
|
2736
2682
|
// 补充origin+/
|
|
2737
|
-
requestOption.url =
|
|
2738
|
-
globalThis.location.origin + "/" + requestOption.url;
|
|
2683
|
+
requestOption.url = globalThis.location.origin + "/" + requestOption.url;
|
|
2739
2684
|
}
|
|
2740
2685
|
}
|
|
2741
2686
|
if (requestOption.fetchInit && !requestOption.fetch) {
|
|
@@ -2760,7 +2705,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
2760
2705
|
else if (typeof requestOption.data === "object") {
|
|
2761
2706
|
isHandler = true;
|
|
2762
2707
|
// URLSearchParams参数可以转普通的string:string,包括FormData
|
|
2763
|
-
// @ts-ignore
|
|
2764
2708
|
let searchParams = new URLSearchParams(requestOption.data);
|
|
2765
2709
|
urlSearch = searchParams.toString();
|
|
2766
2710
|
}
|
|
@@ -2815,9 +2759,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2815
2759
|
else if (ContentType.includes("application/x-www-form-urlencoded")) {
|
|
2816
2760
|
// application/x-www-form-urlencoded
|
|
2817
2761
|
if (typeof requestOption.data === "object") {
|
|
2818
|
-
requestOption.data = new URLSearchParams(
|
|
2819
|
-
// @ts-ignore
|
|
2820
|
-
requestOption.data).toString();
|
|
2762
|
+
requestOption.data = new URLSearchParams(requestOption.data).toString();
|
|
2821
2763
|
}
|
|
2822
2764
|
}
|
|
2823
2765
|
else if (ContentType.includes("multipart/form-data")) {
|
|
@@ -2837,7 +2779,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2837
2779
|
},
|
|
2838
2780
|
/**
|
|
2839
2781
|
* 处理发送请求的配置,去除值为undefined、空function的值
|
|
2840
|
-
* @param option
|
|
2782
|
+
* @param option 请求配置
|
|
2841
2783
|
*/
|
|
2842
2784
|
removeRequestNullOption(option) {
|
|
2843
2785
|
Object.keys(option).forEach((keyName) => {
|
|
@@ -2849,21 +2791,20 @@ System.register('Utils', [], (function (exports) {
|
|
|
2849
2791
|
}
|
|
2850
2792
|
});
|
|
2851
2793
|
if (commonUtil.isNull(option.url)) {
|
|
2852
|
-
throw new TypeError(`Utils.Httpx 参数
|
|
2794
|
+
throw new TypeError(`Utils.Httpx 参数url不能为空:${option.url}`);
|
|
2853
2795
|
}
|
|
2854
2796
|
return option;
|
|
2855
2797
|
},
|
|
2856
2798
|
/**
|
|
2857
2799
|
* 处理fetch的配置
|
|
2858
|
-
* @param option
|
|
2800
|
+
* @param option 请求配置
|
|
2859
2801
|
*/
|
|
2860
2802
|
handleFetchOption(option) {
|
|
2861
2803
|
/**
|
|
2862
2804
|
* fetch的请求配置
|
|
2863
2805
|
**/
|
|
2864
2806
|
let fetchRequestOption = {};
|
|
2865
|
-
if ((option.method === "GET" || option.method === "HEAD") &&
|
|
2866
|
-
option.data != null) {
|
|
2807
|
+
if ((option.method === "GET" || option.method === "HEAD") && option.data != null) {
|
|
2867
2808
|
/* GET 或 HEAD 方法的请求不能包含 body 信息 */
|
|
2868
2809
|
Reflect.deleteProperty(option, "data");
|
|
2869
2810
|
}
|
|
@@ -2908,21 +2849,21 @@ System.register('Utils', [], (function (exports) {
|
|
|
2908
2849
|
};
|
|
2909
2850
|
},
|
|
2910
2851
|
};
|
|
2911
|
-
|
|
2852
|
+
HttpxResponseCallBack = {
|
|
2912
2853
|
context: this,
|
|
2913
2854
|
/**
|
|
2914
2855
|
* onabort请求被取消-触发
|
|
2915
2856
|
* @param details 配置
|
|
2916
|
-
* @param resolve 回调
|
|
2917
|
-
* @param reject
|
|
2857
|
+
* @param resolve promise回调
|
|
2858
|
+
* @param reject promise抛出错误回调
|
|
2918
2859
|
* @param argsResult 返回的参数列表
|
|
2919
2860
|
*/
|
|
2920
2861
|
async onAbort(details, resolve, reject, argsResult) {
|
|
2921
2862
|
// console.log(argsResult);
|
|
2922
|
-
if (
|
|
2863
|
+
if (typeof details?.onabort === "function") {
|
|
2923
2864
|
details.onabort.apply(this, argsResult);
|
|
2924
2865
|
}
|
|
2925
|
-
else if (
|
|
2866
|
+
else if (typeof this.context.#defaultRequestOption?.onabort === "function") {
|
|
2926
2867
|
this.context.#defaultRequestOption.onabort.apply(this, argsResult);
|
|
2927
2868
|
}
|
|
2928
2869
|
let response = argsResult;
|
|
@@ -2931,11 +2872,11 @@ System.register('Utils', [], (function (exports) {
|
|
|
2931
2872
|
}
|
|
2932
2873
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2933
2874
|
type: "onabort",
|
|
2934
|
-
error: new
|
|
2875
|
+
error: new Error("request canceled"),
|
|
2935
2876
|
response: null,
|
|
2936
2877
|
details: details,
|
|
2937
2878
|
})) == null) {
|
|
2938
|
-
// reject(new
|
|
2879
|
+
// reject(new Error("response is intercept with onabort"));
|
|
2939
2880
|
return;
|
|
2940
2881
|
}
|
|
2941
2882
|
resolve({
|
|
@@ -2948,93 +2889,83 @@ System.register('Utils', [], (function (exports) {
|
|
|
2948
2889
|
});
|
|
2949
2890
|
},
|
|
2950
2891
|
/**
|
|
2951
|
-
*
|
|
2892
|
+
* ontimeout请求超时-触发
|
|
2952
2893
|
* @param details 配置
|
|
2953
2894
|
* @param resolve 回调
|
|
2954
2895
|
* @param reject 抛出错误
|
|
2955
2896
|
* @param argsResult 返回的参数列表
|
|
2956
2897
|
*/
|
|
2957
|
-
async
|
|
2898
|
+
async onTimeout(details, resolve, reject, argsResult) {
|
|
2958
2899
|
// console.log(argsResult);
|
|
2959
|
-
if ("
|
|
2960
|
-
|
|
2900
|
+
if (typeof details?.ontimeout === "function") {
|
|
2901
|
+
// 执行配置中的ontime回调
|
|
2902
|
+
details.ontimeout.apply(this, argsResult);
|
|
2961
2903
|
}
|
|
2962
|
-
else if (
|
|
2963
|
-
|
|
2904
|
+
else if (typeof this.context.#defaultRequestOption?.ontimeout === "function") {
|
|
2905
|
+
// 执行默认配置的ontime回调
|
|
2906
|
+
this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
|
|
2964
2907
|
}
|
|
2908
|
+
// 获取响应结果
|
|
2965
2909
|
let response = argsResult;
|
|
2966
2910
|
if (response.length) {
|
|
2967
2911
|
response = response[0];
|
|
2968
2912
|
}
|
|
2913
|
+
// 执行错误回调的钩子
|
|
2969
2914
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2970
|
-
type: "
|
|
2971
|
-
error: new
|
|
2915
|
+
type: "ontimeout",
|
|
2916
|
+
error: new Error("request timeout"),
|
|
2972
2917
|
response: response,
|
|
2973
2918
|
details: details,
|
|
2974
2919
|
})) == null) {
|
|
2975
|
-
// reject(new
|
|
2920
|
+
// reject(new Error("response is intercept with ontimeout"));
|
|
2976
2921
|
return;
|
|
2977
2922
|
}
|
|
2978
2923
|
resolve({
|
|
2979
2924
|
data: response,
|
|
2980
2925
|
details: details,
|
|
2981
|
-
msg: "
|
|
2926
|
+
msg: "请求超时",
|
|
2982
2927
|
status: false,
|
|
2983
|
-
statusCode:
|
|
2984
|
-
type: "
|
|
2928
|
+
statusCode: 0,
|
|
2929
|
+
type: "ontimeout",
|
|
2985
2930
|
});
|
|
2986
2931
|
},
|
|
2987
2932
|
/**
|
|
2988
|
-
*
|
|
2933
|
+
* onerror请求异常-触发
|
|
2989
2934
|
* @param details 配置
|
|
2990
2935
|
* @param resolve 回调
|
|
2991
2936
|
* @param reject 抛出错误
|
|
2992
2937
|
* @param argsResult 返回的参数列表
|
|
2993
2938
|
*/
|
|
2994
|
-
async
|
|
2939
|
+
async onError(details, resolve, reject, argsResult) {
|
|
2995
2940
|
// console.log(argsResult);
|
|
2996
|
-
if ("
|
|
2997
|
-
details.
|
|
2941
|
+
if (typeof details?.onerror === "function") {
|
|
2942
|
+
details.onerror.apply(this, argsResult);
|
|
2998
2943
|
}
|
|
2999
|
-
else if (
|
|
3000
|
-
this.context.#defaultRequestOption.
|
|
2944
|
+
else if (typeof this.context.#defaultRequestOption?.onerror === "function") {
|
|
2945
|
+
this.context.#defaultRequestOption.onerror.apply(this, argsResult);
|
|
3001
2946
|
}
|
|
3002
2947
|
let response = argsResult;
|
|
3003
2948
|
if (response.length) {
|
|
3004
2949
|
response = response[0];
|
|
3005
2950
|
}
|
|
3006
2951
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
3007
|
-
type: "
|
|
3008
|
-
error: new
|
|
3009
|
-
response:
|
|
2952
|
+
type: "onerror",
|
|
2953
|
+
error: new Error("request error"),
|
|
2954
|
+
response: response,
|
|
3010
2955
|
details: details,
|
|
3011
2956
|
})) == null) {
|
|
3012
|
-
// reject(new
|
|
2957
|
+
// reject(new Error("response is intercept with onerror"));
|
|
3013
2958
|
return;
|
|
3014
2959
|
}
|
|
3015
2960
|
resolve({
|
|
3016
2961
|
data: response,
|
|
3017
2962
|
details: details,
|
|
3018
|
-
msg: "
|
|
2963
|
+
msg: "请求异常",
|
|
3019
2964
|
status: false,
|
|
3020
|
-
statusCode:
|
|
3021
|
-
type: "
|
|
2965
|
+
statusCode: response["status"],
|
|
2966
|
+
type: "onerror",
|
|
3022
2967
|
});
|
|
3023
2968
|
},
|
|
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
2969
|
/**
|
|
3039
2970
|
* onload加载完毕-触发
|
|
3040
2971
|
* @param details 请求的配置
|
|
@@ -3114,7 +3045,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3114
3045
|
/* 状态码2xx都是成功的 */
|
|
3115
3046
|
if (Math.floor(originResponse.status / 100) === 2) {
|
|
3116
3047
|
if ((await this.context.HttpxResponseHook.successResponseCallBack(originResponse, details)) == null) {
|
|
3117
|
-
// reject(new
|
|
3048
|
+
// reject(new Error("response is intercept with onloada"));
|
|
3118
3049
|
return;
|
|
3119
3050
|
}
|
|
3120
3051
|
resolve({
|
|
@@ -3127,21 +3058,21 @@ System.register('Utils', [], (function (exports) {
|
|
|
3127
3058
|
});
|
|
3128
3059
|
}
|
|
3129
3060
|
else {
|
|
3130
|
-
this.context.
|
|
3061
|
+
this.context.HttpxResponseCallBack.onError(details, resolve, reject, argsResult);
|
|
3131
3062
|
}
|
|
3132
3063
|
},
|
|
3133
3064
|
/**
|
|
3134
|
-
*
|
|
3065
|
+
* onloadstart请求开始-触发
|
|
3135
3066
|
* @param details 配置
|
|
3136
3067
|
* @param argsResult 返回的参数列表
|
|
3137
3068
|
*/
|
|
3138
|
-
|
|
3069
|
+
onLoadStart(details, argsResult) {
|
|
3139
3070
|
// console.log(argsResult);
|
|
3140
|
-
if ("
|
|
3141
|
-
details.
|
|
3071
|
+
if (typeof details?.onloadstart === "function") {
|
|
3072
|
+
details.onloadstart.apply(this, argsResult);
|
|
3142
3073
|
}
|
|
3143
|
-
else if (
|
|
3144
|
-
this.context.#defaultRequestOption.
|
|
3074
|
+
else if (typeof this.context.#defaultRequestOption?.onloadstart === "function") {
|
|
3075
|
+
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3145
3076
|
}
|
|
3146
3077
|
},
|
|
3147
3078
|
/**
|
|
@@ -3151,13 +3082,27 @@ System.register('Utils', [], (function (exports) {
|
|
|
3151
3082
|
*/
|
|
3152
3083
|
onReadyStateChange(details, argsResult) {
|
|
3153
3084
|
// console.log(argsResult);
|
|
3154
|
-
if (
|
|
3085
|
+
if (typeof details?.onreadystatechange === "function") {
|
|
3155
3086
|
details.onreadystatechange.apply(this, argsResult);
|
|
3156
3087
|
}
|
|
3157
|
-
else if (
|
|
3088
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange === "function") {
|
|
3158
3089
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3159
3090
|
}
|
|
3160
3091
|
},
|
|
3092
|
+
/**
|
|
3093
|
+
* onprogress上传进度-触发
|
|
3094
|
+
* @param details 配置
|
|
3095
|
+
* @param argsResult 返回的参数列表
|
|
3096
|
+
*/
|
|
3097
|
+
onProgress(details, argsResult) {
|
|
3098
|
+
// console.log(argsResult);
|
|
3099
|
+
if (typeof details?.onprogress === "function") {
|
|
3100
|
+
details.onprogress.apply(this, argsResult);
|
|
3101
|
+
}
|
|
3102
|
+
else if (typeof this.context.#defaultRequestOption?.onprogress === "function") {
|
|
3103
|
+
this.context.#defaultRequestOption.onprogress.apply(this, argsResult);
|
|
3104
|
+
}
|
|
3105
|
+
},
|
|
3161
3106
|
};
|
|
3162
3107
|
HttpxRequest = {
|
|
3163
3108
|
context: this,
|
|
@@ -3169,8 +3114,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3169
3114
|
if (this.context.#defaultInitOption.logDetails) {
|
|
3170
3115
|
console.log("[Httpx-HttpxRequest.request] 请求前的配置👇", details);
|
|
3171
3116
|
}
|
|
3172
|
-
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack ===
|
|
3173
|
-
"function") {
|
|
3117
|
+
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack === "function") {
|
|
3174
3118
|
let hookResult = await this.context.HttpxRequestHook.beforeRequestCallBack(details);
|
|
3175
3119
|
if (hookResult == null) {
|
|
3176
3120
|
return;
|
|
@@ -3207,15 +3151,12 @@ System.register('Utils', [], (function (exports) {
|
|
|
3207
3151
|
isFetch: true,
|
|
3208
3152
|
finalUrl: fetchResponse.url,
|
|
3209
3153
|
readyState: 4,
|
|
3210
|
-
// @ts-ignore
|
|
3211
3154
|
status: fetchResponse.status,
|
|
3212
3155
|
statusText: fetchResponse.statusText,
|
|
3213
|
-
|
|
3214
|
-
response: void 0,
|
|
3156
|
+
response: "",
|
|
3215
3157
|
responseFetchHeaders: fetchResponse.headers,
|
|
3216
3158
|
responseHeaders: "",
|
|
3217
|
-
|
|
3218
|
-
responseText: void 0,
|
|
3159
|
+
responseText: "",
|
|
3219
3160
|
responseType: option.responseType,
|
|
3220
3161
|
responseXML: void 0,
|
|
3221
3162
|
};
|
|
@@ -3229,9 +3170,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3229
3170
|
/* 如果需要stream,且获取到的是stream,那直接返回 */
|
|
3230
3171
|
if (option.responseType === "stream" ||
|
|
3231
3172
|
(fetchResponse.headers.has("Content-Type") &&
|
|
3232
|
-
fetchResponse.headers
|
|
3233
|
-
.get("Content-Type")
|
|
3234
|
-
.includes("text/event-stream"))) {
|
|
3173
|
+
fetchResponse.headers.get("Content-Type").includes("text/event-stream"))) {
|
|
3235
3174
|
Reflect.set(httpxResponse, "isStream", true);
|
|
3236
3175
|
Reflect.set(httpxResponse, "response", fetchResponse.body);
|
|
3237
3176
|
Reflect.deleteProperty(httpxResponse, "responseText");
|
|
@@ -3250,9 +3189,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3250
3189
|
/** 数据编码 */
|
|
3251
3190
|
let encoding = "utf-8";
|
|
3252
3191
|
if (fetchResponse.headers.has("Content-Type")) {
|
|
3253
|
-
let charsetMatched = fetchResponse.headers
|
|
3254
|
-
.get("Content-Type")
|
|
3255
|
-
?.match(/charset=(.+)/);
|
|
3192
|
+
let charsetMatched = fetchResponse.headers.get("Content-Type")?.match(/charset=(.+)/);
|
|
3256
3193
|
if (charsetMatched) {
|
|
3257
3194
|
encoding = charsetMatched[1];
|
|
3258
3195
|
encoding = encoding.toLowerCase();
|
|
@@ -3274,13 +3211,11 @@ System.register('Utils', [], (function (exports) {
|
|
|
3274
3211
|
response = new Blob([arrayBuffer]);
|
|
3275
3212
|
}
|
|
3276
3213
|
else if (option.responseType === "json" ||
|
|
3277
|
-
(typeof fetchResponseType === "string" &&
|
|
3278
|
-
fetchResponseType.includes("application/json"))) {
|
|
3214
|
+
(typeof fetchResponseType === "string" && fetchResponseType.includes("application/json"))) {
|
|
3279
3215
|
// response返回格式是JSON格式
|
|
3280
3216
|
response = commonUtil.toJSON(responseText);
|
|
3281
3217
|
}
|
|
3282
|
-
else if (option.responseType === "document" ||
|
|
3283
|
-
option.responseType == null) {
|
|
3218
|
+
else if (option.responseType === "document" || option.responseType == null) {
|
|
3284
3219
|
// response返回格式是文档格式
|
|
3285
3220
|
let parser = new DOMParser();
|
|
3286
3221
|
response = parser.parseFromString(responseText, "text/html");
|
|
@@ -3288,9 +3223,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
3288
3223
|
// 转为XML结构
|
|
3289
3224
|
let parser = new DOMParser();
|
|
3290
3225
|
responseXML = parser.parseFromString(responseText, "text/xml");
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3226
|
+
httpxResponse.response = response;
|
|
3227
|
+
httpxResponse.responseText = responseText;
|
|
3228
|
+
httpxResponse.responseXML = responseXML;
|
|
3294
3229
|
// 执行回调
|
|
3295
3230
|
option.onload(httpxResponse);
|
|
3296
3231
|
})
|
|
@@ -3471,7 +3406,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3471
3406
|
}
|
|
3472
3407
|
/**
|
|
3473
3408
|
* GET 请求
|
|
3474
|
-
* @param url
|
|
3409
|
+
* @param url 请求的url
|
|
3475
3410
|
* @param details 配置
|
|
3476
3411
|
*/
|
|
3477
3412
|
get(...args) {
|
|
@@ -3537,27 +3472,21 @@ System.register('Utils', [], (function (exports) {
|
|
|
3537
3472
|
/** 取消请求 */
|
|
3538
3473
|
let abortFn = null;
|
|
3539
3474
|
let promise = new globalThis.Promise(async (resolve, reject) => {
|
|
3540
|
-
let requestOption = this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject);
|
|
3475
|
+
let requestOption = (this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject));
|
|
3541
3476
|
if (typeof beforeRequestOption === "function") {
|
|
3542
|
-
// @ts-ignore
|
|
3543
3477
|
beforeRequestOption(requestOption);
|
|
3544
3478
|
}
|
|
3545
|
-
|
|
3546
|
-
requestOption =
|
|
3547
|
-
this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3479
|
+
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3548
3480
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3549
|
-
if (requestResult != null &&
|
|
3550
|
-
typeof requestResult.abort === "function") {
|
|
3481
|
+
if (requestResult != null && typeof requestResult.abort === "function") {
|
|
3551
3482
|
abortFn = requestResult.abort;
|
|
3552
3483
|
}
|
|
3553
3484
|
});
|
|
3554
|
-
// @ts-ignore
|
|
3555
3485
|
promise.abort = () => {
|
|
3556
3486
|
if (typeof abortFn === "function") {
|
|
3557
3487
|
abortFn();
|
|
3558
3488
|
}
|
|
3559
3489
|
};
|
|
3560
|
-
// @ts-ignore
|
|
3561
3490
|
return promise;
|
|
3562
3491
|
}
|
|
3563
3492
|
}
|
|
@@ -3567,8 +3496,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3567
3496
|
#storeName;
|
|
3568
3497
|
#dbVersion;
|
|
3569
3498
|
/* websql的版本号,由于ios的问题,版本号的写法不一样 */
|
|
3570
|
-
//
|
|
3571
|
-
#slqVersion = "1";
|
|
3499
|
+
// #slqVersion = "1";
|
|
3572
3500
|
/* 监听IndexDB */
|
|
3573
3501
|
#indexedDB = window.indexedDB ||
|
|
3574
3502
|
window.mozIndexedDB ||
|
|
@@ -3576,8 +3504,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3576
3504
|
window.msIndexedDB;
|
|
3577
3505
|
/* 缓存数据库,避免同一个页面重复创建和销毁 */
|
|
3578
3506
|
#db = {};
|
|
3579
|
-
//
|
|
3580
|
-
#store = null;
|
|
3507
|
+
// #store: IDBObjectStore = null as any;
|
|
3581
3508
|
/** 状态码 */
|
|
3582
3509
|
#statusCode = {
|
|
3583
3510
|
operationSuccess: {
|
|
@@ -3622,7 +3549,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3622
3549
|
txn = this.#db[dbName].transaction(this.#storeName, "readwrite");
|
|
3623
3550
|
/* IndexDB的读写权限 */
|
|
3624
3551
|
store = txn.objectStore(this.#storeName);
|
|
3625
|
-
this.#store = store;
|
|
3552
|
+
// this.#store = store;
|
|
3626
3553
|
return store;
|
|
3627
3554
|
}
|
|
3628
3555
|
/**
|
|
@@ -4042,8 +3969,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
4042
3969
|
if (typeof __GM_info === "string") {
|
|
4043
3970
|
this.tag = __GM_info;
|
|
4044
3971
|
}
|
|
4045
|
-
else if (typeof __GM_info === "object" &&
|
|
4046
|
-
typeof __GM_info?.script?.name === "string") {
|
|
3972
|
+
else if (typeof __GM_info === "object" && typeof __GM_info?.script?.name === "string") {
|
|
4047
3973
|
this.tag = __GM_info.script.name;
|
|
4048
3974
|
}
|
|
4049
3975
|
this.#console = console;
|
|
@@ -4099,8 +4025,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
4099
4025
|
*/
|
|
4100
4026
|
checkClearConsole() {
|
|
4101
4027
|
this.#logCount++;
|
|
4102
|
-
if (this.#details.autoClearConsole &&
|
|
4103
|
-
this.#logCount > this.#details.logMaxCount) {
|
|
4028
|
+
if (this.#details.autoClearConsole && this.#logCount > this.#details.logMaxCount) {
|
|
4104
4029
|
this.#console.clear();
|
|
4105
4030
|
this.#logCount = 0;
|
|
4106
4031
|
}
|
|
@@ -4347,12 +4272,40 @@ System.register('Utils', [], (function (exports) {
|
|
|
4347
4272
|
}
|
|
4348
4273
|
|
|
4349
4274
|
class UtilsDictionary {
|
|
4350
|
-
items
|
|
4275
|
+
items;
|
|
4351
4276
|
constructor(key, value) {
|
|
4277
|
+
this.items = {};
|
|
4352
4278
|
if (key != null) {
|
|
4353
4279
|
this.set(key, value);
|
|
4354
4280
|
}
|
|
4355
4281
|
}
|
|
4282
|
+
/**
|
|
4283
|
+
* 获取字典的长度,同this.size
|
|
4284
|
+
*/
|
|
4285
|
+
get length() {
|
|
4286
|
+
return this.size();
|
|
4287
|
+
}
|
|
4288
|
+
/**
|
|
4289
|
+
* 迭代器
|
|
4290
|
+
*/
|
|
4291
|
+
get entries() {
|
|
4292
|
+
let that = this;
|
|
4293
|
+
return function* () {
|
|
4294
|
+
let itemKeys = Object.keys(that.getItems());
|
|
4295
|
+
for (const keyName of itemKeys) {
|
|
4296
|
+
yield [keyName, that.get(keyName)];
|
|
4297
|
+
}
|
|
4298
|
+
};
|
|
4299
|
+
}
|
|
4300
|
+
/**
|
|
4301
|
+
* 是否可遍历
|
|
4302
|
+
*/
|
|
4303
|
+
get [Symbol.iterator]() {
|
|
4304
|
+
let that = this;
|
|
4305
|
+
return function () {
|
|
4306
|
+
return that.entries();
|
|
4307
|
+
};
|
|
4308
|
+
}
|
|
4356
4309
|
/**
|
|
4357
4310
|
* 检查是否有某一个键
|
|
4358
4311
|
* @param key 键
|
|
@@ -4453,7 +4406,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
4453
4406
|
* 返回字典本身
|
|
4454
4407
|
*/
|
|
4455
4408
|
getItems() {
|
|
4456
|
-
// @ts-ignore
|
|
4457
4409
|
return this.items;
|
|
4458
4410
|
}
|
|
4459
4411
|
/**
|
|
@@ -4463,38 +4415,15 @@ System.register('Utils', [], (function (exports) {
|
|
|
4463
4415
|
concat(data) {
|
|
4464
4416
|
this.items = commonUtil.assign(this.items, data.getItems());
|
|
4465
4417
|
}
|
|
4418
|
+
/**
|
|
4419
|
+
* 迭代字典
|
|
4420
|
+
* @param callbackfn 回调函数
|
|
4421
|
+
*/
|
|
4466
4422
|
forEach(callbackfn) {
|
|
4467
4423
|
for (const key in this.getItems()) {
|
|
4468
4424
|
callbackfn(this.get(key), key, this.getItems());
|
|
4469
4425
|
}
|
|
4470
4426
|
}
|
|
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
4427
|
}
|
|
4499
4428
|
|
|
4500
4429
|
class WindowApi {
|
|
@@ -4520,7 +4449,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
4520
4449
|
if (!option) {
|
|
4521
4450
|
option = Object.assign({}, this.defaultApi);
|
|
4522
4451
|
}
|
|
4523
|
-
// @ts-ignore
|
|
4524
4452
|
this.api = Object.assign({}, option);
|
|
4525
4453
|
}
|
|
4526
4454
|
get document() {
|
|
@@ -4578,11 +4506,10 @@ System.register('Utils', [], (function (exports) {
|
|
|
4578
4506
|
deps = [];
|
|
4579
4507
|
active = true;
|
|
4580
4508
|
fn;
|
|
4581
|
-
//
|
|
4582
|
-
scheduler;
|
|
4509
|
+
// private scheduler;
|
|
4583
4510
|
constructor(fn, scheduler) {
|
|
4584
4511
|
this.fn = fn;
|
|
4585
|
-
this.scheduler = scheduler;
|
|
4512
|
+
// this.scheduler = scheduler;
|
|
4586
4513
|
}
|
|
4587
4514
|
run(cb) {
|
|
4588
4515
|
if (!this.active) {
|
|
@@ -4649,8 +4576,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
4649
4576
|
reactive(target) {
|
|
4650
4577
|
const that = this;
|
|
4651
4578
|
if (!(typeof target === "object" && target !== null)) {
|
|
4652
|
-
|
|
4653
|
-
return;
|
|
4579
|
+
return void 0;
|
|
4654
4580
|
}
|
|
4655
4581
|
if (VueUtils.isReactive(target)) {
|
|
4656
4582
|
return target;
|
|
@@ -4720,7 +4646,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
4720
4646
|
toRefs(object) {
|
|
4721
4647
|
const result = VueUtils.isArray(object) ? new Array(object.length) : {};
|
|
4722
4648
|
for (let key in object) {
|
|
4723
|
-
// @ts-ignore
|
|
4724
4649
|
result[key] = this.toRef(object, key);
|
|
4725
4650
|
}
|
|
4726
4651
|
return result;
|
|
@@ -5016,7 +4941,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5016
4941
|
};
|
|
5017
4942
|
|
|
5018
4943
|
// 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),
|
|
4944
|
+
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
4945
|
|
|
5021
4946
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
5022
4947
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -5448,7 +5373,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
5448
5373
|
let text = textMatch[2];
|
|
5449
5374
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5450
5375
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5451
|
-
// @ts-ignore
|
|
5452
5376
|
return ($ele?.textContent || $ele?.innerText)?.includes(text);
|
|
5453
5377
|
});
|
|
5454
5378
|
}
|
|
@@ -5466,7 +5390,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
5466
5390
|
let regexp = new RegExp(pattern, flags);
|
|
5467
5391
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5468
5392
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5469
|
-
// @ts-ignore
|
|
5470
5393
|
return Boolean(($ele?.textContent || $ele?.innerText)?.match(regexp));
|
|
5471
5394
|
});
|
|
5472
5395
|
}
|
|
@@ -5512,7 +5435,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
5512
5435
|
let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
|
|
5513
5436
|
let text = textMatch[2];
|
|
5514
5437
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5515
|
-
// @ts-ignore
|
|
5516
5438
|
let content = $el?.textContent || $el?.innerText;
|
|
5517
5439
|
if (typeof content !== "string") {
|
|
5518
5440
|
content = "";
|
|
@@ -5532,7 +5454,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
5532
5454
|
}
|
|
5533
5455
|
let regexp = new RegExp(pattern, flags);
|
|
5534
5456
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5535
|
-
// @ts-ignore
|
|
5536
5457
|
let content = $el?.textContent || $el?.innerText;
|
|
5537
5458
|
if (typeof content !== "string") {
|
|
5538
5459
|
content = "";
|
|
@@ -5563,7 +5484,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
5563
5484
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5564
5485
|
let $closest = $el?.closest(selector);
|
|
5565
5486
|
if ($closest) {
|
|
5566
|
-
// @ts-ignore
|
|
5567
5487
|
let content = $el?.textContent || $el?.innerText;
|
|
5568
5488
|
if (typeof content === "string" && content.includes(text)) {
|
|
5569
5489
|
return $closest;
|
|
@@ -5586,7 +5506,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
5586
5506
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5587
5507
|
let $closest = $el?.closest(selector);
|
|
5588
5508
|
if ($closest) {
|
|
5589
|
-
// @ts-ignore
|
|
5590
5509
|
let content = $el?.textContent || $el?.innerText;
|
|
5591
5510
|
if (typeof content === "string" && content.match(regexp)) {
|
|
5592
5511
|
return $closest;
|
|
@@ -5609,7 +5528,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5609
5528
|
this.windowApi = new WindowApi(option);
|
|
5610
5529
|
}
|
|
5611
5530
|
/** 版本号 */
|
|
5612
|
-
version = "2025.
|
|
5531
|
+
version = "2025.8.11";
|
|
5613
5532
|
addStyle(cssText) {
|
|
5614
5533
|
if (typeof cssText !== "string") {
|
|
5615
5534
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5706,7 +5625,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5706
5625
|
return ajaxHooker();
|
|
5707
5626
|
}
|
|
5708
5627
|
};
|
|
5709
|
-
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view =
|
|
5628
|
+
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = this.windowApi.window) {
|
|
5710
5629
|
if (!(canvasElement instanceof HTMLCanvasElement)) {
|
|
5711
5630
|
throw new Error("Utils.canvasClickByPosition 参数canvasElement必须是canvas元素");
|
|
5712
5631
|
}
|
|
@@ -5717,7 +5636,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
5717
5636
|
cancelable: true,
|
|
5718
5637
|
clientX: clientX,
|
|
5719
5638
|
clientY: clientY,
|
|
5720
|
-
// @ts-ignore
|
|
5721
5639
|
view: view,
|
|
5722
5640
|
detail: 1,
|
|
5723
5641
|
};
|
|
@@ -5733,13 +5651,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
5733
5651
|
let touchEvent = UtilsContext.windowApi.window.event;
|
|
5734
5652
|
let $click = clickEvent?.composedPath()?.[0];
|
|
5735
5653
|
// 点击的x坐标
|
|
5736
|
-
let clickPosX = clickEvent?.clientX != null
|
|
5737
|
-
? clickEvent.clientX
|
|
5738
|
-
: touchEvent.touches[0].clientX;
|
|
5654
|
+
let clickPosX = clickEvent?.clientX != null ? clickEvent.clientX : touchEvent.touches[0].clientX;
|
|
5739
5655
|
// 点击的y坐标
|
|
5740
|
-
let clickPosY = clickEvent?.clientY != null
|
|
5741
|
-
? clickEvent.clientY
|
|
5742
|
-
: touchEvent.touches[0].clientY;
|
|
5656
|
+
let clickPosY = clickEvent?.clientY != null ? clickEvent.clientY : touchEvent.touches[0].clientY;
|
|
5743
5657
|
let {
|
|
5744
5658
|
/* 要检测的元素的相对屏幕的横坐标最左边 */
|
|
5745
5659
|
left: elementPosXLeft,
|
|
@@ -5902,9 +5816,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5902
5816
|
/* CODE FOR BROWSERS THAT SUPPORT window.find */
|
|
5903
5817
|
let windowFind = this.windowApi.self.find;
|
|
5904
5818
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5905
|
-
if (strFound &&
|
|
5906
|
-
this.windowApi.self.getSelection &&
|
|
5907
|
-
!this.windowApi.self.getSelection().anchorNode) {
|
|
5819
|
+
if (strFound && this.windowApi.self.getSelection && !this.windowApi.self.getSelection().anchorNode) {
|
|
5908
5820
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5909
5821
|
}
|
|
5910
5822
|
if (!strFound) {
|
|
@@ -6007,9 +5919,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
6007
5919
|
}
|
|
6008
5920
|
}
|
|
6009
5921
|
result = result.toFixed(2);
|
|
6010
|
-
result = addType
|
|
6011
|
-
? result + resultType.toString()
|
|
6012
|
-
: parseFloat(result.toString());
|
|
5922
|
+
result = addType ? result + resultType.toString() : parseFloat(result.toString());
|
|
6013
5923
|
return result;
|
|
6014
5924
|
}
|
|
6015
5925
|
getNodeListValue(...args) {
|
|
@@ -6088,14 +5998,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
6088
5998
|
if (text.length === 8) {
|
|
6089
5999
|
/* 该字符串只有时分秒 */
|
|
6090
6000
|
let today = new Date();
|
|
6091
|
-
text =
|
|
6092
|
-
today.getFullYear() +
|
|
6093
|
-
"-" +
|
|
6094
|
-
(today.getMonth() + 1) +
|
|
6095
|
-
"-" +
|
|
6096
|
-
today.getDate() +
|
|
6097
|
-
" " +
|
|
6098
|
-
text;
|
|
6001
|
+
text = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate() + " " + text;
|
|
6099
6002
|
}
|
|
6100
6003
|
text = text.substring(0, 19);
|
|
6101
6004
|
text = text.replace(/-/g, "/");
|
|
@@ -6116,25 +6019,13 @@ System.register('Utils', [], (function (exports) {
|
|
|
6116
6019
|
* 获取 transitionend 的在各个浏览器的兼容名
|
|
6117
6020
|
*/
|
|
6118
6021
|
getTransitionEndNameList() {
|
|
6119
|
-
return [
|
|
6120
|
-
"webkitTransitionEnd",
|
|
6121
|
-
"mozTransitionEnd",
|
|
6122
|
-
"MSTransitionEnd",
|
|
6123
|
-
"otransitionend",
|
|
6124
|
-
"transitionend",
|
|
6125
|
-
];
|
|
6022
|
+
return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
|
|
6126
6023
|
}
|
|
6127
6024
|
/**
|
|
6128
6025
|
* 获取 animationend 的在各个浏览器的兼容名
|
|
6129
6026
|
*/
|
|
6130
6027
|
getAnimationEndNameList() {
|
|
6131
|
-
return [
|
|
6132
|
-
"webkitAnimationEnd",
|
|
6133
|
-
"mozAnimationEnd",
|
|
6134
|
-
"MSAnimationEnd",
|
|
6135
|
-
"oanimationend",
|
|
6136
|
-
"animationend",
|
|
6137
|
-
];
|
|
6028
|
+
return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
|
|
6138
6029
|
}
|
|
6139
6030
|
getArrayLastValue(targetObj) {
|
|
6140
6031
|
return targetObj[targetObj.length - 1];
|
|
@@ -6224,12 +6115,10 @@ System.register('Utils', [], (function (exports) {
|
|
|
6224
6115
|
}
|
|
6225
6116
|
getElementSelector(element) {
|
|
6226
6117
|
let UtilsContext = this;
|
|
6227
|
-
// @ts-ignore
|
|
6228
6118
|
if (!element)
|
|
6229
|
-
return;
|
|
6230
|
-
// @ts-ignore
|
|
6119
|
+
return void 0;
|
|
6231
6120
|
if (!element.parentElement)
|
|
6232
|
-
return;
|
|
6121
|
+
return void 0;
|
|
6233
6122
|
/* 如果元素有id属性,则直接返回id选择器 */
|
|
6234
6123
|
if (element.id)
|
|
6235
6124
|
return "#" + element.id;
|
|
@@ -6240,10 +6129,8 @@ System.register('Utils', [], (function (exports) {
|
|
|
6240
6129
|
}
|
|
6241
6130
|
/* 如果有多个相同类型的兄弟元素,则需要添加索引 */
|
|
6242
6131
|
if (element.parentElement.querySelectorAll(element.tagName).length > 1) {
|
|
6243
|
-
let index = Array.prototype.indexOf.call(element.parentElement.children, element) +
|
|
6244
|
-
|
|
6245
|
-
selector +=
|
|
6246
|
-
" > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6132
|
+
let index = Array.prototype.indexOf.call(element.parentElement.children, element) + 1;
|
|
6133
|
+
selector += " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6247
6134
|
}
|
|
6248
6135
|
else {
|
|
6249
6136
|
selector += " > " + element.tagName.toLowerCase();
|
|
@@ -6260,13 +6147,10 @@ System.register('Utils', [], (function (exports) {
|
|
|
6260
6147
|
let result = [...args];
|
|
6261
6148
|
let newResult = [];
|
|
6262
6149
|
if (result.length === 0) {
|
|
6263
|
-
|
|
6264
|
-
return;
|
|
6150
|
+
return void 0;
|
|
6265
6151
|
}
|
|
6266
6152
|
if (result.length > 1) {
|
|
6267
|
-
if (result.length === 2 &&
|
|
6268
|
-
typeof result[0] === "object" &&
|
|
6269
|
-
typeof result[1] === "function") {
|
|
6153
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6270
6154
|
let data = result[0];
|
|
6271
6155
|
let handleDataFunc = result[1];
|
|
6272
6156
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6301,7 +6185,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
6301
6185
|
// 当前页面最大的z-index
|
|
6302
6186
|
let zIndex = 0;
|
|
6303
6187
|
// 当前的最大z-index的元素,调试使用
|
|
6304
|
-
// @ts-ignore
|
|
6305
6188
|
let maxZIndexNode = null;
|
|
6306
6189
|
/**
|
|
6307
6190
|
* 元素是否可见
|
|
@@ -6362,13 +6245,10 @@ System.register('Utils', [], (function (exports) {
|
|
|
6362
6245
|
let result = [...args];
|
|
6363
6246
|
let newResult = [];
|
|
6364
6247
|
if (result.length === 0) {
|
|
6365
|
-
|
|
6366
|
-
return;
|
|
6248
|
+
return void 0;
|
|
6367
6249
|
}
|
|
6368
6250
|
if (result.length > 1) {
|
|
6369
|
-
if (result.length === 2 &&
|
|
6370
|
-
typeof result[0] === "object" &&
|
|
6371
|
-
typeof result[1] === "function") {
|
|
6251
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6372
6252
|
let data = result[0];
|
|
6373
6253
|
let handleDataFunc = result[1];
|
|
6374
6254
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6458,12 +6338,10 @@ System.register('Utils', [], (function (exports) {
|
|
|
6458
6338
|
getRandomValue(...args) {
|
|
6459
6339
|
let result = [...args];
|
|
6460
6340
|
if (result.length > 1) {
|
|
6461
|
-
if (result.length === 2 &&
|
|
6462
|
-
typeof result[0] === "number" &&
|
|
6463
|
-
typeof result[1] === "number") {
|
|
6341
|
+
if (result.length === 2 && typeof result[0] === "number" && typeof result[1] === "number") {
|
|
6464
6342
|
let leftNumber = result[0] > result[1] ? result[1] : result[0];
|
|
6465
6343
|
let rightNumber = result[0] > result[1] ? result[0] : result[1];
|
|
6466
|
-
return
|
|
6344
|
+
return Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber;
|
|
6467
6345
|
}
|
|
6468
6346
|
else {
|
|
6469
6347
|
return result[Math.floor(Math.random() * result.length)];
|
|
@@ -6474,8 +6352,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
6474
6352
|
if (Array.isArray(paramData)) {
|
|
6475
6353
|
return paramData[Math.floor(Math.random() * paramData.length)];
|
|
6476
6354
|
}
|
|
6477
|
-
else if (typeof paramData === "object" &&
|
|
6478
|
-
Object.keys(paramData).length > 0) {
|
|
6355
|
+
else if (typeof paramData === "object" && Object.keys(paramData).length > 0) {
|
|
6479
6356
|
let paramObjDataKey = Object.keys(paramData)[Math.floor(Math.random() * Object.keys(paramData).length)];
|
|
6480
6357
|
return paramData[paramObjDataKey];
|
|
6481
6358
|
}
|
|
@@ -6782,11 +6659,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
6782
6659
|
let nearBottomHeight = 50;
|
|
6783
6660
|
let checkWindow = () => {
|
|
6784
6661
|
// 已滚动的距离
|
|
6785
|
-
let scrollTop = this.windowApi.window.pageYOffset ||
|
|
6786
|
-
this.windowApi.document.documentElement.scrollTop;
|
|
6662
|
+
let scrollTop = this.windowApi.window.pageYOffset || this.windowApi.document.documentElement.scrollTop;
|
|
6787
6663
|
// 视窗高度
|
|
6788
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
6789
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6664
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
6790
6665
|
// 最大滚动距离
|
|
6791
6666
|
let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
|
|
6792
6667
|
return scrollTop + viewportHeight >= maxScrollHeight;
|
|
@@ -6837,7 +6712,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
6837
6712
|
}
|
|
6838
6713
|
isJQuery(target) {
|
|
6839
6714
|
let result = false;
|
|
6840
|
-
// @ts-ignore
|
|
6841
6715
|
if (typeof jQuery === "object" && target instanceof jQuery) {
|
|
6842
6716
|
result = true;
|
|
6843
6717
|
}
|
|
@@ -7076,8 +6950,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7076
6950
|
**/
|
|
7077
6951
|
isNull = commonUtil.isNull.bind(commonUtil);
|
|
7078
6952
|
isThemeDark() {
|
|
7079
|
-
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)")
|
|
7080
|
-
.matches;
|
|
6953
|
+
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
7081
6954
|
}
|
|
7082
6955
|
/**
|
|
7083
6956
|
* 判断元素是否在页面中可见
|
|
@@ -7110,10 +6983,8 @@ System.register('Utils', [], (function (exports) {
|
|
|
7110
6983
|
else {
|
|
7111
6984
|
let domClientRect = domItem.getBoundingClientRect();
|
|
7112
6985
|
if (inView) {
|
|
7113
|
-
let viewportWidth = this.windowApi.window.innerWidth ||
|
|
7114
|
-
|
|
7115
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
7116
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6986
|
+
let viewportWidth = this.windowApi.window.innerWidth || this.windowApi.document.documentElement.clientWidth;
|
|
6987
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
7117
6988
|
result = !(domClientRect.right < 0 ||
|
|
7118
6989
|
domClientRect.left > viewportWidth ||
|
|
7119
6990
|
domClientRect.bottom < 0 ||
|
|
@@ -7137,8 +7008,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7137
7008
|
for (const key in Object.values(this.windowApi.top.window.via)) {
|
|
7138
7009
|
if (Reflect.has(this.windowApi.top.window.via, key)) {
|
|
7139
7010
|
let objValueFunc = this.windowApi.top.window.via[key];
|
|
7140
|
-
if (typeof objValueFunc === "function" &&
|
|
7141
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7011
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7142
7012
|
result = true;
|
|
7143
7013
|
}
|
|
7144
7014
|
else {
|
|
@@ -7160,8 +7030,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7160
7030
|
for (const key in Object.values(this.windowApi.top.window.mbrowser)) {
|
|
7161
7031
|
if (Reflect.has(this.windowApi.top.window.mbrowser, key)) {
|
|
7162
7032
|
let objValueFunc = this.windowApi.top.window.mbrowser[key];
|
|
7163
|
-
if (typeof objValueFunc === "function" &&
|
|
7164
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7033
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7165
7034
|
result = true;
|
|
7166
7035
|
}
|
|
7167
7036
|
else {
|
|
@@ -7398,13 +7267,11 @@ System.register('Utils', [], (function (exports) {
|
|
|
7398
7267
|
* 释放所有
|
|
7399
7268
|
*/
|
|
7400
7269
|
function releaseAll() {
|
|
7401
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] !==
|
|
7402
|
-
"undefined") {
|
|
7270
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] !== "undefined") {
|
|
7403
7271
|
/* 已存在 */
|
|
7404
7272
|
return;
|
|
7405
7273
|
}
|
|
7406
|
-
UtilsContext.windowApi.window[needReleaseKey] =
|
|
7407
|
-
UtilsContext.deepClone(needReleaseObject);
|
|
7274
|
+
UtilsContext.windowApi.window[needReleaseKey] = UtilsContext.deepClone(needReleaseObject);
|
|
7408
7275
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7409
7276
|
if (typeof value === "function") {
|
|
7410
7277
|
needReleaseObject[value.name] = () => { };
|
|
@@ -7418,8 +7285,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7418
7285
|
Array.from(functionNameList).forEach((item) => {
|
|
7419
7286
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7420
7287
|
if (typeof value === "function") {
|
|
7421
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7422
|
-
"undefined") {
|
|
7288
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7423
7289
|
UtilsContext.windowApi.window[needReleaseKey] = {};
|
|
7424
7290
|
}
|
|
7425
7291
|
if (item === value.name) {
|
|
@@ -7434,8 +7300,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7434
7300
|
* 恢复所有
|
|
7435
7301
|
*/
|
|
7436
7302
|
function recoveryAll() {
|
|
7437
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7438
|
-
"undefined") {
|
|
7303
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7439
7304
|
/* 未存在 */
|
|
7440
7305
|
return;
|
|
7441
7306
|
}
|
|
@@ -7446,8 +7311,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7446
7311
|
* 恢复单个
|
|
7447
7312
|
*/
|
|
7448
7313
|
function recoveryOne() {
|
|
7449
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7450
|
-
"undefined") {
|
|
7314
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7451
7315
|
/* 未存在 */
|
|
7452
7316
|
return;
|
|
7453
7317
|
}
|
|
@@ -7455,8 +7319,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7455
7319
|
if (UtilsContext.windowApi.window[needReleaseKey][item]) {
|
|
7456
7320
|
needReleaseObject[item] = UtilsContext.windowApi.window[needReleaseKey][item];
|
|
7457
7321
|
Reflect.deleteProperty(UtilsContext.windowApi.window[needReleaseKey], item);
|
|
7458
|
-
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey])
|
|
7459
|
-
.length === 0) {
|
|
7322
|
+
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey]).length === 0) {
|
|
7460
7323
|
Reflect.deleteProperty(window, needReleaseKey);
|
|
7461
7324
|
}
|
|
7462
7325
|
}
|
|
@@ -7618,29 +7481,27 @@ System.register('Utils', [], (function (exports) {
|
|
|
7618
7481
|
EventTarget.prototype.addEventListener = function (...args) {
|
|
7619
7482
|
let type = args[0];
|
|
7620
7483
|
let callback = args[1];
|
|
7621
|
-
//
|
|
7622
|
-
args[2];
|
|
7484
|
+
// let options = args[2];
|
|
7623
7485
|
if (filter(type)) {
|
|
7624
7486
|
if (typeof callback === "function") {
|
|
7625
7487
|
args[1] = function (event) {
|
|
7626
7488
|
callback.call(this, trustEvent(event));
|
|
7627
7489
|
};
|
|
7628
7490
|
}
|
|
7629
|
-
else if (typeof callback === "object" &&
|
|
7630
|
-
"handleEvent" in callback) {
|
|
7491
|
+
else if (typeof callback === "object" && "handleEvent" in callback) {
|
|
7631
7492
|
let oldHandleEvent = callback["handleEvent"];
|
|
7632
7493
|
args[1]["handleEvent"] = function (event) {
|
|
7633
7494
|
if (event == null) {
|
|
7634
7495
|
return;
|
|
7635
7496
|
}
|
|
7636
7497
|
try {
|
|
7637
|
-
|
|
7498
|
+
// Proxy对象使用instanceof会报错
|
|
7499
|
+
// 这里故意尝试一下,如果报错,则说明是Proxy对象
|
|
7638
7500
|
event instanceof Proxy;
|
|
7639
7501
|
oldHandleEvent.call(this, trustEvent(event));
|
|
7640
7502
|
}
|
|
7641
7503
|
catch (error) {
|
|
7642
|
-
|
|
7643
|
-
event["isTrusted"] = isTrustValue;
|
|
7504
|
+
Reflect.set(event, "isTrusted", isTrustValue);
|
|
7644
7505
|
}
|
|
7645
7506
|
};
|
|
7646
7507
|
}
|
|
@@ -7713,10 +7574,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
7713
7574
|
}
|
|
7714
7575
|
async init() {
|
|
7715
7576
|
let copyStatus = false;
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
if (this.hasClipboard() &&
|
|
7719
|
-
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7577
|
+
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7578
|
+
console.log(requestPermissionStatus);
|
|
7579
|
+
if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7720
7580
|
try {
|
|
7721
7581
|
copyStatus = await this.copyDataByClipboard();
|
|
7722
7582
|
}
|
|
@@ -7732,11 +7592,8 @@ System.register('Utils', [], (function (exports) {
|
|
|
7732
7592
|
this.destroy();
|
|
7733
7593
|
}
|
|
7734
7594
|
destroy() {
|
|
7735
|
-
// @ts-ignore
|
|
7736
7595
|
this.#resolve = null;
|
|
7737
|
-
// @ts-ignore
|
|
7738
7596
|
this.#copyData = null;
|
|
7739
|
-
// @ts-ignore
|
|
7740
7597
|
this.#copyDataType = null;
|
|
7741
7598
|
}
|
|
7742
7599
|
isText() {
|
|
@@ -7780,7 +7637,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
7780
7637
|
if (navigator.permissions && navigator.permissions.query) {
|
|
7781
7638
|
navigator.permissions
|
|
7782
7639
|
.query({
|
|
7783
|
-
// @ts-ignore
|
|
7784
7640
|
name: "clipboard-write",
|
|
7785
7641
|
})
|
|
7786
7642
|
.then((permissionStatus) => {
|
|
@@ -7876,17 +7732,13 @@ System.register('Utils', [], (function (exports) {
|
|
|
7876
7732
|
dragSlider(selector, offsetX = this.windowApi.window.innerWidth) {
|
|
7877
7733
|
let UtilsContext = this;
|
|
7878
7734
|
function initMouseEvent(eventName, offSetX, offSetY) {
|
|
7879
|
-
// @ts-ignore
|
|
7880
7735
|
let win = typeof unsafeWindow === "undefined" ? globalThis : unsafeWindow;
|
|
7881
7736
|
let mouseEvent = UtilsContext.windowApi.document.createEvent("MouseEvents");
|
|
7882
7737
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
7883
7738
|
return mouseEvent;
|
|
7884
7739
|
}
|
|
7885
|
-
let sliderElement = typeof selector === "string"
|
|
7886
|
-
|
|
7887
|
-
: selector;
|
|
7888
|
-
if (!(sliderElement instanceof Node) ||
|
|
7889
|
-
!(sliderElement instanceof Element)) {
|
|
7740
|
+
let sliderElement = typeof selector === "string" ? domUtils.selector(selector) : selector;
|
|
7741
|
+
if (!(sliderElement instanceof Node) || !(sliderElement instanceof Element)) {
|
|
7890
7742
|
throw new Error("Utils.dragSlider 参数selector 必须为Node/Element类型");
|
|
7891
7743
|
}
|
|
7892
7744
|
let rect = sliderElement.getBoundingClientRect(), x0 = rect.x || rect.left, y0 = rect.y || rect.top, x1 = x0 + offsetX, y1 = y0;
|
|
@@ -7938,17 +7790,14 @@ System.register('Utils', [], (function (exports) {
|
|
|
7938
7790
|
}
|
|
7939
7791
|
sortListByProperty(data, getPropertyValueFunc, sortByDesc = true) {
|
|
7940
7792
|
let UtilsContext = this;
|
|
7941
|
-
if (typeof getPropertyValueFunc !== "function" &&
|
|
7942
|
-
typeof getPropertyValueFunc !== "string") {
|
|
7793
|
+
if (typeof getPropertyValueFunc !== "function" && typeof getPropertyValueFunc !== "string") {
|
|
7943
7794
|
throw new Error("Utils.sortListByProperty 参数 getPropertyValueFunc 必须为 function|string 类型");
|
|
7944
7795
|
}
|
|
7945
7796
|
if (typeof sortByDesc !== "boolean") {
|
|
7946
7797
|
throw new Error("Utils.sortListByProperty 参数 sortByDesc 必须为 boolean 类型");
|
|
7947
7798
|
}
|
|
7948
7799
|
let getObjValue = function (obj) {
|
|
7949
|
-
return typeof getPropertyValueFunc === "string"
|
|
7950
|
-
? obj[getPropertyValueFunc]
|
|
7951
|
-
: getPropertyValueFunc(obj);
|
|
7800
|
+
return typeof getPropertyValueFunc === "string" ? obj[getPropertyValueFunc] : getPropertyValueFunc(obj);
|
|
7952
7801
|
};
|
|
7953
7802
|
/**
|
|
7954
7803
|
* 排序方法
|
|
@@ -8023,8 +7872,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8023
7872
|
if (Array.isArray(data)) {
|
|
8024
7873
|
data.sort(sortFunc);
|
|
8025
7874
|
}
|
|
8026
|
-
else if (data instanceof NodeList ||
|
|
8027
|
-
UtilsContext.isJQuery(data)) {
|
|
7875
|
+
else if (data instanceof NodeList || UtilsContext.isJQuery(data)) {
|
|
8028
7876
|
sortNodeFunc(data, getDataFunc);
|
|
8029
7877
|
result = getDataFunc();
|
|
8030
7878
|
}
|
|
@@ -8035,7 +7883,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
8035
7883
|
}
|
|
8036
7884
|
stringToRegular(targetString, flags = "ig") {
|
|
8037
7885
|
let reg;
|
|
8038
|
-
// @ts-ignore
|
|
8039
7886
|
flags = flags.toLowerCase();
|
|
8040
7887
|
if (typeof targetString === "string") {
|
|
8041
7888
|
reg = new RegExp(targetString.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"), flags);
|
|
@@ -8128,10 +7975,8 @@ System.register('Utils', [], (function (exports) {
|
|
|
8128
7975
|
*/
|
|
8129
7976
|
searchParamStrToObj(searhParamsStr) {
|
|
8130
7977
|
if (typeof searhParamsStr !== "string") {
|
|
8131
|
-
// @ts-ignore
|
|
8132
7978
|
return {};
|
|
8133
7979
|
}
|
|
8134
|
-
// @ts-ignore
|
|
8135
7980
|
return Object.fromEntries(new URLSearchParams(searhParamsStr));
|
|
8136
7981
|
}
|
|
8137
7982
|
/**
|
|
@@ -8220,9 +8065,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8220
8065
|
let parent = UtilsContext.windowApi.document;
|
|
8221
8066
|
// 超时时间
|
|
8222
8067
|
let timeout = 0;
|
|
8223
|
-
if (typeof args[0] !== "string" &&
|
|
8224
|
-
!Array.isArray(args[0]) &&
|
|
8225
|
-
typeof args[0] !== "function") {
|
|
8068
|
+
if (typeof args[0] !== "string" && !Array.isArray(args[0]) && typeof args[0] !== "function") {
|
|
8226
8069
|
throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
|
|
8227
8070
|
}
|
|
8228
8071
|
if (args.length === 1) ;
|
|
@@ -8232,8 +8075,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8232
8075
|
// "div",10000
|
|
8233
8076
|
timeout = secondParam;
|
|
8234
8077
|
}
|
|
8235
|
-
else if (typeof secondParam === "object" &&
|
|
8236
|
-
secondParam instanceof Node) {
|
|
8078
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8237
8079
|
// "div",document
|
|
8238
8080
|
parent = secondParam;
|
|
8239
8081
|
}
|
|
@@ -8319,8 +8161,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8319
8161
|
// "div",10000
|
|
8320
8162
|
timeout = secondParam;
|
|
8321
8163
|
}
|
|
8322
|
-
else if (typeof secondParam === "object" &&
|
|
8323
|
-
secondParam instanceof Node) {
|
|
8164
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8324
8165
|
// "div",document
|
|
8325
8166
|
parent = secondParam;
|
|
8326
8167
|
}
|
|
@@ -8375,8 +8216,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8375
8216
|
// "div",10000
|
|
8376
8217
|
timeout = secondParam;
|
|
8377
8218
|
}
|
|
8378
|
-
else if (typeof secondParam === "object" &&
|
|
8379
|
-
secondParam instanceof Node) {
|
|
8219
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8380
8220
|
// "div",document
|
|
8381
8221
|
parent = secondParam;
|
|
8382
8222
|
}
|
|
@@ -8462,8 +8302,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8462
8302
|
// "div",10000
|
|
8463
8303
|
timeout = secondParam;
|
|
8464
8304
|
}
|
|
8465
|
-
else if (typeof secondParam === "object" &&
|
|
8466
|
-
secondParam instanceof Node) {
|
|
8305
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8467
8306
|
// "div",document
|
|
8468
8307
|
parent = secondParam;
|
|
8469
8308
|
}
|
|
@@ -8596,8 +8435,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8596
8435
|
return flag;
|
|
8597
8436
|
}
|
|
8598
8437
|
watchObject(target, propertyName, getCallBack, setCallBack) {
|
|
8599
|
-
if (typeof getCallBack !== "function" &&
|
|
8600
|
-
typeof setCallBack !== "function") {
|
|
8438
|
+
if (typeof getCallBack !== "function" && typeof setCallBack !== "function") {
|
|
8601
8439
|
return;
|
|
8602
8440
|
}
|
|
8603
8441
|
if (typeof getCallBack === "function") {
|
|
@@ -8649,13 +8487,27 @@ System.register('Utils', [], (function (exports) {
|
|
|
8649
8487
|
return;
|
|
8650
8488
|
}
|
|
8651
8489
|
let handleResult = handler(target);
|
|
8652
|
-
if (handleResult &&
|
|
8653
|
-
typeof handleResult.isFind === "boolean" &&
|
|
8654
|
-
handleResult.isFind) {
|
|
8490
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8655
8491
|
return handleResult.data;
|
|
8656
8492
|
}
|
|
8657
8493
|
return this.queryProperty(handleResult.data, handler);
|
|
8658
8494
|
}
|
|
8495
|
+
/**
|
|
8496
|
+
* 异步-深度获取对象属性
|
|
8497
|
+
* @param target 待获取的对象
|
|
8498
|
+
* @param handler 获取属性的回调
|
|
8499
|
+
*/
|
|
8500
|
+
async asyncQueryProperty(target, handler) {
|
|
8501
|
+
if (target == null) {
|
|
8502
|
+
// @ts-ignore
|
|
8503
|
+
return;
|
|
8504
|
+
}
|
|
8505
|
+
let handleResult = await handler(target);
|
|
8506
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8507
|
+
return handleResult.data;
|
|
8508
|
+
}
|
|
8509
|
+
return await this.asyncQueryProperty(handleResult.data, handler);
|
|
8510
|
+
}
|
|
8659
8511
|
/**
|
|
8660
8512
|
* 创建一个新的Utils实例
|
|
8661
8513
|
* @param option
|
|
@@ -8834,7 +8686,6 @@ System.register('Utils', [], (function (exports) {
|
|
|
8834
8686
|
function requestPermissionsWithClipboard() {
|
|
8835
8687
|
navigator.permissions
|
|
8836
8688
|
.query({
|
|
8837
|
-
// @ts-ignore
|
|
8838
8689
|
name: "clipboard-read",
|
|
8839
8690
|
})
|
|
8840
8691
|
.then((permissionStatus) => {
|