@but212/atom-effect-jquery 0.27.0 → 0.28.0
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 +1 -1
- package/dist/atom-effect-jquery.min.js +2 -2
- package/dist/atom-effect-jquery.min.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -64
- package/dist/index.mjs +484 -454
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -281,13 +281,13 @@ var d = Object.freeze([]), f = class {
|
|
|
281
281
|
getDebugType(e) {
|
|
282
282
|
if (e != null) return e[x];
|
|
283
283
|
}
|
|
284
|
-
}(),
|
|
285
|
-
function
|
|
284
|
+
}(), w = 1, T = () => w++ | 0;
|
|
285
|
+
function E(e, t, n) {
|
|
286
286
|
return e instanceof m ? e : e instanceof Error ? new t(`${e.name || e.constructor.name || "Error"} (${n}): ${e.message}`, e) : new t(`Unexpected error (${n}): ${String(e)}`);
|
|
287
287
|
}
|
|
288
|
-
var
|
|
288
|
+
var ee = class {
|
|
289
289
|
constructor() {
|
|
290
|
-
this.flags = 0, this.version = 0, this._lastSeenEpoch = c.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id =
|
|
290
|
+
this.flags = 0, this.version = 0, this._lastSeenEpoch = c.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id = T() & l;
|
|
291
291
|
}
|
|
292
292
|
get isDisposed() {
|
|
293
293
|
return (this.flags & r.DISPOSED) !== 0;
|
|
@@ -300,7 +300,7 @@ var te = class {
|
|
|
300
300
|
}
|
|
301
301
|
subscribe(e) {
|
|
302
302
|
let t = typeof e == "function";
|
|
303
|
-
if (!t && (!e || typeof e.execute != "function")) throw
|
|
303
|
+
if (!t && (!e || typeof e.execute != "function")) throw E(/* @__PURE__ */ TypeError("Invalid subscriber"), m, v.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);
|
|
304
304
|
let n = this._slots;
|
|
305
305
|
n || (n = new y(), this._slots = n);
|
|
306
306
|
let r = !1;
|
|
@@ -371,7 +371,7 @@ var te = class {
|
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
373
|
_logNotifyError(e) {
|
|
374
|
-
console.error(
|
|
374
|
+
console.error(E(e, m, v.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
|
|
375
375
|
}
|
|
376
376
|
_isDirty() {
|
|
377
377
|
let e = this._deps;
|
|
@@ -383,32 +383,32 @@ var te = class {
|
|
|
383
383
|
}
|
|
384
384
|
return !e.hasComputeds && !e.isDirtyFast() ? !1 : this._deepDirtyCheck();
|
|
385
385
|
}
|
|
386
|
-
},
|
|
387
|
-
function
|
|
388
|
-
let e =
|
|
389
|
-
return
|
|
386
|
+
}, te = 0;
|
|
387
|
+
function ne() {
|
|
388
|
+
let e = te + 1 & l;
|
|
389
|
+
return te = e === 0 ? 1 : e, te;
|
|
390
390
|
}
|
|
391
|
-
function
|
|
391
|
+
function re(e) {
|
|
392
392
|
let t = e + 1 & l;
|
|
393
393
|
return t === 0 ? 1 : t;
|
|
394
394
|
}
|
|
395
|
-
var
|
|
395
|
+
var ie = 0, ae = !1, oe = 0;
|
|
396
396
|
function se() {
|
|
397
397
|
return oe;
|
|
398
398
|
}
|
|
399
399
|
function ce() {
|
|
400
|
-
return
|
|
400
|
+
return ae ? !1 : (ae = !0, oe = ne(), ie = 0, !0);
|
|
401
401
|
}
|
|
402
402
|
function le() {
|
|
403
|
-
|
|
403
|
+
ae = !1;
|
|
404
404
|
}
|
|
405
405
|
function ue() {
|
|
406
|
-
if (!
|
|
407
|
-
let e = ++
|
|
406
|
+
if (!ae) return 0;
|
|
407
|
+
let e = ++ie;
|
|
408
408
|
if (e <= a.MAX_EXECUTIONS_PER_FLUSH) return e;
|
|
409
409
|
throw Error(`[atom-effect] Infinite loop detected: flush execution count exceeded ${a.MAX_EXECUTIONS_PER_FLUSH}`);
|
|
410
410
|
}
|
|
411
|
-
var
|
|
411
|
+
var D = new class {
|
|
412
412
|
constructor() {
|
|
413
413
|
this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this._isFlushingSync = !1, this._batchDepth = 0, this._batchQueue = [], this._batchQueueSize = 0, this._maxFlushIterations = a.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
|
|
414
414
|
}
|
|
@@ -502,11 +502,12 @@ var de = new class {
|
|
|
502
502
|
if (e < a.MIN_FLUSH_ITERATIONS) throw new _(`Max flush iterations must be at least ${a.MIN_FLUSH_ITERATIONS}`);
|
|
503
503
|
this._maxFlushIterations = e;
|
|
504
504
|
}
|
|
505
|
-
}(),
|
|
505
|
+
}(), de = /* @__PURE__ */ Symbol.for("atom-effect/atom"), fe = /* @__PURE__ */ Symbol.for("atom-effect/computed"), pe = /* @__PURE__ */ Symbol.for("atom-effect/effect"), me = /* @__PURE__ */ Symbol.for("atom-effect/writable"), O = new class {
|
|
506
506
|
constructor() {
|
|
507
507
|
this.current = null;
|
|
508
508
|
}
|
|
509
509
|
run(e, t) {
|
|
510
|
+
if (this.current === e) return t();
|
|
510
511
|
let n = this.current;
|
|
511
512
|
this.current = e;
|
|
512
513
|
try {
|
|
@@ -516,8 +517,8 @@ var de = new class {
|
|
|
516
517
|
}
|
|
517
518
|
}
|
|
518
519
|
}();
|
|
519
|
-
function
|
|
520
|
-
let t =
|
|
520
|
+
function k(e) {
|
|
521
|
+
let t = O, n = t.current;
|
|
521
522
|
if (n === null) return e();
|
|
522
523
|
t.current = null;
|
|
523
524
|
try {
|
|
@@ -526,9 +527,9 @@ function O(e) {
|
|
|
526
527
|
t.current = n;
|
|
527
528
|
}
|
|
528
529
|
}
|
|
529
|
-
var
|
|
530
|
+
var he = class extends ee {
|
|
530
531
|
constructor(e, t) {
|
|
531
|
-
super(), this[
|
|
532
|
+
super(), this[de] = !0, this[me] = !0, this._value = e, t && (this.flags |= i.SYNC), C.attachDebugInfo(this, "atom", this.id);
|
|
532
533
|
}
|
|
533
534
|
get isNotificationScheduled() {
|
|
534
535
|
return (this.flags & i.NOTIFICATION_SCHEDULED) !== 0;
|
|
@@ -537,16 +538,16 @@ var ge = class extends te {
|
|
|
537
538
|
return (this.flags & i.SYNC) !== 0;
|
|
538
539
|
}
|
|
539
540
|
get value() {
|
|
540
|
-
return
|
|
541
|
+
return O.current?.addDependency(this), this._value;
|
|
541
542
|
}
|
|
542
543
|
set value(e) {
|
|
543
544
|
let t = this._value;
|
|
544
545
|
if (Object.is(t, e)) return;
|
|
545
|
-
this._value = e, this.version =
|
|
546
|
+
this._value = e, this.version = re(this.version);
|
|
546
547
|
let n = this.flags;
|
|
547
548
|
if ((n & i.NOTIFICATION_SCHEDULED) !== 0) return;
|
|
548
549
|
let r = this._slots;
|
|
549
|
-
r == null || r.size === 0 || (this._pendingOldValue = t, this.flags = n | i.NOTIFICATION_SCHEDULED, (n & i.SYNC) !== 0 && !
|
|
550
|
+
r == null || r.size === 0 || (this._pendingOldValue = t, this.flags = n | i.NOTIFICATION_SCHEDULED, (n & i.SYNC) !== 0 && !D.isBatching ? this._flushNotifications() : D.schedule(this));
|
|
550
551
|
}
|
|
551
552
|
execute() {
|
|
552
553
|
this._flushNotifications();
|
|
@@ -571,10 +572,10 @@ var ge = class extends te {
|
|
|
571
572
|
this.dispose();
|
|
572
573
|
}
|
|
573
574
|
};
|
|
574
|
-
function
|
|
575
|
-
return new
|
|
575
|
+
function A(e, t = {}) {
|
|
576
|
+
return new he(e, t.sync ?? !1);
|
|
576
577
|
}
|
|
577
|
-
var
|
|
578
|
+
var ge = class extends y {
|
|
578
579
|
constructor(...e) {
|
|
579
580
|
super(...e), this._map = null, this._SCAN_THRESHOLD = 32, this.hasComputeds = !1, this._depsHash = 0;
|
|
580
581
|
}
|
|
@@ -741,57 +742,57 @@ var _e = class extends y {
|
|
|
741
742
|
}
|
|
742
743
|
compact() {}
|
|
743
744
|
};
|
|
745
|
+
function _e(e) {
|
|
746
|
+
return typeof e == "object" && !!e && de in e;
|
|
747
|
+
}
|
|
744
748
|
function ve(e) {
|
|
745
749
|
return typeof e == "object" && !!e && fe in e;
|
|
746
750
|
}
|
|
747
751
|
function ye(e) {
|
|
748
|
-
return typeof e == "object" && !!e && pe in e;
|
|
749
|
-
}
|
|
750
|
-
function be(e) {
|
|
751
752
|
return typeof e == "object" && !!e && typeof e.then == "function";
|
|
752
753
|
}
|
|
753
|
-
var { IDLE:
|
|
754
|
+
var { IDLE: j, DIRTY: M, PENDING: N, RESOLVED: P, REJECTED: F, HAS_ERROR: be, RECOMPUTING: I, DISPOSED: xe, IS_COMPUTED: Se, FORCE_COMPUTE: Ce } = r, we = class extends ee {
|
|
754
755
|
constructor(e, t = {}) {
|
|
755
756
|
if (typeof e != "function") throw new h(v.COMPUTED_MUST_BE_FUNCTION);
|
|
756
|
-
if (super(), this[
|
|
757
|
+
if (super(), this[de] = !0, this[fe] = !0, this._error = null, this._promiseId = 0, this._deps = new ge(), this._asyncRetryCount = 0, this._lastDriftEpoch = c.UNINITIALIZED, this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = Se | M | j, this._equal = t.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in t ? t.defaultValue : S, this._onError = t.onError ?? null, this._maxAsyncRetries = (t.maxAsyncRetries ?? s.MAX_ASYNC_RETRIES) & l, C.attachDebugInfo(this, "computed", this.id), t.lazy === !1) try {
|
|
757
758
|
this._recompute();
|
|
758
759
|
} catch {}
|
|
759
760
|
}
|
|
760
761
|
get isDirty() {
|
|
761
|
-
return (this.flags &
|
|
762
|
+
return (this.flags & M) !== 0;
|
|
762
763
|
}
|
|
763
764
|
get isRejected() {
|
|
764
|
-
return (this.flags &
|
|
765
|
+
return (this.flags & F) !== 0;
|
|
765
766
|
}
|
|
766
767
|
get isRecomputing() {
|
|
767
|
-
return (this.flags &
|
|
768
|
+
return (this.flags & I) !== 0;
|
|
768
769
|
}
|
|
769
770
|
get _hasErrorInternal() {
|
|
770
|
-
return (this.flags &
|
|
771
|
+
return (this.flags & be) !== 0;
|
|
771
772
|
}
|
|
772
773
|
_track() {
|
|
773
|
-
|
|
774
|
+
O.current?.addDependency(this);
|
|
774
775
|
}
|
|
775
776
|
get value() {
|
|
776
|
-
|
|
777
|
+
O.current?.addDependency(this);
|
|
777
778
|
let e = this.flags;
|
|
778
|
-
if ((e & (
|
|
779
|
-
if ((e &
|
|
780
|
-
if ((e &
|
|
779
|
+
if ((e & (P | M | j)) === P) return this._value;
|
|
780
|
+
if ((e & xe) !== 0) throw new h(v.COMPUTED_DISPOSED);
|
|
781
|
+
if ((e & I) !== 0) {
|
|
781
782
|
let e = this._defaultValue;
|
|
782
783
|
if (e !== S) return e;
|
|
783
784
|
throw new h(v.COMPUTED_CIRCULAR_DEPENDENCY);
|
|
784
785
|
}
|
|
785
|
-
if ((e & (
|
|
786
|
+
if ((e & (M | j)) !== 0) {
|
|
786
787
|
let t = this._deps;
|
|
787
|
-
if ((e &
|
|
788
|
+
if ((e & j) === 0 && (e & Ce) === 0 && t.size > 0 && !this._isDirty() ? e = this.flags &= ~M : (this._recompute(), e = this.flags), (e & P) !== 0) return this._value;
|
|
788
789
|
}
|
|
789
790
|
let t = this._defaultValue, n = t !== S;
|
|
790
|
-
if ((e &
|
|
791
|
+
if ((e & N) !== 0) {
|
|
791
792
|
if (n) return t;
|
|
792
793
|
throw new h(v.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
|
|
793
794
|
}
|
|
794
|
-
if ((e &
|
|
795
|
+
if ((e & F) !== 0) {
|
|
795
796
|
if (n) return t;
|
|
796
797
|
throw this._error;
|
|
797
798
|
}
|
|
@@ -801,12 +802,12 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: xe, RE
|
|
|
801
802
|
return this._value;
|
|
802
803
|
}
|
|
803
804
|
get state() {
|
|
804
|
-
|
|
805
|
+
O.current?.addDependency(this);
|
|
805
806
|
let e = this.flags;
|
|
806
|
-
return (e &
|
|
807
|
+
return (e & P) === 0 ? (e & N) === 0 ? (e & F) === 0 ? t.IDLE : t.REJECTED : t.PENDING : t.RESOLVED;
|
|
807
808
|
}
|
|
808
809
|
get hasError() {
|
|
809
|
-
if (
|
|
810
|
+
if (O.current?.addDependency(this), (this.flags & (F | be)) !== 0) return !0;
|
|
810
811
|
let e = this._deps;
|
|
811
812
|
if (!e.hasComputeds) return !1;
|
|
812
813
|
let t = e.size;
|
|
@@ -817,7 +818,7 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: xe, RE
|
|
|
817
818
|
return !this.hasError;
|
|
818
819
|
}
|
|
819
820
|
get errors() {
|
|
820
|
-
|
|
821
|
+
O.current?.addDependency(this);
|
|
821
822
|
let e = this._error, t = this._deps;
|
|
822
823
|
if (!t.hasComputeds) return e == null ? d : Object.freeze([e]);
|
|
823
824
|
let n = [];
|
|
@@ -827,7 +828,7 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: xe, RE
|
|
|
827
828
|
let r = t.getAt(e);
|
|
828
829
|
if (r == null) continue;
|
|
829
830
|
let i = r.node;
|
|
830
|
-
(i.flags &
|
|
831
|
+
(i.flags & Se) !== 0 && i.hasError && this._collectErrorsFromDep(i, n);
|
|
831
832
|
}
|
|
832
833
|
return n.length === 0 ? d : Object.freeze(n);
|
|
833
834
|
}
|
|
@@ -839,19 +840,19 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: xe, RE
|
|
|
839
840
|
}
|
|
840
841
|
}
|
|
841
842
|
get lastError() {
|
|
842
|
-
return
|
|
843
|
+
return O.current?.addDependency(this), this._error;
|
|
843
844
|
}
|
|
844
845
|
get isPending() {
|
|
845
|
-
return
|
|
846
|
+
return O.current?.addDependency(this), (this.flags & N) !== 0;
|
|
846
847
|
}
|
|
847
848
|
get isResolved() {
|
|
848
|
-
return
|
|
849
|
+
return O.current?.addDependency(this), (this.flags & P) !== 0;
|
|
849
850
|
}
|
|
850
851
|
invalidate() {
|
|
851
852
|
this.flags |= Ce, this._markDirty();
|
|
852
853
|
}
|
|
853
854
|
dispose() {
|
|
854
|
-
(this.flags &
|
|
855
|
+
(this.flags & xe) === 0 && (this._deps.disposeAll(), this._slots != null && this._slots.clear(), this.flags = xe | M | j, this._error = null, this._value = void 0, this._hotIndex = -1);
|
|
855
856
|
}
|
|
856
857
|
[Symbol.dispose]() {
|
|
857
858
|
this.dispose();
|
|
@@ -866,26 +867,26 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: xe, RE
|
|
|
866
867
|
let t = new f(e, e.version, e.subscribe(this));
|
|
867
868
|
r.insertNew(n, t);
|
|
868
869
|
}
|
|
869
|
-
(e.flags &
|
|
870
|
+
(e.flags & Se) !== 0 && (r.hasComputeds = !0);
|
|
870
871
|
}
|
|
871
872
|
_recompute() {
|
|
872
873
|
if (this.isRecomputing) return;
|
|
873
|
-
this.flags = (this.flags |
|
|
874
|
+
this.flags = (this.flags | I) & ~Ce, this._trackEpoch = ne(), this._trackCount = 0, this._deps.prepareTracking(), this._hotIndex = -1;
|
|
874
875
|
let e = !1;
|
|
875
876
|
try {
|
|
876
|
-
let t =
|
|
877
|
-
this._deps.truncateFrom(this._trackCount), this._deps.seal(), e = !0,
|
|
877
|
+
let t = O.run(this, this._fn);
|
|
878
|
+
this._deps.truncateFrom(this._trackCount), this._deps.seal(), e = !0, ye(t) ? this._handleAsyncComputation(t) : this._finalizeResolution(t);
|
|
878
879
|
} catch (t) {
|
|
879
880
|
if (!e) try {
|
|
880
881
|
this._deps.truncateFrom(this._trackCount);
|
|
881
882
|
} catch {}
|
|
882
883
|
this._handleError(t, v.COMPUTED_COMPUTATION_FAILED, !0);
|
|
883
884
|
} finally {
|
|
884
|
-
this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this.flags &= ~
|
|
885
|
+
this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this.flags &= ~I;
|
|
885
886
|
}
|
|
886
887
|
}
|
|
887
888
|
_handleAsyncComputation(e) {
|
|
888
|
-
this.flags = (this.flags |
|
|
889
|
+
this.flags = (this.flags | N) & ~(j | M | P | F), this._notifySubscribers(void 0, void 0), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % s.MAX_PROMISE_ID;
|
|
889
890
|
let t = this._promiseId;
|
|
890
891
|
e.then((e) => {
|
|
891
892
|
if (t === this._promiseId) {
|
|
@@ -898,8 +899,8 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: xe, RE
|
|
|
898
899
|
}, (e) => t === this._promiseId && this._handleError(e, v.COMPUTED_ASYNC_COMPUTATION_FAILED));
|
|
899
900
|
}
|
|
900
901
|
_handleError(e, t, n = !1) {
|
|
901
|
-
let r =
|
|
902
|
-
if (!n && !this.isRejected && (this.version =
|
|
902
|
+
let r = E(e, h, t);
|
|
903
|
+
if (!n && !this.isRejected && (this.version = re(this.version)), this._error = r, this.flags = this.flags & ~(j | M | N | P) | F | be, this._onError) try {
|
|
903
904
|
this._onError(r);
|
|
904
905
|
} catch (e) {
|
|
905
906
|
console.error(v.CALLBACK_ERROR_IN_ERROR_HANDLER, e);
|
|
@@ -909,45 +910,45 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: xe, RE
|
|
|
909
910
|
}
|
|
910
911
|
_finalizeResolution(e) {
|
|
911
912
|
let t = this.flags;
|
|
912
|
-
((t &
|
|
913
|
+
((t & P) === 0 || !this._equal(this._value, e)) && (this.version = re(this.version)), this._value = e, this._error = null, this.flags = (t | P) & ~(j | M | N | F | be);
|
|
913
914
|
}
|
|
914
915
|
execute() {
|
|
915
916
|
this._markDirty();
|
|
916
917
|
}
|
|
917
918
|
_markDirty() {
|
|
918
919
|
let e = this.flags;
|
|
919
|
-
(e & (
|
|
920
|
+
(e & (I | M)) === 0 && (this.flags = e | M, this._notifySubscribers(void 0, void 0));
|
|
920
921
|
}
|
|
921
922
|
_isDirty() {
|
|
922
923
|
let e = this._deps;
|
|
923
924
|
return e.hasComputeds ? this._deepDirtyCheck() : e.isDirtyFast();
|
|
924
925
|
}
|
|
925
926
|
_deepDirtyCheck() {
|
|
926
|
-
let e = this._deps, t =
|
|
927
|
-
|
|
927
|
+
let e = this._deps, t = O.current;
|
|
928
|
+
O.current = null;
|
|
928
929
|
try {
|
|
929
930
|
let t = e.size;
|
|
930
931
|
for (let n = 0; n < t; n++) {
|
|
931
932
|
let t = e.getAt(n);
|
|
932
933
|
if (t == null) continue;
|
|
933
934
|
let r = t.node;
|
|
934
|
-
if ((r.flags &
|
|
935
|
+
if ((r.flags & Se) !== 0) try {
|
|
935
936
|
r.value;
|
|
936
937
|
} catch {}
|
|
937
938
|
if (r.version !== t.version) return this._hotIndex = n, !0;
|
|
938
939
|
}
|
|
939
940
|
return this._hotIndex = -1, !1;
|
|
940
941
|
} finally {
|
|
941
|
-
|
|
942
|
+
O.current = t;
|
|
942
943
|
}
|
|
943
944
|
}
|
|
944
945
|
};
|
|
945
946
|
function L(e, t = {}) {
|
|
946
947
|
return new we(e, t);
|
|
947
948
|
}
|
|
948
|
-
var Te = class extends
|
|
949
|
+
var Te = class extends ee {
|
|
949
950
|
constructor(e, t = {}) {
|
|
950
|
-
super(), this[
|
|
951
|
+
super(), this[pe] = !0, this._cleanup = null, this._deps = new ge(), this._currentEpoch = c.UNINITIALIZED, this._lastFlushEpoch = c.UNINITIALIZED, this._fn = e, this._onError = t.onError ?? null, this._sync = t.sync ?? !1, this._maxExecutions = t.maxExecutionsPerSecond ?? a.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = t.maxExecutionsPerFlush ?? a.MAX_EXECUTIONS_PER_EFFECT, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._trackCount = 0, this._sync ? this._notifyCallback = () => this.execute() : this._notifyCallback = () => D.schedule(this), C.attachDebugInfo(this, "effect", this.id);
|
|
951
952
|
}
|
|
952
953
|
run() {
|
|
953
954
|
if (this.isDisposed) throw new g(v.EFFECT_DISPOSED);
|
|
@@ -988,7 +989,7 @@ var Te = class extends te {
|
|
|
988
989
|
let t = e.subscribe(this._notifyCallback);
|
|
989
990
|
n = new f(e, e.version, t);
|
|
990
991
|
} catch (t) {
|
|
991
|
-
let r =
|
|
992
|
+
let r = E(t, g, v.EFFECT_EXECUTION_FAILED);
|
|
992
993
|
if (console.error(r), this._onError) try {
|
|
993
994
|
this._onError(r);
|
|
994
995
|
} catch {}
|
|
@@ -1001,11 +1002,11 @@ var Te = class extends te {
|
|
|
1001
1002
|
if ((t & (n.DISPOSED | n.EXECUTING)) !== 0) return;
|
|
1002
1003
|
let r = this._deps;
|
|
1003
1004
|
if (!e && r.size > 0 && !this._isDirty()) return;
|
|
1004
|
-
this._checkInfiniteLoops(), this.flags = t | n.EXECUTING, this._execCleanup(), this._currentEpoch =
|
|
1005
|
+
this._checkInfiniteLoops(), this.flags = t | n.EXECUTING, this._execCleanup(), this._currentEpoch = ne(), this._trackCount = 0, r.prepareTracking(), this._hotIndex = -1;
|
|
1005
1006
|
let i = !1;
|
|
1006
1007
|
try {
|
|
1007
|
-
let e =
|
|
1008
|
-
r.truncateFrom(this._trackCount), r.seal(), i = !0,
|
|
1008
|
+
let e = O.run(this, this._fn);
|
|
1009
|
+
r.truncateFrom(this._trackCount), r.seal(), i = !0, ye(e) ? this._handleAsyncResult(e) : this._cleanup = typeof e == "function" ? e : null;
|
|
1009
1010
|
} catch (e) {
|
|
1010
1011
|
if (!i) try {
|
|
1011
1012
|
r.truncateFrom(this._trackCount);
|
|
@@ -1034,8 +1035,8 @@ var Te = class extends te {
|
|
|
1034
1035
|
}, (e) => t === this._execId && this._handleExecutionError(e));
|
|
1035
1036
|
}
|
|
1036
1037
|
_deepDirtyCheck() {
|
|
1037
|
-
let e =
|
|
1038
|
-
|
|
1038
|
+
let e = O.current;
|
|
1039
|
+
O.current = null;
|
|
1039
1040
|
let t = this._deps;
|
|
1040
1041
|
try {
|
|
1041
1042
|
let e = t.size;
|
|
@@ -1047,7 +1048,7 @@ var Te = class extends te {
|
|
|
1047
1048
|
}
|
|
1048
1049
|
return !1;
|
|
1049
1050
|
} finally {
|
|
1050
|
-
|
|
1051
|
+
O.current = e;
|
|
1051
1052
|
}
|
|
1052
1053
|
}
|
|
1053
1054
|
_tryPullComputed(e) {
|
|
@@ -1089,15 +1090,15 @@ var Te = class extends te {
|
|
|
1089
1090
|
return (this.flags & n.EXECUTING) !== 0;
|
|
1090
1091
|
}
|
|
1091
1092
|
_throwInfiniteLoopError(e) {
|
|
1092
|
-
let t = new g(`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${
|
|
1093
|
+
let t = new g(`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${ie}`);
|
|
1093
1094
|
throw this.dispose(), console.error(t), t;
|
|
1094
1095
|
}
|
|
1095
1096
|
_handleExecutionError(e, t = v.EFFECT_EXECUTION_FAILED) {
|
|
1096
|
-
let n =
|
|
1097
|
+
let n = E(e, g, t);
|
|
1097
1098
|
if (console.error(n), this._onError) try {
|
|
1098
1099
|
this._onError(n);
|
|
1099
1100
|
} catch (e) {
|
|
1100
|
-
console.error(
|
|
1101
|
+
console.error(E(e, g, v.CALLBACK_ERROR_IN_ERROR_HANDLER));
|
|
1101
1102
|
}
|
|
1102
1103
|
}
|
|
1103
1104
|
};
|
|
@@ -1106,9 +1107,61 @@ function R(e, t = {}) {
|
|
|
1106
1107
|
let n = new Te(e, t);
|
|
1107
1108
|
return n.execute(), n;
|
|
1108
1109
|
}
|
|
1109
|
-
|
|
1110
|
+
var Ee = /* @__PURE__ */ Symbol.for("atom-effect/atom"), De = /* @__PURE__ */ Symbol.for("atom-effect/writable");
|
|
1111
|
+
function Oe(e, t, n, r) {
|
|
1112
|
+
if (n === t.length) return r;
|
|
1113
|
+
let i = t[n], a = typeof e == "object" && e ? e : {}, o = a[i], s = Oe(o, t, n + 1, r);
|
|
1114
|
+
if (Object.is(o, s)) return e;
|
|
1115
|
+
if (Array.isArray(a)) {
|
|
1116
|
+
let e = a.slice(), t = Number.parseInt(i, 10);
|
|
1117
|
+
return Number.isNaN(t) ? e[i] = s : e[t] = s, e;
|
|
1118
|
+
}
|
|
1119
|
+
return {
|
|
1120
|
+
...a,
|
|
1121
|
+
[i]: s
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
function z(e, t) {
|
|
1125
|
+
let n = e, r = t.length;
|
|
1126
|
+
for (let e = 0; e < r; e++) {
|
|
1127
|
+
if (n == null) return;
|
|
1128
|
+
n = n[t[e]];
|
|
1129
|
+
}
|
|
1130
|
+
return n;
|
|
1131
|
+
}
|
|
1132
|
+
function ke(e, t) {
|
|
1133
|
+
let n = t.includes(".") ? t.split(".") : [t], r = /* @__PURE__ */ new Set(), i = () => {
|
|
1134
|
+
r.forEach((e) => e()), r.clear();
|
|
1135
|
+
};
|
|
1136
|
+
return {
|
|
1137
|
+
get value() {
|
|
1138
|
+
return z(e.value, n);
|
|
1139
|
+
},
|
|
1140
|
+
set value(t) {
|
|
1141
|
+
let r = e.peek(), i = Oe(r, n, 0, t);
|
|
1142
|
+
i !== r && (e.value = i);
|
|
1143
|
+
},
|
|
1144
|
+
peek: () => z(e.peek(), n),
|
|
1145
|
+
subscribe(t) {
|
|
1146
|
+
let i = e.subscribe((e, r) => {
|
|
1147
|
+
let i = z(e, n), a = z(r, n);
|
|
1148
|
+
Object.is(i, a) || t(i, a);
|
|
1149
|
+
});
|
|
1150
|
+
return r.add(i), () => {
|
|
1151
|
+
i(), r.delete(i);
|
|
1152
|
+
};
|
|
1153
|
+
},
|
|
1154
|
+
subscriberCount: () => r.size,
|
|
1155
|
+
dispose: i,
|
|
1156
|
+
[Symbol.dispose]: i,
|
|
1157
|
+
[Ee]: !0,
|
|
1158
|
+
[De]: !0
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
var Ae = (e, t) => ke(e, t), je = (e) => (t) => ke(e, t);
|
|
1162
|
+
function Me(e) {
|
|
1110
1163
|
if (typeof e != "function") throw TypeError(v.BATCH_CALLBACK_MUST_BE_FUNCTION);
|
|
1111
|
-
let t =
|
|
1164
|
+
let t = D;
|
|
1112
1165
|
t.startBatch();
|
|
1113
1166
|
try {
|
|
1114
1167
|
return e();
|
|
@@ -1118,8 +1171,8 @@ function Ee(e) {
|
|
|
1118
1171
|
}
|
|
1119
1172
|
//#endregion
|
|
1120
1173
|
//#region src/utils/index.ts
|
|
1121
|
-
var
|
|
1122
|
-
function
|
|
1174
|
+
var B = (e) => _e(e), Ne = (e) => typeof e == "object" && !!e && typeof e.then == "function";
|
|
1175
|
+
function Pe(e) {
|
|
1123
1176
|
let t = e.localName, n = e.id;
|
|
1124
1177
|
if (n) return `${t}#${n}`;
|
|
1125
1178
|
let r = e.className;
|
|
@@ -1130,7 +1183,7 @@ function B(e) {
|
|
|
1130
1183
|
return t;
|
|
1131
1184
|
}
|
|
1132
1185
|
var V = Object.prototype.hasOwnProperty;
|
|
1133
|
-
function
|
|
1186
|
+
function Fe(e, t) {
|
|
1134
1187
|
if (e === t) return !0;
|
|
1135
1188
|
if (typeof e != "object" || !e || typeof t != "object" || !t) return !1;
|
|
1136
1189
|
let n = e, r = t, i = 0;
|
|
@@ -1154,14 +1207,14 @@ var H = {
|
|
|
1154
1207
|
basePath: "",
|
|
1155
1208
|
autoBindLinks: !1,
|
|
1156
1209
|
activeClass: "active"
|
|
1157
|
-
}),
|
|
1210
|
+
}), Ie = {
|
|
1158
1211
|
EVENT: "input",
|
|
1159
1212
|
DEBOUNCE: 0
|
|
1160
|
-
},
|
|
1213
|
+
}, Le = { HIGHLIGHT_DURATION_MS: 500 }, Re = new Set([
|
|
1161
1214
|
"input",
|
|
1162
1215
|
"select",
|
|
1163
1216
|
"textarea"
|
|
1164
|
-
]),
|
|
1217
|
+
]), ze = new Set([
|
|
1165
1218
|
"innerHTML",
|
|
1166
1219
|
"outerHTML",
|
|
1167
1220
|
"srcdoc",
|
|
@@ -1196,34 +1249,24 @@ var H = {
|
|
|
1196
1249
|
CLEANUP_ERROR: (e) => `Cleanup error${e ? ` in component <${e}>` : ""}`
|
|
1197
1250
|
},
|
|
1198
1251
|
CORE: { EFFECT_DISPOSE_ERROR: (e) => `Effect dispose error${e ? `: ${e}` : ""}` }
|
|
1199
|
-
},
|
|
1200
|
-
function
|
|
1201
|
-
|
|
1252
|
+
}, Be = typeof window < "u", Ve = `${Le.HIGHLIGHT_DURATION_MS / 1e3}s`;
|
|
1253
|
+
function He() {
|
|
1254
|
+
let e = globalThis;
|
|
1255
|
+
if (Be && e.window?.__ATOM_DEBUG__ === !0) return !0;
|
|
1202
1256
|
try {
|
|
1203
|
-
if (
|
|
1257
|
+
if (e.process?.env?.VITE_ATOM_DEBUG === "true") return !0;
|
|
1204
1258
|
} catch {}
|
|
1205
1259
|
return !1;
|
|
1206
1260
|
}
|
|
1207
|
-
var
|
|
1261
|
+
var G = new class {
|
|
1262
|
+
constructor() {
|
|
1263
|
+
this._enabled = !1, this._lastState = !1, this.log = () => {}, this.atomChanged = () => {}, this.domUpdated = () => {}, this.cleanup = () => {}, this._enabled = He(), this._lastState = this._enabled, this._applyMethods(this._enabled);
|
|
1264
|
+
}
|
|
1208
1265
|
get enabled() {
|
|
1209
|
-
return
|
|
1266
|
+
return this._enabled;
|
|
1210
1267
|
}
|
|
1211
1268
|
set enabled(e) {
|
|
1212
|
-
|
|
1213
|
-
}
|
|
1214
|
-
log(e, ...t) {
|
|
1215
|
-
this.enabled && console.log(e, ...t);
|
|
1216
|
-
}
|
|
1217
|
-
atomChanged(e, t, n, r) {
|
|
1218
|
-
this.enabled && console.log(`${e} Atom "${t ?? "anonymous"}" changed:`, n, "→", r);
|
|
1219
|
-
}
|
|
1220
|
-
domUpdated(e, t, n, r) {
|
|
1221
|
-
if (!this.enabled) return;
|
|
1222
|
-
let i = t instanceof Element ? t : t[0];
|
|
1223
|
-
i?.isConnected && (console.log(`${e} DOM updated: ${B(i)}.${n} =`, r), Ue(i));
|
|
1224
|
-
}
|
|
1225
|
-
cleanup(e, t) {
|
|
1226
|
-
this.enabled && console.log(`${e} Cleanup: ${t}`);
|
|
1269
|
+
this._enabled !== e && (this._enabled = e, this._applyMethods(e));
|
|
1227
1270
|
}
|
|
1228
1271
|
warn(e, t, ...n) {
|
|
1229
1272
|
console.warn(`${e} ${t}`, ...n);
|
|
@@ -1231,87 +1274,39 @@ var Ie = Fe(), G = new class {
|
|
|
1231
1274
|
error(e, t, n) {
|
|
1232
1275
|
console.error(`${e} ${t}`, n);
|
|
1233
1276
|
}
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1277
|
+
_applyMethods(e) {
|
|
1278
|
+
e ? (this.log = (e, ...t) => console.log(e, ...t), this.atomChanged = (e, t, n, r) => console.log(`${e} Atom "${t ?? "anonymous"}" changed:`, n, "→", r), this.domUpdated = (e, t, n, r) => {
|
|
1279
|
+
let i = t instanceof Element ? t : t[0];
|
|
1280
|
+
i?.isConnected && (console.log(`${e} DOM updated: ${Pe(i)}.${n} =`, r), this._highlightElement(i));
|
|
1281
|
+
}, this.cleanup = (e, t) => console.log(`${e} Cleanup: ${t}`)) : (this.log = () => {}, this.atomChanged = () => {}, this.domUpdated = () => {}, this.cleanup = () => {});
|
|
1282
|
+
}
|
|
1283
|
+
_highlightElement(e) {
|
|
1284
|
+
if (!e.isConnected) return;
|
|
1285
|
+
Ke();
|
|
1286
|
+
let t = Je.get(e), n = qe.get(e);
|
|
1287
|
+
t !== void 0 && cancelAnimationFrame(t), n !== void 0 && (clearTimeout(n), qe.delete(e)), Je.set(e, requestAnimationFrame(() => {
|
|
1288
|
+
Je.delete(e), e.isConnected && (e.classList.add(Ue), qe.set(e, setTimeout(() => {
|
|
1289
|
+
e.isConnected && e.classList.remove(Ue), qe.delete(e);
|
|
1290
|
+
}, Le.HIGHLIGHT_DURATION_MS)));
|
|
1291
|
+
}));
|
|
1292
|
+
}
|
|
1293
|
+
}(), Ue = "atom-debug-highlight", We = "data-atom-debug", Ge = !1;
|
|
1294
|
+
function Ke() {
|
|
1295
|
+
if (Ge || !Be) return;
|
|
1296
|
+
if (document.querySelector(`style[${We}]`)) {
|
|
1297
|
+
Ge = !0;
|
|
1239
1298
|
return;
|
|
1240
1299
|
}
|
|
1241
|
-
let e = Object.assign(document.createElement("style"), { textContent: `.${
|
|
1242
|
-
e.setAttribute(
|
|
1243
|
-
}
|
|
1244
|
-
var Ve = /* @__PURE__ */ new WeakMap(), He = /* @__PURE__ */ new WeakMap();
|
|
1245
|
-
function Ue(e) {
|
|
1246
|
-
if (!G.enabled || !e.isConnected) return;
|
|
1247
|
-
Be();
|
|
1248
|
-
let t = He.get(e), n = Ve.get(e);
|
|
1249
|
-
t !== void 0 && cancelAnimationFrame(t), n !== void 0 && (clearTimeout(n), Ve.delete(e)), He.set(e, requestAnimationFrame(() => {
|
|
1250
|
-
He.delete(e), e.isConnected && (e.classList.add(Le), Ve.set(e, setTimeout(() => {
|
|
1251
|
-
e.isConnected && e.classList.remove(Le), Ve.delete(e);
|
|
1252
|
-
}, Ae.HIGHLIGHT_DURATION_MS)));
|
|
1253
|
-
}));
|
|
1254
|
-
}
|
|
1255
|
-
//#endregion
|
|
1256
|
-
//#region src/core/lens.ts
|
|
1257
|
-
var We = Symbol.for("atom-effect/atom"), Ge = Symbol.for("atom-effect/writable");
|
|
1258
|
-
function Ke(e, t, n, r) {
|
|
1259
|
-
if (n === t.length) return r;
|
|
1260
|
-
let i = t[n], a = typeof e == "object" && e ? e : {}, o = a[i], s = Ke(o, t, n + 1, r);
|
|
1261
|
-
if (Object.is(o, s)) return e;
|
|
1262
|
-
if (Array.isArray(a)) {
|
|
1263
|
-
let e = a.slice(), t = Number.parseInt(i, 10);
|
|
1264
|
-
return Number.isNaN(t) ? e[i] = s : e[t] = s, e;
|
|
1265
|
-
}
|
|
1266
|
-
return {
|
|
1267
|
-
...a,
|
|
1268
|
-
[i]: s
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
function K(e, t) {
|
|
1272
|
-
let n = e, r = t.length;
|
|
1273
|
-
for (let e = 0; e < r; e++) {
|
|
1274
|
-
if (n == null) return;
|
|
1275
|
-
n = n[t[e]];
|
|
1276
|
-
}
|
|
1277
|
-
return n;
|
|
1278
|
-
}
|
|
1279
|
-
function qe(e, t) {
|
|
1280
|
-
let n = t.includes(".") ? t.split(".") : [t], r = /* @__PURE__ */ new Set(), i = () => {
|
|
1281
|
-
r.forEach((e) => e()), r.clear();
|
|
1282
|
-
};
|
|
1283
|
-
return {
|
|
1284
|
-
get value() {
|
|
1285
|
-
return K(e.value, n);
|
|
1286
|
-
},
|
|
1287
|
-
set value(t) {
|
|
1288
|
-
let r = e.peek(), i = Ke(r, n, 0, t);
|
|
1289
|
-
i !== r && (e.value = i);
|
|
1290
|
-
},
|
|
1291
|
-
peek: () => K(e.peek(), n),
|
|
1292
|
-
subscribe(t) {
|
|
1293
|
-
let i = e.subscribe((e, r) => {
|
|
1294
|
-
let i = K(e, n), a = K(r, n);
|
|
1295
|
-
Object.is(i, a) || t(i, a);
|
|
1296
|
-
});
|
|
1297
|
-
return r.add(i), () => {
|
|
1298
|
-
i(), r.delete(i);
|
|
1299
|
-
};
|
|
1300
|
-
},
|
|
1301
|
-
subscriberCount: () => r.size,
|
|
1302
|
-
dispose: i,
|
|
1303
|
-
[Symbol.dispose]: i,
|
|
1304
|
-
[We]: !0,
|
|
1305
|
-
[Ge]: !0
|
|
1306
|
-
};
|
|
1300
|
+
let e = Object.assign(document.createElement("style"), { textContent: `.${Ue}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline ${Ve} ease-out}` });
|
|
1301
|
+
e.setAttribute(We, ""), document.head.appendChild(e), Ge = !0;
|
|
1307
1302
|
}
|
|
1308
|
-
var
|
|
1303
|
+
var qe = /* @__PURE__ */ new WeakMap(), Je = /* @__PURE__ */ new WeakMap();
|
|
1309
1304
|
//#endregion
|
|
1310
1305
|
//#region src/core/namespace.ts
|
|
1311
|
-
function
|
|
1312
|
-
return
|
|
1306
|
+
function Ye(e, t) {
|
|
1307
|
+
return A(e, t);
|
|
1313
1308
|
}
|
|
1314
|
-
Object.defineProperty(
|
|
1309
|
+
Object.defineProperty(Ye, "debug", {
|
|
1315
1310
|
enumerable: !0,
|
|
1316
1311
|
configurable: !0,
|
|
1317
1312
|
get: () => G.enabled,
|
|
@@ -1319,24 +1314,24 @@ Object.defineProperty(Xe, "debug", {
|
|
|
1319
1314
|
G.enabled = e;
|
|
1320
1315
|
}
|
|
1321
1316
|
});
|
|
1322
|
-
var
|
|
1317
|
+
var Xe = () => Promise.resolve();
|
|
1323
1318
|
e.extend({
|
|
1324
|
-
atom:
|
|
1319
|
+
atom: Ye,
|
|
1325
1320
|
computed: L,
|
|
1326
1321
|
effect: R,
|
|
1327
|
-
batch:
|
|
1328
|
-
untracked:
|
|
1329
|
-
isAtom:
|
|
1330
|
-
isComputed:
|
|
1331
|
-
isReactive:
|
|
1332
|
-
nextTick:
|
|
1333
|
-
atomLens:
|
|
1334
|
-
composeLens:
|
|
1335
|
-
lensFor:
|
|
1322
|
+
batch: Me,
|
|
1323
|
+
untracked: k,
|
|
1324
|
+
isAtom: _e,
|
|
1325
|
+
isComputed: ve,
|
|
1326
|
+
isReactive: B,
|
|
1327
|
+
nextTick: Xe,
|
|
1328
|
+
atomLens: ke,
|
|
1329
|
+
composeLens: Ae,
|
|
1330
|
+
lensFor: je
|
|
1336
1331
|
});
|
|
1337
1332
|
//#endregion
|
|
1338
1333
|
//#region src/utils/array-pool.ts
|
|
1339
|
-
var
|
|
1334
|
+
var Ze = class {
|
|
1340
1335
|
constructor(e = 50, t = 256) {
|
|
1341
1336
|
this.limit = e, this.capacity = t, this.pool = [];
|
|
1342
1337
|
}
|
|
@@ -1349,7 +1344,7 @@ var Qe = class {
|
|
|
1349
1344
|
reset() {
|
|
1350
1345
|
this.pool.length = 0;
|
|
1351
1346
|
}
|
|
1352
|
-
},
|
|
1347
|
+
}, Qe = class {
|
|
1353
1348
|
constructor(e, t, n = 64) {
|
|
1354
1349
|
this.factory = e, this.reset = t, this.limit = n, this.pool = [];
|
|
1355
1350
|
}
|
|
@@ -1365,17 +1360,17 @@ var Qe = class {
|
|
|
1365
1360
|
get size() {
|
|
1366
1361
|
return this.pool.length;
|
|
1367
1362
|
}
|
|
1368
|
-
},
|
|
1363
|
+
}, $e = new Ze(), et = new Ze(), tt = new Qe(() => ({
|
|
1369
1364
|
effects: void 0,
|
|
1370
1365
|
cleanups: void 0,
|
|
1371
1366
|
componentCleanup: void 0
|
|
1372
1367
|
}), (e) => {
|
|
1373
1368
|
e.effects = void 0, e.cleanups = void 0, e.componentCleanup = void 0;
|
|
1374
|
-
}, 128),
|
|
1375
|
-
function
|
|
1376
|
-
|
|
1369
|
+
}, 128), nt = !1;
|
|
1370
|
+
function rt() {
|
|
1371
|
+
nt || (nt = !0, typeof document < "u" && document.body && at(document.body));
|
|
1377
1372
|
}
|
|
1378
|
-
var
|
|
1373
|
+
var K = "_aes-bound", q = new class {
|
|
1379
1374
|
constructor() {
|
|
1380
1375
|
this.records = /* @__PURE__ */ new WeakMap(), this.preservedNodes = /* @__PURE__ */ new WeakSet(), this.ignoredNodes = /* @__PURE__ */ new WeakSet();
|
|
1381
1376
|
}
|
|
@@ -1392,17 +1387,17 @@ var q = "_aes-bound", J = new class {
|
|
|
1392
1387
|
return this.ignoredNodes.has(e);
|
|
1393
1388
|
}
|
|
1394
1389
|
getOrCreateRecord(e) {
|
|
1395
|
-
|
|
1390
|
+
rt();
|
|
1396
1391
|
let t = this.records.get(e);
|
|
1397
|
-
return t || (t =
|
|
1392
|
+
return t || (t = tt.acquire(), this.records.set(e, t), e.classList.add(K)), t;
|
|
1398
1393
|
}
|
|
1399
1394
|
trackEffect(e, t) {
|
|
1400
1395
|
let n = this.getOrCreateRecord(e);
|
|
1401
|
-
n.effects ||=
|
|
1396
|
+
n.effects ||= $e.acquire(), n.effects.push(t);
|
|
1402
1397
|
}
|
|
1403
1398
|
trackCleanup(e, t) {
|
|
1404
1399
|
let n = this.getOrCreateRecord(e);
|
|
1405
|
-
n.cleanups ||=
|
|
1400
|
+
n.cleanups ||= et.acquire(), n.cleanups.push(t);
|
|
1406
1401
|
}
|
|
1407
1402
|
setComponentCleanup(e, t) {
|
|
1408
1403
|
this.getOrCreateRecord(e).componentCleanup = t;
|
|
@@ -1413,15 +1408,12 @@ var q = "_aes-bound", J = new class {
|
|
|
1413
1408
|
cleanup(e) {
|
|
1414
1409
|
let t = e.nodeType === 1, n = this.records.get(e);
|
|
1415
1410
|
if (this.preservedNodes.delete(e), this.ignoredNodes.delete(e), !n) {
|
|
1416
|
-
t && e.classList.remove(
|
|
1411
|
+
t && e.classList.remove(K);
|
|
1417
1412
|
return;
|
|
1418
1413
|
}
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
}
|
|
1423
|
-
let r = t ? B(e) : "Node";
|
|
1424
|
-
if (n.componentCleanup) try {
|
|
1414
|
+
this.records.delete(e), t && e.classList.remove(K);
|
|
1415
|
+
let r = t ? Pe(e) : e.nodeName || "Node";
|
|
1416
|
+
if (G.cleanup(H.BINDING, r), n.componentCleanup) try {
|
|
1425
1417
|
n.componentCleanup();
|
|
1426
1418
|
} catch (e) {
|
|
1427
1419
|
G.error(H.MOUNT, W.MOUNT.CLEANUP_ERROR(r), e);
|
|
@@ -1432,7 +1424,7 @@ var q = "_aes-bound", J = new class {
|
|
|
1432
1424
|
} catch (e) {
|
|
1433
1425
|
G.error(H.BINDING, W.CORE.EFFECT_DISPOSE_ERROR(r), e);
|
|
1434
1426
|
}
|
|
1435
|
-
|
|
1427
|
+
$e.release(n.effects), n.effects = void 0;
|
|
1436
1428
|
}
|
|
1437
1429
|
if (n.cleanups) {
|
|
1438
1430
|
for (let e of n.cleanups) try {
|
|
@@ -1440,174 +1432,181 @@ var q = "_aes-bound", J = new class {
|
|
|
1440
1432
|
} catch (e) {
|
|
1441
1433
|
G.error(H.BINDING, W.BINDING.CLEANUP_ERROR(r), e);
|
|
1442
1434
|
}
|
|
1443
|
-
|
|
1435
|
+
et.release(n.cleanups), n.cleanups = void 0;
|
|
1444
1436
|
}
|
|
1445
|
-
|
|
1437
|
+
tt.release(n);
|
|
1446
1438
|
}
|
|
1447
1439
|
cleanupDescendants(e) {
|
|
1448
|
-
let t = e.getElementsByClassName ? e.getElementsByClassName(
|
|
1449
|
-
if (n
|
|
1450
|
-
|
|
1451
|
-
|
|
1440
|
+
let t = e.getElementsByClassName ? e.getElementsByClassName(K) : e.querySelectorAll(`.${K}`), n = t.length;
|
|
1441
|
+
if (n === 0) return;
|
|
1442
|
+
let r = Array(n);
|
|
1443
|
+
for (let e = 0; e < n; e++) r[e] = t[e];
|
|
1444
|
+
for (let e = n - 1; e >= 0; e--) {
|
|
1445
|
+
let t = r[e];
|
|
1446
|
+
this.records.has(t) ? this.cleanup(t) : t.classList.remove(K);
|
|
1452
1447
|
}
|
|
1453
1448
|
}
|
|
1454
1449
|
cleanupTree(e) {
|
|
1455
1450
|
(e.nodeType === 1 || e.nodeType === 11) && this.cleanupDescendants(e), this.cleanup(e);
|
|
1456
1451
|
}
|
|
1457
|
-
}(),
|
|
1458
|
-
function
|
|
1459
|
-
if (
|
|
1452
|
+
}(), it = /* @__PURE__ */ new Map();
|
|
1453
|
+
function at(e) {
|
|
1454
|
+
if (it.has(e)) return;
|
|
1460
1455
|
let t = new MutationObserver((e) => {
|
|
1461
|
-
let t =
|
|
1456
|
+
let t = q;
|
|
1462
1457
|
for (let n = 0, r = e.length; n < r; n++) {
|
|
1463
1458
|
let r = e[n].removedNodes;
|
|
1464
1459
|
for (let e = 0, n = r.length; e < n; e++) {
|
|
1465
1460
|
let n = r[e];
|
|
1466
|
-
if (n.nodeType !== 1) continue;
|
|
1461
|
+
if (n.nodeType !== 1 || n.isConnected) continue;
|
|
1467
1462
|
let i = n;
|
|
1468
|
-
|
|
1463
|
+
t.isKept(i) || t.isIgnored(i) || t.cleanupTree(i);
|
|
1469
1464
|
}
|
|
1470
1465
|
}
|
|
1471
1466
|
});
|
|
1472
1467
|
t.observe(e, {
|
|
1473
1468
|
childList: !0,
|
|
1474
1469
|
subtree: !0
|
|
1475
|
-
}),
|
|
1470
|
+
}), it.set(e, t);
|
|
1476
1471
|
}
|
|
1477
|
-
function
|
|
1478
|
-
|
|
1472
|
+
function ot() {
|
|
1473
|
+
it.forEach((e) => e.disconnect()), it.clear();
|
|
1479
1474
|
}
|
|
1480
1475
|
//#endregion
|
|
1481
1476
|
//#region src/core/jquery-patch.ts
|
|
1482
|
-
var
|
|
1483
|
-
if (e[
|
|
1484
|
-
let t =
|
|
1477
|
+
var st = Symbol("atom-effect-internal"), ct = /* @__PURE__ */ new WeakMap(), J = null, lt = (e) => {
|
|
1478
|
+
if (e[st]) return e;
|
|
1479
|
+
let t = ct.get(e);
|
|
1485
1480
|
return t || (t = function(...t) {
|
|
1486
|
-
return
|
|
1487
|
-
}, t[
|
|
1481
|
+
return Me(() => e.apply(this, t));
|
|
1482
|
+
}, t[st] = !0, ct.set(e, t)), t;
|
|
1488
1483
|
};
|
|
1489
|
-
function
|
|
1484
|
+
function ut(e) {
|
|
1490
1485
|
let t = {};
|
|
1491
|
-
for (let n in e) e[n] && (t[n] =
|
|
1486
|
+
for (let n in e) e[n] && (t[n] = lt(e[n]));
|
|
1492
1487
|
return t;
|
|
1493
1488
|
}
|
|
1494
|
-
function
|
|
1489
|
+
function dt(e) {
|
|
1495
1490
|
let t = {};
|
|
1496
1491
|
for (let n in e) {
|
|
1497
1492
|
let r = e[n];
|
|
1498
|
-
t[n] = r ?
|
|
1493
|
+
t[n] = r ? ct.get(r) ?? r : void 0;
|
|
1499
1494
|
}
|
|
1500
1495
|
return t;
|
|
1501
1496
|
}
|
|
1502
|
-
function
|
|
1503
|
-
if (
|
|
1504
|
-
|
|
1497
|
+
function ft() {
|
|
1498
|
+
if (J !== null) return;
|
|
1499
|
+
J = {
|
|
1505
1500
|
on: e.fn.on,
|
|
1506
1501
|
off: e.fn.off,
|
|
1507
1502
|
remove: e.fn.remove,
|
|
1508
1503
|
empty: e.fn.empty,
|
|
1509
1504
|
detach: e.fn.detach
|
|
1510
1505
|
};
|
|
1511
|
-
let t =
|
|
1506
|
+
let t = J;
|
|
1512
1507
|
e.fn.remove = function(e) {
|
|
1513
1508
|
let n = e ? this.filter(e) : this, r = n.length;
|
|
1514
1509
|
for (let e = 0; e < r; e++) {
|
|
1515
1510
|
let t = n[e];
|
|
1516
|
-
t && (
|
|
1511
|
+
t && (q.markIgnored(t), q.cleanupTree(t));
|
|
1517
1512
|
}
|
|
1518
1513
|
return t.remove.call(this, e) ?? this;
|
|
1519
1514
|
}, e.fn.empty = function() {
|
|
1520
1515
|
let e = this.length;
|
|
1521
1516
|
for (let t = 0; t < e; t++) {
|
|
1522
1517
|
let e = this[t];
|
|
1523
|
-
e?.hasChildNodes() &&
|
|
1518
|
+
e?.hasChildNodes() && q.cleanupDescendants(e);
|
|
1524
1519
|
}
|
|
1525
1520
|
return t.empty.call(this) ?? this;
|
|
1526
1521
|
}, e.fn.detach = function(e) {
|
|
1527
1522
|
let n = e ? this.filter(e) : this, r = n.length;
|
|
1528
1523
|
for (let e = 0; e < r; e++) {
|
|
1529
1524
|
let t = n[e];
|
|
1530
|
-
t &&
|
|
1525
|
+
t && q.keep(t);
|
|
1531
1526
|
}
|
|
1532
1527
|
return t.detach.call(this, e) ?? this;
|
|
1533
1528
|
}, e.fn.on = function(...e) {
|
|
1534
1529
|
let n = e[0];
|
|
1535
|
-
if (n && typeof n == "object") e[0] =
|
|
1530
|
+
if (n && typeof n == "object") e[0] = ut(n);
|
|
1536
1531
|
else {
|
|
1537
1532
|
let t = e.length - 1;
|
|
1538
|
-
t >= 0 && typeof e[t] == "function" && (e[t] =
|
|
1533
|
+
t >= 0 && typeof e[t] == "function" && (e[t] = lt(e[t]));
|
|
1539
1534
|
}
|
|
1540
1535
|
return t.on.apply(this, e) ?? this;
|
|
1541
1536
|
}, e.fn.off = function(...e) {
|
|
1542
1537
|
let n = e[0];
|
|
1543
|
-
if (n && typeof n == "object") e[0] =
|
|
1538
|
+
if (n && typeof n == "object") e[0] = dt(n);
|
|
1544
1539
|
else {
|
|
1545
1540
|
let t = e.length - 1;
|
|
1546
1541
|
if (t >= 0 && typeof e[t] == "function") {
|
|
1547
1542
|
let n = e[t];
|
|
1548
|
-
e[t] =
|
|
1543
|
+
e[t] = ct.get(n) ?? n;
|
|
1549
1544
|
}
|
|
1550
1545
|
}
|
|
1551
1546
|
return t.off.apply(this, e) ?? this;
|
|
1552
1547
|
};
|
|
1553
1548
|
}
|
|
1554
|
-
function
|
|
1555
|
-
|
|
1549
|
+
function pt() {
|
|
1550
|
+
J !== null && (e.fn.on = J.on, e.fn.off = J.off, e.fn.remove = J.remove, e.fn.empty = J.empty, e.fn.detach = J.detach, J = null);
|
|
1556
1551
|
}
|
|
1557
1552
|
//#endregion
|
|
1558
1553
|
//#region src/types.ts
|
|
1559
|
-
var
|
|
1554
|
+
var Y = /* @__PURE__ */ function(e) {
|
|
1560
1555
|
return e[e.None = 0] = "None", e[e.Focused = 1] = "Focused", e[e.Composing = 2] = "Composing", e[e.SyncingToAtom = 4] = "SyncingToAtom", e[e.SyncingToDom = 8] = "SyncingToDom", e[e.Busy = 14] = "Busy", e;
|
|
1561
|
-
}({}),
|
|
1562
|
-
function
|
|
1563
|
-
e[
|
|
1556
|
+
}({}), mt = 0;
|
|
1557
|
+
function ht(e) {
|
|
1558
|
+
e[st] = !0;
|
|
1564
1559
|
}
|
|
1565
|
-
var
|
|
1560
|
+
var gt = class {
|
|
1566
1561
|
constructor(e, t, n) {
|
|
1567
1562
|
this.flags = 0, this.timeoutId = void 0, this.handleCompositionStart = () => {
|
|
1568
|
-
this.flags |=
|
|
1563
|
+
this.flags |= Y.Composing;
|
|
1569
1564
|
}, this.handleCompositionEnd = () => {
|
|
1570
|
-
this.flags &= ~
|
|
1565
|
+
this.flags &= ~Y.Composing, this.handleInput();
|
|
1571
1566
|
}, this.handleFocus = () => {
|
|
1572
|
-
this.flags |=
|
|
1567
|
+
this.flags |= Y.Focused;
|
|
1573
1568
|
}, this.handleBlur = () => {
|
|
1574
|
-
this.flags &= ~
|
|
1575
|
-
let e = !!(this.flags &
|
|
1576
|
-
this.flags &= ~
|
|
1569
|
+
this.flags &= ~Y.Focused;
|
|
1570
|
+
let e = !!(this.flags & Y.Composing);
|
|
1571
|
+
this.flags &= ~Y.Composing, this.flushPendingDebounce(), e && this.timeoutId === void 0 && this.syncAtomFromDom(), this.normalizeDomValue();
|
|
1577
1572
|
}, this.syncDomFromAtom = () => {
|
|
1578
1573
|
let e = this.atom.value;
|
|
1579
|
-
|
|
1580
|
-
let t = this.
|
|
1581
|
-
if (this.
|
|
1582
|
-
let i = !!(this.flags & X.Focused);
|
|
1583
|
-
if (i) try {
|
|
1584
|
-
let n = t ? r : this.parse(this.el.value);
|
|
1574
|
+
k(() => {
|
|
1575
|
+
let t = this.format(e), n = this.getRawDom();
|
|
1576
|
+
if (this.isMultipleSelect) {
|
|
1585
1577
|
if (this.equal(n, e)) return;
|
|
1578
|
+
} else if (n === t) return;
|
|
1579
|
+
if (this.flags & Y.Focused) try {
|
|
1580
|
+
if (this.equal(this.readDom(), e)) return;
|
|
1586
1581
|
} catch {}
|
|
1587
|
-
this.flags |=
|
|
1582
|
+
this.flags |= Y.SyncingToDom;
|
|
1588
1583
|
try {
|
|
1589
|
-
|
|
1590
|
-
else if (i && this.isTextControl) try {
|
|
1591
|
-
let e = this.el, t = e.selectionStart, r = e.selectionEnd;
|
|
1592
|
-
e.value = n;
|
|
1593
|
-
let i = n.length;
|
|
1594
|
-
t !== null && r !== null && e.setSelectionRange(t < i ? t : i, r < i ? r : i);
|
|
1595
|
-
} catch {
|
|
1596
|
-
this.el.value = n;
|
|
1597
|
-
}
|
|
1598
|
-
else this.el.value = n;
|
|
1599
|
-
G.enabled && G.domUpdated(H.BINDING, this.$el, "val", n);
|
|
1584
|
+
this.writeDom(e, t), G.domUpdated(H.BINDING, this.$el, "val", t);
|
|
1600
1585
|
} finally {
|
|
1601
|
-
this.flags &= ~
|
|
1586
|
+
this.flags &= ~Y.SyncingToDom;
|
|
1602
1587
|
}
|
|
1603
1588
|
});
|
|
1604
1589
|
}, this.cleanup = () => {
|
|
1605
1590
|
this.$el.off(this.ns), clearTimeout(this.timeoutId), this.timeoutId = void 0;
|
|
1606
1591
|
}, this.$el = e, this.el = e[0], this.atom = t;
|
|
1607
1592
|
let r = this.el.tagName, i = r === "SELECT" && this.el.multiple;
|
|
1608
|
-
this.isMultipleSelect = i, this.isTextControl = r === "INPUT" || r === "TEXTAREA", this.ns = `.atomBind-${++
|
|
1593
|
+
this.isMultipleSelect = i, this.isTextControl = r === "INPUT" || r === "TEXTAREA", this.ns = `.atomBind-${++mt}`;
|
|
1609
1594
|
let a = n.debounce ?? 0;
|
|
1610
|
-
this.parse = n.parse ?? ((e) => e), i ? this.format = n.format ?? ((e) => (Array.isArray(e) ? e : e ? [String(e)] : []).join(","))
|
|
1595
|
+
this.parse = n.parse ?? ((e) => e), i ? (this.format = n.format ?? ((e) => (Array.isArray(e) ? e : e ? [String(e)] : []).join(",")), this.getRawDom = () => this.$el.val() || [], this.readDom = () => this.getRawDom(), this.writeDom = (e) => {
|
|
1596
|
+
this.$el.val(e);
|
|
1597
|
+
}) : (this.format = n.format ?? ((e) => String(e ?? "")), this.getRawDom = () => this.el.value, this.readDom = () => this.parse(this.el.value), this.isTextControl ? this.writeDom = (e, t) => {
|
|
1598
|
+
if (this.flags & Y.Focused) try {
|
|
1599
|
+
let e = this.el, n = e.selectionStart, r = e.selectionEnd;
|
|
1600
|
+
e.value = t;
|
|
1601
|
+
let i = t.length;
|
|
1602
|
+
n !== null && r !== null && e.setSelectionRange(n < i ? n : i, r < i ? r : i);
|
|
1603
|
+
} catch {
|
|
1604
|
+
this.el.value = t;
|
|
1605
|
+
}
|
|
1606
|
+
else this.el.value = t;
|
|
1607
|
+
} : this.writeDom = (e, t) => {
|
|
1608
|
+
this.el.value = t;
|
|
1609
|
+
});
|
|
1611
1610
|
let o = n.equal ?? Object.is;
|
|
1612
1611
|
i ? this.equal = (e, t) => {
|
|
1613
1612
|
if (o(e, t)) return !0;
|
|
@@ -1619,37 +1618,34 @@ var _t = class {
|
|
|
1619
1618
|
}
|
|
1620
1619
|
return !1;
|
|
1621
1620
|
} : this.equal = o, a > 0 ? this.handleInput = () => {
|
|
1622
|
-
this.flags &
|
|
1621
|
+
this.flags & Y.Composing || (clearTimeout(this.timeoutId), this.timeoutId = setTimeout(() => this.syncAtomFromDom(), a));
|
|
1623
1622
|
} : this.handleInput = () => {
|
|
1624
|
-
this.flags &
|
|
1623
|
+
this.flags & Y.Composing || this.syncAtomFromDom();
|
|
1625
1624
|
}, [
|
|
1626
1625
|
this.handleFocus,
|
|
1627
1626
|
this.handleBlur,
|
|
1628
1627
|
this.handleCompositionStart,
|
|
1629
1628
|
this.handleCompositionEnd,
|
|
1630
1629
|
this.handleInput
|
|
1631
|
-
].forEach(
|
|
1630
|
+
].forEach(ht), this.bindEvents(n.event ?? Ie.EVENT);
|
|
1632
1631
|
}
|
|
1633
1632
|
flushPendingDebounce() {
|
|
1634
1633
|
this.timeoutId !== void 0 && (clearTimeout(this.timeoutId), this.timeoutId = void 0, this.syncAtomFromDom());
|
|
1635
1634
|
}
|
|
1636
1635
|
normalizeDomValue() {
|
|
1637
|
-
let e = this.atom.peek(), t = this.format(e);
|
|
1638
|
-
|
|
1639
|
-
let t = this.$el.val() || [], n = Array.isArray(e) ? e : [];
|
|
1640
|
-
this.equal(t, n) || this.$el.val(n);
|
|
1641
|
-
} else this.el.value !== t && (this.el.value = t);
|
|
1636
|
+
let e = this.atom.peek(), t = this.format(e), n = this.getRawDom();
|
|
1637
|
+
this.isMultipleSelect ? this.equal(n, e) || this.writeDom(e, t) : n !== t && this.writeDom(e, t);
|
|
1642
1638
|
}
|
|
1643
1639
|
syncAtomFromDom() {
|
|
1644
|
-
if (!(this.flags &
|
|
1645
|
-
this.flags |=
|
|
1640
|
+
if (!(this.flags & Y.Busy)) {
|
|
1641
|
+
this.flags |= Y.SyncingToAtom;
|
|
1646
1642
|
try {
|
|
1647
|
-
let e = this.
|
|
1648
|
-
this.equal(this.atom.peek(),
|
|
1643
|
+
let e = this.readDom();
|
|
1644
|
+
this.equal(this.atom.peek(), e) || (this.atom.value = e);
|
|
1649
1645
|
} catch (e) {
|
|
1650
1646
|
G.warn(H.BINDING, W.BINDING.PARSE_ERROR(e instanceof Error ? e.message : String(e)), e);
|
|
1651
1647
|
} finally {
|
|
1652
|
-
this.flags &= ~
|
|
1648
|
+
this.flags &= ~Y.SyncingToAtom;
|
|
1653
1649
|
}
|
|
1654
1650
|
}
|
|
1655
1651
|
}
|
|
@@ -1658,8 +1654,8 @@ var _t = class {
|
|
|
1658
1654
|
this.$el.on(`focus${t}`, this.handleFocus).on(`blur${t}`, this.handleBlur).on(`compositionstart${t}`, this.handleCompositionStart).on(`compositionend${t}`, this.handleCompositionEnd).on(n, this.handleInput);
|
|
1659
1655
|
}
|
|
1660
1656
|
};
|
|
1661
|
-
function
|
|
1662
|
-
let r = new
|
|
1657
|
+
function _t(e, t, n) {
|
|
1658
|
+
let r = new gt(e, t, n);
|
|
1663
1659
|
return {
|
|
1664
1660
|
fx: R(r.syncDomFromAtom),
|
|
1665
1661
|
cleanup: () => {
|
|
@@ -1669,21 +1665,21 @@ function vt(e, t, n) {
|
|
|
1669
1665
|
}
|
|
1670
1666
|
//#endregion
|
|
1671
1667
|
//#region src/core/effect-factory.ts
|
|
1672
|
-
function
|
|
1668
|
+
function vt(e, t, n, r) {
|
|
1673
1669
|
let i = null, a = (t) => {
|
|
1674
|
-
if (!
|
|
1670
|
+
if (!Ne(t)) {
|
|
1675
1671
|
i = null;
|
|
1676
1672
|
try {
|
|
1677
|
-
n(t), G.
|
|
1673
|
+
n(t), G.domUpdated(H.BINDING, e, r, t);
|
|
1678
1674
|
} catch (e) {
|
|
1679
1675
|
G.error(H.BINDING, W.BINDING.UPDATER_ERROR(r, !0), e);
|
|
1680
1676
|
}
|
|
1681
1677
|
return;
|
|
1682
1678
|
}
|
|
1683
1679
|
i = t, t.then((a) => {
|
|
1684
|
-
i === t &&
|
|
1680
|
+
i === t && k(() => {
|
|
1685
1681
|
try {
|
|
1686
|
-
n(a), G.
|
|
1682
|
+
n(a), G.domUpdated(H.BINDING, e, `${r} (async)`, a);
|
|
1687
1683
|
} catch (e) {
|
|
1688
1684
|
G.error(H.BINDING, W.BINDING.UPDATER_ERROR(r), e);
|
|
1689
1685
|
}
|
|
@@ -1691,39 +1687,39 @@ function yt(e, t, n, r) {
|
|
|
1691
1687
|
}).catch((e) => {
|
|
1692
1688
|
i === t && G.error(H.BINDING, W.BINDING.UPDATER_ERROR(r), e);
|
|
1693
1689
|
});
|
|
1694
|
-
}, o =
|
|
1695
|
-
o || typeof t == "function" ?
|
|
1690
|
+
}, o = B(t);
|
|
1691
|
+
o || typeof t == "function" ? q.trackEffect(e, R(() => {
|
|
1696
1692
|
let e = o ? t.value : t();
|
|
1697
|
-
|
|
1698
|
-
}, { name: r })) :
|
|
1693
|
+
k(() => a(e));
|
|
1694
|
+
}, { name: r })) : k(() => a(t));
|
|
1699
1695
|
}
|
|
1700
|
-
function
|
|
1701
|
-
let i = Object.keys(t), a = [], o = {};
|
|
1696
|
+
function yt(e, t, n, r) {
|
|
1697
|
+
let i = Object.keys(t), a = [], o = [], s = [], c = {};
|
|
1702
1698
|
for (let e = 0, n = i.length; e < n; e++) {
|
|
1703
|
-
let n = i[e], r = t[n];
|
|
1704
|
-
|
|
1699
|
+
let n = i[e], r = t[n], l = B(r);
|
|
1700
|
+
l || typeof r == "function" ? (a.push(n), o.push(r), s.push(l)) : c[n] = r;
|
|
1705
1701
|
}
|
|
1706
|
-
let
|
|
1707
|
-
let a = [], o = {},
|
|
1708
|
-
for (let e = 0; e <
|
|
1702
|
+
let l = 0, u = (t) => {
|
|
1703
|
+
let a = [], o = {}, s = i.length;
|
|
1704
|
+
for (let e = 0; e < s; e++) {
|
|
1709
1705
|
let n = i[e], r = t[n];
|
|
1710
|
-
|
|
1706
|
+
Ne(r) ? a.push(r.then((e) => ({
|
|
1711
1707
|
key: n,
|
|
1712
1708
|
val: e
|
|
1713
1709
|
}))) : o[n] = r;
|
|
1714
1710
|
}
|
|
1715
|
-
let
|
|
1716
|
-
if (
|
|
1717
|
-
let t = ++
|
|
1711
|
+
let c = a.length;
|
|
1712
|
+
if (c > 0) {
|
|
1713
|
+
let t = ++l;
|
|
1718
1714
|
Promise.all(a).then((i) => {
|
|
1719
|
-
if (t ===
|
|
1720
|
-
for (let e = 0; e <
|
|
1715
|
+
if (t === l) {
|
|
1716
|
+
for (let e = 0; e < c; e++) {
|
|
1721
1717
|
let t = i[e];
|
|
1722
1718
|
o[t.key] = t.val;
|
|
1723
1719
|
}
|
|
1724
|
-
|
|
1720
|
+
k(() => {
|
|
1725
1721
|
try {
|
|
1726
|
-
n(o), G.
|
|
1722
|
+
n(o), G.domUpdated(H.BINDING, e, `${r} (async)`, o);
|
|
1727
1723
|
} catch (e) {
|
|
1728
1724
|
G.error(H.BINDING, W.BINDING.UPDATER_ERROR(r), e);
|
|
1729
1725
|
}
|
|
@@ -1731,26 +1727,26 @@ function bt(e, t, n, r) {
|
|
|
1731
1727
|
}
|
|
1732
1728
|
});
|
|
1733
1729
|
} else {
|
|
1734
|
-
|
|
1730
|
+
l++;
|
|
1735
1731
|
try {
|
|
1736
|
-
n(o), G.
|
|
1732
|
+
n(o), G.domUpdated(H.BINDING, e, r, o);
|
|
1737
1733
|
} catch (e) {
|
|
1738
1734
|
G.error(H.BINDING, W.BINDING.UPDATER_ERROR(r, !0), e);
|
|
1739
1735
|
}
|
|
1740
1736
|
}
|
|
1741
1737
|
};
|
|
1742
|
-
a.length > 0 ?
|
|
1743
|
-
let e = { ...
|
|
1744
|
-
for (let
|
|
1745
|
-
let
|
|
1746
|
-
e[
|
|
1747
|
-
}
|
|
1748
|
-
|
|
1749
|
-
}, { name: r })) :
|
|
1738
|
+
a.length > 0 ? q.trackEffect(e, R(() => {
|
|
1739
|
+
let e = { ...c };
|
|
1740
|
+
for (let t = 0, n = a.length; t < n; t++) {
|
|
1741
|
+
let n = o[t];
|
|
1742
|
+
e[a[t]] = s[t] ? n.value : n();
|
|
1743
|
+
}
|
|
1744
|
+
k(() => u(e));
|
|
1745
|
+
}, { name: r })) : k(() => u(c));
|
|
1750
1746
|
}
|
|
1751
1747
|
//#endregion
|
|
1752
1748
|
//#region src/utils/sanitize.ts
|
|
1753
|
-
var
|
|
1749
|
+
var bt = new Set([
|
|
1754
1750
|
"href",
|
|
1755
1751
|
"src",
|
|
1756
1752
|
"action",
|
|
@@ -1765,24 +1761,40 @@ var xt = new Set([
|
|
|
1765
1761
|
"usemap",
|
|
1766
1762
|
"classid",
|
|
1767
1763
|
"codebase"
|
|
1768
|
-
]),
|
|
1764
|
+
]), xt = /^\s*(?:javascript|vbscript)\s*:/i, St = /(?:expression\s*\(|behavior\s*:|-moz-binding\s*:|(?:\\[0-9a-f]{1,6}\s*|[\s\x00-\x20/'"])*(?:j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t|d\s*a\s*t\s*a)\s*:(?!image\/))/i, Ct = /url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i, wt = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, Tt = /&#x([0-9a-f]+);?|&#([0-9]+);?/gi, Et = {
|
|
1769
1765
|
colon: ":",
|
|
1770
1766
|
Tab: " ",
|
|
1771
1767
|
NewLine: "\n"
|
|
1772
|
-
},
|
|
1773
|
-
function
|
|
1768
|
+
}, Dt = /&(colon|Tab|NewLine);/g, Ot = /<\?[\s\S]*?\?>/g, kt = /(<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*>([\s\S]*?)<\/\2>|<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*\/?>)/gi, At = /(j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t)\s*:/gi, jt = /data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/gi, Mt = /\bon\w+\s*=/gim, Nt = new RegExp(St.source, "gim");
|
|
1769
|
+
function Pt(e) {
|
|
1770
|
+
let t = e.length;
|
|
1771
|
+
for (let n = 0; n < t; n++) {
|
|
1772
|
+
let t = e.charCodeAt(n);
|
|
1773
|
+
if (t === 60 || t === 38 || t <= 31 && t !== 9 && t !== 10 && t !== 13) return !0;
|
|
1774
|
+
}
|
|
1775
|
+
if (e.indexOf(":") !== -1) return !0;
|
|
1776
|
+
let n = e.toLowerCase(), r = n.indexOf("on");
|
|
1777
|
+
if (r !== -1 && r < t - 2) {
|
|
1778
|
+
let e = n.charCodeAt(r + 2);
|
|
1779
|
+
if (e >= 97 && e <= 122) return !0;
|
|
1780
|
+
}
|
|
1781
|
+
return !1;
|
|
1782
|
+
}
|
|
1783
|
+
function X(e) {
|
|
1774
1784
|
if (!e) return "";
|
|
1775
|
-
let t = String(e)
|
|
1776
|
-
if (t
|
|
1777
|
-
|
|
1785
|
+
let t = String(e);
|
|
1786
|
+
if (!Pt(t)) return t;
|
|
1787
|
+
let n = t.replace(wt, "").replace(Tt, (e, t, n) => String.fromCodePoint(t ? parseInt(t, 16) : parseInt(n, 10))).replace(Dt, (e, t) => Et[t] ?? "");
|
|
1788
|
+
if (n.indexOf("<") !== -1) {
|
|
1789
|
+
n = n.replace(Ot, "");
|
|
1778
1790
|
let e;
|
|
1779
1791
|
do
|
|
1780
|
-
e =
|
|
1781
|
-
while (
|
|
1792
|
+
e = n, n = n.replace(kt, "");
|
|
1793
|
+
while (n !== e);
|
|
1782
1794
|
}
|
|
1783
|
-
return
|
|
1795
|
+
return n.replace(At, "data-unsafe-protocol:").replace(jt, "data-unsafe-protocol:").replace(Mt, "data-unsafe-attr=").replace(Nt, "data-unsafe-css:");
|
|
1784
1796
|
}
|
|
1785
|
-
var Ft = (e) => e.length < 15 ? !1 : e.toLowerCase().includes("url(") &&
|
|
1797
|
+
var Ft = (e) => e.length < 15 ? !1 : e.toLowerCase().includes("url(") && Ct.test(e), It = /* @__PURE__ */ new Map();
|
|
1786
1798
|
function Lt(e) {
|
|
1787
1799
|
let t = It.get(e);
|
|
1788
1800
|
return t === void 0 ? (t = e.includes("-") ? e.replace(/-./g, (e) => e[1].toUpperCase()) : e, It.set(e, t), t) : t;
|
|
@@ -1792,26 +1804,26 @@ function zt(e) {
|
|
|
1792
1804
|
let t = Rt.get(e);
|
|
1793
1805
|
return t || (t = L(() => {
|
|
1794
1806
|
let t = e.value;
|
|
1795
|
-
return
|
|
1807
|
+
return Ne(t) ? t.then((e) => X(e)) : X(t);
|
|
1796
1808
|
}), Rt.set(e, t)), t;
|
|
1797
1809
|
}
|
|
1798
1810
|
function Bt(e) {
|
|
1799
1811
|
return {
|
|
1800
1812
|
el: e,
|
|
1801
|
-
trackCleanup: (t) =>
|
|
1813
|
+
trackCleanup: (t) => q.trackCleanup(e, t)
|
|
1802
1814
|
};
|
|
1803
1815
|
}
|
|
1804
1816
|
function Vt({ el: e }, t, n) {
|
|
1805
|
-
|
|
1817
|
+
vt(e, t, (t) => {
|
|
1806
1818
|
let r = n ? n(t) : String(t ?? "");
|
|
1807
1819
|
e.textContent !== r && (e.textContent = r);
|
|
1808
1820
|
}, "text");
|
|
1809
1821
|
}
|
|
1810
1822
|
function Ht({ el: e }, t) {
|
|
1811
|
-
let n =
|
|
1812
|
-
|
|
1813
|
-
let i = n === t ?
|
|
1814
|
-
e.innerHTML !== i && (
|
|
1823
|
+
let n = _e(t) ? zt(t) : t;
|
|
1824
|
+
vt(e, n, (r) => {
|
|
1825
|
+
let i = n === t ? X(r) : r;
|
|
1826
|
+
e.innerHTML !== i && (q.cleanupDescendants(e), e.innerHTML = i);
|
|
1815
1827
|
}, "html");
|
|
1816
1828
|
}
|
|
1817
1829
|
function Ut({ el: e }, t) {
|
|
@@ -1820,7 +1832,7 @@ function Ut({ el: e }, t) {
|
|
|
1820
1832
|
let t = e.trim();
|
|
1821
1833
|
n[e] = t.indexOf(" ") === -1 ? [t] : t.split(/\s+/).filter(Boolean);
|
|
1822
1834
|
}
|
|
1823
|
-
|
|
1835
|
+
yt(e, t, (t) => {
|
|
1824
1836
|
for (let r in t) {
|
|
1825
1837
|
let i = n[r];
|
|
1826
1838
|
t[r] ? e.classList.add(...i) : e.classList.remove(...i);
|
|
@@ -1836,7 +1848,7 @@ function Wt({ el: e }, t) {
|
|
|
1836
1848
|
unit: o
|
|
1837
1849
|
};
|
|
1838
1850
|
}
|
|
1839
|
-
|
|
1851
|
+
yt(e, r, (e) => {
|
|
1840
1852
|
for (let t in e) {
|
|
1841
1853
|
let r = i[t], a = e[t], o = r.unit ? `${a}${r.unit}` : String(a), s = r.camel;
|
|
1842
1854
|
!Ft(o) && n[s] !== o && (n[s] = o);
|
|
@@ -1854,10 +1866,10 @@ function Gt({ el: e }, t) {
|
|
|
1854
1866
|
}
|
|
1855
1867
|
n[a] = t[a], r[a] = {
|
|
1856
1868
|
isAria: o.startsWith("aria-"),
|
|
1857
|
-
isUrl:
|
|
1869
|
+
isUrl: bt.has(o)
|
|
1858
1870
|
}, i[a] = e.getAttribute(a);
|
|
1859
1871
|
}
|
|
1860
|
-
|
|
1872
|
+
yt(e, n, (t) => {
|
|
1861
1873
|
for (let n in t) {
|
|
1862
1874
|
let a = r[n], o = t[n];
|
|
1863
1875
|
if (o == null || o === !1 && !a.isAria) {
|
|
@@ -1865,7 +1877,7 @@ function Gt({ el: e }, t) {
|
|
|
1865
1877
|
continue;
|
|
1866
1878
|
}
|
|
1867
1879
|
let s = o === !0 ? a.isAria ? "true" : n : String(o);
|
|
1868
|
-
if (a.isUrl &&
|
|
1880
|
+
if (a.isUrl && xt.test(s)) {
|
|
1869
1881
|
console.warn(`${H.BINDING} ${W.SECURITY.BLOCKED_PROTOCOL(n)}`);
|
|
1870
1882
|
continue;
|
|
1871
1883
|
}
|
|
@@ -1878,16 +1890,16 @@ function Kt(e, t) {
|
|
|
1878
1890
|
for (let e in t) {
|
|
1879
1891
|
if (!V.call(t, e)) continue;
|
|
1880
1892
|
let n = e.toLowerCase();
|
|
1881
|
-
if (n.startsWith("on") ||
|
|
1893
|
+
if (n.startsWith("on") || ze.has(e)) {
|
|
1882
1894
|
console.warn(`${H.BINDING} ${n.startsWith("on") ? W.SECURITY.BLOCKED_EVENT_HANDLER(e) : W.SECURITY.BLOCKED_PROP(e)}`);
|
|
1883
1895
|
continue;
|
|
1884
1896
|
}
|
|
1885
|
-
r[e] = t[e], i[e] = { isUrl:
|
|
1897
|
+
r[e] = t[e], i[e] = { isUrl: bt.has(n) };
|
|
1886
1898
|
}
|
|
1887
|
-
|
|
1899
|
+
yt(e.el, r, (e) => {
|
|
1888
1900
|
for (let t in e) {
|
|
1889
1901
|
let r = e[t];
|
|
1890
|
-
if (i[t].isUrl && typeof r == "string" &&
|
|
1902
|
+
if (i[t].isUrl && typeof r == "string" && xt.test(r)) {
|
|
1891
1903
|
console.warn(`${H.BINDING} ${W.SECURITY.BLOCKED_PROTOCOL(t)}`);
|
|
1892
1904
|
continue;
|
|
1893
1905
|
}
|
|
@@ -1897,28 +1909,28 @@ function Kt(e, t) {
|
|
|
1897
1909
|
}
|
|
1898
1910
|
function qt({ el: e }, t, n) {
|
|
1899
1911
|
let r = e.style.display === "none" ? "" : e.style.display;
|
|
1900
|
-
|
|
1912
|
+
vt(e, t, (t) => {
|
|
1901
1913
|
let i = n === !!t ? "none" : r;
|
|
1902
1914
|
e.style.display !== i && (e.style.display = i);
|
|
1903
1915
|
}, n ? "hide" : "show");
|
|
1904
1916
|
}
|
|
1905
1917
|
function Jt(t, n, r = {}) {
|
|
1906
1918
|
let i = t.el.tagName.toLowerCase();
|
|
1907
|
-
if (!
|
|
1919
|
+
if (!Re.has(i)) {
|
|
1908
1920
|
console.warn(`${H.BINDING} ${W.BINDING.INVALID_INPUT_ELEMENT(i)}`);
|
|
1909
1921
|
return;
|
|
1910
1922
|
}
|
|
1911
|
-
let { fx: a, cleanup: o } =
|
|
1912
|
-
|
|
1923
|
+
let { fx: a, cleanup: o } = _t(e(t.el), n, r);
|
|
1924
|
+
q.trackEffect(t.el, a), t.trackCleanup(o);
|
|
1913
1925
|
}
|
|
1914
1926
|
function Yt(t, n) {
|
|
1915
1927
|
let r = t.el, i = e(r), a = () => {
|
|
1916
1928
|
n.peek() !== r.checked && (n.value = r.checked, r.type === "radio" && r.checked && r.name && (r.form ? e(r.form) : e(document)).find(`input[type="radio"][name="${r.name.replace(/"/g, "\\\"")}"]`).not(r).trigger("change.atomRadioSync"));
|
|
1917
1929
|
};
|
|
1918
|
-
a[
|
|
1930
|
+
a[st] = !0, i.on("change change.atomRadioSync", a), t.trackCleanup(() => i.off("change change.atomRadioSync", a)), q.trackEffect(r, R(() => {
|
|
1919
1931
|
let e = !!n.value;
|
|
1920
|
-
|
|
1921
|
-
r.checked !== e && (r.checked = e, G.
|
|
1932
|
+
k(() => {
|
|
1933
|
+
r.checked !== e && (r.checked = e, G.domUpdated(H.BINDING, r, "checked", e));
|
|
1922
1934
|
});
|
|
1923
1935
|
}));
|
|
1924
1936
|
}
|
|
@@ -1931,30 +1943,30 @@ function Zt({ el: t, trackCleanup: n }, r, i) {
|
|
|
1931
1943
|
a.on(r, i), n(() => a.off(r, i));
|
|
1932
1944
|
}
|
|
1933
1945
|
function Qt(e) {
|
|
1934
|
-
|
|
1946
|
+
q.cleanupTree(e);
|
|
1935
1947
|
}
|
|
1936
1948
|
//#endregion
|
|
1937
1949
|
//#region src/bindings/form.ts
|
|
1938
1950
|
function $t(e, t, n = {}) {
|
|
1939
1951
|
let r = /* @__PURE__ */ new Map(), i = [], a = R(() => {
|
|
1940
1952
|
let e = t.value, n = i.length;
|
|
1941
|
-
n !== 0 &&
|
|
1953
|
+
n !== 0 && k(() => {
|
|
1942
1954
|
for (let t = 0; t < n; t++) {
|
|
1943
|
-
let n = i[t], r =
|
|
1955
|
+
let n = i[t], r = z(e, n.parts);
|
|
1944
1956
|
Object.is(n.atom.peek(), r) || (n.atom.value = r);
|
|
1945
1957
|
}
|
|
1946
1958
|
});
|
|
1947
1959
|
});
|
|
1948
|
-
|
|
1960
|
+
q.trackEffect(e, a);
|
|
1949
1961
|
let o = (n) => {
|
|
1950
1962
|
let a = r.get(n);
|
|
1951
1963
|
if (!a) {
|
|
1952
1964
|
let o = n.includes(".") ? n.split(".") : [n];
|
|
1953
|
-
a =
|
|
1965
|
+
a = A(z(t.peek(), o)), i.push({
|
|
1954
1966
|
atom: a,
|
|
1955
1967
|
parts: o
|
|
1956
|
-
}),
|
|
1957
|
-
let e = a.value, n = t.peek(), r =
|
|
1968
|
+
}), q.trackEffect(e, R(() => {
|
|
1969
|
+
let e = a.value, n = t.peek(), r = Oe(n, o, 0, e);
|
|
1958
1970
|
r !== n && (t.value = r);
|
|
1959
1971
|
})), r.set(n, a);
|
|
1960
1972
|
}
|
|
@@ -1962,7 +1974,7 @@ function $t(e, t, n = {}) {
|
|
|
1962
1974
|
}, s = (e) => {
|
|
1963
1975
|
if (!(e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement)) return;
|
|
1964
1976
|
let t = e.name;
|
|
1965
|
-
if (!t ||
|
|
1977
|
+
if (!t || q.hasBind(e)) return;
|
|
1966
1978
|
let r = o(t), i = Bt(e);
|
|
1967
1979
|
e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") ? Yt(i, r) : Jt(i, r, n);
|
|
1968
1980
|
};
|
|
@@ -1987,77 +1999,95 @@ function $t(e, t, n = {}) {
|
|
|
1987
1999
|
subtree: !0,
|
|
1988
2000
|
attributes: !0,
|
|
1989
2001
|
attributeFilter: ["name"]
|
|
1990
|
-
}),
|
|
2002
|
+
}), q.trackCleanup(e, () => c.disconnect());
|
|
1991
2003
|
}
|
|
1992
2004
|
//#endregion
|
|
1993
2005
|
//#region src/bindings/chainable.ts
|
|
1994
|
-
function
|
|
2006
|
+
function Z(e, t) {
|
|
1995
2007
|
let n = e.length;
|
|
1996
2008
|
for (let r = 0; r < n; r++) {
|
|
1997
2009
|
let n = e[r];
|
|
1998
2010
|
if (n?.nodeType === 1) {
|
|
1999
2011
|
let e = n;
|
|
2000
2012
|
t(Bt(e), e);
|
|
2001
|
-
} else
|
|
2013
|
+
} else n && G.log(H.BINDING, `Skipping non-Element node (nodeType=${n.nodeType})`);
|
|
2002
2014
|
}
|
|
2003
2015
|
return e;
|
|
2004
2016
|
}
|
|
2005
2017
|
e.fn.atomText = function(e, t) {
|
|
2006
|
-
return
|
|
2018
|
+
return Z(this, (n) => Vt(n, e, t));
|
|
2007
2019
|
}, e.fn.atomHtml = function(e) {
|
|
2008
|
-
return
|
|
2020
|
+
return Z(this, (t) => Ht(t, e));
|
|
2009
2021
|
}, e.fn.atomClass = function(e, t) {
|
|
2010
2022
|
if (typeof e == "string") {
|
|
2011
2023
|
if (t === void 0) return console.warn(`${H.BINDING} ${W.BINDING.MISSING_CONDITION("atomClass")}`), this;
|
|
2012
2024
|
let n = { [e]: t };
|
|
2013
|
-
return
|
|
2025
|
+
return Z(this, (e) => Ut(e, n));
|
|
2014
2026
|
}
|
|
2015
|
-
return
|
|
2027
|
+
return Z(this, (t) => Ut(t, e));
|
|
2016
2028
|
}, e.fn.atomCss = function(e, t, n) {
|
|
2017
2029
|
if (typeof e == "string") {
|
|
2018
2030
|
if (t === void 0) return console.warn(`${H.BINDING} ${W.BINDING.MISSING_SOURCE("atomCss")}`), this;
|
|
2019
2031
|
let r = { [e]: n ? [t, n] : t };
|
|
2020
|
-
return
|
|
2032
|
+
return Z(this, (e) => Wt(e, r));
|
|
2021
2033
|
}
|
|
2022
|
-
return
|
|
2034
|
+
return Z(this, (t) => Wt(t, e));
|
|
2023
2035
|
}, e.fn.atomAttr = function(e, t) {
|
|
2024
2036
|
if (typeof e == "string") {
|
|
2025
2037
|
if (t === void 0) return console.warn(`${H.BINDING} ${W.BINDING.MISSING_SOURCE("atomAttr")}`), this;
|
|
2026
2038
|
let n = { [e]: t };
|
|
2027
|
-
return
|
|
2039
|
+
return Z(this, (e) => Gt(e, n));
|
|
2028
2040
|
}
|
|
2029
|
-
return
|
|
2041
|
+
return Z(this, (t) => Gt(t, e));
|
|
2030
2042
|
}, e.fn.atomProp = function(e, t) {
|
|
2031
2043
|
if (typeof e == "string") {
|
|
2032
2044
|
if (t === void 0) return console.warn(`${H.BINDING} ${W.BINDING.MISSING_SOURCE("atomProp")}`), this;
|
|
2033
2045
|
let n = { [e]: t };
|
|
2034
|
-
return
|
|
2046
|
+
return Z(this, (e) => Kt(e, n));
|
|
2035
2047
|
}
|
|
2036
|
-
return
|
|
2048
|
+
return Z(this, (t) => Kt(t, e));
|
|
2037
2049
|
}, e.fn.atomShow = function(e) {
|
|
2038
|
-
return
|
|
2050
|
+
return Z(this, (t) => qt(t, e, !1));
|
|
2039
2051
|
}, e.fn.atomHide = function(e) {
|
|
2040
|
-
return
|
|
2052
|
+
return Z(this, (t) => qt(t, e, !0));
|
|
2041
2053
|
}, e.fn.atomVal = function(e, t = {}) {
|
|
2042
|
-
return
|
|
2054
|
+
return Z(this, (n) => Jt(n, e, t));
|
|
2043
2055
|
}, e.fn.atomChecked = function(e) {
|
|
2044
|
-
return
|
|
2056
|
+
return Z(this, (t) => Yt(t, e));
|
|
2045
2057
|
}, e.fn.atomForm = function(e, t = {}) {
|
|
2046
|
-
return
|
|
2058
|
+
return Z(this, (n, r) => {
|
|
2047
2059
|
r instanceof HTMLFormElement && $t(r, e, t);
|
|
2048
2060
|
});
|
|
2049
2061
|
}, e.fn.atomOn = function(e, t) {
|
|
2050
|
-
return
|
|
2051
|
-
}
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2062
|
+
return Z(this, (n) => Zt(n, e, t));
|
|
2063
|
+
};
|
|
2064
|
+
var en = [
|
|
2065
|
+
(e, t) => Vt(e, t.text),
|
|
2066
|
+
(e, t) => Ht(e, t.html),
|
|
2067
|
+
(e, t) => Ut(e, t.class),
|
|
2068
|
+
(e, t) => Wt(e, t.css),
|
|
2069
|
+
(e, t) => Gt(e, t.attr),
|
|
2070
|
+
(e, t) => Kt(e, t.prop),
|
|
2071
|
+
(e, t) => qt(e, t.show, !1),
|
|
2072
|
+
(e, t) => qt(e, t.hide, !0),
|
|
2073
|
+
(e, t) => {
|
|
2074
|
+
let n = t.val;
|
|
2075
|
+
Array.isArray(n) ? Jt(e, n[0], n[1]) : Jt(e, n);
|
|
2076
|
+
},
|
|
2077
|
+
(e, t) => Yt(e, t.checked),
|
|
2078
|
+
(e, t) => {
|
|
2079
|
+
e.el instanceof HTMLFormElement && $t(e.el, t.form);
|
|
2080
|
+
},
|
|
2081
|
+
(e, t) => Xt(e, t.on)
|
|
2082
|
+
];
|
|
2083
|
+
e.fn.atomBind = function(e) {
|
|
2084
|
+
let t = 0;
|
|
2085
|
+
return e.text !== void 0 && (t |= 1), e.html !== void 0 && (t |= 2), e.class !== void 0 && (t |= 4), e.css !== void 0 && (t |= 8), e.attr !== void 0 && (t |= 16), e.prop !== void 0 && (t |= 32), e.show !== void 0 && (t |= 64), e.hide !== void 0 && (t |= 128), e.val !== void 0 && (t |= 256), e.checked !== void 0 && (t |= 512), e.form !== void 0 && (t |= 1024), e.on !== void 0 && (t |= 2048), t === 0 ? this : Z(this, (n) => {
|
|
2086
|
+
let r = t;
|
|
2087
|
+
for (; r > 0;) {
|
|
2088
|
+
let t = r & -r;
|
|
2089
|
+
en[31 - Math.clz32(t)](n, e), r ^= t;
|
|
2090
|
+
}
|
|
2061
2091
|
});
|
|
2062
2092
|
}, e.fn.atomUnbind = function() {
|
|
2063
2093
|
let e = this.length;
|
|
@@ -2069,8 +2099,8 @@ e.fn.atomText = function(e, t) {
|
|
|
2069
2099
|
};
|
|
2070
2100
|
//#endregion
|
|
2071
2101
|
//#region src/bindings/list.ts
|
|
2072
|
-
var
|
|
2073
|
-
function
|
|
2102
|
+
var tn = /* @__PURE__ */ new WeakMap(), nn = 0, rn = new Qe(() => /* @__PURE__ */ new Map(), (e) => e.clear()), an = new Qe(() => /* @__PURE__ */ new Set(), (e) => e.clear()), Q = new Ze(100, 1024);
|
|
2103
|
+
function on(e, t, n) {
|
|
2074
2104
|
if (e instanceof Element) {
|
|
2075
2105
|
n.insertBefore(e, t);
|
|
2076
2106
|
return;
|
|
@@ -2081,7 +2111,7 @@ function an(e, t, n) {
|
|
|
2081
2111
|
r && n.insertBefore(r, t);
|
|
2082
2112
|
}
|
|
2083
2113
|
}
|
|
2084
|
-
function
|
|
2114
|
+
function $(t) {
|
|
2085
2115
|
return t instanceof Element ? e(t) : t;
|
|
2086
2116
|
}
|
|
2087
2117
|
var sn = class {
|
|
@@ -2090,7 +2120,7 @@ var sn = class {
|
|
|
2090
2120
|
}
|
|
2091
2121
|
scheduleRemoval(e, t) {
|
|
2092
2122
|
let n = () => {
|
|
2093
|
-
this.fx?.isDisposed || (t[0]?.isConnected && t.remove(), this.removingKeys.delete(e), G.
|
|
2123
|
+
this.fx?.isDisposed || (t[0]?.isConnected && t.remove(), this.removingKeys.delete(e), G.log(H.LIST, `${this.containerSelector} removed item:`, e));
|
|
2094
2124
|
}, r = this.onRemove?.(t);
|
|
2095
2125
|
r instanceof Promise ? r.then(n, n) : n();
|
|
2096
2126
|
}
|
|
@@ -2110,16 +2140,16 @@ function cn(t, n, r, i) {
|
|
|
2110
2140
|
let { oldKeys: a, oldNodes: o, onRemove: s } = t;
|
|
2111
2141
|
if (s) for (let e = 0, n = a.length; e < n; e++) {
|
|
2112
2142
|
let n = a[e];
|
|
2113
|
-
o[e] && t.removeItem(n,
|
|
2143
|
+
o[e] && t.removeItem(n, $(o[e]));
|
|
2114
2144
|
}
|
|
2115
2145
|
else {
|
|
2116
2146
|
for (let e = 0, n = a.length; e < n; e++) t.removingKeys.delete(a[e]);
|
|
2117
2147
|
r.empty();
|
|
2118
2148
|
}
|
|
2119
|
-
i && !t.$emptyEl && (t.$emptyEl = e(typeof i == "string" ?
|
|
2149
|
+
i && !t.$emptyEl && (t.$emptyEl = e(typeof i == "string" ? X(i) : i), t.$emptyEl.appendTo(r)), Q.release(t.oldKeys), Q.release(t.oldItems), Q.release(t.oldNodes), t.oldKeys = [], t.oldItems = [], t.oldNodes = [];
|
|
2120
2150
|
}
|
|
2121
2151
|
function ln(e, t, n, r, i, a) {
|
|
2122
|
-
let { oldKeys: o, oldItems: s, oldNodes: c, removingKeys: l, keyToIndex: u } = e, d = o.length, f = 0, p = d - 1, m = n - 1, h = a ||
|
|
2152
|
+
let { oldKeys: o, oldItems: s, oldNodes: c, removingKeys: l, keyToIndex: u } = e, d = o.length, f = 0, p = d - 1, m = n - 1, h = a || Fe;
|
|
2123
2153
|
for (; f <= p && f <= m;) {
|
|
2124
2154
|
let e = t[f], n = r(e, f);
|
|
2125
2155
|
if (o[f] !== n || !h(s[f], e)) break;
|
|
@@ -2130,17 +2160,17 @@ function ln(e, t, n, r, i, a) {
|
|
|
2130
2160
|
if (o[p] !== n || !h(s[p], e)) break;
|
|
2131
2161
|
u.set(n, m--), p--;
|
|
2132
2162
|
}
|
|
2133
|
-
let g =
|
|
2163
|
+
let g = rn.acquire();
|
|
2134
2164
|
for (let e = f; e <= p; e++) g.set(o[e], e);
|
|
2135
|
-
let _ =
|
|
2165
|
+
let _ = an.acquire();
|
|
2136
2166
|
e.ensureBuffers(n);
|
|
2137
|
-
let v =
|
|
2167
|
+
let v = Q.acquire();
|
|
2138
2168
|
v.length = n;
|
|
2139
|
-
let y =
|
|
2169
|
+
let y = Q.acquire();
|
|
2140
2170
|
y.length = n;
|
|
2141
|
-
let b =
|
|
2171
|
+
let b = Q.acquire();
|
|
2142
2172
|
b.length = n;
|
|
2143
|
-
let x = e.statesBuffer, S = e.indicesBuffer, C =
|
|
2173
|
+
let x = e.statesBuffer, S = e.indicesBuffer, C = Q.acquire(), w = Q.acquire(), T = Q.acquire();
|
|
2144
2174
|
for (let e = 0; e < f; e++) v[e] = o[e], y[e] = t[e], b[e] = c[e], x[e] = 3, S[e] = e;
|
|
2145
2175
|
for (let e = d - 1, r = n - 1; r > m; r--, e--) v[r] = o[e], y[r] = t[r], b[r] = c[e], x[r] = 3, S[r] = e;
|
|
2146
2176
|
for (let n = f; n <= m; n++) {
|
|
@@ -2152,13 +2182,13 @@ function ln(e, t, n, r, i, a) {
|
|
|
2152
2182
|
_.add(d);
|
|
2153
2183
|
let f = g.get(d);
|
|
2154
2184
|
if (f === void 0) {
|
|
2155
|
-
C.push(d),
|
|
2185
|
+
C.push(d), w.push(o), T.push(n), S[n] = -1, x[n] = 1;
|
|
2156
2186
|
continue;
|
|
2157
2187
|
}
|
|
2158
2188
|
let p = s[f];
|
|
2159
|
-
b[n] = c[f], !i && p !== o && !(a ? a(p, o) :
|
|
2189
|
+
b[n] = c[f], !i && p !== o && !(a ? a(p, o) : Fe(p, o)) ? (C.push(d), w.push(o), T.push(n), x[n] = 2) : x[n] = 0, S[n] = l.has(d) ? -1 : f;
|
|
2160
2190
|
}
|
|
2161
|
-
return
|
|
2191
|
+
return rn.release(g), {
|
|
2162
2192
|
newKeys: v,
|
|
2163
2193
|
newKeySet: _,
|
|
2164
2194
|
newItems: y,
|
|
@@ -2166,8 +2196,8 @@ function ln(e, t, n, r, i, a) {
|
|
|
2166
2196
|
newStates: x,
|
|
2167
2197
|
newIndices: S,
|
|
2168
2198
|
trKeys: C,
|
|
2169
|
-
trItems:
|
|
2170
|
-
trIdxs:
|
|
2199
|
+
trItems: w,
|
|
2200
|
+
trIdxs: T,
|
|
2171
2201
|
startIndex: f,
|
|
2172
2202
|
oldEndIndex: p,
|
|
2173
2203
|
newEndIndex: m
|
|
@@ -2180,10 +2210,10 @@ function un(t, n, r) {
|
|
|
2180
2210
|
u[e] = t, typeof t == "string" && (d.push(t), f++);
|
|
2181
2211
|
}
|
|
2182
2212
|
let p = null;
|
|
2183
|
-
if (d.length > 0) if (d.length === 1) p = [
|
|
2213
|
+
if (d.length > 0) if (d.length === 1) p = [X(d[0])];
|
|
2184
2214
|
else {
|
|
2185
|
-
let e = `<template data-atom-sep="${(
|
|
2186
|
-
p =
|
|
2215
|
+
let e = `<template data-atom-sep="${(nn++).toString(36)}"></template>`;
|
|
2216
|
+
p = X(d.join(e)).split(e);
|
|
2187
2217
|
}
|
|
2188
2218
|
if (r && p && f === l && !n.bind && !n.onAdd && !n.onRemove && !n.events) return p;
|
|
2189
2219
|
let m = 0;
|
|
@@ -2195,12 +2225,12 @@ function un(t, n, r) {
|
|
|
2195
2225
|
}
|
|
2196
2226
|
if (c[a] === 2 && s[a]) {
|
|
2197
2227
|
let e = s[a];
|
|
2198
|
-
if (e instanceof Element)
|
|
2228
|
+
if (e instanceof Element) q.cleanupTree(e);
|
|
2199
2229
|
else for (let t = 0, n = e.length; t < n; t++) {
|
|
2200
2230
|
let n = e[t];
|
|
2201
|
-
n instanceof Element &&
|
|
2231
|
+
n instanceof Element && q.cleanupTree(n);
|
|
2202
2232
|
}
|
|
2203
|
-
|
|
2233
|
+
$(e).replaceWith(r);
|
|
2204
2234
|
}
|
|
2205
2235
|
s[a] = r.length === 1 ? r[0] : r;
|
|
2206
2236
|
}
|
|
@@ -2210,7 +2240,7 @@ function dn(e, t) {
|
|
|
2210
2240
|
let { startIndex: n, oldEndIndex: r, newKeySet: i } = t;
|
|
2211
2241
|
for (let t = n; t <= r; t++) {
|
|
2212
2242
|
let n = e.oldKeys[t];
|
|
2213
|
-
!i.has(n) && e.oldNodes[t] && e.removeItem(n,
|
|
2243
|
+
!i.has(n) && e.oldNodes[t] && e.removeItem(n, $(e.oldNodes[t]));
|
|
2214
2244
|
}
|
|
2215
2245
|
}
|
|
2216
2246
|
function fn(t, n, r, i, a) {
|
|
@@ -2218,7 +2248,7 @@ function fn(t, n, r, i, a) {
|
|
|
2218
2248
|
if (a !== null) {
|
|
2219
2249
|
r.innerHTML = a.join("");
|
|
2220
2250
|
let n = r.firstElementChild;
|
|
2221
|
-
for (let r = 0; r < d && n; r++) n.setAttribute("data-atom-key", String(o[r])), c[r] = n, l[r] = 0, t.removingKeys.delete(o[r]), G.
|
|
2251
|
+
for (let r = 0; r < d && n; r++) n.setAttribute("data-atom-key", String(o[r])), c[r] = n, l[r] = 0, t.removingKeys.delete(o[r]), G.domUpdated(H.LIST, e(n), "list.add", s[r]), n = n.nextElementSibling;
|
|
2222
2252
|
return;
|
|
2223
2253
|
}
|
|
2224
2254
|
if (t.oldKeys.length === 0) {
|
|
@@ -2233,7 +2263,7 @@ function fn(t, n, r, i, a) {
|
|
|
2233
2263
|
let e = null, t = 2147483647;
|
|
2234
2264
|
for (let n = d - 1; n >= 0; n--) {
|
|
2235
2265
|
let i = u[n];
|
|
2236
|
-
i !== -1 && i < t ? t = i :
|
|
2266
|
+
i !== -1 && i < t ? t = i : on(c[n], e, r);
|
|
2237
2267
|
let a = c[n];
|
|
2238
2268
|
e = a instanceof Element ? a : a[0] ?? null;
|
|
2239
2269
|
}
|
|
@@ -2241,8 +2271,8 @@ function fn(t, n, r, i, a) {
|
|
|
2241
2271
|
for (let e = 0; e < d; e++) {
|
|
2242
2272
|
let n = l[e];
|
|
2243
2273
|
if (n !== 3) {
|
|
2244
|
-
let r =
|
|
2245
|
-
n === 0 ? i.update?.(r, a, e) : i.bind?.(r, a, e), n === 1 && (i.onAdd?.(r), t.removingKeys.delete(o[e]), G.
|
|
2274
|
+
let r = $(c[e]), a = s[e];
|
|
2275
|
+
n === 0 ? i.update?.(r, a, e) : i.bind?.(r, a, e), n === 1 && (i.onAdd?.(r), t.removingKeys.delete(o[e]), G.domUpdated(H.LIST, r, "list.add", a));
|
|
2246
2276
|
}
|
|
2247
2277
|
}
|
|
2248
2278
|
}
|
|
@@ -2257,16 +2287,16 @@ e.fn.atomList = function(t, n) {
|
|
|
2257
2287
|
for (let a = 0, o = this.length; a < o; a++) {
|
|
2258
2288
|
let o = this[a], s = e(o);
|
|
2259
2289
|
s.off(".atomList");
|
|
2260
|
-
let c =
|
|
2290
|
+
let c = tn.get(o);
|
|
2261
2291
|
c && (c.fx.dispose(), c.ctx.dispose());
|
|
2262
|
-
let l = new sn(s,
|
|
2292
|
+
let l = new sn(s, Pe(o), n.onRemove), u = R(() => {
|
|
2263
2293
|
let e = t.value, a = e.length;
|
|
2264
|
-
|
|
2294
|
+
k(() => {
|
|
2265
2295
|
if (cn(l, a, s, n.empty), a === 0) return;
|
|
2266
|
-
G.
|
|
2296
|
+
G.log(H.LIST, `${l.containerSelector} updating with ${a} items`);
|
|
2267
2297
|
let t = ln(l, e, a, r, n.update, n.isEqual), c = un(t, n, l.oldKeys.length === 0);
|
|
2268
2298
|
if (dn(l, t), fn(l, t, o, i, c), n.events) for (let e = t.startIndex; e <= t.oldEndIndex; e++) t.newKeySet.has(l.oldKeys[e]) || l.keyToIndex.delete(l.oldKeys[e]);
|
|
2269
|
-
|
|
2299
|
+
Q.release(l.oldKeys), Q.release(l.oldItems), Q.release(l.oldNodes), l.oldKeys = t.newKeys, l.oldItems = t.newItems, l.oldNodes = t.newNodes, an.release(t.newKeySet), Q.release(t.trKeys), Q.release(t.trItems), Q.release(t.trIdxs);
|
|
2270
2300
|
});
|
|
2271
2301
|
});
|
|
2272
2302
|
if (l.fx = u, n.events) for (let e in n.events) {
|
|
@@ -2284,11 +2314,11 @@ e.fn.atomList = function(t, n) {
|
|
|
2284
2314
|
i !== void 0 && a.call(t, l.oldItems[i], i, e);
|
|
2285
2315
|
});
|
|
2286
2316
|
}
|
|
2287
|
-
|
|
2317
|
+
q.trackEffect(o, u), tn.set(o, {
|
|
2288
2318
|
fx: u,
|
|
2289
2319
|
ctx: l
|
|
2290
|
-
}),
|
|
2291
|
-
l.dispose(),
|
|
2320
|
+
}), q.trackCleanup(o, () => {
|
|
2321
|
+
l.dispose(), tn.delete(o);
|
|
2292
2322
|
});
|
|
2293
2323
|
}
|
|
2294
2324
|
return this;
|
|
@@ -2301,10 +2331,10 @@ e.fn.atomMount = function(t, n) {
|
|
|
2301
2331
|
for (let n = 0, a = this.length; n < a; n++) {
|
|
2302
2332
|
let a = this[n];
|
|
2303
2333
|
if (a) {
|
|
2304
|
-
|
|
2334
|
+
q.cleanupTree(a);
|
|
2305
2335
|
try {
|
|
2306
|
-
let n =
|
|
2307
|
-
typeof n == "function" &&
|
|
2336
|
+
let n = k(() => t(e(a), r));
|
|
2337
|
+
typeof n == "function" && q.setComponentCleanup(a, n);
|
|
2308
2338
|
} catch (e) {
|
|
2309
2339
|
G.error(H.MOUNT, W.MOUNT.ERROR(i), e);
|
|
2310
2340
|
}
|
|
@@ -2335,21 +2365,21 @@ var hn = class {
|
|
|
2335
2365
|
autoBindLinks: U.autoBindLinks,
|
|
2336
2366
|
activeClass: U.activeClass,
|
|
2337
2367
|
...t
|
|
2338
|
-
}, this.isHistoryMode = this.config.mode === "history", this.basePath = this.config.basePath.replace(/\/$/, ""), this.activeClass = this.config.activeClass, this.$target = e(this.config.target), this.previousUrl = this.isHistoryMode ? location.pathname + location.search : location.hash, this.currentRouteAtom =
|
|
2368
|
+
}, this.isHistoryMode = this.config.mode === "history", this.basePath = this.config.basePath.replace(/\/$/, ""), this.activeClass = this.config.activeClass, this.$target = e(this.config.target), this.previousUrl = this.isHistoryMode ? location.pathname + location.search : location.hash, this.currentRouteAtom = A(this.getRouteName()), this.currentRoute = this.currentRouteAtom, this.queryParamsAtom = A(this.getQueryParams()), this.queryParams = L(() => this.queryParamsAtom.value), this.init();
|
|
2339
2369
|
}
|
|
2340
2370
|
init() {
|
|
2341
2371
|
let e = this.isHistoryMode ? "popstate" : "hashchange", t = this.handleUrlChange.bind(this);
|
|
2342
2372
|
window.addEventListener(e, t), this.cleanups.push(() => window.removeEventListener(e, t));
|
|
2343
2373
|
let n = R(() => {
|
|
2344
2374
|
let e = this.currentRouteAtom.value;
|
|
2345
|
-
|
|
2375
|
+
k(() => {
|
|
2346
2376
|
for (let e of this.routeCleanups) try {
|
|
2347
2377
|
e();
|
|
2348
2378
|
} catch {}
|
|
2349
2379
|
this.routeCleanups.length = 0;
|
|
2350
2380
|
}), this.renderRoute(e);
|
|
2351
2381
|
});
|
|
2352
|
-
this.cleanups.push(() => n.dispose()), this.setupAutoBindLinks(), this.$target[0] &&
|
|
2382
|
+
this.cleanups.push(() => n.dispose()), this.setupAutoBindLinks(), this.$target[0] && q.trackCleanup(this.$target[0], () => this.destroy());
|
|
2353
2383
|
}
|
|
2354
2384
|
getRouteName() {
|
|
2355
2385
|
let { default: e } = this.config;
|
|
@@ -2393,10 +2423,10 @@ var hn = class {
|
|
|
2393
2423
|
return;
|
|
2394
2424
|
}
|
|
2395
2425
|
let o = this.getQueryParams(), s = this.previousRoute;
|
|
2396
|
-
r &&
|
|
2426
|
+
r && k(() => r(s, e)), this.$target.empty();
|
|
2397
2427
|
let c = o;
|
|
2398
2428
|
if (a.onEnter) {
|
|
2399
|
-
let e =
|
|
2429
|
+
let e = k(() => a.onEnter(o, this));
|
|
2400
2430
|
e && (c = {
|
|
2401
2431
|
...o,
|
|
2402
2432
|
...e
|
|
@@ -2416,7 +2446,7 @@ var hn = class {
|
|
|
2416
2446
|
}
|
|
2417
2447
|
this.$target.append(e.content.cloneNode(!0)), a.onMount && a.onMount(this.$target.children(), l, this);
|
|
2418
2448
|
}
|
|
2419
|
-
i &&
|
|
2449
|
+
i && k(() => i(s, e)), this.previousRoute = e;
|
|
2420
2450
|
}
|
|
2421
2451
|
handleUrlChange() {
|
|
2422
2452
|
if (this.isDestroyed) return;
|
|
@@ -2424,7 +2454,7 @@ var hn = class {
|
|
|
2424
2454
|
if (e === this.previousUrl) return;
|
|
2425
2455
|
let t = this.getRouteName(), n = this.currentRouteAtom.peek();
|
|
2426
2456
|
if (n !== t) {
|
|
2427
|
-
if (
|
|
2457
|
+
if (k(() => this.config.routes[n]?.onLeave?.(this)) === !1) {
|
|
2428
2458
|
this.restoreUrl();
|
|
2429
2459
|
return;
|
|
2430
2460
|
}
|
|
@@ -2442,7 +2472,7 @@ var hn = class {
|
|
|
2442
2472
|
e(document).on("click", "[data-route]", t), this.cleanups.push(() => e(document).off("click", "[data-route]", t));
|
|
2443
2473
|
let n = [], r = R(() => {
|
|
2444
2474
|
let e = this.currentRouteAtom.value, t = this.activeClass;
|
|
2445
|
-
|
|
2475
|
+
k(() => {
|
|
2446
2476
|
let r = n.length;
|
|
2447
2477
|
for (let e = 0; e < r; e++) {
|
|
2448
2478
|
let r = n[e];
|
|
@@ -2551,10 +2581,10 @@ e.extend({ atomFetch(e, t) {
|
|
|
2551
2581
|
});
|
|
2552
2582
|
return Object.assign(r, { abort: () => n.abort() });
|
|
2553
2583
|
} }), e(() => {
|
|
2554
|
-
|
|
2584
|
+
ft(), at(document.body);
|
|
2555
2585
|
});
|
|
2556
2586
|
var vn = e;
|
|
2557
2587
|
//#endregion
|
|
2558
|
-
export {
|
|
2588
|
+
export { vn as default, ot as disableAutoCleanup, pt as disablejQueryOverrides, at as enableAutoCleanup, ft as enablejQueryOverrides, B as isReactive, Xe as nextTick, q as registry };
|
|
2559
2589
|
|
|
2560
2590
|
//# sourceMappingURL=index.mjs.map
|