@whitesev/utils 1.1.0 → 1.1.2
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 +38 -41
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +38 -41
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +38 -41
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +38 -41
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +38 -41
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +38 -41
- package/dist/index.umd.js.map +1 -1
- package/dist/src/LockFunction.d.ts +4 -16
- package/package.json +1 -1
- package/src/LockFunction.ts +36 -31
- package/src/Utils.ts +11 -19
package/dist/index.system.js
CHANGED
|
@@ -2476,7 +2476,12 @@ System.register('Utils', [], (function (exports) {
|
|
|
2476
2476
|
#delayTime = 0;
|
|
2477
2477
|
#callback;
|
|
2478
2478
|
#context;
|
|
2479
|
+
lock;
|
|
2480
|
+
unlock;
|
|
2481
|
+
run;
|
|
2482
|
+
isLock;
|
|
2479
2483
|
constructor(callback, context, delayTime) {
|
|
2484
|
+
let that = this;
|
|
2480
2485
|
this.#callback = callback;
|
|
2481
2486
|
if (typeof context === "number") {
|
|
2482
2487
|
this.#delayTime = context;
|
|
@@ -2486,37 +2491,37 @@ System.register('Utils', [], (function (exports) {
|
|
|
2486
2491
|
this.#delayTime = delayTime;
|
|
2487
2492
|
this.#context = context;
|
|
2488
2493
|
}
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
}
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2494
|
+
/**
|
|
2495
|
+
* 锁
|
|
2496
|
+
*/
|
|
2497
|
+
this.lock = function () {
|
|
2498
|
+
that.#flag = true;
|
|
2499
|
+
};
|
|
2500
|
+
/**
|
|
2501
|
+
* 解锁
|
|
2502
|
+
*/
|
|
2503
|
+
this.unlock = function () {
|
|
2504
|
+
setTimeout(() => {
|
|
2505
|
+
that.#flag = false;
|
|
2506
|
+
}, that.#delayTime);
|
|
2507
|
+
};
|
|
2508
|
+
/**
|
|
2509
|
+
* 判断是否被锁
|
|
2510
|
+
*/
|
|
2511
|
+
this.isLock = function () {
|
|
2512
|
+
return that.#flag;
|
|
2513
|
+
};
|
|
2514
|
+
/**
|
|
2515
|
+
* 执行
|
|
2516
|
+
*/
|
|
2517
|
+
this.run = async function (...args) {
|
|
2518
|
+
if (that.isLock()) {
|
|
2519
|
+
return;
|
|
2520
|
+
}
|
|
2521
|
+
that.lock();
|
|
2522
|
+
await that.#callback.apply(that.#context, args);
|
|
2523
|
+
that.unlock();
|
|
2524
|
+
};
|
|
2520
2525
|
}
|
|
2521
2526
|
}
|
|
2522
2527
|
|
|
@@ -4649,42 +4654,35 @@ System.register('Utils', [], (function (exports) {
|
|
|
4649
4654
|
callback: () => { },
|
|
4650
4655
|
config: {
|
|
4651
4656
|
/**
|
|
4652
|
-
* @type {boolean|undefined}
|
|
4653
4657
|
* + true 监听以 target 为根节点的整个子树。包括子树中所有节点的属性,而不仅仅是针对 target
|
|
4654
4658
|
* + false (默认) 不生效
|
|
4655
4659
|
*/
|
|
4656
4660
|
subtree: void 0,
|
|
4657
4661
|
/**
|
|
4658
|
-
* @type {boolean|undefined}
|
|
4659
4662
|
* + true 监听 target 节点中发生的节点的新增与删除(同时,如果 subtree 为 true,会针对整个子树生效)
|
|
4660
4663
|
* + false (默认) 不生效
|
|
4661
4664
|
*/
|
|
4662
4665
|
childList: void 0,
|
|
4663
4666
|
/**
|
|
4664
|
-
* @type {boolean|undefined}
|
|
4665
4667
|
* + true 观察所有监听的节点属性值的变化。默认值为 true,当声明了 attributeFilter 或 attributeOldValue
|
|
4666
4668
|
* + false (默认) 不生效
|
|
4667
4669
|
*/
|
|
4668
4670
|
attributes: void 0,
|
|
4669
4671
|
/**
|
|
4670
4672
|
* 一个用于声明哪些属性名会被监听的数组。如果不声明该属性,所有属性的变化都将触发通知
|
|
4671
|
-
* @type {[...string]|undefined}
|
|
4672
4673
|
*/
|
|
4673
4674
|
attributeFilter: void 0,
|
|
4674
4675
|
/**
|
|
4675
|
-
* @type {boolean|undefined}
|
|
4676
4676
|
* + true 记录上一次被监听的节点的属性变化;可查阅 MutationObserver 中的 Monitoring attribute values 了解关于观察属性变化和属性值记录的详情
|
|
4677
4677
|
* + false (默认) 不生效
|
|
4678
4678
|
*/
|
|
4679
4679
|
attributeOldValue: void 0,
|
|
4680
4680
|
/**
|
|
4681
|
-
* @type {boolean|undefined}
|
|
4682
4681
|
* + true 监听声明的 target 节点上所有字符的变化。默认值为 true,如果声明了 characterDataOldValue
|
|
4683
4682
|
* + false (默认) 不生效
|
|
4684
4683
|
*/
|
|
4685
4684
|
characterData: void 0,
|
|
4686
4685
|
/**
|
|
4687
|
-
* @type {boolean|undefined}
|
|
4688
4686
|
* + true 记录前一个被监听的节点中发生的文本变化
|
|
4689
4687
|
* + false (默认) 不生效
|
|
4690
4688
|
*/
|
|
@@ -4692,11 +4690,10 @@ System.register('Utils', [], (function (exports) {
|
|
|
4692
4690
|
},
|
|
4693
4691
|
};
|
|
4694
4692
|
observer_config = UtilsContext.assign(default_obverser_config, observer_config);
|
|
4695
|
-
let
|
|
4693
|
+
let windowMutationObserver = window.MutationObserver ||
|
|
4696
4694
|
UtilsCore.window.webkitMutationObserver ||
|
|
4697
4695
|
UtilsCore.window.MozMutationObserver;
|
|
4698
|
-
|
|
4699
|
-
let mutationObserver = new MutationObserver(function (mutations, observer) {
|
|
4696
|
+
let mutationObserver = new windowMutationObserver(function (mutations, observer) {
|
|
4700
4697
|
observer_config?.callback(mutations, observer);
|
|
4701
4698
|
});
|
|
4702
4699
|
if (target instanceof Node) {
|