@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.iife.js
CHANGED
|
@@ -208,6 +208,7 @@ var Utils = (function () {
|
|
|
208
208
|
decode(str) {
|
|
209
209
|
var GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
|
|
210
210
|
var UTFMatcher = /%[0-9A-F]{2}/;
|
|
211
|
+
// @ts-ignore
|
|
211
212
|
var utf = true;
|
|
212
213
|
let that = this;
|
|
213
214
|
while (utf) {
|
|
@@ -1168,6 +1169,7 @@ var Utils = (function () {
|
|
|
1168
1169
|
let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
|
|
1169
1170
|
/** 油猴菜单上显示的文本 */
|
|
1170
1171
|
let showText = menuOption.showText(menuOption.text, defaultEnable);
|
|
1172
|
+
// @ts-ignore
|
|
1171
1173
|
({
|
|
1172
1174
|
/**
|
|
1173
1175
|
* 菜单的id
|
|
@@ -2540,6 +2542,7 @@ var Utils = (function () {
|
|
|
2540
2542
|
#storeName;
|
|
2541
2543
|
#dbVersion;
|
|
2542
2544
|
/* websql的版本号,由于ios的问题,版本号的写法不一样 */
|
|
2545
|
+
// @ts-ignore
|
|
2543
2546
|
#slqVersion = "1";
|
|
2544
2547
|
/* 监听IndexDB */
|
|
2545
2548
|
#indexedDB = UtilsCore.window.indexedDB ||
|
|
@@ -2548,6 +2551,7 @@ var Utils = (function () {
|
|
|
2548
2551
|
UtilsCore.window.msIndexedDB;
|
|
2549
2552
|
/* 缓存数据库,避免同一个页面重复创建和销毁 */
|
|
2550
2553
|
#db = {};
|
|
2554
|
+
// @ts-ignore
|
|
2551
2555
|
#store = null;
|
|
2552
2556
|
#errorCode = {
|
|
2553
2557
|
/* 错误码 */
|
|
@@ -2662,6 +2666,7 @@ var Utils = (function () {
|
|
|
2662
2666
|
let request = idbStore.put(inData);
|
|
2663
2667
|
request.onsuccess = function (event) {
|
|
2664
2668
|
/* 保存成功有success 字段 */
|
|
2669
|
+
// @ts-ignore
|
|
2665
2670
|
event.target;
|
|
2666
2671
|
resolve({
|
|
2667
2672
|
success: true,
|
|
@@ -2671,6 +2676,7 @@ var Utils = (function () {
|
|
|
2671
2676
|
});
|
|
2672
2677
|
};
|
|
2673
2678
|
request.onerror = function (event) {
|
|
2679
|
+
// @ts-ignore
|
|
2674
2680
|
event.target;
|
|
2675
2681
|
resolve({
|
|
2676
2682
|
success: false,
|
|
@@ -2732,6 +2738,7 @@ var Utils = (function () {
|
|
|
2732
2738
|
}
|
|
2733
2739
|
};
|
|
2734
2740
|
request.onerror = function (event) {
|
|
2741
|
+
// @ts-ignore
|
|
2735
2742
|
event.target;
|
|
2736
2743
|
resolve({
|
|
2737
2744
|
success: false,
|
|
@@ -2789,6 +2796,7 @@ var Utils = (function () {
|
|
|
2789
2796
|
});
|
|
2790
2797
|
};
|
|
2791
2798
|
request.onerror = function (event) {
|
|
2799
|
+
// @ts-ignore
|
|
2792
2800
|
event.target;
|
|
2793
2801
|
resolve({
|
|
2794
2802
|
success: false,
|
|
@@ -2843,6 +2851,7 @@ var Utils = (function () {
|
|
|
2843
2851
|
}
|
|
2844
2852
|
};
|
|
2845
2853
|
request.onerror = function (event) {
|
|
2854
|
+
// @ts-ignore
|
|
2846
2855
|
event.target;
|
|
2847
2856
|
resolve({
|
|
2848
2857
|
success: false,
|
|
@@ -5137,8 +5146,11 @@ var Utils = (function () {
|
|
|
5137
5146
|
let windowMutationObserver = UtilsCore.window.MutationObserver ||
|
|
5138
5147
|
UtilsCore.window.webkitMutationObserver ||
|
|
5139
5148
|
UtilsCore.window.MozMutationObserver;
|
|
5149
|
+
// 观察者对象
|
|
5140
5150
|
let mutationObserver = new windowMutationObserver(function (mutations, observer) {
|
|
5141
|
-
observer_config
|
|
5151
|
+
if (typeof observer_config.callback === "function") {
|
|
5152
|
+
observer_config.callback(mutations, observer);
|
|
5153
|
+
}
|
|
5142
5154
|
});
|
|
5143
5155
|
if (Array.isArray(target) || target instanceof NodeList) {
|
|
5144
5156
|
// 传入的是数组或者元素数组
|
|
@@ -5157,7 +5169,9 @@ var Utils = (function () {
|
|
|
5157
5169
|
}
|
|
5158
5170
|
if (observer_config.immediate) {
|
|
5159
5171
|
/* 主动触发一次 */
|
|
5160
|
-
observer_config.callback
|
|
5172
|
+
if (typeof observer_config.callback === "function") {
|
|
5173
|
+
observer_config.callback([], mutationObserver);
|
|
5174
|
+
}
|
|
5161
5175
|
}
|
|
5162
5176
|
return mutationObserver;
|
|
5163
5177
|
}
|
|
@@ -5405,6 +5419,7 @@ var Utils = (function () {
|
|
|
5405
5419
|
EventTarget.prototype.addEventListener = function (...args) {
|
|
5406
5420
|
let type = args[0];
|
|
5407
5421
|
let callback = args[1];
|
|
5422
|
+
// @ts-ignore
|
|
5408
5423
|
args[2];
|
|
5409
5424
|
if (filter(type)) {
|
|
5410
5425
|
if (typeof callback === "function") {
|
|
@@ -5498,6 +5513,7 @@ var Utils = (function () {
|
|
|
5498
5513
|
}
|
|
5499
5514
|
async init() {
|
|
5500
5515
|
let copyStatus = false;
|
|
5516
|
+
// @ts-ignore
|
|
5501
5517
|
await this.requestClipboardPermission();
|
|
5502
5518
|
if (this.hasClipboard() &&
|
|
5503
5519
|
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
@@ -6031,12 +6047,7 @@ var Utils = (function () {
|
|
|
6031
6047
|
return parent.querySelector(selector);
|
|
6032
6048
|
}
|
|
6033
6049
|
}
|
|
6034
|
-
|
|
6035
|
-
if (node) {
|
|
6036
|
-
resolve(node);
|
|
6037
|
-
return;
|
|
6038
|
-
}
|
|
6039
|
-
let observer = that.mutationObserver(parent, {
|
|
6050
|
+
var observer = that.mutationObserver(parent, {
|
|
6040
6051
|
config: {
|
|
6041
6052
|
subtree: true,
|
|
6042
6053
|
childList: true,
|
|
@@ -6046,16 +6057,21 @@ var Utils = (function () {
|
|
|
6046
6057
|
let node = getNode();
|
|
6047
6058
|
if (node) {
|
|
6048
6059
|
// 取消观察器
|
|
6049
|
-
observer
|
|
6060
|
+
if (typeof observer?.disconnect === "function") {
|
|
6061
|
+
observer.disconnect();
|
|
6062
|
+
}
|
|
6050
6063
|
resolve(node);
|
|
6051
6064
|
return;
|
|
6052
6065
|
}
|
|
6053
6066
|
},
|
|
6067
|
+
immediate: true,
|
|
6054
6068
|
});
|
|
6055
6069
|
if (timeout > 0) {
|
|
6056
6070
|
setTimeout(() => {
|
|
6057
6071
|
// 取消观察器
|
|
6058
|
-
observer
|
|
6072
|
+
if (typeof observer?.disconnect === "function") {
|
|
6073
|
+
observer.disconnect();
|
|
6074
|
+
}
|
|
6059
6075
|
resolve(null);
|
|
6060
6076
|
}, timeout);
|
|
6061
6077
|
}
|
|
@@ -6189,12 +6205,7 @@ var Utils = (function () {
|
|
|
6189
6205
|
}
|
|
6190
6206
|
}
|
|
6191
6207
|
}
|
|
6192
|
-
|
|
6193
|
-
if (nodeList) {
|
|
6194
|
-
resolve(nodeList);
|
|
6195
|
-
return;
|
|
6196
|
-
}
|
|
6197
|
-
let observer = that.mutationObserver(parent, {
|
|
6208
|
+
var observer = that.mutationObserver(parent, {
|
|
6198
6209
|
config: {
|
|
6199
6210
|
subtree: true,
|
|
6200
6211
|
childList: true,
|
|
@@ -6204,16 +6215,22 @@ var Utils = (function () {
|
|
|
6204
6215
|
let node = getNodeList();
|
|
6205
6216
|
if (node) {
|
|
6206
6217
|
// 取消观察器
|
|
6207
|
-
|
|
6218
|
+
try {
|
|
6219
|
+
observer.disconnect();
|
|
6220
|
+
}
|
|
6221
|
+
catch (error) { }
|
|
6208
6222
|
resolve(node);
|
|
6209
6223
|
return;
|
|
6210
6224
|
}
|
|
6211
6225
|
},
|
|
6226
|
+
immediate: true,
|
|
6212
6227
|
});
|
|
6213
6228
|
if (timeout > 0) {
|
|
6214
6229
|
setTimeout(() => {
|
|
6215
6230
|
// 取消观察器
|
|
6216
|
-
observer
|
|
6231
|
+
if (typeof observer?.disconnect === "function") {
|
|
6232
|
+
observer.disconnect();
|
|
6233
|
+
}
|
|
6217
6234
|
resolve(null);
|
|
6218
6235
|
}, timeout);
|
|
6219
6236
|
}
|