@solidjs/signals 2.0.0-beta.24 → 2.0.0-beta.26
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 +577 -87
- package/dist/node.cjs +1120 -683
- package/dist/prod/core/async.js +180 -107
- package/dist/prod/core/core.js +214 -180
- package/dist/prod/core/effect.js +19 -19
- package/dist/prod/core/external.js +4 -4
- package/dist/prod/core/graph.js +25 -25
- package/dist/prod/core/heap.js +23 -23
- package/dist/prod/core/lanes.js +15 -15
- package/dist/prod/core/optimistic.js +42 -40
- package/dist/prod/core/owner.js +41 -41
- package/dist/prod/core/scheduler.js +90 -90
- package/dist/prod/core/verdict.js +54 -54
- package/dist/prod/map.js +60 -60
- package/dist/prod/signals.js +1 -1
- package/dist/prod/store/optimistic.js +18 -11
- package/dist/prod/store/projection.js +25 -18
- package/dist/prod/store/reconcile.js +405 -211
- package/dist/prod/store/store.js +225 -105
- package/dist/prod/store/utils.js +22 -22
- package/dist/types/core/async.d.ts +1 -0
- package/dist/types/core/core.d.ts +15 -0
- package/dist/types/store/optimistic.d.ts +1 -1
- package/dist/types/store/store.d.ts +20 -2
- package/dist/types-cjs/core/async.d.cts +1 -0
- package/dist/types-cjs/core/core.d.cts +15 -0
- package/dist/types-cjs/store/optimistic.d.cts +1 -1
- package/dist/types-cjs/store/store.d.cts +20 -2
- package/package.json +1 -1
package/dist/prod/core/effect.js
CHANGED
|
@@ -14,7 +14,7 @@ import { GlobalQueue, haltReactivity } from "./scheduler.js";
|
|
|
14
14
|
const r = !!R?.user;
|
|
15
15
|
const f = createEffectNode(t, E, e, r ? EFFECT_USER : EFFECT_RENDER, notifyEffectStatus, R);
|
|
16
16
|
recompute(f, true);
|
|
17
|
-
!R?.defer && (f.
|
|
17
|
+
!R?.defer && (f.Pe === EFFECT_USER || R?.schedule ? f.C.enqueue(f.Pe, runEffect.bind(null, f)) : runEffect(f));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function notifyEffectStatus(t, E) {
|
|
@@ -23,7 +23,7 @@ function notifyEffectStatus(t, E) {
|
|
|
23
23
|
const R = E !== undefined ? E : this._;
|
|
24
24
|
if (e & STATUS_ERROR) {
|
|
25
25
|
this.C.notify(this, STATUS_PENDING, 0);
|
|
26
|
-
if (this.
|
|
26
|
+
if (this.Pe === EFFECT_USER) {
|
|
27
27
|
// The error handler is the error arm of the effect phase (#2840 ruling):
|
|
28
28
|
// queue it like the effect function. It runs in the same imperative,
|
|
29
29
|
// writable scope, throws escalate the same way, and a held transition
|
|
@@ -34,8 +34,8 @@ function notifyEffectStatus(t, E) {
|
|
|
34
34
|
// `status` arg without node-state writes) don't queue: the status
|
|
35
35
|
// re-propagates unblocked at commit.
|
|
36
36
|
if (this.S & STATUS_ERROR) {
|
|
37
|
-
this
|
|
38
|
-
this.C.enqueue(this.
|
|
37
|
+
this.Be = true;
|
|
38
|
+
this.C.enqueue(this.Pe, this.Je ??= runEffect.bind(null, this));
|
|
39
39
|
}
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
@@ -43,13 +43,13 @@ function notifyEffectStatus(t, E) {
|
|
|
43
43
|
haltReactivity(unwrapStatusError(R));
|
|
44
44
|
throw R;
|
|
45
45
|
}
|
|
46
|
-
} else if (this.
|
|
46
|
+
} else if (this.Pe === EFFECT_RENDER) {
|
|
47
47
|
this.C.notify(this, STATUS_PENDING | STATUS_ERROR, e, R);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function runEffect(t) {
|
|
52
|
-
if (!t
|
|
52
|
+
if (!t.Be || t.se & REACTIVE_DISPOSED) return;
|
|
53
53
|
// Error arm (#2840), user effects only: a compute-phase error that is still
|
|
54
54
|
// the node's settled state at effect time runs the bundle's error handler in
|
|
55
55
|
// this same imperative, writable scope. Unwrap the StatusError used for
|
|
@@ -60,12 +60,12 @@ function runEffect(t) {
|
|
|
60
60
|
// Render effects bypass: their errors route to boundaries synchronously in
|
|
61
61
|
// notifyEffectStatus, and a runner queued by an earlier valueChanged in the
|
|
62
62
|
// same flush must not be hijacked by a later-arriving error status.
|
|
63
|
-
if (t.S & STATUS_ERROR && t.
|
|
63
|
+
if (t.S & STATUS_ERROR && t.Pe === EFFECT_USER) {
|
|
64
64
|
const E = unwrapStatusError(t._);
|
|
65
|
-
t.
|
|
66
|
-
t
|
|
65
|
+
t.ct = t.Ue;
|
|
66
|
+
t.Be = false;
|
|
67
67
|
try {
|
|
68
|
-
t.
|
|
68
|
+
t.ft ? t.ft(E, () => {
|
|
69
69
|
const E = t.Et;
|
|
70
70
|
t.Et = undefined;
|
|
71
71
|
E?.();
|
|
@@ -82,7 +82,7 @@ function runEffect(t) {
|
|
|
82
82
|
t.Et = undefined;
|
|
83
83
|
try {
|
|
84
84
|
E?.();
|
|
85
|
-
const e = t.
|
|
85
|
+
const e = t._t(t.Ue, t.ct);
|
|
86
86
|
if (false && e !== undefined && typeof e !== "function") ;
|
|
87
87
|
// The final cleanup is invoked by disposeChildren at true disposal.
|
|
88
88
|
t.Et = e;
|
|
@@ -94,12 +94,12 @@ function runEffect(t) {
|
|
|
94
94
|
throw E;
|
|
95
95
|
}
|
|
96
96
|
} finally {
|
|
97
|
-
t.
|
|
98
|
-
t
|
|
97
|
+
t.ct = t.Ue;
|
|
98
|
+
t.Be = false;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
GlobalQueue.
|
|
102
|
+
GlobalQueue.Xe = runEffect;
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* Internal tracked effect - bypasses heap, goes directly to effect queue.
|
|
@@ -107,9 +107,9 @@ GlobalQueue.Je = runEffect;
|
|
|
107
107
|
* Uses stale reads.
|
|
108
108
|
*/ function trackedEffect(t, E) {
|
|
109
109
|
const run = () => {
|
|
110
|
-
if (!e
|
|
110
|
+
if (!e.Be || e.se & REACTIVE_DISPOSED) return;
|
|
111
111
|
try {
|
|
112
|
-
e
|
|
112
|
+
e.Be = false;
|
|
113
113
|
recompute(e);
|
|
114
114
|
} finally {}
|
|
115
115
|
};
|
|
@@ -125,8 +125,8 @@ GlobalQueue.Je = runEffect;
|
|
|
125
125
|
});
|
|
126
126
|
e.Et = undefined;
|
|
127
127
|
e.T = e.T & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
|
|
128
|
-
e
|
|
129
|
-
e.
|
|
128
|
+
e.Be = true;
|
|
129
|
+
e.Pe = EFFECT_TRACKED;
|
|
130
130
|
e.i = (t, E) => {
|
|
131
131
|
const R = t !== undefined ? t : e.S;
|
|
132
132
|
if (R & STATUS_ERROR) {
|
|
@@ -138,7 +138,7 @@ GlobalQueue.Je = runEffect;
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
};
|
|
141
|
-
e.
|
|
141
|
+
e.Ft = run;
|
|
142
142
|
e.C.enqueue(EFFECT_USER, run);
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -46,11 +46,11 @@ function wireExternalSource(e) {
|
|
|
46
46
|
equals: false,
|
|
47
47
|
ownedWrite: true
|
|
48
48
|
});
|
|
49
|
-
const r = externalSourceConfig.factory(e.
|
|
49
|
+
const r = externalSourceConfig.factory(e.ae, () => {
|
|
50
50
|
setSignal(n, undefined);
|
|
51
51
|
});
|
|
52
52
|
cleanup(() => r.dispose());
|
|
53
|
-
e.
|
|
53
|
+
e.ae = e => {
|
|
54
54
|
read(n);
|
|
55
55
|
return r.track(e);
|
|
56
56
|
};
|
|
@@ -64,8 +64,8 @@ function externalUntrack(e) {
|
|
|
64
64
|
// removed on reset) so core's null checks stay equivalent to the old
|
|
65
65
|
// `externalSourceConfig` truthiness checks.
|
|
66
66
|
function syncExternalHooks() {
|
|
67
|
-
GlobalQueue.
|
|
68
|
-
GlobalQueue.
|
|
67
|
+
GlobalQueue.It = externalSourceConfig ? wireExternalSource : null;
|
|
68
|
+
GlobalQueue.dt = externalSourceConfig ? externalUntrack : null;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
function enableExternalSource(e) {
|
package/dist/prod/core/graph.js
CHANGED
|
@@ -8,15 +8,15 @@ import "./scheduler.js";
|
|
|
8
8
|
|
|
9
9
|
// https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L100
|
|
10
10
|
function unlinkSubs(l) {
|
|
11
|
-
const n = l.
|
|
12
|
-
const e = l.
|
|
11
|
+
const n = l.nt;
|
|
12
|
+
const e = l.tt;
|
|
13
13
|
const u = l.ue;
|
|
14
14
|
const s = l.ll;
|
|
15
|
-
if (u !== null) u.ll = s; else n.
|
|
15
|
+
if (u !== null) u.ll = s; else n.st = s;
|
|
16
16
|
if (s !== null) s.ue = u; else {
|
|
17
17
|
n.o = u;
|
|
18
18
|
if (u === null) {
|
|
19
|
-
n.
|
|
19
|
+
n.ut?.();
|
|
20
20
|
// No more subscribers; only tear down if CONFIG_AUTO_DISPOSE is set.
|
|
21
21
|
// A pending node is exempt: its in-flight async work (or the
|
|
22
22
|
// transition holding it) is an observer — tearing down would orphan
|
|
@@ -24,31 +24,31 @@ function unlinkSubs(l) {
|
|
|
24
24
|
// this same last-one-out check when that observer releases (the
|
|
25
25
|
// untracked-read dispose in core.ts guards on pending identically).
|
|
26
26
|
const l = n;
|
|
27
|
-
l.
|
|
27
|
+
l.ae && l.T & CONFIG_AUTO_DISPOSE && !(l.se & REACTIVE_ZOMBIE) && !(l.S & STATUS_PENDING) && unobserved(l);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
return e;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function trimStaleDeps(l) {
|
|
34
|
-
const n = l.
|
|
35
|
-
let e = n !== null ? n.
|
|
34
|
+
const n = l.We;
|
|
35
|
+
let e = n !== null ? n.tt : l.et;
|
|
36
36
|
if (e !== null) {
|
|
37
37
|
do {
|
|
38
38
|
e = unlinkSubs(e);
|
|
39
39
|
} while (e !== null);
|
|
40
|
-
if (n !== null) n.
|
|
40
|
+
if (n !== null) n.tt = null; else l.et = null;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function unobserved(l) {
|
|
45
45
|
deleteFromHeap(l, queueFor(l));
|
|
46
|
-
let n = l.
|
|
46
|
+
let n = l.et;
|
|
47
47
|
while (n !== null) {
|
|
48
48
|
n = unlinkSubs(n);
|
|
49
49
|
}
|
|
50
|
-
l.
|
|
51
|
-
l.
|
|
50
|
+
l.et = null;
|
|
51
|
+
l.We = null;
|
|
52
52
|
disposeChildren(l, true);
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -59,20 +59,20 @@ function link(l, n, e = false) {
|
|
|
59
59
|
// not relabel the value dependency as probe-only — the value read is what
|
|
60
60
|
// real-error propagation and affects() coverage key off, regardless of
|
|
61
61
|
// read order within the computation.
|
|
62
|
-
const u = n.
|
|
63
|
-
if (u !== null && u.
|
|
64
|
-
u.
|
|
62
|
+
const u = n.We;
|
|
63
|
+
if (u !== null && u.nt === l) {
|
|
64
|
+
u.ge &&= e;
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
let s = null;
|
|
68
68
|
const t = n.se & REACTIVE_RECOMPUTING_DEPS;
|
|
69
69
|
if (t) {
|
|
70
|
-
s = u !== null ? u.
|
|
71
|
-
if (s !== null && s.
|
|
70
|
+
s = u !== null ? u.tt : n.et;
|
|
71
|
+
if (s !== null && s.nt === l) {
|
|
72
72
|
s.nl = n.Ye;
|
|
73
|
-
n.
|
|
73
|
+
n.We = s;
|
|
74
74
|
// First touch of this pass: the previous pass's label is stale.
|
|
75
|
-
s.
|
|
75
|
+
s.ge = e;
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -81,23 +81,23 @@ function link(l, n, e = false) {
|
|
|
81
81
|
// [deps.._depsTail] prefix — the O(1) equivalent of scanning the dep list
|
|
82
82
|
// (the old alien-signals `isValidLink` walk, O(n²) when a computation
|
|
83
83
|
// re-reads earlier deps non-consecutively, e.g. store leaf reads).
|
|
84
|
-
const i = l.
|
|
84
|
+
const i = l.st;
|
|
85
85
|
if (i !== null && i.le === n && (!t || i.nl === n.Ye)) {
|
|
86
86
|
// Gen-matched during a recompute = repeat touch this pass (AND); outside
|
|
87
87
|
// a recompute there is no pass boundary, so the latest read labels it.
|
|
88
|
-
if (t) i.
|
|
88
|
+
if (t) i.ge &&= e; else i.ge = e;
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
|
-
const o = n.
|
|
92
|
-
|
|
91
|
+
const o = n.We = l.st = {
|
|
92
|
+
nt: l,
|
|
93
93
|
le: n,
|
|
94
|
-
|
|
94
|
+
tt: s,
|
|
95
95
|
ll: i,
|
|
96
96
|
ue: null,
|
|
97
97
|
nl: n.Ye,
|
|
98
|
-
|
|
98
|
+
ge: e
|
|
99
99
|
};
|
|
100
|
-
if (u !== null) u.
|
|
100
|
+
if (u !== null) u.tt = o; else n.et = o;
|
|
101
101
|
if (i !== null) i.ue = o; else l.o = o;
|
|
102
102
|
}
|
|
103
103
|
|
package/dist/prod/core/heap.js
CHANGED
|
@@ -11,29 +11,29 @@ import { zombieQueue, dirtyQueue } from "./scheduler.js";
|
|
|
11
11
|
* the heap and go directly to their effect queue; everything else is inserted
|
|
12
12
|
* into its own (zombie-flag-routed) heap with the `_min` cursor pulled down.
|
|
13
13
|
*/ function enqueueSub(e) {
|
|
14
|
-
if (e.
|
|
14
|
+
if (e.Pe === EFFECT_TRACKED) {
|
|
15
15
|
const E = e;
|
|
16
|
-
if (!E
|
|
17
|
-
E
|
|
18
|
-
E.C.enqueue(EFFECT_USER, E.
|
|
16
|
+
if (!E.Be) {
|
|
17
|
+
E.Be = true;
|
|
18
|
+
E.C.enqueue(EFFECT_USER, E.Ft);
|
|
19
19
|
}
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
const E = queueFor(e);
|
|
23
|
-
if (E.He > e.
|
|
23
|
+
if (E.He > e.Ve) E.He = e.Ve;
|
|
24
24
|
insertIntoHeap(e, E);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function actualInsertIntoHeap(e, E) {
|
|
28
|
-
const t = (e.
|
|
29
|
-
if (t >= e.
|
|
30
|
-
const n = e.
|
|
28
|
+
const t = (e.ve?.Nt ? e.ve.Tt?.Ve : e.ve?.Ve) ?? -1;
|
|
29
|
+
if (t >= e.Ve) e.Ve = t + 1;
|
|
30
|
+
const n = e.Ve;
|
|
31
31
|
const I = E.eE[n];
|
|
32
32
|
if (I === undefined) E.eE[n] = e; else {
|
|
33
|
-
const E = I.
|
|
33
|
+
const E = I.ot;
|
|
34
34
|
E.lt = e;
|
|
35
|
-
e.
|
|
36
|
-
I.
|
|
35
|
+
e.ot = E;
|
|
36
|
+
I.ot = e;
|
|
37
37
|
}
|
|
38
38
|
if (n > E.EE) E.EE = n;
|
|
39
39
|
}
|
|
@@ -66,15 +66,15 @@ function deleteFromHeap(e, E) {
|
|
|
66
66
|
const t = e.se;
|
|
67
67
|
if (!(t & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
|
|
68
68
|
e.se = t & -25;
|
|
69
|
-
const n = e.
|
|
70
|
-
if (e.
|
|
69
|
+
const n = e.Ve;
|
|
70
|
+
if (e.ot === e) E.eE[n] = undefined; else {
|
|
71
71
|
const t = e.lt;
|
|
72
72
|
const I = E.eE[n];
|
|
73
73
|
const o = t ?? I;
|
|
74
|
-
if (e === I) E.eE[n] = t; else e.
|
|
75
|
-
o.
|
|
74
|
+
if (e === I) E.eE[n] = t; else e.ot.lt = t;
|
|
75
|
+
o.ot = e.ot;
|
|
76
76
|
}
|
|
77
|
-
e.
|
|
77
|
+
e.ot = e;
|
|
78
78
|
e.lt = undefined;
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -118,14 +118,14 @@ function runHeap(e, E) {
|
|
|
118
118
|
|
|
119
119
|
function adjustHeight(e, E) {
|
|
120
120
|
deleteFromHeap(e, E);
|
|
121
|
-
let t = e.
|
|
122
|
-
for (let E = e.
|
|
123
|
-
const e = E.
|
|
124
|
-
const n = e.
|
|
125
|
-
if (n.
|
|
121
|
+
let t = e.Ve;
|
|
122
|
+
for (let E = e.et; E; E = E.tt) {
|
|
123
|
+
const e = E.nt;
|
|
124
|
+
const n = e.it || e;
|
|
125
|
+
if (n.ae && n.Ve >= t) t = n.Ve + 1;
|
|
126
126
|
}
|
|
127
|
-
if (e.
|
|
128
|
-
e.
|
|
127
|
+
if (e.Ve !== t) {
|
|
128
|
+
e.Ve = t;
|
|
129
129
|
for (let E = e.o; E !== null; E = E.ue) {
|
|
130
130
|
// Route each subscriber by its own zombie flag, mirroring the
|
|
131
131
|
// post-recompute height-adjust path. Inserting into the running `heap`
|
package/dist/prod/core/lanes.js
CHANGED
|
@@ -19,13 +19,13 @@ const activeLanes = new Set;
|
|
|
19
19
|
// Detect parent lane: _parentSource chains from pendingSignal → pendingValueComputed → original.
|
|
20
20
|
// The child lane should not merge with the parent lane.
|
|
21
21
|
const i = n.nn;
|
|
22
|
-
const r = i?.
|
|
22
|
+
const r = i?.Me ? findLane(i.Me) : null;
|
|
23
23
|
e = {
|
|
24
24
|
en: n,
|
|
25
|
-
|
|
25
|
+
Ne: new Set,
|
|
26
26
|
rn: [ [], [] ],
|
|
27
27
|
tn: null,
|
|
28
|
-
|
|
28
|
+
Ie: activeTransition,
|
|
29
29
|
an: r
|
|
30
30
|
};
|
|
31
31
|
signalLanes.set(n, e);
|
|
@@ -36,8 +36,8 @@ const activeLanes = new Set;
|
|
|
36
36
|
// parent-child is a property of the nodes, not of write order — otherwise
|
|
37
37
|
// the owner's write merges the companion's subscribers into this lane and
|
|
38
38
|
// their effects wait on its async instead of flushing immediately.
|
|
39
|
-
adoptCompanionLane(n.
|
|
40
|
-
adoptCompanionLane(n.
|
|
39
|
+
adoptCompanionLane(n.he, e);
|
|
40
|
+
adoptCompanionLane(n.Ge, e);
|
|
41
41
|
return e;
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -68,8 +68,8 @@ function adoptCompanionLane(n, e) {
|
|
|
68
68
|
// Move (not copy) the merged lane's work: after the merge all routing goes
|
|
69
69
|
// through findLane() to the root, so anything left behind here is dead —
|
|
70
70
|
// and anything *added* here later is a routing bug (INV-5).
|
|
71
|
-
for (const i of e.
|
|
72
|
-
e.
|
|
71
|
+
for (const i of e.Ne) n.Ne.add(i);
|
|
72
|
+
e.Ne.clear();
|
|
73
73
|
n.rn[0].push(...e.rn[0]);
|
|
74
74
|
n.rn[1].push(...e.rn[1]);
|
|
75
75
|
e.rn[0].length = 0;
|
|
@@ -80,11 +80,11 @@ function adoptCompanionLane(n, e) {
|
|
|
80
80
|
/**
|
|
81
81
|
* Resolve a node's lane: follow union-find chain, verify active, clear if stale.
|
|
82
82
|
*/ function resolveLane(n) {
|
|
83
|
-
const e = n.
|
|
83
|
+
const e = n.Me;
|
|
84
84
|
if (!e) return undefined;
|
|
85
85
|
const i = findLane(e);
|
|
86
86
|
if (activeLanes.has(i)) return i;
|
|
87
|
-
n.
|
|
87
|
+
n.Me = undefined;
|
|
88
88
|
return undefined;
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -99,13 +99,13 @@ function resolveTransition(n) {
|
|
|
99
99
|
if (e.fn !== true) return e;
|
|
100
100
|
n.sn = null;
|
|
101
101
|
}
|
|
102
|
-
return resolveLane(n)?.
|
|
102
|
+
return resolveLane(n)?.Ie ?? n.Ie;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* Check if a node has an active optimistic override.
|
|
107
107
|
*/ function hasActiveOverride(n) {
|
|
108
|
-
return !!(n.
|
|
108
|
+
return !!(n.Ae !== undefined && n.Ae !== NOT_PENDING);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/**
|
|
@@ -113,13 +113,13 @@ function resolveTransition(n) {
|
|
|
113
113
|
* a different active lane), merge unless the node has an active override.
|
|
114
114
|
*/ function assignOrMergeLane(n, e) {
|
|
115
115
|
const i = findLane(e);
|
|
116
|
-
const r = n.
|
|
116
|
+
const r = n.Me;
|
|
117
117
|
if (r) {
|
|
118
118
|
// If the subscriber's lane was merged into another lane, it's stale —
|
|
119
119
|
// replace it with the new source lane instead of following the merge chain
|
|
120
120
|
// (which would incorrectly merge the new lane into the old group)
|
|
121
121
|
if (r.tn) {
|
|
122
|
-
n.
|
|
122
|
+
n.Me = e;
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
125
|
const t = findLane(r);
|
|
@@ -128,13 +128,13 @@ function resolveTransition(n) {
|
|
|
128
128
|
// Parent-child lanes stay independent so isPending resolves without
|
|
129
129
|
// waiting for the parent's async. The child keeps ownership.
|
|
130
130
|
if (i.an && findLane(i.an) === t) {
|
|
131
|
-
n.
|
|
131
|
+
n.Me = e;
|
|
132
132
|
} else if (t.an && findLane(t.an) === i) ; else mergeLanes(i, t);
|
|
133
133
|
}
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
n.
|
|
137
|
+
n.Me = e;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
export { activeLanes, assignOrMergeLane, findLane, getOrCreateLane, hasActiveOverride, mergeLanes, resolveLane, resolveTransition, signalLanes };
|
|
@@ -24,8 +24,8 @@ import { GlobalQueue, activeTransition, globalQueue, clock, insertSubs, schedule
|
|
|
24
24
|
* once the gate holds — the same late-binding contract as verdict.ts.
|
|
25
25
|
*/
|
|
26
26
|
/** The optimistic half of setSignal, fired when `_overrideValue !== undefined`. */ function optimisticWrite(e, n) {
|
|
27
|
-
const t = e.
|
|
28
|
-
const i = t ? unwrapOverride(e.
|
|
27
|
+
const t = e.Ae !== NOT_PENDING;
|
|
28
|
+
const i = t ? unwrapOverride(e.Ae) : e.Ue;
|
|
29
29
|
if (typeof n === "function") n = n(i);
|
|
30
30
|
const u = !!(e.S & STATUS_UNINITIALIZED) || !e.Re || !e.Re(i, n);
|
|
31
31
|
if (!u) {
|
|
@@ -41,19 +41,21 @@ import { GlobalQueue, activeTransition, globalQueue, clock, insertSubs, schedule
|
|
|
41
41
|
// No revert target is stashed: while the override is active every reader
|
|
42
42
|
// sees it (A17), so authoritative arrivals commit silently into _value and
|
|
43
43
|
// reverting is just dropping the override — _value is already correct.
|
|
44
|
-
else globalQueue.m.
|
|
44
|
+
else globalQueue.m.je.push(e);
|
|
45
45
|
// Stamp ownership on the node (post-merge, so entangled writers share the
|
|
46
46
|
// joint root). resolveTransition prefers this over the lane's _transition,
|
|
47
47
|
// which a shared subscriber can merge across transactions (#2912).
|
|
48
48
|
e.sn = activeTransition;
|
|
49
49
|
const o = getOrCreateLane(e);
|
|
50
|
-
e.
|
|
50
|
+
e.Me = o;
|
|
51
51
|
// Literal undefined must not land raw: the slot doubles as the optimistic
|
|
52
52
|
// brand, and erasing it makes the write invisible and routes follow-up
|
|
53
53
|
// writes off the optimistic path into permanent commits (#2898).
|
|
54
|
-
e.
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
e.Ae = n === undefined ? OVERRIDE_UNDEFINED : n;
|
|
55
|
+
// syncCompanions only pokes _pendingSignal/_latestValueComputed — with
|
|
56
|
+
// neither companion present the call is a guaranteed no-op.
|
|
57
|
+
(e.he !== undefined || e.Ge !== undefined) && GlobalQueue.De !== null && GlobalQueue.De(e, n);
|
|
58
|
+
e.Se = clock;
|
|
57
59
|
insertSubs(e, true);
|
|
58
60
|
schedule();
|
|
59
61
|
return n;
|
|
@@ -64,8 +66,8 @@ import { GlobalQueue, activeTransition, globalQueue, clock, insertSubs, schedule
|
|
|
64
66
|
* while one of its optimistic nodes holds an active override that is still
|
|
65
67
|
* pending on real (non-affects-sentinel) async.
|
|
66
68
|
*/ function transitionBlocked(e) {
|
|
67
|
-
for (let n = 0; n < e.
|
|
68
|
-
const t = e.
|
|
69
|
+
for (let n = 0; n < e.je.length; n++) {
|
|
70
|
+
const t = e.je[n];
|
|
69
71
|
if (hasActiveOverride(t) && "S" in t && t.S & STATUS_PENDING && t._ instanceof NotReadyError) {
|
|
70
72
|
return true;
|
|
71
73
|
}
|
|
@@ -80,15 +82,15 @@ function resolveOptimisticNodes(e) {
|
|
|
80
82
|
const n = e.length;
|
|
81
83
|
for (let t = 0; t < n; t++) {
|
|
82
84
|
const n = e[t];
|
|
83
|
-
n.
|
|
85
|
+
n.Me = undefined;
|
|
84
86
|
// Revert is a pure drop: there is no revert target to commit —
|
|
85
87
|
// override-covered authoritative values hold in _pendingValue and
|
|
86
88
|
// elevate on their OWN transition's schedule (A18 as re-ruled 2026-07-07).
|
|
87
89
|
if (!(n.S & STATUS_PENDING)) n.S &= ~STATUS_UNINITIALIZED;
|
|
88
|
-
const i = n.
|
|
89
|
-
n.
|
|
90
|
-
if (i !== NOT_PENDING && n.
|
|
91
|
-
n.
|
|
90
|
+
const i = n.Ae;
|
|
91
|
+
n.Ae = NOT_PENDING;
|
|
92
|
+
if (i !== NOT_PENDING && n.Ue !== unwrapOverride(i)) insertSubs(n, true);
|
|
93
|
+
n.Ie = null;
|
|
92
94
|
n.sn = null;
|
|
93
95
|
}
|
|
94
96
|
// Settlement checkpoint (#2838): companions caught in this batch (or owned
|
|
@@ -96,9 +98,9 @@ function resolveOptimisticNodes(e) {
|
|
|
96
98
|
// transition that produced them (A19 — pending is a property of the data).
|
|
97
99
|
for (let t = 0; t < n; t++) {
|
|
98
100
|
const n = e[t];
|
|
99
|
-
if (n.
|
|
101
|
+
if (n.he || n.Ge) GlobalQueue.un(n);
|
|
100
102
|
const i = n.nn;
|
|
101
|
-
if (i && (i.
|
|
103
|
+
if (i && (i.he === n || i.Ge === n)) GlobalQueue.un(i);
|
|
102
104
|
}
|
|
103
105
|
e.splice(0, n);
|
|
104
106
|
}
|
|
@@ -111,7 +113,7 @@ function runQueue(e, n) {
|
|
|
111
113
|
* Run effects from all lanes that are ready (no pending async).
|
|
112
114
|
*/ function runLaneEffects(e) {
|
|
113
115
|
for (const n of activeLanes) {
|
|
114
|
-
if (n.tn || n.
|
|
116
|
+
if (n.tn || n.Ne.size > 0) continue;
|
|
115
117
|
const t = n.rn[e - 1];
|
|
116
118
|
if (t.length) {
|
|
117
119
|
n.rn[e - 1] = [];
|
|
@@ -122,14 +124,14 @@ function runQueue(e, n) {
|
|
|
122
124
|
|
|
123
125
|
function cleanupCompletedLanes(e) {
|
|
124
126
|
for (const n of activeLanes) {
|
|
125
|
-
const t = e ? n.
|
|
127
|
+
const t = e ? n.Ie === e : !n.Ie;
|
|
126
128
|
if (!t) continue;
|
|
127
129
|
if (!n.tn) {
|
|
128
130
|
if (n.rn[0].length) runQueue(n.rn[0], EFFECT_RENDER);
|
|
129
131
|
if (n.rn[1].length) runQueue(n.rn[1], EFFECT_USER);
|
|
130
132
|
}
|
|
131
|
-
if (n.en.
|
|
132
|
-
n.
|
|
133
|
+
if (n.en.Me === n) n.en.Me = undefined;
|
|
134
|
+
n.Ne.clear();
|
|
133
135
|
n.rn[0].length = 0;
|
|
134
136
|
n.rn[1].length = 0;
|
|
135
137
|
activeLanes.delete(n);
|
|
@@ -141,7 +143,7 @@ function cleanupCompletedLanes(e) {
|
|
|
141
143
|
// Per-lane suspension: only throw if in same lane as pending async
|
|
142
144
|
// AND the node doesn't have an active override (overrides are the visible value,
|
|
143
145
|
// downstream in the lane should read the override, not throw)
|
|
144
|
-
const n = e.
|
|
146
|
+
const n = e.Me;
|
|
145
147
|
if (!n) return false;
|
|
146
148
|
return findLane(n) === findLane(currentOptimisticLane) && !hasActiveOverride(e);
|
|
147
149
|
}
|
|
@@ -151,7 +153,7 @@ function cleanupCompletedLanes(e) {
|
|
|
151
153
|
* that reads a pending mid-transition write sees the committed value; the sub
|
|
152
154
|
* is recorded for replay at commit.
|
|
153
155
|
*/ function gatedRead(e, n, t) {
|
|
154
|
-
if (latestReadActive || e.
|
|
156
|
+
if (latestReadActive || e._e === NOT_PENDING || e.ae || n !== e && !(n.se & REACTIVE_MANUAL_WRITE)) {
|
|
155
157
|
return false;
|
|
156
158
|
}
|
|
157
159
|
activeTransition.ln.add(t);
|
|
@@ -162,7 +164,7 @@ function cleanupCompletedLanes(e) {
|
|
|
162
164
|
* read()'s value selection under a lane: return the committed `_value` for
|
|
163
165
|
* optimistic/lane-assigned signals, stale-mode reads, and pending owners.
|
|
164
166
|
*/ function laneReadsCommitted(e, n, t) {
|
|
165
|
-
return e.
|
|
167
|
+
return e.Ae !== undefined || !!e.Me || n === e && stale && t.nn !== e || !!(n.S & STATUS_PENDING);
|
|
166
168
|
}
|
|
167
169
|
|
|
168
170
|
/**
|
|
@@ -171,8 +173,8 @@ function cleanupCompletedLanes(e) {
|
|
|
171
173
|
* can run before its OPT-dirty child propagates).
|
|
172
174
|
*/ function recomputeLane(e, n) {
|
|
173
175
|
if (n) return resolveLane(e) ?? null;
|
|
174
|
-
for (let n = e.
|
|
175
|
-
const t = n.
|
|
176
|
+
for (let n = e.et; n; n = n.tt) {
|
|
177
|
+
const t = n.nt;
|
|
176
178
|
if (t.se & REACTIVE_OPTIMISTIC_DIRTY) {
|
|
177
179
|
const n = resolveLane(t);
|
|
178
180
|
if (n) {
|
|
@@ -188,17 +190,17 @@ function cleanupCompletedLanes(e) {
|
|
|
188
190
|
/** recompute()'s catch path: track pending async in the current lane. */ function laneAsyncPending(e) {
|
|
189
191
|
const n = findLane(currentOptimisticLane);
|
|
190
192
|
if (n.en !== e) {
|
|
191
|
-
n.
|
|
192
|
-
e.
|
|
193
|
-
GlobalQueue.
|
|
193
|
+
n.Ne.add(e);
|
|
194
|
+
e.Me = n;
|
|
195
|
+
GlobalQueue.ce !== null && GlobalQueue.ce(n.en);
|
|
194
196
|
}
|
|
195
197
|
}
|
|
196
198
|
|
|
197
199
|
/** recompute()'s success path: the node's async settled, clear it from its lane. */ function laneAsyncSettled(e) {
|
|
198
200
|
const n = resolveLane(e);
|
|
199
201
|
if (n) {
|
|
200
|
-
n.
|
|
201
|
-
GlobalQueue.
|
|
202
|
+
n.Ne.delete(e);
|
|
203
|
+
GlobalQueue.ce !== null && GlobalQueue.ce(n.en);
|
|
202
204
|
}
|
|
203
205
|
}
|
|
204
206
|
|
|
@@ -213,18 +215,18 @@ function trackOptimisticStore(e) {
|
|
|
213
215
|
* create optimistic state (verdict.ts at module top level, createOptimistic
|
|
214
216
|
* and createOptimisticStore at first call) BEFORE any optimistic node exists.
|
|
215
217
|
*/ function installOptimisticEngine() {
|
|
216
|
-
if (GlobalQueue.
|
|
217
|
-
GlobalQueue.
|
|
218
|
+
if (GlobalQueue.ht !== null) return;
|
|
219
|
+
GlobalQueue.ht = optimisticWrite;
|
|
218
220
|
GlobalQueue.En = resolveOptimisticNodes;
|
|
219
|
-
GlobalQueue.
|
|
220
|
-
GlobalQueue.
|
|
221
|
+
GlobalQueue.dn = transitionBlocked;
|
|
222
|
+
GlobalQueue.Tn = cleanupCompletedLanes;
|
|
221
223
|
GlobalQueue.In = runLaneEffects;
|
|
222
|
-
GlobalQueue.
|
|
223
|
-
GlobalQueue.
|
|
224
|
-
GlobalQueue.
|
|
225
|
-
GlobalQueue.
|
|
226
|
-
GlobalQueue.
|
|
227
|
-
GlobalQueue.
|
|
224
|
+
GlobalQueue.Ot = gatedRead;
|
|
225
|
+
GlobalQueue.Ct = laneSuspends;
|
|
226
|
+
GlobalQueue.Rt = laneReadsCommitted;
|
|
227
|
+
GlobalQueue.Ze = recomputeLane;
|
|
228
|
+
GlobalQueue.ze = laneAsyncPending;
|
|
229
|
+
GlobalQueue.Ke = laneAsyncSettled;
|
|
228
230
|
GlobalQueue.Nn = trackOptimisticStore;
|
|
229
231
|
}
|
|
230
232
|
|