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