@solidjs/signals 2.0.0-beta.21 → 2.0.0-beta.22
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 +182 -298
- package/dist/node.cjs +1055 -1166
- package/dist/prod/affects.js +71 -163
- package/dist/prod/boundaries.js +141 -137
- package/dist/prod/core/action.js +3 -3
- package/dist/prod/core/async.js +83 -99
- package/dist/prod/core/core.js +254 -297
- package/dist/prod/core/effect.js +46 -46
- package/dist/prod/core/external.js +4 -4
- package/dist/prod/core/graph.js +54 -46
- package/dist/prod/core/heap.js +50 -50
- package/dist/prod/core/lanes.js +34 -34
- package/dist/prod/core/optimistic.js +64 -106
- package/dist/prod/core/owner.js +52 -52
- package/dist/prod/core/scheduler.js +209 -210
- package/dist/prod/core/verdict.js +129 -78
- package/dist/prod/map.js +101 -101
- package/dist/prod/signals.js +23 -5
- package/dist/prod/store/optimistic.js +11 -11
- package/dist/prod/store/projection.js +2 -2
- package/dist/prod/store/store.js +14 -14
- package/dist/types/affects.d.ts +9 -9
- package/dist/types/core/async.d.ts +1 -1
- package/dist/types/core/error.d.ts +7 -0
- package/dist/types/core/scheduler.d.ts +1 -6
- package/dist/types/core/types.d.ts +6 -11
- package/dist/types-cjs/affects.d.cts +9 -9
- package/dist/types-cjs/core/async.d.cts +1 -1
- package/dist/types-cjs/core/error.d.cts +7 -0
- package/dist/types-cjs/core/scheduler.d.cts +1 -6
- package/dist/types-cjs/core/types.d.cts +6 -11
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -330,15 +330,15 @@ const transitions = new Set;
|
|
|
330
330
|
const dirtyQueue = {
|
|
331
331
|
h: new Array(2e3).fill(undefined),
|
|
332
332
|
N: false,
|
|
333
|
-
|
|
334
|
-
|
|
333
|
+
C: 0,
|
|
334
|
+
P: 0
|
|
335
335
|
};
|
|
336
336
|
|
|
337
337
|
const zombieQueue = {
|
|
338
338
|
h: new Array(2e3).fill(undefined),
|
|
339
339
|
N: false,
|
|
340
|
-
|
|
341
|
-
|
|
340
|
+
C: 0,
|
|
341
|
+
P: 0
|
|
342
342
|
};
|
|
343
343
|
|
|
344
344
|
let clock = 0;
|
|
@@ -572,35 +572,32 @@ class GlobalQueue extends Queue {
|
|
|
572
572
|
// _clearOptimisticStore).
|
|
573
573
|
static ne=null;
|
|
574
574
|
// affects()-side hooks (wired by affects.ts, mirroring _update): the mark
|
|
575
|
-
// engine — count/register/release
|
|
576
|
-
//
|
|
577
|
-
//
|
|
575
|
+
// engine — count/register/release — lives with the feature. Every call site
|
|
576
|
+
// is gated by state only that module creates, so `!` invocations are safe
|
|
577
|
+
// once the gate holds.
|
|
578
578
|
static re=null;
|
|
579
579
|
static ie=null;
|
|
580
580
|
static oe=null;
|
|
581
|
-
static se=null;
|
|
582
|
-
static ue=null;
|
|
583
|
-
static le=null;
|
|
584
581
|
// External-source bridge (wired by enableExternalSource(); null while no
|
|
585
582
|
// config is active — including after _resetExternalSourceConfig()).
|
|
586
|
-
static
|
|
587
|
-
static
|
|
583
|
+
static se=null;
|
|
584
|
+
static ue=null;
|
|
588
585
|
// Verdict-layer hooks (wired by verdict.ts when isPending()/latest() are
|
|
589
586
|
// imported; null in apps that never use them). Call sites either guard for
|
|
590
587
|
// null or sit behind state only the verdict layer can create (`!` is safe
|
|
591
588
|
// there: `_pendingSignal`/`_latestValueComputed` are only ever assigned by
|
|
592
589
|
// verdict.ts, and `pendingCheckActive`/`latestReadActive` only flip inside
|
|
593
590
|
// isPending()/latest()).
|
|
591
|
+
static le=null;
|
|
592
|
+
static ce=null;
|
|
593
|
+
static ae=null;
|
|
594
594
|
static fe=null;
|
|
595
595
|
static Ee=null;
|
|
596
|
-
static de=null;
|
|
597
596
|
static Se=null;
|
|
597
|
+
static de=null;
|
|
598
598
|
static Te=null;
|
|
599
599
|
static pe=null;
|
|
600
600
|
static _e=null;
|
|
601
|
-
static Oe=null;
|
|
602
|
-
static Re=null;
|
|
603
|
-
static Ie=null;
|
|
604
601
|
// Optimistic-engine hooks (wired by core/optimistic.ts via
|
|
605
602
|
// installOptimisticEngine(), called from verdict.ts / createOptimistic /
|
|
606
603
|
// createOptimisticStore — every module that can create optimistic state).
|
|
@@ -608,20 +605,18 @@ class GlobalQueue extends Queue {
|
|
|
608
605
|
// `_overrideValue` slot, a lane in `activeLanes`, an `_optimisticNodes`
|
|
609
606
|
// entry, or a non-null `currentOptimisticLane`, so `!` invocations are safe
|
|
610
607
|
// once the gate holds.
|
|
608
|
+
static Oe=null;
|
|
609
|
+
static Re=null;
|
|
610
|
+
static Ie=null;
|
|
611
611
|
static Ae=null;
|
|
612
612
|
static he=null;
|
|
613
613
|
static Ne=null;
|
|
614
614
|
static ye=null;
|
|
615
|
-
static Pe=null;
|
|
616
615
|
static Ce=null;
|
|
616
|
+
static Pe=null;
|
|
617
617
|
static ge=null;
|
|
618
618
|
static be=null;
|
|
619
619
|
static De=null;
|
|
620
|
-
static me=null;
|
|
621
|
-
static ve=null;
|
|
622
|
-
static we=null;
|
|
623
|
-
static Ge=null;
|
|
624
|
-
static Le=null;
|
|
625
620
|
flush() {
|
|
626
621
|
if (this.B) return;
|
|
627
622
|
this.B = true;
|
|
@@ -642,25 +637,18 @@ class GlobalQueue extends Queue {
|
|
|
642
637
|
if (this.D === e) currentBatch = this.D = createBatch();
|
|
643
638
|
// Run lane effects immediately (before stashing) - lanes with no pending async
|
|
644
639
|
if (activeLanes.size) {
|
|
645
|
-
GlobalQueue.
|
|
646
|
-
GlobalQueue.
|
|
640
|
+
GlobalQueue.he(EFFECT_RENDER);
|
|
641
|
+
GlobalQueue.he(EFFECT_USER);
|
|
647
642
|
}
|
|
648
643
|
this.stashQueues(e.K);
|
|
649
644
|
clock++;
|
|
650
645
|
// A kept ambient batch may hold pending nodes (#2916): stay
|
|
651
646
|
// scheduled so the outer drain loop commits them via the plain
|
|
652
647
|
// flush path instead of leaving them until the next natural flush.
|
|
653
|
-
scheduled = dirtyQueue.
|
|
648
|
+
scheduled = dirtyQueue.P >= dirtyQueue.C || this.D.H.length > 0;
|
|
654
649
|
reassignPendingTransition(e.H);
|
|
655
650
|
activeTransition = null;
|
|
656
|
-
|
|
657
|
-
// wraps finalizePureQueue in the engine; a non-empty _optimisticNodes
|
|
658
|
-
// means _optimisticWrite ran, which installed the hook.
|
|
659
|
-
if (!e.$.length && !e.j.size && e.G.length) {
|
|
660
|
-
GlobalQueue.Ne(e);
|
|
661
|
-
} else {
|
|
662
|
-
finalizePureQueue(null, true);
|
|
663
|
-
}
|
|
651
|
+
finalizePureQueue(null, true);
|
|
664
652
|
return;
|
|
665
653
|
}
|
|
666
654
|
const t = activeTransition;
|
|
@@ -685,7 +673,7 @@ class GlobalQueue extends Queue {
|
|
|
685
673
|
} else {
|
|
686
674
|
if (canUseSimpleSyncFlush(this)) {
|
|
687
675
|
commitPendingNodes();
|
|
688
|
-
if (dirtyQueue.
|
|
676
|
+
if (dirtyQueue.P >= dirtyQueue.C) {
|
|
689
677
|
runHeap(dirtyQueue, GlobalQueue.X);
|
|
690
678
|
commitPendingNodes();
|
|
691
679
|
}
|
|
@@ -696,11 +684,11 @@ class GlobalQueue extends Queue {
|
|
|
696
684
|
}
|
|
697
685
|
clock++;
|
|
698
686
|
// Check if finalization added items to the heap (from optimistic reversion)
|
|
699
|
-
scheduled = dirtyQueue.
|
|
687
|
+
scheduled = dirtyQueue.P >= dirtyQueue.C;
|
|
700
688
|
// Run lane effects first (for ready lanes), then regular effects
|
|
701
|
-
activeLanes.size && GlobalQueue.
|
|
689
|
+
activeLanes.size && GlobalQueue.he(EFFECT_RENDER);
|
|
702
690
|
this.run(EFFECT_RENDER);
|
|
703
|
-
activeLanes.size && GlobalQueue.
|
|
691
|
+
activeLanes.size && GlobalQueue.he(EFFECT_USER);
|
|
704
692
|
this.run(EFFECT_USER);
|
|
705
693
|
if (false) ;
|
|
706
694
|
if (false && !scheduled && !activeTransition && transitions.size === 0 && activeLanes.size === 0) ;
|
|
@@ -713,7 +701,12 @@ class GlobalQueue extends Queue {
|
|
|
713
701
|
// Only track async if the boundary is propagating STATUS_PENDING (not caught by boundary)
|
|
714
702
|
if (t & STATUS_PENDING) {
|
|
715
703
|
if (n & STATUS_PENDING) {
|
|
716
|
-
const t = r !== undefined ? r : e.
|
|
704
|
+
const t = r !== undefined ? r : e.me;
|
|
705
|
+
// A visibility-only mark notification (the affects() boundary
|
|
706
|
+
// channel) updates display state on its way up but must be invisible
|
|
707
|
+
// to completion accounting BY CONSTRUCTION: it never registers a
|
|
708
|
+
// reporter and never counts toward the loading-boundary diagnostic.
|
|
709
|
+
if (t?.ve) return true;
|
|
717
710
|
if (activeTransition && t) {
|
|
718
711
|
const n = t.source;
|
|
719
712
|
let r = activeTransition.j.get(n);
|
|
@@ -787,48 +780,48 @@ function insertSubs(e, t = false) {
|
|
|
787
780
|
// Get source lane: prefer node's own lane over current context
|
|
788
781
|
// This is important for isPending signals which need their own lane to flush immediately
|
|
789
782
|
const n = e.i || currentOptimisticLane;
|
|
790
|
-
const r = e.
|
|
783
|
+
const r = e.we !== undefined;
|
|
791
784
|
const i = reaskArmed;
|
|
792
|
-
for (let o = e.k; o !== null; o = o.
|
|
785
|
+
for (let o = e.k; o !== null; o = o.Ge) {
|
|
793
786
|
// A value-change notification is a new question for the subscriber: any
|
|
794
787
|
// pending re-ask mark (refresh) it carried is superseded.
|
|
795
|
-
if (i) o.
|
|
796
|
-
if (r && o.
|
|
797
|
-
o.
|
|
788
|
+
if (i) o.Ue.Le &= ~REACTIVE_REASK;
|
|
789
|
+
if (r && o.Ue.ke & CONFIG_IN_SNAPSHOT_SCOPE) {
|
|
790
|
+
o.Ue.Le |= REACTIVE_SNAPSHOT_STALE;
|
|
798
791
|
continue;
|
|
799
792
|
}
|
|
800
793
|
if (t && n) {
|
|
801
|
-
o.
|
|
802
|
-
assignOrMergeLane(o.
|
|
794
|
+
o.Ue.Le |= REACTIVE_OPTIMISTIC_DIRTY;
|
|
795
|
+
assignOrMergeLane(o.Ue, n);
|
|
803
796
|
} else if (t) {
|
|
804
|
-
o.
|
|
797
|
+
o.Ue.Le |= REACTIVE_OPTIMISTIC_DIRTY;
|
|
805
798
|
// No source lane means reversion - clear subscriber's lane so effects go to regular queue
|
|
806
|
-
o.
|
|
799
|
+
o.Ue.i = undefined;
|
|
807
800
|
}
|
|
808
|
-
enqueueSub(o.
|
|
801
|
+
enqueueSub(o.Ue);
|
|
809
802
|
}
|
|
810
803
|
}
|
|
811
804
|
|
|
812
805
|
function commitPendingNode(e) {
|
|
813
806
|
const t = e;
|
|
814
|
-
if (!t.
|
|
807
|
+
if (!t.Ve) {
|
|
815
808
|
if (e.V !== NOT_PENDING) {
|
|
816
|
-
e.
|
|
809
|
+
e.xe = e.V;
|
|
817
810
|
e.V = NOT_PENDING;
|
|
818
811
|
}
|
|
819
|
-
if (e._ || e.O) GlobalQueue.
|
|
812
|
+
if (e._ || e.O) GlobalQueue.fe(e);
|
|
820
813
|
return;
|
|
821
814
|
}
|
|
822
815
|
if (e.V !== NOT_PENDING) {
|
|
823
|
-
e.
|
|
816
|
+
e.xe = e.V;
|
|
824
817
|
e.V = NOT_PENDING;
|
|
825
818
|
// Set _modified for effects, but not for tracked effects (they handle their own scheduling)
|
|
826
|
-
if (e.
|
|
819
|
+
if (e.Qe && e.Qe !== EFFECT_TRACKED) e.Fe = true;
|
|
827
820
|
}
|
|
828
|
-
t.
|
|
829
|
-
if (!(t
|
|
830
|
-
if (t.
|
|
831
|
-
if (e._ || e.O) GlobalQueue.
|
|
821
|
+
t.Le &= ~REACTIVE_MANUAL_WRITE;
|
|
822
|
+
if (!(t.We & STATUS_PENDING)) t.We &= ~STATUS_UNINITIALIZED;
|
|
823
|
+
if (t.Me !== null || t.He !== null) GlobalQueue.J(t, false, true);
|
|
824
|
+
if (e._ || e.O) GlobalQueue.fe(e);
|
|
832
825
|
}
|
|
833
826
|
|
|
834
827
|
function commitPendingNodes() {
|
|
@@ -845,7 +838,7 @@ function finalizePureQueue(e = null, t = false) {
|
|
|
845
838
|
const n = !t;
|
|
846
839
|
if (n) commitPendingNodes();
|
|
847
840
|
if (!t && globalQueue.m.length) checkBoundaryChildren(globalQueue);
|
|
848
|
-
const r = dirtyQueue.
|
|
841
|
+
const r = dirtyQueue.P >= dirtyQueue.C;
|
|
849
842
|
if (r) runHeap(dirtyQueue, GlobalQueue.X);
|
|
850
843
|
if (n) {
|
|
851
844
|
if (r) commitPendingNodes();
|
|
@@ -853,20 +846,26 @@ function finalizePureQueue(e = null, t = false) {
|
|
|
853
846
|
const t = e ?? globalQueue.D;
|
|
854
847
|
// Optimistic reversion: a non-empty batch means _optimisticWrite ran,
|
|
855
848
|
// which installed the engine's hooks.
|
|
856
|
-
if (t.G.length) GlobalQueue.
|
|
849
|
+
if (t.G.length) GlobalQueue.Re(t.G);
|
|
857
850
|
// Replay entanglement: subs recorded by the read-time gate get rescheduled
|
|
858
851
|
// so they re-run with the now-committed values visible.
|
|
859
852
|
if (e && e.q.size) {
|
|
860
853
|
for (const t of e.q) {
|
|
861
|
-
if (t.
|
|
854
|
+
if (t.Le & REACTIVE_DISPOSED) continue;
|
|
862
855
|
enqueueSub(t);
|
|
863
856
|
}
|
|
864
857
|
e.q.clear();
|
|
865
858
|
}
|
|
866
859
|
// Declared motion ends with the transaction: settle (or plain flush end
|
|
867
860
|
// for ambient marks) releases each registration's refcount. A non-empty
|
|
868
|
-
// batch means registerAffectsMark ran, which installed the hook.
|
|
869
|
-
|
|
861
|
+
// batch means registerAffectsMark ran, which installed the hook. Marks
|
|
862
|
+
// held boundary display state through the visual channel, and their
|
|
863
|
+
// release is the display-state update point — re-run the boundary sweep
|
|
864
|
+
// (the earlier sweep above ran while the marks were still live).
|
|
865
|
+
if (t.L.length) {
|
|
866
|
+
GlobalQueue.re(t.L);
|
|
867
|
+
if (globalQueue.m.length) checkBoundaryChildren(globalQueue);
|
|
868
|
+
}
|
|
870
869
|
// A non-empty set means trackOptimisticStore ran, which installed the
|
|
871
870
|
// hook; the hook iterates, clears, and schedules (keeping the loop out of
|
|
872
871
|
// core lets esbuild shake it — rollup already folds the null guard). The
|
|
@@ -874,13 +873,13 @@ function finalizePureQueue(e = null, t = false) {
|
|
|
874
873
|
if (t.U.size) GlobalQueue.te(t.U, e);
|
|
875
874
|
sweepTransientStoreNodes();
|
|
876
875
|
// Lanes only enter activeLanes through the engine's getOrCreateLane.
|
|
877
|
-
if (activeLanes.size) GlobalQueue.
|
|
876
|
+
if (activeLanes.size) GlobalQueue.Ae(e);
|
|
878
877
|
}
|
|
879
878
|
}
|
|
880
879
|
|
|
881
880
|
function checkBoundaryChildren(e) {
|
|
882
881
|
for (const t of e.m) {
|
|
883
|
-
t.
|
|
882
|
+
t.je?.();
|
|
884
883
|
checkBoundaryChildren(t);
|
|
885
884
|
}
|
|
886
885
|
}
|
|
@@ -947,16 +946,16 @@ function runQueue$1(e, t) {
|
|
|
947
946
|
}
|
|
948
947
|
|
|
949
948
|
function reporterBlocksSource(e, t) {
|
|
950
|
-
if (e.
|
|
951
|
-
if (e
|
|
952
|
-
for (let n = e.
|
|
953
|
-
let e = n.
|
|
949
|
+
if (e.Le & (REACTIVE_ZOMBIE | REACTIVE_DISPOSED)) return false;
|
|
950
|
+
if (e.$e?.has(t)) return true;
|
|
951
|
+
for (let n = e.Ke; n; n = n.Ye) {
|
|
952
|
+
let e = n.qe;
|
|
954
953
|
while (e) {
|
|
955
|
-
if (e === t || e.
|
|
954
|
+
if (e === t || e.Be === t) return true;
|
|
956
955
|
e = e.t;
|
|
957
956
|
}
|
|
958
957
|
}
|
|
959
|
-
return !!(e
|
|
958
|
+
return !!(e.We & STATUS_PENDING && e.me instanceof NotReadyError && e.me.source === t);
|
|
960
959
|
}
|
|
961
960
|
|
|
962
961
|
function transitionComplete(e) {
|
|
@@ -972,7 +971,7 @@ function transitionComplete(e) {
|
|
|
972
971
|
}
|
|
973
972
|
r.delete(e);
|
|
974
973
|
}
|
|
975
|
-
if (!i) e.j.delete(n); else if (n
|
|
974
|
+
if (!i) e.j.delete(n); else if (n.We & STATUS_PENDING && n.me?.source === n) {
|
|
976
975
|
t = false;
|
|
977
976
|
break;
|
|
978
977
|
}
|
|
@@ -980,7 +979,7 @@ function transitionComplete(e) {
|
|
|
980
979
|
// Override blockage lives with the engine. Absent hook = "no optimistic
|
|
981
980
|
// blockage", which is exact: only _optimisticWrite (engine) pushes to
|
|
982
981
|
// _optimisticNodes, so without the engine the loop was vacuous anyway.
|
|
983
|
-
if (t && e.G.length && GlobalQueue.
|
|
982
|
+
if (t && e.G.length && GlobalQueue.Ie(e)) t = false;
|
|
984
983
|
t && (e.I = true);
|
|
985
984
|
return t;
|
|
986
985
|
}
|
|
@@ -1005,7 +1004,7 @@ function runInTransition(e, t) {
|
|
|
1005
1004
|
}
|
|
1006
1005
|
|
|
1007
1006
|
/** The queue a node belongs to, picked from its own zombie flag. */ function queueFor(e) {
|
|
1008
|
-
return e.
|
|
1007
|
+
return e.Le & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
1009
1008
|
}
|
|
1010
1009
|
|
|
1011
1010
|
/**
|
|
@@ -1013,40 +1012,40 @@ function runInTransition(e, t) {
|
|
|
1013
1012
|
* the heap and go directly to their effect queue; everything else is inserted
|
|
1014
1013
|
* into its own (zombie-flag-routed) heap with the `_min` cursor pulled down.
|
|
1015
1014
|
*/ function enqueueSub(e) {
|
|
1016
|
-
if (e.
|
|
1015
|
+
if (e.Qe === EFFECT_TRACKED) {
|
|
1017
1016
|
const t = e;
|
|
1018
|
-
if (!t.
|
|
1019
|
-
t.
|
|
1020
|
-
t.
|
|
1017
|
+
if (!t.Fe) {
|
|
1018
|
+
t.Fe = true;
|
|
1019
|
+
t.Ze.enqueue(EFFECT_USER, t.Xe);
|
|
1021
1020
|
}
|
|
1022
1021
|
return;
|
|
1023
1022
|
}
|
|
1024
1023
|
const t = queueFor(e);
|
|
1025
|
-
if (t.
|
|
1024
|
+
if (t.C > e.ze) t.C = e.ze;
|
|
1026
1025
|
insertIntoHeap(e, t);
|
|
1027
1026
|
}
|
|
1028
1027
|
|
|
1029
1028
|
function actualInsertIntoHeap(e, t) {
|
|
1030
|
-
const n = (e.Z?.
|
|
1031
|
-
if (n >= e.
|
|
1032
|
-
const r = e.
|
|
1029
|
+
const n = (e.Z?.Je ? e.Z.et?.ze : e.Z?.ze) ?? -1;
|
|
1030
|
+
if (n >= e.ze) e.ze = n + 1;
|
|
1031
|
+
const r = e.ze;
|
|
1033
1032
|
const i = t.h[r];
|
|
1034
1033
|
if (i === undefined) t.h[r] = e; else {
|
|
1035
|
-
const t = i.
|
|
1036
|
-
t.
|
|
1037
|
-
e.
|
|
1038
|
-
i.
|
|
1034
|
+
const t = i.tt;
|
|
1035
|
+
t.nt = e;
|
|
1036
|
+
e.tt = t;
|
|
1037
|
+
i.tt = e;
|
|
1039
1038
|
}
|
|
1040
|
-
if (r > t.
|
|
1039
|
+
if (r > t.P) t.P = r;
|
|
1041
1040
|
}
|
|
1042
1041
|
|
|
1043
1042
|
function insertIntoHeap(e, t) {
|
|
1044
|
-
let n = e.
|
|
1043
|
+
let n = e.Le;
|
|
1045
1044
|
if (n & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_MANUAL_WRITE)) return;
|
|
1046
1045
|
if (n & REACTIVE_CHECK) {
|
|
1047
|
-
e.
|
|
1046
|
+
e.Le = n & -4 | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
|
|
1048
1047
|
} else {
|
|
1049
|
-
e.
|
|
1048
|
+
e.Le = n | REACTIVE_IN_HEAP;
|
|
1050
1049
|
// An unmarked node entering a marked heap invalidates the markHeap memo:
|
|
1051
1050
|
// `_marked` is only reset by runHeap, so a write between two mid-tick
|
|
1052
1051
|
// pulls (read-time markHeap + updateIfNecessary) would otherwise leave
|
|
@@ -1058,49 +1057,49 @@ function insertIntoHeap(e, t) {
|
|
|
1058
1057
|
}
|
|
1059
1058
|
|
|
1060
1059
|
function insertIntoHeapHeight(e, t) {
|
|
1061
|
-
let n = e.
|
|
1060
|
+
let n = e.Le;
|
|
1062
1061
|
if (n & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT | REACTIVE_MANUAL_WRITE)) return;
|
|
1063
|
-
e.
|
|
1062
|
+
e.Le = n | REACTIVE_IN_HEAP_HEIGHT;
|
|
1064
1063
|
actualInsertIntoHeap(e, t);
|
|
1065
1064
|
}
|
|
1066
1065
|
|
|
1067
1066
|
function deleteFromHeap(e, t) {
|
|
1068
|
-
const n = e.
|
|
1067
|
+
const n = e.Le;
|
|
1069
1068
|
if (!(n & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
|
|
1070
|
-
e.
|
|
1071
|
-
const r = e.
|
|
1072
|
-
if (e.
|
|
1073
|
-
const n = e.
|
|
1069
|
+
e.Le = n & -25;
|
|
1070
|
+
const r = e.ze;
|
|
1071
|
+
if (e.tt === e) t.h[r] = undefined; else {
|
|
1072
|
+
const n = e.nt;
|
|
1074
1073
|
const i = t.h[r];
|
|
1075
1074
|
const o = n ?? i;
|
|
1076
|
-
if (e === i) t.h[r] = n; else e.
|
|
1077
|
-
o.
|
|
1075
|
+
if (e === i) t.h[r] = n; else e.tt.nt = n;
|
|
1076
|
+
o.tt = e.tt;
|
|
1078
1077
|
}
|
|
1079
|
-
e.
|
|
1080
|
-
e.
|
|
1078
|
+
e.tt = e;
|
|
1079
|
+
e.nt = undefined;
|
|
1081
1080
|
}
|
|
1082
1081
|
|
|
1083
1082
|
function markHeap(e) {
|
|
1084
1083
|
if (e.N) return;
|
|
1085
1084
|
e.N = true;
|
|
1086
|
-
for (let t = 0; t <= e.
|
|
1087
|
-
for (let n = e.h[t]; n !== undefined; n = n.
|
|
1088
|
-
if (n.
|
|
1085
|
+
for (let t = 0; t <= e.P; t++) {
|
|
1086
|
+
for (let n = e.h[t]; n !== undefined; n = n.nt) {
|
|
1087
|
+
if (n.Le & REACTIVE_IN_HEAP) markNode(n);
|
|
1089
1088
|
}
|
|
1090
1089
|
}
|
|
1091
1090
|
}
|
|
1092
1091
|
|
|
1093
1092
|
function markNode(e, t = REACTIVE_DIRTY) {
|
|
1094
|
-
const n = e.
|
|
1093
|
+
const n = e.Le;
|
|
1095
1094
|
if ((n & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= t) return;
|
|
1096
|
-
e.
|
|
1097
|
-
for (let t = e.k; t !== null; t = t.
|
|
1098
|
-
markNode(t.
|
|
1099
|
-
}
|
|
1100
|
-
if (e.
|
|
1101
|
-
for (let t = e.
|
|
1102
|
-
for (let e = t.k; e !== null; e = e.
|
|
1103
|
-
markNode(e.
|
|
1095
|
+
e.Le = n & -4 | t;
|
|
1096
|
+
for (let t = e.k; t !== null; t = t.Ge) {
|
|
1097
|
+
markNode(t.Ue, REACTIVE_CHECK);
|
|
1098
|
+
}
|
|
1099
|
+
if (e.rt !== null) {
|
|
1100
|
+
for (let t = e.rt; t !== null; t = t.it) {
|
|
1101
|
+
for (let e = t.k; e !== null; e = e.Ge) {
|
|
1102
|
+
markNode(e.Ue, REACTIVE_CHECK);
|
|
1104
1103
|
}
|
|
1105
1104
|
}
|
|
1106
1105
|
}
|
|
@@ -1108,33 +1107,33 @@ function markNode(e, t = REACTIVE_DIRTY) {
|
|
|
1108
1107
|
|
|
1109
1108
|
function runHeap(e, t) {
|
|
1110
1109
|
e.N = false;
|
|
1111
|
-
for (e.
|
|
1112
|
-
let n = e.h[e.
|
|
1110
|
+
for (e.C = 0; e.C <= e.P; e.C++) {
|
|
1111
|
+
let n = e.h[e.C];
|
|
1113
1112
|
while (n !== undefined) {
|
|
1114
|
-
if (n.
|
|
1115
|
-
n = e.h[e.
|
|
1113
|
+
if (n.Le & REACTIVE_IN_HEAP) t(n); else adjustHeight(n, e);
|
|
1114
|
+
n = e.h[e.C];
|
|
1116
1115
|
}
|
|
1117
1116
|
}
|
|
1118
|
-
e.
|
|
1117
|
+
e.P = 0;
|
|
1119
1118
|
}
|
|
1120
1119
|
|
|
1121
1120
|
function adjustHeight(e, t) {
|
|
1122
1121
|
deleteFromHeap(e, t);
|
|
1123
|
-
let n = e.
|
|
1124
|
-
for (let t = e.
|
|
1125
|
-
const e = t.
|
|
1126
|
-
const r = e.
|
|
1127
|
-
if (r.
|
|
1128
|
-
}
|
|
1129
|
-
if (e.
|
|
1130
|
-
e.
|
|
1131
|
-
for (let t = e.k; t !== null; t = t.
|
|
1122
|
+
let n = e.ze;
|
|
1123
|
+
for (let t = e.Ke; t; t = t.Ye) {
|
|
1124
|
+
const e = t.qe;
|
|
1125
|
+
const r = e.Be || e;
|
|
1126
|
+
if (r.Ve && r.ze >= n) n = r.ze + 1;
|
|
1127
|
+
}
|
|
1128
|
+
if (e.ze !== n) {
|
|
1129
|
+
e.ze = n;
|
|
1130
|
+
for (let t = e.k; t !== null; t = t.Ge) {
|
|
1132
1131
|
// Route each subscriber by its own zombie flag, mirroring the
|
|
1133
1132
|
// post-recompute height-adjust path. Inserting into the running `heap`
|
|
1134
1133
|
// unconditionally can park a zombie in `dirtyQueue` (or a live node in
|
|
1135
1134
|
// `zombieQueue`), breaking the flag/queue invariant `deleteFromHeap`
|
|
1136
1135
|
// relies on — the same corruption class as #2759.
|
|
1137
|
-
insertIntoHeapHeight(t.
|
|
1136
|
+
insertIntoHeapHeight(t.Ue, queueFor(t.Ue));
|
|
1138
1137
|
}
|
|
1139
1138
|
}
|
|
1140
1139
|
}
|
|
@@ -1143,10 +1142,10 @@ const PENDING_OWNER = {};
|
|
|
1143
1142
|
|
|
1144
1143
|
// Dummy owner to trigger store's read() path
|
|
1145
1144
|
function markDisposal(e) {
|
|
1146
|
-
let t = e.
|
|
1145
|
+
let t = e.ot;
|
|
1147
1146
|
while (t) {
|
|
1148
|
-
const e = t.
|
|
1149
|
-
t.
|
|
1147
|
+
const e = t.Le;
|
|
1148
|
+
t.Le = e | REACTIVE_ZOMBIE;
|
|
1150
1149
|
// migrate height-adjust entries too, not just recompute entries: every
|
|
1151
1150
|
// `deleteFromHeap` call site picks the queue from the zombie flag, so a
|
|
1152
1151
|
// node left physically linked in `dirtyQueue` after being zombified gets
|
|
@@ -1157,79 +1156,79 @@ function markDisposal(e) {
|
|
|
1157
1156
|
if (e & REACTIVE_IN_HEAP) insertIntoHeap(t, zombieQueue); else insertIntoHeapHeight(t, zombieQueue);
|
|
1158
1157
|
}
|
|
1159
1158
|
markDisposal(t);
|
|
1160
|
-
t = t.
|
|
1159
|
+
t = t.st;
|
|
1161
1160
|
}
|
|
1162
1161
|
}
|
|
1163
1162
|
|
|
1164
1163
|
function dispose(e) {
|
|
1165
|
-
let t = e.
|
|
1164
|
+
let t = e.Ke;
|
|
1166
1165
|
while (t !== null) {
|
|
1167
1166
|
t = unlinkSubs(t);
|
|
1168
1167
|
}
|
|
1169
|
-
e.
|
|
1170
|
-
e.
|
|
1168
|
+
e.Ke = null;
|
|
1169
|
+
e.ut = null;
|
|
1171
1170
|
disposeChildren(e, true);
|
|
1172
1171
|
}
|
|
1173
1172
|
|
|
1174
1173
|
function disposeChildren(e, t = false, n) {
|
|
1175
|
-
const r = e.
|
|
1174
|
+
const r = e.Le;
|
|
1176
1175
|
if (r & REACTIVE_DISPOSED) return;
|
|
1177
1176
|
if (t) {
|
|
1178
|
-
e.
|
|
1177
|
+
e.Le = r | REACTIVE_DISPOSED;
|
|
1179
1178
|
// Companions are created detached and outlive their owner, but a verdict
|
|
1180
1179
|
// must not: a disposed source can never settle, so an isPending companion
|
|
1181
1180
|
// latched `true` here would hold a spinner forever (INV-9, the PR #2845
|
|
1182
1181
|
// edge). Snap runs after the DISPOSED flag is set so the oracle reads
|
|
1183
1182
|
// false, and notifies subscribers still watching the companion.
|
|
1184
1183
|
const t = e;
|
|
1185
|
-
if (t._ || t.O) GlobalQueue.
|
|
1184
|
+
if (t._ || t.O) GlobalQueue.fe(t);
|
|
1186
1185
|
}
|
|
1187
|
-
if (t && e.
|
|
1188
|
-
let i = n ? e.
|
|
1186
|
+
if (t && e.Ve) e.lt = null;
|
|
1187
|
+
let i = n ? e.Me : e.ot;
|
|
1189
1188
|
while (i) {
|
|
1190
|
-
const e = i.
|
|
1191
|
-
if (i.
|
|
1189
|
+
const e = i.st;
|
|
1190
|
+
if (i.Ke) {
|
|
1192
1191
|
const e = i;
|
|
1193
1192
|
deleteFromHeap(e, queueFor(e));
|
|
1194
|
-
let t = e.
|
|
1193
|
+
let t = e.Ke;
|
|
1195
1194
|
do {
|
|
1196
1195
|
t = unlinkSubs(t);
|
|
1197
1196
|
} while (t !== null);
|
|
1198
|
-
e.
|
|
1199
|
-
e.
|
|
1197
|
+
e.Ke = null;
|
|
1198
|
+
e.ut = null;
|
|
1200
1199
|
}
|
|
1201
1200
|
disposeChildren(i, true);
|
|
1202
1201
|
i = e;
|
|
1203
1202
|
}
|
|
1204
1203
|
if (n) {
|
|
1205
|
-
e.
|
|
1204
|
+
e.Me = null;
|
|
1206
1205
|
} else {
|
|
1207
|
-
e.
|
|
1208
|
-
e.
|
|
1206
|
+
e.ot = null;
|
|
1207
|
+
e.ct = 0;
|
|
1209
1208
|
}
|
|
1210
1209
|
// O(1) splice out of parent's chain on individual dispose. Skipped during
|
|
1211
1210
|
// batch dispose (parent already disposed) and zombie disposal (node sits on
|
|
1212
1211
|
// parent's _pendingFirstChild). We leave node._nextSibling intact so outer
|
|
1213
1212
|
// walks that already advanced past us still reach later siblings.
|
|
1214
|
-
if (t && !n && !(r & REACTIVE_ZOMBIE) && e.Z !== null && !(e.Z.
|
|
1215
|
-
const t = e.
|
|
1216
|
-
const n = e.
|
|
1217
|
-
if (t !== null) t.
|
|
1218
|
-
if (n !== null) n.
|
|
1219
|
-
e.
|
|
1213
|
+
if (t && !n && !(r & REACTIVE_ZOMBIE) && e.Z !== null && !(e.Z.Le & REACTIVE_DISPOSED)) {
|
|
1214
|
+
const t = e.ft;
|
|
1215
|
+
const n = e.st;
|
|
1216
|
+
if (t !== null) t.st = n; else e.Z.ot = n;
|
|
1217
|
+
if (n !== null) n.ft = t;
|
|
1218
|
+
e.ft = null;
|
|
1220
1219
|
}
|
|
1221
1220
|
runDisposal(e, n);
|
|
1222
1221
|
// Final effect-returned cleanup fires at true disposal, after `_disposal`
|
|
1223
1222
|
// to mirror rerun ordering (compute-phase teardown first, cleanup last).
|
|
1224
|
-
if (t && e.
|
|
1225
|
-
const t = e.
|
|
1226
|
-
e.
|
|
1223
|
+
if (t && e.Et) {
|
|
1224
|
+
const t = e.Et;
|
|
1225
|
+
e.Et = undefined;
|
|
1227
1226
|
t();
|
|
1228
1227
|
}
|
|
1229
1228
|
}
|
|
1230
1229
|
|
|
1231
1230
|
function runDisposal(e, t) {
|
|
1232
|
-
let n = t ? e.
|
|
1231
|
+
let n = t ? e.He : e.St;
|
|
1233
1232
|
if (!n) return;
|
|
1234
1233
|
if (Array.isArray(n)) {
|
|
1235
1234
|
for (let e = 0; e < n.length; e++) {
|
|
@@ -1239,13 +1238,13 @@ function runDisposal(e, t) {
|
|
|
1239
1238
|
} else {
|
|
1240
1239
|
n.call(n);
|
|
1241
1240
|
}
|
|
1242
|
-
t ? e.
|
|
1241
|
+
t ? e.He = null : e.St = null;
|
|
1243
1242
|
}
|
|
1244
1243
|
|
|
1245
1244
|
function childId(e, t) {
|
|
1246
1245
|
let n = e;
|
|
1247
|
-
while (n.
|
|
1248
|
-
if (n.id != null) return formatId(n.id, t ? n.
|
|
1246
|
+
while (n.ke & CONFIG_TRANSPARENT && n.Z) n = n.Z;
|
|
1247
|
+
if (n.id != null) return formatId(n.id, t ? n.ct++ : n.ct);
|
|
1249
1248
|
throw new Error("");
|
|
1250
1249
|
}
|
|
1251
1250
|
|
|
@@ -1326,7 +1325,7 @@ function formatId(e, t) {
|
|
|
1326
1325
|
* checks. `cleanup()` is the unchecked primitive used by internals.
|
|
1327
1326
|
*/ function cleanup(e) {
|
|
1328
1327
|
if (!context) return e;
|
|
1329
|
-
if (!context.
|
|
1328
|
+
if (!context.St) context.St = e; else if (Array.isArray(context.St)) context.St.push(e); else context.St = [ context.St, e ];
|
|
1330
1329
|
return e;
|
|
1331
1330
|
}
|
|
1332
1331
|
|
|
@@ -1346,7 +1345,7 @@ function formatId(e, t) {
|
|
|
1346
1345
|
* }
|
|
1347
1346
|
* ```
|
|
1348
1347
|
*/ function isDisposed(e) {
|
|
1349
|
-
return !!(e.
|
|
1348
|
+
return !!(e.Le & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE));
|
|
1350
1349
|
}
|
|
1351
1350
|
|
|
1352
1351
|
function disposeRootSelf(e = true) {
|
|
@@ -1365,29 +1364,29 @@ function disposeRootSelf(e = true) {
|
|
|
1365
1364
|
const n = e?.transparent ?? false;
|
|
1366
1365
|
const r = {
|
|
1367
1366
|
id: inheritId(e, n, t),
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1367
|
+
ke: n ? CONFIG_TRANSPARENT : 0,
|
|
1368
|
+
Je: true,
|
|
1369
|
+
et: t?.Je ? t.et : t,
|
|
1370
|
+
ot: null,
|
|
1371
|
+
st: null,
|
|
1372
1372
|
ft: null,
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
Ke: null,
|
|
1373
|
+
St: null,
|
|
1374
|
+
Ze: t?.Ze ?? globalQueue,
|
|
1375
|
+
dt: t?.dt || defaultContext,
|
|
1376
|
+
ct: 0,
|
|
1377
|
+
He: null,
|
|
1378
|
+
Me: null,
|
|
1380
1379
|
Z: t,
|
|
1381
1380
|
dispose: disposeRootSelf
|
|
1382
1381
|
};
|
|
1383
1382
|
if (t) {
|
|
1384
|
-
const e = t.
|
|
1383
|
+
const e = t.ot;
|
|
1385
1384
|
if (e === null) {
|
|
1386
|
-
t.
|
|
1385
|
+
t.ot = r;
|
|
1387
1386
|
} else {
|
|
1388
|
-
r.
|
|
1389
|
-
e.
|
|
1390
|
-
t.
|
|
1387
|
+
r.st = e;
|
|
1388
|
+
e.ft = r;
|
|
1389
|
+
t.ot = r;
|
|
1391
1390
|
}
|
|
1392
1391
|
}
|
|
1393
1392
|
return r;
|
|
@@ -1423,60 +1422,66 @@ function disposeRootSelf(e = true) {
|
|
|
1423
1422
|
|
|
1424
1423
|
// https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L100
|
|
1425
1424
|
function unlinkSubs(e) {
|
|
1426
|
-
const t = e.
|
|
1427
|
-
const n = e.
|
|
1428
|
-
const r = e.
|
|
1429
|
-
const i = e.
|
|
1430
|
-
if (r !== null) r.
|
|
1431
|
-
if (i !== null) i.
|
|
1425
|
+
const t = e.qe;
|
|
1426
|
+
const n = e.Ye;
|
|
1427
|
+
const r = e.Ge;
|
|
1428
|
+
const i = e.Tt;
|
|
1429
|
+
if (r !== null) r.Tt = i; else t._t = i;
|
|
1430
|
+
if (i !== null) i.Ge = r; else {
|
|
1432
1431
|
t.k = r;
|
|
1433
1432
|
if (r === null) {
|
|
1434
1433
|
t.W?.();
|
|
1435
1434
|
// No more subscribers; only tear down if CONFIG_AUTO_DISPOSE is set.
|
|
1436
1435
|
const e = t;
|
|
1437
|
-
e.
|
|
1436
|
+
e.Ve && e.ke & CONFIG_AUTO_DISPOSE && !(e.Le & REACTIVE_ZOMBIE) && unobserved(e);
|
|
1438
1437
|
}
|
|
1439
1438
|
}
|
|
1440
1439
|
return n;
|
|
1441
1440
|
}
|
|
1442
1441
|
|
|
1443
1442
|
function trimStaleDeps(e) {
|
|
1444
|
-
const t = e.
|
|
1445
|
-
let n = t !== null ? t.
|
|
1443
|
+
const t = e.ut;
|
|
1444
|
+
let n = t !== null ? t.Ye : e.Ke;
|
|
1446
1445
|
if (n !== null) {
|
|
1447
1446
|
do {
|
|
1448
1447
|
n = unlinkSubs(n);
|
|
1449
1448
|
} while (n !== null);
|
|
1450
|
-
if (t !== null) t.
|
|
1449
|
+
if (t !== null) t.Ye = null; else e.Ke = null;
|
|
1451
1450
|
}
|
|
1452
1451
|
}
|
|
1453
1452
|
|
|
1454
1453
|
function unobserved(e) {
|
|
1455
1454
|
deleteFromHeap(e, queueFor(e));
|
|
1456
|
-
let t = e.
|
|
1455
|
+
let t = e.Ke;
|
|
1457
1456
|
while (t !== null) {
|
|
1458
1457
|
t = unlinkSubs(t);
|
|
1459
1458
|
}
|
|
1460
|
-
e.
|
|
1461
|
-
e.
|
|
1459
|
+
e.Ke = null;
|
|
1460
|
+
e.ut = null;
|
|
1462
1461
|
disposeChildren(e, true);
|
|
1463
1462
|
}
|
|
1464
1463
|
|
|
1465
1464
|
// https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L52
|
|
1466
1465
|
function link(e, t, n = false) {
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1466
|
+
// Repeat touches within one pass AND-combine `_pendingObserver`: a probe
|
|
1467
|
+
// read (`isPending(() => x())`) beside a value read of the same dep must
|
|
1468
|
+
// not relabel the value dependency as probe-only — the value read is what
|
|
1469
|
+
// real-error propagation and affects() coverage key off, regardless of
|
|
1470
|
+
// read order within the computation.
|
|
1471
|
+
const r = t.ut;
|
|
1472
|
+
if (r !== null && r.qe === e) {
|
|
1473
|
+
r.Ot &&= n;
|
|
1470
1474
|
return;
|
|
1471
1475
|
}
|
|
1472
1476
|
let i = null;
|
|
1473
|
-
const o = t.
|
|
1477
|
+
const o = t.Le & REACTIVE_RECOMPUTING_DEPS;
|
|
1474
1478
|
if (o) {
|
|
1475
|
-
i = r !== null ? r.
|
|
1476
|
-
if (i !== null && i.
|
|
1477
|
-
i.
|
|
1478
|
-
t.
|
|
1479
|
-
|
|
1479
|
+
i = r !== null ? r.Ye : t.Ke;
|
|
1480
|
+
if (i !== null && i.qe === e) {
|
|
1481
|
+
i.Rt = t.It;
|
|
1482
|
+
t.ut = i;
|
|
1483
|
+
// First touch of this pass: the previous pass's label is stale.
|
|
1484
|
+
i.Ot = n;
|
|
1480
1485
|
return;
|
|
1481
1486
|
}
|
|
1482
1487
|
}
|
|
@@ -1485,22 +1490,24 @@ function link(e, t, n = false) {
|
|
|
1485
1490
|
// [deps.._depsTail] prefix — the O(1) equivalent of scanning the dep list
|
|
1486
1491
|
// (the old alien-signals `isValidLink` walk, O(n²) when a computation
|
|
1487
1492
|
// re-reads earlier deps non-consecutively, e.g. store leaf reads).
|
|
1488
|
-
const s = e.
|
|
1489
|
-
if (s !== null && s.
|
|
1490
|
-
|
|
1493
|
+
const s = e._t;
|
|
1494
|
+
if (s !== null && s.Ue === t && (!o || s.Rt === t.It)) {
|
|
1495
|
+
// Gen-matched during a recompute = repeat touch this pass (AND); outside
|
|
1496
|
+
// a recompute there is no pass boundary, so the latest read labels it.
|
|
1497
|
+
if (o) s.Ot &&= n; else s.Ot = n;
|
|
1491
1498
|
return;
|
|
1492
1499
|
}
|
|
1493
|
-
const u = t.
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1500
|
+
const u = t.ut = e._t = {
|
|
1501
|
+
qe: e,
|
|
1502
|
+
Ue: t,
|
|
1503
|
+
Ye: i,
|
|
1504
|
+
Tt: s,
|
|
1505
|
+
Ge: null,
|
|
1506
|
+
Rt: t.It,
|
|
1507
|
+
Ot: n
|
|
1501
1508
|
};
|
|
1502
|
-
if (r !== null) r.
|
|
1503
|
-
if (s !== null) s.
|
|
1509
|
+
if (r !== null) r.Ye = u; else t.Ke = u;
|
|
1510
|
+
if (s !== null) s.Ge = u; else e.k = u;
|
|
1504
1511
|
}
|
|
1505
1512
|
|
|
1506
1513
|
// The lazily-created Set is the ONE container for pending sources. Its
|
|
@@ -1509,79 +1516,75 @@ function link(e, t, n = false) {
|
|
|
1509
1516
|
// overlapping source landed beside the Set and removePendingSource refused
|
|
1510
1517
|
// to clear it, stranding the Set members' pending forever (#2893).
|
|
1511
1518
|
function addPendingSource(e, t) {
|
|
1512
|
-
if (e
|
|
1513
|
-
(e
|
|
1519
|
+
if (e.$e?.has(t)) return false;
|
|
1520
|
+
(e.$e ??= new Set).add(t);
|
|
1514
1521
|
return true;
|
|
1515
1522
|
}
|
|
1516
1523
|
|
|
1517
1524
|
function removePendingSource(e, t) {
|
|
1518
|
-
if (!e
|
|
1519
|
-
if (e.
|
|
1525
|
+
if (!e.$e?.delete(t)) return false;
|
|
1526
|
+
if (e.$e.size === 0) e.$e = undefined;
|
|
1520
1527
|
return true;
|
|
1521
1528
|
}
|
|
1522
1529
|
|
|
1523
1530
|
function clearPendingSources(e) {
|
|
1524
|
-
e
|
|
1525
|
-
e
|
|
1531
|
+
e.$e?.clear();
|
|
1532
|
+
e.$e = undefined;
|
|
1526
1533
|
}
|
|
1527
1534
|
|
|
1528
1535
|
function setPendingError(e, t, n) {
|
|
1529
1536
|
if (!t) {
|
|
1530
|
-
e.
|
|
1537
|
+
e.me = null;
|
|
1531
1538
|
return;
|
|
1532
1539
|
}
|
|
1533
1540
|
if (n instanceof NotReadyError && n.source === t) {
|
|
1534
|
-
e.
|
|
1541
|
+
e.me = n;
|
|
1535
1542
|
return;
|
|
1536
1543
|
}
|
|
1537
|
-
const r = e.
|
|
1544
|
+
const r = e.me;
|
|
1538
1545
|
if (!(r instanceof NotReadyError) || r.source !== t) {
|
|
1539
|
-
e.
|
|
1546
|
+
e.me = new NotReadyError(t);
|
|
1540
1547
|
}
|
|
1541
1548
|
}
|
|
1542
1549
|
|
|
1543
1550
|
function forEachDependent(e, t) {
|
|
1544
|
-
for (let n = e.k; n !== null; n = n.
|
|
1551
|
+
for (let n = e.k; n !== null; n = n.Ge) t(n.Ue, n);
|
|
1545
1552
|
// `?? null`: affects() marks route plain signals (no `_child` slot) through here.
|
|
1546
|
-
for (let n = e.
|
|
1547
|
-
for (let e = n.k; e !== null; e = e.
|
|
1553
|
+
for (let n = e.rt ?? null; n !== null; n = n.it) {
|
|
1554
|
+
for (let e = n.k; e !== null; e = e.Ge) t(e.Ue, e);
|
|
1548
1555
|
}
|
|
1549
1556
|
}
|
|
1550
1557
|
|
|
1551
1558
|
// Queue a node to re-run on the next flush (used both when a pending source
|
|
1552
1559
|
// settles and when an `isPending` observer must re-evaluate after a real error):
|
|
1553
1560
|
// shared scheduling helper in heap.ts (tracked effects bypass the heap).
|
|
1554
|
-
function settlePendingSource(e
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
//
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
if (
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
const n = e.Be?.values().next().value;
|
|
1568
|
-
if (n) {
|
|
1569
|
-
setPendingError(e, n);
|
|
1570
|
-
o !== null && o(e);
|
|
1561
|
+
function settlePendingSource(e) {
|
|
1562
|
+
let t = false;
|
|
1563
|
+
const n = new Set;
|
|
1564
|
+
// Companion updates no-op without the verdict layer (null hook).
|
|
1565
|
+
const r = GlobalQueue.ce;
|
|
1566
|
+
const settle = i => {
|
|
1567
|
+
if (n.has(i) || !removePendingSource(i, e)) return;
|
|
1568
|
+
n.add(i);
|
|
1569
|
+
i.M = clock;
|
|
1570
|
+
const o = i.$e?.values().next().value;
|
|
1571
|
+
if (o) {
|
|
1572
|
+
setPendingError(i, o);
|
|
1573
|
+
r !== null && r(i);
|
|
1571
1574
|
} else {
|
|
1572
|
-
|
|
1573
|
-
setPendingError(
|
|
1574
|
-
|
|
1575
|
-
if (
|
|
1576
|
-
enqueueSub(
|
|
1577
|
-
|
|
1575
|
+
i.We &= ~STATUS_PENDING;
|
|
1576
|
+
setPendingError(i);
|
|
1577
|
+
r !== null && r(i);
|
|
1578
|
+
if (i.At) {
|
|
1579
|
+
enqueueSub(i);
|
|
1580
|
+
t = true;
|
|
1578
1581
|
}
|
|
1579
|
-
|
|
1582
|
+
i.At = false;
|
|
1580
1583
|
}
|
|
1581
|
-
forEachDependent(
|
|
1584
|
+
forEachDependent(i, settle);
|
|
1582
1585
|
};
|
|
1583
1586
|
forEachDependent(e, settle);
|
|
1584
|
-
if (
|
|
1587
|
+
if (t) schedule();
|
|
1585
1588
|
}
|
|
1586
1589
|
|
|
1587
1590
|
// Object-thenable detection (Promises/A+ shape).
|
|
@@ -1599,26 +1602,26 @@ function handleAsync(e, t, n) {
|
|
|
1599
1602
|
});
|
|
1600
1603
|
}
|
|
1601
1604
|
if (!i && !r) {
|
|
1602
|
-
e.
|
|
1605
|
+
e.lt = null;
|
|
1603
1606
|
return t;
|
|
1604
1607
|
}
|
|
1605
|
-
e.
|
|
1608
|
+
e.lt = t;
|
|
1606
1609
|
let o;
|
|
1607
1610
|
const handleError = n => {
|
|
1608
|
-
if (e.
|
|
1611
|
+
if (e.lt !== t) return;
|
|
1609
1612
|
globalQueue.initTransition(resolveTransition(e));
|
|
1610
1613
|
// NotReadyError from rejected promises should be treated as pending, not error
|
|
1611
1614
|
notifyStatus(e, n instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR, n);
|
|
1612
1615
|
e.M = clock;
|
|
1613
1616
|
};
|
|
1614
1617
|
const asyncWrite = (r, i) => {
|
|
1615
|
-
if (e.
|
|
1618
|
+
if (e.lt !== t) return;
|
|
1616
1619
|
// If the node was dirtied by a newer write (optimistic override or regular),
|
|
1617
1620
|
// skip this stale async result — the upcoming flush will recompute the node
|
|
1618
1621
|
// with the new value, creating a fresh Promise that supersedes this one.
|
|
1619
|
-
if (e.
|
|
1622
|
+
if (e.Le & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY)) return;
|
|
1620
1623
|
globalQueue.initTransition(resolveTransition(e));
|
|
1621
|
-
const o = !!(e
|
|
1624
|
+
const o = !!(e.We & STATUS_UNINITIALIZED);
|
|
1622
1625
|
trimStaleDeps(e);
|
|
1623
1626
|
clearStatus(e);
|
|
1624
1627
|
const s = resolveLane(e);
|
|
@@ -1645,22 +1648,22 @@ function handleAsync(e, t, n) {
|
|
|
1645
1648
|
// only notified when the hold is visible to them: under an active
|
|
1646
1649
|
// override every reader sees the override (A17), so waking subs would
|
|
1647
1650
|
// re-show an unchanged view — the revert is the notification point.
|
|
1648
|
-
GlobalQueue.
|
|
1651
|
+
GlobalQueue.le !== null && GlobalQueue.le(e, r);
|
|
1649
1652
|
if (!hasActiveOverride(e)) insertSubs(e);
|
|
1650
1653
|
e.M = clock;
|
|
1651
1654
|
} else if (s) {
|
|
1652
1655
|
// Route through lane's effect queue for independent flushing
|
|
1653
|
-
const t = e.
|
|
1654
|
-
const n = e.
|
|
1655
|
-
const i = e.
|
|
1656
|
+
const t = e.Qe;
|
|
1657
|
+
const n = e.xe;
|
|
1658
|
+
const i = e.ht;
|
|
1656
1659
|
try {
|
|
1657
1660
|
if (!t && o || !i || !i(r, n)) {
|
|
1658
|
-
e.
|
|
1661
|
+
e.xe = r;
|
|
1659
1662
|
e.M = clock;
|
|
1660
1663
|
// The latest() shadow write gives latest() effects independent lanes; the
|
|
1661
1664
|
// _pendingSignal update is a no-op repeat of the clearStatus() call above
|
|
1662
1665
|
// (computePendingState doesn't read _value).
|
|
1663
|
-
GlobalQueue.
|
|
1666
|
+
GlobalQueue.le !== null && GlobalQueue.le(e, r);
|
|
1664
1667
|
insertSubs(e, true);
|
|
1665
1668
|
}
|
|
1666
1669
|
} catch (t) {
|
|
@@ -1729,7 +1732,7 @@ function handleAsync(e, t, n) {
|
|
|
1729
1732
|
u = n;
|
|
1730
1733
|
c = true;
|
|
1731
1734
|
if (n.done) i = true;
|
|
1732
|
-
} else if (e.
|
|
1735
|
+
} else if (e.lt !== t) {
|
|
1733
1736
|
return;
|
|
1734
1737
|
} else if (!n.done) {
|
|
1735
1738
|
r = true;
|
|
@@ -1748,7 +1751,7 @@ function handleAsync(e, t, n) {
|
|
|
1748
1751
|
if (f) {
|
|
1749
1752
|
l = n;
|
|
1750
1753
|
a = true;
|
|
1751
|
-
} else if (e.
|
|
1754
|
+
} else if (e.lt === t) {
|
|
1752
1755
|
i = true;
|
|
1753
1756
|
handleError(n);
|
|
1754
1757
|
}
|
|
@@ -1780,86 +1783,74 @@ function handleAsync(e, t, n) {
|
|
|
1780
1783
|
}
|
|
1781
1784
|
|
|
1782
1785
|
function clearStatus(e, t = false) {
|
|
1783
|
-
if (e
|
|
1784
|
-
if (e.
|
|
1786
|
+
if (e.$e) clearPendingSources(e);
|
|
1787
|
+
if (e.At) e.At = false;
|
|
1785
1788
|
// The pending window is over; its quiet classification dies with it.
|
|
1786
1789
|
// (Unconditional: _reask is baked into the node literals, so this is a
|
|
1787
1790
|
// plain store to an existing slot — no shape change.)
|
|
1788
|
-
e.
|
|
1789
|
-
e
|
|
1790
|
-
if (e.
|
|
1791
|
+
e.Nt = false;
|
|
1792
|
+
e.We = t ? 0 : e.We & STATUS_UNINITIALIZED;
|
|
1793
|
+
if (e.me) setPendingError(e);
|
|
1791
1794
|
// Update pending signal for isPending() reactivity (companions only exist
|
|
1792
1795
|
// once the verdict layer created them, which installs the hooks).
|
|
1793
|
-
if (e._ || e.O) GlobalQueue.
|
|
1794
|
-
if (e.
|
|
1795
|
-
if (e.
|
|
1796
|
+
if (e._ || e.O) GlobalQueue.ce(e);
|
|
1797
|
+
if (e.rt && GlobalQueue.ae !== null) GlobalQueue.ae(e);
|
|
1798
|
+
if (e.yt) e.yt();
|
|
1796
1799
|
}
|
|
1797
1800
|
|
|
1798
1801
|
function notifyStatus(e, t, n, r, i) {
|
|
1799
1802
|
// Wrap regular errors to track source node
|
|
1800
1803
|
if (t === STATUS_ERROR && !(n instanceof StatusError) && !(n instanceof NotReadyError)) n = new StatusError(e, n);
|
|
1801
1804
|
const o = t === STATUS_PENDING && n instanceof NotReadyError ? n.source : undefined;
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
// freeze unrelated writes that share a downstream memo until the action
|
|
1806
|
-
// settles. Real async keeps queuing (its commits ride the transition).
|
|
1807
|
-
const s = o?.Dt !== undefined;
|
|
1808
|
-
// A real error is a settled verdict a mark must not erase (#2893): landing
|
|
1809
|
-
// STATUS_PENDING here would clobber `_error` with the sentinel's
|
|
1810
|
-
// NotReadyError, and unlike real async there is no arriving value whose
|
|
1811
|
-
// recompute would surface the error again. Descent stops too — everything
|
|
1812
|
-
// downstream holds the propagated error for the same reason.
|
|
1813
|
-
if (s && e.$e & STATUS_ERROR) return;
|
|
1814
|
-
const u = o === e;
|
|
1815
|
-
const l = t === STATUS_PENDING && e.A !== undefined && !u;
|
|
1816
|
-
const c = l && hasActiveOverride(e);
|
|
1805
|
+
const s = o === e;
|
|
1806
|
+
const u = t === STATUS_PENDING && e.A !== undefined && !s;
|
|
1807
|
+
const l = u && hasActiveOverride(e);
|
|
1817
1808
|
if (!r) {
|
|
1818
1809
|
if (t === STATUS_PENDING && o) {
|
|
1819
1810
|
addPendingSource(e, o);
|
|
1820
|
-
e
|
|
1811
|
+
e.We = STATUS_PENDING | e.We & STATUS_UNINITIALIZED;
|
|
1821
1812
|
// Preserve the current source on this propagation so render-effect notification
|
|
1822
1813
|
// can register every distinct pending source with the transition.
|
|
1823
1814
|
setPendingError(e, o, n);
|
|
1824
1815
|
} else {
|
|
1825
1816
|
clearPendingSources(e);
|
|
1826
|
-
e
|
|
1827
|
-
e.
|
|
1817
|
+
e.We = t | (t !== STATUS_ERROR ? e.We & STATUS_UNINITIALIZED : 0);
|
|
1818
|
+
e.me = n;
|
|
1828
1819
|
}
|
|
1829
|
-
GlobalQueue.
|
|
1830
|
-
if (e.
|
|
1820
|
+
GlobalQueue.ce !== null && GlobalQueue.ce(e);
|
|
1821
|
+
if (e.rt && GlobalQueue.ae !== null) GlobalQueue.ae(e);
|
|
1831
1822
|
}
|
|
1832
1823
|
if (i && !r) {
|
|
1833
1824
|
assignOrMergeLane(e, i);
|
|
1834
1825
|
}
|
|
1835
|
-
const
|
|
1836
|
-
const
|
|
1837
|
-
if (e.
|
|
1826
|
+
const c = r || l;
|
|
1827
|
+
const a = r || u ? undefined : i;
|
|
1828
|
+
if (e.yt) {
|
|
1838
1829
|
if (r && t === STATUS_PENDING) {
|
|
1839
1830
|
return;
|
|
1840
1831
|
}
|
|
1841
|
-
if (
|
|
1842
|
-
e.
|
|
1832
|
+
if (c) {
|
|
1833
|
+
e.yt(t, n);
|
|
1843
1834
|
} else {
|
|
1844
|
-
e.
|
|
1835
|
+
e.yt();
|
|
1845
1836
|
}
|
|
1846
1837
|
return;
|
|
1847
1838
|
}
|
|
1848
1839
|
forEachDependent(e, (e, r) => {
|
|
1849
1840
|
e.M = clock;
|
|
1850
|
-
if (t === STATUS_PENDING && o && !e
|
|
1841
|
+
if (t === STATUS_PENDING && o && !e.$e?.has(o) || t !== STATUS_PENDING && (e.me !== n || e.$e)) {
|
|
1851
1842
|
// A pending-observer link is the subscription an `isPending` read created.
|
|
1852
1843
|
// It exists so the observer re-runs when the source settles, but it must
|
|
1853
1844
|
// not carry a real (non-NotReadyError) error — the synchronous `isPending`
|
|
1854
1845
|
// read swallows those, and the async path must match. Re-run the observer
|
|
1855
1846
|
// so `isPending` re-evaluates (to not-pending) instead of forwarding.
|
|
1856
|
-
if (r.
|
|
1847
|
+
if (r.Ot && t !== STATUS_PENDING && !(n instanceof NotReadyError)) {
|
|
1857
1848
|
enqueueSub(e);
|
|
1858
1849
|
schedule();
|
|
1859
1850
|
return;
|
|
1860
1851
|
}
|
|
1861
|
-
if (!
|
|
1862
|
-
notifyStatus(e, t, n,
|
|
1852
|
+
if (!c && !e.T) queuePendingNode(e);
|
|
1853
|
+
notifyStatus(e, t, n, c, a);
|
|
1863
1854
|
}
|
|
1864
1855
|
});
|
|
1865
1856
|
}
|
|
@@ -1892,24 +1883,13 @@ let context = null;
|
|
|
1892
1883
|
|
|
1893
1884
|
let currentOptimisticLane = null;
|
|
1894
1885
|
|
|
1895
|
-
/**
|
|
1896
|
-
* Marked sources read by the recompute currently on the stack (saved/restored
|
|
1897
|
-
* per recompute, like `context`). A computed that reads a node with a live
|
|
1898
|
-
* `affects()` mark inherits the mark's pendingness — `recompute` applies the
|
|
1899
|
-
* collected sources through `applyAffectsReads` after its commit, because the
|
|
1900
|
-
* `clearStatus` at the top of the commit path wipes whatever sentinel entries
|
|
1901
|
-
* the node held from the registration-time push. This is the pull half of
|
|
1902
|
-
* mark propagation (real async re-establishes itself by re-throwing on read;
|
|
1903
|
-
* marks are value-transparent, so they re-establish here instead).
|
|
1904
|
-
*/ let affectsReads = null;
|
|
1905
|
-
|
|
1906
1886
|
let snapshotCaptureActive = false;
|
|
1907
1887
|
|
|
1908
1888
|
let snapshotSources = null;
|
|
1909
1889
|
|
|
1910
1890
|
function ownerInSnapshotScope(e) {
|
|
1911
1891
|
while (e) {
|
|
1912
|
-
if (e.
|
|
1892
|
+
if (e.Ct) return true;
|
|
1913
1893
|
e = e.Z;
|
|
1914
1894
|
}
|
|
1915
1895
|
return false;
|
|
@@ -1921,41 +1901,41 @@ function setSnapshotCapture(e) {
|
|
|
1921
1901
|
}
|
|
1922
1902
|
|
|
1923
1903
|
function markSnapshotScope(e) {
|
|
1924
|
-
e.
|
|
1904
|
+
e.Ct = true;
|
|
1925
1905
|
}
|
|
1926
1906
|
|
|
1927
1907
|
function releaseSnapshotScope(e) {
|
|
1928
|
-
e.
|
|
1908
|
+
e.Ct = false;
|
|
1929
1909
|
releaseSubtree(e);
|
|
1930
1910
|
schedule();
|
|
1931
1911
|
}
|
|
1932
1912
|
|
|
1933
1913
|
function releaseSubtree(e) {
|
|
1934
|
-
let t = e.
|
|
1914
|
+
let t = e.ot;
|
|
1935
1915
|
while (t) {
|
|
1936
|
-
if (t.
|
|
1937
|
-
t = t.
|
|
1916
|
+
if (t.Ct) {
|
|
1917
|
+
t = t.st;
|
|
1938
1918
|
continue;
|
|
1939
1919
|
}
|
|
1940
|
-
if (t.
|
|
1920
|
+
if (t.Ve) {
|
|
1941
1921
|
const e = t;
|
|
1942
|
-
e.
|
|
1943
|
-
if (e.
|
|
1944
|
-
e.
|
|
1945
|
-
e.
|
|
1946
|
-
if (dirtyQueue.
|
|
1922
|
+
e.ke &= ~CONFIG_IN_SNAPSHOT_SCOPE;
|
|
1923
|
+
if (e.Le & REACTIVE_SNAPSHOT_STALE) {
|
|
1924
|
+
e.Le &= ~REACTIVE_SNAPSHOT_STALE;
|
|
1925
|
+
e.Le |= REACTIVE_DIRTY;
|
|
1926
|
+
if (dirtyQueue.C > e.ze) dirtyQueue.C = e.ze;
|
|
1947
1927
|
insertIntoHeap(e, dirtyQueue);
|
|
1948
1928
|
}
|
|
1949
1929
|
}
|
|
1950
1930
|
releaseSubtree(t);
|
|
1951
|
-
t = t.
|
|
1931
|
+
t = t.st;
|
|
1952
1932
|
}
|
|
1953
1933
|
}
|
|
1954
1934
|
|
|
1955
1935
|
function clearSnapshots() {
|
|
1956
1936
|
if (snapshotSources) {
|
|
1957
1937
|
for (const e of snapshotSources) {
|
|
1958
|
-
delete e.
|
|
1938
|
+
delete e.we;
|
|
1959
1939
|
delete e[STORE_SNAPSHOT_PROPS];
|
|
1960
1940
|
}
|
|
1961
1941
|
snapshotSources = null;
|
|
@@ -1964,105 +1944,109 @@ function clearSnapshots() {
|
|
|
1964
1944
|
}
|
|
1965
1945
|
|
|
1966
1946
|
function recompute(e, t = false) {
|
|
1967
|
-
const n = e.
|
|
1947
|
+
const n = e.Qe;
|
|
1968
1948
|
if (!t) {
|
|
1969
1949
|
if (e.T && (!n || activeTransition) && activeTransition !== e.T) globalQueue.initTransition(e.T);
|
|
1970
1950
|
deleteFromHeap(e, queueFor(e));
|
|
1971
|
-
e.
|
|
1951
|
+
e.lt = null;
|
|
1972
1952
|
// Tracked effects run after finalizePureQueue, so dispose immediately instead of deferring
|
|
1973
|
-
if (e.T || n === EFFECT_TRACKED) disposeChildren(e); else if (e.
|
|
1953
|
+
if (e.T || n === EFFECT_TRACKED) disposeChildren(e); else if (e.ot !== null || e.St !== null) {
|
|
1974
1954
|
markDisposal(e);
|
|
1975
|
-
e.
|
|
1976
|
-
e.
|
|
1977
|
-
e.
|
|
1978
|
-
e.
|
|
1979
|
-
e.
|
|
1955
|
+
e.He = e.St;
|
|
1956
|
+
e.Me = e.ot;
|
|
1957
|
+
e.St = null;
|
|
1958
|
+
e.ot = null;
|
|
1959
|
+
e.ct = 0;
|
|
1980
1960
|
} else ;
|
|
1981
1961
|
}
|
|
1982
|
-
let r = !!(e.
|
|
1962
|
+
let r = !!(e.Le & REACTIVE_OPTIMISTIC_DIRTY);
|
|
1983
1963
|
const i = e.A !== undefined && e.A !== NOT_PENDING;
|
|
1984
|
-
const o = !!(e
|
|
1964
|
+
const o = !!(e.We & STATUS_UNINITIALIZED);
|
|
1985
1965
|
// Re-ask classification lives in the verdict module; capture the flag before
|
|
1986
1966
|
// the recompute wipes _flags below.
|
|
1987
|
-
const s = (e.
|
|
1967
|
+
const s = (e.Le & REACTIVE_REASK) !== 0;
|
|
1988
1968
|
const u = context;
|
|
1989
1969
|
context = e;
|
|
1990
|
-
e.
|
|
1991
|
-
e.
|
|
1992
|
-
e.
|
|
1970
|
+
e.ut = null;
|
|
1971
|
+
e.It++;
|
|
1972
|
+
e.Le = REACTIVE_RECOMPUTING_DEPS;
|
|
1993
1973
|
e.M = clock;
|
|
1994
|
-
let l = e.V === NOT_PENDING ? e.
|
|
1995
|
-
let c = e.
|
|
1974
|
+
let l = e.V === NOT_PENDING ? e.xe : e.V;
|
|
1975
|
+
let c = e.ze;
|
|
1996
1976
|
let a = tracking;
|
|
1997
|
-
|
|
1998
|
-
affectsReads = null;
|
|
1999
|
-
let E = null;
|
|
2000
|
-
let d = currentOptimisticLane;
|
|
1977
|
+
let f = currentOptimisticLane;
|
|
2001
1978
|
tracking = true;
|
|
1979
|
+
// A computed's fn establishes its OWN dependencies, so it must never run
|
|
1980
|
+
// inside a latest() read window: read() short-circuits through the
|
|
1981
|
+
// companion path before dependency linking, so a memo created (eagerly
|
|
1982
|
+
// computed) inside latest(fn) came out permanently dependency-less (#2926).
|
|
1983
|
+
// latestRead() already suspends the flag for its pull-recomputes; this
|
|
1984
|
+
// covers creation-time computes and flushes that run inside the window.
|
|
1985
|
+
const E = latestReadActive;
|
|
1986
|
+
latestReadActive = false;
|
|
2002
1987
|
// Lane posture lives with the engine: OPTIMISTIC_DIRTY is only ever set by
|
|
2003
1988
|
// engine-driven paths, and _optimisticNodes is only pushed by
|
|
2004
1989
|
// _optimisticWrite, so the hook is installed whenever either gate holds.
|
|
2005
1990
|
if (r) {
|
|
2006
|
-
const t = GlobalQueue.
|
|
1991
|
+
const t = GlobalQueue.Pe(e, true);
|
|
2007
1992
|
if (t) currentOptimisticLane = t;
|
|
2008
1993
|
} else if (activeTransition && !t && activeTransition.G.length) {
|
|
2009
1994
|
// Lane adoption: parent-deeper-than-owned-child can run before its OPT-dirty
|
|
2010
1995
|
// child propagates. Walk deps once and inherit the OPT lane so this node
|
|
2011
1996
|
// recomputes under the right posture and propagates correctly.
|
|
2012
|
-
const t = GlobalQueue.
|
|
1997
|
+
const t = GlobalQueue.Pe(e, false);
|
|
2013
1998
|
if (t) {
|
|
2014
1999
|
r = true;
|
|
2015
2000
|
currentOptimisticLane = t;
|
|
2016
2001
|
}
|
|
2017
2002
|
}
|
|
2018
2003
|
const S = n && n !== EFFECT_USER;
|
|
2019
|
-
const
|
|
2004
|
+
const d = stale;
|
|
2020
2005
|
if (S) stale = true;
|
|
2021
2006
|
try {
|
|
2022
|
-
if (!false && e.
|
|
2023
|
-
l = e.
|
|
2024
|
-
e.
|
|
2007
|
+
if (!false && e.ke & CONFIG_SYNC) {
|
|
2008
|
+
l = e.Ve(l);
|
|
2009
|
+
e.lt = null;
|
|
2025
2010
|
} else {
|
|
2026
2011
|
// Snapshot `_inFlight` so we can detect whether `_fn` self-registered an async
|
|
2027
2012
|
// subscription (e.g. `createProjection` calls `handleAsync` from inside its body
|
|
2028
2013
|
// with a setter callback). In that case, the outer `handleAsync` call below would
|
|
2029
2014
|
// clobber the fresh subscription, so we skip it and let the internally-registered
|
|
2030
2015
|
// iteration drive updates.
|
|
2031
|
-
const t = e.
|
|
2032
|
-
const n = e.
|
|
2016
|
+
const t = e.lt;
|
|
2017
|
+
const n = e.Ve(l);
|
|
2033
2018
|
const r = typeof n === "object" && n !== null;
|
|
2034
|
-
const i = e.
|
|
2019
|
+
const i = e.lt !== t;
|
|
2035
2020
|
l = i || !r ? n : handleAsync(e, n);
|
|
2036
|
-
if (!i && !r) e.
|
|
2021
|
+
if (!i && !r) e.lt = null;
|
|
2037
2022
|
}
|
|
2038
2023
|
clearStatus(e, t);
|
|
2039
2024
|
// _optimisticLane is only ever assigned by engine paths.
|
|
2040
|
-
if (e.i) GlobalQueue.
|
|
2025
|
+
if (e.i) GlobalQueue.be(e);
|
|
2041
2026
|
} catch (t) {
|
|
2042
2027
|
// Track pending async in the lane (not the lane's source — it creates the lane
|
|
2043
2028
|
// but doesn't belong to it). Set lane BEFORE notifyStatus for downstream propagation.
|
|
2044
|
-
if (t instanceof NotReadyError && currentOptimisticLane) GlobalQueue.
|
|
2029
|
+
if (t instanceof NotReadyError && currentOptimisticLane) GlobalQueue.ge(e);
|
|
2045
2030
|
let n = false;
|
|
2046
2031
|
if (t instanceof NotReadyError) {
|
|
2047
|
-
e.
|
|
2048
|
-
if (GlobalQueue.
|
|
2032
|
+
e.At = true;
|
|
2033
|
+
if (GlobalQueue.Te !== null) n = GlobalQueue.Te(e, s);
|
|
2049
2034
|
}
|
|
2050
2035
|
notifyStatus(e, t instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR, t, undefined, t instanceof NotReadyError ? e.i : undefined);
|
|
2051
|
-
if (n) GlobalQueue.
|
|
2036
|
+
if (n) GlobalQueue.pe(e);
|
|
2052
2037
|
} finally {
|
|
2053
2038
|
tracking = a;
|
|
2054
|
-
|
|
2055
|
-
|
|
2039
|
+
latestReadActive = E;
|
|
2040
|
+
if (S) stale = d;
|
|
2041
|
+
e.Le = REACTIVE_NONE | (t ? e.Le & REACTIVE_SNAPSHOT_STALE : 0);
|
|
2056
2042
|
context = u;
|
|
2057
|
-
E = affectsReads;
|
|
2058
|
-
affectsReads = f;
|
|
2059
2043
|
}
|
|
2060
|
-
if (!e.
|
|
2044
|
+
if (!e.me) {
|
|
2061
2045
|
trimStaleDeps(e);
|
|
2062
|
-
const s = i ? unwrapOverride(e.A) : e.V === NOT_PENDING ? e.
|
|
2046
|
+
const s = i ? unwrapOverride(e.A) : e.V === NOT_PENDING ? e.xe : e.V;
|
|
2063
2047
|
let u = false;
|
|
2064
2048
|
try {
|
|
2065
|
-
u = !n && o || !e.
|
|
2049
|
+
u = !n && o || !e.ht || !e.ht(s, l);
|
|
2066
2050
|
} catch (t) {
|
|
2067
2051
|
// A throwing user comparator is an error of this node's computation.
|
|
2068
2052
|
// Route it through the same status path as a compute-phase throw so
|
|
@@ -2076,15 +2060,15 @@ function recompute(e, t = false) {
|
|
|
2076
2060
|
// gate: the explicit recompute(node, true) inside effect() does not enqueue, so
|
|
2077
2061
|
// effect() can call its runner synchronously for the first run.
|
|
2078
2062
|
if (n && u) {
|
|
2079
|
-
e.
|
|
2063
|
+
e.Fe = !e.me;
|
|
2080
2064
|
// Reuse one bound runner per effect — runEffect no-ops on a stale
|
|
2081
2065
|
// `_modified`, so re-enqueueing the same function is harmless.
|
|
2082
|
-
if (!t) e.
|
|
2066
|
+
if (!t) e.Ze.enqueue(n, e.Pt ??= GlobalQueue.ee.bind(null, e));
|
|
2083
2067
|
}
|
|
2084
|
-
if (e.
|
|
2068
|
+
if (e.me) ; else if (u) {
|
|
2085
2069
|
const o = i ? e.A : undefined;
|
|
2086
2070
|
if (t || n && activeTransition !== e.T || r) {
|
|
2087
|
-
e.
|
|
2071
|
+
e.xe = l;
|
|
2088
2072
|
// Lane-propagated correction: upstream data is fresh, correct the
|
|
2089
2073
|
// override unconditionally. The direct _value commit is the lane's
|
|
2090
2074
|
// own reveal schedule; drop any superseded older hold so its queued
|
|
@@ -2100,7 +2084,7 @@ function recompute(e, t = false) {
|
|
|
2100
2084
|
// (#2831). Both companion writes are transition-scoped (optimistic) and
|
|
2101
2085
|
// auto-revert/re-derive at commit. Skipped for plain flushes where the
|
|
2102
2086
|
// pending value commits before effects run.
|
|
2103
|
-
if ((activeTransition || e.T) && GlobalQueue.
|
|
2087
|
+
if ((activeTransition || e.T) && GlobalQueue.le !== null) GlobalQueue.le(e, l);
|
|
2104
2088
|
}
|
|
2105
2089
|
if (!i || r || e.A !== o) insertSubs(e, r || i);
|
|
2106
2090
|
} else if (i) {
|
|
@@ -2109,90 +2093,77 @@ function recompute(e, t = false) {
|
|
|
2109
2093
|
// for commit on its own transition's schedule — invisibly (A17/A18).
|
|
2110
2094
|
if (e.V === NOT_PENDING) queuePendingNode(e);
|
|
2111
2095
|
e.V = l;
|
|
2112
|
-
} else if (e.
|
|
2113
|
-
for (let t = e.k; t !== null; t = t.
|
|
2114
|
-
insertIntoHeapHeight(t.
|
|
2096
|
+
} else if (e.ze != c) {
|
|
2097
|
+
for (let t = e.k; t !== null; t = t.Ge) {
|
|
2098
|
+
insertIntoHeapHeight(t.Ue, queueFor(t.Ue));
|
|
2115
2099
|
}
|
|
2116
2100
|
}
|
|
2117
2101
|
}
|
|
2118
|
-
currentOptimisticLane =
|
|
2119
|
-
|
|
2120
|
-
// earlier, the sentinel's NotReadyError in `_error` would have routed the
|
|
2121
|
-
// fresh value into the error-skip branch instead of committing it. A real
|
|
2122
|
-
// (non-NotReady) error wins over marks (#2893): applying the sentinel here
|
|
2123
|
-
// would clobber the user's error with a NotReadyError from a node whose
|
|
2124
|
-
// reads value-transparency promises can never throw NotReady.
|
|
2125
|
-
// `markedReads` only collects under a live mark, so the hook is installed.
|
|
2126
|
-
if (E && !(e.$e & STATUS_ERROR)) GlobalQueue.re(e, E);
|
|
2127
|
-
// Mark-only pending doesn't queue (#2893): the node holds no value needing
|
|
2128
|
-
// a transition-scheduled commit, and queueing would stamp the marking
|
|
2129
|
-
// action's transaction onto it — freezing unrelated writes that share it.
|
|
2130
|
-
// (Single mask test up front keeps the mark-free hot path at original cost.)
|
|
2131
|
-
const p = e.$e & (STATUS_PENDING | STATUS_UNINITIALIZED);
|
|
2132
|
-
const _ = e.V !== NOT_PENDING || e.Ke !== null || e.Ye !== null || p !== 0 && (p !== STATUS_PENDING || activeAffectsMarks === 0 || !GlobalQueue.ue(e));
|
|
2102
|
+
currentOptimisticLane = f;
|
|
2103
|
+
const T = e.V !== NOT_PENDING || e.Me !== null || e.He !== null || (e.We & (STATUS_PENDING | STATUS_UNINITIALIZED)) !== 0;
|
|
2133
2104
|
// Override-covered holds (hasOverride) always queue: their commit belongs
|
|
2134
2105
|
// to their own transition's schedule (A18 re-rule) and is unobservable
|
|
2135
2106
|
// under the override (A17). Revert no longer commits anything, so an
|
|
2136
2107
|
// unqueued covered hold would leak (INV-7) once the revert clears
|
|
2137
2108
|
// _transition.
|
|
2138
|
-
|
|
2109
|
+
T && (!t || e.We & STATUS_PENDING) && (!e.T || i) && queuePendingNode(e);
|
|
2139
2110
|
e.T && n && activeTransition !== e.T && runInTransition(e.T, () => recompute(e));
|
|
2140
2111
|
}
|
|
2141
2112
|
|
|
2142
2113
|
function updateIfNecessary(e) {
|
|
2143
|
-
if (e.
|
|
2144
|
-
for (let t = e.
|
|
2145
|
-
const n = t.
|
|
2146
|
-
const r = n.
|
|
2147
|
-
if (r.
|
|
2114
|
+
if (e.Le & REACTIVE_CHECK) {
|
|
2115
|
+
for (let t = e.Ke; t; t = t.Ye) {
|
|
2116
|
+
const n = t.qe;
|
|
2117
|
+
const r = n.Be || n;
|
|
2118
|
+
if (r.Ve) {
|
|
2148
2119
|
updateIfNecessary(r);
|
|
2149
2120
|
}
|
|
2150
|
-
if (e.
|
|
2121
|
+
if (e.Le & REACTIVE_DIRTY) {
|
|
2151
2122
|
break;
|
|
2152
2123
|
}
|
|
2153
2124
|
}
|
|
2154
2125
|
}
|
|
2155
|
-
if (e.
|
|
2126
|
+
if (e.Le & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || e.me && e.M < clock && !e.lt) {
|
|
2156
2127
|
recompute(e);
|
|
2157
2128
|
}
|
|
2158
|
-
e.
|
|
2129
|
+
e.Le = e.Le & (REACTIVE_SNAPSHOT_STALE | REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT);
|
|
2159
2130
|
}
|
|
2160
2131
|
|
|
2161
2132
|
function computed(e, t) {
|
|
2162
2133
|
const n = t?.transparent ?? false;
|
|
2163
2134
|
const r = {
|
|
2164
2135
|
id: inheritId(t, n, context),
|
|
2165
|
-
|
|
2166
|
-
|
|
2136
|
+
ke: (n ? CONFIG_TRANSPARENT : 0) | (t?.ownedWrite ? CONFIG_OWNED_WRITE : 0) | (!context || t?.lazy ? CONFIG_AUTO_DISPOSE : 0) | (t?.sync ? CONFIG_SYNC : 0) | (t?.gt ? CONFIG_NO_SNAPSHOT : 0) | (snapshotCaptureActive && ownerInSnapshotScope(context) ? CONFIG_IN_SNAPSHOT_SCOPE : 0),
|
|
2137
|
+
ht: t?.equals != null ? t.equals : isEqual,
|
|
2167
2138
|
W: t?.unobserved,
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2139
|
+
St: null,
|
|
2140
|
+
Ze: context?.Ze ?? globalQueue,
|
|
2141
|
+
dt: context?.dt ?? defaultContext,
|
|
2142
|
+
ct: 0,
|
|
2143
|
+
Ve: e,
|
|
2144
|
+
xe: undefined,
|
|
2145
|
+
ze: 0,
|
|
2146
|
+
rt: null,
|
|
2147
|
+
nt: undefined,
|
|
2148
|
+
tt: null,
|
|
2149
|
+
Ke: null,
|
|
2175
2150
|
ut: null,
|
|
2176
|
-
|
|
2177
|
-
ot: null,
|
|
2178
|
-
Ze: null,
|
|
2179
|
-
Et: null,
|
|
2180
|
-
yt: 0,
|
|
2151
|
+
It: 0,
|
|
2181
2152
|
k: null,
|
|
2182
|
-
|
|
2153
|
+
_t: null,
|
|
2183
2154
|
Z: context,
|
|
2155
|
+
st: null,
|
|
2184
2156
|
ft: null,
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
$e: STATUS_UNINITIALIZED,
|
|
2157
|
+
ot: null,
|
|
2158
|
+
Le: t?.lazy ? REACTIVE_LAZY : REACTIVE_NONE,
|
|
2159
|
+
We: STATUS_UNINITIALIZED,
|
|
2189
2160
|
M: clock,
|
|
2190
2161
|
V: NOT_PENDING,
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2162
|
+
He: null,
|
|
2163
|
+
Me: null,
|
|
2164
|
+
lt: null,
|
|
2194
2165
|
T: null,
|
|
2195
|
-
|
|
2166
|
+
Nt: false
|
|
2196
2167
|
};
|
|
2197
2168
|
setupComputedNode(r, t);
|
|
2198
2169
|
return r;
|
|
@@ -2207,44 +2178,44 @@ function computed(e, t) {
|
|
|
2207
2178
|
const s = o?.transparent ?? false;
|
|
2208
2179
|
const u = {
|
|
2209
2180
|
id: inheritId(o, s, context),
|
|
2210
|
-
|
|
2211
|
-
|
|
2181
|
+
ke: (s ? CONFIG_TRANSPARENT : 0) | (o?.ownedWrite ? CONFIG_OWNED_WRITE : 0) | (o?.sync ? CONFIG_SYNC : 0) | (snapshotCaptureActive && ownerInSnapshotScope(context) ? CONFIG_IN_SNAPSHOT_SCOPE : 0),
|
|
2182
|
+
ht: false,
|
|
2212
2183
|
W: o?.unobserved,
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2184
|
+
St: null,
|
|
2185
|
+
Ze: context?.Ze ?? globalQueue,
|
|
2186
|
+
dt: context?.dt ?? defaultContext,
|
|
2187
|
+
ct: 0,
|
|
2188
|
+
Ve: e,
|
|
2189
|
+
xe: undefined,
|
|
2190
|
+
ze: 0,
|
|
2191
|
+
rt: null,
|
|
2192
|
+
nt: undefined,
|
|
2193
|
+
tt: null,
|
|
2194
|
+
Ke: null,
|
|
2220
2195
|
ut: null,
|
|
2221
|
-
|
|
2222
|
-
ot: null,
|
|
2223
|
-
Ze: null,
|
|
2224
|
-
Et: null,
|
|
2225
|
-
yt: 0,
|
|
2196
|
+
It: 0,
|
|
2226
2197
|
k: null,
|
|
2227
|
-
|
|
2198
|
+
_t: null,
|
|
2228
2199
|
Z: context,
|
|
2200
|
+
st: null,
|
|
2229
2201
|
ft: null,
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
$e: STATUS_UNINITIALIZED,
|
|
2202
|
+
ot: null,
|
|
2203
|
+
Le: REACTIVE_LAZY,
|
|
2204
|
+
We: STATUS_UNINITIALIZED,
|
|
2234
2205
|
M: clock,
|
|
2235
2206
|
V: NOT_PENDING,
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2207
|
+
He: null,
|
|
2208
|
+
Me: null,
|
|
2209
|
+
lt: null,
|
|
2239
2210
|
T: null,
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2211
|
+
Nt: false,
|
|
2212
|
+
Fe: false,
|
|
2213
|
+
bt: undefined,
|
|
2214
|
+
Dt: t,
|
|
2215
|
+
vt: n,
|
|
2216
|
+
Et: undefined,
|
|
2217
|
+
Qe: r,
|
|
2218
|
+
yt: i
|
|
2248
2219
|
};
|
|
2249
2220
|
setupComputedNode(u, lazyOptions);
|
|
2250
2221
|
return u;
|
|
@@ -2255,24 +2226,24 @@ const lazyOptions = {
|
|
|
2255
2226
|
};
|
|
2256
2227
|
|
|
2257
2228
|
function setupComputedNode(e, t) {
|
|
2258
|
-
e.
|
|
2259
|
-
const n = context?.
|
|
2229
|
+
e.tt = e;
|
|
2230
|
+
const n = context?.Je ? context.et : context;
|
|
2260
2231
|
if (context) {
|
|
2261
|
-
const t = context.
|
|
2232
|
+
const t = context.ot;
|
|
2262
2233
|
if (t === null) {
|
|
2263
|
-
context.
|
|
2234
|
+
context.ot = e;
|
|
2264
2235
|
} else {
|
|
2265
|
-
e.
|
|
2266
|
-
t.
|
|
2267
|
-
context.
|
|
2236
|
+
e.st = t;
|
|
2237
|
+
t.ft = e;
|
|
2238
|
+
context.ot = e;
|
|
2268
2239
|
}
|
|
2269
2240
|
}
|
|
2270
|
-
if (n) e.
|
|
2271
|
-
if (GlobalQueue.
|
|
2241
|
+
if (n) e.ze = n.ze + 1;
|
|
2242
|
+
if (GlobalQueue.se !== null) GlobalQueue.se(e);
|
|
2272
2243
|
!t?.lazy && recompute(e, true);
|
|
2273
2244
|
if (snapshotCaptureActive && !t?.lazy) {
|
|
2274
|
-
if (!(e
|
|
2275
|
-
e.
|
|
2245
|
+
if (!(e.We & STATUS_PENDING) && !(e.ke & CONFIG_NO_SNAPSHOT)) {
|
|
2246
|
+
e.we = e.xe === undefined ? NO_SNAPSHOT : e.xe;
|
|
2276
2247
|
snapshotSources.add(e);
|
|
2277
2248
|
}
|
|
2278
2249
|
}
|
|
@@ -2280,20 +2251,20 @@ function setupComputedNode(e, t) {
|
|
|
2280
2251
|
|
|
2281
2252
|
function signal(e, t, n = null) {
|
|
2282
2253
|
const r = {
|
|
2283
|
-
|
|
2284
|
-
|
|
2254
|
+
ht: t?.equals != null ? t.equals : isEqual,
|
|
2255
|
+
ke: (t?.ownedWrite ? CONFIG_OWNED_WRITE : 0) | (t?.gt ? CONFIG_NO_SNAPSHOT : 0),
|
|
2285
2256
|
W: t?.unobserved,
|
|
2286
|
-
|
|
2257
|
+
xe: e,
|
|
2287
2258
|
k: null,
|
|
2288
|
-
|
|
2259
|
+
_t: null,
|
|
2289
2260
|
M: clock,
|
|
2290
|
-
|
|
2291
|
-
|
|
2261
|
+
Be: n,
|
|
2262
|
+
it: n?.rt || null,
|
|
2292
2263
|
V: NOT_PENDING
|
|
2293
2264
|
};
|
|
2294
|
-
n && (n.
|
|
2295
|
-
if (snapshotCaptureActive && !(r.
|
|
2296
|
-
r.
|
|
2265
|
+
n && (n.rt = r);
|
|
2266
|
+
if (snapshotCaptureActive && !(r.ke & CONFIG_NO_SNAPSHOT) && !((n?.We ?? 0) & STATUS_PENDING)) {
|
|
2267
|
+
r.we = e === undefined ? NO_SNAPSHOT : e;
|
|
2297
2268
|
snapshotSources.add(r);
|
|
2298
2269
|
}
|
|
2299
2270
|
return r;
|
|
@@ -2337,11 +2308,11 @@ function isEqual(e, t) {
|
|
|
2337
2308
|
* );
|
|
2338
2309
|
* ```
|
|
2339
2310
|
*/ function untrack(e, t) {
|
|
2340
|
-
if (GlobalQueue.
|
|
2311
|
+
if (GlobalQueue.ue === null && !tracking && true) return e();
|
|
2341
2312
|
const n = tracking;
|
|
2342
2313
|
tracking = false;
|
|
2343
2314
|
try {
|
|
2344
|
-
if (GlobalQueue.
|
|
2315
|
+
if (GlobalQueue.ue !== null) return GlobalQueue.ue(e);
|
|
2345
2316
|
return e();
|
|
2346
2317
|
} finally {
|
|
2347
2318
|
tracking = n;
|
|
@@ -2353,10 +2324,10 @@ function isEqual(e, t) {
|
|
|
2353
2324
|
* an isPending() probe (`refresh`) additionally pulls the node fully up to
|
|
2354
2325
|
* date so its status flags reflect the current graph.
|
|
2355
2326
|
*/ function prepareComputed(e, t) {
|
|
2356
|
-
if (e.
|
|
2357
|
-
e.
|
|
2327
|
+
if (e.Le & REACTIVE_LAZY) {
|
|
2328
|
+
e.Le &= ~REACTIVE_LAZY;
|
|
2358
2329
|
recompute(e, true);
|
|
2359
|
-
} else if (e.
|
|
2330
|
+
} else if (e.Le & REACTIVE_DISPOSED) {
|
|
2360
2331
|
recompute(e, true);
|
|
2361
2332
|
} else if (t) {
|
|
2362
2333
|
updateIfNecessary(e);
|
|
@@ -2368,78 +2339,57 @@ function read(e) {
|
|
|
2368
2339
|
// Checked before isPending so that isPending(() => latest(x)) checks
|
|
2369
2340
|
// the _pendingSignal of _latestValueComputed (async in flight) rather
|
|
2370
2341
|
// than the original node (which stays "pending" while held in a transition).
|
|
2371
|
-
if (latestReadActive) return GlobalQueue.
|
|
2342
|
+
if (latestReadActive) return GlobalQueue.Ee(e);
|
|
2372
2343
|
let t = context;
|
|
2373
|
-
if (t?.
|
|
2344
|
+
if (t?.Je) t = t.et;
|
|
2374
2345
|
const n = e;
|
|
2375
|
-
const r = e.
|
|
2346
|
+
const r = e.Be;
|
|
2376
2347
|
const i = r || e;
|
|
2377
2348
|
// Handle isPending() mode: collect pending state while preserving normal read semantics.
|
|
2378
2349
|
// Probe mode is suspended while preparing the node so nested reads during a
|
|
2379
2350
|
// recompute don't collect into the probe.
|
|
2380
2351
|
if (pendingCheckActive) {
|
|
2381
|
-
GlobalQueue.
|
|
2382
|
-
} else if (typeof n.
|
|
2352
|
+
GlobalQueue.Se(e, t, i, r);
|
|
2353
|
+
} else if (typeof n.Ve === "function") {
|
|
2383
2354
|
prepareComputed(e, false);
|
|
2384
2355
|
}
|
|
2385
|
-
if (!n.
|
|
2386
|
-
if (t && tracking)
|
|
2387
|
-
|
|
2388
|
-
// A live mark on a read source flows to the reader (probe reads are
|
|
2389
|
-
// excluded: the probe's own collection owns that verdict, and marking
|
|
2390
|
-
// the enclosing memo would make an `isPending` wrapper itself pending).
|
|
2391
|
-
if (activeAffectsMarks !== 0 && e.F && !pendingCheckActive) (affectsReads ??= []).push(e);
|
|
2392
|
-
}
|
|
2393
|
-
return !t || e.V === NOT_PENDING ? e.Me : e.V;
|
|
2356
|
+
if (!n.Ve && i === e && e.A === undefined && e.we === undefined && activeTransition === null && currentOptimisticLane === null && !snapshotCaptureActive && true) {
|
|
2357
|
+
if (t && tracking) link(e, t);
|
|
2358
|
+
return !t || e.V === NOT_PENDING ? e.xe : e.V;
|
|
2394
2359
|
}
|
|
2395
2360
|
if (t && tracking) {
|
|
2396
2361
|
link(e, t, pendingCheckActive);
|
|
2397
|
-
|
|
2398
|
-
// transitive half (#2893): a mark-pended owner's sentinel sources flow to
|
|
2399
|
-
// the reader like a direct mark — value-transparent reads have no throw
|
|
2400
|
-
// to re-establish through, so without this a mid-window recompute sheds
|
|
2401
|
-
// pendingness permanently past one derivation level.
|
|
2402
|
-
if (activeAffectsMarks !== 0 && !pendingCheckActive) {
|
|
2403
|
-
if (e.F) (affectsReads ??= []).push(e);
|
|
2404
|
-
if (i.$e & STATUS_PENDING) GlobalQueue.le(i, affectsReads ??= []);
|
|
2405
|
-
}
|
|
2406
|
-
if (i.We) {
|
|
2362
|
+
if (i.Ve) {
|
|
2407
2363
|
const n = queueFor(e);
|
|
2408
|
-
if (i.
|
|
2364
|
+
if (i.ze >= n.C) {
|
|
2409
2365
|
markNode(t);
|
|
2410
2366
|
markHeap(n);
|
|
2411
2367
|
updateIfNecessary(i);
|
|
2412
2368
|
}
|
|
2413
|
-
const r = i.
|
|
2369
|
+
const r = i.ze;
|
|
2414
2370
|
// parent check is shallow, might need to be recursive
|
|
2415
|
-
if (r >= t.
|
|
2416
|
-
t.
|
|
2371
|
+
if (r >= t.ze && e.Z !== t) {
|
|
2372
|
+
t.ze = r + 1;
|
|
2417
2373
|
}
|
|
2418
2374
|
}
|
|
2419
2375
|
}
|
|
2420
|
-
|
|
2421
|
-
// a promise of change, not an absence of value, so a derived node whose only
|
|
2422
|
-
// pending sources are mark sentinels keeps its real value readable —
|
|
2423
|
-
// pendingness reaches readers through verdicts (isPending), not throws.
|
|
2424
|
-
// (`activeAffectsMarks` gates the source scan off the mark-free hot path;
|
|
2425
|
-
// sentinels can't survive in pending sources past their last release.)
|
|
2426
|
-
if (i.$e & STATUS_PENDING && !(activeAffectsMarks !== 0 && GlobalQueue.ue(i))) {
|
|
2376
|
+
if (i.We & STATUS_PENDING) {
|
|
2427
2377
|
if (t && !(stale && i.T && activeTransition !== i.T)) {
|
|
2428
2378
|
// Per-lane suspension lives with the engine (a non-null lane implies it
|
|
2429
2379
|
// is installed): under a lane, only same-lane pending async without an
|
|
2430
2380
|
// active override throws.
|
|
2431
|
-
if (currentOptimisticLane === null || GlobalQueue.
|
|
2381
|
+
if (currentOptimisticLane === null || GlobalQueue.ye(i)) {
|
|
2432
2382
|
if (!tracking && e !== t) link(e, t);
|
|
2433
|
-
throw i.
|
|
2383
|
+
throw i.me;
|
|
2434
2384
|
}
|
|
2435
|
-
} else if (t && i !== e && i
|
|
2385
|
+
} else if (t && i !== e && i.We & STATUS_UNINITIALIZED) {
|
|
2436
2386
|
if (!tracking && e !== t) link(e, t);
|
|
2437
|
-
throw i.
|
|
2438
|
-
} else if (!t && i
|
|
2439
|
-
throw i.
|
|
2387
|
+
throw i.me;
|
|
2388
|
+
} else if (!t && i.We & STATUS_UNINITIALIZED) {
|
|
2389
|
+
throw i.me;
|
|
2440
2390
|
}
|
|
2441
2391
|
}
|
|
2442
|
-
if (e.
|
|
2392
|
+
if (e.Ve && e.We & STATUS_ERROR) {
|
|
2443
2393
|
// Only a genuine reactive re-read may retry an errored async source:
|
|
2444
2394
|
// - tracking: owned/tracked scope only (never events / `untrack` / effect side-effect phase)
|
|
2445
2395
|
// - !pendingCheckActive: an `isPending` probe observes the error, never refetches
|
|
@@ -2447,21 +2397,19 @@ function read(e) {
|
|
|
2447
2397
|
if (tracking && !pendingCheckActive && e.M < clock) {
|
|
2448
2398
|
recompute(e);
|
|
2449
2399
|
return read(e);
|
|
2450
|
-
} else throw e.
|
|
2400
|
+
} else throw e.me;
|
|
2451
2401
|
}
|
|
2452
|
-
if (snapshotCaptureActive && t && t.
|
|
2453
|
-
const n = e.
|
|
2402
|
+
if (snapshotCaptureActive && t && t.ke & CONFIG_IN_SNAPSHOT_SCOPE) {
|
|
2403
|
+
const n = e.we;
|
|
2454
2404
|
if (n !== undefined) {
|
|
2455
2405
|
const r = n === NO_SNAPSHOT ? undefined : n;
|
|
2456
|
-
const i = e.V !== NOT_PENDING ? e.V : e.
|
|
2457
|
-
if (i !== r) t.
|
|
2406
|
+
const i = e.V !== NOT_PENDING ? e.V : e.xe;
|
|
2407
|
+
if (i !== r) t.Le |= REACTIVE_SNAPSHOT_STALE;
|
|
2458
2408
|
return r;
|
|
2459
2409
|
}
|
|
2460
2410
|
}
|
|
2461
2411
|
if (e.A !== undefined && e.A !== NOT_PENDING) {
|
|
2462
|
-
//
|
|
2463
|
-
// the value for every reader — that check itself stays right here).
|
|
2464
|
-
if (t && stale && GlobalQueue.ge(e)) return e.Me;
|
|
2412
|
+
// A17: the override IS the value for every reader.
|
|
2465
2413
|
return unwrapOverride(e.A);
|
|
2466
2414
|
}
|
|
2467
2415
|
// Entanglement gate: a reader recomputing under an optimistic lane that reads
|
|
@@ -2471,18 +2419,18 @@ function read(e) {
|
|
|
2471
2419
|
// _pendingValue for correct fetching. The sub is recorded for replay at commit
|
|
2472
2420
|
// so it re-runs with the new committed view. (Gate details live with the
|
|
2473
2421
|
// engine — a non-null lane implies it is installed.)
|
|
2474
|
-
if (currentOptimisticLane !== null && activeTransition !== null && t !== null && GlobalQueue.
|
|
2475
|
-
return e.
|
|
2422
|
+
if (currentOptimisticLane !== null && activeTransition !== null && t !== null && GlobalQueue.Ne(e, i, t)) {
|
|
2423
|
+
return e.xe;
|
|
2476
2424
|
}
|
|
2477
2425
|
// In optimistic lane context, return _value for optimistic/lane-assigned signals
|
|
2478
2426
|
// and for regular signals in stale mode (render effects). Non-stale readers (user
|
|
2479
2427
|
// effects) see _pendingValue so that latest() and direct reads stay consistent.
|
|
2480
2428
|
// (The lane-context clause lives with the engine.)
|
|
2481
|
-
const o = !t || currentOptimisticLane !== null && GlobalQueue.
|
|
2429
|
+
const o = !t || currentOptimisticLane !== null && GlobalQueue.Ce(e, i, t) || e.V === NOT_PENDING || stale && e.T && activeTransition !== e.T ? e.xe : e.V;
|
|
2482
2430
|
// Record that this isPending() probe observed the fresh pending value, so
|
|
2483
2431
|
// the probe doesn't pair "pending" with the new value (#2831).
|
|
2484
|
-
if (pendingCheckActive) GlobalQueue.
|
|
2485
|
-
if (!t && i === e && typeof n.
|
|
2432
|
+
if (pendingCheckActive) GlobalQueue.de(e, o);
|
|
2433
|
+
if (!t && i === e && typeof n.Ve === "function" && e.ke & CONFIG_AUTO_DISPOSE && !(i.We & STATUS_PENDING) && !e.k) {
|
|
2486
2434
|
unobserved(e);
|
|
2487
2435
|
}
|
|
2488
2436
|
return o;
|
|
@@ -2494,16 +2442,16 @@ function setSignal(e, t) {
|
|
|
2494
2442
|
// optimisticComputed callers and optimistic store nodes carry an
|
|
2495
2443
|
// _overrideValue slot, and every module that creates one installs the
|
|
2496
2444
|
// engine first.
|
|
2497
|
-
if (e.A !== undefined && !projectionWriteActive) return GlobalQueue.
|
|
2498
|
-
const n = e.V === NOT_PENDING ? e.
|
|
2445
|
+
if (e.A !== undefined && !projectionWriteActive) return GlobalQueue.Oe(e, t);
|
|
2446
|
+
const n = e.V === NOT_PENDING ? e.xe : e.V;
|
|
2499
2447
|
if (typeof t === "function") t = t(n);
|
|
2500
2448
|
// Uninitialized check first: the first commit has no previous value, so the
|
|
2501
2449
|
// user comparator must not run against `undefined` (matches recompute).
|
|
2502
|
-
const r = !!(e
|
|
2450
|
+
const r = !!(e.We & STATUS_UNINITIALIZED) || !e.ht || !e.ht(n, t);
|
|
2503
2451
|
if (!r) return t;
|
|
2504
2452
|
if (e.V === NOT_PENDING) queuePendingNode(e);
|
|
2505
2453
|
e.V = t;
|
|
2506
|
-
GlobalQueue.
|
|
2454
|
+
GlobalQueue.le !== null && GlobalQueue.le(e, t);
|
|
2507
2455
|
e.M = clock;
|
|
2508
2456
|
insertSubs(e);
|
|
2509
2457
|
schedule();
|
|
@@ -2518,11 +2466,11 @@ function setSignal(e, t) {
|
|
|
2518
2466
|
* cleanup point.
|
|
2519
2467
|
*/ function suppressComputedRecompute(e) {
|
|
2520
2468
|
deleteFromHeap(e, queueFor(e));
|
|
2521
|
-
if (!(e.
|
|
2469
|
+
if (!(e.Le & REACTIVE_MANUAL_WRITE) && e.V === NOT_PENDING) {
|
|
2522
2470
|
queuePendingNode(e);
|
|
2523
2471
|
schedule();
|
|
2524
2472
|
}
|
|
2525
|
-
e.
|
|
2473
|
+
e.Le = e.Le & -4 | REACTIVE_MANUAL_WRITE;
|
|
2526
2474
|
}
|
|
2527
2475
|
|
|
2528
2476
|
/**
|
|
@@ -2601,7 +2549,7 @@ function staleValues(e, t = true) {
|
|
|
2601
2549
|
if (!t) {
|
|
2602
2550
|
return;
|
|
2603
2551
|
}
|
|
2604
|
-
if (typeof t.
|
|
2552
|
+
if (typeof t.Ve === "function" && !(t.Le & (REACTIVE_DISPOSED | REACTIVE_MANUAL_WRITE))) {
|
|
2605
2553
|
// A refresh with no value-change dirt already queued is a re-ask of the
|
|
2606
2554
|
// same question: mark it so the recompute classifies any resulting
|
|
2607
2555
|
// pending window as quiet (not pending). If the node is already dirty
|
|
@@ -2609,11 +2557,11 @@ function staleValues(e, t = true) {
|
|
|
2609
2557
|
// REACTIVE_IN_HEAP counts as dirt: insertSubs schedules subscribers by
|
|
2610
2558
|
// heap insertion alone (no DIRTY/CHECK flag), so a same-batch value
|
|
2611
2559
|
// change followed by refresh() must not be laundered into a quiet re-ask.
|
|
2612
|
-
if (!(t.
|
|
2613
|
-
t.
|
|
2560
|
+
if (!(t.Le & (REACTIVE_DIRTY | REACTIVE_CHECK | REACTIVE_IN_HEAP))) {
|
|
2561
|
+
t.Le |= REACTIVE_REASK;
|
|
2614
2562
|
armReaskClear();
|
|
2615
2563
|
}
|
|
2616
|
-
t.
|
|
2564
|
+
t.Le = t.Le & ~REACTIVE_CHECK | REACTIVE_DIRTY;
|
|
2617
2565
|
insertIntoHeap(t, queueFor(t));
|
|
2618
2566
|
schedule();
|
|
2619
2567
|
}
|
|
@@ -2661,11 +2609,11 @@ function wireExternalSource(e) {
|
|
|
2661
2609
|
equals: false,
|
|
2662
2610
|
ownedWrite: true
|
|
2663
2611
|
});
|
|
2664
|
-
const n = externalSourceConfig.factory(e.
|
|
2612
|
+
const n = externalSourceConfig.factory(e.Ve, () => {
|
|
2665
2613
|
setSignal(t, undefined);
|
|
2666
2614
|
});
|
|
2667
2615
|
cleanup(() => n.dispose());
|
|
2668
|
-
e.
|
|
2616
|
+
e.Ve = e => {
|
|
2669
2617
|
read(t);
|
|
2670
2618
|
return n.track(e);
|
|
2671
2619
|
};
|
|
@@ -2679,8 +2627,8 @@ function externalUntrack(e) {
|
|
|
2679
2627
|
// removed on reset) so core's null checks stay equivalent to the old
|
|
2680
2628
|
// `externalSourceConfig` truthiness checks.
|
|
2681
2629
|
function syncExternalHooks() {
|
|
2682
|
-
GlobalQueue.
|
|
2683
|
-
GlobalQueue.
|
|
2630
|
+
GlobalQueue.se = externalSourceConfig ? wireExternalSource : null;
|
|
2631
|
+
GlobalQueue.ue = externalSourceConfig ? externalUntrack : null;
|
|
2684
2632
|
}
|
|
2685
2633
|
|
|
2686
2634
|
function enableExternalSource(e) {
|
|
@@ -2737,7 +2685,7 @@ function enableExternalSource(e) {
|
|
|
2737
2685
|
if (!t) {
|
|
2738
2686
|
throw new NoOwnerError;
|
|
2739
2687
|
}
|
|
2740
|
-
const n = hasContext(e, t) ? t.
|
|
2688
|
+
const n = hasContext(e, t) ? t.dt[e.id] : e.defaultValue;
|
|
2741
2689
|
if (isUndefined(n)) {
|
|
2742
2690
|
throw new ContextNotFoundError;
|
|
2743
2691
|
}
|
|
@@ -2758,14 +2706,14 @@ function enableExternalSource(e) {
|
|
|
2758
2706
|
}
|
|
2759
2707
|
// We're creating a new object to avoid child context values being exposed to parent owners. If
|
|
2760
2708
|
// we don't do this, everything will be a singleton and all hell will break lose.
|
|
2761
|
-
n.
|
|
2762
|
-
...n.
|
|
2709
|
+
n.dt = {
|
|
2710
|
+
...n.dt,
|
|
2763
2711
|
[e.id]: isUndefined(t) ? e.defaultValue : t
|
|
2764
2712
|
};
|
|
2765
2713
|
}
|
|
2766
2714
|
|
|
2767
2715
|
function hasContext(e, t) {
|
|
2768
|
-
return !isUndefined(t?.
|
|
2716
|
+
return !isUndefined(t?.dt[e.id]);
|
|
2769
2717
|
}
|
|
2770
2718
|
|
|
2771
2719
|
function isUndefined(e) {
|
|
@@ -2785,15 +2733,11 @@ function isUndefined(e) {
|
|
|
2785
2733
|
* `_optimisticNodes.length`, `activeLanes.size`), so `!` invocations are safe
|
|
2786
2734
|
* once the gate holds — the same late-binding contract as verdict.ts.
|
|
2787
2735
|
*/
|
|
2788
|
-
// When a background transition is stashed, plain optimistic signals need one
|
|
2789
|
-
// committed-view rerun. Keep that override local to the stash flush.
|
|
2790
|
-
let stashedOptimisticReads = null;
|
|
2791
|
-
|
|
2792
2736
|
/** The optimistic half of setSignal, fired when `_overrideValue !== undefined`. */ function optimisticWrite(e, t) {
|
|
2793
2737
|
const n = e.A !== NOT_PENDING;
|
|
2794
|
-
const r = n ? unwrapOverride(e.A) : e.
|
|
2738
|
+
const r = n ? unwrapOverride(e.A) : e.xe;
|
|
2795
2739
|
if (typeof t === "function") t = t(r);
|
|
2796
|
-
const i = !!(e
|
|
2740
|
+
const i = !!(e.We & STATUS_UNINITIALIZED) || !e.ht || !e.ht(r, t);
|
|
2797
2741
|
if (!i) {
|
|
2798
2742
|
// Same-value write with an active override still entangles the current
|
|
2799
2743
|
// action's transition — the hold must outlast all overlapping actions.
|
|
@@ -2818,43 +2762,13 @@ let stashedOptimisticReads = null;
|
|
|
2818
2762
|
// brand, and erasing it makes the write invisible and routes follow-up
|
|
2819
2763
|
// writes off the optimistic path into permanent commits (#2898).
|
|
2820
2764
|
e.A = t === undefined ? OVERRIDE_UNDEFINED : t;
|
|
2821
|
-
GlobalQueue.
|
|
2765
|
+
GlobalQueue.le !== null && GlobalQueue.le(e, t);
|
|
2822
2766
|
e.M = clock;
|
|
2823
2767
|
insertSubs(e, true);
|
|
2824
2768
|
schedule();
|
|
2825
2769
|
return t;
|
|
2826
2770
|
}
|
|
2827
2771
|
|
|
2828
|
-
function readStashed(e) {
|
|
2829
|
-
return !!stashedOptimisticReads?.has(e);
|
|
2830
|
-
}
|
|
2831
|
-
|
|
2832
|
-
function queueStashedOptimisticEffects(e) {
|
|
2833
|
-
for (let t = e.k; t !== null; t = t.Ve) {
|
|
2834
|
-
const e = t.xe;
|
|
2835
|
-
if (!e.He) continue;
|
|
2836
|
-
enqueueSub(e);
|
|
2837
|
-
}
|
|
2838
|
-
}
|
|
2839
|
-
|
|
2840
|
-
/**
|
|
2841
|
-
* Incomplete-transition finalization when the stashed transition holds
|
|
2842
|
-
* optimistic nodes: give plain optimistic signals one committed-view rerun.
|
|
2843
|
-
*/ function stashOptimistic(e) {
|
|
2844
|
-
stashedOptimisticReads = new Set;
|
|
2845
|
-
for (let t = 0; t < e.G.length; t++) {
|
|
2846
|
-
const n = e.G[t];
|
|
2847
|
-
if (n.We || n.Fe & CONFIG_OWNED_WRITE) continue;
|
|
2848
|
-
stashedOptimisticReads.add(n);
|
|
2849
|
-
queueStashedOptimisticEffects(n);
|
|
2850
|
-
}
|
|
2851
|
-
try {
|
|
2852
|
-
finalizePureQueue(null, true);
|
|
2853
|
-
} finally {
|
|
2854
|
-
stashedOptimisticReads = null;
|
|
2855
|
-
}
|
|
2856
|
-
}
|
|
2857
|
-
|
|
2858
2772
|
/**
|
|
2859
2773
|
* transitionComplete's override blockage: a settling transition stays open
|
|
2860
2774
|
* while one of its optimistic nodes holds an active override that is still
|
|
@@ -2862,11 +2776,7 @@ function queueStashedOptimisticEffects(e) {
|
|
|
2862
2776
|
*/ function transitionBlocked(e) {
|
|
2863
2777
|
for (let t = 0; t < e.G.length; t++) {
|
|
2864
2778
|
const n = e.G[t];
|
|
2865
|
-
if (hasActiveOverride(n) && "
|
|
2866
|
-
// Mark-sourced pending never blocks settlement: affects() releases AT
|
|
2867
|
-
// settle, so counting its sentinel here would deadlock the window it
|
|
2868
|
-
// is scoped to.
|
|
2869
|
-
!n.Ue.source?.Dt) {
|
|
2779
|
+
if (hasActiveOverride(n) && "We" in n && n.We & STATUS_PENDING && n.me instanceof NotReadyError) {
|
|
2870
2780
|
return true;
|
|
2871
2781
|
}
|
|
2872
2782
|
}
|
|
@@ -2884,10 +2794,10 @@ function resolveOptimisticNodes(e) {
|
|
|
2884
2794
|
// Revert is a pure drop: there is no revert target to commit —
|
|
2885
2795
|
// override-covered authoritative values hold in _pendingValue and
|
|
2886
2796
|
// elevate on their OWN transition's schedule (A18 as re-ruled 2026-07-07).
|
|
2887
|
-
if (!(t
|
|
2797
|
+
if (!(t.We & STATUS_PENDING)) t.We &= ~STATUS_UNINITIALIZED;
|
|
2888
2798
|
const r = t.A;
|
|
2889
2799
|
t.A = NOT_PENDING;
|
|
2890
|
-
if (r !== NOT_PENDING && t.
|
|
2800
|
+
if (r !== NOT_PENDING && t.xe !== unwrapOverride(r)) insertSubs(t, true);
|
|
2891
2801
|
t.T = null;
|
|
2892
2802
|
t.R = null;
|
|
2893
2803
|
}
|
|
@@ -2896,9 +2806,9 @@ function resolveOptimisticNodes(e) {
|
|
|
2896
2806
|
// transition that produced them (A19 — pending is a property of the data).
|
|
2897
2807
|
for (let n = 0; n < t; n++) {
|
|
2898
2808
|
const t = e[n];
|
|
2899
|
-
if (t._ || t.O) GlobalQueue.
|
|
2809
|
+
if (t._ || t.O) GlobalQueue.fe(t);
|
|
2900
2810
|
const r = t.t;
|
|
2901
|
-
if (r && (r._ === t || r.O === t)) GlobalQueue.
|
|
2811
|
+
if (r && (r._ === t || r.O === t)) GlobalQueue.fe(r);
|
|
2902
2812
|
}
|
|
2903
2813
|
e.splice(0, t);
|
|
2904
2814
|
}
|
|
@@ -2951,7 +2861,7 @@ function cleanupCompletedLanes(e) {
|
|
|
2951
2861
|
* that reads a pending mid-transition write sees the committed value; the sub
|
|
2952
2862
|
* is recorded for replay at commit.
|
|
2953
2863
|
*/ function gatedRead(e, t, n) {
|
|
2954
|
-
if (latestReadActive || e.V === NOT_PENDING || e.
|
|
2864
|
+
if (latestReadActive || e.V === NOT_PENDING || e.Ve || t !== e && !(t.Le & REACTIVE_MANUAL_WRITE)) {
|
|
2955
2865
|
return false;
|
|
2956
2866
|
}
|
|
2957
2867
|
activeTransition.q.add(n);
|
|
@@ -2962,7 +2872,7 @@ function cleanupCompletedLanes(e) {
|
|
|
2962
2872
|
* read()'s value selection under a lane: return the committed `_value` for
|
|
2963
2873
|
* optimistic/lane-assigned signals, stale-mode reads, and pending owners.
|
|
2964
2874
|
*/ function laneReadsCommitted(e, t, n) {
|
|
2965
|
-
return e.A !== undefined || !!e.i || t === e && stale && n.t !== e || !!(t
|
|
2875
|
+
return e.A !== undefined || !!e.i || t === e && stale && n.t !== e || !!(t.We & STATUS_PENDING);
|
|
2966
2876
|
}
|
|
2967
2877
|
|
|
2968
2878
|
/**
|
|
@@ -2971,12 +2881,12 @@ function cleanupCompletedLanes(e) {
|
|
|
2971
2881
|
* can run before its OPT-dirty child propagates).
|
|
2972
2882
|
*/ function recomputeLane(e, t) {
|
|
2973
2883
|
if (t) return resolveLane(e) ?? null;
|
|
2974
|
-
for (let t = e.
|
|
2975
|
-
const n = t.
|
|
2976
|
-
if (n.
|
|
2884
|
+
for (let t = e.Ke; t; t = t.Ye) {
|
|
2885
|
+
const n = t.qe;
|
|
2886
|
+
if (n.Le & REACTIVE_OPTIMISTIC_DIRTY) {
|
|
2977
2887
|
const t = resolveLane(n);
|
|
2978
2888
|
if (t) {
|
|
2979
|
-
e.
|
|
2889
|
+
e.Le |= REACTIVE_OPTIMISTIC_DIRTY;
|
|
2980
2890
|
assignOrMergeLane(e, t);
|
|
2981
2891
|
return t;
|
|
2982
2892
|
}
|
|
@@ -2990,7 +2900,7 @@ function cleanupCompletedLanes(e) {
|
|
|
2990
2900
|
if (t.o !== e) {
|
|
2991
2901
|
t.u.add(e);
|
|
2992
2902
|
e.i = t;
|
|
2993
|
-
GlobalQueue.
|
|
2903
|
+
GlobalQueue.ce !== null && GlobalQueue.ce(t.o);
|
|
2994
2904
|
}
|
|
2995
2905
|
}
|
|
2996
2906
|
|
|
@@ -2998,7 +2908,7 @@ function cleanupCompletedLanes(e) {
|
|
|
2998
2908
|
const t = resolveLane(e);
|
|
2999
2909
|
if (t) {
|
|
3000
2910
|
t.u.delete(e);
|
|
3001
|
-
GlobalQueue.
|
|
2911
|
+
GlobalQueue.ce !== null && GlobalQueue.ce(t.o);
|
|
3002
2912
|
}
|
|
3003
2913
|
}
|
|
3004
2914
|
|
|
@@ -3013,21 +2923,19 @@ function trackOptimisticStore(e) {
|
|
|
3013
2923
|
* create optimistic state (verdict.ts at module top level, createOptimistic
|
|
3014
2924
|
* and createOptimisticStore at first call) BEFORE any optimistic node exists.
|
|
3015
2925
|
*/ function installOptimisticEngine() {
|
|
3016
|
-
if (GlobalQueue.
|
|
3017
|
-
GlobalQueue.
|
|
3018
|
-
GlobalQueue.
|
|
3019
|
-
GlobalQueue.
|
|
3020
|
-
GlobalQueue.
|
|
3021
|
-
GlobalQueue.
|
|
3022
|
-
GlobalQueue.
|
|
3023
|
-
GlobalQueue.
|
|
3024
|
-
GlobalQueue.
|
|
3025
|
-
GlobalQueue.
|
|
3026
|
-
GlobalQueue.
|
|
3027
|
-
GlobalQueue.
|
|
3028
|
-
GlobalQueue.
|
|
3029
|
-
GlobalQueue.Ge = laneAsyncSettled;
|
|
3030
|
-
GlobalQueue.Le = trackOptimisticStore;
|
|
2926
|
+
if (GlobalQueue.Oe !== null) return;
|
|
2927
|
+
GlobalQueue.Oe = optimisticWrite;
|
|
2928
|
+
GlobalQueue.Re = resolveOptimisticNodes;
|
|
2929
|
+
GlobalQueue.Ie = transitionBlocked;
|
|
2930
|
+
GlobalQueue.Ae = cleanupCompletedLanes;
|
|
2931
|
+
GlobalQueue.he = runLaneEffects;
|
|
2932
|
+
GlobalQueue.Ne = gatedRead;
|
|
2933
|
+
GlobalQueue.ye = laneSuspends;
|
|
2934
|
+
GlobalQueue.Ce = laneReadsCommitted;
|
|
2935
|
+
GlobalQueue.Pe = recomputeLane;
|
|
2936
|
+
GlobalQueue.ge = laneAsyncPending;
|
|
2937
|
+
GlobalQueue.be = laneAsyncSettled;
|
|
2938
|
+
GlobalQueue.De = trackOptimisticStore;
|
|
3031
2939
|
}
|
|
3032
2940
|
|
|
3033
2941
|
/**
|
|
@@ -3060,7 +2968,7 @@ let pendingProbe = null;
|
|
|
3060
2968
|
function collectPendingSources(e) {
|
|
3061
2969
|
if (!pendingProbe) return;
|
|
3062
2970
|
pendingProbe.sources.add(e);
|
|
3063
|
-
const t = e.
|
|
2971
|
+
const t = e.Be || e;
|
|
3064
2972
|
if (t !== e) pendingProbe.sources.add(t);
|
|
3065
2973
|
}
|
|
3066
2974
|
|
|
@@ -3074,34 +2982,76 @@ function collectPendingSources(e) {
|
|
|
3074
2982
|
pendingProbe?.sources.add(e);
|
|
3075
2983
|
}
|
|
3076
2984
|
|
|
2985
|
+
/**
|
|
2986
|
+
* The affects() coverage walk — the read half of the dedicated mark channel.
|
|
2987
|
+
* A node is covered by a live mark iff it carries one (`_affectsCount`) or
|
|
2988
|
+
* derives, through its CURRENT deps (hopping store firewalls), from a node
|
|
2989
|
+
* that does. Pull-based coverage means graph rewires, mid-window recomputes,
|
|
2990
|
+
* and probe-triggered recomputes can never strand or strip a mark — there is
|
|
2991
|
+
* nothing stored downstream to corrupt. Probe-created links
|
|
2992
|
+
* (`_pendingObserver`) are skipped so an `isPending` wrapper memo never
|
|
2993
|
+
* inherits the coverage it reports on.
|
|
2994
|
+
*/ function markWalk(e, t) {
|
|
2995
|
+
if (e.F) return true;
|
|
2996
|
+
// A real error outranks an inherited mark (A16/A24c): an errored node
|
|
2997
|
+
// answers probes with its error, not a coverage verdict, and coverage does
|
|
2998
|
+
// not flow through it — matching the rails' behavior, where propagation
|
|
2999
|
+
// stopped at errored nodes. A DIRECT mark on an errored node still reads
|
|
3000
|
+
// pending (the count check above), also matching.
|
|
3001
|
+
if (e.We & STATUS_ERROR) return false;
|
|
3002
|
+
if (t.has(e)) return false;
|
|
3003
|
+
t.add(e);
|
|
3004
|
+
const n = e.Be;
|
|
3005
|
+
if (n && markWalk(n, t)) return true;
|
|
3006
|
+
// Mid-recompute (the clearStatus companion poke runs before
|
|
3007
|
+
// trimStaleDeps), only the validated prefix [_deps.._depsTail] is this
|
|
3008
|
+
// pass's dependency set — walking past it would read dropped deps and
|
|
3009
|
+
// latch a stale verdict on the companion.
|
|
3010
|
+
const r = e;
|
|
3011
|
+
const i = r.Le & REACTIVE_RECOMPUTING_DEPS ? r.ut : undefined;
|
|
3012
|
+
if (i !== null) {
|
|
3013
|
+
for (let e = r.Ke ?? null; e !== null; e = e.Ye) {
|
|
3014
|
+
if (!e.Ot && markWalk(e.qe, t)) return true;
|
|
3015
|
+
if (e === i) break;
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
return false;
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3021
|
+
/** Gated entry: apps with no live mark pay one integer compare. */ function markCovered(e) {
|
|
3022
|
+
return activeAffectsMarks !== 0 && markWalk(e, new Set);
|
|
3023
|
+
}
|
|
3024
|
+
|
|
3077
3025
|
function quietPending(e) {
|
|
3078
|
-
if (e
|
|
3079
|
-
for (const t of e
|
|
3026
|
+
if (e.$e) {
|
|
3027
|
+
for (const t of e.$e) if (!t.Nt) return false;
|
|
3080
3028
|
return true;
|
|
3081
3029
|
}
|
|
3082
|
-
return e.
|
|
3030
|
+
return e.Nt;
|
|
3083
3031
|
}
|
|
3084
3032
|
|
|
3085
3033
|
function newQuestionInFlight(e) {
|
|
3086
|
-
return !!(e
|
|
3034
|
+
return !!(e.We & STATUS_PENDING) && !(e.We & STATUS_UNINITIALIZED) && !quietPending(e);
|
|
3087
3035
|
}
|
|
3088
3036
|
|
|
3089
3037
|
function computePendingState(e) {
|
|
3090
3038
|
const t = e;
|
|
3091
|
-
if (t.
|
|
3092
|
-
|
|
3093
|
-
|
|
3039
|
+
if (t.Le & REACTIVE_DISPOSED) return false;
|
|
3040
|
+
// Mark coverage is transitive by dep-graph reachability: a latest() shadow
|
|
3041
|
+
// reaches its owner (and a store leaf its firewall) through its own deps,
|
|
3042
|
+
// so the one walk covers direct marks, derivation, and companion chains.
|
|
3043
|
+
if (markCovered(e)) return true;
|
|
3044
|
+
const n = e.Be;
|
|
3094
3045
|
if (e.t) {
|
|
3095
3046
|
const t = e.t;
|
|
3096
|
-
|
|
3097
|
-
const n = t.Je || t;
|
|
3047
|
+
const n = t.Be || t;
|
|
3098
3048
|
return newQuestionInFlight(n);
|
|
3099
3049
|
}
|
|
3100
3050
|
if (n && e.V !== NOT_PENDING && !hasActiveOverride(e)) {
|
|
3101
|
-
return !!(n.
|
|
3051
|
+
return !!(n.Le & REACTIVE_MANUAL_WRITE) || !n.lt && !(n.We & STATUS_PENDING) || !!(n.We & STATUS_PENDING) && quietPending(n);
|
|
3102
3052
|
}
|
|
3103
|
-
if (e.V !== NOT_PENDING && !(t
|
|
3104
|
-
if (hasActiveOverride(e)) return !e.
|
|
3053
|
+
if (e.V !== NOT_PENDING && !(t.We & STATUS_UNINITIALIZED)) {
|
|
3054
|
+
if (hasActiveOverride(e)) return !e.ht || !e.ht(e.V, unwrapOverride(e.A));
|
|
3105
3055
|
return true;
|
|
3106
3056
|
}
|
|
3107
3057
|
return newQuestionInFlight(t);
|
|
@@ -3120,19 +3070,28 @@ function updatePendingSignal(e) {
|
|
|
3120
3070
|
}
|
|
3121
3071
|
|
|
3122
3072
|
function updateChildCompanions(e) {
|
|
3123
|
-
for (let t = e.
|
|
3073
|
+
for (let t = e.rt; t !== null; t = t.it) {
|
|
3124
3074
|
if (t._ || t.O) updatePendingSignal(t);
|
|
3125
3075
|
}
|
|
3126
3076
|
}
|
|
3127
3077
|
|
|
3128
|
-
|
|
3129
|
-
|
|
3078
|
+
/**
|
|
3079
|
+
* Re-derive every verdict companion downstream of `el` (subs + firewall
|
|
3080
|
+
* children, dedup'd). The affects() channel's poke walk: registration and
|
|
3081
|
+
* re-ask flips use the live write path (companion setSignal — its own lane
|
|
3082
|
+
* lets the wake escape an incomplete transition's effect stash, #2887);
|
|
3083
|
+
* mark release passes `snap` because it runs inside queue finalization,
|
|
3084
|
+
* where companion writes must land committed (a setSignal there would open
|
|
3085
|
+
* a fresh override window that nothing settles).
|
|
3086
|
+
*/ function repollDownstreamVerdicts(e, t = false) {
|
|
3087
|
+
const n = t ? snapCompanionsToState : updatePendingSignal;
|
|
3088
|
+
const r = new Set;
|
|
3130
3089
|
const visit = e => {
|
|
3131
|
-
if (
|
|
3132
|
-
|
|
3133
|
-
if (e._ || e.O)
|
|
3134
|
-
for (let t = e.k; t !== null; t = t.
|
|
3135
|
-
for (let t = e.
|
|
3090
|
+
if (r.has(e)) return;
|
|
3091
|
+
r.add(e);
|
|
3092
|
+
if (e._ || e.O) n(e);
|
|
3093
|
+
for (let t = e.k; t !== null; t = t.Ge) visit(t.Ue);
|
|
3094
|
+
for (let t = e.rt ?? null; t !== null; t = t.it) {
|
|
3136
3095
|
visit(t);
|
|
3137
3096
|
}
|
|
3138
3097
|
};
|
|
@@ -3143,8 +3102,8 @@ function snapCompanionsToState(e) {
|
|
|
3143
3102
|
const t = e._;
|
|
3144
3103
|
if (t && (t.A === undefined || t.A === NOT_PENDING)) {
|
|
3145
3104
|
const n = computePendingState(e);
|
|
3146
|
-
if (t.
|
|
3147
|
-
t.
|
|
3105
|
+
if (t.xe !== n || t.V !== NOT_PENDING) {
|
|
3106
|
+
t.xe = n;
|
|
3148
3107
|
t.V = NOT_PENDING;
|
|
3149
3108
|
t.M = clock;
|
|
3150
3109
|
insertSubs(t);
|
|
@@ -3152,9 +3111,9 @@ function snapCompanionsToState(e) {
|
|
|
3152
3111
|
}
|
|
3153
3112
|
}
|
|
3154
3113
|
const n = e.O;
|
|
3155
|
-
if (n && !(n.
|
|
3156
|
-
if ((n.A === undefined || n.A === NOT_PENDING) && n.V === NOT_PENDING && !Object.is(n.
|
|
3157
|
-
n.
|
|
3114
|
+
if (n && !(n.Le & REACTIVE_DISPOSED)) {
|
|
3115
|
+
if ((n.A === undefined || n.A === NOT_PENDING) && n.V === NOT_PENDING && !Object.is(n.xe, e.xe) && !(n.Le & (REACTIVE_DIRTY | REACTIVE_CHECK))) {
|
|
3116
|
+
n.Le |= REACTIVE_DIRTY;
|
|
3158
3117
|
insertIntoHeap(n, queueFor(n));
|
|
3159
3118
|
insertSubs(n);
|
|
3160
3119
|
schedule();
|
|
@@ -3186,7 +3145,7 @@ function getLatestValueComputed(e) {
|
|
|
3186
3145
|
const t = getLatestValueComputed(e);
|
|
3187
3146
|
const n = latestReadActive;
|
|
3188
3147
|
setLatestReadActive(false);
|
|
3189
|
-
const r = e.A !== undefined && e.A !== NOT_PENDING ? unwrapOverride(e.A) : e.
|
|
3148
|
+
const r = e.A !== undefined && e.A !== NOT_PENDING ? unwrapOverride(e.A) : e.xe;
|
|
3190
3149
|
let i;
|
|
3191
3150
|
try {
|
|
3192
3151
|
// An untracked latest() read has no reading context, so read() never
|
|
@@ -3195,18 +3154,18 @@ function getLatestValueComputed(e) {
|
|
|
3195
3154
|
// until the flush (#2922). Mirror the tracked-read pull here: mark the
|
|
3196
3155
|
// queued staleness through the graph, then bring the shadow up to date.
|
|
3197
3156
|
const e = queueFor(t);
|
|
3198
|
-
if (t.
|
|
3157
|
+
if (t.ze >= e.C && !(t.Le & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE))) {
|
|
3199
3158
|
markHeap(e);
|
|
3200
3159
|
prepareComputed(t, true);
|
|
3201
3160
|
}
|
|
3202
3161
|
i = read(t);
|
|
3203
3162
|
} catch (t) {
|
|
3204
|
-
if (t instanceof NotReadyError && (!context || !(e
|
|
3163
|
+
if (t instanceof NotReadyError && (!context || !(e.We & STATUS_UNINITIALIZED))) return r;
|
|
3205
3164
|
throw t;
|
|
3206
3165
|
} finally {
|
|
3207
3166
|
setLatestReadActive(n);
|
|
3208
3167
|
}
|
|
3209
|
-
if (t
|
|
3168
|
+
if (t.We & STATUS_PENDING) return r;
|
|
3210
3169
|
if (stale && currentOptimisticLane && t.i) {
|
|
3211
3170
|
const e = findLane(t.i);
|
|
3212
3171
|
const n = findLane(currentOptimisticLane);
|
|
@@ -3224,12 +3183,12 @@ function getLatestValueComputed(e) {
|
|
|
3224
3183
|
|
|
3225
3184
|
/** The isPending()-probe read path, installed as GlobalQueue._pendingCheck. */ function pendingCheckRead(e, t, n, r) {
|
|
3226
3185
|
setPendingCheckActive(false);
|
|
3227
|
-
if (typeof e.
|
|
3228
|
-
const i = n
|
|
3186
|
+
if (typeof e.Ve === "function") prepareComputed(e, true);
|
|
3187
|
+
const i = n.We;
|
|
3229
3188
|
if (t && i & STATUS_PENDING && i & STATUS_UNINITIALIZED) {
|
|
3230
3189
|
if (tracking && e !== t) link(e, t);
|
|
3231
3190
|
setPendingCheckActive(true);
|
|
3232
|
-
throw n.
|
|
3191
|
+
throw n.me;
|
|
3233
3192
|
}
|
|
3234
3193
|
collectPendingSources(e);
|
|
3235
3194
|
if (r) collectPendingSources(r);
|
|
@@ -3241,10 +3200,10 @@ function recordFreshRead(e, t) {
|
|
|
3241
3200
|
}
|
|
3242
3201
|
|
|
3243
3202
|
function applyReask(e, t) {
|
|
3244
|
-
const n = !!(e
|
|
3245
|
-
const r = t && !(n && !e.
|
|
3246
|
-
const i = n && e.
|
|
3247
|
-
e.
|
|
3203
|
+
const n = !!(e.We & STATUS_PENDING);
|
|
3204
|
+
const r = t && !(n && !e.Nt);
|
|
3205
|
+
const i = n && e.Nt !== r;
|
|
3206
|
+
e.Nt = r;
|
|
3248
3207
|
return i;
|
|
3249
3208
|
}
|
|
3250
3209
|
|
|
@@ -3284,7 +3243,7 @@ function isPending(e) {
|
|
|
3284
3243
|
} catch (e) {
|
|
3285
3244
|
collectPending();
|
|
3286
3245
|
if (e instanceof NotReadyError) {
|
|
3287
|
-
const t = !!(e.source
|
|
3246
|
+
const t = !!(e.source?.We & STATUS_UNINITIALIZED);
|
|
3288
3247
|
if (r.found && !t) return true;
|
|
3289
3248
|
if (context && t) throw e;
|
|
3290
3249
|
}
|
|
@@ -3298,25 +3257,25 @@ function isPending(e) {
|
|
|
3298
3257
|
// Hook installation (same late-binding pattern as GlobalQueue._update /
|
|
3299
3258
|
// _propagateAffects): core call sites fire these behind the same guards the
|
|
3300
3259
|
// direct calls used, so behavior is identical once this module loads.
|
|
3301
|
-
GlobalQueue.
|
|
3260
|
+
GlobalQueue.le = syncCompanions;
|
|
3302
3261
|
|
|
3303
|
-
GlobalQueue.
|
|
3262
|
+
GlobalQueue.ce = updatePendingSignal;
|
|
3304
3263
|
|
|
3305
|
-
GlobalQueue.
|
|
3264
|
+
GlobalQueue.ae = updateChildCompanions;
|
|
3306
3265
|
|
|
3307
|
-
GlobalQueue.
|
|
3266
|
+
GlobalQueue.fe = snapCompanionsToState;
|
|
3308
3267
|
|
|
3309
|
-
GlobalQueue.
|
|
3268
|
+
GlobalQueue.Ee = latestRead;
|
|
3310
3269
|
|
|
3311
|
-
GlobalQueue.
|
|
3270
|
+
GlobalQueue.Se = pendingCheckRead;
|
|
3312
3271
|
|
|
3313
|
-
GlobalQueue.
|
|
3272
|
+
GlobalQueue.de = recordFreshRead;
|
|
3314
3273
|
|
|
3315
|
-
GlobalQueue.
|
|
3274
|
+
GlobalQueue.Te = applyReask;
|
|
3316
3275
|
|
|
3317
|
-
GlobalQueue.
|
|
3276
|
+
GlobalQueue.pe = repollDownstreamVerdicts;
|
|
3318
3277
|
|
|
3319
|
-
GlobalQueue.
|
|
3278
|
+
GlobalQueue._e = witnessAffects;
|
|
3320
3279
|
|
|
3321
3280
|
/**
|
|
3322
3281
|
* Effects are the leaf nodes of our reactive graph. When their sources change, they are
|
|
@@ -3326,16 +3285,16 @@ GlobalQueue.Ie = witnessAffects;
|
|
|
3326
3285
|
const i = !!r?.user;
|
|
3327
3286
|
const o = createEffectNode(e, t, n, i ? EFFECT_USER : EFFECT_RENDER, notifyEffectStatus, r);
|
|
3328
3287
|
recompute(o, true);
|
|
3329
|
-
!r?.defer && (o.
|
|
3288
|
+
!r?.defer && (o.Qe === EFFECT_USER || r?.schedule ? o.Ze.enqueue(o.Qe, runEffect.bind(null, o)) : runEffect(o));
|
|
3330
3289
|
}
|
|
3331
3290
|
|
|
3332
3291
|
function notifyEffectStatus(e, t) {
|
|
3333
3292
|
// Use passed values if provided, otherwise read from node
|
|
3334
|
-
const n = e !== undefined ? e : this
|
|
3335
|
-
const r = t !== undefined ? t : this.
|
|
3293
|
+
const n = e !== undefined ? e : this.We;
|
|
3294
|
+
const r = t !== undefined ? t : this.me;
|
|
3336
3295
|
if (n & STATUS_ERROR) {
|
|
3337
|
-
this.
|
|
3338
|
-
if (this.
|
|
3296
|
+
this.Ze.notify(this, STATUS_PENDING, 0);
|
|
3297
|
+
if (this.Qe === EFFECT_USER) {
|
|
3339
3298
|
// The error handler is the error arm of the effect phase (#2840 ruling):
|
|
3340
3299
|
// queue it like the effect function. It runs in the same imperative,
|
|
3341
3300
|
// writable scope, throws escalate the same way, and a held transition
|
|
@@ -3345,23 +3304,23 @@ function notifyEffectStatus(e, t) {
|
|
|
3345
3304
|
// phase takes the success arm instead. Blocked forwards (explicit
|
|
3346
3305
|
// `status` arg without node-state writes) don't queue: the status
|
|
3347
3306
|
// re-propagates unblocked at commit.
|
|
3348
|
-
if (this
|
|
3349
|
-
this.
|
|
3350
|
-
this.
|
|
3307
|
+
if (this.We & STATUS_ERROR) {
|
|
3308
|
+
this.Fe = true;
|
|
3309
|
+
this.Ze.enqueue(this.Qe, this.Pt ??= runEffect.bind(null, this));
|
|
3351
3310
|
}
|
|
3352
3311
|
return;
|
|
3353
3312
|
}
|
|
3354
|
-
if (!this.
|
|
3313
|
+
if (!this.Ze.notify(this, STATUS_ERROR, STATUS_ERROR)) {
|
|
3355
3314
|
haltReactivity(unwrapStatusError(r));
|
|
3356
3315
|
throw r;
|
|
3357
3316
|
}
|
|
3358
|
-
} else if (this.
|
|
3359
|
-
this.
|
|
3317
|
+
} else if (this.Qe === EFFECT_RENDER) {
|
|
3318
|
+
this.Ze.notify(this, STATUS_PENDING | STATUS_ERROR, n, r);
|
|
3360
3319
|
}
|
|
3361
3320
|
}
|
|
3362
3321
|
|
|
3363
3322
|
function runEffect(e) {
|
|
3364
|
-
if (!e.
|
|
3323
|
+
if (!e.Fe || e.Le & REACTIVE_DISPOSED) return;
|
|
3365
3324
|
// Error arm (#2840), user effects only: a compute-phase error that is still
|
|
3366
3325
|
// the node's settled state at effect time runs the bundle's error handler in
|
|
3367
3326
|
// this same imperative, writable scope. Unwrap the StatusError used for
|
|
@@ -3372,42 +3331,42 @@ function runEffect(e) {
|
|
|
3372
3331
|
// Render effects bypass: their errors route to boundaries synchronously in
|
|
3373
3332
|
// notifyEffectStatus, and a runner queued by an earlier valueChanged in the
|
|
3374
3333
|
// same flush must not be hijacked by a later-arriving error status.
|
|
3375
|
-
if (e
|
|
3376
|
-
const t = unwrapStatusError(e.
|
|
3377
|
-
e.
|
|
3378
|
-
e.
|
|
3334
|
+
if (e.We & STATUS_ERROR && e.Qe === EFFECT_USER) {
|
|
3335
|
+
const t = unwrapStatusError(e.me);
|
|
3336
|
+
e.bt = e.xe;
|
|
3337
|
+
e.Fe = false;
|
|
3379
3338
|
try {
|
|
3380
|
-
e.
|
|
3381
|
-
const t = e.
|
|
3382
|
-
e.
|
|
3339
|
+
e.vt ? e.vt(t, () => {
|
|
3340
|
+
const t = e.Et;
|
|
3341
|
+
e.Et = undefined;
|
|
3383
3342
|
t?.();
|
|
3384
3343
|
}) : console.error(t);
|
|
3385
3344
|
} catch (t) {
|
|
3386
|
-
if (!e.
|
|
3345
|
+
if (!e.Ze.notify(e, STATUS_ERROR, STATUS_ERROR)) {
|
|
3387
3346
|
haltReactivity(t);
|
|
3388
3347
|
throw t;
|
|
3389
3348
|
}
|
|
3390
3349
|
}
|
|
3391
3350
|
return;
|
|
3392
3351
|
}
|
|
3393
|
-
const t = e.
|
|
3394
|
-
e.
|
|
3352
|
+
const t = e.Et;
|
|
3353
|
+
e.Et = undefined;
|
|
3395
3354
|
try {
|
|
3396
3355
|
t?.();
|
|
3397
|
-
const n = e.
|
|
3356
|
+
const n = e.Dt(e.xe, e.bt);
|
|
3398
3357
|
if (false && n !== undefined && typeof n !== "function") ;
|
|
3399
3358
|
// The final cleanup is invoked by disposeChildren at true disposal.
|
|
3400
|
-
e.
|
|
3359
|
+
e.Et = n;
|
|
3401
3360
|
} catch (t) {
|
|
3402
|
-
e.
|
|
3403
|
-
e
|
|
3404
|
-
if (!e.
|
|
3361
|
+
e.me = new StatusError(e, t);
|
|
3362
|
+
e.We |= STATUS_ERROR;
|
|
3363
|
+
if (!e.Ze.notify(e, STATUS_ERROR, STATUS_ERROR)) {
|
|
3405
3364
|
haltReactivity(t);
|
|
3406
3365
|
throw t;
|
|
3407
3366
|
}
|
|
3408
3367
|
} finally {
|
|
3409
|
-
e.
|
|
3410
|
-
e.
|
|
3368
|
+
e.bt = e.xe;
|
|
3369
|
+
e.Fe = false;
|
|
3411
3370
|
}
|
|
3412
3371
|
}
|
|
3413
3372
|
|
|
@@ -3419,39 +3378,39 @@ GlobalQueue.ee = runEffect;
|
|
|
3419
3378
|
* Uses stale reads.
|
|
3420
3379
|
*/ function trackedEffect(e, t) {
|
|
3421
3380
|
const run = () => {
|
|
3422
|
-
if (!n.
|
|
3381
|
+
if (!n.Fe || n.Le & REACTIVE_DISPOSED) return;
|
|
3423
3382
|
try {
|
|
3424
|
-
n.
|
|
3383
|
+
n.Fe = false;
|
|
3425
3384
|
recompute(n);
|
|
3426
3385
|
} finally {}
|
|
3427
3386
|
};
|
|
3428
3387
|
const n = computed(() => {
|
|
3429
|
-
const t = n.
|
|
3430
|
-
n.
|
|
3388
|
+
const t = n.Et;
|
|
3389
|
+
n.Et = undefined;
|
|
3431
3390
|
t?.();
|
|
3432
3391
|
const r = staleValues(e);
|
|
3433
|
-
n.
|
|
3392
|
+
n.Et = r;
|
|
3434
3393
|
}, {
|
|
3435
3394
|
...t,
|
|
3436
3395
|
lazy: true
|
|
3437
3396
|
});
|
|
3438
|
-
n.
|
|
3439
|
-
n.
|
|
3440
|
-
n.
|
|
3441
|
-
n.
|
|
3442
|
-
n.
|
|
3443
|
-
const r = e !== undefined ? e : n
|
|
3397
|
+
n.Et = undefined;
|
|
3398
|
+
n.ke = n.ke & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
|
|
3399
|
+
n.Fe = true;
|
|
3400
|
+
n.Qe = EFFECT_TRACKED;
|
|
3401
|
+
n.yt = (e, t) => {
|
|
3402
|
+
const r = e !== undefined ? e : n.We;
|
|
3444
3403
|
if (r & STATUS_ERROR) {
|
|
3445
|
-
n.
|
|
3446
|
-
const e = t !== undefined ? t : n.
|
|
3447
|
-
if (!n.
|
|
3404
|
+
n.Ze.notify(n, STATUS_PENDING, 0);
|
|
3405
|
+
const e = t !== undefined ? t : n.me;
|
|
3406
|
+
if (!n.Ze.notify(n, STATUS_ERROR, STATUS_ERROR)) {
|
|
3448
3407
|
haltReactivity(unwrapStatusError(e));
|
|
3449
3408
|
throw e;
|
|
3450
3409
|
}
|
|
3451
3410
|
}
|
|
3452
3411
|
};
|
|
3453
|
-
n.
|
|
3454
|
-
n.
|
|
3412
|
+
n.Xe = run;
|
|
3413
|
+
n.Ze.enqueue(EFFECT_USER, run);
|
|
3455
3414
|
}
|
|
3456
3415
|
|
|
3457
3416
|
function restoreTransition(e, t) {
|
|
@@ -3632,7 +3591,7 @@ function accessor(e) {
|
|
|
3632
3591
|
function createSignal(e, t) {
|
|
3633
3592
|
if (typeof e === "function") {
|
|
3634
3593
|
const n = computed(e, t);
|
|
3635
|
-
n.
|
|
3594
|
+
n.ke &= ~CONFIG_AUTO_DISPOSE;
|
|
3636
3595
|
return [ accessor(n), setMemo.bind(null, n) ];
|
|
3637
3596
|
}
|
|
3638
3597
|
const n = signal(e, t);
|
|
@@ -3806,6 +3765,12 @@ function createEffect(e, t, n) {
|
|
|
3806
3765
|
};
|
|
3807
3766
|
}
|
|
3808
3767
|
|
|
3768
|
+
/** Delivers effect applies on a microtask instead of queueing them (#2930). */ class MicrotaskQueue extends Queue {
|
|
3769
|
+
enqueue(e, t) {
|
|
3770
|
+
queueMicrotask(() => t(e));
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
|
|
3809
3774
|
/**
|
|
3810
3775
|
* Awaits a reactive expression and returns its first fully-settled value as a
|
|
3811
3776
|
* `Promise`. Pending async reads (`createMemo` returning a promise, etc.) are
|
|
@@ -3829,11 +3794,23 @@ function createEffect(e, t, n) {
|
|
|
3829
3794
|
*/ function resolve(e) {
|
|
3830
3795
|
return new Promise((t, n) => {
|
|
3831
3796
|
createRoot(r => {
|
|
3797
|
+
// Deliver effect applies on a microtask instead of the owner queue: an
|
|
3798
|
+
// incomplete transition stashes its effect queues until it settles, but
|
|
3799
|
+
// an action yielding this promise is itself what keeps the transition
|
|
3800
|
+
// open — the stashed res() deadlocked the action (#2930). The compute
|
|
3801
|
+
// still runs in place (under the transaction's view when created inside
|
|
3802
|
+
// an action step), and status/boundary notifications keep their normal
|
|
3803
|
+
// route through the inherited queue.
|
|
3804
|
+
const i = getOwner();
|
|
3805
|
+
const o = new MicrotaskQueue;
|
|
3806
|
+
o.Z = i.Ze;
|
|
3807
|
+
// notify() forwards up the normal chain
|
|
3808
|
+
i.Ze = o;
|
|
3832
3809
|
// A user effect rather than a bare computed: computeds are pull-based and
|
|
3833
3810
|
// are only re-enqueued when a pending source *resolves* — a rejection just
|
|
3834
3811
|
// marks them errored, so nothing would re-run and the promise would never
|
|
3835
3812
|
// settle (#2842). The effect's error channel is notified on rejection.
|
|
3836
|
-
|
|
3813
|
+
effect(e, e => {
|
|
3837
3814
|
t(e);
|
|
3838
3815
|
r();
|
|
3839
3816
|
}, e => {
|
|
@@ -3855,7 +3832,7 @@ function createOptimistic(e, t) {
|
|
|
3855
3832
|
installOptimisticEngine();
|
|
3856
3833
|
if (typeof e === "function") {
|
|
3857
3834
|
const n = optimisticComputed(e, t);
|
|
3858
|
-
n.
|
|
3835
|
+
n.ke &= ~CONFIG_AUTO_DISPOSE;
|
|
3859
3836
|
return [ accessor(n), setSignal.bind(null, n) ];
|
|
3860
3837
|
}
|
|
3861
3838
|
const n = optimisticSignal(e, t);
|
|
@@ -3944,7 +3921,7 @@ function createOptimistic(e, t) {
|
|
|
3944
3921
|
* on owner disposal
|
|
3945
3922
|
*/ function onSettled(e) {
|
|
3946
3923
|
const t = getOwner();
|
|
3947
|
-
t && !(t.
|
|
3924
|
+
t && !(t.ke & CONFIG_CHILDREN_FORBIDDEN) ? createTrackedEffect(() => untrack(e), undefined) : globalQueue.enqueue(EFFECT_USER, () => {
|
|
3948
3925
|
// Unowned, out-of-band fire (no owner, or a children-forbidden one this
|
|
3949
3926
|
// one-shot must not bind to): a returned cleanup has no lifecycle to
|
|
3950
3927
|
// attach to. Reject it in dev; in production the return is simply
|
|
@@ -4098,9 +4075,9 @@ function applyArrayItem(e, t, n, r, i) {
|
|
|
4098
4075
|
if (!isWrappable(f)) continue;
|
|
4099
4076
|
const E = (u.get(f) ?? storeLookup.get(f))?.[$TARGET];
|
|
4100
4077
|
if (!E?.[STORE_DESC]) continue;
|
|
4101
|
-
const
|
|
4102
|
-
if (f ===
|
|
4103
|
-
applyState(
|
|
4078
|
+
const S = unwrap(t[a]);
|
|
4079
|
+
if (f === S || !isWrappable(S) || Array.isArray(f) !== Array.isArray(S) || i(f) != null && i(f) !== i(S)) continue;
|
|
4080
|
+
applyState(S, wrap(f, n), i);
|
|
4104
4081
|
}
|
|
4105
4082
|
}
|
|
4106
4083
|
|
|
@@ -4134,7 +4111,7 @@ function applyStateFast(e, t, n) {
|
|
|
4134
4111
|
let o = false;
|
|
4135
4112
|
const s = r.length;
|
|
4136
4113
|
if (e.length && s && isWrappable(e[0]) && n(e[0]) != null) {
|
|
4137
|
-
let u, l, c, a, f, E,
|
|
4114
|
+
let u, l, c, a, f, E, S, d;
|
|
4138
4115
|
for (c = 0, a = Math.min(s, e.length); c < a && keyedMatch(E = r[c], e[c], n); c++) {
|
|
4139
4116
|
isWrappable(E) && isWrappable(e[c]) && applyState(e[c], wrap(E, t), n);
|
|
4140
4117
|
}
|
|
@@ -4157,22 +4134,22 @@ function applyStateFast(e, t, n) {
|
|
|
4157
4134
|
s !== e.length && i?.length && setSignal(i.length, e.length);
|
|
4158
4135
|
return;
|
|
4159
4136
|
}
|
|
4160
|
-
|
|
4137
|
+
S = new Array(f + 1);
|
|
4161
4138
|
for (l = f; l >= c; l--) {
|
|
4162
4139
|
E = e[l];
|
|
4163
|
-
|
|
4164
|
-
u = p.get(
|
|
4165
|
-
|
|
4166
|
-
p.set(
|
|
4140
|
+
d = itemKey(E, n);
|
|
4141
|
+
u = p.get(d);
|
|
4142
|
+
S[l] = u === undefined ? -1 : u;
|
|
4143
|
+
p.set(d, l);
|
|
4167
4144
|
}
|
|
4168
4145
|
for (u = c; u <= a; u++) {
|
|
4169
4146
|
E = r[u];
|
|
4170
|
-
|
|
4171
|
-
l = p.get(
|
|
4147
|
+
d = itemKey(E, n);
|
|
4148
|
+
l = p.get(d);
|
|
4172
4149
|
if (l !== undefined && l !== -1) {
|
|
4173
4150
|
T[l] = E;
|
|
4174
|
-
l =
|
|
4175
|
-
p.set(
|
|
4151
|
+
l = S[l];
|
|
4152
|
+
p.set(d, l);
|
|
4176
4153
|
}
|
|
4177
4154
|
}
|
|
4178
4155
|
for (l = c; l < e.length; l++) {
|
|
@@ -4241,17 +4218,17 @@ function applyStateSlow(e, t, n) {
|
|
|
4241
4218
|
let u = false;
|
|
4242
4219
|
const l = getOverrideValue(r, i, "length", o);
|
|
4243
4220
|
if (e.length && l && isWrappable(e[0]) && n(e[0]) != null) {
|
|
4244
|
-
let c, a, f, E,
|
|
4245
|
-
for (f = 0, E = Math.min(l, e.length); f < E && keyedMatch(
|
|
4246
|
-
isWrappable(
|
|
4221
|
+
let c, a, f, E, S, d, T, p;
|
|
4222
|
+
for (f = 0, E = Math.min(l, e.length); f < E && keyedMatch(d = getOverrideValue(r, i, f, o), e[f], n); f++) {
|
|
4223
|
+
isWrappable(d) && isWrappable(e[f]) && applyState(e[f], wrap(d, t), n);
|
|
4247
4224
|
}
|
|
4248
4225
|
const _ = new Array(e.length), O = new Map;
|
|
4249
|
-
for (E = l - 1,
|
|
4250
|
-
|
|
4251
|
-
_[
|
|
4226
|
+
for (E = l - 1, S = e.length - 1; E >= f && S >= f && keyedMatch(d = getOverrideValue(r, i, E, o), e[S], n); E--,
|
|
4227
|
+
S--) {
|
|
4228
|
+
_[S] = d;
|
|
4252
4229
|
}
|
|
4253
|
-
if (f >
|
|
4254
|
-
for (a = f; a <=
|
|
4230
|
+
if (f > S || f > E) {
|
|
4231
|
+
for (a = f; a <= S; a++) {
|
|
4255
4232
|
u = true;
|
|
4256
4233
|
s?.[a] && setSignal(s[a], wrapValue(e[a], t));
|
|
4257
4234
|
}
|
|
@@ -4265,20 +4242,20 @@ function applyStateSlow(e, t, n) {
|
|
|
4265
4242
|
l !== r && s?.length && setSignal(s.length, r);
|
|
4266
4243
|
return;
|
|
4267
4244
|
}
|
|
4268
|
-
T = new Array(
|
|
4269
|
-
for (a =
|
|
4270
|
-
|
|
4271
|
-
p = itemKey(
|
|
4245
|
+
T = new Array(S + 1);
|
|
4246
|
+
for (a = S; a >= f; a--) {
|
|
4247
|
+
d = e[a];
|
|
4248
|
+
p = itemKey(d, n);
|
|
4272
4249
|
c = O.get(p);
|
|
4273
4250
|
T[a] = c === undefined ? -1 : c;
|
|
4274
4251
|
O.set(p, a);
|
|
4275
4252
|
}
|
|
4276
4253
|
for (c = f; c <= E; c++) {
|
|
4277
|
-
|
|
4278
|
-
p = itemKey(
|
|
4254
|
+
d = getOverrideValue(r, i, c, o);
|
|
4255
|
+
p = itemKey(d, n);
|
|
4279
4256
|
a = O.get(p);
|
|
4280
4257
|
if (a !== undefined && a !== -1) {
|
|
4281
|
-
_[a] =
|
|
4258
|
+
_[a] = d;
|
|
4282
4259
|
a = T[a];
|
|
4283
4260
|
O.set(p, a);
|
|
4284
4261
|
}
|
|
@@ -4316,12 +4293,12 @@ function applyStateSlow(e, t, n) {
|
|
|
4316
4293
|
const a = l[c];
|
|
4317
4294
|
const f = s[a];
|
|
4318
4295
|
const E = unwrap(getOverrideValue(r, i, a, o));
|
|
4319
|
-
let
|
|
4320
|
-
if (E ===
|
|
4321
|
-
if (!E || !isWrappable(E) || !isWrappable(
|
|
4296
|
+
let S = unwrap(e[a]);
|
|
4297
|
+
if (E === S) continue;
|
|
4298
|
+
if (!E || !isWrappable(E) || !isWrappable(S) || Array.isArray(E) !== Array.isArray(S) || n(E) != null && n(E) !== n(S)) {
|
|
4322
4299
|
u && setSignal(u, void 0);
|
|
4323
|
-
f && setSignal(f, isWrappable(
|
|
4324
|
-
} else applyState(
|
|
4300
|
+
f && setSignal(f, isWrappable(S) ? wrap(S, t) : S);
|
|
4301
|
+
} else applyState(S, wrap(E, t), n);
|
|
4325
4302
|
}
|
|
4326
4303
|
}
|
|
4327
4304
|
if (!u && t[STORE_DESC]) applyDescendants(r, e, t, s, n, i, o);
|
|
@@ -4391,7 +4368,7 @@ function createProjectionInternal(e, t, n) {
|
|
|
4391
4368
|
if (!r) r = getOwner();
|
|
4392
4369
|
runProjectionComputed(o, e, n?.key || "id");
|
|
4393
4370
|
}, undefined);
|
|
4394
|
-
r.
|
|
4371
|
+
r.ke &= ~CONFIG_AUTO_DISPOSE;
|
|
4395
4372
|
return {
|
|
4396
4373
|
store: o,
|
|
4397
4374
|
node: r
|
|
@@ -4460,7 +4437,7 @@ function createProjectionInternal(e, t, n) {
|
|
|
4460
4437
|
const o = getOwner();
|
|
4461
4438
|
let s = false;
|
|
4462
4439
|
let u;
|
|
4463
|
-
const l = new Proxy(e, createWriteTraps(() => !s || o.
|
|
4440
|
+
const l = new Proxy(e, createWriteTraps(() => !s || o.lt === u, i));
|
|
4464
4441
|
storeSetter(l, i => {
|
|
4465
4442
|
u = t(i);
|
|
4466
4443
|
s = true;
|
|
@@ -4667,7 +4644,7 @@ function ownEnumerableKeysPlain(e) {
|
|
|
4667
4644
|
* The value a store leaf's backing signal currently shows to readers: active
|
|
4668
4645
|
* override, else held pending value, else committed value.
|
|
4669
4646
|
*/ function visibleNodeValue(e) {
|
|
4670
|
-
return e.A !== undefined && e.A !== NOT_PENDING ? unwrapOverride(e.A) : e.V !== NOT_PENDING ? e.V : e.
|
|
4647
|
+
return e.A !== undefined && e.A !== NOT_PENDING ? unwrapOverride(e.A) : e.V !== NOT_PENDING ? e.V : e.xe;
|
|
4671
4648
|
}
|
|
4672
4649
|
|
|
4673
4650
|
function hasOwnStoreProperty(e, t) {
|
|
@@ -4722,7 +4699,7 @@ function getNode(e, t, n, r, i = isEqual, o) {
|
|
|
4722
4699
|
}
|
|
4723
4700
|
if (o && n in o) {
|
|
4724
4701
|
const e = o[n];
|
|
4725
|
-
s.
|
|
4702
|
+
s.we = e === undefined ? NO_SNAPSHOT : e;
|
|
4726
4703
|
snapshotSources?.add(s);
|
|
4727
4704
|
}
|
|
4728
4705
|
if (typeof n === "symbol" && n !== $TRACK && n !== $AFFECTS) symbolKeyedRecords.add(t);
|
|
@@ -4752,7 +4729,7 @@ function getNode(e, t, n, r, i = isEqual, o) {
|
|
|
4752
4729
|
// A live scope exists, so affects.ts already installed the mark engine.
|
|
4753
4730
|
for (const [r, i] of affectsScopes) {
|
|
4754
4731
|
if (r.F && i.scope.has(t) && (i.key === undefined || i.key === n)) {
|
|
4755
|
-
GlobalQueue.
|
|
4732
|
+
GlobalQueue.ie(e);
|
|
4756
4733
|
i.inherited.push(e);
|
|
4757
4734
|
}
|
|
4758
4735
|
}
|
|
@@ -4840,11 +4817,11 @@ i) {
|
|
|
4840
4817
|
// Callers guard on `pendingCheckActive`, which only flips inside
|
|
4841
4818
|
// isPending() — the verdict layer is loaded and its hook installed.
|
|
4842
4819
|
const n = e[STORE_NODE]?.[$AFFECTS];
|
|
4843
|
-
if (n?.F) GlobalQueue.
|
|
4820
|
+
if (n?.F) GlobalQueue._e(n);
|
|
4844
4821
|
if (affectsScopes.size) {
|
|
4845
4822
|
const r = e[STORE_VALUE];
|
|
4846
4823
|
for (const [e, i] of affectsScopes) {
|
|
4847
|
-
if (e !== n && e.F && i.scope.has(r) && (i.key === undefined || i.key === t)) GlobalQueue.
|
|
4824
|
+
if (e !== n && e.F && i.scope.has(r) && (i.key === undefined || i.key === t)) GlobalQueue._e(e);
|
|
4848
4825
|
}
|
|
4849
4826
|
}
|
|
4850
4827
|
}
|
|
@@ -4865,7 +4842,7 @@ i) {
|
|
|
4865
4842
|
const t = affectsScopes.get(e);
|
|
4866
4843
|
if (!t) return;
|
|
4867
4844
|
affectsScopes.delete(e);
|
|
4868
|
-
for (let e = 0; e < t.inherited.length; e++) GlobalQueue.
|
|
4845
|
+
for (let e = 0; e < t.inherited.length; e++) GlobalQueue.oe(t.inherited[e]);
|
|
4869
4846
|
};
|
|
4870
4847
|
if (t === undefined) {
|
|
4871
4848
|
const t = getNode(e, n, $AFFECTS, undefined, false);
|
|
@@ -4992,7 +4969,7 @@ function prepareStoreWrite(e, t, n) {
|
|
|
4992
4969
|
}
|
|
4993
4970
|
const r = e[STORE_VALUE];
|
|
4994
4971
|
const i = r[n];
|
|
4995
|
-
if (snapshotCaptureActive && typeof n !== "symbol" && !((e[STORE_FIREWALL]
|
|
4972
|
+
if (snapshotCaptureActive && typeof n !== "symbol" && !((e[STORE_FIREWALL]?.We ?? 0) & STATUS_PENDING)) {
|
|
4996
4973
|
if (!e[STORE_SNAPSHOT_PROPS]) {
|
|
4997
4974
|
e[STORE_SNAPSHOT_PROPS] = Object.create(null);
|
|
4998
4975
|
snapshotSources?.add(e);
|
|
@@ -5020,7 +4997,7 @@ function prepareStoreWrite(e, t, n) {
|
|
|
5020
4997
|
// STORE_OPTIMISTIC is only set by createOptimisticStore, which installs the
|
|
5021
4998
|
// optimistic engine before wrapping.
|
|
5022
4999
|
if (e[STORE_OPTIMISTIC] && !projectionWriteActive) {
|
|
5023
|
-
GlobalQueue.
|
|
5000
|
+
GlobalQueue.De(t);
|
|
5024
5001
|
}
|
|
5025
5002
|
}
|
|
5026
5003
|
|
|
@@ -5093,7 +5070,7 @@ let Writing = null;
|
|
|
5093
5070
|
* itself (the derive function works its own draft while uninitialized).
|
|
5094
5071
|
*/ function throwIfUninitialized(e) {
|
|
5095
5072
|
const t = e[STORE_FIREWALL];
|
|
5096
|
-
if (t && t
|
|
5073
|
+
if (t && t.We & STATUS_UNINITIALIZED) throw t.me ?? new NotReadyError(t);
|
|
5097
5074
|
}
|
|
5098
5075
|
|
|
5099
5076
|
const storeTraps = {
|
|
@@ -5186,9 +5163,9 @@ const storeTraps = {
|
|
|
5186
5163
|
// throws). #2769
|
|
5187
5164
|
const f = typeof t === "string" ? Number(t) : -1;
|
|
5188
5165
|
const E = Array.isArray(s) && Number.isInteger(f) && f >= 0 && f < 4294967295 && String(f) === t;
|
|
5189
|
-
const
|
|
5190
|
-
const
|
|
5191
|
-
const T = E &&
|
|
5166
|
+
const S = E ? f + 1 : 0;
|
|
5167
|
+
const d = E && (getOverlayLayer(e, "length") ?? s).length;
|
|
5168
|
+
const T = E && S > d ? S : undefined;
|
|
5192
5169
|
if (l === a && T === undefined) return true;
|
|
5193
5170
|
armOptimisticStoreWrite(e, r);
|
|
5194
5171
|
if (a !== undefined && a === i && T === undefined) {
|
|
@@ -5224,7 +5201,7 @@ const storeTraps = {
|
|
|
5224
5201
|
if (t.length) {
|
|
5225
5202
|
setSignal(t.length, T);
|
|
5226
5203
|
} else if (!projectionWriteActive && !e[STORE_OPTIMISTIC]) {
|
|
5227
|
-
const n = upsertStoreNode(e, t, "length",
|
|
5204
|
+
const n = upsertStoreNode(e, t, "length", d, e[STORE_SNAPSHOT_PROPS]);
|
|
5228
5205
|
setSignal(n, T);
|
|
5229
5206
|
}
|
|
5230
5207
|
}
|
|
@@ -5380,126 +5357,76 @@ function createStore(e, t, n) {
|
|
|
5380
5357
|
} : e => storeSetter(i, e) ];
|
|
5381
5358
|
}
|
|
5382
5359
|
|
|
5383
|
-
/**
|
|
5384
|
-
* The pending-source identity of a live `affects()` mark on `node` (lazy,
|
|
5385
|
-
* one per node, shared by overlapping registrations via the refcount).
|
|
5386
|
-
*
|
|
5387
|
-
* A mark rides the SAME status rails as real in-flight async — downstream
|
|
5388
|
-
* subscribers hold the sentinel in `_pendingSources` — but under its own
|
|
5389
|
-
* identity so the two channels can't clear each other:
|
|
5390
|
-
* - `_reask` is permanently `false`: a mark is by definition a declared
|
|
5391
|
-
* value change, so `quietPending` never silences a window it participates
|
|
5392
|
-
* in — even when the mark rides over an otherwise-quiet `refresh()`
|
|
5393
|
-
* re-ask of the same node (the whole point of declaring one).
|
|
5394
|
-
* - A landing on the marked node settles only the node's OWN source entry;
|
|
5395
|
-
* the sentinel entry survives until the mark's transaction releases it.
|
|
5396
|
-
* - The sentinel itself never carries `STATUS_PENDING`, so
|
|
5397
|
-
* `transitionComplete` never counts a mark as a blocker of its own
|
|
5398
|
-
* transaction (release happens AT settle — self-blocking would deadlock),
|
|
5399
|
-
* and reads of the marked node never throw (marks are value-transparent
|
|
5400
|
-
* at the source; pendingness is what propagates).
|
|
5401
|
-
*/ function getAffectsSentinel(e) {
|
|
5402
|
-
return e.Vt ??= {
|
|
5403
|
-
Qt: undefined,
|
|
5404
|
-
// Brand + backref: lets the scheduler's settlement checks recognize
|
|
5405
|
-
// mark-sourced pending (which must never block its own transaction —
|
|
5406
|
-
// release happens AT settle).
|
|
5407
|
-
Dt: e,
|
|
5408
|
-
Qe: 0,
|
|
5409
|
-
$e: 0,
|
|
5410
|
-
gt: false,
|
|
5411
|
-
Ue: undefined,
|
|
5412
|
-
k: null,
|
|
5413
|
-
Ze: null
|
|
5414
|
-
};
|
|
5415
|
-
}
|
|
5416
|
-
|
|
5417
|
-
/**
|
|
5418
|
-
* Push a live mark's pendingness downstream from the marked node through the
|
|
5419
|
-
* normal status rails. Runs on every registration (dedup in `notifyStatus`
|
|
5420
|
-
* stops re-descent at already-covered subscribers). Subscribers that
|
|
5421
|
-
* recompute mid-window shed this via `clearStatus` and re-acquire it through
|
|
5422
|
-
* the read path (`applyAffectsReads` for direct readers of the marked node,
|
|
5423
|
-
* `collectMarkSources` transitively) — the mark analogue of real async's
|
|
5424
|
-
* re-throw-on-read. Subscribers are deliberately NOT queued as pending nodes
|
|
5425
|
-
* (#2893): they hold no value needing a transition-scheduled commit, and
|
|
5426
|
-
* queueing would stamp the marking action's transaction onto them — from then
|
|
5427
|
-
* on ANY write dirtying one of them (including writes to unmarked signals
|
|
5428
|
-
* that merely share a downstream memo) would be captured and frozen until the
|
|
5429
|
-
* action settles.
|
|
5430
|
-
*/ function propagateAffectsMark(e) {
|
|
5431
|
-
if (!e.k && !e.ut) return;
|
|
5432
|
-
const t = getAffectsSentinel(e);
|
|
5433
|
-
const n = new NotReadyError(t);
|
|
5434
|
-
forEachDependent(e, e => {
|
|
5435
|
-
if (!e.Be?.has(t)) {
|
|
5436
|
-
notifyStatus(e, STATUS_PENDING, n);
|
|
5437
|
-
}
|
|
5438
|
-
});
|
|
5439
|
-
}
|
|
5440
|
-
|
|
5441
|
-
/**
|
|
5442
|
-
* Re-establish mark pendingness on a computed that read marked sources
|
|
5443
|
-
* during its recompute (`clearStatus` at the top of the commit path wiped
|
|
5444
|
-
* any sentinel entries it held). Called by `recompute` after the commit —
|
|
5445
|
-
* not before, because setting `_error` earlier would make the commit path
|
|
5446
|
-
* treat the node as errored and skip the value write.
|
|
5447
|
-
*/ function applyAffectsReads(e, t) {
|
|
5448
|
-
let n = false;
|
|
5449
|
-
for (let r = 0; r < t.length; r++) {
|
|
5450
|
-
const i = t[r];
|
|
5451
|
-
if (!i.F) continue;
|
|
5452
|
-
const o = getAffectsSentinel(i);
|
|
5453
|
-
if (addPendingSource(e, o)) {
|
|
5454
|
-
e.$e |= STATUS_PENDING;
|
|
5455
|
-
setPendingError(e, o);
|
|
5456
|
-
n = true;
|
|
5457
|
-
}
|
|
5458
|
-
}
|
|
5459
|
-
if (n && GlobalQueue.Ee !== null) GlobalQueue.Ee(e);
|
|
5460
|
-
}
|
|
5461
|
-
|
|
5462
5360
|
/**
|
|
5463
5361
|
* The counting half of a mark, shared by direct registration and store-scope
|
|
5464
|
-
* inheritance (a node created inside a live keyless mark's identity scope)
|
|
5465
|
-
*
|
|
5466
|
-
*
|
|
5362
|
+
* inheritance (a node created inside a live keyless mark's identity scope).
|
|
5363
|
+
* A mark is ONLY this count: coverage of everything derived from the node is
|
|
5364
|
+
* pull-derived by the verdict layer's `markWalk` (dep-graph reachability), so
|
|
5365
|
+
* nothing is stored downstream and nothing can be stranded or stripped by
|
|
5366
|
+
* mid-window recomputes.
|
|
5467
5367
|
*/ function markAffects(e) {
|
|
5468
5368
|
e.F = (e.F || 0) + 1;
|
|
5469
5369
|
shiftAffectsMarks(1);
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5370
|
+
}
|
|
5371
|
+
|
|
5372
|
+
/**
|
|
5373
|
+
* Boundary visual channel: within a transaction, a live mark holds Loading
|
|
5374
|
+
* fallbacks / reveal ordering the way real in-flight async would — but the
|
|
5375
|
+
* notification is tagged visibility-only at the source (`_markVisual`), so
|
|
5376
|
+
* the root queue never registers reporters from it: marks are invisible to
|
|
5377
|
+
* ALL completion and settlement accounting by construction. Boundaries hold
|
|
5378
|
+
* the marked node in `_sources` while `_affectsCount` is live; the release
|
|
5379
|
+
* sweep (finalizePureQueue re-checks boundary children after mark release)
|
|
5380
|
+
* is the display-state update point. Ambient marks release inside the same
|
|
5381
|
+
* flush that would surface them, before effects run — verdict-only, netting
|
|
5382
|
+
* no visual change.
|
|
5383
|
+
*/ function notifyMarkBoundaries(e) {
|
|
5384
|
+
if (!e.k && !e.rt) return;
|
|
5385
|
+
const t = new NotReadyError(e);
|
|
5386
|
+
t.ve = true;
|
|
5387
|
+
const n = new Set;
|
|
5388
|
+
const visit = e => {
|
|
5389
|
+
if (n.has(e)) return;
|
|
5390
|
+
n.add(e);
|
|
5391
|
+
// Display consumers (render effects, boundary computeds) act on the
|
|
5392
|
+
// notification; descent stops there, exactly like the status rails.
|
|
5393
|
+
if (e.yt) {
|
|
5394
|
+
e.yt(STATUS_PENDING, t);
|
|
5395
|
+
return;
|
|
5396
|
+
}
|
|
5397
|
+
forEachDependent(e, visit);
|
|
5398
|
+
};
|
|
5399
|
+
forEachDependent(e, visit);
|
|
5473
5400
|
}
|
|
5474
5401
|
|
|
5475
5402
|
/**
|
|
5476
5403
|
* Registers one `affects()` mark on a node: counts it, records the
|
|
5477
5404
|
* registration with the current transaction (after initTransition the queue's
|
|
5478
|
-
* batch IS the active transition, mirroring `_optimisticNodes`),
|
|
5479
|
-
*
|
|
5480
|
-
*
|
|
5481
|
-
* registration (not just the first): subscribers gained since an
|
|
5482
|
-
* overlapping registration get covered, and dedup stops re-descent
|
|
5405
|
+
* batch IS the active transition, mirroring `_optimisticNodes`), re-derives
|
|
5406
|
+
* every downstream verdict companion (the mark channel's only push — verdict
|
|
5407
|
+
* pokes, not state), and notifies boundary display state. Both walks run on
|
|
5408
|
+
* every registration (not just the first): subscribers gained since an
|
|
5409
|
+
* earlier overlapping registration get covered, and dedup stops re-descent.
|
|
5483
5410
|
*/ function registerAffectsMark(e) {
|
|
5484
5411
|
markAffects(e);
|
|
5485
5412
|
globalQueue.D.L.push(e);
|
|
5486
|
-
|
|
5413
|
+
// Companions only exist once the verdict layer (isPending/latest) loaded;
|
|
5414
|
+
// without them there is no materialized verdict to poke.
|
|
5415
|
+
GlobalQueue.pe !== null && GlobalQueue.pe(e);
|
|
5416
|
+
notifyMarkBoundaries(e);
|
|
5487
5417
|
schedule();
|
|
5488
5418
|
}
|
|
5489
5419
|
|
|
5490
5420
|
/**
|
|
5491
|
-
* Releases one registration. When the node's last mark drops,
|
|
5492
|
-
*
|
|
5493
|
-
*
|
|
5494
|
-
*
|
|
5495
|
-
* can't open a fresh override window that would itself need settlement.
|
|
5421
|
+
* Releases one registration. When the node's last mark drops, re-derives
|
|
5422
|
+
* every downstream verdict through the settlement snap (committed, not
|
|
5423
|
+
* transition-scoped — release runs inside queue finalization, where a
|
|
5424
|
+
* setSignal would open a fresh override window that nothing settles).
|
|
5496
5425
|
*/ function releaseAffectsMark(e) {
|
|
5497
5426
|
shiftAffectsMarks(-1);
|
|
5498
5427
|
e.F--;
|
|
5499
5428
|
if (!e.F) {
|
|
5500
|
-
|
|
5501
|
-
if (t) settlePendingSource(e, t, true);
|
|
5502
|
-
GlobalQueue.Se !== null && GlobalQueue.Se(e);
|
|
5429
|
+
GlobalQueue.pe !== null && GlobalQueue.pe(e, true);
|
|
5503
5430
|
GlobalQueue.ne?.(e);
|
|
5504
5431
|
}
|
|
5505
5432
|
}
|
|
@@ -5512,58 +5439,16 @@ function createStore(e, t, n) {
|
|
|
5512
5439
|
e.length = 0;
|
|
5513
5440
|
}
|
|
5514
5441
|
|
|
5515
|
-
/**
|
|
5516
|
-
* True when a node's pending status comes ONLY from affects() sentinels. A
|
|
5517
|
-
* mark is a promise of change, not an absence of value: reads of mark-pended
|
|
5518
|
-
* derived nodes stay value-transparent (verdicts report pending; the read
|
|
5519
|
-
* path must not suspend). Any real async source among the pending sources
|
|
5520
|
-
* keeps normal suspension semantics. Core's read path reaches this through
|
|
5521
|
-
* `GlobalQueue._onlyMarkPending`, gated on the `activeAffectsMarks` counter.
|
|
5522
|
-
*/ function onlyMarkPending(e) {
|
|
5523
|
-
const t = e.Be;
|
|
5524
|
-
if (t) {
|
|
5525
|
-
for (const e of t) if (!e.Dt) return false;
|
|
5526
|
-
return true;
|
|
5527
|
-
}
|
|
5528
|
-
return false;
|
|
5529
|
-
}
|
|
5530
|
-
|
|
5531
|
-
/**
|
|
5532
|
-
* Collect the still-live marked nodes behind a pended owner's sentinel
|
|
5533
|
-
* sources into a recompute's `affectsReads`. This is the transitive half of
|
|
5534
|
-
* read-path re-establishment (#2893): real async re-establishes at every
|
|
5535
|
-
* derivation level because its re-throw on read re-registers the source, but
|
|
5536
|
-
* mark-pended reads are value-transparent — without this, pendingness dies on
|
|
5537
|
-
* the first mid-window recompute past depth one, and the isPending() probe
|
|
5538
|
-
* itself (whose prepare step recomputes retryable NotReady holders) strips
|
|
5539
|
-
* the very status it reports on. Reached through
|
|
5540
|
-
* `GlobalQueue._collectMarkSources`, gated on `activeAffectsMarks`.
|
|
5541
|
-
*/ function collectMarkSources(e, t) {
|
|
5542
|
-
if (e.Be) {
|
|
5543
|
-
for (const n of e.Be) {
|
|
5544
|
-
const e = n.Dt;
|
|
5545
|
-
if (e && e.F) t.push(e);
|
|
5546
|
-
}
|
|
5547
|
-
}
|
|
5548
|
-
}
|
|
5549
|
-
|
|
5550
5442
|
// Late installation (same pattern as `GlobalQueue._update`): the mark engine
|
|
5551
5443
|
// lives with the feature so graphs that never declare a mark never ship it.
|
|
5552
|
-
// Each call site is gated by state only this module creates (
|
|
5553
|
-
//
|
|
5554
|
-
//
|
|
5555
|
-
|
|
5556
|
-
GlobalQueue.re = applyAffectsReads;
|
|
5557
|
-
|
|
5558
|
-
GlobalQueue.ie = releaseAffectsMarks;
|
|
5559
|
-
|
|
5560
|
-
GlobalQueue.oe = markAffects;
|
|
5561
|
-
|
|
5562
|
-
GlobalQueue.se = releaseAffectsMark;
|
|
5444
|
+
// Each call site is gated by state only this module creates (a non-empty
|
|
5445
|
+
// `_affectsNodes` batch, a live scope in the store's `affectsScopes`), so the
|
|
5446
|
+
// hooks are installed before the first time any of them can fire.
|
|
5447
|
+
GlobalQueue.re = releaseAffectsMarks;
|
|
5563
5448
|
|
|
5564
|
-
GlobalQueue.
|
|
5449
|
+
GlobalQueue.ie = markAffects;
|
|
5565
5450
|
|
|
5566
|
-
GlobalQueue.
|
|
5451
|
+
GlobalQueue.oe = releaseAffectsMark;
|
|
5567
5452
|
|
|
5568
5453
|
function affects(e, t) {
|
|
5569
5454
|
const n = e?.[$TARGET];
|
|
@@ -5663,8 +5548,8 @@ function clearOptimisticStores(e, t) {
|
|
|
5663
5548
|
c.A = NOT_PENDING;
|
|
5664
5549
|
c.R = null;
|
|
5665
5550
|
c.V = NOT_PENDING;
|
|
5666
|
-
c.
|
|
5667
|
-
if (!c.
|
|
5551
|
+
c.xe = i;
|
|
5552
|
+
if (!c.ht || !c.ht(o, i)) {
|
|
5668
5553
|
insertSubs(c, true);
|
|
5669
5554
|
schedule();
|
|
5670
5555
|
}
|
|
@@ -5736,7 +5621,7 @@ function createOptimisticProjectionInternal(e, t, n) {
|
|
|
5736
5621
|
setProjectionWriteActive(false);
|
|
5737
5622
|
}
|
|
5738
5623
|
}, undefined);
|
|
5739
|
-
r.
|
|
5624
|
+
r.ke &= ~CONFIG_AUTO_DISPOSE;
|
|
5740
5625
|
}
|
|
5741
5626
|
return {
|
|
5742
5627
|
store: o,
|
|
@@ -6148,24 +6033,24 @@ function mapArray(e, t, n) {
|
|
|
6148
6033
|
const i = t.length > 1;
|
|
6149
6034
|
const o = t;
|
|
6150
6035
|
const s = {
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6036
|
+
wt: createOwner(),
|
|
6037
|
+
Gt: 0,
|
|
6038
|
+
Lt: e,
|
|
6039
|
+
Ut: [],
|
|
6040
|
+
kt: o,
|
|
6041
|
+
Vt: [],
|
|
6042
|
+
xt: [],
|
|
6043
|
+
Qt: r,
|
|
6044
|
+
Ft: r || n?.keyed === false ? [] : undefined,
|
|
6045
|
+
Wt: i && n?.keyed !== false ? [] : undefined,
|
|
6046
|
+
Mt: n?.keyed === false,
|
|
6047
|
+
Ht: n?.fallback
|
|
6163
6048
|
};
|
|
6164
6049
|
const u = computed(updateKeyedMap.bind(s));
|
|
6165
6050
|
// Untracked reads inside the internal owner resolve via _parentComputed; routing
|
|
6166
6051
|
// them through node lets store-proxy lookups see pending writes (not stale _value).
|
|
6167
|
-
s.
|
|
6168
|
-
u.
|
|
6052
|
+
s.wt.et = u;
|
|
6053
|
+
u.ke &= ~CONFIG_AUTO_DISPOSE;
|
|
6169
6054
|
return accessor(u);
|
|
6170
6055
|
}
|
|
6171
6056
|
|
|
@@ -6183,52 +6068,52 @@ const pureOptions = {
|
|
|
6183
6068
|
// strong-abort ordering: removed rows now dispose AFTER the pass's new rows
|
|
6184
6069
|
// are created (you cannot destroy state before knowing the pass will land).
|
|
6185
6070
|
function updateKeyedMap() {
|
|
6186
|
-
const e = this.
|
|
6071
|
+
const e = this.Lt() || [], t = e.length;
|
|
6187
6072
|
e[$TRACK];
|
|
6188
6073
|
// top level tracking
|
|
6189
|
-
runWithOwner(this.
|
|
6074
|
+
runWithOwner(this.wt, () => {
|
|
6190
6075
|
let n, r, i, o,
|
|
6191
6076
|
// Mappers write freshly-created row/index signals into the STAGE
|
|
6192
6077
|
// arrays (`rows`/`indexes`), never into `this._rows`/`this._indexes`.
|
|
6193
|
-
s = this.
|
|
6078
|
+
s = this.Ft ? this.Mt ? () => {
|
|
6194
6079
|
i[r] = signal(e[r], pureOptions);
|
|
6195
|
-
return this.
|
|
6080
|
+
return this.kt(accessor(i[r]), r);
|
|
6196
6081
|
} : () => {
|
|
6197
6082
|
i[r] = signal(e[r], pureOptions);
|
|
6198
6083
|
o && (o[r] = signal(r, pureOptions));
|
|
6199
|
-
return this.
|
|
6200
|
-
} : this.
|
|
6084
|
+
return this.kt(accessor(i[r]), o ? accessor(o[r]) : undefined);
|
|
6085
|
+
} : this.Wt ? () => {
|
|
6201
6086
|
const t = e[r];
|
|
6202
6087
|
o[r] = signal(r, pureOptions);
|
|
6203
|
-
return this.
|
|
6088
|
+
return this.kt(t, accessor(o[r]));
|
|
6204
6089
|
} : () => {
|
|
6205
6090
|
const t = e[r];
|
|
6206
|
-
return this.
|
|
6091
|
+
return this.kt(t);
|
|
6207
6092
|
};
|
|
6208
6093
|
// fast path for empty arrays
|
|
6209
6094
|
if (t === 0) {
|
|
6210
|
-
if (this.
|
|
6211
|
-
this.
|
|
6212
|
-
this
|
|
6213
|
-
this.
|
|
6214
|
-
this.
|
|
6215
|
-
this.
|
|
6216
|
-
this.
|
|
6217
|
-
this.
|
|
6095
|
+
if (this.Gt !== 0) {
|
|
6096
|
+
this.wt.dispose(false);
|
|
6097
|
+
this.xt = [];
|
|
6098
|
+
this.Ut = [];
|
|
6099
|
+
this.Vt = [];
|
|
6100
|
+
this.Gt = 0;
|
|
6101
|
+
this.Ft && (this.Ft = []);
|
|
6102
|
+
this.Wt && (this.Wt = []);
|
|
6218
6103
|
}
|
|
6219
|
-
if (this.
|
|
6104
|
+
if (this.Ht && !this.Vt[0]) {
|
|
6220
6105
|
// an aborted fallback attempt leaves an owner without a mapping;
|
|
6221
6106
|
// dispose it before re-creating
|
|
6222
|
-
this
|
|
6223
|
-
this.
|
|
6107
|
+
this.xt[0]?.dispose();
|
|
6108
|
+
this.Vt[0] = runWithOwner(this.xt[0] = createOwner(), this.Ht);
|
|
6224
6109
|
}
|
|
6225
6110
|
}
|
|
6226
6111
|
// fast path for new create
|
|
6227
|
-
else if (this.
|
|
6112
|
+
else if (this.Gt === 0) {
|
|
6228
6113
|
const u = new Array(t);
|
|
6229
6114
|
const l = new Array(t);
|
|
6230
|
-
i = this.
|
|
6231
|
-
o = this.
|
|
6115
|
+
i = this.Ft && new Array(t);
|
|
6116
|
+
o = this.Wt && new Array(t);
|
|
6232
6117
|
try {
|
|
6233
6118
|
for (r = 0; r < t; r++) u[r] = runWithOwner(l[r] = createOwner(), s);
|
|
6234
6119
|
} catch (e) {
|
|
@@ -6236,53 +6121,53 @@ function updateKeyedMap() {
|
|
|
6236
6121
|
throw e;
|
|
6237
6122
|
}
|
|
6238
6123
|
// commit
|
|
6239
|
-
if (this
|
|
6124
|
+
if (this.xt[0]) this.xt[0].dispose();
|
|
6240
6125
|
// previous fallback
|
|
6241
|
-
this.
|
|
6242
|
-
this
|
|
6243
|
-
i && (this.
|
|
6244
|
-
o && (this.
|
|
6245
|
-
this.
|
|
6246
|
-
this.
|
|
6126
|
+
this.Vt = u;
|
|
6127
|
+
this.xt = l;
|
|
6128
|
+
i && (this.Ft = i);
|
|
6129
|
+
o && (this.Wt = o);
|
|
6130
|
+
this.Ut = e.slice(0);
|
|
6131
|
+
this.Gt = t;
|
|
6247
6132
|
} else {
|
|
6248
|
-
let u, l, c, a, f, E,
|
|
6249
|
-
i = this.
|
|
6250
|
-
o = this.
|
|
6133
|
+
let u, l, c, a, f, E, S, d, T, p = new Array(t), _ = new Array(t);
|
|
6134
|
+
i = this.Ft ? new Array(t) : undefined;
|
|
6135
|
+
o = this.Wt ? new Array(t) : undefined;
|
|
6251
6136
|
// skip common prefix
|
|
6252
|
-
for (u = 0, l = Math.min(this.
|
|
6253
|
-
if (this.
|
|
6137
|
+
for (u = 0, l = Math.min(this.Gt, t); u < l && (this.Ut[u] === e[u] || this.Ft && compare(this.Qt, this.Ut[u], e[u])); u++) {
|
|
6138
|
+
if (this.Ft) setSignal(this.Ft[u], e[u]);
|
|
6254
6139
|
}
|
|
6255
6140
|
// common suffix
|
|
6256
|
-
for (l = this.
|
|
6141
|
+
for (l = this.Gt - 1, c = t - 1; l >= u && c >= u && (this.Ut[l] === e[c] || this.Ft && compare(this.Qt, this.Ut[l], e[c])); l--,
|
|
6257
6142
|
c--) {
|
|
6258
|
-
p[c] = this.
|
|
6259
|
-
_[c] = this
|
|
6260
|
-
i && (i[c] = this.
|
|
6261
|
-
o && (o[c] = this.
|
|
6143
|
+
p[c] = this.Vt[l];
|
|
6144
|
+
_[c] = this.xt[l];
|
|
6145
|
+
i && (i[c] = this.Ft[l]);
|
|
6146
|
+
o && (o[c] = this.Wt[l]);
|
|
6262
6147
|
}
|
|
6263
6148
|
// 0) prepare a map of all indices in newItems, scanning backwards so we encounter them in natural order
|
|
6264
6149
|
E = new Map;
|
|
6265
|
-
|
|
6150
|
+
S = new Array(c + 1);
|
|
6266
6151
|
for (r = c; r >= u; r--) {
|
|
6267
6152
|
a = e[r];
|
|
6268
|
-
f = this.
|
|
6153
|
+
f = this.Qt ? this.Qt(a) : a;
|
|
6269
6154
|
n = E.get(f);
|
|
6270
|
-
|
|
6155
|
+
S[r] = n === undefined ? -1 : n;
|
|
6271
6156
|
E.set(f, r);
|
|
6272
6157
|
}
|
|
6273
6158
|
// 1) step through all old items and see if they can be found in the new set; if so, save them in a temp array and mark them moved; if not, queue them for disposal at commit
|
|
6274
6159
|
for (n = u; n <= l; n++) {
|
|
6275
|
-
a = this.
|
|
6276
|
-
f = this.
|
|
6160
|
+
a = this.Ut[n];
|
|
6161
|
+
f = this.Qt ? this.Qt(a) : a;
|
|
6277
6162
|
r = E.get(f);
|
|
6278
6163
|
if (r !== undefined && r !== -1) {
|
|
6279
|
-
p[r] = this.
|
|
6280
|
-
_[r] = this
|
|
6281
|
-
i && (i[r] = this.
|
|
6282
|
-
o && (o[r] = this.
|
|
6283
|
-
r =
|
|
6164
|
+
p[r] = this.Vt[n];
|
|
6165
|
+
_[r] = this.xt[n];
|
|
6166
|
+
i && (i[r] = this.Ft[n]);
|
|
6167
|
+
o && (o[r] = this.Wt[n]);
|
|
6168
|
+
r = S[r];
|
|
6284
6169
|
E.set(f, r);
|
|
6285
|
-
} else (
|
|
6170
|
+
} else (d ??= []).push(this.xt[n]);
|
|
6286
6171
|
}
|
|
6287
6172
|
// 2) create new rows into the temp arrays; an abort disposes only these
|
|
6288
6173
|
try {
|
|
@@ -6297,25 +6182,25 @@ function updateKeyedMap() {
|
|
|
6297
6182
|
}
|
|
6298
6183
|
// 3) commit: land positions, then dispose exited rows
|
|
6299
6184
|
for (r = u; r < t; r++) {
|
|
6300
|
-
this.
|
|
6301
|
-
this
|
|
6185
|
+
this.Vt[r] = p[r];
|
|
6186
|
+
this.xt[r] = _[r];
|
|
6302
6187
|
if (i) {
|
|
6303
|
-
this.
|
|
6304
|
-
setSignal(this.
|
|
6188
|
+
this.Ft[r] = i[r];
|
|
6189
|
+
setSignal(this.Ft[r], e[r]);
|
|
6305
6190
|
}
|
|
6306
6191
|
if (o) {
|
|
6307
|
-
this.
|
|
6308
|
-
setSignal(this.
|
|
6192
|
+
this.Wt[r] = o[r];
|
|
6193
|
+
setSignal(this.Wt[r], r);
|
|
6309
6194
|
}
|
|
6310
6195
|
}
|
|
6311
|
-
if (
|
|
6196
|
+
if (d) for (n = 0; n < d.length; n++) d[n].dispose();
|
|
6312
6197
|
// 4) in case the new set is shorter than the old, set the length of the mapped array
|
|
6313
|
-
this.
|
|
6198
|
+
this.Vt = this.Vt.slice(0, this.Gt = t);
|
|
6314
6199
|
// 5) save a copy of the mapped items for the next update
|
|
6315
|
-
this.
|
|
6200
|
+
this.Ut = e.slice(0);
|
|
6316
6201
|
}
|
|
6317
6202
|
});
|
|
6318
|
-
return this.
|
|
6203
|
+
return this.Vt;
|
|
6319
6204
|
}
|
|
6320
6205
|
|
|
6321
6206
|
/**
|
|
@@ -6335,22 +6220,22 @@ function updateKeyedMap() {
|
|
|
6335
6220
|
*/ function repeat(e, t, n) {
|
|
6336
6221
|
const r = t;
|
|
6337
6222
|
const i = {
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6223
|
+
wt: createOwner(),
|
|
6224
|
+
Gt: 0,
|
|
6225
|
+
jt: 0,
|
|
6226
|
+
$t: e,
|
|
6227
|
+
kt: r,
|
|
6228
|
+
xt: [],
|
|
6229
|
+
Vt: [],
|
|
6230
|
+
Kt: n?.from,
|
|
6231
|
+
Ht: n?.fallback
|
|
6347
6232
|
};
|
|
6348
6233
|
const o = computed(updateRepeat.bind(i));
|
|
6349
6234
|
// Same as mapArray: untracked reads inside the internal owner resolve via
|
|
6350
6235
|
// _parentComputed, so async reads in row callbacks register with the node
|
|
6351
6236
|
// (pending tracking + post-settle retry) instead of vanishing.
|
|
6352
|
-
i.
|
|
6353
|
-
o.
|
|
6237
|
+
i.wt.et = o;
|
|
6238
|
+
o.ke &= ~CONFIG_AUTO_DISPOSE;
|
|
6354
6239
|
return accessor(o);
|
|
6355
6240
|
}
|
|
6356
6241
|
|
|
@@ -6362,55 +6247,55 @@ function updateKeyedMap() {
|
|
|
6362
6247
|
// for the post-settle retry. The overlap math also subsumes the previous
|
|
6363
6248
|
// disjoint-window/front-clear/end-clear/shift special cases.
|
|
6364
6249
|
function updateRepeat() {
|
|
6365
|
-
const e = this
|
|
6366
|
-
const t = this.
|
|
6367
|
-
runWithOwner(this.
|
|
6250
|
+
const e = this.$t();
|
|
6251
|
+
const t = this.Kt?.() || 0;
|
|
6252
|
+
runWithOwner(this.wt, () => {
|
|
6368
6253
|
if (e === 0) {
|
|
6369
|
-
if (this.
|
|
6370
|
-
this.
|
|
6371
|
-
this
|
|
6372
|
-
this.
|
|
6373
|
-
this.
|
|
6254
|
+
if (this.Gt !== 0) {
|
|
6255
|
+
this.wt.dispose(false);
|
|
6256
|
+
this.xt = [];
|
|
6257
|
+
this.Vt = [];
|
|
6258
|
+
this.Gt = 0;
|
|
6374
6259
|
// Reset offset to match the cleared data (#2767, repro 2).
|
|
6375
|
-
this.
|
|
6260
|
+
this.jt = 0;
|
|
6376
6261
|
}
|
|
6377
|
-
if (this.
|
|
6262
|
+
if (this.Ht && !this.Vt[0]) {
|
|
6378
6263
|
// an aborted fallback attempt leaves an owner without a mapping;
|
|
6379
6264
|
// dispose it before re-creating
|
|
6380
|
-
this
|
|
6381
|
-
this.
|
|
6265
|
+
this.xt[0]?.dispose();
|
|
6266
|
+
this.Vt[0] = runWithOwner(this.xt[0] = createOwner(), this.Ht);
|
|
6382
6267
|
}
|
|
6383
6268
|
return;
|
|
6384
6269
|
}
|
|
6385
6270
|
const n = t + e;
|
|
6386
|
-
const r = this.
|
|
6271
|
+
const r = this.jt + this.Gt;
|
|
6387
6272
|
// Retained overlap [keepStart, keepEnd) in global indexes; empty when the
|
|
6388
6273
|
// windows are disjoint or when coming from empty/fallback.
|
|
6389
|
-
const i = Math.max(t, this.
|
|
6274
|
+
const i = Math.max(t, this.jt);
|
|
6390
6275
|
const o = Math.min(n, r);
|
|
6391
6276
|
const s = new Array(e);
|
|
6392
6277
|
const u = new Array(e);
|
|
6393
6278
|
for (let e = i; e < o; e++) {
|
|
6394
|
-
u[e - t] = this
|
|
6395
|
-
s[e - t] = this.
|
|
6279
|
+
u[e - t] = this.xt[e - this.jt];
|
|
6280
|
+
s[e - t] = this.Vt[e - this.jt];
|
|
6396
6281
|
}
|
|
6397
6282
|
try {
|
|
6398
6283
|
for (let e = t; e < n; e++) {
|
|
6399
6284
|
if (e >= i && e < o) continue;
|
|
6400
|
-
s[e - t] = runWithOwner(u[e - t] = createOwner(), () => this.
|
|
6285
|
+
s[e - t] = runWithOwner(u[e - t] = createOwner(), () => this.kt(e));
|
|
6401
6286
|
}
|
|
6402
6287
|
} catch (e) {
|
|
6403
6288
|
for (let e = t; e < n; e++) if ((e < i || e >= o) && u[e - t]) u[e - t].dispose();
|
|
6404
6289
|
throw e;
|
|
6405
6290
|
}
|
|
6406
6291
|
// commit: dispose the previous fallback or the rows leaving the window
|
|
6407
|
-
if (this.
|
|
6408
|
-
this.
|
|
6409
|
-
this
|
|
6410
|
-
this.
|
|
6411
|
-
this.
|
|
6292
|
+
if (this.Gt === 0) this.xt[0]?.dispose(); else for (let e = this.jt; e < r; e++) if (e < t || e >= n) this.xt[e - this.jt].dispose();
|
|
6293
|
+
this.Vt = s;
|
|
6294
|
+
this.xt = u;
|
|
6295
|
+
this.jt = t;
|
|
6296
|
+
this.Gt = e;
|
|
6412
6297
|
});
|
|
6413
|
-
return this.
|
|
6298
|
+
return this.Vt;
|
|
6414
6299
|
}
|
|
6415
6300
|
|
|
6416
6301
|
function compare(e, t, n) {
|
|
@@ -6421,23 +6306,23 @@ function boundaryComputed(e, t) {
|
|
|
6421
6306
|
const n = computed(e, {
|
|
6422
6307
|
lazy: true
|
|
6423
6308
|
});
|
|
6424
|
-
n.
|
|
6309
|
+
n.yt = (e, t) => {
|
|
6425
6310
|
// Use passed values if provided, otherwise read from node
|
|
6426
|
-
const r = e !== undefined ? e : n
|
|
6427
|
-
const i = t !== undefined ? t : n.
|
|
6311
|
+
const r = e !== undefined ? e : n.We;
|
|
6312
|
+
const i = t !== undefined ? t : n.me;
|
|
6428
6313
|
// Notify both status dimensions like a render effect does; the queue chain
|
|
6429
6314
|
// consumes this boundary's own type and forwards the remainder upward until
|
|
6430
6315
|
// a boundary that handles it is found.
|
|
6431
|
-
n
|
|
6432
|
-
const o = n.
|
|
6316
|
+
n.We &= ~n.Yt;
|
|
6317
|
+
const o = n.Ze.notify(n, STATUS_PENDING | STATUS_ERROR, r, i);
|
|
6433
6318
|
// The queue is the only propagation channel: a foreign status must not stay
|
|
6434
6319
|
// reader-visible on the tree, or reads re-throw it across the boundary and
|
|
6435
6320
|
// link unrelated ambient contexts (the #2809 nested-boundary loop). Deps are
|
|
6436
6321
|
// untouched, so the tree still recomputes when the foreign source settles.
|
|
6437
|
-
const s = r & ~n.
|
|
6322
|
+
const s = r & ~n.Yt & (STATUS_PENDING | STATUS_ERROR);
|
|
6438
6323
|
if (s) {
|
|
6439
|
-
n
|
|
6440
|
-
if (n.
|
|
6324
|
+
n.We &= ~s;
|
|
6325
|
+
if (n.me === i && !(n.We & (STATUS_PENDING | STATUS_ERROR))) n.me = undefined;
|
|
6441
6326
|
}
|
|
6442
6327
|
// An ERROR the chain could not deliver to any boundary is uncaught. The
|
|
6443
6328
|
// scrub above already removed it from reader-visible state, so without
|
|
@@ -6448,16 +6333,16 @@ function boundaryComputed(e, t) {
|
|
|
6448
6333
|
throw i;
|
|
6449
6334
|
}
|
|
6450
6335
|
};
|
|
6451
|
-
n.
|
|
6452
|
-
n.
|
|
6336
|
+
n.Yt = t;
|
|
6337
|
+
n.ke &= ~CONFIG_AUTO_DISPOSE;
|
|
6453
6338
|
recompute(n, true);
|
|
6454
6339
|
return n;
|
|
6455
6340
|
}
|
|
6456
6341
|
|
|
6457
6342
|
function createBoundChildren(e, t, n, r) {
|
|
6458
|
-
const i = e.
|
|
6459
|
-
i.addChild(e.
|
|
6460
|
-
cleanup(() => i.removeChild(e.
|
|
6343
|
+
const i = e.Ze;
|
|
6344
|
+
i.addChild(e.Ze = n);
|
|
6345
|
+
cleanup(() => i.removeChild(e.Ze));
|
|
6461
6346
|
return runWithOwner(e, () => {
|
|
6462
6347
|
const e = computed(t);
|
|
6463
6348
|
return boundaryComputed(() => flatten(read(e)), r);
|
|
@@ -6479,53 +6364,53 @@ function isRevealController(e) {
|
|
|
6479
6364
|
}
|
|
6480
6365
|
|
|
6481
6366
|
function isSlotReady(e) {
|
|
6482
|
-
return isRevealController(e) ? e.
|
|
6367
|
+
return isRevealController(e) ? e.qt() : e.Bt.size === 0 && !e.Zt;
|
|
6483
6368
|
}
|
|
6484
6369
|
|
|
6485
6370
|
function isSlotMinimallyReady(e) {
|
|
6486
|
-
return isRevealController(e) ? e.
|
|
6371
|
+
return isRevealController(e) ? e.Xt() : isSlotReady(e);
|
|
6487
6372
|
}
|
|
6488
6373
|
|
|
6489
6374
|
function setSlotState(e, t, n, r) {
|
|
6490
|
-
setSignal(e.
|
|
6491
|
-
setSignal(e.
|
|
6375
|
+
setSignal(e.zt, n);
|
|
6376
|
+
setSignal(e.Jt, r);
|
|
6492
6377
|
if (isRevealController(e)) {
|
|
6493
|
-
if (!n && e.
|
|
6494
|
-
return e.
|
|
6378
|
+
if (!n && e.en === t) e.en = undefined;
|
|
6379
|
+
return e.tn(n, r);
|
|
6495
6380
|
}
|
|
6496
|
-
if (!n && e.
|
|
6381
|
+
if (!n && e.nn === t && e.rn) e.nn = undefined;
|
|
6497
6382
|
}
|
|
6498
6383
|
|
|
6499
6384
|
class RevealController {
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6385
|
+
sn;
|
|
6386
|
+
un;
|
|
6387
|
+
ln=[];
|
|
6388
|
+
en;
|
|
6389
|
+
zt=signal(false, {
|
|
6505
6390
|
ownedWrite: true,
|
|
6506
|
-
|
|
6391
|
+
gt: true
|
|
6507
6392
|
});
|
|
6508
|
-
|
|
6393
|
+
Jt=signal(false, {
|
|
6509
6394
|
ownedWrite: true,
|
|
6510
|
-
|
|
6395
|
+
gt: true
|
|
6511
6396
|
});
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6397
|
+
cn=true;
|
|
6398
|
+
an=true;
|
|
6399
|
+
fn=false;
|
|
6515
6400
|
constructor(e, t) {
|
|
6516
|
-
this.
|
|
6517
|
-
this.
|
|
6401
|
+
this.sn = e;
|
|
6402
|
+
this.un = t;
|
|
6518
6403
|
}
|
|
6519
|
-
|
|
6520
|
-
for (let t = 0; t < this.
|
|
6521
|
-
const n = this.
|
|
6522
|
-
if ((isRevealController(n) ? n.
|
|
6404
|
+
En(e) {
|
|
6405
|
+
for (let t = 0; t < this.ln.length; t++) {
|
|
6406
|
+
const n = this.ln[t];
|
|
6407
|
+
if ((isRevealController(n) ? n.en : n.nn) !== this) continue;
|
|
6523
6408
|
if (e(n) === false) return false;
|
|
6524
6409
|
}
|
|
6525
6410
|
return true;
|
|
6526
6411
|
}
|
|
6527
|
-
|
|
6528
|
-
return this.
|
|
6412
|
+
qt() {
|
|
6413
|
+
return this.En(isSlotReady);
|
|
6529
6414
|
}
|
|
6530
6415
|
/**
|
|
6531
6416
|
* "Minimally ready" = this group has something visible to show under its own policy.
|
|
@@ -6533,13 +6418,13 @@ class RevealController {
|
|
|
6533
6418
|
* - `together`: every direct slot is minimally ready.
|
|
6534
6419
|
* - `sequential`: the first owned slot is minimally ready (frontier can advance).
|
|
6535
6420
|
* - `natural`: any owned slot is minimally ready.
|
|
6536
|
-
*/
|
|
6537
|
-
const e = untrack(this.
|
|
6538
|
-
if (e === "together") return this.
|
|
6421
|
+
*/ Xt() {
|
|
6422
|
+
const e = untrack(this.sn);
|
|
6423
|
+
if (e === "together") return this.En(isSlotMinimallyReady);
|
|
6539
6424
|
if (e === "natural") {
|
|
6540
6425
|
let e = false;
|
|
6541
6426
|
let t = false;
|
|
6542
|
-
this.
|
|
6427
|
+
this.En(n => {
|
|
6543
6428
|
e = true;
|
|
6544
6429
|
if (isSlotMinimallyReady(n)) {
|
|
6545
6430
|
t = true;
|
|
@@ -6550,45 +6435,45 @@ class RevealController {
|
|
|
6550
6435
|
}
|
|
6551
6436
|
// sequential: only the first owned slot matters.
|
|
6552
6437
|
let t = true;
|
|
6553
|
-
this.
|
|
6438
|
+
this.En(e => {
|
|
6554
6439
|
t = isSlotMinimallyReady(e);
|
|
6555
6440
|
return false;
|
|
6556
6441
|
});
|
|
6557
6442
|
return t;
|
|
6558
6443
|
}
|
|
6559
|
-
|
|
6560
|
-
if (this.
|
|
6561
|
-
this.
|
|
6562
|
-
const t = untrack(this.
|
|
6563
|
-
setSignal(e.
|
|
6564
|
-
untrack(() => this.
|
|
6565
|
-
}
|
|
6566
|
-
|
|
6567
|
-
const t = this.
|
|
6568
|
-
if (t >= 0) this.
|
|
6569
|
-
untrack(() => this.
|
|
6570
|
-
}
|
|
6571
|
-
|
|
6572
|
-
if (this.
|
|
6573
|
-
this.
|
|
6574
|
-
const n = this.
|
|
6575
|
-
const r = this.
|
|
6444
|
+
Sn(e) {
|
|
6445
|
+
if (this.ln.includes(e)) return;
|
|
6446
|
+
this.ln.push(e);
|
|
6447
|
+
const t = untrack(this.sn);
|
|
6448
|
+
setSignal(e.zt, true), setSignal(e.Jt, t === "sequential" ? !!untrack(this.un) : false);
|
|
6449
|
+
untrack(() => this.tn());
|
|
6450
|
+
}
|
|
6451
|
+
dn(e) {
|
|
6452
|
+
const t = this.ln.indexOf(e);
|
|
6453
|
+
if (t >= 0) this.ln.splice(t, 1);
|
|
6454
|
+
untrack(() => this.tn());
|
|
6455
|
+
}
|
|
6456
|
+
tn(e, t) {
|
|
6457
|
+
if (this.fn) return;
|
|
6458
|
+
this.fn = true;
|
|
6459
|
+
const n = this.cn;
|
|
6460
|
+
const r = this.an;
|
|
6576
6461
|
try {
|
|
6577
|
-
const n = e ?? read(this.
|
|
6462
|
+
const n = e ?? read(this.zt), r = untrack(this.sn), i = r === "sequential" && !!untrack(this.un), o = t ?? i;
|
|
6578
6463
|
if (n) {
|
|
6579
6464
|
// Held by an outer group. Propagate the hold (and whatever collapsed policy
|
|
6580
6465
|
// the outer asked for) down the whole subtree. Inner order is ignored while
|
|
6581
6466
|
// held; it resumes once the outer releases us.
|
|
6582
|
-
this.
|
|
6467
|
+
this.En(e => setSlotState(e, this, true, o));
|
|
6583
6468
|
} else if (r === "natural") {
|
|
6584
6469
|
// Each child reveals based on its own readiness. A nested controller slot
|
|
6585
6470
|
// is released to run its own order locally — we bypass setSlotState for it
|
|
6586
6471
|
// so the parent backpointer survives for upward readiness notifications.
|
|
6587
|
-
this.
|
|
6472
|
+
this.En(e => {
|
|
6588
6473
|
if (isRevealController(e)) {
|
|
6589
|
-
setSignal(e.
|
|
6590
|
-
setSignal(e.
|
|
6591
|
-
e.
|
|
6474
|
+
setSignal(e.Jt, false);
|
|
6475
|
+
setSignal(e.zt, false);
|
|
6476
|
+
e.tn(false, false);
|
|
6592
6477
|
} else {
|
|
6593
6478
|
setSlotState(e, this, !isSlotReady(e), false);
|
|
6594
6479
|
}
|
|
@@ -6599,11 +6484,11 @@ class RevealController {
|
|
|
6599
6484
|
// sequential's first slot being ready is minimally ready; natural having any
|
|
6600
6485
|
// ready child is minimally ready. This lets `together` guarantee a single
|
|
6601
6486
|
// cohesive reveal without waiting for every grandchild.
|
|
6602
|
-
const e = this.
|
|
6603
|
-
this.
|
|
6487
|
+
const e = this.En(isSlotMinimallyReady);
|
|
6488
|
+
this.En(t => setSlotState(t, this, !e, false));
|
|
6604
6489
|
} else {
|
|
6605
6490
|
let e = false;
|
|
6606
|
-
this.
|
|
6491
|
+
this.En(t => {
|
|
6607
6492
|
if (e) return setSlotState(t, this, true, i);
|
|
6608
6493
|
if (isSlotReady(t)) return setSlotState(t, this, false, false);
|
|
6609
6494
|
e = true;
|
|
@@ -6614,63 +6499,63 @@ class RevealController {
|
|
|
6614
6499
|
// advancing past this slot, and we bypass setSlotState so the parent
|
|
6615
6500
|
// backpointer survives for upward readiness notifications.
|
|
6616
6501
|
if (isRevealController(t)) {
|
|
6617
|
-
setSignal(t.
|
|
6618
|
-
setSignal(t.
|
|
6619
|
-
t.
|
|
6502
|
+
setSignal(t.Jt, false);
|
|
6503
|
+
setSignal(t.zt, false);
|
|
6504
|
+
t.tn(false, false);
|
|
6620
6505
|
} else {
|
|
6621
6506
|
setSlotState(t, this, true, false);
|
|
6622
6507
|
}
|
|
6623
6508
|
});
|
|
6624
6509
|
}
|
|
6625
6510
|
} finally {
|
|
6626
|
-
this.
|
|
6627
|
-
this.
|
|
6628
|
-
this.
|
|
6511
|
+
this.cn = this.qt();
|
|
6512
|
+
this.an = this.Xt();
|
|
6513
|
+
this.fn = false;
|
|
6629
6514
|
}
|
|
6630
|
-
if (this.
|
|
6515
|
+
if (this.en && (n !== this.cn || r !== this.an)) this.en.tn();
|
|
6631
6516
|
}
|
|
6632
6517
|
}
|
|
6633
6518
|
|
|
6634
6519
|
class CollectionQueue extends Queue {
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6520
|
+
Tn;
|
|
6521
|
+
Bt=new Set;
|
|
6522
|
+
pn;
|
|
6523
|
+
Zt=true;
|
|
6524
|
+
zt=signal(false, {
|
|
6640
6525
|
ownedWrite: true,
|
|
6641
|
-
|
|
6526
|
+
gt: true
|
|
6642
6527
|
});
|
|
6643
|
-
|
|
6644
|
-
|
|
6528
|
+
me;
|
|
6529
|
+
Jt=signal(false, {
|
|
6645
6530
|
ownedWrite: true,
|
|
6646
|
-
|
|
6531
|
+
gt: true
|
|
6647
6532
|
});
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6533
|
+
nn;
|
|
6534
|
+
rn=false;
|
|
6535
|
+
_n;
|
|
6536
|
+
On=ON_INIT;
|
|
6652
6537
|
constructor(e) {
|
|
6653
6538
|
super();
|
|
6654
|
-
this.
|
|
6539
|
+
this.Tn = e;
|
|
6655
6540
|
}
|
|
6656
6541
|
run(e) {
|
|
6657
|
-
if (!e || read(this.
|
|
6542
|
+
if (!e || read(this.zt) && (!_revealUsed || read(this.Jt))) return;
|
|
6658
6543
|
return super.run(e);
|
|
6659
6544
|
}
|
|
6660
6545
|
notify(e, t, n, r) {
|
|
6661
|
-
if (!(t & this.
|
|
6662
|
-
if (this.
|
|
6546
|
+
if (!(t & this.Tn)) return super.notify(e, t, n, r);
|
|
6547
|
+
if (this.rn && this._n) {
|
|
6663
6548
|
const e = untrack(() => {
|
|
6664
6549
|
try {
|
|
6665
|
-
return this.
|
|
6550
|
+
return this._n();
|
|
6666
6551
|
} catch {
|
|
6667
6552
|
return ON_INIT;
|
|
6668
6553
|
}
|
|
6669
6554
|
});
|
|
6670
|
-
if (e !== this.
|
|
6671
|
-
this.
|
|
6672
|
-
this.
|
|
6673
|
-
this.
|
|
6555
|
+
if (e !== this.On) {
|
|
6556
|
+
this.On = e;
|
|
6557
|
+
this.rn = false;
|
|
6558
|
+
this.Bt.clear();
|
|
6674
6559
|
}
|
|
6675
6560
|
}
|
|
6676
6561
|
// Routing is dimension-independent: each boundary consumes only its own
|
|
@@ -6683,43 +6568,47 @@ class CollectionQueue extends Queue {
|
|
|
6683
6568
|
// dimension, while a status already caught by an inner boundary arrives with
|
|
6684
6569
|
// its dimension consumed from the mask and is correctly not re-routed
|
|
6685
6570
|
// (the Loading > Errored > content composition escape, #2856).
|
|
6686
|
-
if (this.
|
|
6687
|
-
if (n & this.
|
|
6688
|
-
this.
|
|
6689
|
-
const t = r?.source || e.
|
|
6571
|
+
if (this.Tn & STATUS_PENDING && this.rn) return super.notify(e, t, n, r);
|
|
6572
|
+
if (n & this.Tn) {
|
|
6573
|
+
this.Zt = true;
|
|
6574
|
+
const t = r?.source || e.me?.source;
|
|
6690
6575
|
if (t) {
|
|
6691
|
-
const e = this.
|
|
6692
|
-
this.
|
|
6693
|
-
if (e) setSignal(this.
|
|
6694
|
-
if (this.
|
|
6695
|
-
setSignal(this.
|
|
6576
|
+
const e = this.Bt.size === 0;
|
|
6577
|
+
this.Bt.add(t);
|
|
6578
|
+
if (e) setSignal(this.zt, true);
|
|
6579
|
+
if (this.Tn & STATUS_ERROR) {
|
|
6580
|
+
setSignal(this.me, unwrapStatusError(t.me));
|
|
6696
6581
|
}
|
|
6697
6582
|
}
|
|
6698
6583
|
}
|
|
6699
|
-
t &= ~this.
|
|
6584
|
+
t &= ~this.Tn;
|
|
6700
6585
|
return t ? super.notify(e, t, n, r) : true;
|
|
6701
6586
|
}
|
|
6702
|
-
|
|
6703
|
-
for (const e of this.
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6587
|
+
je() {
|
|
6588
|
+
for (const e of this.Bt) {
|
|
6589
|
+
// A source with a live affects() mark holds display state for the
|
|
6590
|
+
// mark's lifetime (the visual channel): the marked node carries no
|
|
6591
|
+
// status of its own, so the count is the liveness test. The release
|
|
6592
|
+
// sweep (finalizePureQueue after mark release) re-runs this check.
|
|
6593
|
+
if (e.Le & REACTIVE_DISPOSED || !e.F && !(e.We & this.Tn) && !(this.Tn & STATUS_ERROR && e.We & STATUS_PENDING)) this.Bt.delete(e);
|
|
6594
|
+
}
|
|
6595
|
+
if (!this.Bt.size) {
|
|
6596
|
+
if (this.Tn & STATUS_PENDING && this.Zt && !this.rn && this.pn) {
|
|
6597
|
+
this.Zt = !!(this.pn.We & this.Tn);
|
|
6709
6598
|
} else {
|
|
6710
|
-
this.
|
|
6599
|
+
this.Zt = false;
|
|
6711
6600
|
}
|
|
6712
|
-
if (!this.
|
|
6713
|
-
setSignal(this.
|
|
6714
|
-
if (this.
|
|
6601
|
+
if (!this.Zt) {
|
|
6602
|
+
setSignal(this.zt, false);
|
|
6603
|
+
if (this._n) {
|
|
6715
6604
|
try {
|
|
6716
|
-
this.
|
|
6605
|
+
this.On = untrack(() => this._n());
|
|
6717
6606
|
} catch {
|
|
6718
6607
|
/* value not yet committed — _prevOn stays stale, next notify will reset */}
|
|
6719
6608
|
}
|
|
6720
6609
|
}
|
|
6721
6610
|
}
|
|
6722
|
-
if (_revealUsed) this.
|
|
6611
|
+
if (_revealUsed) this.nn?.tn();
|
|
6723
6612
|
}
|
|
6724
6613
|
}
|
|
6725
6614
|
|
|
@@ -6727,12 +6616,12 @@ function createCollectionBoundary(e, t, n, r) {
|
|
|
6727
6616
|
const i = createOwner();
|
|
6728
6617
|
if (_revealUsed) setContext(RevealControllerContext, null, i);
|
|
6729
6618
|
const o = new CollectionQueue(e);
|
|
6730
|
-
if (e === STATUS_ERROR) o.
|
|
6619
|
+
if (e === STATUS_ERROR) o.me = signal(undefined, {
|
|
6731
6620
|
ownedWrite: true,
|
|
6732
|
-
|
|
6621
|
+
gt: true
|
|
6733
6622
|
});
|
|
6734
|
-
if (r) o.
|
|
6735
|
-
const s = o.
|
|
6623
|
+
if (r) o._n = r;
|
|
6624
|
+
const s = o.pn = createBoundChildren(i, t, o, e);
|
|
6736
6625
|
// Prime source tracking so reveal registration sees pending sources.
|
|
6737
6626
|
untrack(() => {
|
|
6738
6627
|
let t = false;
|
|
@@ -6741,23 +6630,23 @@ function createCollectionBoundary(e, t, n, r) {
|
|
|
6741
6630
|
} catch (e) {
|
|
6742
6631
|
if (e instanceof NotReadyError) t = true; else throw e;
|
|
6743
6632
|
}
|
|
6744
|
-
o.
|
|
6633
|
+
o.Zt = t || !!(s.We & e) || s.me instanceof NotReadyError;
|
|
6745
6634
|
});
|
|
6746
6635
|
const u = _revealUsed && e === STATUS_PENDING ? getContext(RevealControllerContext) : null;
|
|
6747
6636
|
if (u) {
|
|
6748
|
-
o.
|
|
6749
|
-
u.
|
|
6750
|
-
cleanup(() => u.
|
|
6637
|
+
o.nn = u;
|
|
6638
|
+
u.Sn(o);
|
|
6639
|
+
cleanup(() => u.dn(o));
|
|
6751
6640
|
}
|
|
6752
6641
|
return accessor(computed(() => {
|
|
6753
|
-
if (!read(o.
|
|
6642
|
+
if (!read(o.zt)) {
|
|
6754
6643
|
const e = read(s);
|
|
6755
|
-
if (!untrack(() => read(o.
|
|
6644
|
+
if (!untrack(() => read(o.zt))) return o.rn = true, e;
|
|
6756
6645
|
}
|
|
6757
6646
|
// Collapsed reveal slots suppress their own output entirely; the
|
|
6758
6647
|
// renderer treats the hole as empty, so the cast never leaks to users
|
|
6759
6648
|
// outside a `createRevealOrder` scope.
|
|
6760
|
-
if (_revealUsed && read(o.
|
|
6649
|
+
if (_revealUsed && read(o.Jt)) return undefined;
|
|
6761
6650
|
return n(o);
|
|
6762
6651
|
},
|
|
6763
6652
|
// Boundary structure, not a user source: its value is fallback-or-content and
|
|
@@ -6765,7 +6654,7 @@ function createCollectionBoundary(e, t, n, r) {
|
|
|
6765
6654
|
// by snapshot capture. The tree no longer carries foreign status flags, so
|
|
6766
6655
|
// capture can't rely on PENDING to skip this node the way it used to.
|
|
6767
6656
|
{
|
|
6768
|
-
|
|
6657
|
+
gt: true
|
|
6769
6658
|
}));
|
|
6770
6659
|
}
|
|
6771
6660
|
|
|
@@ -6818,8 +6707,8 @@ function createCollectionBoundary(e, t, n, r) {
|
|
|
6818
6707
|
* }
|
|
6819
6708
|
* ```
|
|
6820
6709
|
*/ function createErrorBoundary(e, t) {
|
|
6821
|
-
return createCollectionBoundary(STATUS_ERROR, e, e => t(accessor(e.
|
|
6822
|
-
for (const t of e.
|
|
6710
|
+
return createCollectionBoundary(STATUS_ERROR, e, e => t(accessor(e.me), () => {
|
|
6711
|
+
for (const t of e.Bt) recompute(t);
|
|
6823
6712
|
schedule();
|
|
6824
6713
|
}));
|
|
6825
6714
|
}
|
|
@@ -6876,12 +6765,12 @@ function createCollectionBoundary(e, t, n, r) {
|
|
|
6876
6765
|
computed(() => {
|
|
6877
6766
|
i();
|
|
6878
6767
|
o();
|
|
6879
|
-
s.
|
|
6768
|
+
s.tn();
|
|
6880
6769
|
});
|
|
6881
6770
|
if (r) {
|
|
6882
|
-
s.
|
|
6883
|
-
r.
|
|
6884
|
-
cleanup(() => r.
|
|
6771
|
+
s.en = r;
|
|
6772
|
+
r.Sn(s);
|
|
6773
|
+
cleanup(() => r.dn(s));
|
|
6885
6774
|
}
|
|
6886
6775
|
return t;
|
|
6887
6776
|
});
|