@solidjs/signals 0.13.6 → 0.13.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.js +308 -233
- package/dist/node.cjs +418 -360
- package/dist/prod.js +427 -364
- package/dist/types/store/utils.d.ts +1 -2
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -424,9 +424,9 @@ class GlobalQueue extends Queue {
|
|
|
424
424
|
}
|
|
425
425
|
function insertSubs(e, t = false) {
|
|
426
426
|
const n = e.q || currentOptimisticLane;
|
|
427
|
-
const i = e.
|
|
427
|
+
const i = e.de !== undefined;
|
|
428
428
|
for (let r = e.I; r !== null; r = r.p) {
|
|
429
|
-
if (i && r.h.
|
|
429
|
+
if (i && r.h.Te) {
|
|
430
430
|
r.h.O |= REACTIVE_SNAPSHOT_STALE;
|
|
431
431
|
continue;
|
|
432
432
|
}
|
|
@@ -619,39 +619,230 @@ function assignOrMergeLane(e, t) {
|
|
|
619
619
|
}
|
|
620
620
|
e.q = t;
|
|
621
621
|
}
|
|
622
|
+
function unlinkSubs(e) {
|
|
623
|
+
const t = e.m;
|
|
624
|
+
const n = e.D;
|
|
625
|
+
const i = e.p;
|
|
626
|
+
const r = e.Ie;
|
|
627
|
+
if (i !== null) i.Ie = r;
|
|
628
|
+
else t.pe = r;
|
|
629
|
+
if (r !== null) r.p = i;
|
|
630
|
+
else {
|
|
631
|
+
t.I = i;
|
|
632
|
+
if (i === null) {
|
|
633
|
+
t.he?.();
|
|
634
|
+
t.L && !t.Ae && !(t.O & REACTIVE_ZOMBIE) && unobserved(t);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
return n;
|
|
638
|
+
}
|
|
639
|
+
function unobserved(e) {
|
|
640
|
+
deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
641
|
+
let t = e.C;
|
|
642
|
+
while (t !== null) {
|
|
643
|
+
t = unlinkSubs(t);
|
|
644
|
+
}
|
|
645
|
+
e.C = null;
|
|
646
|
+
disposeChildren(e, true);
|
|
647
|
+
}
|
|
648
|
+
function link(e, t) {
|
|
649
|
+
const n = t.Ne;
|
|
650
|
+
if (n !== null && n.m === e) return;
|
|
651
|
+
let i = null;
|
|
652
|
+
const r = t.O & REACTIVE_RECOMPUTING_DEPS;
|
|
653
|
+
if (r) {
|
|
654
|
+
i = n !== null ? n.D : t.C;
|
|
655
|
+
if (i !== null && i.m === e) {
|
|
656
|
+
t.Ne = i;
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
const s = e.pe;
|
|
661
|
+
if (s !== null && s.h === t && (!r || isValidLink(s, t))) return;
|
|
662
|
+
const o = (t.Ne = e.pe = { m: e, h: t, D: i, Ie: s, p: null });
|
|
663
|
+
if (n !== null) n.D = o;
|
|
664
|
+
else t.C = o;
|
|
665
|
+
if (s !== null) s.p = o;
|
|
666
|
+
else e.I = o;
|
|
667
|
+
}
|
|
668
|
+
function isValidLink(e, t) {
|
|
669
|
+
const n = t.Ne;
|
|
670
|
+
if (n !== null) {
|
|
671
|
+
let i = t.C;
|
|
672
|
+
do {
|
|
673
|
+
if (i === e) return true;
|
|
674
|
+
if (i === n) break;
|
|
675
|
+
i = i.D;
|
|
676
|
+
} while (i !== null);
|
|
677
|
+
}
|
|
678
|
+
return false;
|
|
679
|
+
}
|
|
680
|
+
const PENDING_OWNER = {};
|
|
681
|
+
function markDisposal(e) {
|
|
682
|
+
let t = e.Pe;
|
|
683
|
+
while (t) {
|
|
684
|
+
t.O |= REACTIVE_ZOMBIE;
|
|
685
|
+
if (t.O & REACTIVE_IN_HEAP) {
|
|
686
|
+
deleteFromHeap(t, dirtyQueue);
|
|
687
|
+
insertIntoHeap(t, zombieQueue);
|
|
688
|
+
}
|
|
689
|
+
markDisposal(t);
|
|
690
|
+
t = t.ge;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
function dispose(e) {
|
|
694
|
+
let t = e.C || null;
|
|
695
|
+
do {
|
|
696
|
+
t = unlinkSubs(t);
|
|
697
|
+
} while (t !== null);
|
|
698
|
+
e.C = null;
|
|
699
|
+
e.Ne = null;
|
|
700
|
+
disposeChildren(e, true);
|
|
701
|
+
}
|
|
702
|
+
function disposeChildren(e, t = false, n) {
|
|
703
|
+
if (e.O & REACTIVE_DISPOSED) return;
|
|
704
|
+
if (t) e.O = REACTIVE_DISPOSED;
|
|
705
|
+
if (t && e.L) e.Ce = null;
|
|
706
|
+
let i = n ? e.De : e.Pe;
|
|
707
|
+
while (i) {
|
|
708
|
+
const e = i.ge;
|
|
709
|
+
if (i.C) {
|
|
710
|
+
const e = i;
|
|
711
|
+
deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
712
|
+
let t = e.C;
|
|
713
|
+
do {
|
|
714
|
+
t = unlinkSubs(t);
|
|
715
|
+
} while (t !== null);
|
|
716
|
+
e.C = null;
|
|
717
|
+
e.Ne = null;
|
|
718
|
+
}
|
|
719
|
+
disposeChildren(i, true);
|
|
720
|
+
i = e;
|
|
721
|
+
}
|
|
722
|
+
if (n) {
|
|
723
|
+
e.De = null;
|
|
724
|
+
} else {
|
|
725
|
+
e.Pe = null;
|
|
726
|
+
e.ye = 0;
|
|
727
|
+
}
|
|
728
|
+
runDisposal(e, n);
|
|
729
|
+
}
|
|
730
|
+
function runDisposal(e, t) {
|
|
731
|
+
let n = t ? e.ve : e.me;
|
|
732
|
+
if (!n) return;
|
|
733
|
+
if (Array.isArray(n)) {
|
|
734
|
+
for (let e = 0; e < n.length; e++) {
|
|
735
|
+
const t = n[e];
|
|
736
|
+
t.call(t);
|
|
737
|
+
}
|
|
738
|
+
} else {
|
|
739
|
+
n.call(n);
|
|
740
|
+
}
|
|
741
|
+
t ? (e.ve = null) : (e.me = null);
|
|
742
|
+
}
|
|
743
|
+
function childId(e, t) {
|
|
744
|
+
let n = e;
|
|
745
|
+
while (n.Ve && n.i) n = n.i;
|
|
746
|
+
if (n.id != null) return formatId(n.id, t ? n.ye++ : n.ye);
|
|
747
|
+
throw new Error("Cannot get child id from owner without an id");
|
|
748
|
+
}
|
|
749
|
+
function getNextChildId(e) {
|
|
750
|
+
return childId(e, true);
|
|
751
|
+
}
|
|
752
|
+
function peekNextChildId(e) {
|
|
753
|
+
return childId(e, false);
|
|
754
|
+
}
|
|
755
|
+
function formatId(e, t) {
|
|
756
|
+
const n = t.toString(36),
|
|
757
|
+
i = n.length - 1;
|
|
758
|
+
return e + (i ? String.fromCharCode(64 + i) : "") + n;
|
|
759
|
+
}
|
|
760
|
+
function getObserver() {
|
|
761
|
+
if (pendingCheckActive || latestReadActive) return PENDING_OWNER;
|
|
762
|
+
return tracking ? context : null;
|
|
763
|
+
}
|
|
764
|
+
function getOwner() {
|
|
765
|
+
return context;
|
|
766
|
+
}
|
|
767
|
+
function cleanup(e) {
|
|
768
|
+
if (!context) return e;
|
|
769
|
+
if (!context.me) context.me = e;
|
|
770
|
+
else if (Array.isArray(context.me)) context.me.push(e);
|
|
771
|
+
else context.me = [context.me, e];
|
|
772
|
+
return e;
|
|
773
|
+
}
|
|
774
|
+
function isDisposed(e) {
|
|
775
|
+
return !!(e.O & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE));
|
|
776
|
+
}
|
|
777
|
+
function createOwner(e) {
|
|
778
|
+
const t = context;
|
|
779
|
+
const n = e?.transparent ?? false;
|
|
780
|
+
const i = {
|
|
781
|
+
id: e?.id ?? (n ? t?.id : t?.id != null ? getNextChildId(t) : undefined),
|
|
782
|
+
Ve: n || undefined,
|
|
783
|
+
t: true,
|
|
784
|
+
u: t?.t ? t.u : t,
|
|
785
|
+
Pe: null,
|
|
786
|
+
ge: null,
|
|
787
|
+
me: null,
|
|
788
|
+
F: t?.F ?? globalQueue,
|
|
789
|
+
we: t?.we || defaultContext,
|
|
790
|
+
ye: 0,
|
|
791
|
+
ve: null,
|
|
792
|
+
De: null,
|
|
793
|
+
i: t,
|
|
794
|
+
dispose(e = true) {
|
|
795
|
+
disposeChildren(i, e);
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
if (t) {
|
|
799
|
+
const e = t.Pe;
|
|
800
|
+
if (e === null) {
|
|
801
|
+
t.Pe = i;
|
|
802
|
+
} else {
|
|
803
|
+
i.ge = e;
|
|
804
|
+
t.Pe = i;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
return i;
|
|
808
|
+
}
|
|
809
|
+
function createRoot(e, t) {
|
|
810
|
+
const n = createOwner(t);
|
|
811
|
+
return runWithOwner(n, () => e(n.dispose));
|
|
812
|
+
}
|
|
622
813
|
function addPendingSource(e, t) {
|
|
623
|
-
if (e.
|
|
624
|
-
if (!e.
|
|
625
|
-
e.
|
|
814
|
+
if (e.be === t || e.Le?.has(t)) return false;
|
|
815
|
+
if (!e.be) {
|
|
816
|
+
e.be = t;
|
|
626
817
|
return true;
|
|
627
818
|
}
|
|
628
|
-
if (!e.
|
|
629
|
-
e.
|
|
819
|
+
if (!e.Le) {
|
|
820
|
+
e.Le = new Set([e.be, t]);
|
|
630
821
|
} else {
|
|
631
|
-
e.
|
|
822
|
+
e.Le.add(t);
|
|
632
823
|
}
|
|
633
|
-
e.
|
|
824
|
+
e.be = undefined;
|
|
634
825
|
return true;
|
|
635
826
|
}
|
|
636
827
|
function removePendingSource(e, t) {
|
|
637
|
-
if (e.
|
|
638
|
-
if (e.
|
|
639
|
-
e.
|
|
828
|
+
if (e.be) {
|
|
829
|
+
if (e.be !== t) return false;
|
|
830
|
+
e.be = undefined;
|
|
640
831
|
return true;
|
|
641
832
|
}
|
|
642
|
-
if (!e.
|
|
643
|
-
if (e.
|
|
644
|
-
e.
|
|
645
|
-
e.
|
|
646
|
-
} else if (e.
|
|
647
|
-
e.
|
|
833
|
+
if (!e.Le?.delete(t)) return false;
|
|
834
|
+
if (e.Le.size === 1) {
|
|
835
|
+
e.be = e.Le.values().next().value;
|
|
836
|
+
e.Le = undefined;
|
|
837
|
+
} else if (e.Le.size === 0) {
|
|
838
|
+
e.Le = undefined;
|
|
648
839
|
}
|
|
649
840
|
return true;
|
|
650
841
|
}
|
|
651
842
|
function clearPendingSources(e) {
|
|
652
|
-
e.
|
|
653
|
-
e.
|
|
654
|
-
e.
|
|
843
|
+
e.be = undefined;
|
|
844
|
+
e.Le?.clear();
|
|
845
|
+
e.Le = undefined;
|
|
655
846
|
}
|
|
656
847
|
function setPendingError(e, t, n) {
|
|
657
848
|
if (!t) {
|
|
@@ -680,7 +871,7 @@ function settlePendingSource(e) {
|
|
|
680
871
|
if (n.has(i) || !removePendingSource(i, e)) return;
|
|
681
872
|
n.add(i);
|
|
682
873
|
i.Ee = clock;
|
|
683
|
-
const r = i.
|
|
874
|
+
const r = i.be ?? i.Le?.values().next().value;
|
|
684
875
|
if (r) {
|
|
685
876
|
setPendingError(i, r);
|
|
686
877
|
updatePendingSignal(i);
|
|
@@ -688,7 +879,7 @@ function settlePendingSource(e) {
|
|
|
688
879
|
i.Se &= ~STATUS_PENDING;
|
|
689
880
|
setPendingError(i);
|
|
690
881
|
updatePendingSignal(i);
|
|
691
|
-
if (i.
|
|
882
|
+
if (i.Ue) {
|
|
692
883
|
if (i.W === EFFECT_TRACKED) {
|
|
693
884
|
const e = i;
|
|
694
885
|
if (!e.H) {
|
|
@@ -702,7 +893,7 @@ function settlePendingSource(e) {
|
|
|
702
893
|
}
|
|
703
894
|
t = true;
|
|
704
895
|
}
|
|
705
|
-
i.
|
|
896
|
+
i.Ue = false;
|
|
706
897
|
}
|
|
707
898
|
forEachDependent(i, settle);
|
|
708
899
|
};
|
|
@@ -714,19 +905,19 @@ function handleAsync(e, t, n) {
|
|
|
714
905
|
const r = i && untrack(() => t[Symbol.asyncIterator]);
|
|
715
906
|
const s = !r && i && untrack(() => typeof t.then === "function");
|
|
716
907
|
if (!s && !r) {
|
|
717
|
-
e.
|
|
908
|
+
e.Ce = null;
|
|
718
909
|
return t;
|
|
719
910
|
}
|
|
720
|
-
e.
|
|
911
|
+
e.Ce = t;
|
|
721
912
|
let o;
|
|
722
913
|
const handleError = n => {
|
|
723
|
-
if (e.
|
|
914
|
+
if (e.Ce !== t) return;
|
|
724
915
|
globalQueue.initTransition(resolveTransition(e));
|
|
725
916
|
notifyStatus(e, n instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR, n);
|
|
726
917
|
e.Ee = clock;
|
|
727
918
|
};
|
|
728
919
|
const asyncWrite = (i, r) => {
|
|
729
|
-
if (e.
|
|
920
|
+
if (e.Ce !== t) return;
|
|
730
921
|
if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY)) return;
|
|
731
922
|
globalQueue.initTransition(resolveTransition(e));
|
|
732
923
|
clearStatus(e);
|
|
@@ -742,12 +933,12 @@ function handleAsync(e, t, n) {
|
|
|
742
933
|
e.Ee = clock;
|
|
743
934
|
} else if (s) {
|
|
744
935
|
const t = e.J;
|
|
745
|
-
const n = e.
|
|
936
|
+
const n = e.ke;
|
|
746
937
|
if (!n || !n(i, t)) {
|
|
747
938
|
e.J = i;
|
|
748
939
|
e.Ee = clock;
|
|
749
|
-
if (e.
|
|
750
|
-
setSignal(e.
|
|
940
|
+
if (e.Ge) {
|
|
941
|
+
setSignal(e.Ge, i);
|
|
751
942
|
}
|
|
752
943
|
insertSubs(e, true);
|
|
753
944
|
}
|
|
@@ -782,35 +973,53 @@ function handleAsync(e, t, n) {
|
|
|
782
973
|
if (r) {
|
|
783
974
|
const n = t[Symbol.asyncIterator]();
|
|
784
975
|
let i = false;
|
|
976
|
+
let r = false;
|
|
977
|
+
cleanup(() => {
|
|
978
|
+
if (r) return;
|
|
979
|
+
r = true;
|
|
980
|
+
try {
|
|
981
|
+
const e = n.return?.();
|
|
982
|
+
if (e && typeof e.then === "function") {
|
|
983
|
+
e.then(undefined, () => {});
|
|
984
|
+
}
|
|
985
|
+
} catch {}
|
|
986
|
+
});
|
|
785
987
|
const iterate = () => {
|
|
786
|
-
let
|
|
787
|
-
|
|
788
|
-
|
|
988
|
+
let s,
|
|
989
|
+
u = false,
|
|
990
|
+
c = true;
|
|
789
991
|
n.next().then(
|
|
790
992
|
n => {
|
|
791
|
-
if (
|
|
792
|
-
|
|
793
|
-
|
|
993
|
+
if (c) {
|
|
994
|
+
s = n;
|
|
995
|
+
u = true;
|
|
996
|
+
if (n.done) r = true;
|
|
997
|
+
} else if (e.Ce !== t) {
|
|
998
|
+
return;
|
|
794
999
|
} else if (!n.done) asyncWrite(n.value, iterate);
|
|
795
1000
|
else {
|
|
1001
|
+
r = true;
|
|
796
1002
|
schedule();
|
|
797
1003
|
flush();
|
|
798
1004
|
}
|
|
799
1005
|
},
|
|
800
|
-
|
|
801
|
-
if (!
|
|
1006
|
+
n => {
|
|
1007
|
+
if (!c && e.Ce === t) {
|
|
1008
|
+
r = true;
|
|
1009
|
+
handleError(n);
|
|
1010
|
+
}
|
|
802
1011
|
}
|
|
803
1012
|
);
|
|
804
|
-
|
|
805
|
-
if (
|
|
806
|
-
o =
|
|
1013
|
+
c = false;
|
|
1014
|
+
if (u && !s.done) {
|
|
1015
|
+
o = s.value;
|
|
807
1016
|
i = true;
|
|
808
1017
|
return iterate();
|
|
809
1018
|
}
|
|
810
|
-
return
|
|
1019
|
+
return u && s.done;
|
|
811
1020
|
};
|
|
812
|
-
const
|
|
813
|
-
if (!i && !
|
|
1021
|
+
const s = iterate();
|
|
1022
|
+
if (!i && !s) {
|
|
814
1023
|
globalQueue.initTransition(resolveTransition(e));
|
|
815
1024
|
throw new NotReadyError(context);
|
|
816
1025
|
}
|
|
@@ -819,11 +1028,11 @@ function handleAsync(e, t, n) {
|
|
|
819
1028
|
}
|
|
820
1029
|
function clearStatus(e, t = false) {
|
|
821
1030
|
clearPendingSources(e);
|
|
822
|
-
e.
|
|
1031
|
+
e.Ue = false;
|
|
823
1032
|
e.Se = t ? 0 : e.Se & STATUS_UNINITIALIZED;
|
|
824
1033
|
setPendingError(e);
|
|
825
1034
|
updatePendingSignal(e);
|
|
826
|
-
e.
|
|
1035
|
+
e.xe?.();
|
|
827
1036
|
}
|
|
828
1037
|
function notifyStatus(e, t, n, i, r) {
|
|
829
1038
|
if (t === STATUS_ERROR && !(n instanceof StatusError) && !(n instanceof NotReadyError))
|
|
@@ -849,22 +1058,22 @@ function notifyStatus(e, t, n, i, r) {
|
|
|
849
1058
|
}
|
|
850
1059
|
const a = i || c;
|
|
851
1060
|
const f = i || u ? undefined : r;
|
|
852
|
-
if (e.
|
|
1061
|
+
if (e.xe) {
|
|
853
1062
|
if (i && t === STATUS_PENDING) {
|
|
854
1063
|
return;
|
|
855
1064
|
}
|
|
856
1065
|
if (a) {
|
|
857
|
-
e.
|
|
1066
|
+
e.xe(t, n);
|
|
858
1067
|
} else {
|
|
859
|
-
e.
|
|
1068
|
+
e.xe();
|
|
860
1069
|
}
|
|
861
1070
|
return;
|
|
862
1071
|
}
|
|
863
1072
|
forEachDependent(e, e => {
|
|
864
1073
|
e.Ee = clock;
|
|
865
1074
|
if (
|
|
866
|
-
(t === STATUS_PENDING && s && e.
|
|
867
|
-
(t !== STATUS_PENDING && (e.le !== n || e.
|
|
1075
|
+
(t === STATUS_PENDING && s && e.be !== s && !e.Le?.has(s)) ||
|
|
1076
|
+
(t !== STATUS_PENDING && (e.le !== n || e.be || e.Le))
|
|
868
1077
|
) {
|
|
869
1078
|
if (!a && !e.K) globalQueue.se.push(e);
|
|
870
1079
|
notifyStatus(e, t, n, a, f);
|
|
@@ -894,196 +1103,6 @@ function enableExternalSource(e) {
|
|
|
894
1103
|
externalSourceConfig = { factory: t, untrack: n };
|
|
895
1104
|
}
|
|
896
1105
|
}
|
|
897
|
-
const PENDING_OWNER = {};
|
|
898
|
-
function markDisposal(e) {
|
|
899
|
-
let t = e.Ce;
|
|
900
|
-
while (t) {
|
|
901
|
-
t.O |= REACTIVE_ZOMBIE;
|
|
902
|
-
if (t.O & REACTIVE_IN_HEAP) {
|
|
903
|
-
deleteFromHeap(t, dirtyQueue);
|
|
904
|
-
insertIntoHeap(t, zombieQueue);
|
|
905
|
-
}
|
|
906
|
-
markDisposal(t);
|
|
907
|
-
t = t.De;
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
function dispose(e) {
|
|
911
|
-
let t = e.C || null;
|
|
912
|
-
do {
|
|
913
|
-
t = unlinkSubs(t);
|
|
914
|
-
} while (t !== null);
|
|
915
|
-
e.C = null;
|
|
916
|
-
e.ye = null;
|
|
917
|
-
disposeChildren(e, true);
|
|
918
|
-
}
|
|
919
|
-
function disposeChildren(e, t = false, n) {
|
|
920
|
-
if (e.O & REACTIVE_DISPOSED) return;
|
|
921
|
-
if (t) e.O = REACTIVE_DISPOSED;
|
|
922
|
-
let i = n ? e.me : e.Ce;
|
|
923
|
-
while (i) {
|
|
924
|
-
const e = i.De;
|
|
925
|
-
if (i.C) {
|
|
926
|
-
const e = i;
|
|
927
|
-
deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
928
|
-
let t = e.C;
|
|
929
|
-
do {
|
|
930
|
-
t = unlinkSubs(t);
|
|
931
|
-
} while (t !== null);
|
|
932
|
-
e.C = null;
|
|
933
|
-
e.ye = null;
|
|
934
|
-
}
|
|
935
|
-
disposeChildren(i, true);
|
|
936
|
-
i = e;
|
|
937
|
-
}
|
|
938
|
-
if (n) {
|
|
939
|
-
e.me = null;
|
|
940
|
-
} else {
|
|
941
|
-
e.Ce = null;
|
|
942
|
-
e.ve = 0;
|
|
943
|
-
}
|
|
944
|
-
runDisposal(e, n);
|
|
945
|
-
}
|
|
946
|
-
function runDisposal(e, t) {
|
|
947
|
-
let n = t ? e.we : e.be;
|
|
948
|
-
if (!n) return;
|
|
949
|
-
if (Array.isArray(n)) {
|
|
950
|
-
for (let e = 0; e < n.length; e++) {
|
|
951
|
-
const t = n[e];
|
|
952
|
-
t.call(t);
|
|
953
|
-
}
|
|
954
|
-
} else {
|
|
955
|
-
n.call(n);
|
|
956
|
-
}
|
|
957
|
-
t ? (e.we = null) : (e.be = null);
|
|
958
|
-
}
|
|
959
|
-
function childId(e, t) {
|
|
960
|
-
let n = e;
|
|
961
|
-
while (n.Ve && n.i) n = n.i;
|
|
962
|
-
if (n.id != null) return formatId(n.id, t ? n.ve++ : n.ve);
|
|
963
|
-
throw new Error("Cannot get child id from owner without an id");
|
|
964
|
-
}
|
|
965
|
-
function getNextChildId(e) {
|
|
966
|
-
return childId(e, true);
|
|
967
|
-
}
|
|
968
|
-
function peekNextChildId(e) {
|
|
969
|
-
return childId(e, false);
|
|
970
|
-
}
|
|
971
|
-
function formatId(e, t) {
|
|
972
|
-
const n = t.toString(36),
|
|
973
|
-
i = n.length - 1;
|
|
974
|
-
return e + (i ? String.fromCharCode(64 + i) : "") + n;
|
|
975
|
-
}
|
|
976
|
-
function getObserver() {
|
|
977
|
-
if (pendingCheckActive || latestReadActive) return PENDING_OWNER;
|
|
978
|
-
return tracking ? context : null;
|
|
979
|
-
}
|
|
980
|
-
function getOwner() {
|
|
981
|
-
return context;
|
|
982
|
-
}
|
|
983
|
-
function cleanup(e) {
|
|
984
|
-
if (!context) return e;
|
|
985
|
-
if (!context.be) context.be = e;
|
|
986
|
-
else if (Array.isArray(context.be)) context.be.push(e);
|
|
987
|
-
else context.be = [context.be, e];
|
|
988
|
-
return e;
|
|
989
|
-
}
|
|
990
|
-
function isDisposed(e) {
|
|
991
|
-
return !!(e.O & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE));
|
|
992
|
-
}
|
|
993
|
-
function createOwner(e) {
|
|
994
|
-
const t = context;
|
|
995
|
-
const n = e?.transparent ?? false;
|
|
996
|
-
const i = {
|
|
997
|
-
id: e?.id ?? (n ? t?.id : t?.id != null ? getNextChildId(t) : undefined),
|
|
998
|
-
Ve: n || undefined,
|
|
999
|
-
t: true,
|
|
1000
|
-
u: t?.t ? t.u : t,
|
|
1001
|
-
Ce: null,
|
|
1002
|
-
De: null,
|
|
1003
|
-
be: null,
|
|
1004
|
-
F: t?.F ?? globalQueue,
|
|
1005
|
-
Le: t?.Le || defaultContext,
|
|
1006
|
-
ve: 0,
|
|
1007
|
-
we: null,
|
|
1008
|
-
me: null,
|
|
1009
|
-
i: t,
|
|
1010
|
-
dispose(e = true) {
|
|
1011
|
-
disposeChildren(i, e);
|
|
1012
|
-
}
|
|
1013
|
-
};
|
|
1014
|
-
if (t) {
|
|
1015
|
-
const e = t.Ce;
|
|
1016
|
-
if (e === null) {
|
|
1017
|
-
t.Ce = i;
|
|
1018
|
-
} else {
|
|
1019
|
-
i.De = e;
|
|
1020
|
-
t.Ce = i;
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
return i;
|
|
1024
|
-
}
|
|
1025
|
-
function createRoot(e, t) {
|
|
1026
|
-
const n = createOwner(t);
|
|
1027
|
-
return runWithOwner(n, () => e(n.dispose));
|
|
1028
|
-
}
|
|
1029
|
-
function unlinkSubs(e) {
|
|
1030
|
-
const t = e.m;
|
|
1031
|
-
const n = e.D;
|
|
1032
|
-
const i = e.p;
|
|
1033
|
-
const r = e.Ue;
|
|
1034
|
-
if (i !== null) i.Ue = r;
|
|
1035
|
-
else t.ke = r;
|
|
1036
|
-
if (r !== null) r.p = i;
|
|
1037
|
-
else {
|
|
1038
|
-
t.I = i;
|
|
1039
|
-
if (i === null) {
|
|
1040
|
-
t.Ge?.();
|
|
1041
|
-
t.L && !t.xe && !(t.O & REACTIVE_ZOMBIE) && unobserved(t);
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
return n;
|
|
1045
|
-
}
|
|
1046
|
-
function unobserved(e) {
|
|
1047
|
-
deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
1048
|
-
let t = e.C;
|
|
1049
|
-
while (t !== null) {
|
|
1050
|
-
t = unlinkSubs(t);
|
|
1051
|
-
}
|
|
1052
|
-
e.C = null;
|
|
1053
|
-
disposeChildren(e, true);
|
|
1054
|
-
}
|
|
1055
|
-
function link(e, t) {
|
|
1056
|
-
const n = t.ye;
|
|
1057
|
-
if (n !== null && n.m === e) return;
|
|
1058
|
-
let i = null;
|
|
1059
|
-
const r = t.O & REACTIVE_RECOMPUTING_DEPS;
|
|
1060
|
-
if (r) {
|
|
1061
|
-
i = n !== null ? n.D : t.C;
|
|
1062
|
-
if (i !== null && i.m === e) {
|
|
1063
|
-
t.ye = i;
|
|
1064
|
-
return;
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
const s = e.ke;
|
|
1068
|
-
if (s !== null && s.h === t && (!r || isValidLink(s, t))) return;
|
|
1069
|
-
const o = (t.ye = e.ke = { m: e, h: t, D: i, Ue: s, p: null });
|
|
1070
|
-
if (n !== null) n.D = o;
|
|
1071
|
-
else t.C = o;
|
|
1072
|
-
if (s !== null) s.p = o;
|
|
1073
|
-
else e.I = o;
|
|
1074
|
-
}
|
|
1075
|
-
function isValidLink(e, t) {
|
|
1076
|
-
const n = t.ye;
|
|
1077
|
-
if (n !== null) {
|
|
1078
|
-
let i = t.C;
|
|
1079
|
-
do {
|
|
1080
|
-
if (i === e) return true;
|
|
1081
|
-
if (i === n) break;
|
|
1082
|
-
i = i.D;
|
|
1083
|
-
} while (i !== null);
|
|
1084
|
-
}
|
|
1085
|
-
return false;
|
|
1086
|
-
}
|
|
1087
1106
|
GlobalQueue.oe = recompute;
|
|
1088
1107
|
GlobalQueue.ue = disposeChildren;
|
|
1089
1108
|
let tracking = false;
|
|
@@ -1116,15 +1135,15 @@ function releaseSnapshotScope(e) {
|
|
|
1116
1135
|
schedule();
|
|
1117
1136
|
}
|
|
1118
1137
|
function releaseSubtree(e) {
|
|
1119
|
-
let t = e.
|
|
1138
|
+
let t = e.Pe;
|
|
1120
1139
|
while (t) {
|
|
1121
1140
|
if (t.We) {
|
|
1122
|
-
t = t.
|
|
1141
|
+
t = t.ge;
|
|
1123
1142
|
continue;
|
|
1124
1143
|
}
|
|
1125
1144
|
if (t.L) {
|
|
1126
1145
|
const e = t;
|
|
1127
|
-
e.
|
|
1146
|
+
e.Te = false;
|
|
1128
1147
|
if (e.O & REACTIVE_SNAPSHOT_STALE) {
|
|
1129
1148
|
e.O &= ~REACTIVE_SNAPSHOT_STALE;
|
|
1130
1149
|
e.O |= REACTIVE_DIRTY;
|
|
@@ -1133,13 +1152,13 @@ function releaseSubtree(e) {
|
|
|
1133
1152
|
}
|
|
1134
1153
|
}
|
|
1135
1154
|
releaseSubtree(t);
|
|
1136
|
-
t = t.
|
|
1155
|
+
t = t.ge;
|
|
1137
1156
|
}
|
|
1138
1157
|
}
|
|
1139
1158
|
function clearSnapshots() {
|
|
1140
1159
|
if (snapshotSources) {
|
|
1141
1160
|
for (const e of snapshotSources) {
|
|
1142
|
-
delete e.
|
|
1161
|
+
delete e.de;
|
|
1143
1162
|
delete e[STORE_SNAPSHOT_PROPS];
|
|
1144
1163
|
}
|
|
1145
1164
|
snapshotSources = null;
|
|
@@ -1152,14 +1171,15 @@ function recompute(e, t = false) {
|
|
|
1152
1171
|
if (e.K && (!n || activeTransition) && activeTransition !== e.K)
|
|
1153
1172
|
globalQueue.initTransition(e.K);
|
|
1154
1173
|
deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
1174
|
+
e.Ce = null;
|
|
1155
1175
|
if (e.K || n === EFFECT_TRACKED) disposeChildren(e);
|
|
1156
1176
|
else {
|
|
1157
1177
|
markDisposal(e);
|
|
1158
|
-
e.
|
|
1159
|
-
e.
|
|
1160
|
-
e.
|
|
1161
|
-
e.
|
|
1162
|
-
e.
|
|
1178
|
+
e.ve = e.me;
|
|
1179
|
+
e.De = e.Pe;
|
|
1180
|
+
e.me = null;
|
|
1181
|
+
e.Pe = null;
|
|
1182
|
+
e.ye = 0;
|
|
1163
1183
|
}
|
|
1164
1184
|
}
|
|
1165
1185
|
const i = !!(e.O & REACTIVE_OPTIMISTIC_DIRTY);
|
|
@@ -1167,7 +1187,7 @@ function recompute(e, t = false) {
|
|
|
1167
1187
|
const s = !!(e.Se & STATUS_PENDING);
|
|
1168
1188
|
const o = context;
|
|
1169
1189
|
context = e;
|
|
1170
|
-
e.
|
|
1190
|
+
e.Ne = null;
|
|
1171
1191
|
e.O = REACTIVE_RECOMPUTING_DEPS;
|
|
1172
1192
|
e.Ee = clock;
|
|
1173
1193
|
let u = e.X === NOT_PENDING ? e.J : e.X;
|
|
@@ -1196,7 +1216,7 @@ function recompute(e, t = false) {
|
|
|
1196
1216
|
updatePendingSignal(t.te);
|
|
1197
1217
|
}
|
|
1198
1218
|
}
|
|
1199
|
-
if (t instanceof NotReadyError) e.
|
|
1219
|
+
if (t instanceof NotReadyError) e.Ue = true;
|
|
1200
1220
|
notifyStatus(
|
|
1201
1221
|
e,
|
|
1202
1222
|
t instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR,
|
|
@@ -1210,7 +1230,7 @@ function recompute(e, t = false) {
|
|
|
1210
1230
|
context = o;
|
|
1211
1231
|
}
|
|
1212
1232
|
if (!e.le) {
|
|
1213
|
-
const o = e.
|
|
1233
|
+
const o = e.Ne;
|
|
1214
1234
|
let a = o !== null ? o.D : e.C;
|
|
1215
1235
|
if (a !== null) {
|
|
1216
1236
|
do {
|
|
@@ -1220,7 +1240,7 @@ function recompute(e, t = false) {
|
|
|
1220
1240
|
else e.C = null;
|
|
1221
1241
|
}
|
|
1222
1242
|
const f = r ? e.ee : e.X === NOT_PENDING ? e.J : e.X;
|
|
1223
|
-
const l = !e.
|
|
1243
|
+
const l = !e.ke || !e.ke(f, u);
|
|
1224
1244
|
if (l) {
|
|
1225
1245
|
const o = r ? e.ee : undefined;
|
|
1226
1246
|
if (t || (n && activeTransition !== e.K) || i) {
|
|
@@ -1257,7 +1277,7 @@ function updateIfNecessary(e) {
|
|
|
1257
1277
|
}
|
|
1258
1278
|
}
|
|
1259
1279
|
}
|
|
1260
|
-
if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (e.le && e.Ee < clock && !e.
|
|
1280
|
+
if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (e.le && e.Ee < clock && !e.Ce)) {
|
|
1261
1281
|
recompute(e);
|
|
1262
1282
|
}
|
|
1263
1283
|
e.O = REACTIVE_NONE | (e.O & REACTIVE_SNAPSHOT_STALE);
|
|
@@ -1267,13 +1287,13 @@ function computed(e, t, n) {
|
|
|
1267
1287
|
const r = {
|
|
1268
1288
|
id: n?.id ?? (i ? context?.id : context?.id != null ? getNextChildId(context) : undefined),
|
|
1269
1289
|
Ve: i || undefined,
|
|
1270
|
-
|
|
1290
|
+
ke: n?.equals != null ? n.equals : isEqual,
|
|
1271
1291
|
fe: !!n?.pureWrite,
|
|
1272
|
-
|
|
1273
|
-
|
|
1292
|
+
he: n?.unobserved,
|
|
1293
|
+
me: null,
|
|
1274
1294
|
F: context?.F ?? globalQueue,
|
|
1275
|
-
|
|
1276
|
-
|
|
1295
|
+
we: context?.we ?? defaultContext,
|
|
1296
|
+
ye: 0,
|
|
1277
1297
|
L: e,
|
|
1278
1298
|
J: t,
|
|
1279
1299
|
o: 0,
|
|
@@ -1281,34 +1301,34 @@ function computed(e, t, n) {
|
|
|
1281
1301
|
S: undefined,
|
|
1282
1302
|
T: null,
|
|
1283
1303
|
C: null,
|
|
1284
|
-
|
|
1304
|
+
Ne: null,
|
|
1285
1305
|
I: null,
|
|
1286
|
-
|
|
1306
|
+
pe: null,
|
|
1287
1307
|
i: context,
|
|
1288
|
-
|
|
1289
|
-
|
|
1308
|
+
ge: null,
|
|
1309
|
+
Pe: null,
|
|
1290
1310
|
O: n?.lazy ? REACTIVE_LAZY : REACTIVE_NONE,
|
|
1291
1311
|
Se: STATUS_UNINITIALIZED,
|
|
1292
1312
|
Ee: clock,
|
|
1293
1313
|
X: NOT_PENDING,
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1314
|
+
ve: null,
|
|
1315
|
+
De: null,
|
|
1316
|
+
Ce: null,
|
|
1297
1317
|
K: null
|
|
1298
1318
|
};
|
|
1299
1319
|
r.T = r;
|
|
1300
1320
|
const s = context?.t ? context.u : context;
|
|
1301
1321
|
if (context) {
|
|
1302
|
-
const e = context.
|
|
1322
|
+
const e = context.Pe;
|
|
1303
1323
|
if (e === null) {
|
|
1304
|
-
context.
|
|
1324
|
+
context.Pe = r;
|
|
1305
1325
|
} else {
|
|
1306
|
-
r.
|
|
1307
|
-
context.
|
|
1326
|
+
r.ge = e;
|
|
1327
|
+
context.Pe = r;
|
|
1308
1328
|
}
|
|
1309
1329
|
}
|
|
1310
1330
|
if (s) r.o = s.o + 1;
|
|
1311
|
-
if (snapshotCaptureActive && ownerInSnapshotScope(context)) r.
|
|
1331
|
+
if (snapshotCaptureActive && ownerInSnapshotScope(context)) r.Te = true;
|
|
1312
1332
|
if (externalSourceConfig) {
|
|
1313
1333
|
const e = signal(undefined, { equals: false, pureWrite: true });
|
|
1314
1334
|
const t = externalSourceConfig.factory(r.L, () => {
|
|
@@ -1323,7 +1343,7 @@ function computed(e, t, n) {
|
|
|
1323
1343
|
!n?.lazy && recompute(r, true);
|
|
1324
1344
|
if (snapshotCaptureActive && !n?.lazy) {
|
|
1325
1345
|
if (!(r.Se & STATUS_PENDING)) {
|
|
1326
|
-
r.
|
|
1346
|
+
r.de = r.J === undefined ? NO_SNAPSHOT : r.J;
|
|
1327
1347
|
snapshotSources.add(r);
|
|
1328
1348
|
}
|
|
1329
1349
|
}
|
|
@@ -1331,13 +1351,13 @@ function computed(e, t, n) {
|
|
|
1331
1351
|
}
|
|
1332
1352
|
function signal(e, t, n = null) {
|
|
1333
1353
|
const i = {
|
|
1334
|
-
|
|
1354
|
+
ke: t?.equals != null ? t.equals : isEqual,
|
|
1335
1355
|
fe: !!t?.pureWrite,
|
|
1336
1356
|
He: !!t?.He,
|
|
1337
|
-
|
|
1357
|
+
he: t?.unobserved,
|
|
1338
1358
|
J: e,
|
|
1339
1359
|
I: null,
|
|
1340
|
-
|
|
1360
|
+
pe: null,
|
|
1341
1361
|
Ee: clock,
|
|
1342
1362
|
V: n,
|
|
1343
1363
|
N: n?.A || null,
|
|
@@ -1345,7 +1365,7 @@ function signal(e, t, n = null) {
|
|
|
1345
1365
|
};
|
|
1346
1366
|
n && (n.A = i);
|
|
1347
1367
|
if (snapshotCaptureActive && !i.He && !((n?.Se ?? 0) & STATUS_PENDING)) {
|
|
1348
|
-
i.
|
|
1368
|
+
i.de = e === undefined ? NO_SNAPSHOT : e;
|
|
1349
1369
|
snapshotSources.add(i);
|
|
1350
1370
|
}
|
|
1351
1371
|
return i;
|
|
@@ -1404,9 +1424,14 @@ function read(e) {
|
|
|
1404
1424
|
const n = pendingCheckActive;
|
|
1405
1425
|
pendingCheckActive = false;
|
|
1406
1426
|
if (t && e.ee !== undefined) {
|
|
1407
|
-
if (e.ee !== NOT_PENDING && (t.
|
|
1427
|
+
if (e.ee !== NOT_PENDING && (t.Ce || !!(t.Se & STATUS_PENDING))) {
|
|
1408
1428
|
foundPending = true;
|
|
1409
1429
|
}
|
|
1430
|
+
let n = context;
|
|
1431
|
+
if (n?.t) n = n.u;
|
|
1432
|
+
if (n && tracking) link(e, n);
|
|
1433
|
+
read(getPendingSignal(e));
|
|
1434
|
+
read(getPendingSignal(t));
|
|
1410
1435
|
} else {
|
|
1411
1436
|
if (read(getPendingSignal(e))) foundPending = true;
|
|
1412
1437
|
if (t && read(getPendingSignal(t))) foundPending = true;
|
|
@@ -1464,8 +1489,8 @@ function read(e) {
|
|
|
1464
1489
|
return read(e);
|
|
1465
1490
|
} else throw e.le;
|
|
1466
1491
|
}
|
|
1467
|
-
if (snapshotCaptureActive && t && t.
|
|
1468
|
-
const n = e.
|
|
1492
|
+
if (snapshotCaptureActive && t && t.Te) {
|
|
1493
|
+
const n = e.de;
|
|
1469
1494
|
if (n !== undefined) {
|
|
1470
1495
|
const i = n === NO_SNAPSHOT ? undefined : n;
|
|
1471
1496
|
const r = e.X !== NOT_PENDING ? e.X : e.J;
|
|
@@ -1491,7 +1516,7 @@ function setSignal(e, t) {
|
|
|
1491
1516
|
const i = e.ee !== undefined && e.ee !== NOT_PENDING;
|
|
1492
1517
|
const r = n ? (i ? e.ee : e.J) : e.X === NOT_PENDING ? e.J : e.X;
|
|
1493
1518
|
if (typeof t === "function") t = t(r);
|
|
1494
|
-
const s = !e.
|
|
1519
|
+
const s = !e.ke || !e.ke(r, t) || !!(e.Se & STATUS_UNINITIALIZED);
|
|
1495
1520
|
if (!s) {
|
|
1496
1521
|
if (n && i && e.L) {
|
|
1497
1522
|
insertSubs(e, true);
|
|
@@ -1515,8 +1540,8 @@ function setSignal(e, t) {
|
|
|
1515
1540
|
e.X = t;
|
|
1516
1541
|
}
|
|
1517
1542
|
updatePendingSignal(e);
|
|
1518
|
-
if (e.
|
|
1519
|
-
setSignal(e.
|
|
1543
|
+
if (e.Ge) {
|
|
1544
|
+
setSignal(e.Ge, t);
|
|
1520
1545
|
}
|
|
1521
1546
|
e.Ee = clock;
|
|
1522
1547
|
insertSubs(e, n);
|
|
@@ -1549,7 +1574,7 @@ function computePendingState(e) {
|
|
|
1549
1574
|
const t = e;
|
|
1550
1575
|
const n = e.V;
|
|
1551
1576
|
if (n && e.X !== NOT_PENDING) {
|
|
1552
|
-
return !n.
|
|
1577
|
+
return !n.Ce && !(n.Se & STATUS_PENDING);
|
|
1553
1578
|
}
|
|
1554
1579
|
if (e.ee !== undefined && e.ee !== NOT_PENDING) {
|
|
1555
1580
|
if (t.Se & STATUS_PENDING && !(t.Se & STATUS_UNINITIALIZED)) return true;
|
|
@@ -1584,20 +1609,20 @@ function updatePendingSignal(e) {
|
|
|
1584
1609
|
}
|
|
1585
1610
|
}
|
|
1586
1611
|
function getLatestValueComputed(e) {
|
|
1587
|
-
if (!e.
|
|
1612
|
+
if (!e.Ge) {
|
|
1588
1613
|
const t = latestReadActive;
|
|
1589
1614
|
latestReadActive = false;
|
|
1590
1615
|
const n = pendingCheckActive;
|
|
1591
1616
|
pendingCheckActive = false;
|
|
1592
1617
|
const i = context;
|
|
1593
1618
|
context = null;
|
|
1594
|
-
e.
|
|
1595
|
-
e.
|
|
1619
|
+
e.Ge = optimisticComputed(() => read(e));
|
|
1620
|
+
e.Ge.Re = e;
|
|
1596
1621
|
context = i;
|
|
1597
1622
|
pendingCheckActive = n;
|
|
1598
1623
|
latestReadActive = t;
|
|
1599
1624
|
}
|
|
1600
|
-
return e.
|
|
1625
|
+
return e.Ge;
|
|
1601
1626
|
}
|
|
1602
1627
|
function staleValues(e, t = true) {
|
|
1603
1628
|
const n = stale;
|
|
@@ -1658,7 +1683,7 @@ function getContext(e, t = getOwner()) {
|
|
|
1658
1683
|
if (!t) {
|
|
1659
1684
|
throw new NoOwnerError();
|
|
1660
1685
|
}
|
|
1661
|
-
const n = hasContext(e, t) ? t.
|
|
1686
|
+
const n = hasContext(e, t) ? t.we[e.id] : e.defaultValue;
|
|
1662
1687
|
if (isUndefined(n)) {
|
|
1663
1688
|
throw new ContextNotFoundError();
|
|
1664
1689
|
}
|
|
@@ -1668,10 +1693,10 @@ function setContext(e, t, n = getOwner()) {
|
|
|
1668
1693
|
if (!n) {
|
|
1669
1694
|
throw new NoOwnerError();
|
|
1670
1695
|
}
|
|
1671
|
-
n.
|
|
1696
|
+
n.we = { ...n.we, [e.id]: isUndefined(t) ? e.defaultValue : t };
|
|
1672
1697
|
}
|
|
1673
1698
|
function hasContext(e, t) {
|
|
1674
|
-
return !isUndefined(t?.
|
|
1699
|
+
return !isUndefined(t?.we[e.id]);
|
|
1675
1700
|
}
|
|
1676
1701
|
function isUndefined(e) {
|
|
1677
1702
|
return typeof e === "undefined";
|
|
@@ -1692,7 +1717,7 @@ function effect(e, t, n, i, r) {
|
|
|
1692
1717
|
o.$e = n;
|
|
1693
1718
|
o.je = undefined;
|
|
1694
1719
|
o.W = r?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
1695
|
-
o.
|
|
1720
|
+
o.xe = (e, t) => {
|
|
1696
1721
|
const n = e !== undefined ? e : o.Se;
|
|
1697
1722
|
const i = t !== undefined ? t : o.le;
|
|
1698
1723
|
if (n & STATUS_ERROR) {
|
|
@@ -1725,7 +1750,9 @@ function runEffect() {
|
|
|
1725
1750
|
this.je?.();
|
|
1726
1751
|
this.je = undefined;
|
|
1727
1752
|
try {
|
|
1728
|
-
|
|
1753
|
+
const e = this.Me(this.J, this.Fe);
|
|
1754
|
+
if (false && e !== undefined && typeof e !== "function");
|
|
1755
|
+
this.je = e;
|
|
1729
1756
|
} catch (e) {
|
|
1730
1757
|
this.le = new StatusError(this, e);
|
|
1731
1758
|
this.Se |= STATUS_ERROR;
|
|
@@ -1748,7 +1775,8 @@ function trackedEffect(e, t) {
|
|
|
1748
1775
|
() => {
|
|
1749
1776
|
n.je?.();
|
|
1750
1777
|
n.je = undefined;
|
|
1751
|
-
|
|
1778
|
+
const t = staleValues(e);
|
|
1779
|
+
n.je = t;
|
|
1752
1780
|
},
|
|
1753
1781
|
undefined,
|
|
1754
1782
|
{ ...t, lazy: true }
|
|
@@ -1757,7 +1785,7 @@ function trackedEffect(e, t) {
|
|
|
1757
1785
|
n.Ke = true;
|
|
1758
1786
|
n.H = true;
|
|
1759
1787
|
n.W = EFFECT_TRACKED;
|
|
1760
|
-
n.
|
|
1788
|
+
n.xe = (e, t) => {
|
|
1761
1789
|
const i = e !== undefined ? e : n.Se;
|
|
1762
1790
|
if (i & STATUS_ERROR) {
|
|
1763
1791
|
n.F.notify(n, STATUS_PENDING, 0);
|
|
@@ -1852,7 +1880,9 @@ function createReaction(e, t) {
|
|
|
1852
1880
|
() => (r(), getOwner()),
|
|
1853
1881
|
t => {
|
|
1854
1882
|
n?.();
|
|
1855
|
-
|
|
1883
|
+
const i = (e.effect || e)?.();
|
|
1884
|
+
if (false && i !== undefined && typeof i !== "function");
|
|
1885
|
+
n = i;
|
|
1856
1886
|
dispose(t);
|
|
1857
1887
|
},
|
|
1858
1888
|
e.error,
|
|
@@ -1884,7 +1914,7 @@ function createOptimistic(e, t, n) {
|
|
|
1884
1914
|
function onSettled(e) {
|
|
1885
1915
|
const t = getOwner();
|
|
1886
1916
|
t && !t.Ke
|
|
1887
|
-
? createTrackedEffect(() => untrack(e))
|
|
1917
|
+
? createTrackedEffect(() => untrack(e), undefined)
|
|
1888
1918
|
: globalQueue.enqueue(EFFECT_USER, () => {
|
|
1889
1919
|
const t = e();
|
|
1890
1920
|
t?.();
|
|
@@ -1917,28 +1947,28 @@ function applyState(e, t, n) {
|
|
|
1917
1947
|
let t = false;
|
|
1918
1948
|
const c = getOverrideValue(r, s, u, "length", o);
|
|
1919
1949
|
if (e.length && c && e[0] && n(e[0]) != null) {
|
|
1920
|
-
let a, f, l, E,
|
|
1950
|
+
let a, f, l, E, d, T, S, R;
|
|
1921
1951
|
for (
|
|
1922
1952
|
l = 0, E = Math.min(c, e.length);
|
|
1923
1953
|
l < E &&
|
|
1924
|
-
((
|
|
1954
|
+
((T = getOverrideValue(r, s, u, l, o)) === e[l] || (T && e[l] && n(T) === n(e[l])));
|
|
1925
1955
|
l++
|
|
1926
1956
|
) {
|
|
1927
|
-
applyState(e[l], wrap(
|
|
1957
|
+
applyState(e[l], wrap(T, i), n);
|
|
1928
1958
|
}
|
|
1929
1959
|
const O = new Array(e.length),
|
|
1930
1960
|
_ = new Map();
|
|
1931
1961
|
for (
|
|
1932
|
-
E = c - 1,
|
|
1962
|
+
E = c - 1, d = e.length - 1;
|
|
1933
1963
|
E >= l &&
|
|
1934
|
-
|
|
1935
|
-
((
|
|
1936
|
-
E--,
|
|
1964
|
+
d >= l &&
|
|
1965
|
+
((T = getOverrideValue(r, s, u, E, o)) === e[d] || (T && e[d] && n(T) === n(e[d])));
|
|
1966
|
+
E--, d--
|
|
1937
1967
|
) {
|
|
1938
|
-
O[
|
|
1968
|
+
O[d] = T;
|
|
1939
1969
|
}
|
|
1940
|
-
if (l >
|
|
1941
|
-
for (f = l; f <=
|
|
1970
|
+
if (l > d || l > E) {
|
|
1971
|
+
for (f = l; f <= d; f++) {
|
|
1942
1972
|
t = true;
|
|
1943
1973
|
i[STORE_NODE][f] && setSignal(i[STORE_NODE][f], wrap(e[f], i));
|
|
1944
1974
|
}
|
|
@@ -1952,20 +1982,20 @@ function applyState(e, t, n) {
|
|
|
1952
1982
|
c !== e.length && i[STORE_NODE].length && setSignal(i[STORE_NODE].length, e.length);
|
|
1953
1983
|
return;
|
|
1954
1984
|
}
|
|
1955
|
-
S = new Array(
|
|
1956
|
-
for (f =
|
|
1957
|
-
|
|
1958
|
-
R =
|
|
1985
|
+
S = new Array(d + 1);
|
|
1986
|
+
for (f = d; f >= l; f--) {
|
|
1987
|
+
T = e[f];
|
|
1988
|
+
R = T ? n(T) : T;
|
|
1959
1989
|
a = _.get(R);
|
|
1960
1990
|
S[f] = a === undefined ? -1 : a;
|
|
1961
1991
|
_.set(R, f);
|
|
1962
1992
|
}
|
|
1963
1993
|
for (a = l; a <= E; a++) {
|
|
1964
|
-
|
|
1965
|
-
R =
|
|
1994
|
+
T = getOverrideValue(r, s, u, a, o);
|
|
1995
|
+
R = T ? n(T) : T;
|
|
1966
1996
|
f = _.get(R);
|
|
1967
1997
|
if (f !== undefined && f !== -1) {
|
|
1968
|
-
O[f] =
|
|
1998
|
+
O[f] = T;
|
|
1969
1999
|
f = S[f];
|
|
1970
2000
|
_.set(R, f);
|
|
1971
2001
|
}
|
|
@@ -2000,12 +2030,12 @@ function applyState(e, t, n) {
|
|
|
2000
2030
|
const f = c[a];
|
|
2001
2031
|
const l = u[f];
|
|
2002
2032
|
const E = unwrap(getOverrideValue(r, s, u, f, o));
|
|
2003
|
-
let
|
|
2004
|
-
if (E ===
|
|
2005
|
-
if (!E || !isWrappable(E) || !isWrappable(
|
|
2033
|
+
let d = unwrap(e[f]);
|
|
2034
|
+
if (E === d) continue;
|
|
2035
|
+
if (!E || !isWrappable(E) || !isWrappable(d) || (n(E) != null && n(E) !== n(d))) {
|
|
2006
2036
|
t && setSignal(t, void 0);
|
|
2007
|
-
l && setSignal(l, isWrappable(
|
|
2008
|
-
} else applyState(
|
|
2037
|
+
l && setSignal(l, isWrappable(d) ? wrap(d, i) : d);
|
|
2038
|
+
} else applyState(d, wrap(E, i), n);
|
|
2009
2039
|
}
|
|
2010
2040
|
}
|
|
2011
2041
|
if ((u = i[STORE_HAS])) {
|
|
@@ -2053,7 +2083,7 @@ function createProjectionInternal(e, t = {}, n) {
|
|
|
2053
2083
|
let r;
|
|
2054
2084
|
const o = new Proxy(
|
|
2055
2085
|
s,
|
|
2056
|
-
createWriteTraps(() => !i || t.
|
|
2086
|
+
createWriteTraps(() => !i || t.Ce === r)
|
|
2057
2087
|
);
|
|
2058
2088
|
storeSetter(o, o => {
|
|
2059
2089
|
r = e(o);
|
|
@@ -2064,7 +2094,7 @@ function createProjectionInternal(e, t = {}, n) {
|
|
|
2064
2094
|
u !== o && u !== undefined && reconcile(u, n?.key || "id")(s);
|
|
2065
2095
|
});
|
|
2066
2096
|
});
|
|
2067
|
-
i.
|
|
2097
|
+
i.Ae = true;
|
|
2068
2098
|
return { store: s, node: i };
|
|
2069
2099
|
}
|
|
2070
2100
|
function createProjection(e, t = {}, n) {
|
|
@@ -2084,6 +2114,18 @@ function createWriteTraps(e) {
|
|
|
2084
2114
|
}
|
|
2085
2115
|
return typeof i === "object" && i !== null ? new Proxy(i, t) : i;
|
|
2086
2116
|
},
|
|
2117
|
+
has(e, t) {
|
|
2118
|
+
let n;
|
|
2119
|
+
setWriteOverride(true);
|
|
2120
|
+
setProjectionWriteActive(true);
|
|
2121
|
+
try {
|
|
2122
|
+
n = t in e;
|
|
2123
|
+
} finally {
|
|
2124
|
+
setWriteOverride(false);
|
|
2125
|
+
setProjectionWriteActive(false);
|
|
2126
|
+
}
|
|
2127
|
+
return n;
|
|
2128
|
+
},
|
|
2087
2129
|
set(t, n, i) {
|
|
2088
2130
|
if (e && !e()) return true;
|
|
2089
2131
|
setWriteOverride(true);
|
|
@@ -2141,7 +2183,12 @@ function wrap(e, t) {
|
|
|
2141
2183
|
return n;
|
|
2142
2184
|
}
|
|
2143
2185
|
function isWrappable(e) {
|
|
2144
|
-
return
|
|
2186
|
+
return (
|
|
2187
|
+
e != null &&
|
|
2188
|
+
typeof e === "object" &&
|
|
2189
|
+
!Object.isFrozen(e) &&
|
|
2190
|
+
!(typeof Node !== "undefined" && e instanceof Node)
|
|
2191
|
+
);
|
|
2145
2192
|
}
|
|
2146
2193
|
let writeOverride = false;
|
|
2147
2194
|
function setWriteOverride(e) {
|
|
@@ -2172,7 +2219,7 @@ function getNode(e, t, n, i, r = isEqual, s, o) {
|
|
|
2172
2219
|
}
|
|
2173
2220
|
if (o && t in o) {
|
|
2174
2221
|
const e = o[t];
|
|
2175
|
-
u.
|
|
2222
|
+
u.de = e === undefined ? NO_SNAPSHOT : e;
|
|
2176
2223
|
snapshotSources?.add(u);
|
|
2177
2224
|
}
|
|
2178
2225
|
return (e[t] = u);
|
|
@@ -2275,8 +2322,12 @@ const storeTraps = {
|
|
|
2275
2322
|
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
2276
2323
|
? e[STORE_OVERRIDE][t] !== $DELETED
|
|
2277
2324
|
: t in e[STORE_VALUE];
|
|
2278
|
-
|
|
2279
|
-
|
|
2325
|
+
if (!writeOnly(e[$PROXY])) {
|
|
2326
|
+
getObserver() &&
|
|
2327
|
+
read(
|
|
2328
|
+
getNode(getNodes(e, STORE_HAS), t, n, e[STORE_FIREWALL], isEqual, e[STORE_OPTIMISTIC])
|
|
2329
|
+
);
|
|
2330
|
+
}
|
|
2280
2331
|
return n;
|
|
2281
2332
|
},
|
|
2282
2333
|
set(e, t, n) {
|
|
@@ -2314,23 +2365,32 @@ const storeTraps = {
|
|
|
2314
2365
|
? e[STORE_OVERRIDE][t]
|
|
2315
2366
|
: s;
|
|
2316
2367
|
const a = n?.[$TARGET]?.[STORE_VALUE] ?? n;
|
|
2317
|
-
|
|
2318
|
-
const
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2368
|
+
const f = Array.isArray(r) && t !== "length";
|
|
2369
|
+
const l = f ? parseInt(t) + 1 : 0;
|
|
2370
|
+
const E =
|
|
2371
|
+
f &&
|
|
2372
|
+
(e[STORE_OPTIMISTIC_OVERRIDE] && "length" in e[STORE_OPTIMISTIC_OVERRIDE]
|
|
2373
|
+
? e[STORE_OPTIMISTIC_OVERRIDE].length
|
|
2374
|
+
: e[STORE_OVERRIDE] && "length" in e[STORE_OVERRIDE]
|
|
2375
|
+
? e[STORE_OVERRIDE].length
|
|
2376
|
+
: r.length);
|
|
2377
|
+
const d = f && l > E ? l : undefined;
|
|
2378
|
+
if (c === a && d === undefined) return true;
|
|
2379
|
+
if (a !== undefined && a === s && d === undefined) delete e[u]?.[t];
|
|
2380
|
+
else {
|
|
2381
|
+
const n = e[u] || (e[u] = Object.create(null));
|
|
2382
|
+
n[t] = a;
|
|
2383
|
+
if (d !== undefined) n.length = d;
|
|
2384
|
+
}
|
|
2385
|
+
const T = isWrappable(a);
|
|
2322
2386
|
e[STORE_HAS]?.[t] && setSignal(e[STORE_HAS][t], true);
|
|
2323
|
-
const
|
|
2324
|
-
|
|
2387
|
+
const S = getNodes(e, STORE_NODE);
|
|
2388
|
+
S[t] && setSignal(S[t], () => (T ? wrap(a, e) : a));
|
|
2325
2389
|
if (Array.isArray(r)) {
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
} else {
|
|
2329
|
-
const e = parseInt(t) + 1;
|
|
2330
|
-
if (e > f) E.length && setSignal(E.length, e);
|
|
2331
|
-
}
|
|
2390
|
+
const e = t === "length" ? a : d;
|
|
2391
|
+
e !== undefined && S.length && setSignal(S.length, e);
|
|
2332
2392
|
}
|
|
2333
|
-
|
|
2393
|
+
S[$TRACK] && setSignal(S[$TRACK], undefined);
|
|
2334
2394
|
});
|
|
2335
2395
|
}
|
|
2336
2396
|
return true;
|
|
@@ -2488,7 +2548,7 @@ function createOptimisticProjectionInternal(e, t = {}, n) {
|
|
|
2488
2548
|
let r;
|
|
2489
2549
|
const o = new Proxy(
|
|
2490
2550
|
s,
|
|
2491
|
-
createWriteTraps(() => !i || t.
|
|
2551
|
+
createWriteTraps(() => !i || t.Ce === r)
|
|
2492
2552
|
);
|
|
2493
2553
|
setProjectionWriteActive(true);
|
|
2494
2554
|
try {
|
|
@@ -2509,7 +2569,7 @@ function createOptimisticProjectionInternal(e, t = {}, n) {
|
|
|
2509
2569
|
setProjectionWriteActive(false);
|
|
2510
2570
|
}
|
|
2511
2571
|
});
|
|
2512
|
-
i.
|
|
2572
|
+
i.Ae = true;
|
|
2513
2573
|
}
|
|
2514
2574
|
return { store: s, node: i };
|
|
2515
2575
|
}
|
|
@@ -2834,8 +2894,8 @@ function updateKeyedMap() {
|
|
|
2834
2894
|
f,
|
|
2835
2895
|
l,
|
|
2836
2896
|
E = new Array(t),
|
|
2837
|
-
|
|
2838
|
-
|
|
2897
|
+
d = new Array(t),
|
|
2898
|
+
T = this.tt ? new Array(t) : undefined,
|
|
2839
2899
|
S = this.nt ? new Array(t) : undefined;
|
|
2840
2900
|
for (
|
|
2841
2901
|
s = 0, o = Math.min(this.Ze, t);
|
|
@@ -2852,8 +2912,8 @@ function updateKeyedMap() {
|
|
|
2852
2912
|
o--, u--
|
|
2853
2913
|
) {
|
|
2854
2914
|
E[u] = this.Xe[o];
|
|
2855
|
-
|
|
2856
|
-
|
|
2915
|
+
d[u] = this.Je[o];
|
|
2916
|
+
T && (T[u] = this.tt[o]);
|
|
2857
2917
|
S && (S[u] = this.nt[o]);
|
|
2858
2918
|
}
|
|
2859
2919
|
f = new Map();
|
|
@@ -2871,8 +2931,8 @@ function updateKeyedMap() {
|
|
|
2871
2931
|
i = f.get(a);
|
|
2872
2932
|
if (i !== undefined && i !== -1) {
|
|
2873
2933
|
E[i] = this.Xe[n];
|
|
2874
|
-
|
|
2875
|
-
|
|
2934
|
+
d[i] = this.Je[n];
|
|
2935
|
+
T && (T[i] = this.tt[n]);
|
|
2876
2936
|
S && (S[i] = this.nt[n]);
|
|
2877
2937
|
i = l[i];
|
|
2878
2938
|
f.set(a, i);
|
|
@@ -2881,9 +2941,9 @@ function updateKeyedMap() {
|
|
|
2881
2941
|
for (i = s; i < t; i++) {
|
|
2882
2942
|
if (i in E) {
|
|
2883
2943
|
this.Xe[i] = E[i];
|
|
2884
|
-
this.Je[i] =
|
|
2885
|
-
if (
|
|
2886
|
-
this.tt[i] =
|
|
2944
|
+
this.Je[i] = d[i];
|
|
2945
|
+
if (T) {
|
|
2946
|
+
this.tt[i] = T[i];
|
|
2887
2947
|
setSignal(this.tt[i], e[i]);
|
|
2888
2948
|
}
|
|
2889
2949
|
if (S) {
|
|
@@ -2966,14 +3026,14 @@ function compare(e, t, n) {
|
|
|
2966
3026
|
}
|
|
2967
3027
|
function boundaryComputed(e, t) {
|
|
2968
3028
|
const n = computed(e, undefined, { lazy: true });
|
|
2969
|
-
n.
|
|
3029
|
+
n.xe = (e, t) => {
|
|
2970
3030
|
const i = e !== undefined ? e : n.Se;
|
|
2971
3031
|
const r = t !== undefined ? t : n.le;
|
|
2972
3032
|
n.Se &= ~n.ut;
|
|
2973
3033
|
n.F.notify(n, n.ut, i, r);
|
|
2974
3034
|
};
|
|
2975
3035
|
n.ut = t;
|
|
2976
|
-
n.
|
|
3036
|
+
n.Ae = true;
|
|
2977
3037
|
recompute(n, true);
|
|
2978
3038
|
return n;
|
|
2979
3039
|
}
|
|
@@ -2992,8 +3052,8 @@ class CollectionQueue extends Queue {
|
|
|
2992
3052
|
ft = new Set();
|
|
2993
3053
|
lt = signal(false, { pureWrite: true, He: true });
|
|
2994
3054
|
Et = false;
|
|
2995
|
-
|
|
2996
|
-
|
|
3055
|
+
dt;
|
|
3056
|
+
Tt = ON_INIT;
|
|
2997
3057
|
constructor(e) {
|
|
2998
3058
|
super();
|
|
2999
3059
|
this.ct = e;
|
|
@@ -3004,16 +3064,16 @@ class CollectionQueue extends Queue {
|
|
|
3004
3064
|
}
|
|
3005
3065
|
notify(e, t, n, i) {
|
|
3006
3066
|
if (!(t & this.ct)) return super.notify(e, t, n, i);
|
|
3007
|
-
if (this.Et && this.
|
|
3067
|
+
if (this.Et && this.dt) {
|
|
3008
3068
|
const e = untrack(() => {
|
|
3009
3069
|
try {
|
|
3010
|
-
return this.
|
|
3070
|
+
return this.dt();
|
|
3011
3071
|
} catch {
|
|
3012
3072
|
return ON_INIT;
|
|
3013
3073
|
}
|
|
3014
3074
|
});
|
|
3015
|
-
if (e !== this.
|
|
3016
|
-
this.
|
|
3075
|
+
if (e !== this.Tt) {
|
|
3076
|
+
this.Tt = e;
|
|
3017
3077
|
this.Et = false;
|
|
3018
3078
|
this.ft.clear();
|
|
3019
3079
|
}
|
|
@@ -3035,14 +3095,17 @@ class CollectionQueue extends Queue {
|
|
|
3035
3095
|
}
|
|
3036
3096
|
checkSources() {
|
|
3037
3097
|
for (const e of this.ft) {
|
|
3038
|
-
if (
|
|
3098
|
+
if (
|
|
3099
|
+
e.O & REACTIVE_DISPOSED ||
|
|
3100
|
+
(!(e.Se & this.ct) && !(this.ct & STATUS_ERROR && e.Se & STATUS_PENDING))
|
|
3101
|
+
)
|
|
3039
3102
|
this.ft.delete(e);
|
|
3040
3103
|
}
|
|
3041
3104
|
if (!this.ft.size) {
|
|
3042
3105
|
setSignal(this.lt, false);
|
|
3043
|
-
if (this.
|
|
3106
|
+
if (this.dt) {
|
|
3044
3107
|
try {
|
|
3045
|
-
this.
|
|
3108
|
+
this.Tt = untrack(() => this.dt());
|
|
3046
3109
|
} catch {}
|
|
3047
3110
|
}
|
|
3048
3111
|
}
|
|
@@ -3051,7 +3114,7 @@ class CollectionQueue extends Queue {
|
|
|
3051
3114
|
function createCollectionBoundary(e, t, n, i) {
|
|
3052
3115
|
const r = createOwner();
|
|
3053
3116
|
const s = new CollectionQueue(e);
|
|
3054
|
-
if (i) s.
|
|
3117
|
+
if (i) s.dt = i;
|
|
3055
3118
|
const o = createBoundChildren(r, t, s, e);
|
|
3056
3119
|
const u = computed(() => {
|
|
3057
3120
|
if (!read(s.lt)) {
|