@whitesev/utils 1.9.6 → 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 +43 -33
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +43 -33
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +43 -33
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +43 -33
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +43 -33
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +43 -33
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -211,6 +211,7 @@
|
|
|
211
211
|
decode(str) {
|
|
212
212
|
var GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
|
|
213
213
|
var UTFMatcher = /%[0-9A-F]{2}/;
|
|
214
|
+
// @ts-ignore
|
|
214
215
|
var utf = true;
|
|
215
216
|
let that = this;
|
|
216
217
|
while (utf) {
|
|
@@ -1171,6 +1172,7 @@
|
|
|
1171
1172
|
let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
|
|
1172
1173
|
/** 油猴菜单上显示的文本 */
|
|
1173
1174
|
let showText = menuOption.showText(menuOption.text, defaultEnable);
|
|
1175
|
+
// @ts-ignore
|
|
1174
1176
|
({
|
|
1175
1177
|
/**
|
|
1176
1178
|
* 菜单的id
|
|
@@ -2543,6 +2545,7 @@
|
|
|
2543
2545
|
#storeName;
|
|
2544
2546
|
#dbVersion;
|
|
2545
2547
|
/* websql的版本号,由于ios的问题,版本号的写法不一样 */
|
|
2548
|
+
// @ts-ignore
|
|
2546
2549
|
#slqVersion = "1";
|
|
2547
2550
|
/* 监听IndexDB */
|
|
2548
2551
|
#indexedDB = UtilsCore.window.indexedDB ||
|
|
@@ -2551,6 +2554,7 @@
|
|
|
2551
2554
|
UtilsCore.window.msIndexedDB;
|
|
2552
2555
|
/* 缓存数据库,避免同一个页面重复创建和销毁 */
|
|
2553
2556
|
#db = {};
|
|
2557
|
+
// @ts-ignore
|
|
2554
2558
|
#store = null;
|
|
2555
2559
|
#errorCode = {
|
|
2556
2560
|
/* 错误码 */
|
|
@@ -2665,6 +2669,7 @@
|
|
|
2665
2669
|
let request = idbStore.put(inData);
|
|
2666
2670
|
request.onsuccess = function (event) {
|
|
2667
2671
|
/* 保存成功有success 字段 */
|
|
2672
|
+
// @ts-ignore
|
|
2668
2673
|
event.target;
|
|
2669
2674
|
resolve({
|
|
2670
2675
|
success: true,
|
|
@@ -2674,6 +2679,7 @@
|
|
|
2674
2679
|
});
|
|
2675
2680
|
};
|
|
2676
2681
|
request.onerror = function (event) {
|
|
2682
|
+
// @ts-ignore
|
|
2677
2683
|
event.target;
|
|
2678
2684
|
resolve({
|
|
2679
2685
|
success: false,
|
|
@@ -2735,6 +2741,7 @@
|
|
|
2735
2741
|
}
|
|
2736
2742
|
};
|
|
2737
2743
|
request.onerror = function (event) {
|
|
2744
|
+
// @ts-ignore
|
|
2738
2745
|
event.target;
|
|
2739
2746
|
resolve({
|
|
2740
2747
|
success: false,
|
|
@@ -2792,6 +2799,7 @@
|
|
|
2792
2799
|
});
|
|
2793
2800
|
};
|
|
2794
2801
|
request.onerror = function (event) {
|
|
2802
|
+
// @ts-ignore
|
|
2795
2803
|
event.target;
|
|
2796
2804
|
resolve({
|
|
2797
2805
|
success: false,
|
|
@@ -2846,6 +2854,7 @@
|
|
|
2846
2854
|
}
|
|
2847
2855
|
};
|
|
2848
2856
|
request.onerror = function (event) {
|
|
2857
|
+
// @ts-ignore
|
|
2849
2858
|
event.target;
|
|
2850
2859
|
resolve({
|
|
2851
2860
|
success: false,
|
|
@@ -3821,7 +3830,9 @@
|
|
|
3821
3830
|
/* CODE FOR BROWSERS THAT SUPPORT window.find */
|
|
3822
3831
|
let windowFind = UtilsCore.self.find;
|
|
3823
3832
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
3824
|
-
if (strFound &&
|
|
3833
|
+
if (strFound &&
|
|
3834
|
+
UtilsCore.self.getSelection &&
|
|
3835
|
+
!UtilsCore.self.getSelection().anchorNode) {
|
|
3825
3836
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
3826
3837
|
}
|
|
3827
3838
|
if (!strFound) {
|
|
@@ -4893,7 +4904,8 @@
|
|
|
4893
4904
|
return result;
|
|
4894
4905
|
}
|
|
4895
4906
|
isThemeDark() {
|
|
4896
|
-
return UtilsCore.globalThis.matchMedia("(prefers-color-scheme: dark)")
|
|
4907
|
+
return UtilsCore.globalThis.matchMedia("(prefers-color-scheme: dark)")
|
|
4908
|
+
.matches;
|
|
4897
4909
|
}
|
|
4898
4910
|
isVisible(element, inView = false) {
|
|
4899
4911
|
let needCheckDomList = [];
|
|
@@ -5092,11 +5104,6 @@
|
|
|
5092
5104
|
}
|
|
5093
5105
|
mutationObserver(target, observer_config) {
|
|
5094
5106
|
let UtilsContext = this;
|
|
5095
|
-
if (!(target instanceof Node) &&
|
|
5096
|
-
!(target instanceof NodeList) &&
|
|
5097
|
-
!UtilsContext.isJQuery(target)) {
|
|
5098
|
-
throw new Error("Utils.mutationObserver 参数 target 必须为 Node|NodeList|jQuery类型");
|
|
5099
|
-
}
|
|
5100
5107
|
let default_obverser_config = {
|
|
5101
5108
|
/* 监听到元素有反馈,需执行的函数 */
|
|
5102
5109
|
callback: () => { },
|
|
@@ -5142,15 +5149,14 @@
|
|
|
5142
5149
|
let windowMutationObserver = UtilsCore.window.MutationObserver ||
|
|
5143
5150
|
UtilsCore.window.webkitMutationObserver ||
|
|
5144
5151
|
UtilsCore.window.MozMutationObserver;
|
|
5152
|
+
// 观察者对象
|
|
5145
5153
|
let mutationObserver = new windowMutationObserver(function (mutations, observer) {
|
|
5146
|
-
observer_config
|
|
5154
|
+
if (typeof observer_config.callback === "function") {
|
|
5155
|
+
observer_config.callback(mutations, observer);
|
|
5156
|
+
}
|
|
5147
5157
|
});
|
|
5148
|
-
if (target instanceof
|
|
5149
|
-
|
|
5150
|
-
mutationObserver.observe(target, observer_config.config);
|
|
5151
|
-
}
|
|
5152
|
-
else if (target instanceof NodeList) {
|
|
5153
|
-
/* 传入的参数是节点元素数组 */
|
|
5158
|
+
if (Array.isArray(target) || target instanceof NodeList) {
|
|
5159
|
+
// 传入的是数组或者元素数组
|
|
5154
5160
|
target.forEach((item) => {
|
|
5155
5161
|
mutationObserver.observe(item, observer_config.config);
|
|
5156
5162
|
});
|
|
@@ -5162,12 +5168,13 @@
|
|
|
5162
5168
|
});
|
|
5163
5169
|
}
|
|
5164
5170
|
else {
|
|
5165
|
-
|
|
5166
|
-
console.error("Utils.mutationObserver 未知参数", arguments);
|
|
5171
|
+
mutationObserver.observe(target, observer_config.config);
|
|
5167
5172
|
}
|
|
5168
5173
|
if (observer_config.immediate) {
|
|
5169
5174
|
/* 主动触发一次 */
|
|
5170
|
-
observer_config.callback
|
|
5175
|
+
if (typeof observer_config.callback === "function") {
|
|
5176
|
+
observer_config.callback([], mutationObserver);
|
|
5177
|
+
}
|
|
5171
5178
|
}
|
|
5172
5179
|
return mutationObserver;
|
|
5173
5180
|
}
|
|
@@ -5415,6 +5422,7 @@
|
|
|
5415
5422
|
EventTarget.prototype.addEventListener = function (...args) {
|
|
5416
5423
|
let type = args[0];
|
|
5417
5424
|
let callback = args[1];
|
|
5425
|
+
// @ts-ignore
|
|
5418
5426
|
args[2];
|
|
5419
5427
|
if (filter(type)) {
|
|
5420
5428
|
if (typeof callback === "function") {
|
|
@@ -5508,6 +5516,7 @@
|
|
|
5508
5516
|
}
|
|
5509
5517
|
async init() {
|
|
5510
5518
|
let copyStatus = false;
|
|
5519
|
+
// @ts-ignore
|
|
5511
5520
|
await this.requestClipboardPermission();
|
|
5512
5521
|
if (this.hasClipboard() &&
|
|
5513
5522
|
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
@@ -6041,12 +6050,7 @@
|
|
|
6041
6050
|
return parent.querySelector(selector);
|
|
6042
6051
|
}
|
|
6043
6052
|
}
|
|
6044
|
-
|
|
6045
|
-
if (node) {
|
|
6046
|
-
resolve(node);
|
|
6047
|
-
return;
|
|
6048
|
-
}
|
|
6049
|
-
let observer = that.mutationObserver(parent, {
|
|
6053
|
+
var observer = that.mutationObserver(parent, {
|
|
6050
6054
|
config: {
|
|
6051
6055
|
subtree: true,
|
|
6052
6056
|
childList: true,
|
|
@@ -6056,16 +6060,21 @@
|
|
|
6056
6060
|
let node = getNode();
|
|
6057
6061
|
if (node) {
|
|
6058
6062
|
// 取消观察器
|
|
6059
|
-
observer
|
|
6063
|
+
if (typeof observer?.disconnect === "function") {
|
|
6064
|
+
observer.disconnect();
|
|
6065
|
+
}
|
|
6060
6066
|
resolve(node);
|
|
6061
6067
|
return;
|
|
6062
6068
|
}
|
|
6063
6069
|
},
|
|
6070
|
+
immediate: true,
|
|
6064
6071
|
});
|
|
6065
6072
|
if (timeout > 0) {
|
|
6066
6073
|
setTimeout(() => {
|
|
6067
6074
|
// 取消观察器
|
|
6068
|
-
observer
|
|
6075
|
+
if (typeof observer?.disconnect === "function") {
|
|
6076
|
+
observer.disconnect();
|
|
6077
|
+
}
|
|
6069
6078
|
resolve(null);
|
|
6070
6079
|
}, timeout);
|
|
6071
6080
|
}
|
|
@@ -6199,12 +6208,7 @@
|
|
|
6199
6208
|
}
|
|
6200
6209
|
}
|
|
6201
6210
|
}
|
|
6202
|
-
|
|
6203
|
-
if (nodeList) {
|
|
6204
|
-
resolve(nodeList);
|
|
6205
|
-
return;
|
|
6206
|
-
}
|
|
6207
|
-
let observer = that.mutationObserver(parent, {
|
|
6211
|
+
var observer = that.mutationObserver(parent, {
|
|
6208
6212
|
config: {
|
|
6209
6213
|
subtree: true,
|
|
6210
6214
|
childList: true,
|
|
@@ -6214,16 +6218,22 @@
|
|
|
6214
6218
|
let node = getNodeList();
|
|
6215
6219
|
if (node) {
|
|
6216
6220
|
// 取消观察器
|
|
6217
|
-
|
|
6221
|
+
try {
|
|
6222
|
+
observer.disconnect();
|
|
6223
|
+
}
|
|
6224
|
+
catch (error) { }
|
|
6218
6225
|
resolve(node);
|
|
6219
6226
|
return;
|
|
6220
6227
|
}
|
|
6221
6228
|
},
|
|
6229
|
+
immediate: true,
|
|
6222
6230
|
});
|
|
6223
6231
|
if (timeout > 0) {
|
|
6224
6232
|
setTimeout(() => {
|
|
6225
6233
|
// 取消观察器
|
|
6226
|
-
observer
|
|
6234
|
+
if (typeof observer?.disconnect === "function") {
|
|
6235
|
+
observer.disconnect();
|
|
6236
|
+
}
|
|
6227
6237
|
resolve(null);
|
|
6228
6238
|
}, timeout);
|
|
6229
6239
|
}
|