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