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