@but212/atom-effect-jquery 0.8.2 → 0.8.3
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/README.md +2 -7
- package/dist/atom-effect-jquery.min.js +1 -1
- package/dist/atom-effect-jquery.min.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +176 -177
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import u from "jquery";
|
|
2
|
-
import { default as
|
|
3
|
-
const
|
|
2
|
+
import { default as Tt } from "jquery";
|
|
3
|
+
const Ve = {
|
|
4
4
|
/** One second in milliseconds */
|
|
5
5
|
ONE_SECOND_MS: 1e3
|
|
6
6
|
}, oe = {
|
|
@@ -50,7 +50,7 @@ const Be = {
|
|
|
50
50
|
MAX_DEPENDENCIES: 1e3,
|
|
51
51
|
/** Enable infinite loop detection warnings */
|
|
52
52
|
WARN_INFINITE_LOOP: !0
|
|
53
|
-
}, B = 1073741823, R = typeof process < "u" && process.env && process.env.NODE_ENV !== "production",
|
|
53
|
+
}, B = 1073741823, R = typeof process < "u" && process.env && process.env.NODE_ENV !== "production", je = Object.freeze([]);
|
|
54
54
|
class k extends Error {
|
|
55
55
|
/**
|
|
56
56
|
* Creates a new AtomError
|
|
@@ -176,8 +176,8 @@ const m = {
|
|
|
176
176
|
* @remarks This prevents cascading failures from masking the original error.
|
|
177
177
|
*/
|
|
178
178
|
CALLBACK_ERROR_IN_ERROR_HANDLER: "Error occurred during onError callback execution"
|
|
179
|
-
}, he = /* @__PURE__ */ Symbol("debugName"),
|
|
180
|
-
function
|
|
179
|
+
}, he = /* @__PURE__ */ Symbol("debugName"), Be = /* @__PURE__ */ Symbol("id"), ae = /* @__PURE__ */ Symbol("type"), ge = /* @__PURE__ */ Symbol("noDefaultValue");
|
|
180
|
+
function qe(t) {
|
|
181
181
|
return "dependencies" in t && Array.isArray(t.dependencies);
|
|
182
182
|
}
|
|
183
183
|
let me = 0;
|
|
@@ -185,7 +185,7 @@ function Ce(t, e, s) {
|
|
|
185
185
|
if (t._visitedEpoch !== s) {
|
|
186
186
|
if (t._visitedEpoch = s, t === e)
|
|
187
187
|
throw new X("Indirect circular dependency detected");
|
|
188
|
-
if (
|
|
188
|
+
if (qe(t)) {
|
|
189
189
|
const n = t.dependencies;
|
|
190
190
|
for (let i = 0; i < n.length; i++) {
|
|
191
191
|
const r = n[i];
|
|
@@ -215,7 +215,7 @@ const w = {
|
|
|
215
215
|
if (!this.enabled)
|
|
216
216
|
return;
|
|
217
217
|
const n = t;
|
|
218
|
-
n[he] = `${e}_${s}`, n[
|
|
218
|
+
n[he] = `${e}_${s}`, n[Be] = s, n[ae] = e;
|
|
219
219
|
},
|
|
220
220
|
getDebugName(t) {
|
|
221
221
|
if (t != null && he in t)
|
|
@@ -226,11 +226,11 @@ const w = {
|
|
|
226
226
|
return t[ae];
|
|
227
227
|
}
|
|
228
228
|
};
|
|
229
|
-
let
|
|
230
|
-
const
|
|
229
|
+
let ze = 1;
|
|
230
|
+
const Xe = () => ze++;
|
|
231
231
|
class ve {
|
|
232
232
|
constructor() {
|
|
233
|
-
this.id =
|
|
233
|
+
this.id = Xe() & B, this.flags = 0;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
class Ne extends ve {
|
|
@@ -277,7 +277,7 @@ let te = 0;
|
|
|
277
277
|
function Te() {
|
|
278
278
|
return te = (te + 1 | 0) & B, te;
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function Ge() {
|
|
281
281
|
return te;
|
|
282
282
|
}
|
|
283
283
|
let ne = 0, fe = 0, ie = !1;
|
|
@@ -289,10 +289,10 @@ function Se() {
|
|
|
289
289
|
function ye() {
|
|
290
290
|
ie = !1;
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function Qe() {
|
|
293
293
|
return ie ? ++fe : 0;
|
|
294
294
|
}
|
|
295
|
-
class
|
|
295
|
+
class He {
|
|
296
296
|
constructor() {
|
|
297
297
|
this.queueA = [], this.queueB = [], this.queue = this.queueA, this.queueSize = 0, this._epoch = 0, this.isProcessing = !1, this.isBatching = !1, this.batchDepth = 0, this.batchQueue = [], this.batchQueueSize = 0, this.isFlushingSync = !1, this.maxFlushIterations = V.MAX_FLUSH_ITERATIONS;
|
|
298
298
|
}
|
|
@@ -392,7 +392,7 @@ class Ye {
|
|
|
392
392
|
this.maxFlushIterations = e;
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
const Y = new
|
|
395
|
+
const Y = new He();
|
|
396
396
|
function z(t) {
|
|
397
397
|
if (typeof t != "function")
|
|
398
398
|
throw new k("Batch callback must be a function");
|
|
@@ -485,6 +485,59 @@ class re {
|
|
|
485
485
|
return this.subscribers ? [...this.subscribers] : [];
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
+
class de {
|
|
489
|
+
constructor() {
|
|
490
|
+
this.pool = [], this.maxPoolSize = 50, this.maxReusableCapacity = 256, this.stats = R ? {
|
|
491
|
+
acquired: 0,
|
|
492
|
+
released: 0,
|
|
493
|
+
rejected: { frozen: 0, tooLarge: 0, poolFull: 0 }
|
|
494
|
+
} : null;
|
|
495
|
+
}
|
|
496
|
+
/** Acquires an array from the pool or creates a new one if the pool is empty. */
|
|
497
|
+
acquire() {
|
|
498
|
+
return R && this.stats && this.stats.acquired++, this.pool.pop() ?? [];
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Releases an array back to the pool.
|
|
502
|
+
* Clears the array before storing it.
|
|
503
|
+
* @param arr - The array to release.
|
|
504
|
+
* @param emptyConst - Optional reference to a constant empty array to skip.
|
|
505
|
+
*/
|
|
506
|
+
release(e, s) {
|
|
507
|
+
if (!(s && e === s)) {
|
|
508
|
+
if (Object.isFrozen(e)) {
|
|
509
|
+
R && this.stats && this.stats.rejected.frozen++;
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
if (e.length > this.maxReusableCapacity) {
|
|
513
|
+
R && this.stats && this.stats.rejected.tooLarge++;
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
if (this.pool.length >= this.maxPoolSize) {
|
|
517
|
+
R && this.stats && this.stats.rejected.poolFull++;
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
e.length = 0, this.pool.push(e), R && this.stats && this.stats.released++;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
/** Returns current stats for the pool (dev mode only). */
|
|
524
|
+
getStats() {
|
|
525
|
+
if (!R || !this.stats) return null;
|
|
526
|
+
const { acquired: e, released: s, rejected: n } = this.stats, i = n.frozen + n.tooLarge + n.poolFull;
|
|
527
|
+
return {
|
|
528
|
+
acquired: e,
|
|
529
|
+
released: s,
|
|
530
|
+
rejected: n,
|
|
531
|
+
leaked: e - s - i,
|
|
532
|
+
poolSize: this.pool.length
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
/** Resets the pool and its stats. */
|
|
536
|
+
reset() {
|
|
537
|
+
this.pool.length = 0, R && this.stats && (this.stats.acquired = 0, this.stats.released = 0, this.stats.rejected = { frozen: 0, tooLarge: 0, poolFull: 0 });
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
const y = Object.freeze([]), O = Object.freeze([]), D = Object.freeze([]), $ = new de(), j = new de(), A = new de();
|
|
488
541
|
function le(t) {
|
|
489
542
|
return t !== null && typeof t == "object" && "value" in t && "subscribe" in t && typeof t.subscribe == "function";
|
|
490
543
|
}
|
|
@@ -499,19 +552,51 @@ function De(t) {
|
|
|
499
552
|
function Ue(t) {
|
|
500
553
|
return t != null && typeof t.then == "function";
|
|
501
554
|
}
|
|
502
|
-
function
|
|
555
|
+
function Je(t) {
|
|
503
556
|
return typeof t == "object" && t !== null;
|
|
504
557
|
}
|
|
505
|
-
function
|
|
558
|
+
function Ye(t) {
|
|
506
559
|
return (typeof t == "object" || typeof t == "function") && t !== null && typeof t.addDependency == "function";
|
|
507
560
|
}
|
|
508
|
-
function
|
|
561
|
+
function Ke(t) {
|
|
509
562
|
return typeof t == "function" && typeof t.addDependency != "function";
|
|
510
563
|
}
|
|
511
|
-
function
|
|
512
|
-
return
|
|
564
|
+
function We(t) {
|
|
565
|
+
return Je(t) && typeof t.execute == "function";
|
|
566
|
+
}
|
|
567
|
+
function xe(t, e, s, n) {
|
|
568
|
+
if (e) {
|
|
569
|
+
if (Ye(e)) {
|
|
570
|
+
e.addDependency(t);
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
if (Ke(e)) {
|
|
574
|
+
s.add(e);
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
We(e) && n.add(e);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
function Ze(t, e, s, n) {
|
|
581
|
+
if (e !== y && s !== O)
|
|
582
|
+
for (let r = 0; r < e.length; r++) {
|
|
583
|
+
const o = e[r];
|
|
584
|
+
o && (o._tempUnsub = s[r]);
|
|
585
|
+
}
|
|
586
|
+
const i = j.acquire();
|
|
587
|
+
i.length = t.length;
|
|
588
|
+
for (let r = 0; r < t.length; r++) {
|
|
589
|
+
const o = t[r];
|
|
590
|
+
o && (o._tempUnsub ? (i[r] = o._tempUnsub, o._tempUnsub = void 0) : (w.checkCircular(o, n), i[r] = o.subscribe(n)));
|
|
591
|
+
}
|
|
592
|
+
if (e !== y)
|
|
593
|
+
for (let r = 0; r < e.length; r++) {
|
|
594
|
+
const o = e[r];
|
|
595
|
+
o?._tempUnsub && (o._tempUnsub(), o._tempUnsub = void 0);
|
|
596
|
+
}
|
|
597
|
+
return s !== O && j.release(s), i;
|
|
513
598
|
}
|
|
514
|
-
class
|
|
599
|
+
class et extends Ne {
|
|
515
600
|
constructor(e, s) {
|
|
516
601
|
super(), this._isNotificationScheduled = !1, this._value = e, this._functionSubscribersStore = new re(), this._objectSubscribersStore = new re(), this._sync = s, this._notifyTask = this._flushNotifications.bind(this), w.attachDebugInfo(this, "atom", this.id);
|
|
517
602
|
}
|
|
@@ -540,15 +625,7 @@ class We extends Ne {
|
|
|
540
625
|
this.version = this.version + 1 & B, this._value = e, !(!this._functionSubscribersStore.hasSubscribers && !this._objectSubscribersStore.hasSubscribers) && this._scheduleNotification(s);
|
|
541
626
|
}
|
|
542
627
|
_track(e) {
|
|
543
|
-
|
|
544
|
-
e.addDependency(this);
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
if (Oe(e)) {
|
|
548
|
-
this._functionSubscribersStore.add(e);
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
Ae(e) && this._objectSubscribersStore.add(e);
|
|
628
|
+
xe(this, e, this._functionSubscribersStore, this._objectSubscribersStore);
|
|
552
629
|
}
|
|
553
630
|
_scheduleNotification(e) {
|
|
554
631
|
this._isNotificationScheduled || (this._pendingOldValue = e, this._isNotificationScheduled = !0), this._sync && !Y.isBatching ? this._flushNotifications() : Y.schedule(this._notifyTask);
|
|
@@ -571,80 +648,8 @@ class We extends Ne {
|
|
|
571
648
|
this._functionSubscribersStore.clear(), this._objectSubscribersStore.clear(), this._value = void 0;
|
|
572
649
|
}
|
|
573
650
|
}
|
|
574
|
-
function
|
|
575
|
-
return new
|
|
576
|
-
}
|
|
577
|
-
class de {
|
|
578
|
-
constructor() {
|
|
579
|
-
this.pool = [], this.maxPoolSize = 50, this.maxReusableCapacity = 256, this.stats = R ? {
|
|
580
|
-
acquired: 0,
|
|
581
|
-
released: 0,
|
|
582
|
-
rejected: { frozen: 0, tooLarge: 0, poolFull: 0 }
|
|
583
|
-
} : null;
|
|
584
|
-
}
|
|
585
|
-
/** Acquires an array from the pool or creates a new one if the pool is empty. */
|
|
586
|
-
acquire() {
|
|
587
|
-
return R && this.stats && this.stats.acquired++, this.pool.pop() ?? [];
|
|
588
|
-
}
|
|
589
|
-
/**
|
|
590
|
-
* Releases an array back to the pool.
|
|
591
|
-
* Clears the array before storing it.
|
|
592
|
-
* @param arr - The array to release.
|
|
593
|
-
* @param emptyConst - Optional reference to a constant empty array to skip.
|
|
594
|
-
*/
|
|
595
|
-
release(e, s) {
|
|
596
|
-
if (!(s && e === s)) {
|
|
597
|
-
if (Object.isFrozen(e)) {
|
|
598
|
-
R && this.stats && this.stats.rejected.frozen++;
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
if (e.length > this.maxReusableCapacity) {
|
|
602
|
-
R && this.stats && this.stats.rejected.tooLarge++;
|
|
603
|
-
return;
|
|
604
|
-
}
|
|
605
|
-
if (this.pool.length >= this.maxPoolSize) {
|
|
606
|
-
R && this.stats && this.stats.rejected.poolFull++;
|
|
607
|
-
return;
|
|
608
|
-
}
|
|
609
|
-
e.length = 0, this.pool.push(e), R && this.stats && this.stats.released++;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
/** Returns current stats for the pool (dev mode only). */
|
|
613
|
-
getStats() {
|
|
614
|
-
if (!R || !this.stats) return null;
|
|
615
|
-
const { acquired: e, released: s, rejected: n } = this.stats, i = n.frozen + n.tooLarge + n.poolFull;
|
|
616
|
-
return {
|
|
617
|
-
acquired: e,
|
|
618
|
-
released: s,
|
|
619
|
-
rejected: n,
|
|
620
|
-
leaked: e - s - i,
|
|
621
|
-
poolSize: this.pool.length
|
|
622
|
-
};
|
|
623
|
-
}
|
|
624
|
-
/** Resets the pool and its stats. */
|
|
625
|
-
reset() {
|
|
626
|
-
this.pool.length = 0, R && this.stats && (this.stats.acquired = 0, this.stats.released = 0, this.stats.rejected = { frozen: 0, tooLarge: 0, poolFull: 0 });
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
const y = Object.freeze([]), O = Object.freeze([]), D = Object.freeze([]), $ = new de(), j = new de(), A = new de();
|
|
630
|
-
function et(t, e, s, n) {
|
|
631
|
-
if (e !== y && s !== O)
|
|
632
|
-
for (let r = 0; r < e.length; r++) {
|
|
633
|
-
const o = e[r];
|
|
634
|
-
o && (o._tempUnsub = s[r]);
|
|
635
|
-
}
|
|
636
|
-
const i = j.acquire();
|
|
637
|
-
i.length = t.length;
|
|
638
|
-
for (let r = 0; r < t.length; r++) {
|
|
639
|
-
const o = t[r];
|
|
640
|
-
o && (o._tempUnsub ? (i[r] = o._tempUnsub, o._tempUnsub = void 0) : (w.checkCircular(o, n), i[r] = o.subscribe(n)));
|
|
641
|
-
}
|
|
642
|
-
if (e !== y)
|
|
643
|
-
for (let r = 0; r < e.length; r++) {
|
|
644
|
-
const o = e[r];
|
|
645
|
-
o?._tempUnsub && (o._tempUnsub(), o._tempUnsub = void 0);
|
|
646
|
-
}
|
|
647
|
-
return s !== O && j.release(s), i;
|
|
651
|
+
function tt(t, e = {}) {
|
|
652
|
+
return new et(t, e.sync ?? !1);
|
|
648
653
|
}
|
|
649
654
|
function G(t, e, s) {
|
|
650
655
|
if (t instanceof TypeError)
|
|
@@ -656,11 +661,11 @@ function G(t, e, s) {
|
|
|
656
661
|
const n = t instanceof Error ? t.message : String(t), i = t instanceof Error ? t : null;
|
|
657
662
|
return new e(`Unexpected error (${s}): ${n}`, i);
|
|
658
663
|
}
|
|
659
|
-
const
|
|
664
|
+
const Oe = d.RESOLVED | d.PENDING | d.REJECTED, ce = Array(Oe + 1).fill(oe.IDLE);
|
|
660
665
|
ce[d.RESOLVED] = oe.RESOLVED;
|
|
661
666
|
ce[d.PENDING] = oe.PENDING;
|
|
662
667
|
ce[d.REJECTED] = oe.REJECTED;
|
|
663
|
-
class
|
|
668
|
+
class Ae extends Ne {
|
|
664
669
|
constructor(e, s = {}) {
|
|
665
670
|
if (typeof e != "function")
|
|
666
671
|
throw new X(m.COMPUTED_MUST_BE_FUNCTION);
|
|
@@ -715,8 +720,8 @@ class ke extends Ne {
|
|
|
715
720
|
}
|
|
716
721
|
get errors() {
|
|
717
722
|
if (this._registerTracking(), !this.hasError)
|
|
718
|
-
return
|
|
719
|
-
const e =
|
|
723
|
+
return je;
|
|
724
|
+
const e = Ge();
|
|
720
725
|
if (this._errorCacheEpoch === e && this._cachedErrors !== null)
|
|
721
726
|
return this._cachedErrors;
|
|
722
727
|
const s = /* @__PURE__ */ new Set();
|
|
@@ -797,7 +802,7 @@ class ke extends Ne {
|
|
|
797
802
|
this.flags = this.flags & ~s | -Number(e) & s;
|
|
798
803
|
}
|
|
799
804
|
_getAsyncState() {
|
|
800
|
-
return ce[this.flags &
|
|
805
|
+
return ce[this.flags & Oe];
|
|
801
806
|
}
|
|
802
807
|
_getFlagsAsString() {
|
|
803
808
|
const e = [];
|
|
@@ -834,7 +839,7 @@ class ke extends Ne {
|
|
|
834
839
|
}
|
|
835
840
|
_commitDependencies(e) {
|
|
836
841
|
const { nextDeps: s, nextVersions: n, state: i, prevDeps: r } = e;
|
|
837
|
-
s.length = i.depCount, n.length = i.depCount, this._unsubscribes =
|
|
842
|
+
s.length = i.depCount, n.length = i.depCount, this._unsubscribes = Ze(s, r, this._unsubscribes, this), this._dependencies = s, this._dependencyVersions = n;
|
|
838
843
|
}
|
|
839
844
|
_cleanupContext(e, s) {
|
|
840
845
|
this._trackable.addDependency = e.originalAdd, s ? (e.prevDeps !== y && $.release(e.prevDeps), e.prevVersions !== D && A.release(e.prevVersions)) : ($.release(e.nextDeps), A.release(e.nextVersions));
|
|
@@ -894,25 +899,19 @@ class ke extends Ne {
|
|
|
894
899
|
this._isRecomputing() || this._isDirty() || (this._setDirty(), this._notifyJob());
|
|
895
900
|
}
|
|
896
901
|
_registerTracking() {
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
if (Oe(e)) {
|
|
904
|
-
this._functionSubscribersStore.add(e);
|
|
905
|
-
return;
|
|
906
|
-
}
|
|
907
|
-
Ae(e) && this._objectSubscribersStore.add(e);
|
|
908
|
-
}
|
|
902
|
+
xe(
|
|
903
|
+
this,
|
|
904
|
+
q.getCurrent(),
|
|
905
|
+
this._functionSubscribersStore,
|
|
906
|
+
this._objectSubscribersStore
|
|
907
|
+
);
|
|
909
908
|
}
|
|
910
909
|
}
|
|
911
|
-
Object.freeze(
|
|
912
|
-
function
|
|
913
|
-
return new
|
|
910
|
+
Object.freeze(Ae.prototype);
|
|
911
|
+
function st(t, e = {}) {
|
|
912
|
+
return new Ae(t, e);
|
|
914
913
|
}
|
|
915
|
-
class
|
|
914
|
+
class nt extends ve {
|
|
916
915
|
/**
|
|
917
916
|
* Creates a new EffectImpl instance.
|
|
918
917
|
* @param fn - The effect function to run.
|
|
@@ -1064,7 +1063,7 @@ class st extends ve {
|
|
|
1064
1063
|
* @throws {EffectError} If an infinite loop is detected.
|
|
1065
1064
|
*/
|
|
1066
1065
|
_checkInfiniteLoop() {
|
|
1067
|
-
if (this._lastFlushEpoch !== ne && (this._lastFlushEpoch = ne, this._executionsInEpoch = 0), this._executionsInEpoch++, this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"),
|
|
1066
|
+
if (this._lastFlushEpoch !== ne && (this._lastFlushEpoch = ne, this._executionsInEpoch = 0), this._executionsInEpoch++, this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), Qe() > V.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, this._history) {
|
|
1068
1067
|
const e = Date.now();
|
|
1069
1068
|
this._history.push(e), this._history.length > V.MAX_EXECUTIONS_PER_SECOND + 10 && this._history.shift(), this._checkTimestampLoop(e);
|
|
1070
1069
|
}
|
|
@@ -1072,7 +1071,7 @@ class st extends ve {
|
|
|
1072
1071
|
_checkTimestampLoop(e) {
|
|
1073
1072
|
const s = this._history;
|
|
1074
1073
|
if (!s || this._maxExecutions <= 0) return;
|
|
1075
|
-
const n = e -
|
|
1074
|
+
const n = e - Ve.ONE_SECOND_MS;
|
|
1076
1075
|
let i = 0;
|
|
1077
1076
|
for (let r = s.length - 1; r >= 0 && !(s[r] < n); r--)
|
|
1078
1077
|
i++;
|
|
@@ -1132,7 +1131,7 @@ class st extends ve {
|
|
|
1132
1131
|
function I(t, e = {}) {
|
|
1133
1132
|
if (typeof t != "function")
|
|
1134
1133
|
throw new M(m.EFFECT_MUST_BE_FUNCTION);
|
|
1135
|
-
const s = new
|
|
1134
|
+
const s = new nt(t, e);
|
|
1136
1135
|
return s.execute(), s;
|
|
1137
1136
|
}
|
|
1138
1137
|
function b(t) {
|
|
@@ -1151,7 +1150,7 @@ function ue(t) {
|
|
|
1151
1150
|
}
|
|
1152
1151
|
return e.tagName.toLowerCase();
|
|
1153
1152
|
}
|
|
1154
|
-
function
|
|
1153
|
+
function it() {
|
|
1155
1154
|
if (typeof window < "u") {
|
|
1156
1155
|
const t = window.__ATOM_DEBUG__;
|
|
1157
1156
|
if (typeof t == "boolean")
|
|
@@ -1164,7 +1163,7 @@ function nt() {
|
|
|
1164
1163
|
}
|
|
1165
1164
|
return !1;
|
|
1166
1165
|
}
|
|
1167
|
-
let P =
|
|
1166
|
+
let P = it();
|
|
1168
1167
|
const h = {
|
|
1169
1168
|
get enabled() {
|
|
1170
1169
|
return P;
|
|
@@ -1184,7 +1183,7 @@ const h = {
|
|
|
1184
1183
|
domUpdated(t, e, s) {
|
|
1185
1184
|
if (!P) return;
|
|
1186
1185
|
const n = ue(t);
|
|
1187
|
-
console.log(`[atom-effect-jquery] DOM updated: ${n}.${e} =`, s),
|
|
1186
|
+
console.log(`[atom-effect-jquery] DOM updated: ${n}.${e} =`, s), rt(t);
|
|
1188
1187
|
},
|
|
1189
1188
|
cleanup(t) {
|
|
1190
1189
|
P && console.log(`[atom-effect-jquery] Cleanup: ${t}`);
|
|
@@ -1193,7 +1192,7 @@ const h = {
|
|
|
1193
1192
|
P && console.warn("[atom-effect-jquery]", ...t);
|
|
1194
1193
|
}
|
|
1195
1194
|
};
|
|
1196
|
-
function
|
|
1195
|
+
function rt(t) {
|
|
1197
1196
|
const e = t[0];
|
|
1198
1197
|
if (!e || !document.contains(e)) return;
|
|
1199
1198
|
const s = "atom_debug_timer", n = "atom_debug_cleanup_timer", i = "atom_debug_org_style";
|
|
@@ -1222,12 +1221,12 @@ function it(t) {
|
|
|
1222
1221
|
}, 100);
|
|
1223
1222
|
t.data(s, r);
|
|
1224
1223
|
}
|
|
1225
|
-
const
|
|
1226
|
-
function
|
|
1227
|
-
const s =
|
|
1228
|
-
return e.name &&
|
|
1224
|
+
const ot = /* @__PURE__ */ new WeakMap();
|
|
1225
|
+
function we(t, e = {}) {
|
|
1226
|
+
const s = tt(t, e);
|
|
1227
|
+
return e.name && ot.set(s, { name: e.name }), s;
|
|
1229
1228
|
}
|
|
1230
|
-
Object.defineProperty(
|
|
1229
|
+
Object.defineProperty(we, "debug", {
|
|
1231
1230
|
get() {
|
|
1232
1231
|
return h.enabled;
|
|
1233
1232
|
},
|
|
@@ -1235,30 +1234,30 @@ Object.defineProperty(Fe, "debug", {
|
|
|
1235
1234
|
h.enabled = t;
|
|
1236
1235
|
}
|
|
1237
1236
|
});
|
|
1238
|
-
function
|
|
1237
|
+
function ct() {
|
|
1239
1238
|
return new Promise((t) => setTimeout(t, 0));
|
|
1240
1239
|
}
|
|
1241
1240
|
u.extend({
|
|
1242
|
-
atom:
|
|
1243
|
-
computed:
|
|
1241
|
+
atom: we,
|
|
1242
|
+
computed: st,
|
|
1244
1243
|
effect: I,
|
|
1245
1244
|
batch: z,
|
|
1246
1245
|
untracked: Re,
|
|
1247
1246
|
isAtom: le,
|
|
1248
1247
|
isComputed: De,
|
|
1249
1248
|
isReactive: (t) => le(t) || De(t),
|
|
1250
|
-
nextTick:
|
|
1249
|
+
nextTick: ct
|
|
1251
1250
|
});
|
|
1252
|
-
function
|
|
1251
|
+
function ke() {
|
|
1253
1252
|
return { timeoutId: null, phase: "idle", hasFocus: !1 };
|
|
1254
1253
|
}
|
|
1255
|
-
function
|
|
1254
|
+
function Fe(t, e, s = {}) {
|
|
1256
1255
|
const {
|
|
1257
1256
|
debounce: n,
|
|
1258
1257
|
event: i = "input",
|
|
1259
1258
|
parse: r = (p) => p,
|
|
1260
1259
|
format: o = (p) => String(p ?? "")
|
|
1261
|
-
} = s, c =
|
|
1260
|
+
} = s, c = ke(), f = () => {
|
|
1262
1261
|
c.phase = "composing";
|
|
1263
1262
|
}, _ = () => {
|
|
1264
1263
|
c.phase = "idle", F();
|
|
@@ -1290,7 +1289,7 @@ function $e(t, e, s = {}) {
|
|
|
1290
1289
|
t.off(i, v), t.off("change", v), t.off("compositionstart", f), t.off("compositionend", _), t.off("focus", C), t.off("blur", S), c.timeoutId && clearTimeout(c.timeoutId);
|
|
1291
1290
|
} };
|
|
1292
1291
|
}
|
|
1293
|
-
class
|
|
1292
|
+
class ut {
|
|
1294
1293
|
// DOM Element -> Effect Array (for disposal)
|
|
1295
1294
|
effects = /* @__PURE__ */ new WeakMap();
|
|
1296
1295
|
// DOM Element -> Custom Cleanup Function Array
|
|
@@ -1363,9 +1362,9 @@ class ct {
|
|
|
1363
1362
|
}), this.cleanup(e);
|
|
1364
1363
|
}
|
|
1365
1364
|
}
|
|
1366
|
-
const l = new
|
|
1365
|
+
const l = new ut();
|
|
1367
1366
|
let J = null;
|
|
1368
|
-
function
|
|
1367
|
+
function ht(t = document.body) {
|
|
1369
1368
|
J || (J = new MutationObserver((e) => {
|
|
1370
1369
|
for (const s of e)
|
|
1371
1370
|
s.removedNodes.forEach((n) => {
|
|
@@ -1373,7 +1372,7 @@ function ut(t = document.body) {
|
|
|
1373
1372
|
});
|
|
1374
1373
|
}), J.observe(t, { childList: !0, subtree: !0 }));
|
|
1375
1374
|
}
|
|
1376
|
-
function
|
|
1375
|
+
function It() {
|
|
1377
1376
|
J?.disconnect(), J = null;
|
|
1378
1377
|
}
|
|
1379
1378
|
u.fn.atomText = function(t, e) {
|
|
@@ -1483,7 +1482,7 @@ u.fn.atomHide = function(t) {
|
|
|
1483
1482
|
};
|
|
1484
1483
|
u.fn.atomVal = function(t, e = {}) {
|
|
1485
1484
|
return this.each(function() {
|
|
1486
|
-
const { effect: s, cleanup: n } =
|
|
1485
|
+
const { effect: s, cleanup: n } = Fe(u(this), t, e), i = I(s);
|
|
1487
1486
|
l.trackEffect(this, i), l.trackCleanup(this, n);
|
|
1488
1487
|
});
|
|
1489
1488
|
};
|
|
@@ -1516,26 +1515,26 @@ u.fn.atomUnbind = function() {
|
|
|
1516
1515
|
l.cleanupTree(this);
|
|
1517
1516
|
});
|
|
1518
1517
|
};
|
|
1519
|
-
function
|
|
1518
|
+
function at(t, e) {
|
|
1520
1519
|
b(e) ? t.effects.push(() => {
|
|
1521
1520
|
const s = String(E(e) ?? "");
|
|
1522
1521
|
t.$el.text(s), h.domUpdated(t.$el, "text", s);
|
|
1523
1522
|
}) : t.$el.text(String(e ?? ""));
|
|
1524
1523
|
}
|
|
1525
|
-
function
|
|
1524
|
+
function lt(t, e) {
|
|
1526
1525
|
b(e) ? t.effects.push(() => {
|
|
1527
1526
|
const s = String(E(e) ?? "");
|
|
1528
1527
|
t.$el.html(s), h.domUpdated(t.$el, "html", s);
|
|
1529
1528
|
}) : t.$el.html(String(e ?? ""));
|
|
1530
1529
|
}
|
|
1531
|
-
function
|
|
1530
|
+
function ft(t, e) {
|
|
1532
1531
|
for (const [s, n] of Object.entries(e))
|
|
1533
1532
|
b(n) ? t.effects.push(() => {
|
|
1534
1533
|
const i = !!E(n);
|
|
1535
1534
|
t.$el.toggleClass(s, i), h.domUpdated(t.$el, `class.${s}`, i);
|
|
1536
1535
|
}) : t.$el.toggleClass(s, !!n);
|
|
1537
1536
|
}
|
|
1538
|
-
function
|
|
1537
|
+
function dt(t, e) {
|
|
1539
1538
|
for (const [s, n] of Object.entries(e))
|
|
1540
1539
|
if (Array.isArray(n)) {
|
|
1541
1540
|
const [i, r] = n;
|
|
@@ -1548,7 +1547,7 @@ function ft(t, e) {
|
|
|
1548
1547
|
t.$el.css(s, i), h.domUpdated(t.$el, `css.${s}`, i);
|
|
1549
1548
|
}) : t.$el.css(s, n);
|
|
1550
1549
|
}
|
|
1551
|
-
function
|
|
1550
|
+
function _t(t, e) {
|
|
1552
1551
|
for (const [s, n] of Object.entries(e)) {
|
|
1553
1552
|
const i = (r) => {
|
|
1554
1553
|
r == null || r === !1 ? t.$el.removeAttr(s) : r === !0 ? t.$el.attr(s, s) : t.$el.attr(s, String(r)), h.domUpdated(t.$el, `attr.${s}`, r);
|
|
@@ -1556,31 +1555,31 @@ function dt(t, e) {
|
|
|
1556
1555
|
b(n) ? t.effects.push(() => i(E(n))) : i(n);
|
|
1557
1556
|
}
|
|
1558
1557
|
}
|
|
1559
|
-
function
|
|
1558
|
+
function pt(t, e) {
|
|
1560
1559
|
for (const [s, n] of Object.entries(e))
|
|
1561
1560
|
b(n) ? t.effects.push(() => {
|
|
1562
1561
|
const i = E(n);
|
|
1563
1562
|
t.$el.prop(s, i), h.domUpdated(t.$el, `prop.${s}`, i);
|
|
1564
1563
|
}) : t.$el.prop(s, n);
|
|
1565
1564
|
}
|
|
1566
|
-
function
|
|
1565
|
+
function bt(t, e) {
|
|
1567
1566
|
b(e) ? t.effects.push(() => {
|
|
1568
1567
|
const s = !!E(e);
|
|
1569
1568
|
t.$el.toggle(s), h.domUpdated(t.$el, "show", s);
|
|
1570
1569
|
}) : t.$el.toggle(!!e);
|
|
1571
1570
|
}
|
|
1572
|
-
function
|
|
1571
|
+
function Et(t, e) {
|
|
1573
1572
|
b(e) ? t.effects.push(() => {
|
|
1574
1573
|
const s = !E(e);
|
|
1575
1574
|
t.$el.toggle(s), h.domUpdated(t.$el, "hide", !s);
|
|
1576
1575
|
}) : t.$el.toggle(!e);
|
|
1577
1576
|
}
|
|
1578
|
-
function
|
|
1579
|
-
const s = Array.isArray(e) ? e[0] : e, n = Array.isArray(e) ? e[1] : {}, { effect: i, cleanup: r } =
|
|
1577
|
+
function gt(t, e) {
|
|
1578
|
+
const s = Array.isArray(e) ? e[0] : e, n = Array.isArray(e) ? e[1] : {}, { effect: i, cleanup: r } = Fe(t.$el, s, n);
|
|
1580
1579
|
t.effects.push(i), t.trackCleanup(r);
|
|
1581
1580
|
}
|
|
1582
|
-
function
|
|
1583
|
-
const s =
|
|
1581
|
+
function mt(t, e) {
|
|
1582
|
+
const s = ke(), n = () => {
|
|
1584
1583
|
s.phase === "idle" && z(() => {
|
|
1585
1584
|
e.value = t.$el.prop("checked");
|
|
1586
1585
|
});
|
|
@@ -1589,7 +1588,7 @@ function gt(t, e) {
|
|
|
1589
1588
|
s.phase = "syncing-to-dom", t.$el.prop("checked", e.value), h.domUpdated(t.$el, "checked", e.value), s.phase = "idle";
|
|
1590
1589
|
});
|
|
1591
1590
|
}
|
|
1592
|
-
function
|
|
1591
|
+
function St(t, e) {
|
|
1593
1592
|
for (const [s, n] of Object.entries(e)) {
|
|
1594
1593
|
const i = function(r) {
|
|
1595
1594
|
z(() => n.call(this, r));
|
|
@@ -1605,13 +1604,13 @@ u.fn.atomBind = function(t) {
|
|
|
1605
1604
|
effects: s,
|
|
1606
1605
|
trackCleanup: (i) => l.trackCleanup(this, i)
|
|
1607
1606
|
};
|
|
1608
|
-
t.text !== void 0 &&
|
|
1607
|
+
t.text !== void 0 && at(n, t.text), t.html !== void 0 && lt(n, t.html), t.class && ft(n, t.class), t.css && dt(n, t.css), t.attr && _t(n, t.attr), t.prop && pt(n, t.prop), t.show !== void 0 && bt(n, t.show), t.hide !== void 0 && Et(n, t.hide), t.val !== void 0 && gt(n, t.val), t.checked !== void 0 && mt(n, t.checked), t.on && St(n, t.on), s.forEach((i) => {
|
|
1609
1608
|
const r = I(i);
|
|
1610
1609
|
l.trackEffect(this, r);
|
|
1611
1610
|
});
|
|
1612
1611
|
});
|
|
1613
1612
|
};
|
|
1614
|
-
function
|
|
1613
|
+
function yt(t) {
|
|
1615
1614
|
if (t.length === 0) return [];
|
|
1616
1615
|
const e = t.slice(), s = [0];
|
|
1617
1616
|
let n, i, r, o;
|
|
@@ -1666,10 +1665,10 @@ u.fn.atomList = function(t, e) {
|
|
|
1666
1665
|
}
|
|
1667
1666
|
const be = /* @__PURE__ */ new Map();
|
|
1668
1667
|
F.forEach((a, g) => be.set(a, g));
|
|
1669
|
-
const
|
|
1668
|
+
const $e = L.map((a) => be.get(a) ?? -1), Le = yt($e), Pe = new Set(Le);
|
|
1670
1669
|
let U = null;
|
|
1671
1670
|
for (let a = p.length - 1; a >= 0; a--) {
|
|
1672
|
-
const g = L[a], T = p[a], W =
|
|
1671
|
+
const g = L[a], T = p[a], W = Pe.has(a);
|
|
1673
1672
|
if (S.has(g)) {
|
|
1674
1673
|
const N = S.get(g);
|
|
1675
1674
|
if (!N) continue;
|
|
@@ -1730,7 +1729,7 @@ u.fn.atomUnmount = function() {
|
|
|
1730
1729
|
};
|
|
1731
1730
|
const H = /* @__PURE__ */ new WeakMap();
|
|
1732
1731
|
let Ie = !1;
|
|
1733
|
-
function
|
|
1732
|
+
function Me() {
|
|
1734
1733
|
if (Ie) return;
|
|
1735
1734
|
Ie = !0;
|
|
1736
1735
|
const t = u.fn.on, e = u.fn.off, s = u.fn.remove, n = u.fn.empty, i = u.fn.detach;
|
|
@@ -1778,21 +1777,21 @@ function Le() {
|
|
|
1778
1777
|
return e.apply(this, r);
|
|
1779
1778
|
};
|
|
1780
1779
|
}
|
|
1781
|
-
const
|
|
1782
|
-
|
|
1780
|
+
const Ct = Me;
|
|
1781
|
+
Me();
|
|
1783
1782
|
u(() => {
|
|
1784
|
-
|
|
1783
|
+
ht(document.body);
|
|
1785
1784
|
});
|
|
1786
1785
|
export {
|
|
1787
|
-
|
|
1786
|
+
tt as atom,
|
|
1788
1787
|
z as batch,
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1788
|
+
st as computed,
|
|
1789
|
+
Tt as default,
|
|
1790
|
+
It as disableAutoCleanup,
|
|
1792
1791
|
I as effect,
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1792
|
+
ht as enableAutoCleanup,
|
|
1793
|
+
Ct as enablejQueryBatching,
|
|
1794
|
+
Me as enablejQueryOverrides,
|
|
1796
1795
|
l as registry,
|
|
1797
1796
|
Re as untracked
|
|
1798
1797
|
};
|