@whitesev/utils 1.9.7 → 1.9.8
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 +35 -18
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +35 -18
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +35 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +35 -18
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +35 -18
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +35 -18
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -205,6 +205,7 @@ class GBKEncoder {
|
|
|
205
205
|
decode(str) {
|
|
206
206
|
var GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
|
|
207
207
|
var UTFMatcher = /%[0-9A-F]{2}/;
|
|
208
|
+
// @ts-ignore
|
|
208
209
|
var utf = true;
|
|
209
210
|
let that = this;
|
|
210
211
|
while (utf) {
|
|
@@ -1165,6 +1166,7 @@ class GMMenu {
|
|
|
1165
1166
|
let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
|
|
1166
1167
|
/** 油猴菜单上显示的文本 */
|
|
1167
1168
|
let showText = menuOption.showText(menuOption.text, defaultEnable);
|
|
1169
|
+
// @ts-ignore
|
|
1168
1170
|
({
|
|
1169
1171
|
/**
|
|
1170
1172
|
* 菜单的id
|
|
@@ -2537,6 +2539,7 @@ class indexedDB {
|
|
|
2537
2539
|
#storeName;
|
|
2538
2540
|
#dbVersion;
|
|
2539
2541
|
/* websql的版本号,由于ios的问题,版本号的写法不一样 */
|
|
2542
|
+
// @ts-ignore
|
|
2540
2543
|
#slqVersion = "1";
|
|
2541
2544
|
/* 监听IndexDB */
|
|
2542
2545
|
#indexedDB = UtilsCore.window.indexedDB ||
|
|
@@ -2545,6 +2548,7 @@ class indexedDB {
|
|
|
2545
2548
|
UtilsCore.window.msIndexedDB;
|
|
2546
2549
|
/* 缓存数据库,避免同一个页面重复创建和销毁 */
|
|
2547
2550
|
#db = {};
|
|
2551
|
+
// @ts-ignore
|
|
2548
2552
|
#store = null;
|
|
2549
2553
|
#errorCode = {
|
|
2550
2554
|
/* 错误码 */
|
|
@@ -2659,6 +2663,7 @@ class indexedDB {
|
|
|
2659
2663
|
let request = idbStore.put(inData);
|
|
2660
2664
|
request.onsuccess = function (event) {
|
|
2661
2665
|
/* 保存成功有success 字段 */
|
|
2666
|
+
// @ts-ignore
|
|
2662
2667
|
event.target;
|
|
2663
2668
|
resolve({
|
|
2664
2669
|
success: true,
|
|
@@ -2668,6 +2673,7 @@ class indexedDB {
|
|
|
2668
2673
|
});
|
|
2669
2674
|
};
|
|
2670
2675
|
request.onerror = function (event) {
|
|
2676
|
+
// @ts-ignore
|
|
2671
2677
|
event.target;
|
|
2672
2678
|
resolve({
|
|
2673
2679
|
success: false,
|
|
@@ -2729,6 +2735,7 @@ class indexedDB {
|
|
|
2729
2735
|
}
|
|
2730
2736
|
};
|
|
2731
2737
|
request.onerror = function (event) {
|
|
2738
|
+
// @ts-ignore
|
|
2732
2739
|
event.target;
|
|
2733
2740
|
resolve({
|
|
2734
2741
|
success: false,
|
|
@@ -2786,6 +2793,7 @@ class indexedDB {
|
|
|
2786
2793
|
});
|
|
2787
2794
|
};
|
|
2788
2795
|
request.onerror = function (event) {
|
|
2796
|
+
// @ts-ignore
|
|
2789
2797
|
event.target;
|
|
2790
2798
|
resolve({
|
|
2791
2799
|
success: false,
|
|
@@ -2840,6 +2848,7 @@ class indexedDB {
|
|
|
2840
2848
|
}
|
|
2841
2849
|
};
|
|
2842
2850
|
request.onerror = function (event) {
|
|
2851
|
+
// @ts-ignore
|
|
2843
2852
|
event.target;
|
|
2844
2853
|
resolve({
|
|
2845
2854
|
success: false,
|
|
@@ -5134,8 +5143,11 @@ class Utils {
|
|
|
5134
5143
|
let windowMutationObserver = UtilsCore.window.MutationObserver ||
|
|
5135
5144
|
UtilsCore.window.webkitMutationObserver ||
|
|
5136
5145
|
UtilsCore.window.MozMutationObserver;
|
|
5146
|
+
// 观察者对象
|
|
5137
5147
|
let mutationObserver = new windowMutationObserver(function (mutations, observer) {
|
|
5138
|
-
observer_config
|
|
5148
|
+
if (typeof observer_config.callback === "function") {
|
|
5149
|
+
observer_config.callback(mutations, observer);
|
|
5150
|
+
}
|
|
5139
5151
|
});
|
|
5140
5152
|
if (Array.isArray(target) || target instanceof NodeList) {
|
|
5141
5153
|
// 传入的是数组或者元素数组
|
|
@@ -5154,7 +5166,9 @@ class Utils {
|
|
|
5154
5166
|
}
|
|
5155
5167
|
if (observer_config.immediate) {
|
|
5156
5168
|
/* 主动触发一次 */
|
|
5157
|
-
observer_config.callback
|
|
5169
|
+
if (typeof observer_config.callback === "function") {
|
|
5170
|
+
observer_config.callback([], mutationObserver);
|
|
5171
|
+
}
|
|
5158
5172
|
}
|
|
5159
5173
|
return mutationObserver;
|
|
5160
5174
|
}
|
|
@@ -5402,6 +5416,7 @@ class Utils {
|
|
|
5402
5416
|
EventTarget.prototype.addEventListener = function (...args) {
|
|
5403
5417
|
let type = args[0];
|
|
5404
5418
|
let callback = args[1];
|
|
5419
|
+
// @ts-ignore
|
|
5405
5420
|
args[2];
|
|
5406
5421
|
if (filter(type)) {
|
|
5407
5422
|
if (typeof callback === "function") {
|
|
@@ -5495,6 +5510,7 @@ class Utils {
|
|
|
5495
5510
|
}
|
|
5496
5511
|
async init() {
|
|
5497
5512
|
let copyStatus = false;
|
|
5513
|
+
// @ts-ignore
|
|
5498
5514
|
await this.requestClipboardPermission();
|
|
5499
5515
|
if (this.hasClipboard() &&
|
|
5500
5516
|
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
@@ -6028,12 +6044,7 @@ class Utils {
|
|
|
6028
6044
|
return parent.querySelector(selector);
|
|
6029
6045
|
}
|
|
6030
6046
|
}
|
|
6031
|
-
|
|
6032
|
-
if (node) {
|
|
6033
|
-
resolve(node);
|
|
6034
|
-
return;
|
|
6035
|
-
}
|
|
6036
|
-
let observer = that.mutationObserver(parent, {
|
|
6047
|
+
var observer = that.mutationObserver(parent, {
|
|
6037
6048
|
config: {
|
|
6038
6049
|
subtree: true,
|
|
6039
6050
|
childList: true,
|
|
@@ -6043,16 +6054,21 @@ class Utils {
|
|
|
6043
6054
|
let node = getNode();
|
|
6044
6055
|
if (node) {
|
|
6045
6056
|
// 取消观察器
|
|
6046
|
-
observer
|
|
6057
|
+
if (typeof observer?.disconnect === "function") {
|
|
6058
|
+
observer.disconnect();
|
|
6059
|
+
}
|
|
6047
6060
|
resolve(node);
|
|
6048
6061
|
return;
|
|
6049
6062
|
}
|
|
6050
6063
|
},
|
|
6064
|
+
immediate: true,
|
|
6051
6065
|
});
|
|
6052
6066
|
if (timeout > 0) {
|
|
6053
6067
|
setTimeout(() => {
|
|
6054
6068
|
// 取消观察器
|
|
6055
|
-
observer
|
|
6069
|
+
if (typeof observer?.disconnect === "function") {
|
|
6070
|
+
observer.disconnect();
|
|
6071
|
+
}
|
|
6056
6072
|
resolve(null);
|
|
6057
6073
|
}, timeout);
|
|
6058
6074
|
}
|
|
@@ -6186,12 +6202,7 @@ class Utils {
|
|
|
6186
6202
|
}
|
|
6187
6203
|
}
|
|
6188
6204
|
}
|
|
6189
|
-
|
|
6190
|
-
if (nodeList) {
|
|
6191
|
-
resolve(nodeList);
|
|
6192
|
-
return;
|
|
6193
|
-
}
|
|
6194
|
-
let observer = that.mutationObserver(parent, {
|
|
6205
|
+
var observer = that.mutationObserver(parent, {
|
|
6195
6206
|
config: {
|
|
6196
6207
|
subtree: true,
|
|
6197
6208
|
childList: true,
|
|
@@ -6201,16 +6212,22 @@ class Utils {
|
|
|
6201
6212
|
let node = getNodeList();
|
|
6202
6213
|
if (node) {
|
|
6203
6214
|
// 取消观察器
|
|
6204
|
-
|
|
6215
|
+
try {
|
|
6216
|
+
observer.disconnect();
|
|
6217
|
+
}
|
|
6218
|
+
catch (error) { }
|
|
6205
6219
|
resolve(node);
|
|
6206
6220
|
return;
|
|
6207
6221
|
}
|
|
6208
6222
|
},
|
|
6223
|
+
immediate: true,
|
|
6209
6224
|
});
|
|
6210
6225
|
if (timeout > 0) {
|
|
6211
6226
|
setTimeout(() => {
|
|
6212
6227
|
// 取消观察器
|
|
6213
|
-
observer
|
|
6228
|
+
if (typeof observer?.disconnect === "function") {
|
|
6229
|
+
observer.disconnect();
|
|
6230
|
+
}
|
|
6214
6231
|
resolve(null);
|
|
6215
6232
|
}, timeout);
|
|
6216
6233
|
}
|