@but212/atom-effect-jquery 0.24.1 → 0.25.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 +17 -9
- package/dist/index.mjs +568 -465
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -89,7 +89,7 @@ var d = Object.freeze([]), f = class {
|
|
|
89
89
|
BATCH_CALLBACK_MUST_BE_FUNCTION: "Batch callback must be a function"
|
|
90
90
|
}, y = class {
|
|
91
91
|
constructor() {
|
|
92
|
-
this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this.
|
|
92
|
+
this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow = null;
|
|
93
93
|
}
|
|
94
94
|
get size() {
|
|
95
95
|
return this._count;
|
|
@@ -284,19 +284,19 @@ var d = Object.freeze([]), f = class {
|
|
|
284
284
|
attachDebugInfo(e, t, n) {},
|
|
285
285
|
getDebugName: (e) => e?.[b],
|
|
286
286
|
getDebugType: (e) => e?.[x]
|
|
287
|
-
},
|
|
288
|
-
function
|
|
287
|
+
}, ee = 1, te = () => ee++;
|
|
288
|
+
function w(e, t, n) {
|
|
289
289
|
if (e instanceof m) return e;
|
|
290
290
|
let r = e instanceof Error, i = r ? e.message : String(e), a = r ? e : void 0;
|
|
291
291
|
return new t(`${r ? e.constructor.name : "Unexpected error"} (${n}): ${i}`, a);
|
|
292
292
|
}
|
|
293
|
-
var
|
|
293
|
+
var ne = class {
|
|
294
294
|
constructor() {
|
|
295
|
-
this.flags = 0, this.version = 0, this._lastSeenEpoch = c.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id =
|
|
295
|
+
this.flags = 0, this.version = 0, this._lastSeenEpoch = c.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id = te() & l;
|
|
296
296
|
}
|
|
297
297
|
subscribe(e) {
|
|
298
298
|
let t = typeof e == "function";
|
|
299
|
-
if (!t && (!e || typeof e.execute != "function")) throw
|
|
299
|
+
if (!t && (!e || typeof e.execute != "function")) throw w(/* @__PURE__ */ TypeError("Invalid subscriber"), m, v.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);
|
|
300
300
|
let n = this._slots;
|
|
301
301
|
n || (n = new y(), this._slots = n);
|
|
302
302
|
let r = !1;
|
|
@@ -327,7 +327,7 @@ var te = class {
|
|
|
327
327
|
try {
|
|
328
328
|
n.notify(e, t);
|
|
329
329
|
} catch (e) {
|
|
330
|
-
console.error(
|
|
330
|
+
console.error(w(e, m, v.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
|
|
331
331
|
}
|
|
332
332
|
});
|
|
333
333
|
} finally {
|
|
@@ -344,20 +344,20 @@ var te = class {
|
|
|
344
344
|
}
|
|
345
345
|
return !e.hasComputeds && !e.isDirtyFast() ? !1 : this._deepDirtyCheck();
|
|
346
346
|
}
|
|
347
|
-
},
|
|
348
|
-
function
|
|
349
|
-
return
|
|
347
|
+
}, re = 0, ie = () => (re = re + 1 & 1073741823 || 1, re), ae = (e) => e + 1 & l, oe = 0, se = !1, ce = 0, le = () => ce;
|
|
348
|
+
function ue() {
|
|
349
|
+
return se ? !1 : (se = !0, ce = ie(), oe = 0, !0);
|
|
350
350
|
}
|
|
351
|
-
var
|
|
352
|
-
|
|
353
|
-
},
|
|
351
|
+
var de = () => {
|
|
352
|
+
se = !1;
|
|
353
|
+
}, fe = () => se ? ++oe : 0, pe = /* @__PURE__ */ (function(e) {
|
|
354
354
|
return e[e.IDLE = 0] = "IDLE", e[e.BATCHING = 1] = "BATCHING", e[e.FLUSHING = 2] = "FLUSHING", e;
|
|
355
|
-
})({}),
|
|
355
|
+
})({}), T = new class {
|
|
356
356
|
constructor() {
|
|
357
357
|
this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this._isBatching = !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);
|
|
358
358
|
}
|
|
359
359
|
get phase() {
|
|
360
|
-
return this._isProcessing || this._isFlushingSync ?
|
|
360
|
+
return this._isProcessing || this._isFlushingSync ? pe.FLUSHING : this._isBatching ? pe.BATCHING : pe.IDLE;
|
|
361
361
|
}
|
|
362
362
|
get queueSize() {
|
|
363
363
|
return this._size;
|
|
@@ -380,19 +380,19 @@ var ue = () => {
|
|
|
380
380
|
_runLoop() {
|
|
381
381
|
try {
|
|
382
382
|
if (this._size === 0) return;
|
|
383
|
-
let e =
|
|
384
|
-
this._drainQueue(), e &&
|
|
383
|
+
let e = ue();
|
|
384
|
+
this._drainQueue(), e && de();
|
|
385
385
|
} finally {
|
|
386
386
|
this._isProcessing = !1, this._size > 0 && !this._isBatching && this._flush();
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
_flushSync() {
|
|
390
390
|
this._isFlushingSync = !0;
|
|
391
|
-
let e =
|
|
391
|
+
let e = ue();
|
|
392
392
|
try {
|
|
393
393
|
this._mergeBatchQueue(), this._drainQueue();
|
|
394
394
|
} finally {
|
|
395
|
-
this._isFlushingSync = !1, e &&
|
|
395
|
+
this._isFlushingSync = !1, e && de();
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
_mergeBatchQueue() {
|
|
@@ -441,7 +441,7 @@ var ue = () => {
|
|
|
441
441
|
if (e < a.MIN_FLUSH_ITERATIONS) throw new _(`Max flush iterations must be at least ${a.MIN_FLUSH_ITERATIONS}`);
|
|
442
442
|
this._maxFlushIterations = e;
|
|
443
443
|
}
|
|
444
|
-
}(),
|
|
444
|
+
}(), me = /* @__PURE__ */ Symbol.for("atom-effect/atom"), he = /* @__PURE__ */ Symbol.for("atom-effect/computed"), ge = /* @__PURE__ */ Symbol.for("atom-effect/effect"), _e = /* @__PURE__ */ Symbol.for("atom-effect/writable"), E = {
|
|
445
445
|
current: null,
|
|
446
446
|
run(e, t) {
|
|
447
447
|
let n = this.current;
|
|
@@ -453,36 +453,36 @@ var ue = () => {
|
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
455
|
};
|
|
456
|
-
function
|
|
457
|
-
let t =
|
|
456
|
+
function D(e) {
|
|
457
|
+
let t = E.current;
|
|
458
458
|
if (t === null) return e();
|
|
459
|
-
|
|
459
|
+
E.current = null;
|
|
460
460
|
try {
|
|
461
461
|
return e();
|
|
462
462
|
} finally {
|
|
463
|
-
|
|
463
|
+
E.current = t;
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
var
|
|
466
|
+
var ve = class extends ne {
|
|
467
467
|
constructor(e, t) {
|
|
468
|
-
super(), this[
|
|
468
|
+
super(), this[me] = !0, this[_e] = !0, this._value = e, this._pendingOldValue = void 0, t && (this.flags |= i.SYNC), C.attachDebugInfo(this, "atom", this.id);
|
|
469
469
|
}
|
|
470
470
|
get value() {
|
|
471
|
-
return
|
|
471
|
+
return E.current?.addDependency(this), this._value;
|
|
472
472
|
}
|
|
473
473
|
set value(e) {
|
|
474
474
|
let t = this._value;
|
|
475
475
|
if (Object.is(t, e)) return;
|
|
476
|
-
this._value = e, this.version =
|
|
476
|
+
this._value = e, this.version = ae(this.version);
|
|
477
477
|
let n = this._slots, r = this.flags;
|
|
478
478
|
if (n == null || n.size === 0 || r & i.NOTIFICATION_SCHEDULED) return;
|
|
479
479
|
this._pendingOldValue = t;
|
|
480
480
|
let a = r | i.NOTIFICATION_SCHEDULED;
|
|
481
|
-
if (this.flags = a, (a & i.SYNC) !== 0 && !
|
|
481
|
+
if (this.flags = a, (a & i.SYNC) !== 0 && !T.isBatching) {
|
|
482
482
|
this._flushNotifications();
|
|
483
483
|
return;
|
|
484
484
|
}
|
|
485
|
-
|
|
485
|
+
T.schedule(this);
|
|
486
486
|
}
|
|
487
487
|
execute() {
|
|
488
488
|
this._flushNotifications();
|
|
@@ -506,10 +506,10 @@ var _e = class extends te {
|
|
|
506
506
|
this.dispose();
|
|
507
507
|
}
|
|
508
508
|
};
|
|
509
|
-
function
|
|
510
|
-
return new
|
|
509
|
+
function ye(e, t = {}) {
|
|
510
|
+
return new ve(e, t.sync ?? !1);
|
|
511
511
|
}
|
|
512
|
-
var
|
|
512
|
+
var be = class extends y {
|
|
513
513
|
constructor() {
|
|
514
514
|
super(), this._map = null, this._SCAN_THRESHOLD = 32, this.hasComputeds = !1, this._depsHash = 0, this._map = null, this.hasComputeds = !1, this._depsHash = 0;
|
|
515
515
|
}
|
|
@@ -695,41 +695,41 @@ var ye = class extends y {
|
|
|
695
695
|
}
|
|
696
696
|
compact() {}
|
|
697
697
|
};
|
|
698
|
-
function
|
|
699
|
-
return typeof e == "object" && !!e && pe in e;
|
|
700
|
-
}
|
|
701
|
-
function be(e) {
|
|
698
|
+
function xe(e) {
|
|
702
699
|
return typeof e == "object" && !!e && me in e;
|
|
703
700
|
}
|
|
704
|
-
function
|
|
701
|
+
function Se(e) {
|
|
702
|
+
return typeof e == "object" && !!e && he in e;
|
|
703
|
+
}
|
|
704
|
+
function Ce(e) {
|
|
705
705
|
return typeof e == "object" && !!e && typeof e.then == "function";
|
|
706
706
|
}
|
|
707
|
-
var { IDLE:
|
|
707
|
+
var { IDLE: O, DIRTY: k, PENDING: A, RESOLVED: j, REJECTED: M, HAS_ERROR: N, RECOMPUTING: P, DISPOSED: we, IS_COMPUTED: Te, FORCE_COMPUTE: Ee } = r, De = class extends ne {
|
|
708
708
|
constructor(e, t = {}) {
|
|
709
709
|
if (typeof e != "function") throw new h(v.COMPUTED_MUST_BE_FUNCTION);
|
|
710
|
-
if (super(), this[
|
|
710
|
+
if (super(), this[me] = !0, this[he] = !0, this._error = null, this._promiseId = 0, this._deps = new be(), this._asyncRetryCount = 0, this._lastDriftEpoch = c.UNINITIALIZED, this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = Te | k | O, 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 {
|
|
711
711
|
this._recompute();
|
|
712
712
|
} catch {}
|
|
713
713
|
}
|
|
714
714
|
_track() {
|
|
715
|
-
|
|
715
|
+
E.current?.addDependency(this);
|
|
716
716
|
}
|
|
717
717
|
get value() {
|
|
718
718
|
this._track();
|
|
719
719
|
let e = this.flags;
|
|
720
|
-
if ((e & (
|
|
721
|
-
if (e &
|
|
722
|
-
if (e &
|
|
720
|
+
if ((e & (j | k | O)) === j) return this._value;
|
|
721
|
+
if (e & we) throw new h(v.COMPUTED_DISPOSED);
|
|
722
|
+
if (e & P) {
|
|
723
723
|
if (this._defaultValue !== S) return this._defaultValue;
|
|
724
724
|
throw new h(v.COMPUTED_CIRCULAR_DEPENDENCY);
|
|
725
725
|
}
|
|
726
|
-
if (e & (
|
|
726
|
+
if (e & (k | O) && ((e & O) === 0 && (e & Ee) === 0 && this._deps.size > 0 && !this._isDirty() ? this.flags &= ~k : this._recompute(), this.flags & j)) return this._value;
|
|
727
727
|
let t = this._defaultValue, n = t !== S;
|
|
728
|
-
if (this.flags &
|
|
728
|
+
if (this.flags & A) {
|
|
729
729
|
if (n) return t;
|
|
730
730
|
throw new h(v.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
|
|
731
731
|
}
|
|
732
|
-
if (this.flags &
|
|
732
|
+
if (this.flags & M) {
|
|
733
733
|
if (n) return t;
|
|
734
734
|
throw this._error;
|
|
735
735
|
}
|
|
@@ -741,16 +741,16 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: F, REC
|
|
|
741
741
|
get state() {
|
|
742
742
|
this._track();
|
|
743
743
|
let e = this.flags;
|
|
744
|
-
return e &
|
|
744
|
+
return e & j ? t.RESOLVED : e & A ? t.PENDING : e & M ? t.REJECTED : t.IDLE;
|
|
745
745
|
}
|
|
746
746
|
get hasError() {
|
|
747
|
-
if (this._track(), this.flags & (
|
|
747
|
+
if (this._track(), this.flags & (M | N)) return !0;
|
|
748
748
|
let e = this._deps;
|
|
749
749
|
if (!e.hasComputeds) return !1;
|
|
750
750
|
let t = e.size;
|
|
751
751
|
for (let n = 0; n < t; n++) {
|
|
752
752
|
let t = e.getAt(n);
|
|
753
|
-
if (t != null && t.node.flags &
|
|
753
|
+
if (t != null && t.node.flags & N) return !0;
|
|
754
754
|
}
|
|
755
755
|
return !1;
|
|
756
756
|
}
|
|
@@ -768,7 +768,7 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: F, REC
|
|
|
768
768
|
let n = t.getAt(r);
|
|
769
769
|
if (n == null) continue;
|
|
770
770
|
let i = n.node;
|
|
771
|
-
i.flags &
|
|
771
|
+
i.flags & N && this._collectErrorsFromDep(i, e);
|
|
772
772
|
}
|
|
773
773
|
return e.length === 0 ? d : Object.freeze(e);
|
|
774
774
|
}
|
|
@@ -783,16 +783,16 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: F, REC
|
|
|
783
783
|
return this._track(), this._error;
|
|
784
784
|
}
|
|
785
785
|
get isPending() {
|
|
786
|
-
return this._track(), (this.flags &
|
|
786
|
+
return this._track(), (this.flags & A) !== 0;
|
|
787
787
|
}
|
|
788
788
|
get isResolved() {
|
|
789
|
-
return this._track(), (this.flags &
|
|
789
|
+
return this._track(), (this.flags & j) !== 0;
|
|
790
790
|
}
|
|
791
791
|
invalidate() {
|
|
792
|
-
this.flags |=
|
|
792
|
+
this.flags |= Ee, this._markDirty();
|
|
793
793
|
}
|
|
794
794
|
dispose() {
|
|
795
|
-
this.flags &
|
|
795
|
+
this.flags & we || (this._deps.disposeAll(), this._slots?.clear(), this.flags = we | k | O, this._error = null, this._value = void 0, this._hotIndex = -1);
|
|
796
796
|
}
|
|
797
797
|
[Symbol.dispose]() {
|
|
798
798
|
this.dispose();
|
|
@@ -806,31 +806,31 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: F, REC
|
|
|
806
806
|
let n = new f(e, e.version, e.subscribe(this));
|
|
807
807
|
this._deps.insertNew(t, n);
|
|
808
808
|
}
|
|
809
|
-
e.flags &
|
|
809
|
+
e.flags & Te && (this._deps.hasComputeds = !0), this._trackCount = t + 1;
|
|
810
810
|
}
|
|
811
811
|
_recompute() {
|
|
812
|
-
if (this.flags &
|
|
813
|
-
this.flags = (this.flags |
|
|
812
|
+
if (this.flags & P) return;
|
|
813
|
+
this.flags = (this.flags | P) & ~Ee, this._trackEpoch = ie(), this._trackCount = 0, this._deps.prepareTracking(), this._hotIndex = -1;
|
|
814
814
|
let e = !1;
|
|
815
815
|
try {
|
|
816
|
-
let t =
|
|
817
|
-
this._deps.truncateFrom(this._trackCount), this._deps.seal(), e = !0,
|
|
816
|
+
let t = E.run(this, this._fn);
|
|
817
|
+
this._deps.truncateFrom(this._trackCount), this._deps.seal(), e = !0, Ce(t) ? this._handleAsyncComputation(t) : this._finalizeResolution(t);
|
|
818
818
|
} catch (t) {
|
|
819
819
|
if (!e) try {
|
|
820
820
|
this._deps.truncateFrom(this._trackCount);
|
|
821
821
|
} catch {}
|
|
822
822
|
this._handleError(t, v.COMPUTED_COMPUTATION_FAILED, !0);
|
|
823
823
|
} finally {
|
|
824
|
-
this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this.flags &= ~
|
|
824
|
+
this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this.flags &= ~P;
|
|
825
825
|
}
|
|
826
826
|
}
|
|
827
827
|
_handleAsyncComputation(e) {
|
|
828
|
-
this.flags = (this.flags |
|
|
828
|
+
this.flags = (this.flags | A) & ~(O | k | j | M), this._notifySubscribers(void 0, void 0), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % s.MAX_PROMISE_ID;
|
|
829
829
|
let t = this._promiseId;
|
|
830
830
|
e.then((e) => {
|
|
831
831
|
if (t === this._promiseId) {
|
|
832
832
|
if (this._isDirty()) {
|
|
833
|
-
let e =
|
|
833
|
+
let e = le();
|
|
834
834
|
return this._lastDriftEpoch !== e && (this._lastDriftEpoch = e, this._asyncRetryCount = 0), this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(new h(`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`), v.COMPUTED_ASYNC_COMPUTATION_FAILED);
|
|
835
835
|
}
|
|
836
836
|
this._finalizeResolution(e), this._notifySubscribers(e, void 0);
|
|
@@ -838,8 +838,8 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: F, REC
|
|
|
838
838
|
}, (e) => t === this._promiseId && this._handleError(e, v.COMPUTED_ASYNC_COMPUTATION_FAILED));
|
|
839
839
|
}
|
|
840
840
|
_handleError(e, t, n = !1) {
|
|
841
|
-
let r =
|
|
842
|
-
if (!n && !(this.flags &
|
|
841
|
+
let r = w(e, h, t);
|
|
842
|
+
if (!n && !(this.flags & M) && (this.version = ae(this.version)), this._error = r, this.flags = this.flags & ~(O | k | A | j) | M | N, this._onError) try {
|
|
843
843
|
this._onError(r);
|
|
844
844
|
} catch (e) {
|
|
845
845
|
console.error(v.CALLBACK_ERROR_IN_ERROR_HANDLER, e);
|
|
@@ -848,44 +848,44 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: F, REC
|
|
|
848
848
|
this._notifySubscribers(void 0, void 0);
|
|
849
849
|
}
|
|
850
850
|
_finalizeResolution(e) {
|
|
851
|
-
(!(this.flags &
|
|
851
|
+
(!(this.flags & j) || !this._equal(this._value, e)) && (this.version = ae(this.version)), this._value = e, this._error = null, this.flags = (this.flags | j) & ~(O | k | A | M | N);
|
|
852
852
|
}
|
|
853
853
|
execute() {
|
|
854
854
|
this._markDirty();
|
|
855
855
|
}
|
|
856
856
|
_markDirty() {
|
|
857
|
-
this.flags & (
|
|
857
|
+
this.flags & (P | k) || (this.flags |= k, this._notifySubscribers(void 0, void 0));
|
|
858
858
|
}
|
|
859
859
|
_isDirty() {
|
|
860
860
|
let e = this._deps;
|
|
861
861
|
return e.hasComputeds ? this._deepDirtyCheck() : e.isDirtyFast();
|
|
862
862
|
}
|
|
863
863
|
_deepDirtyCheck() {
|
|
864
|
-
let e = this._deps, t =
|
|
865
|
-
|
|
864
|
+
let e = this._deps, t = E.current;
|
|
865
|
+
E.current = null;
|
|
866
866
|
try {
|
|
867
867
|
let t = e.size;
|
|
868
868
|
for (let n = 0; n < t; n++) {
|
|
869
869
|
let t = e.getAt(n);
|
|
870
870
|
if (t == null) continue;
|
|
871
871
|
let r = t.node;
|
|
872
|
-
if (r.flags &
|
|
872
|
+
if (r.flags & Te) try {
|
|
873
873
|
r.value;
|
|
874
874
|
} catch {}
|
|
875
875
|
if (r.version !== t.version) return this._hotIndex = n, !0;
|
|
876
876
|
}
|
|
877
877
|
return this._hotIndex = -1, !1;
|
|
878
878
|
} finally {
|
|
879
|
-
|
|
879
|
+
E.current = t;
|
|
880
880
|
}
|
|
881
881
|
}
|
|
882
882
|
};
|
|
883
|
-
function
|
|
884
|
-
return new
|
|
883
|
+
function F(e, t = {}) {
|
|
884
|
+
return new De(e, t);
|
|
885
885
|
}
|
|
886
|
-
var
|
|
886
|
+
var Oe = class extends ne {
|
|
887
887
|
constructor(e, t = {}) {
|
|
888
|
-
super(), this[
|
|
888
|
+
super(), this[ge] = !0, this._cleanup = null, this._deps = new be(), 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._cleanup = null, this._deps = new be(), this._currentEpoch = c.UNINITIALIZED, this._lastFlushEpoch = c.UNINITIALIZED, 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 = () => T.schedule(this), C.attachDebugInfo(this, "effect", this.id);
|
|
889
889
|
}
|
|
890
890
|
run() {
|
|
891
891
|
if (this.flags & n.DISPOSED) throw new g(v.EFFECT_DISPOSED);
|
|
@@ -911,7 +911,7 @@ var Ee = class extends te {
|
|
|
911
911
|
let t = e.subscribe(this._notifyCallback);
|
|
912
912
|
n = new f(e, e.version, t);
|
|
913
913
|
} catch (t) {
|
|
914
|
-
let r =
|
|
914
|
+
let r = w(t, g, v.EFFECT_EXECUTION_FAILED);
|
|
915
915
|
if (console.error(r), this._onError) try {
|
|
916
916
|
this._onError(r);
|
|
917
917
|
} catch {}
|
|
@@ -923,11 +923,11 @@ var Ee = class extends te {
|
|
|
923
923
|
if (this.flags & (n.DISPOSED | n.EXECUTING)) return;
|
|
924
924
|
let t = this._deps;
|
|
925
925
|
if (!e && t.size > 0 && !this._isDirty()) return;
|
|
926
|
-
this._checkInfiniteLoops(), this.flags |= n.EXECUTING, this._execCleanup(), this._currentEpoch =
|
|
926
|
+
this._checkInfiniteLoops(), this.flags |= n.EXECUTING, this._execCleanup(), this._currentEpoch = ie(), this._trackCount = 0, t.prepareTracking(), this._hotIndex = -1;
|
|
927
927
|
let r = !1;
|
|
928
928
|
try {
|
|
929
|
-
let e =
|
|
930
|
-
t.truncateFrom(this._trackCount), t.seal(), r = !0,
|
|
929
|
+
let e = E.run(this, this._fn);
|
|
930
|
+
t.truncateFrom(this._trackCount), t.seal(), r = !0, Ce(e) ? this._handleAsyncResult(e) : this._cleanup = typeof e == "function" ? e : null;
|
|
931
931
|
} catch (e) {
|
|
932
932
|
if (!r) try {
|
|
933
933
|
t.truncateFrom(this._trackCount);
|
|
@@ -956,8 +956,8 @@ var Ee = class extends te {
|
|
|
956
956
|
}, (e) => t === this._execId && this._handleExecutionError(e));
|
|
957
957
|
}
|
|
958
958
|
_deepDirtyCheck() {
|
|
959
|
-
let e =
|
|
960
|
-
|
|
959
|
+
let e = E.current;
|
|
960
|
+
E.current = null;
|
|
961
961
|
let t = this._deps;
|
|
962
962
|
try {
|
|
963
963
|
let e = t.size;
|
|
@@ -969,7 +969,7 @@ var Ee = class extends te {
|
|
|
969
969
|
}
|
|
970
970
|
return !1;
|
|
971
971
|
} finally {
|
|
972
|
-
|
|
972
|
+
E.current = e;
|
|
973
973
|
}
|
|
974
974
|
}
|
|
975
975
|
_tryPullComputed(e) {
|
|
@@ -988,8 +988,8 @@ var Ee = class extends te {
|
|
|
988
988
|
}
|
|
989
989
|
}
|
|
990
990
|
_checkInfiniteLoops() {
|
|
991
|
-
let e =
|
|
992
|
-
this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"),
|
|
991
|
+
let e = le();
|
|
992
|
+
this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), fe() > a.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++;
|
|
993
993
|
}
|
|
994
994
|
_checkFrequencyLimit() {
|
|
995
995
|
if (!Number.isFinite(this._maxExecutions)) return;
|
|
@@ -1013,38 +1013,41 @@ var Ee = class extends te {
|
|
|
1013
1013
|
return (this.flags & n.EXECUTING) !== 0;
|
|
1014
1014
|
}
|
|
1015
1015
|
_throwInfiniteLoopError(e) {
|
|
1016
|
-
let t = new g(`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${
|
|
1016
|
+
let t = new g(`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${oe}`);
|
|
1017
1017
|
throw this.dispose(), console.error(t), t;
|
|
1018
1018
|
}
|
|
1019
1019
|
_handleExecutionError(e, t = v.EFFECT_EXECUTION_FAILED) {
|
|
1020
|
-
let n =
|
|
1020
|
+
let n = w(e, g, t);
|
|
1021
1021
|
if (console.error(n), this._onError) try {
|
|
1022
1022
|
this._onError(n);
|
|
1023
1023
|
} catch (e) {
|
|
1024
|
-
console.error(
|
|
1024
|
+
console.error(w(e, g, v.CALLBACK_ERROR_IN_ERROR_HANDLER));
|
|
1025
1025
|
}
|
|
1026
1026
|
}
|
|
1027
1027
|
};
|
|
1028
|
-
function
|
|
1028
|
+
function I(e, t = {}) {
|
|
1029
1029
|
if (typeof e != "function") throw new g(v.EFFECT_MUST_BE_FUNCTION);
|
|
1030
|
-
let n = new
|
|
1030
|
+
let n = new Oe(e, t);
|
|
1031
1031
|
return n.execute(), n;
|
|
1032
1032
|
}
|
|
1033
|
-
function
|
|
1033
|
+
function ke(e) {
|
|
1034
1034
|
if (typeof e != "function") throw TypeError(v.BATCH_CALLBACK_MUST_BE_FUNCTION);
|
|
1035
|
-
|
|
1035
|
+
T.startBatch();
|
|
1036
1036
|
try {
|
|
1037
1037
|
return e();
|
|
1038
1038
|
} finally {
|
|
1039
|
-
|
|
1039
|
+
T.endBatch();
|
|
1040
1040
|
}
|
|
1041
1041
|
}
|
|
1042
1042
|
//#endregion
|
|
1043
1043
|
//#region src/utils/index.ts
|
|
1044
|
-
function
|
|
1045
|
-
return
|
|
1044
|
+
function L(e) {
|
|
1045
|
+
return xe(e);
|
|
1046
|
+
}
|
|
1047
|
+
function Ae(e) {
|
|
1048
|
+
return !!e && typeof e.then == "function";
|
|
1046
1049
|
}
|
|
1047
|
-
function
|
|
1050
|
+
function R(e) {
|
|
1048
1051
|
let t = e.tagName.toLowerCase();
|
|
1049
1052
|
if (e.id) return `${t}#${e.id}`;
|
|
1050
1053
|
let n = e.classList, r = n.length;
|
|
@@ -1053,8 +1056,8 @@ function B(e) {
|
|
|
1053
1056
|
for (let e = 0; e < r; e++) i += `.${n[e]}`;
|
|
1054
1057
|
return i;
|
|
1055
1058
|
}
|
|
1056
|
-
var
|
|
1057
|
-
function
|
|
1059
|
+
var z = Object.prototype.hasOwnProperty;
|
|
1060
|
+
function je(e, t) {
|
|
1058
1061
|
if (e === t) return !0;
|
|
1059
1062
|
if (e === null || t === null || typeof e != "object" || typeof t != "object") return !1;
|
|
1060
1063
|
let n = Object.keys(e), r = Object.keys(t);
|
|
@@ -1062,52 +1065,37 @@ function Oe(e, t) {
|
|
|
1062
1065
|
let i = e, a = t;
|
|
1063
1066
|
for (let e = 0; e < n.length; e++) {
|
|
1064
1067
|
let t = n[e];
|
|
1065
|
-
if (!
|
|
1068
|
+
if (!z.call(a, t) || i[t] !== a[t]) return !1;
|
|
1066
1069
|
}
|
|
1067
1070
|
return !0;
|
|
1068
1071
|
}
|
|
1069
1072
|
//#endregion
|
|
1070
1073
|
//#region src/constants.ts
|
|
1071
|
-
var
|
|
1074
|
+
var B = {
|
|
1072
1075
|
ROUTE: "[atom-route]",
|
|
1073
1076
|
BINDING: "[atom-binding]",
|
|
1074
1077
|
LIST: "[atom-list]",
|
|
1075
1078
|
MOUNT: "[atom-mount]"
|
|
1076
|
-
},
|
|
1079
|
+
}, V = Object.freeze({
|
|
1077
1080
|
mode: "hash",
|
|
1078
1081
|
basePath: "",
|
|
1079
1082
|
autoBindLinks: !1,
|
|
1080
1083
|
activeClass: "active"
|
|
1081
|
-
}),
|
|
1084
|
+
}), Me = {
|
|
1082
1085
|
EVENT: "input",
|
|
1083
1086
|
DEBOUNCE: 0
|
|
1084
|
-
},
|
|
1087
|
+
}, Ne = { HIGHLIGHT_DURATION_MS: 500 }, Pe = new Set([
|
|
1085
1088
|
"input",
|
|
1086
1089
|
"select",
|
|
1087
1090
|
"textarea"
|
|
1088
|
-
]),
|
|
1089
|
-
"src",
|
|
1090
|
-
"href",
|
|
1091
|
-
"action",
|
|
1092
|
-
"formaction",
|
|
1093
|
-
"data",
|
|
1094
|
-
"poster",
|
|
1095
|
-
"background",
|
|
1096
|
-
"cite",
|
|
1097
|
-
"longdesc",
|
|
1098
|
-
"profile",
|
|
1099
|
-
"usemap",
|
|
1100
|
-
"classid",
|
|
1101
|
-
"codebase",
|
|
1102
|
-
"xlink:href"
|
|
1103
|
-
]), Ne = new Set([
|
|
1091
|
+
]), Fe = new Set([
|
|
1104
1092
|
"innerHTML",
|
|
1105
1093
|
"outerHTML",
|
|
1106
1094
|
"srcdoc",
|
|
1107
1095
|
"__proto__",
|
|
1108
1096
|
"constructor",
|
|
1109
1097
|
"prototype"
|
|
1110
|
-
]),
|
|
1098
|
+
]), H = {
|
|
1111
1099
|
ROUTE: {
|
|
1112
1100
|
NOT_FOUND: (e) => `Route "${e}" not found and no notFound route configured`,
|
|
1113
1101
|
TEMPLATE_NOT_FOUND: (e) => `Template "${e}" not found`,
|
|
@@ -1135,8 +1123,8 @@ var H = {
|
|
|
1135
1123
|
CLEANUP_ERROR: (e) => `Cleanup error${e ? ` in component <${e}>` : ""}`
|
|
1136
1124
|
},
|
|
1137
1125
|
CORE: { EFFECT_DISPOSE_ERROR: (e) => `Effect dispose error${e ? `: ${e}` : ""}` }
|
|
1138
|
-
},
|
|
1139
|
-
function
|
|
1126
|
+
}, Ie = `${Ne.HIGHLIGHT_DURATION_MS / 1e3}s`;
|
|
1127
|
+
function Le() {
|
|
1140
1128
|
if (typeof window < "u") {
|
|
1141
1129
|
let e = window.__ATOM_DEBUG__;
|
|
1142
1130
|
if (typeof e == "boolean") return e;
|
|
@@ -1146,16 +1134,16 @@ function Fe() {
|
|
|
1146
1134
|
} catch {}
|
|
1147
1135
|
return !1;
|
|
1148
1136
|
}
|
|
1149
|
-
var
|
|
1137
|
+
var Re = Le(), U = {
|
|
1150
1138
|
get enabled() {
|
|
1151
1139
|
if (typeof window < "u") {
|
|
1152
1140
|
let e = window.__ATOM_DEBUG__;
|
|
1153
1141
|
if (typeof e == "boolean") return e;
|
|
1154
1142
|
}
|
|
1155
|
-
return
|
|
1143
|
+
return Re;
|
|
1156
1144
|
},
|
|
1157
1145
|
set enabled(e) {
|
|
1158
|
-
|
|
1146
|
+
Re = e;
|
|
1159
1147
|
},
|
|
1160
1148
|
log(e, ...t) {
|
|
1161
1149
|
this.enabled && console.log(`${e}`, ...t);
|
|
@@ -1166,7 +1154,7 @@ var Ie = Fe(), G = {
|
|
|
1166
1154
|
domUpdated(e, t, n, r) {
|
|
1167
1155
|
if (!this.enabled) return;
|
|
1168
1156
|
let i = t instanceof Element ? t : t[0];
|
|
1169
|
-
i && (console.log(`${e} DOM updated: ${
|
|
1157
|
+
i && (console.log(`${e} DOM updated: ${R(i)}.${n} =`, r), We(i));
|
|
1170
1158
|
},
|
|
1171
1159
|
cleanup(e, t) {
|
|
1172
1160
|
this.enabled && console.log(`${e} Cleanup: ${t}`);
|
|
@@ -1177,60 +1165,60 @@ var Ie = Fe(), G = {
|
|
|
1177
1165
|
error(e, t, n) {
|
|
1178
1166
|
console.error(`${e} ${t}`, n);
|
|
1179
1167
|
}
|
|
1180
|
-
},
|
|
1181
|
-
function
|
|
1182
|
-
if ((
|
|
1168
|
+
}, ze = "atom-debug-highlight", Be = "data-atom-debug", W;
|
|
1169
|
+
function Ve() {
|
|
1170
|
+
if ((W instanceof HTMLStyleElement ? W : W?.deref())?.isConnected || document.querySelector(`style[${Be}]`)) return;
|
|
1183
1171
|
let e = document.createElement("style");
|
|
1184
|
-
e.setAttribute(
|
|
1172
|
+
e.setAttribute(Be, ""), e.textContent = `.${ze}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline ${Ie} ease-out}`, document.head.appendChild(e), W = typeof WeakRef < "u" ? new WeakRef(e) : e;
|
|
1185
1173
|
}
|
|
1186
|
-
var
|
|
1187
|
-
function
|
|
1188
|
-
if (!
|
|
1189
|
-
|
|
1190
|
-
let t =
|
|
1174
|
+
var He = /* @__PURE__ */ new WeakMap(), Ue = /* @__PURE__ */ new WeakMap();
|
|
1175
|
+
function We(e) {
|
|
1176
|
+
if (!U.enabled || !e.isConnected) return;
|
|
1177
|
+
Ve();
|
|
1178
|
+
let t = Ue.get(e);
|
|
1191
1179
|
t !== void 0 && cancelAnimationFrame(t);
|
|
1192
|
-
let n =
|
|
1180
|
+
let n = He.get(e);
|
|
1193
1181
|
n !== void 0 && clearTimeout(n);
|
|
1194
1182
|
let r = requestAnimationFrame(() => {
|
|
1195
|
-
|
|
1196
|
-
e.isConnected && e.classList.remove(
|
|
1197
|
-
},
|
|
1183
|
+
Ue.delete(e), e.isConnected && (e.classList.add(ze), He.set(e, setTimeout(() => {
|
|
1184
|
+
e.isConnected && e.classList.remove(ze), He.delete(e);
|
|
1185
|
+
}, Ne.HIGHLIGHT_DURATION_MS)));
|
|
1198
1186
|
});
|
|
1199
|
-
|
|
1187
|
+
Ue.set(e, r);
|
|
1200
1188
|
}
|
|
1201
1189
|
//#endregion
|
|
1202
1190
|
//#region src/core/namespace.ts
|
|
1203
|
-
function
|
|
1204
|
-
return
|
|
1191
|
+
function Ge(e, t) {
|
|
1192
|
+
return ye(e, t);
|
|
1205
1193
|
}
|
|
1206
|
-
Object.defineProperty(
|
|
1194
|
+
Object.defineProperty(Ge, "debug", {
|
|
1207
1195
|
enumerable: !0,
|
|
1208
1196
|
configurable: !0,
|
|
1209
1197
|
get() {
|
|
1210
|
-
return
|
|
1198
|
+
return U.enabled;
|
|
1211
1199
|
},
|
|
1212
1200
|
set(e) {
|
|
1213
|
-
|
|
1201
|
+
U.enabled = e;
|
|
1214
1202
|
}
|
|
1215
1203
|
});
|
|
1216
|
-
function
|
|
1204
|
+
function Ke() {
|
|
1217
1205
|
return new Promise((e) => setTimeout(e, 0));
|
|
1218
1206
|
}
|
|
1219
|
-
var
|
|
1220
|
-
atom:
|
|
1221
|
-
computed:
|
|
1222
|
-
effect:
|
|
1223
|
-
batch:
|
|
1224
|
-
untracked:
|
|
1225
|
-
isAtom:
|
|
1226
|
-
isComputed:
|
|
1227
|
-
isReactive:
|
|
1228
|
-
nextTick:
|
|
1207
|
+
var qe = {
|
|
1208
|
+
atom: Ge,
|
|
1209
|
+
computed: F,
|
|
1210
|
+
effect: I,
|
|
1211
|
+
batch: ke,
|
|
1212
|
+
untracked: D,
|
|
1213
|
+
isAtom: xe,
|
|
1214
|
+
isComputed: Se,
|
|
1215
|
+
isReactive: L,
|
|
1216
|
+
nextTick: Ke
|
|
1229
1217
|
};
|
|
1230
|
-
e.extend(
|
|
1218
|
+
e.extend(qe);
|
|
1231
1219
|
//#endregion
|
|
1232
1220
|
//#region src/utils/array-pool.ts
|
|
1233
|
-
var
|
|
1221
|
+
var Je = class {
|
|
1234
1222
|
constructor(e = 50, t = 256) {
|
|
1235
1223
|
this.limit = e, this.capacity = t, this.pool = [];
|
|
1236
1224
|
}
|
|
@@ -1243,7 +1231,7 @@ var qe = class {
|
|
|
1243
1231
|
reset() {
|
|
1244
1232
|
this.pool.length = 0;
|
|
1245
1233
|
}
|
|
1246
|
-
},
|
|
1234
|
+
}, Ye = class {
|
|
1247
1235
|
constructor(e, t, n = 64) {
|
|
1248
1236
|
this.factory = e, this.reset = t, this.limit = n, this.pool = [];
|
|
1249
1237
|
}
|
|
@@ -1259,13 +1247,13 @@ var qe = class {
|
|
|
1259
1247
|
get size() {
|
|
1260
1248
|
return this.pool.length;
|
|
1261
1249
|
}
|
|
1262
|
-
},
|
|
1250
|
+
}, Xe = new Je(), Ze = new Je(), Qe = new Ye(() => ({
|
|
1263
1251
|
effects: void 0,
|
|
1264
1252
|
cleanups: void 0,
|
|
1265
1253
|
componentCleanup: void 0
|
|
1266
1254
|
}), (e) => {
|
|
1267
1255
|
e.effects = void 0, e.cleanups = void 0, e.componentCleanup = void 0;
|
|
1268
|
-
}, 128),
|
|
1256
|
+
}, 128), G = "_aes-bound", K = new class {
|
|
1269
1257
|
constructor() {
|
|
1270
1258
|
this.records = /* @__PURE__ */ new WeakMap(), this.preservedNodes = /* @__PURE__ */ new WeakSet(), this.ignoredNodes = /* @__PURE__ */ new WeakSet();
|
|
1271
1259
|
}
|
|
@@ -1283,15 +1271,15 @@ var qe = class {
|
|
|
1283
1271
|
}
|
|
1284
1272
|
getOrCreateRecord(e) {
|
|
1285
1273
|
let t = this.records.get(e);
|
|
1286
|
-
return t || (t =
|
|
1274
|
+
return t || (t = Qe.acquire(), this.records.set(e, t), e.classList.add(G)), t;
|
|
1287
1275
|
}
|
|
1288
1276
|
trackEffect(e, t) {
|
|
1289
1277
|
let n = this.getOrCreateRecord(e);
|
|
1290
|
-
n.effects ??=
|
|
1278
|
+
n.effects ??= Xe.acquire(), n.effects.push(t);
|
|
1291
1279
|
}
|
|
1292
1280
|
trackCleanup(e, t) {
|
|
1293
1281
|
let n = this.getOrCreateRecord(e);
|
|
1294
|
-
n.cleanups ??=
|
|
1282
|
+
n.cleanups ??= Ze.acquire(), n.cleanups.push(t);
|
|
1295
1283
|
}
|
|
1296
1284
|
setComponentCleanup(e, t) {
|
|
1297
1285
|
let n = this.getOrCreateRecord(e);
|
|
@@ -1303,118 +1291,118 @@ var qe = class {
|
|
|
1303
1291
|
cleanup(e) {
|
|
1304
1292
|
let t = this.records.get(e);
|
|
1305
1293
|
if (!t) {
|
|
1306
|
-
e.nodeType === 1 && e.classList.remove(
|
|
1294
|
+
e.nodeType === 1 && e.classList.remove(G), this.preservedNodes.delete(e), this.ignoredNodes.delete(e);
|
|
1307
1295
|
return;
|
|
1308
1296
|
}
|
|
1309
|
-
if (this.records.delete(e), this.preservedNodes.delete(e), this.ignoredNodes.delete(e), e.nodeType === 1 && e.classList.remove(
|
|
1310
|
-
let t = e.nodeType === 1 ?
|
|
1311
|
-
|
|
1297
|
+
if (this.records.delete(e), this.preservedNodes.delete(e), this.ignoredNodes.delete(e), e.nodeType === 1 && e.classList.remove(G), U.enabled) {
|
|
1298
|
+
let t = e.nodeType === 1 ? R(e) : e.nodeName || "Node";
|
|
1299
|
+
U.cleanup(B.BINDING, t);
|
|
1312
1300
|
}
|
|
1313
1301
|
if (t.componentCleanup) try {
|
|
1314
1302
|
t.componentCleanup();
|
|
1315
1303
|
} catch (t) {
|
|
1316
|
-
let n = e.nodeType === 1 ?
|
|
1317
|
-
|
|
1304
|
+
let n = e.nodeType === 1 ? R(e) : "Node";
|
|
1305
|
+
U.error(B.MOUNT, H.MOUNT.CLEANUP_ERROR(n), t);
|
|
1318
1306
|
}
|
|
1319
1307
|
if (t.effects) {
|
|
1320
1308
|
let n = t.effects;
|
|
1321
1309
|
for (let t = 0, r = n.length; t < r; t++) try {
|
|
1322
1310
|
n[t].dispose();
|
|
1323
1311
|
} catch (t) {
|
|
1324
|
-
let n = e.nodeType === 1 ?
|
|
1325
|
-
|
|
1312
|
+
let n = e.nodeType === 1 ? R(e) : "Node";
|
|
1313
|
+
U.error(B.BINDING, H.CORE.EFFECT_DISPOSE_ERROR(n), t);
|
|
1326
1314
|
}
|
|
1327
|
-
|
|
1315
|
+
Xe.release(n), t.effects = void 0;
|
|
1328
1316
|
}
|
|
1329
1317
|
if (t.cleanups) {
|
|
1330
1318
|
let n = t.cleanups;
|
|
1331
1319
|
for (let t = 0, r = n.length; t < r; t++) try {
|
|
1332
1320
|
n[t]();
|
|
1333
1321
|
} catch (t) {
|
|
1334
|
-
let n = e.nodeType === 1 ?
|
|
1335
|
-
|
|
1322
|
+
let n = e.nodeType === 1 ? R(e) : "Node";
|
|
1323
|
+
U.error(B.BINDING, H.BINDING.CLEANUP_ERROR(n), t);
|
|
1336
1324
|
}
|
|
1337
|
-
|
|
1325
|
+
Ze.release(n), t.cleanups = void 0;
|
|
1338
1326
|
}
|
|
1339
|
-
|
|
1327
|
+
Qe.release(t);
|
|
1340
1328
|
}
|
|
1341
1329
|
cleanupDescendants(e) {
|
|
1342
|
-
let t = "getElementsByClassName" in e && typeof e.getElementsByClassName == "function" ? e.getElementsByClassName(
|
|
1330
|
+
let t = "getElementsByClassName" in e && typeof e.getElementsByClassName == "function" ? e.getElementsByClassName(G) : e.querySelectorAll(`.${G}`);
|
|
1343
1331
|
for (let e = t.length - 1; e >= 0; e--) {
|
|
1344
1332
|
let n = t[e];
|
|
1345
|
-
n && (this.records.has(n) ? this.cleanup(n) : (n.classList.remove(
|
|
1333
|
+
n && (this.records.has(n) ? this.cleanup(n) : (n.classList.remove(G), U.enabled && U.warn(B.BINDING, `${G} class found on unregistered element:`, n)));
|
|
1346
1334
|
}
|
|
1347
1335
|
}
|
|
1348
1336
|
cleanupTree(e) {
|
|
1349
1337
|
(e.nodeType === 1 || e.nodeType === 11) && this.cleanupDescendants(e), this.cleanup(e);
|
|
1350
1338
|
}
|
|
1351
|
-
}(),
|
|
1352
|
-
function
|
|
1353
|
-
if (
|
|
1339
|
+
}(), $e = /* @__PURE__ */ new Map();
|
|
1340
|
+
function et(e) {
|
|
1341
|
+
if ($e.has(e)) return;
|
|
1354
1342
|
let t = new MutationObserver((e) => {
|
|
1355
1343
|
for (let t = 0, n = e.length; t < n; t++) {
|
|
1356
1344
|
let n = e[t].removedNodes;
|
|
1357
1345
|
for (let e = 0, t = n.length; e < t; e++) {
|
|
1358
1346
|
let t = n[e];
|
|
1359
|
-
t.nodeType === 1 && (t.isConnected ||
|
|
1347
|
+
t.nodeType === 1 && (t.isConnected || K.isKept(t) || K.isIgnored(t) || K.cleanupTree(t));
|
|
1360
1348
|
}
|
|
1361
1349
|
}
|
|
1362
1350
|
});
|
|
1363
1351
|
t.observe(e, {
|
|
1364
1352
|
childList: !0,
|
|
1365
1353
|
subtree: !0
|
|
1366
|
-
}),
|
|
1354
|
+
}), $e.set(e, t);
|
|
1367
1355
|
}
|
|
1368
|
-
function
|
|
1369
|
-
|
|
1356
|
+
function tt() {
|
|
1357
|
+
$e.forEach((e) => e.disconnect()), $e.clear();
|
|
1370
1358
|
}
|
|
1371
1359
|
//#endregion
|
|
1372
1360
|
//#region src/core/jquery-patch.ts
|
|
1373
|
-
var
|
|
1374
|
-
if (e[
|
|
1375
|
-
let t =
|
|
1361
|
+
var nt = Symbol("atom-effect-internal"), rt = /* @__PURE__ */ new WeakMap(), q = null, it = (e) => {
|
|
1362
|
+
if (e[nt]) return e;
|
|
1363
|
+
let t = rt.get(e);
|
|
1376
1364
|
return t || (t = function(...t) {
|
|
1377
|
-
return
|
|
1378
|
-
}, t[
|
|
1365
|
+
return ke(() => e.apply(this, t));
|
|
1366
|
+
}, t[nt] = !0, rt.set(e, t)), t;
|
|
1379
1367
|
};
|
|
1380
|
-
function
|
|
1368
|
+
function at(e) {
|
|
1381
1369
|
let t = {}, n = Object.entries(e);
|
|
1382
1370
|
for (let e = 0, r = n.length; e < r; e++) {
|
|
1383
1371
|
let r = n[e], i = r[0], a = r[1];
|
|
1384
|
-
a && (t[i] =
|
|
1372
|
+
a && (t[i] = it(a));
|
|
1385
1373
|
}
|
|
1386
1374
|
return t;
|
|
1387
1375
|
}
|
|
1388
|
-
function
|
|
1376
|
+
function ot(e) {
|
|
1389
1377
|
let t = {}, n = Object.entries(e);
|
|
1390
1378
|
for (let e = 0, r = n.length; e < r; e++) {
|
|
1391
1379
|
let r = n[e], i = r[0], a = r[1];
|
|
1392
|
-
t[i] = a ?
|
|
1380
|
+
t[i] = a ? rt.get(a) ?? a : void 0;
|
|
1393
1381
|
}
|
|
1394
1382
|
return t;
|
|
1395
1383
|
}
|
|
1396
|
-
function
|
|
1397
|
-
if (
|
|
1398
|
-
|
|
1384
|
+
function st() {
|
|
1385
|
+
if (q !== null) return;
|
|
1386
|
+
q = {
|
|
1399
1387
|
on: e.fn.on,
|
|
1400
1388
|
off: e.fn.off,
|
|
1401
1389
|
remove: e.fn.remove,
|
|
1402
1390
|
empty: e.fn.empty,
|
|
1403
1391
|
detach: e.fn.detach
|
|
1404
1392
|
};
|
|
1405
|
-
let t =
|
|
1393
|
+
let t = q;
|
|
1406
1394
|
e.fn.remove = function(e) {
|
|
1407
1395
|
let n = e ? this.filter(e) : this;
|
|
1408
1396
|
for (let e = 0, t = n.length; e < t; e++) {
|
|
1409
1397
|
let t = n[e];
|
|
1410
|
-
t && (
|
|
1398
|
+
t && (K.markIgnored(t), K.cleanupTree(t));
|
|
1411
1399
|
}
|
|
1412
1400
|
let r = t.remove.call(this, e);
|
|
1413
1401
|
return r === void 0 ? this : r;
|
|
1414
1402
|
}, e.fn.empty = function() {
|
|
1415
1403
|
for (let e = 0, t = this.length; e < t; e++) {
|
|
1416
1404
|
let t = this[e];
|
|
1417
|
-
t?.hasChildNodes() &&
|
|
1405
|
+
t?.hasChildNodes() && K.cleanupDescendants(t);
|
|
1418
1406
|
}
|
|
1419
1407
|
let e = t.empty.call(this);
|
|
1420
1408
|
return e === void 0 ? this : e;
|
|
@@ -1422,67 +1410,67 @@ function ot() {
|
|
|
1422
1410
|
let n = e ? this.filter(e) : this;
|
|
1423
1411
|
for (let e = 0, t = n.length; e < t; e++) {
|
|
1424
1412
|
let t = n[e];
|
|
1425
|
-
t &&
|
|
1413
|
+
t && K.keep(t);
|
|
1426
1414
|
}
|
|
1427
1415
|
let r = t.detach.call(this, e);
|
|
1428
1416
|
return r === void 0 ? this : r;
|
|
1429
1417
|
}, e.fn.on = function(...e) {
|
|
1430
1418
|
let n = e[0];
|
|
1431
|
-
if (n && typeof n == "object") e[0] =
|
|
1419
|
+
if (n && typeof n == "object") e[0] = at(n);
|
|
1432
1420
|
else {
|
|
1433
1421
|
let t = e.length - 1;
|
|
1434
|
-
t >= 0 && typeof e[t] == "function" && (e[t] =
|
|
1422
|
+
t >= 0 && typeof e[t] == "function" && (e[t] = it(e[t]));
|
|
1435
1423
|
}
|
|
1436
1424
|
let r = t.on.apply(this, e);
|
|
1437
1425
|
return r === void 0 ? this : r;
|
|
1438
1426
|
}, e.fn.off = function(...e) {
|
|
1439
1427
|
let n = e[0];
|
|
1440
|
-
if (n && typeof n == "object") e[0] =
|
|
1428
|
+
if (n && typeof n == "object") e[0] = ot(n);
|
|
1441
1429
|
else {
|
|
1442
1430
|
let t = e.length - 1;
|
|
1443
1431
|
if (t >= 0 && typeof e[t] == "function") {
|
|
1444
1432
|
let n = e[t];
|
|
1445
|
-
e[t] =
|
|
1433
|
+
e[t] = rt.get(n) ?? n;
|
|
1446
1434
|
}
|
|
1447
1435
|
}
|
|
1448
1436
|
let r = t.off.apply(this, e);
|
|
1449
1437
|
return r === void 0 ? this : r;
|
|
1450
1438
|
};
|
|
1451
1439
|
}
|
|
1452
|
-
function
|
|
1453
|
-
|
|
1440
|
+
function ct() {
|
|
1441
|
+
q !== null && (e.fn.on = q.on, e.fn.off = q.off, e.fn.remove = q.remove, e.fn.empty = q.empty, e.fn.detach = q.detach, q = null);
|
|
1454
1442
|
}
|
|
1455
1443
|
//#endregion
|
|
1456
1444
|
//#region src/types.ts
|
|
1457
|
-
var
|
|
1445
|
+
var J = /* @__PURE__ */ function(e) {
|
|
1458
1446
|
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;
|
|
1459
|
-
}({}),
|
|
1460
|
-
function
|
|
1461
|
-
e[
|
|
1447
|
+
}({}), lt = 0;
|
|
1448
|
+
function Y(e) {
|
|
1449
|
+
e[nt] = !0;
|
|
1462
1450
|
}
|
|
1463
|
-
var
|
|
1451
|
+
var ut = class {
|
|
1464
1452
|
constructor(e, t, n) {
|
|
1465
1453
|
this.flags = 0, this.timeoutId = void 0, this.handleCompositionStart = () => {
|
|
1466
|
-
this.flags |=
|
|
1454
|
+
this.flags |= J.Composing;
|
|
1467
1455
|
}, this.handleCompositionEnd = () => {
|
|
1468
|
-
this.flags &= ~
|
|
1456
|
+
this.flags &= ~J.Composing, this.handleInput();
|
|
1469
1457
|
}, this.handleFocus = () => {
|
|
1470
|
-
this.flags |=
|
|
1458
|
+
this.flags |= J.Focused;
|
|
1471
1459
|
}, this.handleBlur = () => {
|
|
1472
|
-
this.flags &= ~
|
|
1473
|
-
let e = !!(this.flags &
|
|
1474
|
-
this.flags &= ~
|
|
1460
|
+
this.flags &= ~J.Focused;
|
|
1461
|
+
let e = !!(this.flags & J.Composing);
|
|
1462
|
+
this.flags &= ~J.Composing, this.flushPendingDebounce(), e && this.timeoutId === void 0 && this.syncAtomFromDom(), this.normalizeDomValue();
|
|
1475
1463
|
}, this.syncDomFromAtom = () => {
|
|
1476
1464
|
let e = this.atom.value;
|
|
1477
|
-
|
|
1465
|
+
D(() => {
|
|
1478
1466
|
let t = this.format(e), n;
|
|
1479
1467
|
if (n = this.isMultipleSelect ? this.$el.val() || [] : this.el.value, this.equal(n, e)) return;
|
|
1480
|
-
let r = !!(this.flags &
|
|
1468
|
+
let r = !!(this.flags & J.Focused);
|
|
1481
1469
|
if (r) try {
|
|
1482
1470
|
let t = this.isMultipleSelect ? n : this.parse(this.el.value);
|
|
1483
1471
|
if (this.equal(t, e)) return;
|
|
1484
1472
|
} catch {}
|
|
1485
|
-
this.flags |=
|
|
1473
|
+
this.flags |= J.SyncingToDom;
|
|
1486
1474
|
try {
|
|
1487
1475
|
if (this.isMultipleSelect) this.$el.val(e);
|
|
1488
1476
|
else if (r && (this.el instanceof HTMLInputElement || this.el instanceof HTMLTextAreaElement)) try {
|
|
@@ -1494,22 +1482,22 @@ var lt = class {
|
|
|
1494
1482
|
this.el.value = t;
|
|
1495
1483
|
}
|
|
1496
1484
|
else this.el.value = t;
|
|
1497
|
-
|
|
1485
|
+
U.enabled && U.domUpdated(B.BINDING, this.$el, "val", t);
|
|
1498
1486
|
} finally {
|
|
1499
|
-
this.flags &= ~
|
|
1487
|
+
this.flags &= ~J.SyncingToDom;
|
|
1500
1488
|
}
|
|
1501
1489
|
});
|
|
1502
1490
|
}, this.cleanup = () => {
|
|
1503
1491
|
this.$el.off(this.ns), clearTimeout(this.timeoutId), this.timeoutId = void 0;
|
|
1504
|
-
}, this.$el = e, this.el = e[0], this.atom = t, this.isMultipleSelect = this.el.tagName === "SELECT" && this.el.multiple, this.ns = `.atomBind-${++
|
|
1505
|
-
let r = n.debounce ?? 0, i = n.event ??
|
|
1492
|
+
}, this.$el = e, this.el = e[0], this.atom = t, this.isMultipleSelect = this.el.tagName === "SELECT" && this.el.multiple, this.ns = `.atomBind-${++lt}`;
|
|
1493
|
+
let r = n.debounce ?? 0, i = n.event ?? Me.EVENT;
|
|
1506
1494
|
this.parse = n.parse ?? ((e) => e), this.format = n.format ?? ((e) => this.isMultipleSelect ? (Array.isArray(e) ? e : e ? [String(e)] : []).join(",") : String(e ?? ""));
|
|
1507
1495
|
let a = n.equal ?? Object.is;
|
|
1508
1496
|
this.equal = (e, t) => a(e, t) ? !0 : Array.isArray(e) && Array.isArray(t) ? e.length === t.length && e.every((e, n) => Object.is(e, t[n])) : !1, r > 0 ? this.handleInput = () => {
|
|
1509
|
-
this.flags &
|
|
1497
|
+
this.flags & J.Composing || (clearTimeout(this.timeoutId), this.timeoutId = setTimeout(() => this.syncAtomFromDom(), r));
|
|
1510
1498
|
} : this.handleInput = () => {
|
|
1511
|
-
this.flags &
|
|
1512
|
-
},
|
|
1499
|
+
this.flags & J.Composing || this.syncAtomFromDom();
|
|
1500
|
+
}, Y(this.handleFocus), Y(this.handleBlur), Y(this.handleCompositionStart), Y(this.handleCompositionEnd), Y(this.handleInput), this.bindEvents(i);
|
|
1513
1501
|
}
|
|
1514
1502
|
flushPendingDebounce() {
|
|
1515
1503
|
this.timeoutId !== void 0 && (clearTimeout(this.timeoutId), this.timeoutId = void 0, this.syncAtomFromDom());
|
|
@@ -1522,17 +1510,17 @@ var lt = class {
|
|
|
1522
1510
|
} else this.el.value !== e && (this.el.value = e);
|
|
1523
1511
|
}
|
|
1524
1512
|
syncAtomFromDom() {
|
|
1525
|
-
if (!(this.flags &
|
|
1526
|
-
this.flags |=
|
|
1513
|
+
if (!(this.flags & J.Busy)) {
|
|
1514
|
+
this.flags |= J.SyncingToAtom;
|
|
1527
1515
|
try {
|
|
1528
1516
|
let e;
|
|
1529
1517
|
e = this.isMultipleSelect ? this.$el.val() || [] : this.el.value;
|
|
1530
1518
|
let t = this.parse(e);
|
|
1531
1519
|
this.equal(this.atom.peek(), t) || (this.atom.value = t);
|
|
1532
1520
|
} catch (e) {
|
|
1533
|
-
|
|
1521
|
+
U.warn(B.BINDING, H.BINDING.PARSE_ERROR(e instanceof Error ? e.message : String(e)), e);
|
|
1534
1522
|
} finally {
|
|
1535
|
-
this.flags &= ~
|
|
1523
|
+
this.flags &= ~J.SyncingToAtom;
|
|
1536
1524
|
}
|
|
1537
1525
|
}
|
|
1538
1526
|
}
|
|
@@ -1541,74 +1529,100 @@ var lt = class {
|
|
|
1541
1529
|
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);
|
|
1542
1530
|
}
|
|
1543
1531
|
};
|
|
1544
|
-
function
|
|
1545
|
-
let r = new
|
|
1532
|
+
function dt(e, t, n) {
|
|
1533
|
+
let r = new ut(e, t, n);
|
|
1546
1534
|
return {
|
|
1547
|
-
fx:
|
|
1535
|
+
fx: I(r.syncDomFromAtom),
|
|
1548
1536
|
cleanup: r.cleanup
|
|
1549
1537
|
};
|
|
1550
1538
|
}
|
|
1551
1539
|
//#endregion
|
|
1552
1540
|
//#region src/core/effect-factory.ts
|
|
1553
|
-
function
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1541
|
+
function ft(e, t, n, r) {
|
|
1542
|
+
let i = null, a = (t) => {
|
|
1543
|
+
if (Ae(t)) {
|
|
1544
|
+
let a = t;
|
|
1545
|
+
i = a, a.then((t) => {
|
|
1546
|
+
i === a && D(() => {
|
|
1547
|
+
try {
|
|
1548
|
+
n(t), U.enabled && U.domUpdated(B.BINDING, e, `${r} (async)`, t);
|
|
1549
|
+
} catch (e) {
|
|
1550
|
+
U.error(B.BINDING, H.BINDING.UPDATER_ERROR(r), e);
|
|
1551
|
+
}
|
|
1552
|
+
});
|
|
1553
|
+
}).catch((e) => {
|
|
1554
|
+
i === a && U.error(B.BINDING, H.BINDING.UPDATER_ERROR(r), e);
|
|
1566
1555
|
});
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1556
|
+
} else {
|
|
1557
|
+
i = null;
|
|
1558
|
+
try {
|
|
1559
|
+
n(t), U.enabled && U.domUpdated(B.BINDING, e, r, t);
|
|
1560
|
+
} catch (e) {
|
|
1561
|
+
U.error(B.BINDING, H.BINDING.UPDATER_ERROR(r, !0), e);
|
|
1562
|
+
}
|
|
1574
1563
|
}
|
|
1575
|
-
|
|
1576
|
-
|
|
1564
|
+
};
|
|
1565
|
+
L(t) ? K.trackEffect(e, I(() => {
|
|
1566
|
+
let e = t.value;
|
|
1567
|
+
D(() => a(e));
|
|
1568
|
+
}, { name: r })) : typeof t == "function" ? K.trackEffect(e, I(() => {
|
|
1569
|
+
let e = t();
|
|
1570
|
+
D(() => a(e));
|
|
1571
|
+
}, { name: r })) : D(() => a(t));
|
|
1577
1572
|
}
|
|
1578
|
-
function
|
|
1573
|
+
function pt(e, t, n, r) {
|
|
1579
1574
|
let i = Object.keys(t), a = [], o = {};
|
|
1580
1575
|
for (let e = 0; e < i.length; e++) {
|
|
1581
1576
|
let n = i[e], r = t[n];
|
|
1582
|
-
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
let i =
|
|
1586
|
-
for (let e = 0; e <
|
|
1587
|
-
let n =
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1577
|
+
L(r) || typeof r == "function" ? a.push(n) : o[n] = r;
|
|
1578
|
+
}
|
|
1579
|
+
let s = 0, c = (t) => {
|
|
1580
|
+
let i = Object.keys(t), a = [], o = {};
|
|
1581
|
+
for (let e = 0; e < i.length; e++) {
|
|
1582
|
+
let n = i[e], r = t[n];
|
|
1583
|
+
Ae(r) ? a.push(r.then((e) => ({
|
|
1584
|
+
key: n,
|
|
1585
|
+
val: e
|
|
1586
|
+
}))) : o[n] = r;
|
|
1587
|
+
}
|
|
1588
|
+
if (a.length > 0) {
|
|
1589
|
+
let t = ++s;
|
|
1590
|
+
Promise.all(a).then((i) => {
|
|
1591
|
+
if (t === s) {
|
|
1592
|
+
for (let e = 0; e < i.length; e++) {
|
|
1593
|
+
let { key: t, val: n } = i[e];
|
|
1594
|
+
o[t] = n;
|
|
1595
|
+
}
|
|
1596
|
+
D(() => {
|
|
1597
|
+
try {
|
|
1598
|
+
n(o), U.enabled && U.domUpdated(B.BINDING, e, `${r} (async)`, o);
|
|
1599
|
+
} catch (e) {
|
|
1600
|
+
U.error(B.BINDING, H.BINDING.UPDATER_ERROR(r), e);
|
|
1601
|
+
}
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
});
|
|
1605
|
+
} else {
|
|
1606
|
+
s++;
|
|
1591
1607
|
try {
|
|
1592
|
-
n(
|
|
1608
|
+
n(o), U.enabled && U.domUpdated(B.BINDING, e, r, o);
|
|
1593
1609
|
} catch (e) {
|
|
1594
|
-
|
|
1595
|
-
return;
|
|
1610
|
+
U.error(B.BINDING, H.BINDING.UPDATER_ERROR(r, !0), e);
|
|
1596
1611
|
}
|
|
1597
|
-
G.enabled && G.domUpdated(H.BINDING, e, r, i);
|
|
1598
|
-
});
|
|
1599
|
-
}, { name: r })) : O(() => {
|
|
1600
|
-
try {
|
|
1601
|
-
n(o);
|
|
1602
|
-
} catch (e) {
|
|
1603
|
-
G.error(H.BINDING, W.BINDING.UPDATER_ERROR(r, !0), e);
|
|
1604
|
-
return;
|
|
1605
1612
|
}
|
|
1606
|
-
|
|
1607
|
-
|
|
1613
|
+
};
|
|
1614
|
+
a.length > 0 ? K.trackEffect(e, I(() => {
|
|
1615
|
+
let e = { ...o };
|
|
1616
|
+
for (let n = 0; n < a.length; n++) {
|
|
1617
|
+
let r = a[n], i = t[r];
|
|
1618
|
+
e[r] = L(i) ? i.value : i();
|
|
1619
|
+
}
|
|
1620
|
+
D(() => c(e));
|
|
1621
|
+
}, { name: r })) : D(() => c(o));
|
|
1608
1622
|
}
|
|
1609
1623
|
//#endregion
|
|
1610
1624
|
//#region src/utils/sanitize.ts
|
|
1611
|
-
var
|
|
1625
|
+
var mt = new Set([
|
|
1612
1626
|
"href",
|
|
1613
1627
|
"src",
|
|
1614
1628
|
"action",
|
|
@@ -1623,144 +1637,157 @@ var pt = new Set([
|
|
|
1623
1637
|
"usemap",
|
|
1624
1638
|
"classid",
|
|
1625
1639
|
"codebase"
|
|
1626
|
-
]),
|
|
1640
|
+
]), ht = /^\s*(?:javascript|vbscript)\s*:/i, gt = /(?: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, _t = /url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i, vt = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, yt = /&#x([0-9a-f]+);?|&#([0-9]+);?/gi, bt = {
|
|
1627
1641
|
colon: ":",
|
|
1628
1642
|
Tab: " ",
|
|
1629
1643
|
NewLine: "\n"
|
|
1630
|
-
},
|
|
1631
|
-
function
|
|
1644
|
+
}, xt = /&(colon|Tab|NewLine);/g, St = /<\?[\s\S]*?\?>/g, Ct = /(<(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, wt = /(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, Tt = /data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/gi, Et = /\bon\w+\s*=/gim, Dt = new RegExp(gt.source, "gim");
|
|
1645
|
+
function X(e) {
|
|
1632
1646
|
let t = String(e ?? "");
|
|
1633
|
-
t = t.replace(
|
|
1647
|
+
t = t.replace(vt, ""), t = t.replace(yt, (e, t, n) => String.fromCodePoint(t ? parseInt(t, 16) : parseInt(n, 10))), t = t.replace(xt, (e, t) => bt[t] ?? ""), t = t.replace(St, "");
|
|
1634
1648
|
let n;
|
|
1635
1649
|
do
|
|
1636
|
-
n = t, t = t.replace(
|
|
1650
|
+
n = t, t = t.replace(Ct, "");
|
|
1637
1651
|
while (t !== n);
|
|
1638
|
-
return t = t.replace(
|
|
1639
|
-
}
|
|
1640
|
-
function Ot(e, t) {
|
|
1641
|
-
return pt.has(e.toLowerCase()) ? mt.test(t) : !1;
|
|
1652
|
+
return t = t.replace(wt, "data-unsafe-protocol:"), t = t.replace(Tt, "data-unsafe-protocol:"), t = t.replace(Et, "data-unsafe-attr="), t = t.replace(Dt, "data-unsafe-css:"), t;
|
|
1642
1653
|
}
|
|
1643
|
-
function
|
|
1644
|
-
return e.toLowerCase().includes("url(") ?
|
|
1654
|
+
function Ot(e) {
|
|
1655
|
+
return e.toLowerCase().includes("url(") ? _t.test(e) : !1;
|
|
1645
1656
|
}
|
|
1646
1657
|
//#endregion
|
|
1647
1658
|
//#region src/bindings/unified.ts
|
|
1648
|
-
var
|
|
1649
|
-
function
|
|
1650
|
-
let t =
|
|
1651
|
-
return t === void 0 ? (t = e.includes("-") ? e.replace(/-./g, (e) => e[1].toUpperCase()) : e,
|
|
1659
|
+
var kt = /* @__PURE__ */ new Map();
|
|
1660
|
+
function At(e) {
|
|
1661
|
+
let t = kt.get(e);
|
|
1662
|
+
return t === void 0 ? (t = e.includes("-") ? e.replace(/-./g, (e) => e[1].toUpperCase()) : e, kt.set(e, t), t) : t;
|
|
1652
1663
|
}
|
|
1653
|
-
var
|
|
1654
|
-
function
|
|
1655
|
-
let t =
|
|
1656
|
-
return t || (t =
|
|
1664
|
+
var jt = /* @__PURE__ */ new WeakMap();
|
|
1665
|
+
function Mt(e) {
|
|
1666
|
+
let t = jt.get(e);
|
|
1667
|
+
return t || (t = F(() => {
|
|
1668
|
+
let t = e.value;
|
|
1669
|
+
return Ae(t) ? t.then((e) => X(e)) : X(t);
|
|
1670
|
+
}), jt.set(e, t)), t;
|
|
1657
1671
|
}
|
|
1658
|
-
function
|
|
1672
|
+
function Nt(e) {
|
|
1659
1673
|
return {
|
|
1660
1674
|
el: e,
|
|
1661
|
-
trackCleanup: (t) =>
|
|
1675
|
+
trackCleanup: (t) => K.trackCleanup(e, t)
|
|
1662
1676
|
};
|
|
1663
1677
|
}
|
|
1664
|
-
function
|
|
1678
|
+
function Pt(e, t, n) {
|
|
1665
1679
|
let r = e.el;
|
|
1666
|
-
|
|
1680
|
+
ft(r, t, (e) => {
|
|
1667
1681
|
let t = n ? n(e) : typeof e == "string" ? e : String(e ?? "");
|
|
1668
1682
|
r.textContent !== t && (r.textContent = t);
|
|
1669
1683
|
}, "text");
|
|
1670
1684
|
}
|
|
1671
|
-
function
|
|
1672
|
-
let n = e.el;
|
|
1673
|
-
|
|
1674
|
-
|
|
1685
|
+
function Ft(e, t) {
|
|
1686
|
+
let n = e.el, r = xe(t) ? Mt(t) : t;
|
|
1687
|
+
ft(n, r, (e) => {
|
|
1688
|
+
let i = r === t ? X(e) : e;
|
|
1689
|
+
n.innerHTML !== i && (K.cleanupDescendants(n), n.innerHTML = i);
|
|
1675
1690
|
}, "html");
|
|
1676
1691
|
}
|
|
1677
|
-
function
|
|
1678
|
-
let n = e.el;
|
|
1679
|
-
|
|
1692
|
+
function It(e, t) {
|
|
1693
|
+
let n = e.el, r = {};
|
|
1694
|
+
for (let e in t) z.call(t, e) && (r[e] = e.trim().split(/\s+/).filter(Boolean));
|
|
1695
|
+
pt(n, t, (e) => {
|
|
1680
1696
|
for (let t in e) {
|
|
1681
|
-
let
|
|
1682
|
-
|
|
1697
|
+
let i = e[t], a = r[t];
|
|
1698
|
+
i ? n.classList.add(...a) : n.classList.remove(...a);
|
|
1683
1699
|
}
|
|
1684
1700
|
}, "class");
|
|
1685
1701
|
}
|
|
1686
|
-
function
|
|
1687
|
-
let n = e.el, r = n.style;
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1702
|
+
function Lt(e, t) {
|
|
1703
|
+
let n = e.el, r = n.style, i = {}, a = {};
|
|
1704
|
+
for (let e in t) if (z.call(t, e)) {
|
|
1705
|
+
let n = t[e], [r, o] = Array.isArray(n) ? n : [n, ""];
|
|
1706
|
+
i[e] = r, a[e] = {
|
|
1707
|
+
camel: At(e),
|
|
1708
|
+
unit: o
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1711
|
+
pt(n, i, (e) => {
|
|
1712
|
+
for (let t in e) {
|
|
1713
|
+
let n = e[t], { camel: i, unit: o } = a[t], s = o ? String(n) + o : String(n);
|
|
1714
|
+
Ot(s) || r[i] !== s && (r[i] = s);
|
|
1695
1715
|
}
|
|
1696
|
-
},
|
|
1716
|
+
}, "css");
|
|
1697
1717
|
}
|
|
1698
|
-
function
|
|
1699
|
-
let n = e.el, r = {};
|
|
1700
|
-
for (let e in t) if (
|
|
1701
|
-
|
|
1702
|
-
|
|
1718
|
+
function Rt(e, t) {
|
|
1719
|
+
let n = e.el, r = {}, i = {};
|
|
1720
|
+
for (let e in t) if (z.call(t, e)) {
|
|
1721
|
+
let n = e.toLowerCase();
|
|
1722
|
+
if (n.startsWith("on")) {
|
|
1723
|
+
console.warn(`${B.BINDING} ${H.SECURITY.BLOCKED_EVENT_HANDLER(e)}`);
|
|
1703
1724
|
continue;
|
|
1704
1725
|
}
|
|
1705
|
-
r[e] = t[e]
|
|
1726
|
+
r[e] = t[e], i[e] = {
|
|
1727
|
+
isAria: n.startsWith("aria-"),
|
|
1728
|
+
isUrl: mt.has(n)
|
|
1729
|
+
};
|
|
1706
1730
|
}
|
|
1707
|
-
|
|
1731
|
+
let a = {};
|
|
1732
|
+
for (let e in r) a[e] = n.getAttribute(e);
|
|
1733
|
+
pt(n, r, (e) => {
|
|
1708
1734
|
for (let t in e) {
|
|
1709
|
-
let r = e[t], i =
|
|
1710
|
-
if (r == null || r === !1 && !
|
|
1711
|
-
n.removeAttribute(t);
|
|
1735
|
+
let r = e[t], o = i[t], s = o.isAria;
|
|
1736
|
+
if (r == null || r === !1 && !s) {
|
|
1737
|
+
a[t] !== null && (n.removeAttribute(t), a[t] = null);
|
|
1712
1738
|
continue;
|
|
1713
1739
|
}
|
|
1714
|
-
let
|
|
1715
|
-
if (
|
|
1716
|
-
console.warn(`${
|
|
1740
|
+
let c = r === !0 ? s ? "true" : t : String(r);
|
|
1741
|
+
if (o.isUrl && ht.test(c)) {
|
|
1742
|
+
console.warn(`${B.BINDING} ${H.SECURITY.BLOCKED_PROTOCOL(t)}`);
|
|
1717
1743
|
continue;
|
|
1718
1744
|
}
|
|
1719
|
-
|
|
1745
|
+
a[t] !== c && (n.setAttribute(t, c), a[t] = c);
|
|
1720
1746
|
}
|
|
1721
1747
|
}, "attr");
|
|
1722
1748
|
}
|
|
1723
|
-
function
|
|
1724
|
-
let n = e.el, r = {};
|
|
1725
|
-
for (let e in t) if (
|
|
1726
|
-
|
|
1727
|
-
|
|
1749
|
+
function zt(e, t) {
|
|
1750
|
+
let n = e.el, r = {}, i = {};
|
|
1751
|
+
for (let e in t) if (z.call(t, e)) {
|
|
1752
|
+
let n = e.toLowerCase();
|
|
1753
|
+
if (n.startsWith("on")) {
|
|
1754
|
+
console.warn(`${B.BINDING} ${H.SECURITY.BLOCKED_EVENT_HANDLER(e)}`);
|
|
1728
1755
|
continue;
|
|
1729
1756
|
}
|
|
1730
|
-
if (
|
|
1731
|
-
console.warn(`${
|
|
1757
|
+
if (Fe.has(e)) {
|
|
1758
|
+
console.warn(`${B.BINDING} ${H.SECURITY.BLOCKED_PROP(e)}`);
|
|
1732
1759
|
continue;
|
|
1733
1760
|
}
|
|
1734
|
-
r[e] = t[e];
|
|
1761
|
+
r[e] = t[e], i[e] = { isUrl: mt.has(n) };
|
|
1735
1762
|
}
|
|
1736
|
-
|
|
1763
|
+
pt(e.el, r, (e) => {
|
|
1737
1764
|
for (let t in e) {
|
|
1738
|
-
let r = e[t]
|
|
1739
|
-
if (
|
|
1740
|
-
console.warn(`${
|
|
1765
|
+
let r = e[t];
|
|
1766
|
+
if (i[t].isUrl && typeof r == "string" && ht.test(r)) {
|
|
1767
|
+
console.warn(`${B.BINDING} ${H.SECURITY.BLOCKED_PROTOCOL(t)}`);
|
|
1741
1768
|
continue;
|
|
1742
1769
|
}
|
|
1743
1770
|
n[t] !== r && (n[t] = r);
|
|
1744
1771
|
}
|
|
1745
1772
|
}, "prop");
|
|
1746
1773
|
}
|
|
1747
|
-
function
|
|
1774
|
+
function Bt(e, t, n) {
|
|
1748
1775
|
let r = e.el, i = n ? "hide" : "show", a = r.style.display, o = a === "none" ? "" : a;
|
|
1749
|
-
|
|
1776
|
+
ft(r, t, (e) => {
|
|
1750
1777
|
let t = n === !!e ? "none" : o;
|
|
1751
1778
|
r.style.display !== t && (r.style.display = t);
|
|
1752
1779
|
}, i);
|
|
1753
1780
|
}
|
|
1754
|
-
function
|
|
1781
|
+
function Vt(t, n, r = {}) {
|
|
1755
1782
|
let i = t.el.tagName.toLowerCase();
|
|
1756
|
-
if (!
|
|
1757
|
-
console.warn(`${
|
|
1783
|
+
if (!Pe.has(i)) {
|
|
1784
|
+
console.warn(`${B.BINDING} ${H.BINDING.INVALID_INPUT_ELEMENT(i)}`);
|
|
1758
1785
|
return;
|
|
1759
1786
|
}
|
|
1760
|
-
let { fx: a, cleanup: o } =
|
|
1761
|
-
|
|
1787
|
+
let { fx: a, cleanup: o } = dt(e(t.el), n, r);
|
|
1788
|
+
K.trackEffect(t.el, a), t.trackCleanup(o);
|
|
1762
1789
|
}
|
|
1763
|
-
function
|
|
1790
|
+
function Ht(t, n) {
|
|
1764
1791
|
let r = t.el, i = e(r), a = r.type === "radio", o = () => {
|
|
1765
1792
|
let t = r.checked;
|
|
1766
1793
|
if (n.peek() !== t && (n.value = t, a && t && r.name)) {
|
|
@@ -1768,67 +1795,143 @@ function Ut(t, n) {
|
|
|
1768
1795
|
(r.form ? e(r.form) : e(document)).find(`input[type="radio"][name="${t}"]`).not(r).trigger("change.atomRadioSync");
|
|
1769
1796
|
}
|
|
1770
1797
|
};
|
|
1771
|
-
o[
|
|
1772
|
-
let s =
|
|
1798
|
+
o[nt] = !0, i.on("change change.atomRadioSync", o), t.trackCleanup(() => i.off("change change.atomRadioSync", o));
|
|
1799
|
+
let s = I(() => {
|
|
1773
1800
|
let e = !!n.value;
|
|
1774
|
-
|
|
1775
|
-
r.checked !== e && (r.checked = e,
|
|
1801
|
+
D(() => {
|
|
1802
|
+
r.checked !== e && (r.checked = e, U.enabled && U.domUpdated(B.BINDING, r, "checked", e));
|
|
1776
1803
|
});
|
|
1777
1804
|
});
|
|
1778
|
-
|
|
1805
|
+
K.trackEffect(r, s);
|
|
1779
1806
|
}
|
|
1780
|
-
function
|
|
1807
|
+
function Ut(t, n) {
|
|
1781
1808
|
let r = e(t.el);
|
|
1782
1809
|
r.on(n), t.trackCleanup(() => r.off(n));
|
|
1783
1810
|
}
|
|
1784
|
-
function
|
|
1811
|
+
function Wt(t, n, r) {
|
|
1785
1812
|
let i = e(t.el);
|
|
1786
1813
|
i.on(n, r), t.trackCleanup(() => i.off(n, r));
|
|
1787
1814
|
}
|
|
1788
|
-
function
|
|
1789
|
-
|
|
1815
|
+
function Gt(e) {
|
|
1816
|
+
K.cleanupTree(e);
|
|
1817
|
+
}
|
|
1818
|
+
//#endregion
|
|
1819
|
+
//#region src/bindings/form.ts
|
|
1820
|
+
function Kt(e, t, n, r) {
|
|
1821
|
+
if (n === t.length) return r;
|
|
1822
|
+
let i = t[n], a = e && typeof e == "object" ? e : {}, o = a[i], s = Kt(o, t, n + 1, r);
|
|
1823
|
+
return Object.is(o, s) ? e : {
|
|
1824
|
+
...a,
|
|
1825
|
+
[i]: s
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
function qt(e, t) {
|
|
1829
|
+
let n = Symbol.for("atom-effect/atom"), r = Symbol.for("atom-effect/writable"), i = t.includes(".") ? t.split(".") : [t], a = (e) => {
|
|
1830
|
+
let t = e;
|
|
1831
|
+
for (let e = 0, n = i.length; e < n && t != null; e++) t = t[i[e]];
|
|
1832
|
+
return t;
|
|
1833
|
+
};
|
|
1834
|
+
return {
|
|
1835
|
+
get value() {
|
|
1836
|
+
return a(e.value);
|
|
1837
|
+
},
|
|
1838
|
+
set value(t) {
|
|
1839
|
+
let n = e.peek(), r = Kt(n, i, 0, t);
|
|
1840
|
+
r !== n && (e.value = r);
|
|
1841
|
+
},
|
|
1842
|
+
peek() {
|
|
1843
|
+
return a(e.peek());
|
|
1844
|
+
},
|
|
1845
|
+
subscribe(t) {
|
|
1846
|
+
return e.subscribe(t);
|
|
1847
|
+
},
|
|
1848
|
+
subscriberCount() {
|
|
1849
|
+
return e.subscriberCount();
|
|
1850
|
+
},
|
|
1851
|
+
dispose() {},
|
|
1852
|
+
[Symbol.dispose]() {},
|
|
1853
|
+
[n]: !0,
|
|
1854
|
+
[r]: !0
|
|
1855
|
+
};
|
|
1856
|
+
}
|
|
1857
|
+
function Jt(e, t, n = {}) {
|
|
1858
|
+
let r = e.elements, i = (e) => {
|
|
1859
|
+
if (!(e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement)) return;
|
|
1860
|
+
let r = e.name;
|
|
1861
|
+
if (!r || K.hasBind(e)) return;
|
|
1862
|
+
let i = qt(t, r), a = Nt(e);
|
|
1863
|
+
e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") ? Ht(a, i) : Vt(a, i, n);
|
|
1864
|
+
};
|
|
1865
|
+
for (let e = 0, t = r.length; e < t; e++) i(r[e]);
|
|
1866
|
+
let a = new MutationObserver((e) => {
|
|
1867
|
+
for (let t = 0, n = e.length; t < n; t++) {
|
|
1868
|
+
let n = e[t];
|
|
1869
|
+
if (n.type === "childList") {
|
|
1870
|
+
let e = n.addedNodes;
|
|
1871
|
+
for (let t = 0, n = e.length; t < n; t++) {
|
|
1872
|
+
let n = e[t];
|
|
1873
|
+
if (n.nodeType === 1) {
|
|
1874
|
+
let e = n;
|
|
1875
|
+
i(e);
|
|
1876
|
+
let t = e.querySelectorAll("input, select, textarea");
|
|
1877
|
+
for (let e = 0, n = t.length; e < n; e++) i(t[e]);
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
} else n.type === "attributes" && n.attributeName === "name" && i(n.target);
|
|
1881
|
+
}
|
|
1882
|
+
});
|
|
1883
|
+
a.observe(e, {
|
|
1884
|
+
childList: !0,
|
|
1885
|
+
subtree: !0,
|
|
1886
|
+
attributes: !0,
|
|
1887
|
+
attributeFilter: ["name"]
|
|
1888
|
+
}), K.trackCleanup(e, () => a.disconnect());
|
|
1790
1889
|
}
|
|
1791
1890
|
//#endregion
|
|
1792
1891
|
//#region src/bindings/chainable.ts
|
|
1793
1892
|
function Z(e, t) {
|
|
1794
1893
|
for (let n = 0, r = e.length; n < r; n++) {
|
|
1795
1894
|
let r = e[n];
|
|
1796
|
-
r.nodeType === 1 ? t(
|
|
1895
|
+
r.nodeType === 1 ? t(Nt(r), r) : U.enabled && U.log(B.BINDING, `Skipping non-Element node (nodeType=${r.nodeType})`);
|
|
1797
1896
|
}
|
|
1798
1897
|
return e;
|
|
1799
1898
|
}
|
|
1800
1899
|
e.fn.atomText = function(e, t) {
|
|
1801
|
-
return Z(this, (n) =>
|
|
1900
|
+
return Z(this, (n) => Pt(n, e, t));
|
|
1802
1901
|
}, e.fn.atomHtml = function(e) {
|
|
1803
|
-
return Z(this, (t) =>
|
|
1902
|
+
return Z(this, (t) => Ft(t, e));
|
|
1804
1903
|
}, e.fn.atomClass = function(e, t) {
|
|
1805
|
-
if (typeof e == "string" && t === void 0) return console.warn(`${
|
|
1904
|
+
if (typeof e == "string" && t === void 0) return console.warn(`${B.BINDING} ${H.BINDING.MISSING_CONDITION("atomClass")}`), this;
|
|
1806
1905
|
let n = typeof e == "string" ? { [e]: t } : e;
|
|
1807
|
-
return Z(this, (e) =>
|
|
1906
|
+
return Z(this, (e) => It(e, n));
|
|
1808
1907
|
}, e.fn.atomCss = function(e, t, n) {
|
|
1809
|
-
if (typeof e == "string" && t === void 0) return console.warn(`${
|
|
1908
|
+
if (typeof e == "string" && t === void 0) return console.warn(`${B.BINDING} ${H.BINDING.MISSING_SOURCE("atomCss")}`), this;
|
|
1810
1909
|
let r = typeof e == "string" ? { [e]: n ? [t, n] : t } : e;
|
|
1811
|
-
return Z(this, (e) =>
|
|
1910
|
+
return Z(this, (e) => Lt(e, r));
|
|
1812
1911
|
}, e.fn.atomAttr = function(e, t) {
|
|
1813
|
-
if (typeof e == "string" && t === void 0) return console.warn(`${
|
|
1912
|
+
if (typeof e == "string" && t === void 0) return console.warn(`${B.BINDING} ${H.BINDING.MISSING_SOURCE("atomAttr")}`), this;
|
|
1814
1913
|
let n = typeof e == "string" ? { [e]: t } : e;
|
|
1815
|
-
return Z(this, (e) =>
|
|
1914
|
+
return Z(this, (e) => Rt(e, n));
|
|
1816
1915
|
}, e.fn.atomProp = function(e, t) {
|
|
1817
|
-
if (typeof e == "string" && t === void 0) return console.warn(`${
|
|
1916
|
+
if (typeof e == "string" && t === void 0) return console.warn(`${B.BINDING} ${H.BINDING.MISSING_SOURCE("atomProp")}`), this;
|
|
1818
1917
|
let n = typeof e == "string" ? { [e]: t } : e;
|
|
1819
|
-
return Z(this, (e) =>
|
|
1918
|
+
return Z(this, (e) => zt(e, n));
|
|
1820
1919
|
}, e.fn.atomShow = function(e) {
|
|
1821
|
-
return Z(this, (t) =>
|
|
1920
|
+
return Z(this, (t) => Bt(t, e, !1));
|
|
1822
1921
|
}, e.fn.atomHide = function(e) {
|
|
1823
|
-
return Z(this, (t) =>
|
|
1922
|
+
return Z(this, (t) => Bt(t, e, !0));
|
|
1824
1923
|
}, e.fn.atomVal = function(e, t = {}) {
|
|
1825
|
-
return Z(this, (n) =>
|
|
1924
|
+
return Z(this, (n) => Vt(n, e, t));
|
|
1826
1925
|
}, e.fn.atomChecked = function(e) {
|
|
1827
|
-
return Z(this, (t) =>
|
|
1926
|
+
return Z(this, (t) => Ht(t, e));
|
|
1927
|
+
}, e.fn.atomForm = function(e, t = {}) {
|
|
1928
|
+
return Z(this, (n, r) => {
|
|
1929
|
+
r instanceof HTMLFormElement && Jt(r, e, t);
|
|
1930
|
+
});
|
|
1828
1931
|
}, e.fn.atomOn = function(e, t) {
|
|
1829
|
-
return Z(this, (n) =>
|
|
1932
|
+
return Z(this, (n) => Wt(n, e, t));
|
|
1830
1933
|
}, e.fn.atomBind = function(e) {
|
|
1831
|
-
let { text: t, html: n, class: r, css: i, attr: a, prop: o, show: s, hide: c, val: l, checked: u,
|
|
1934
|
+
let { text: t, html: n, class: r, css: i, attr: a, prop: o, show: s, hide: c, val: l, checked: u, form: d, on: f } = e, p = l === void 0 ? null : Array.isArray(l) ? {
|
|
1832
1935
|
atom: l[0],
|
|
1833
1936
|
opts: l[1]
|
|
1834
1937
|
} : {
|
|
@@ -1836,31 +1939,31 @@ e.fn.atomText = function(e, t) {
|
|
|
1836
1939
|
opts: void 0
|
|
1837
1940
|
};
|
|
1838
1941
|
return Z(this, (e) => {
|
|
1839
|
-
t !== void 0 &&
|
|
1942
|
+
t !== void 0 && Pt(e, t), n !== void 0 && Ft(e, n), r !== void 0 && It(e, r), i !== void 0 && Lt(e, i), a !== void 0 && Rt(e, a), o !== void 0 && zt(e, o), s !== void 0 && Bt(e, s, !1), c !== void 0 && Bt(e, c, !0), p !== null && Vt(e, p.atom, p.opts), u !== void 0 && Ht(e, u), d !== void 0 && e.el instanceof HTMLFormElement && Jt(e.el, d), f !== void 0 && Ut(e, f);
|
|
1840
1943
|
});
|
|
1841
1944
|
}, e.fn.atomUnbind = function() {
|
|
1842
1945
|
for (let e = 0, t = this.length; e < t; e++) {
|
|
1843
1946
|
let t = this[e];
|
|
1844
|
-
t.nodeType === 1 &&
|
|
1947
|
+
t.nodeType === 1 && Gt(t);
|
|
1845
1948
|
}
|
|
1846
1949
|
return this;
|
|
1847
1950
|
};
|
|
1848
1951
|
//#endregion
|
|
1849
1952
|
//#region src/bindings/list.ts
|
|
1850
|
-
var
|
|
1851
|
-
function
|
|
1953
|
+
var Yt = /* @__PURE__ */ new WeakMap(), Xt = 0, Zt = new Ye(() => /* @__PURE__ */ new Map(), (e) => e.clear()), Qt = new Ye(() => /* @__PURE__ */ new Set(), (e) => e.clear()), Q = new Je(100, 1024);
|
|
1954
|
+
function $t(e, t, n) {
|
|
1852
1955
|
t?.isConnected ? e.insertBefore(t) : e.appendTo(n);
|
|
1853
1956
|
}
|
|
1854
1957
|
function $(t) {
|
|
1855
1958
|
return t instanceof Element ? e(t) : t;
|
|
1856
1959
|
}
|
|
1857
|
-
var
|
|
1960
|
+
var en = class {
|
|
1858
1961
|
constructor(e, t, n) {
|
|
1859
1962
|
this.$container = e, this.containerSelector = t, this.onRemove = n, this.oldKeys = [], this.oldItems = [], this.oldNodes = [], this.removingKeys = /* @__PURE__ */ new Set(), this.$emptyEl = null, this.keyToIndex = /* @__PURE__ */ new Map(), this.statesBuffer = new Uint8Array(256), this.indicesBuffer = new Int32Array(256);
|
|
1860
1963
|
}
|
|
1861
1964
|
scheduleRemoval(e, t) {
|
|
1862
1965
|
let n = () => {
|
|
1863
|
-
this.fx?.isDisposed || (t.remove(), this.removingKeys.delete(e),
|
|
1966
|
+
this.fx?.isDisposed || (t.remove(), this.removingKeys.delete(e), U.log(B.LIST, `${this.containerSelector} removed item:`, e));
|
|
1864
1967
|
};
|
|
1865
1968
|
if (!this.onRemove) {
|
|
1866
1969
|
n();
|
|
@@ -1885,7 +1988,7 @@ var Qt = class {
|
|
|
1885
1988
|
this.statesBuffer.length < e && (this.statesBuffer = new Uint8Array(Math.max(e, this.statesBuffer.length * 2))), this.indicesBuffer.length < e && (this.indicesBuffer = new Int32Array(Math.max(e, this.indicesBuffer.length * 2)));
|
|
1886
1989
|
}
|
|
1887
1990
|
};
|
|
1888
|
-
function
|
|
1991
|
+
function tn(t, n, r, i) {
|
|
1889
1992
|
if (t.$emptyEl && n > 0 && (t.$emptyEl.remove(), t.$emptyEl = null), n !== 0) return;
|
|
1890
1993
|
let { oldKeys: a, oldNodes: o, onRemove: s } = t;
|
|
1891
1994
|
if (s) for (let e = 0, n = a.length; e < n; e++) {
|
|
@@ -1896,55 +1999,55 @@ function $t(t, n, r, i) {
|
|
|
1896
1999
|
for (let e = 0, n = a.length; e < n; e++) t.removingKeys.delete(a[e]);
|
|
1897
2000
|
r.empty();
|
|
1898
2001
|
}
|
|
1899
|
-
i && !t.$emptyEl && (t.$emptyEl = e(typeof i == "string" ?
|
|
2002
|
+
i && !t.$emptyEl && (t.$emptyEl = e(typeof i == "string" ? X(i) : i).appendTo(r)), Q.release(t.oldKeys), Q.release(t.oldItems), Q.release(t.oldNodes), t.oldKeys = [], t.oldItems = [], t.oldNodes = [];
|
|
1900
2003
|
}
|
|
1901
|
-
function
|
|
2004
|
+
function nn(e, t, n, r, i, a) {
|
|
1902
2005
|
let { oldKeys: o, oldItems: s, oldNodes: c, removingKeys: l, keyToIndex: u } = e, d = o.length, f = 0, p = d - 1, m = n - 1;
|
|
1903
2006
|
for (; f <= p && f <= m;) {
|
|
1904
2007
|
let e = t[f], n = r(e, f);
|
|
1905
2008
|
if (o[f] !== n) break;
|
|
1906
2009
|
let i = s[f];
|
|
1907
|
-
if (!(a ? a(i, e) :
|
|
2010
|
+
if (!(a ? a(i, e) : je(i, e))) break;
|
|
1908
2011
|
u.set(n, f), f++;
|
|
1909
2012
|
}
|
|
1910
2013
|
for (; p >= f && m >= f;) {
|
|
1911
2014
|
let e = t[m], n = r(e, m);
|
|
1912
2015
|
if (o[p] !== n) break;
|
|
1913
2016
|
let i = s[p];
|
|
1914
|
-
if (!(a ? a(i, e) :
|
|
2017
|
+
if (!(a ? a(i, e) : je(i, e))) break;
|
|
1915
2018
|
u.set(n, m), p--, m--;
|
|
1916
2019
|
}
|
|
1917
|
-
let h =
|
|
2020
|
+
let h = Zt.acquire();
|
|
1918
2021
|
for (let e = f; e <= p; e++) h.set(o[e], e);
|
|
1919
2022
|
let g = Q.acquire();
|
|
1920
2023
|
g.length = n;
|
|
1921
|
-
let _ =
|
|
2024
|
+
let _ = Qt.acquire();
|
|
1922
2025
|
e.ensureBuffers(n);
|
|
1923
2026
|
let v = Q.acquire();
|
|
1924
2027
|
v.length = n;
|
|
1925
2028
|
let y = Q.acquire();
|
|
1926
2029
|
y.length = n;
|
|
1927
|
-
let b = e.statesBuffer, x = e.indicesBuffer, S = Q.acquire(), C = Q.acquire(),
|
|
2030
|
+
let b = e.statesBuffer, x = e.indicesBuffer, S = Q.acquire(), C = Q.acquire(), ee = Q.acquire();
|
|
1928
2031
|
for (let e = 0; e < f; e++) g[e] = o[e], v[e] = t[e], y[e] = c[e], b[e] = 3, x[e] = e;
|
|
1929
2032
|
for (let e = d - 1, r = n - 1; r > m; r--, e--) g[r] = o[e], v[r] = t[r], y[r] = c[e], b[r] = 3, x[r] = e;
|
|
1930
2033
|
for (let n = f; n <= m; n++) {
|
|
1931
2034
|
let o = t[n], d = r(o, n);
|
|
1932
2035
|
if (g[n] = d, v[n] = o, u.set(d, n), _.has(d)) {
|
|
1933
|
-
|
|
2036
|
+
U.warn(B.LIST, H.LIST.DUPLICATE_KEY(d, n, e.containerSelector)), x[n] = -1;
|
|
1934
2037
|
continue;
|
|
1935
2038
|
}
|
|
1936
2039
|
_.add(d);
|
|
1937
2040
|
let f = h.get(d);
|
|
1938
2041
|
if (f === void 0) {
|
|
1939
|
-
S.push(d), C.push(o),
|
|
2042
|
+
S.push(d), C.push(o), ee.push(n), x[n] = -1, b[n] = 1;
|
|
1940
2043
|
continue;
|
|
1941
2044
|
}
|
|
1942
2045
|
let p = s[f];
|
|
1943
2046
|
y[n] = c[f];
|
|
1944
|
-
let m = a ? a(p, o) :
|
|
1945
|
-
!i && p !== o && !m ? (S.push(d), C.push(o),
|
|
2047
|
+
let m = a ? a(p, o) : je(p, o);
|
|
2048
|
+
!i && p !== o && !m ? (S.push(d), C.push(o), ee.push(n), b[n] = 2) : b[n] = 0, x[n] = l.has(d) ? -1 : f;
|
|
1946
2049
|
}
|
|
1947
|
-
return
|
|
2050
|
+
return Zt.release(h), {
|
|
1948
2051
|
newKeys: g,
|
|
1949
2052
|
newKeySet: _,
|
|
1950
2053
|
newItems: v,
|
|
@@ -1953,23 +2056,23 @@ function en(e, t, n, r, i, a) {
|
|
|
1953
2056
|
newIndices: x,
|
|
1954
2057
|
trKeys: S,
|
|
1955
2058
|
trItems: C,
|
|
1956
|
-
trIdxs:
|
|
2059
|
+
trIdxs: ee,
|
|
1957
2060
|
startIndex: f,
|
|
1958
2061
|
oldEndIndex: p,
|
|
1959
2062
|
newEndIndex: m
|
|
1960
2063
|
};
|
|
1961
2064
|
}
|
|
1962
|
-
function
|
|
2065
|
+
function rn(t, n, r) {
|
|
1963
2066
|
let { trKeys: i, trItems: a, trIdxs: o, newNodes: s, newStates: c } = t, l = i.length, u = n.render, d = Array(l), f = [], p = 0;
|
|
1964
2067
|
for (let e = 0; e < l; e++) {
|
|
1965
2068
|
let t = u(a[e], o[e]);
|
|
1966
2069
|
d[e] = t, typeof t == "string" && (f.push(t), p++);
|
|
1967
2070
|
}
|
|
1968
2071
|
let m = null, h = f.length;
|
|
1969
|
-
if (h > 0) if (h === 1) m = [
|
|
2072
|
+
if (h > 0) if (h === 1) m = [X(f[0])];
|
|
1970
2073
|
else {
|
|
1971
|
-
let e = `<template data-atom-sep="${(
|
|
1972
|
-
m =
|
|
2074
|
+
let e = `<template data-atom-sep="${(Xt++).toString(36)}"></template>`;
|
|
2075
|
+
m = X(f.join(e)).split(e);
|
|
1973
2076
|
}
|
|
1974
2077
|
if (r && m && p === l && !n.bind && !n.onAdd && !n.onRemove && !n.events) return m;
|
|
1975
2078
|
let g = 0;
|
|
@@ -1985,7 +2088,7 @@ function tn(t, n, r) {
|
|
|
1985
2088
|
let t = $(e);
|
|
1986
2089
|
for (let e = 0, n = t.length; e < n; e++) {
|
|
1987
2090
|
let n = t[e];
|
|
1988
|
-
n &&
|
|
2091
|
+
n && K.cleanupTree(n);
|
|
1989
2092
|
}
|
|
1990
2093
|
t.replaceWith(r);
|
|
1991
2094
|
}
|
|
@@ -1994,7 +2097,7 @@ function tn(t, n, r) {
|
|
|
1994
2097
|
}
|
|
1995
2098
|
return null;
|
|
1996
2099
|
}
|
|
1997
|
-
function
|
|
2100
|
+
function an(e, t) {
|
|
1998
2101
|
let { startIndex: n, oldEndIndex: r, newKeySet: i } = t, { oldKeys: a, oldNodes: o } = e;
|
|
1999
2102
|
for (let t = n; t <= r; t++) {
|
|
2000
2103
|
let n = a[t];
|
|
@@ -2003,14 +2106,14 @@ function nn(e, t) {
|
|
|
2003
2106
|
r && e.removeItem(n, $(r));
|
|
2004
2107
|
}
|
|
2005
2108
|
}
|
|
2006
|
-
function
|
|
2109
|
+
function on(t, n, r, i, a, o) {
|
|
2007
2110
|
let { bind: s, update: c, onAdd: l } = a, { newKeys: u, newItems: d, newNodes: f, newStates: p, newIndices: m } = n, h = u.length, g = t.oldKeys.length === 0;
|
|
2008
2111
|
if (o !== null) {
|
|
2009
2112
|
r.innerHTML = o.join("");
|
|
2010
2113
|
let n = r.firstElementChild;
|
|
2011
2114
|
for (let r = 0; r < h && n; r++) {
|
|
2012
2115
|
let i = u[r];
|
|
2013
|
-
n.setAttribute("data-atom-key", String(i)), f[r] = n, p[r] = 0, t.removingKeys.delete(i),
|
|
2116
|
+
n.setAttribute("data-atom-key", String(i)), f[r] = n, p[r] = 0, t.removingKeys.delete(i), U.enabled && U.domUpdated(B.LIST, e(n), "list.add", d[r]), n = n.nextElementSibling;
|
|
2014
2117
|
}
|
|
2015
2118
|
return;
|
|
2016
2119
|
}
|
|
@@ -2026,7 +2129,7 @@ function rn(t, n, r, i, a, o) {
|
|
|
2026
2129
|
let e = null, t = 2147483647;
|
|
2027
2130
|
for (let n = h - 1; n >= 0; n--) {
|
|
2028
2131
|
let r = m[n], a = f[n];
|
|
2029
|
-
r !== -1 && r < t ? t = r :
|
|
2132
|
+
r !== -1 && r < t ? t = r : $t($(a), e, i), e = a instanceof Element ? a : a[0] ?? null;
|
|
2030
2133
|
}
|
|
2031
2134
|
}
|
|
2032
2135
|
for (let e = 0; e < h; e++) {
|
|
@@ -2036,7 +2139,7 @@ function rn(t, n, r, i, a, o) {
|
|
|
2036
2139
|
if (r === 0 ? c?.(i, a, e) : s?.(i, a, e), r === 1) {
|
|
2037
2140
|
l?.(i);
|
|
2038
2141
|
let n = u[e];
|
|
2039
|
-
t.removingKeys.delete(n),
|
|
2142
|
+
t.removingKeys.delete(n), U.enabled && U.domUpdated(B.LIST, i, "list.add", d[e]);
|
|
2040
2143
|
}
|
|
2041
2144
|
}
|
|
2042
2145
|
}
|
|
@@ -2052,26 +2155,26 @@ e.fn.atomList = function(t, n) {
|
|
|
2052
2155
|
for (let r = 0, i = this.length; r < i; r++) {
|
|
2053
2156
|
let i = this[r], o = e(i);
|
|
2054
2157
|
o.off(".atomList");
|
|
2055
|
-
let p =
|
|
2158
|
+
let p = Yt.get(i);
|
|
2056
2159
|
p && (p.fx.dispose(), p.ctx.dispose());
|
|
2057
|
-
let m =
|
|
2160
|
+
let m = R(i), h = new en(o, m, s), g = I(() => {
|
|
2058
2161
|
let e = t.value, r = e.length;
|
|
2059
|
-
|
|
2060
|
-
if (
|
|
2061
|
-
|
|
2062
|
-
let t =
|
|
2063
|
-
if (
|
|
2162
|
+
D(() => {
|
|
2163
|
+
if (tn(h, r, o, c), r === 0) return;
|
|
2164
|
+
U.log(B.LIST, `${m} updating with ${r} items`);
|
|
2165
|
+
let t = nn(h, e, r, d, a, u), s = rn(t, n, h.oldKeys.length === 0);
|
|
2166
|
+
if (an(h, t), on(h, t, i, o, f, s), l) {
|
|
2064
2167
|
let { startIndex: e, oldEndIndex: n, newKeySet: r } = t;
|
|
2065
2168
|
for (let t = e; t <= n; t++) {
|
|
2066
2169
|
let e = h.oldKeys[t];
|
|
2067
2170
|
r.has(e) || h.keyToIndex.delete(e);
|
|
2068
2171
|
}
|
|
2069
2172
|
}
|
|
2070
|
-
Q.release(h.oldKeys), Q.release(h.oldItems), Q.release(h.oldNodes), h.oldKeys = t.newKeys, h.oldItems = t.newItems, h.oldNodes = t.newNodes,
|
|
2173
|
+
Q.release(h.oldKeys), Q.release(h.oldItems), Q.release(h.oldNodes), h.oldKeys = t.newKeys, h.oldItems = t.newItems, h.oldNodes = t.newNodes, Qt.release(t.newKeySet), Q.release(t.trKeys), Q.release(t.trItems), Q.release(t.trIdxs);
|
|
2071
2174
|
});
|
|
2072
2175
|
});
|
|
2073
2176
|
if (h.fx = g, l) for (let e in l) {
|
|
2074
|
-
if (!
|
|
2177
|
+
if (!z.call(l, e)) continue;
|
|
2075
2178
|
let t = l[e], n = e.indexOf(" "), r = n === -1 ? e : e.slice(0, n), i = (n === -1 ? null : e.slice(n + 1).trim()) || "> *";
|
|
2076
2179
|
o.on(`${r}.atomList`, i, function(e) {
|
|
2077
2180
|
let n = e.target.closest?.("[data-atom-key]");
|
|
@@ -2087,76 +2190,76 @@ e.fn.atomList = function(t, n) {
|
|
|
2087
2190
|
a !== void 0 && t.call(n, h.oldItems[a], a, e);
|
|
2088
2191
|
});
|
|
2089
2192
|
}
|
|
2090
|
-
|
|
2193
|
+
K.trackEffect(i, g), Yt.set(i, {
|
|
2091
2194
|
fx: g,
|
|
2092
2195
|
ctx: h
|
|
2093
|
-
}),
|
|
2094
|
-
h.dispose(),
|
|
2196
|
+
}), K.trackCleanup(i, () => {
|
|
2197
|
+
h.dispose(), Yt.delete(i);
|
|
2095
2198
|
});
|
|
2096
2199
|
}
|
|
2097
2200
|
return this;
|
|
2098
2201
|
};
|
|
2099
2202
|
//#endregion
|
|
2100
2203
|
//#region src/bindings/mount.ts
|
|
2101
|
-
var
|
|
2204
|
+
var sn = Object.freeze({});
|
|
2102
2205
|
e.fn.atomMount = function(t, n) {
|
|
2103
|
-
let r = n ??
|
|
2206
|
+
let r = n ?? sn;
|
|
2104
2207
|
for (let n = 0, i = this.length; n < i; n++) {
|
|
2105
2208
|
let i = this[n];
|
|
2106
2209
|
if (!i) continue;
|
|
2107
|
-
|
|
2210
|
+
K.cleanupTree(i);
|
|
2108
2211
|
let a = e(i), o;
|
|
2109
2212
|
try {
|
|
2110
|
-
o =
|
|
2213
|
+
o = D(() => t(a, r));
|
|
2111
2214
|
} catch (e) {
|
|
2112
|
-
|
|
2215
|
+
U.error(B.MOUNT, H.MOUNT.ERROR(t.name), e);
|
|
2113
2216
|
continue;
|
|
2114
2217
|
}
|
|
2115
|
-
typeof o == "function" &&
|
|
2218
|
+
typeof o == "function" && K.setComponentCleanup(i, o);
|
|
2116
2219
|
}
|
|
2117
2220
|
return this;
|
|
2118
2221
|
}, e.fn.atomUnmount = function() {
|
|
2119
2222
|
for (let e = 0, t = this.length; e < t; e++) {
|
|
2120
2223
|
let t = this[e];
|
|
2121
|
-
t &&
|
|
2224
|
+
t && Gt(t);
|
|
2122
2225
|
}
|
|
2123
2226
|
return this;
|
|
2124
2227
|
};
|
|
2125
2228
|
//#endregion
|
|
2126
2229
|
//#region src/features/route.ts
|
|
2127
|
-
function
|
|
2230
|
+
function cn(e, t) {
|
|
2128
2231
|
try {
|
|
2129
2232
|
return history.pushState(e, "", t), !0;
|
|
2130
2233
|
} catch (e) {
|
|
2131
|
-
return
|
|
2234
|
+
return U.warn(B.ROUTE, "PushState failed (likely file:// protocol or security restriction). UI will update, but URL will not.", e), !1;
|
|
2132
2235
|
}
|
|
2133
2236
|
}
|
|
2134
|
-
var
|
|
2237
|
+
var ln = class {
|
|
2135
2238
|
constructor(t) {
|
|
2136
2239
|
this.isDestroyed = !1, this.previousRoute = "", this.cleanups = [], this.templateCache = /* @__PURE__ */ new Map(), this.routeCleanups = [], this.lastRawQuery = "", this.cachedParams = {}, this.config = {
|
|
2137
2240
|
...t,
|
|
2138
|
-
mode: t.mode ??
|
|
2139
|
-
basePath: t.basePath ??
|
|
2140
|
-
autoBindLinks: t.autoBindLinks ??
|
|
2141
|
-
activeClass: t.activeClass ??
|
|
2142
|
-
}, this.isHistoryMode = this.config.mode === "history", this.$target = e(this.config.target), this.normalizedBasePath = this.config.basePath?.replace(/\/$/, "") || "", this.activeClass = this.config.activeClass ??
|
|
2241
|
+
mode: t.mode ?? V.mode,
|
|
2242
|
+
basePath: t.basePath ?? V.basePath,
|
|
2243
|
+
autoBindLinks: t.autoBindLinks ?? V.autoBindLinks,
|
|
2244
|
+
activeClass: t.activeClass ?? V.activeClass
|
|
2245
|
+
}, this.isHistoryMode = this.config.mode === "history", this.$target = e(this.config.target), this.normalizedBasePath = this.config.basePath?.replace(/\/$/, "") || "", this.activeClass = this.config.activeClass ?? V.activeClass, this.previousUrl = this.isHistoryMode ? window.location.pathname + window.location.search : window.location.hash, this.currentRouteAtom = ye(this.getRouteName()), this.currentRoute = this.currentRouteAtom, this.queryParamsAtom = ye(this.getQueryParams()), this.queryParams = F(() => this.queryParamsAtom.value), this.handleUrlChange = this.handleUrlChange.bind(this), this.destroy = this.destroy.bind(this), this.init();
|
|
2143
2246
|
}
|
|
2144
2247
|
init() {
|
|
2145
2248
|
let e = this.isHistoryMode ? "popstate" : "hashchange";
|
|
2146
2249
|
window.addEventListener(e, this.handleUrlChange), this.cleanups.push(() => window.removeEventListener(e, this.handleUrlChange));
|
|
2147
|
-
let t =
|
|
2250
|
+
let t = I(() => {
|
|
2148
2251
|
let e = this.currentRouteAtom.value;
|
|
2149
|
-
|
|
2252
|
+
D(() => {
|
|
2150
2253
|
let e = this.routeCleanups;
|
|
2151
2254
|
for (let t = 0, n = e.length; t < n; t++) try {
|
|
2152
2255
|
e[t]();
|
|
2153
2256
|
} catch (e) {
|
|
2154
|
-
|
|
2257
|
+
U.warn(B.ROUTE, "Cleanup error during route transition:", e);
|
|
2155
2258
|
}
|
|
2156
2259
|
e.length = 0;
|
|
2157
2260
|
}), this.renderRoute(e);
|
|
2158
2261
|
});
|
|
2159
|
-
this.cleanups.push(() => t.dispose()), this.setupAutoBindLinks(), this.$target[0] &&
|
|
2262
|
+
this.cleanups.push(() => t.dispose()), this.setupAutoBindLinks(), this.$target[0] && K.trackCleanup(this.$target[0], this.destroy);
|
|
2160
2263
|
}
|
|
2161
2264
|
getRouteName() {
|
|
2162
2265
|
let e = this.config.default;
|
|
@@ -2195,27 +2298,27 @@ var sn = class {
|
|
|
2195
2298
|
setUrl(e) {
|
|
2196
2299
|
if (this.isHistoryMode) {
|
|
2197
2300
|
let t = `${this.normalizedBasePath}/${e}`;
|
|
2198
|
-
|
|
2301
|
+
cn(null, t), this.previousUrl = t;
|
|
2199
2302
|
} else {
|
|
2200
2303
|
let t = `#${e}`;
|
|
2201
2304
|
window.location.hash = t, this.previousUrl = t;
|
|
2202
2305
|
}
|
|
2203
2306
|
}
|
|
2204
2307
|
restoreUrl() {
|
|
2205
|
-
this.isHistoryMode ?
|
|
2308
|
+
this.isHistoryMode ? cn(null, this.previousUrl) : window.location.hash = this.previousUrl;
|
|
2206
2309
|
}
|
|
2207
2310
|
getCurrentUrl() {
|
|
2208
2311
|
return this.isHistoryMode ? window.location.pathname + window.location.search : window.location.hash;
|
|
2209
2312
|
}
|
|
2210
2313
|
getRouteConfig(e) {
|
|
2211
2314
|
let { routes: t, notFound: n } = this.config, r = t[e];
|
|
2212
|
-
return !r && n && (r = t[n]), r || (
|
|
2315
|
+
return !r && n && (r = t[n]), r || (U.warn(B.ROUTE, H.ROUTE.NOT_FOUND(e)), null);
|
|
2213
2316
|
}
|
|
2214
2317
|
renderTemplate(e) {
|
|
2215
2318
|
let t = this.templateCache.get(e);
|
|
2216
2319
|
if (!t) {
|
|
2217
2320
|
let n = document.querySelector(e);
|
|
2218
|
-
if (!n || !(n instanceof HTMLTemplateElement)) return
|
|
2321
|
+
if (!n || !(n instanceof HTMLTemplateElement)) return U.warn(B.ROUTE, H.ROUTE.TEMPLATE_NOT_FOUND(e)), !1;
|
|
2219
2322
|
t = n, this.templateCache.set(e, t);
|
|
2220
2323
|
}
|
|
2221
2324
|
let n = t.content.cloneNode(!0);
|
|
@@ -2225,16 +2328,16 @@ var sn = class {
|
|
|
2225
2328
|
if (this.isDestroyed) return;
|
|
2226
2329
|
let t = this.$target[0];
|
|
2227
2330
|
if (!t) {
|
|
2228
|
-
|
|
2331
|
+
U.warn(B.ROUTE, H.ROUTE.TARGET_NOT_FOUND(this.config.target));
|
|
2229
2332
|
return;
|
|
2230
2333
|
}
|
|
2231
2334
|
let n = this.getRouteConfig(e);
|
|
2232
2335
|
if (!n) return;
|
|
2233
2336
|
let r = this.getQueryParams(), i = this.previousRoute, { beforeTransition: a, afterTransition: o } = this.config;
|
|
2234
|
-
a &&
|
|
2337
|
+
a && D(() => a(i, e)), this.$target.empty();
|
|
2235
2338
|
let s = r, { onEnter: c } = n;
|
|
2236
2339
|
if (c) {
|
|
2237
|
-
let e =
|
|
2340
|
+
let e = D(() => c(r, this));
|
|
2238
2341
|
e !== void 0 && (s = {
|
|
2239
2342
|
...r,
|
|
2240
2343
|
...e
|
|
@@ -2243,7 +2346,7 @@ var sn = class {
|
|
|
2243
2346
|
let l = (e) => {
|
|
2244
2347
|
this.routeCleanups.push(e);
|
|
2245
2348
|
};
|
|
2246
|
-
n.render ? n.render(t, e, s, l, this) : n.template && this.renderTemplate(n.template) && n.onMount && n.onMount(this.$target.children(), l, this), o &&
|
|
2349
|
+
n.render ? n.render(t, e, s, l, this) : n.template && this.renderTemplate(n.template) && n.onMount && n.onMount(this.$target.children(), l, this), o && D(() => o(i, e)), this.previousRoute = e;
|
|
2247
2350
|
}
|
|
2248
2351
|
handleUrlChange() {
|
|
2249
2352
|
if (this.isDestroyed) return;
|
|
@@ -2252,7 +2355,7 @@ var sn = class {
|
|
|
2252
2355
|
let t = this.getRouteName(), n = this.currentRouteAtom.peek(), r = this.getQueryParams();
|
|
2253
2356
|
if (n !== t) {
|
|
2254
2357
|
let e = this.config.routes[n];
|
|
2255
|
-
if (e?.onLeave &&
|
|
2358
|
+
if (e?.onLeave && D(() => e.onLeave(this)) === !1) {
|
|
2256
2359
|
this.restoreUrl();
|
|
2257
2360
|
return;
|
|
2258
2361
|
}
|
|
@@ -2270,9 +2373,9 @@ var sn = class {
|
|
|
2270
2373
|
e(document).on("click", "[data-route]", t), this.cleanups.push(() => {
|
|
2271
2374
|
e(document).off("click", "[data-route]", t);
|
|
2272
2375
|
});
|
|
2273
|
-
let n = this.activeClass, r = [], i =
|
|
2376
|
+
let n = this.activeClass, r = [], i = I(() => {
|
|
2274
2377
|
let e = this.currentRouteAtom.value;
|
|
2275
|
-
|
|
2378
|
+
D(() => {
|
|
2276
2379
|
for (let e = 0, t = r.length; e < t; e++) {
|
|
2277
2380
|
let t = r[e];
|
|
2278
2381
|
t.classList.remove(n), t.removeAttribute("aria-current");
|
|
@@ -2297,7 +2400,7 @@ var sn = class {
|
|
|
2297
2400
|
if (n?.onLeave && n.onLeave(this) === !1) return;
|
|
2298
2401
|
let r = e || this.config.default;
|
|
2299
2402
|
if (!r) {
|
|
2300
|
-
|
|
2403
|
+
U.warn(B.ROUTE, "navigate() called with empty routeName and no default configured.");
|
|
2301
2404
|
return;
|
|
2302
2405
|
}
|
|
2303
2406
|
this.setUrl(r), this.queryParamsAtom.value = {}, this.currentRouteAtom.value = r;
|
|
@@ -2310,18 +2413,18 @@ var sn = class {
|
|
|
2310
2413
|
for (let t = 0, n = e.length; t < n; t++) try {
|
|
2311
2414
|
e[t]();
|
|
2312
2415
|
} catch (e) {
|
|
2313
|
-
|
|
2416
|
+
U.warn(B.ROUTE, "Cleanup error during destroy:", e);
|
|
2314
2417
|
}
|
|
2315
2418
|
this.templateCache.clear();
|
|
2316
2419
|
}
|
|
2317
2420
|
};
|
|
2318
|
-
function
|
|
2319
|
-
return new
|
|
2421
|
+
function un(e) {
|
|
2422
|
+
return new ln(e);
|
|
2320
2423
|
}
|
|
2321
|
-
e.extend({ route:
|
|
2424
|
+
e.extend({ route: un });
|
|
2322
2425
|
//#endregion
|
|
2323
2426
|
//#region src/features/fetch.ts
|
|
2324
|
-
var
|
|
2427
|
+
var dn = class {
|
|
2325
2428
|
constructor(e, t) {
|
|
2326
2429
|
this.abortController = null, this.isStaticUrl = typeof e == "string", this.isStaticUrl ? this.staticUrl = e : this.getUrl = e, typeof t.ajaxOptions == "function" ? (this.ajaxOptionsFn = t.ajaxOptions, this.staticOptions = {}) : this.staticOptions = { ...t.ajaxOptions }, t.method !== void 0 && (this.staticOptions.method = t.method), t.headers !== void 0 && (this.staticOptions.headers = {
|
|
2327
2430
|
...this.staticOptions.headers,
|
|
@@ -2374,16 +2477,16 @@ var ln = class {
|
|
|
2374
2477
|
//#endregion
|
|
2375
2478
|
//#region src/index.ts
|
|
2376
2479
|
e.extend({ atomFetch(e, t) {
|
|
2377
|
-
let n = new
|
|
2480
|
+
let n = new dn(e, t), r = !(t.eager ?? !0), i = F(n.execute, {
|
|
2378
2481
|
defaultValue: t.defaultValue,
|
|
2379
2482
|
lazy: r
|
|
2380
2483
|
});
|
|
2381
2484
|
return Object.assign(i, { abort: () => n.abort() });
|
|
2382
2485
|
} }), e(() => {
|
|
2383
|
-
|
|
2486
|
+
st(), et(document.body);
|
|
2384
2487
|
});
|
|
2385
|
-
var
|
|
2488
|
+
var fn = e;
|
|
2386
2489
|
//#endregion
|
|
2387
|
-
export {
|
|
2490
|
+
export { ye as atom, ke as batch, F as computed, fn as default, tt as disableAutoCleanup, ct as disablejQueryOverrides, I as effect, et as enableAutoCleanup, st as enablejQueryOverrides, xe as isAtom, Se as isComputed, L as isReactive, Ke as nextTick, K as registry, D as untracked };
|
|
2388
2491
|
|
|
2389
2492
|
//# sourceMappingURL=index.mjs.map
|