@solidjs/signals 2.0.0-rc.13 → 2.0.0-rc.14
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-shared.js +2000 -3768
- package/dist/dev.attribution.js +132 -79
- package/dist/dev.js +7226 -8488
- package/dist/observe/affects.js +125 -104
- package/dist/observe/boundaries.js +458 -665
- package/dist/observe/core/action.js +63 -66
- package/dist/observe/core/async.js +240 -383
- package/dist/observe/core/attribution-queries.js +1 -1
- package/dist/observe/core/attribution.js +240 -183
- package/dist/observe/core/constants.js +115 -187
- package/dist/observe/core/context.js +3 -3
- package/dist/observe/core/core.js +840 -1438
- package/dist/observe/core/dev.js +3 -3
- package/dist/observe/core/effect.js +75 -86
- package/dist/observe/core/external.js +5 -5
- package/dist/observe/core/graph.js +61 -70
- package/dist/observe/core/heap.js +75 -98
- package/dist/observe/core/invariants.js +1 -34
- package/dist/observe/core/lanes.js +704 -181
- package/dist/observe/core/owner.js +80 -101
- package/dist/observe/core/scheduler.js +708 -1351
- package/dist/observe/core/verdict.js +302 -621
- package/dist/observe/flatten.js +79 -0
- package/dist/observe/index.js +15 -13
- package/dist/observe/map.js +232 -235
- package/dist/observe/reveal.js +212 -0
- package/dist/observe/signals.js +133 -215
- package/dist/observe/store/affects.js +135 -0
- package/dist/observe/store/index.js +29 -24
- package/dist/observe/store/optimistic.js +538 -0
- package/dist/observe/store/projection.js +302 -0
- package/dist/observe/store/reconcile.js +257 -0
- package/dist/observe/store/store.js +1945 -277
- package/dist/observe/store/storePath.js +1 -1
- package/dist/{prod/store/next → observe/store}/target.js +17 -18
- package/dist/observe/store/types.js +73 -0
- package/dist/observe/store/utils.js +1 -13
- package/dist/prod/affects.js +127 -106
- package/dist/prod/boundaries.js +442 -654
- package/dist/prod/core/action.js +71 -74
- package/dist/prod/core/async.js +307 -442
- package/dist/prod/core/constants.js +112 -186
- package/dist/prod/core/context.js +3 -3
- package/dist/prod/core/core.js +852 -1458
- package/dist/prod/core/effect.js +88 -99
- package/dist/prod/core/external.js +5 -5
- package/dist/prod/core/graph.js +61 -70
- package/dist/prod/core/heap.js +75 -98
- package/dist/prod/core/invariants.js +1 -32
- package/dist/prod/core/lanes.js +666 -181
- package/dist/prod/core/owner.js +75 -96
- package/dist/prod/core/scheduler.js +677 -1332
- package/dist/prod/core/verdict.js +297 -621
- package/dist/prod/flatten.js +77 -0
- package/dist/prod/index.js +15 -13
- package/dist/prod/map.js +143 -146
- package/dist/prod/reveal.js +212 -0
- package/dist/prod/signals.js +144 -226
- package/dist/prod/store/affects.js +135 -0
- package/dist/prod/store/index.js +28 -19
- package/dist/prod/store/optimistic.js +533 -0
- package/dist/prod/store/projection.js +295 -0
- package/dist/prod/store/reconcile.js +257 -0
- package/dist/prod/store/store.js +1840 -272
- package/dist/prod/store/storePath.js +1 -1
- package/dist/{observe/store/next → prod/store}/target.js +13 -17
- package/dist/prod/store/types.js +73 -0
- package/dist/prod/store/utils.js +1 -11
- package/dist/types/affects.d.ts +11 -30
- package/dist/types/boundaries.d.ts +62 -176
- package/dist/types/carved.d.ts +1 -0
- package/dist/types/core/action.d.ts +5 -6
- package/dist/types/core/async.d.ts +10 -5
- package/dist/types/core/attribution-hooks.d.ts +20 -1
- package/dist/types/core/attribution.d.ts +20 -9
- package/dist/types/core/constants.d.ts +125 -180
- package/dist/types/core/core.d.ts +104 -264
- package/dist/types/core/dev.d.ts +2 -2
- package/dist/types/core/effect.d.ts +0 -7
- package/dist/types/core/graph.d.ts +7 -1
- package/dist/types/core/heap.d.ts +5 -7
- package/dist/types/core/index.d.ts +5 -5
- package/dist/types/core/invariants.d.ts +0 -29
- package/dist/types/core/lanes.d.ts +65 -87
- package/dist/types/core/owner.d.ts +3 -3
- package/dist/types/core/scheduler.d.ts +249 -331
- package/dist/types/core/types.d.ts +51 -85
- package/dist/types/core/verdict.d.ts +3 -0
- package/dist/types/flatten.d.ts +8 -0
- package/dist/types/index.d.ts +6 -4
- package/dist/types/reveal.d.ts +19 -0
- package/dist/types/signals.d.ts +35 -91
- package/dist/types/store/affects.d.ts +1 -0
- package/dist/types/store/index.d.ts +35 -15
- package/dist/types/store/optimistic.d.ts +23 -0
- package/dist/types/store/projection.d.ts +18 -0
- package/dist/types/store/reconcile.d.ts +3 -0
- package/dist/types/store/store.d.ts +165 -143
- package/dist/types/store/storePath.d.ts +1 -1
- package/dist/types/store/target.d.ts +151 -0
- package/dist/types/store/types.d.ts +84 -0
- package/package.json +1 -1
- package/dist/observe/core/optimistic.js +0 -669
- package/dist/observe/store/next/optimistic.js +0 -717
- package/dist/observe/store/next/projection.js +0 -266
- package/dist/observe/store/next/reconcile.js +0 -375
- package/dist/observe/store/next/store.js +0 -2608
- package/dist/prod/core/optimistic.js +0 -658
- package/dist/prod/store/next/optimistic.js +0 -710
- package/dist/prod/store/next/projection.js +0 -257
- package/dist/prod/store/next/reconcile.js +0 -373
- package/dist/prod/store/next/store.js +0 -2484
- package/dist/types/core/optimistic.d.ts +0 -6
- package/dist/types/store/next/optimistic.d.ts +0 -25
- package/dist/types/store/next/projection.d.ts +0 -27
- package/dist/types/store/next/reconcile.d.ts +0 -10
- package/dist/types/store/next/store.d.ts +0 -145
- package/dist/types/store/next/target.d.ts +0 -196
package/dist/prod/core/core.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { releaseFlightTeardown, handleAsync, clearStatus, parkLoadingWindow, notifyStatus, settlePendingSource, settleErroredDependents } from "./async.js";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { STATUS_UNINITIALIZED, REACTIVE_LAZY, REACTIVE_NONE, defaultContext, CONFIG_TRANSPARENT, CONFIG_OWNED_WRITE, CONFIG_AUTO_DISPOSE, CONFIG_SYNC, CONFIG_NO_SNAPSHOT, CONFIG_IN_SNAPSHOT_SCOPE, NOT_PENDING, NO_SNAPSHOT, CONFIG_HAS_SNAPSHOT, CONFIG_HELD, REACTIVE_MANUAL_WRITE, REACTIVE_DIRTY, CONFIG_OVERRIDE, REACTIVE_DISPOSED, REACTIVE_CHECK, REACTIVE_IN_HEAP, REACTIVE_REASK, REACTIVE_SNAPSHOT_STALE, REACTIVE_LANE_DIRTY, CONFIG_GUESS, REACTIVE_RECOMPUTING_DEPS, EFFECT_RENDER, CONFIG_VERDICT, EFFECT_TRACKED, CONFIG_STAGED, STATUS_ERROR, STATUS_PENDING, REACTIVE_ZOMBIE, REACTIVE_MISSED_WAKE, REACTIVE_JOINED, REACTIVE_PROBED, REACTIVE_FRAME_READ, REACTIVE_STAGED_READ, REACTIVE_LANE_READ, REACTIVE_SCREEN_READ, REACTIVE_PROBE_UNANSWERED, CONFIG_CHILDREN_FORBIDDEN, CONFIG_PROMOTED, CONFIG_INPUTS_PUBLISHED, CONFIG_FRESH_READ, REACTIVE_IN_HEAP_HEIGHT, CONFIG_SLOT_NODE, EFFECT_USER } from "./constants.js";
|
|
4
4
|
|
|
5
5
|
import { NotReadyError } from "./error.js";
|
|
6
6
|
|
|
7
7
|
import { clearDeps, trimStaleDeps, link, dormantNodes } from "./graph.js";
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { insertIntoHeap, deleteFromHeap, insertIntoHeapHeight, enqueueSub, markNode, markHeap } from "./heap.js";
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { inheritId, disposeChildren, linkChild, markDisposal } from "./owner.js";
|
|
12
12
|
|
|
13
|
-
import "./
|
|
14
|
-
|
|
15
|
-
import { disposeChildren, markDisposal, linkChild, inheritId } from "./owner.js";
|
|
16
|
-
|
|
17
|
-
import { GlobalQueue, bumpNotifyEpoch, activeTransition, globalQueue, clock, currentTransition, insertSubs, queuePendingNode, wakeParked, heldTrims, runInTransition, schedule, batchJoins, notifyEpoch, dirtyQueue, projectionWriteActive, reaskArmed, armReaskClear } from "./scheduler.js";
|
|
13
|
+
import { schedule, GlobalQueue, clock, txOf, flushTransaction, joinFuture, queuePendingNode, globalQueue, notifyEpoch, insertSubs, dirtyQueue, bumpNotifyEpoch, setPassLane, passLane, joinPassTx, passTx, holdNode, laneDirty, heldTrim, staleReader, stagedReaders, deferZombie } from "./scheduler.js";
|
|
18
14
|
|
|
19
15
|
// The heap's per-node step. A tracked effect's heap visit is its compute
|
|
20
16
|
// phase — empty, like a user effect whose compute reads nothing — and hands
|
|
@@ -24,62 +20,34 @@ import { GlobalQueue, bumpNotifyEpoch, activeTransition, globalQueue, clock, cur
|
|
|
24
20
|
// render-effect callback stages its value for the next pass, but a wake pushed
|
|
25
21
|
// directly into the user queue ran in the SAME pass, read the old value, and
|
|
26
22
|
// nothing re-notified it when the value landed (#3291).
|
|
27
|
-
GlobalQueue.
|
|
28
|
-
if (e.
|
|
29
|
-
deleteFromHeap(e,
|
|
30
|
-
e.
|
|
31
|
-
|
|
32
|
-
}
|
|
23
|
+
GlobalQueue.Ce = e => {
|
|
24
|
+
if (e.i === EFFECT_TRACKED) {
|
|
25
|
+
deleteFromHeap(e, dirtyQueue);
|
|
26
|
+
e.Fe = true;
|
|
27
|
+
globalQueue.enqueue(EFFECT_USER, e.q);
|
|
28
|
+
}
|
|
29
|
+
// L2: a zombie's fate is the seam's — its owner's commit disposes it, or
|
|
30
|
+
// the park cancels the pass (the write that dirtied it is held). It runs
|
|
31
|
+
// only past a seam that left it alive (a live write to a frame whose
|
|
32
|
+
// owner is held in the future). Its lane's own re-staging is a live write
|
|
33
|
+
// (REACTIVE_LANE_DIRTY — a lane shows ahead of any park): it runs now, as
|
|
34
|
+
// the lane's work, for the reveal this seam (#3463).
|
|
35
|
+
else if (e.R & REACTIVE_ZOMBIE && !(e.R & REACTIVE_LANE_DIRTY)) deferZombie(e); else recompute(e);
|
|
33
36
|
};
|
|
34
37
|
|
|
35
|
-
GlobalQueue.
|
|
38
|
+
GlobalQueue.he = disposeChildren;
|
|
36
39
|
|
|
37
40
|
let tracking = false;
|
|
38
41
|
|
|
39
|
-
/** @internal verdict-module glue */ function setPendingCheckActive(e) {
|
|
40
|
-
pendingCheckActive = e;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** @internal verdict-module glue */ function setLatestReadActive(e) {
|
|
44
|
-
latestReadActive = e;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** @internal verdict-module glue */ function setContextInternal(e) {
|
|
48
|
-
context = e;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let stale = false;
|
|
52
|
-
|
|
53
|
-
let pendingCheckActive = false;
|
|
54
|
-
|
|
55
|
-
let latestReadActive = false;
|
|
56
|
-
|
|
57
42
|
let context = null;
|
|
58
43
|
|
|
59
|
-
let currentOptimisticLane = null;
|
|
60
|
-
|
|
61
|
-
/** Notify `node`'s subscribers on `lane`'s channel: they recompute as the
|
|
62
|
-
* lane's passes — a memo publishes a derived override (lanes stage, #3479),
|
|
63
|
-
* an effect runs from the lane's queue, at the park, ahead of the
|
|
64
|
-
* transaction — the display-ahead view. The write itself is already staged
|
|
65
|
-
* (setSignal) and commits with the frame; this walk shows it now. Used by a
|
|
66
|
-
* boundary re-armed from a lane pass (boundaries.ts `_swap`, #3540). */ function notifyOnLane(e, n) {
|
|
67
|
-
const t = currentOptimisticLane;
|
|
68
|
-
currentOptimisticLane = n;
|
|
69
|
-
try {
|
|
70
|
-
insertSubs(e, true);
|
|
71
|
-
} finally {
|
|
72
|
-
currentOptimisticLane = t;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
44
|
let snapshotCaptureActive = false;
|
|
77
45
|
|
|
78
46
|
let snapshotSources = null;
|
|
79
47
|
|
|
80
48
|
function ownerInSnapshotScope(e) {
|
|
81
49
|
while (e) {
|
|
82
|
-
if (e.
|
|
50
|
+
if (e.Ve) return true;
|
|
83
51
|
e = e._parent;
|
|
84
52
|
}
|
|
85
53
|
return false;
|
|
@@ -91,34 +59,34 @@ function setSnapshotCapture(e) {
|
|
|
91
59
|
}
|
|
92
60
|
|
|
93
61
|
function markSnapshotScope(e) {
|
|
94
|
-
e.
|
|
62
|
+
e.Ve = true;
|
|
95
63
|
}
|
|
96
64
|
|
|
97
65
|
function releaseSnapshotScope(e) {
|
|
98
|
-
e.
|
|
66
|
+
e.Ve = false;
|
|
99
67
|
releaseSubtree(e);
|
|
100
68
|
schedule();
|
|
101
69
|
}
|
|
102
70
|
|
|
103
71
|
function releaseSubtree(e) {
|
|
104
|
-
let
|
|
105
|
-
while (
|
|
106
|
-
if (
|
|
107
|
-
|
|
72
|
+
let t = e.ge;
|
|
73
|
+
while (t) {
|
|
74
|
+
if (t.Ve) {
|
|
75
|
+
t = t.me;
|
|
108
76
|
continue;
|
|
109
77
|
}
|
|
110
|
-
if (
|
|
111
|
-
const e =
|
|
112
|
-
e.
|
|
113
|
-
if (e.
|
|
114
|
-
e.
|
|
115
|
-
e.
|
|
116
|
-
if (dirtyQueue.
|
|
78
|
+
if (t.re) {
|
|
79
|
+
const e = t;
|
|
80
|
+
e.u &= ~CONFIG_IN_SNAPSHOT_SCOPE;
|
|
81
|
+
if (e.R & REACTIVE_SNAPSHOT_STALE) {
|
|
82
|
+
e.R &= ~REACTIVE_SNAPSHOT_STALE;
|
|
83
|
+
e.R |= REACTIVE_DIRTY;
|
|
84
|
+
if (dirtyQueue.He > e.Le) dirtyQueue.He = e.Le;
|
|
117
85
|
insertIntoHeap(e, dirtyQueue);
|
|
118
86
|
}
|
|
119
87
|
}
|
|
120
|
-
releaseSubtree(
|
|
121
|
-
|
|
88
|
+
releaseSubtree(t);
|
|
89
|
+
t = t.me;
|
|
122
90
|
}
|
|
123
91
|
}
|
|
124
92
|
|
|
@@ -129,256 +97,160 @@ function clearSnapshots() {
|
|
|
129
97
|
// pre-initialized to undefined (see ext()), and every reader tests
|
|
130
98
|
// `!== undefined` — assign, don't `delete`: deleting a field pushes the
|
|
131
99
|
// object to dictionary mode for every later read of every field.
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
// StoreNode targets share one pre-initialized hidden class (see
|
|
135
|
-
// createStoreProxy) — same rule, and only when present so signal-node
|
|
136
|
-
// sources don't grow the field.
|
|
137
|
-
if (e[STORE_SNAPSHOT_PROPS] !== undefined) e[STORE_SNAPSHOT_PROPS] = undefined;
|
|
100
|
+
const t = e.m;
|
|
101
|
+
if (t != null) t.xe = undefined;
|
|
138
102
|
}
|
|
139
103
|
snapshotSources = null;
|
|
140
104
|
}
|
|
141
105
|
snapshotCaptureActive = false;
|
|
142
106
|
}
|
|
143
107
|
|
|
144
|
-
function recompute(e,
|
|
108
|
+
function recompute(e, t = false) {
|
|
145
109
|
// §12d: any recompute can clean a marked subscriber — invalidate skips.
|
|
146
110
|
bumpNotifyEpoch();
|
|
147
|
-
const
|
|
148
|
-
//
|
|
149
|
-
//
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
} else if (activeTransition && !n && activeTransition.cn.length) {
|
|
173
|
-
// Lane adoption: parent-deeper-than-owned-child can run before its OPT-dirty
|
|
174
|
-
// child propagates. Walk deps once and inherit the OPT lane so this node
|
|
175
|
-
// recomputes under the right posture and propagates correctly.
|
|
176
|
-
u = GlobalQueue.an(e, false);
|
|
177
|
-
if (u) i = true;
|
|
178
|
-
}
|
|
179
|
-
if (!n) {
|
|
180
|
-
// A stamped memo re-enters its hold: its value is that transaction's work.
|
|
181
|
-
// An effect's pass belongs to whatever dirtied it (A15 corollary: effects
|
|
182
|
-
// don't entangle parallel transactions); it joins its stamp only when the
|
|
183
|
-
// pass observes the held flight — queue notification (#3407).
|
|
184
|
-
if (e.we && !t && activeTransition !== e.we) globalQueue.initTransition(e.we);
|
|
185
|
-
deleteFromHeap(e, queueFor(e));
|
|
186
|
-
if (e.o !== null) {
|
|
187
|
-
e.o.Ce = null;
|
|
111
|
+
const n = e.i;
|
|
112
|
+
// Lanes (plan sec. 28): the seat of a pass is its node's. A node carrying a lane's
|
|
113
|
+
// derived value runs as the lane's whoever dirtied it — a sync write, a
|
|
114
|
+
// boundary reset, a frame rerun — so its children and its result are the
|
|
115
|
+
// lane's; so does a member the lane's own re-staging dirtied
|
|
116
|
+
// (REACTIVE_LANE_DIRTY, lanes.ts — a leaf the lane owns). A written guess's
|
|
117
|
+
// own pass is its truth arriving (A18), the frame's. A first pass is its
|
|
118
|
+
// creator's (ruling A: a lane pass's children are the lane's frame), and
|
|
119
|
+
// under a guess's lane it reads as the lane's too — a binding the lane
|
|
120
|
+
// mounts sees the screen, like the pass that mounted it (#3835). Not
|
|
121
|
+
// under a verdict lane, for its reads or its result: a verdict lane holds
|
|
122
|
+
// verdicts, and a mount it makes is a mainline mount (A29's boundary
|
|
123
|
+
// exemption, #3851). A tracked read of a lane's value moves a
|
|
124
|
+
// derivation's pass into the lane (`read`); a leaf's never moves.
|
|
125
|
+
// Restored at the end, after this pass's staging and runs have been
|
|
126
|
+
// routed.
|
|
127
|
+
const E = passLane;
|
|
128
|
+
setPassLane((e.R & REACTIVE_LANE_DIRTY || (e.u & (CONFIG_OVERRIDE | CONFIG_GUESS)) === CONFIG_OVERRIDE) && e.m?.ke?.Z ? e.m.ke : // Loose `!=`: false with no creator lane (undefined == null).
|
|
129
|
+
t && E?._parent.ye != E && (creatorPass(context)?.R ?? 0) & REACTIVE_RECOMPUTING_DEPS ? E : null);
|
|
130
|
+
// CARVE 2: lane posture resolution (OPTIMISTIC_DIRTY, derived-override
|
|
131
|
+
// re-derivation, lane adoption through deps) went with the optimistic engine.
|
|
132
|
+
if (!t) {
|
|
133
|
+
deleteFromHeap(e, dirtyQueue);
|
|
134
|
+
if (e.m !== null) {
|
|
135
|
+
e.m.De = null;
|
|
188
136
|
// Supersede is where an iterator flight dies (#3122): close it now.
|
|
189
|
-
//
|
|
190
|
-
// disposal list that a held transition only drains when the
|
|
191
|
-
// SUPERSEDING flight settles — cancellation must not wait for the
|
|
192
|
-
// work that replaced it. Idempotent with the cleanup-channel close.
|
|
137
|
+
// Idempotent with the cleanup-channel close.
|
|
193
138
|
releaseFlightTeardown(e);
|
|
194
139
|
}
|
|
195
|
-
//
|
|
196
|
-
//
|
|
197
|
-
//
|
|
198
|
-
//
|
|
199
|
-
//
|
|
200
|
-
//
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
//
|
|
204
|
-
//
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
// stamped-memo arm above — a `Show` whose `when` getter owns a
|
|
220
|
-
// compiler-emitted memo held an unrelated sync write for the action's
|
|
221
|
-
// lifetime, against the #3460 ruling that a lane never holds a sync write.
|
|
222
|
-
if (t === EFFECT_TRACKED || e.C & (CONFIG_HELD_CHILDREN | CONFIG_LANE_FRAME)) disposeChildren(e); else if (e.tn !== null || e.qe !== null) {
|
|
223
|
-
markDisposal(e);
|
|
224
|
-
const n = ext(e);
|
|
225
|
-
n.fn = e.qe;
|
|
226
|
-
n._n = e.tn;
|
|
227
|
-
e.qe = null;
|
|
228
|
-
e.tn = null;
|
|
229
|
-
e.En = 0;
|
|
230
|
-
if (u) {
|
|
231
|
-
e.C |= CONFIG_LANE_FRAME;
|
|
232
|
-
findLane(u).dn[0].push(() => {
|
|
233
|
-
e.C &= ~CONFIG_LANE_FRAME;
|
|
234
|
-
disposeChildren(e, false, true);
|
|
235
|
-
});
|
|
140
|
+
// L2: a pass over a held derivation joins its transaction — the
|
|
141
|
+
// propagation that reached this node reached the transaction, and this
|
|
142
|
+
// pass's answer replaces the held one there. A node held with nothing
|
|
143
|
+
// staged — pending when its flush parked, or a member of a held frame —
|
|
144
|
+
// joins all the same. Not a render effect (rule 3): it is the frame.
|
|
145
|
+
// Re-run outside its transaction's flush it publishes mainline — the
|
|
146
|
+
// value it staged there is superseded (`frameRead` remembers it for the
|
|
147
|
+
// landing). A frame born into the transaction (uninitialized: never run,
|
|
148
|
+
// A29) keeps staging: live writes keep it current, it effects at the
|
|
149
|
+
// swap (ruling A).
|
|
150
|
+
if (e.u & CONFIG_HELD) {
|
|
151
|
+
const t = txOf(e);
|
|
152
|
+
// Held by a blocked lane: the frame joins nothing — a lane never holds
|
|
153
|
+
// a sync write (#3460). The pass is the lane's if it reads the lane's
|
|
154
|
+
// world (`read`), and has left it otherwise.
|
|
155
|
+
if (t.Z) ; else if (n !== EFFECT_RENDER && !(e.u & CONFIG_VERDICT)) joinPassTx(t); else if (t !== flushTransaction && !(e.G & STATUS_UNINITIALIZED)) {
|
|
156
|
+
// Published mainline, it is not held: the frame this pass builds is
|
|
157
|
+
// replaced on the spot (#3404) — this flush's commit retires the
|
|
158
|
+
// committed frame the held pass had parked (`commitPendingNode`),
|
|
159
|
+
// after the new frame's first runs, and the held pass's own
|
|
160
|
+
// children die below (`disposeChildren`). The landing re-derives a
|
|
161
|
+
// fresh held frame for the reveal (`_reruns`).
|
|
162
|
+
e.Ae = NOT_PENDING;
|
|
163
|
+
if (n === EFFECT_RENDER) e.u &= ~CONFIG_HELD;
|
|
236
164
|
}
|
|
237
|
-
}
|
|
165
|
+
}
|
|
166
|
+
// The previous pass's frame. If that pass is still awaiting its commit
|
|
167
|
+
// (CONFIG_STAGED) its children were never shown and die on the spot — the
|
|
168
|
+
// frame parked before it stays parked. Otherwise they ARE the frame:
|
|
169
|
+
// park them until this pass commits. Tracked effects run after the seam
|
|
170
|
+
// and own nothing to park.
|
|
171
|
+
if (n === EFFECT_TRACKED || e.u & CONFIG_STAGED) disposeChildren(e); else if (e.ge !== null || e.Pe !== null) parkChildren(e);
|
|
238
172
|
}
|
|
239
|
-
|
|
240
|
-
// one: a plain pass over it — its source superseded (A18) — stages the truth
|
|
241
|
-
// and supersedes the override through the sync twin below.
|
|
242
|
-
const l = (e.C & (CONFIG_OPTIMISTIC | CONFIG_DERIVED_OVERRIDE)) !== 0 && e.o?.Fe !== NOT_PENDING && e.o?.Fe !== undefined;
|
|
243
|
-
const r = !!(e.h & STATUS_UNINITIALIZED);
|
|
173
|
+
const u = !!(e.G & STATUS_UNINITIALIZED);
|
|
244
174
|
// Capture both error and pending status before the compute clears them.
|
|
245
175
|
// A conditional can drop its pending source and recover to an unchanged
|
|
246
176
|
// value, leaving blocked dependents outside that source’s settle walk.
|
|
247
|
-
const
|
|
248
|
-
const
|
|
249
|
-
const
|
|
177
|
+
const s = e.G & STATUS_ERROR ? e.m?.V : undefined;
|
|
178
|
+
const i = (e.G & STATUS_PENDING) !== 0;
|
|
179
|
+
const l = i ? e.m?.Se : undefined;
|
|
250
180
|
// Pending SOURCE-hood, captured before the compute clears status: a node
|
|
251
181
|
// whose own flight parked dependents self-registers in _pendingSources
|
|
252
182
|
// (notifyStatus, isSource). If this recompute supersedes that flight and
|
|
253
183
|
// settles synchronously, those dependents settle HERE — asyncWrite's
|
|
254
184
|
// settlePendingSource walk never runs for a landing that was preempted
|
|
255
185
|
// (#3181).
|
|
256
|
-
const
|
|
257
|
-
//
|
|
258
|
-
// the
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
// commits (commitPendingNode) — a closed window plus a held value reads as
|
|
263
|
-
// a pending frame to live observers of the verdict (#2990).
|
|
264
|
-
const _ = e.ve;
|
|
265
|
-
// Creation-time A29 (see enterStagedRead): a pass outside a flush that is
|
|
266
|
-
// served a live transaction's staged value records the transaction here
|
|
267
|
-
// and is staged INTO it below — "born held" — instead of committing.
|
|
268
|
-
const E = stagedEntry;
|
|
269
|
-
stagedEntry = null;
|
|
270
|
-
const d = context;
|
|
186
|
+
const _ = e.m?.Se?.has(e);
|
|
187
|
+
// A19 exc. 2: a `refresh()` re-asks the question already answered — quiet
|
|
188
|
+
// for the verdict — unless the question in flight is a new one, which the
|
|
189
|
+
// re-ask does not launder (a poll during a quiet confirm stays quiet).
|
|
190
|
+
const o = (e.R & REACTIVE_REASK) !== 0 && !(e.G & STATUS_PENDING && e.m !== null && !e.m.be);
|
|
191
|
+
const r = context;
|
|
271
192
|
context = e;
|
|
272
|
-
e.
|
|
273
|
-
e.
|
|
274
|
-
// REACTIVE_ZOMBIE is position
|
|
275
|
-
//
|
|
276
|
-
//
|
|
277
|
-
//
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
//
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
let
|
|
284
|
-
let
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
let
|
|
193
|
+
e.S = null;
|
|
194
|
+
e.Ge++;
|
|
195
|
+
// REACTIVE_ZOMBIE is position: it says the node sits on its owner's parked
|
|
196
|
+
// frame, and the splice/reawaken paths key off it. A zombie reruns for
|
|
197
|
+
// live writes until the commit that disposes it, so every per-pass wipe
|
|
198
|
+
// — here, the finally below, updateIfNecessary — carries it (#3543).
|
|
199
|
+
e.R = REACTIVE_RECOMPUTING_DEPS | e.R & REACTIVE_ZOMBIE;
|
|
200
|
+
e.Ne = clock;
|
|
201
|
+
// The pass's previous value: its staging, else the lane's value for a
|
|
202
|
+
// lane's node (lanes.ts), else the committed one.
|
|
203
|
+
let I = e.Ae !== NOT_PENDING ? e.Ae : e.u & CONFIG_OVERRIDE ? e.m.Z : e.pe;
|
|
204
|
+
let a = e.Le;
|
|
205
|
+
let N = false;
|
|
206
|
+
// L2: did this pass read the future (REACTIVE_JOINED, set by read)?
|
|
207
|
+
let f = false;
|
|
208
|
+
let T = tracking;
|
|
288
209
|
tracking = true;
|
|
289
|
-
// A computed's fn establishes its OWN dependencies, so it must never run
|
|
290
|
-
// inside a latest() read window: read() short-circuits through the
|
|
291
|
-
// companion path before dependency linking, so a memo created (eagerly
|
|
292
|
-
// computed) inside latest(fn) came out permanently dependency-less (#2926).
|
|
293
|
-
// latestRead() already suspends the flag for its pull-recomputes; this
|
|
294
|
-
// covers creation-time computes and flushes that run inside the window.
|
|
295
|
-
const A = latestReadActive;
|
|
296
|
-
latestReadActive = false;
|
|
297
|
-
// A memo computes under its OWN lane posture, never the puller's (A31,
|
|
298
|
-
// #3442): its value is one shared slot every reader sees, so a pull from a
|
|
299
|
-
// lane-carrying reader (a probe effect on its companion lane pulling a sync
|
|
300
|
-
// memo) must not run it with that lane's read carve-outs — under a lane, a
|
|
301
|
-
// pending node on no lane serves its committed value instead of throwing,
|
|
302
|
-
// and the memo then published a stale "settled" value, dropped its
|
|
303
|
-
// pending status, and stopped holding its transaction. The branches below
|
|
304
|
-
// re-establish the posture the memo itself owns (OPT-dirty, or adopted
|
|
305
|
-
// through its deps). Effects keep the ambient lane: their runs are the
|
|
306
|
-
// lane's own view.
|
|
307
|
-
if (!t) currentOptimisticLane = null;
|
|
308
|
-
// Lane posture lives with the engine: OPTIMISTIC_DIRTY is only ever set by
|
|
309
|
-
// engine-driven paths, and _optimisticNodes is only pushed by
|
|
310
|
-
// _optimisticWrite, so the hook is installed whenever either gate holds.
|
|
311
|
-
// (Resolved at the top of this pass, ahead of the parking site.)
|
|
312
|
-
if (u) currentOptimisticLane = u;
|
|
313
|
-
const C = t && t !== EFFECT_USER;
|
|
314
|
-
const p = stale;
|
|
315
|
-
if (C) stale = true;
|
|
316
|
-
// An effect recorded for this transaction's commit replay (it once read a
|
|
317
|
-
// node the transaction held and showed the committed value) and now
|
|
318
|
-
// recomputing UNDER the transaction sees its staged view: the value this
|
|
319
|
-
// run produces is applied by the commit itself, and the stale recording
|
|
320
|
-
// would publish the frame a second time. Drop it; the reads below re-record
|
|
321
|
-
// if they are served the committed view again (a lane's committed read).
|
|
322
|
-
if (t && activeTransition !== null && activeTransition.In.size) activeTransition.In.delete(e);
|
|
323
210
|
try {
|
|
324
|
-
if (!false && e.
|
|
325
|
-
|
|
326
|
-
if (e.
|
|
327
|
-
e.
|
|
211
|
+
if (!false && e.u & CONFIG_SYNC) {
|
|
212
|
+
I = e.re(I);
|
|
213
|
+
if (e.m !== null) e.m.De = null;
|
|
214
|
+
e._e = false;
|
|
328
215
|
} else {
|
|
329
|
-
//
|
|
330
|
-
//
|
|
331
|
-
//
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if (!u && !i) {
|
|
340
|
-
if (e.o !== null) e.o.Ce = null;
|
|
216
|
+
// A projection's body self-registers its flight through handleAsync
|
|
217
|
+
// (with the commit as setter): its undefined return is not a sync
|
|
218
|
+
// answer, and the outer handleAsync must not clobber the registration.
|
|
219
|
+
const t = e.m?.De;
|
|
220
|
+
const n = e.re(I);
|
|
221
|
+
const E = typeof n === "object" && n !== null;
|
|
222
|
+
const u = e.m?.De !== t;
|
|
223
|
+
I = u || !E ? n : handleAsync(e, n);
|
|
224
|
+
if (!u && !E) {
|
|
225
|
+
if (e.m !== null) e.m.De = null;
|
|
341
226
|
// A sync (non-object) return is the first real answer; async-shaped
|
|
342
227
|
// results clear inside handleAsync at their own landing points, and a
|
|
343
|
-
// self-registered flight
|
|
344
|
-
|
|
345
|
-
e.ve = false;
|
|
228
|
+
// self-registered flight clears when its own handleAsync lands.
|
|
229
|
+
e._e = false;
|
|
346
230
|
}
|
|
347
231
|
}
|
|
348
232
|
// On a status-free node clearStatus is a guaranteed no-op: every field
|
|
349
233
|
// its body gates on is either _statusFlags or lives in the cold
|
|
350
234
|
// extension — no extension, no status to clear. (_x from an unrelated
|
|
351
235
|
// installer just makes clearStatus a cheap re-verified no-op.)
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
// is their sticky presence mark).
|
|
357
|
-
if (e.C & CONFIG_HAS_LANE && e.o?.me) GlobalQueue.Tn(e);
|
|
358
|
-
} catch (n) {
|
|
359
|
-
const t = n instanceof NotReadyError;
|
|
360
|
-
if (t && e.ve) {
|
|
236
|
+
if (e.G !== 0 || e.m !== null) clearStatus(e, t);
|
|
237
|
+
} catch (t) {
|
|
238
|
+
const n = t instanceof NotReadyError;
|
|
239
|
+
if (n && e._e) {
|
|
361
240
|
// Loading window with an unready sync dependency: register for the
|
|
362
241
|
// source's settle (the settlePendingSource walk runs off
|
|
363
242
|
// _pendingSources + _blocked alone) but take NO read-visible pending
|
|
364
|
-
// status
|
|
365
|
-
//
|
|
243
|
+
// status and no downstream propagation — the committed loading value
|
|
244
|
+
// keeps serving. If the
|
|
366
245
|
// node is currently errored the error stays the answer until this
|
|
367
246
|
// retry can actually run.
|
|
368
|
-
parkLoadingWindow(e,
|
|
247
|
+
parkLoadingWindow(e, t);
|
|
369
248
|
} else {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
if (t && currentOptimisticLane) GlobalQueue.Sn(e);
|
|
373
|
-
let i = false;
|
|
374
|
-
if (t) {
|
|
375
|
-
ext(e).Pe = true;
|
|
376
|
-
if (GlobalQueue.On !== null) i = GlobalQueue.On(e, f);
|
|
377
|
-
}
|
|
378
|
-
notifyStatus(e, t ? STATUS_PENDING : STATUS_ERROR, n, undefined, t ? e.o?.me : undefined);
|
|
249
|
+
if (n) ext(e).Ie = true;
|
|
250
|
+
notifyStatus(e, n ? STATUS_PENDING : STATUS_ERROR, t);
|
|
379
251
|
// The replacement source is fully propagated now. If no new flight
|
|
380
252
|
// re-owned self, retire the superseded flight and its dependent copies.
|
|
381
|
-
if (
|
|
253
|
+
if (n && _ && !e.m?.De) settlePendingSource(e);
|
|
382
254
|
// A re-park drops what the earlier pass carried (#3456): a source this
|
|
383
255
|
// pass no longer reaches — its branch switched, or a fresh flight
|
|
384
256
|
// replaced the inputs' pending with its own — stays copied onto
|
|
@@ -387,32 +259,34 @@ function recompute(e, n = false) {
|
|
|
387
259
|
// dependent then waits forever on a flight it has no path to. The
|
|
388
260
|
// re-park twin of the unchanged-value recovery sweep below; dependents
|
|
389
261
|
// with another path keep the source (retryReaches).
|
|
390
|
-
if (
|
|
391
|
-
if (i) GlobalQueue.k(e);
|
|
262
|
+
if (n && l) for (const t of l) if (t !== e && !e.m?.Se?.has(t)) settlePendingSource(e, t);
|
|
392
263
|
}
|
|
393
264
|
} finally {
|
|
394
|
-
tracking =
|
|
395
|
-
latestReadActive = A;
|
|
396
|
-
if (C) stale = p;
|
|
265
|
+
tracking = T;
|
|
397
266
|
// Consume the missed-wake latch (#3037, set by insertSubs): a dep write
|
|
398
267
|
// landed beneath this pass on a link it had already validated. The wipe
|
|
399
268
|
// below must not key off DIRTY/CHECK — the read-time pull protocol
|
|
400
269
|
// (markNode(c) in read()) marks the running node as part of ordinary
|
|
401
270
|
// bookkeeping, and those marks are correctly discarded here.
|
|
402
|
-
|
|
271
|
+
N = (e.R & REACTIVE_MISSED_WAKE) !== 0;
|
|
272
|
+
f = (e.R & REACTIVE_JOINED) !== 0;
|
|
273
|
+
// A verdict reader is one for as long as it probes: a pass that entered
|
|
274
|
+
// no window (REACTIVE_PROBED) is an ordinary derivation again.
|
|
275
|
+
if (!(e.R & REACTIVE_PROBED)) e.u &= ~CONFIG_VERDICT;
|
|
403
276
|
// REACTIVE_DISPOSED survives too (#3621): the pass may have disposed its
|
|
404
277
|
// own owner (a memo calling its root's `dispose()`, a cleanup doing so
|
|
405
278
|
// #3601/#3606), and `disposeChildren` set the flag on this node
|
|
406
279
|
// reentrantly. Dropped, the node read as live — `refresh()` re-ran it
|
|
407
|
-
// and `isDisposed()` lied.
|
|
408
|
-
|
|
409
|
-
|
|
280
|
+
// and `isDisposed()` lied. REACTIVE_FRAME_READ (A15 stale reader) is
|
|
281
|
+
// this pass's verdict for the landing; the next pass's wipe at the top
|
|
282
|
+
// clears it.
|
|
283
|
+
e.R = e.R & (REACTIVE_ZOMBIE | REACTIVE_DISPOSED | REACTIVE_FRAME_READ | REACTIVE_STAGED_READ | REACTIVE_LANE_READ | REACTIVE_SCREEN_READ | REACTIVE_PROBE_UNANSWERED) | (t ? e.R & REACTIVE_SNAPSHOT_STALE : 0);
|
|
284
|
+
context = r;
|
|
285
|
+
// A19 exc. 2: a pass that went pending on a `refresh()` re-asks the
|
|
286
|
+
// question already answered — quiet for the verdict; any other pending
|
|
287
|
+
// pass is a new question. Settled, there is nothing to classify.
|
|
288
|
+
if (e.m !== null) e.m.be = o && (e.G & STATUS_PENDING) !== 0;
|
|
410
289
|
}
|
|
411
|
-
// The cast re-widens: TS narrowed `stagedEntry` to `null` at the reset
|
|
412
|
-
// above and does not invalidate that across the compute call that
|
|
413
|
-
// `enterStagedRead` runs under. No emitted code.
|
|
414
|
-
const R = stagedEntry;
|
|
415
|
-
stagedEntry = E;
|
|
416
290
|
// A node that died during its own pass (#3621) is dead at the end of it,
|
|
417
291
|
// and the pass is void. Its owner's teardown already unlinked its deps,
|
|
418
292
|
// removed it from the heap and ran its cleanups; what remains is what the
|
|
@@ -424,278 +298,185 @@ function recompute(e, n = false) {
|
|
|
424
298
|
// so nothing is staged, committed, or propagated to subscribers, and an
|
|
425
299
|
// effect's run is not enqueued (runEffect would refuse it anyway). The
|
|
426
300
|
// attribution frame opened at the top is still closed.
|
|
427
|
-
if (e.
|
|
301
|
+
if (e.R & REACTIVE_DISPOSED) {
|
|
428
302
|
clearDeps(e);
|
|
429
|
-
if (e.
|
|
430
|
-
|
|
303
|
+
if (e.m !== null) e.m.De = null;
|
|
304
|
+
setPassLane(E);
|
|
431
305
|
return;
|
|
432
306
|
}
|
|
433
|
-
if (
|
|
307
|
+
// The lane this pass is work of, if any: its seat (the node's, its
|
|
308
|
+
// creator's, or the one a lane read moved it into). A pass in a lane's
|
|
309
|
+
// seat that read none of the lane's world has left it: its result is the
|
|
310
|
+
// frame's (a derivation whose branch no longer reaches the guess). A
|
|
311
|
+
// guess is written, not derived — it never leaves this way.
|
|
312
|
+
let S = passLane;
|
|
313
|
+
// Listed before its staging, a pending pass included (the lane's own
|
|
314
|
+
// flight is the lane's); false: the pass left the lane (lanes.ts).
|
|
315
|
+
const c = !!e.m?.V;
|
|
316
|
+
if (S !== null) {
|
|
317
|
+
if (GlobalQueue.M(e, S, t, c)) setPassLane(S); else S = null;
|
|
318
|
+
}
|
|
319
|
+
if (!e.m?.V) {
|
|
434
320
|
// INV-11 (#3330): the equality gate compares against the slot this run
|
|
435
|
-
// publishes to
|
|
436
|
-
//
|
|
437
|
-
//
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
const u = l ? unwrapOverride(e.o?.Fe) : i || e._e === NOT_PENDING ? e.ce : e._e;
|
|
441
|
-
let s = false;
|
|
321
|
+
// publishes to — the staged `_pendingValue` when staged; a lane node's
|
|
322
|
+
// lane value (a node entering the lane this pass has none yet — its
|
|
323
|
+
// committed value, `laneStage` having voided a frame staging).
|
|
324
|
+
const i = e.Ae !== NOT_PENDING ? e.Ae : e.u & CONFIG_OVERRIDE && e.m.Z !== NOT_PENDING ? e.m.Z : e.pe;
|
|
325
|
+
let o = false;
|
|
442
326
|
try {
|
|
443
|
-
|
|
444
|
-
} catch (
|
|
327
|
+
o = !n && u || !e.We || !e.We(i, I);
|
|
328
|
+
} catch (t) {
|
|
445
329
|
// A throwing user comparator is an error of this node's computation.
|
|
446
330
|
// Route it through the same status path as a compute-phase throw so
|
|
447
331
|
// error boundaries contain it; otherwise it unwinds the scheduler
|
|
448
332
|
// flush, bypassing every boundary and wedging the queue (#2837).
|
|
449
|
-
notifyStatus(e, STATUS_ERROR,
|
|
333
|
+
notifyStatus(e, STATUS_ERROR, t);
|
|
450
334
|
}
|
|
451
335
|
// Effects use `_equals: false` (no per-effect closure). The side effects that
|
|
452
336
|
// the equals closure used to perform — flagging the effect dirty and enqueueing
|
|
453
337
|
// its runner — happen here instead. `!create` matches the previous `initialized`
|
|
454
338
|
// gate: the explicit recompute(node, true) inside effect() does not enqueue, so
|
|
455
339
|
// effect() can call its runner synchronously for the first run.
|
|
456
|
-
if (
|
|
457
|
-
|
|
340
|
+
if (n && o &&
|
|
341
|
+
// A stale reader of a lane (REACTIVE_SCREEN_READ) that computed what it
|
|
342
|
+
// last applied owes no run (lanes.ts).
|
|
343
|
+
!(e.R & REACTIVE_SCREEN_READ && !e.Fe && Object.is(e.Ze, I)) &&
|
|
344
|
+
// A re-staging pass owes no run: the commit replays the effect (#3802).
|
|
345
|
+
e.Ae === NOT_PENDING) {
|
|
346
|
+
e.Fe = !e.m?.V;
|
|
458
347
|
// Reuse one bound runner per effect — runEffect no-ops on a stale
|
|
459
348
|
// `_modified`, so re-enqueueing the same function is harmless.
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
// when this write commits under a different transaction
|
|
465
|
-
// (`activeTransition`, null = mainline) than the one that produced the
|
|
466
|
-
// previous value (`_valueTransition`), that view is gone. Rather than
|
|
467
|
-
// merge the two, each commit re-derives the effect against its own
|
|
468
|
-
// committed world (Transition._contested, re-dirtied by
|
|
469
|
-
// finalizePureQueue ahead of the heap run). The previous owner always
|
|
470
|
-
// needs it if still live: its commit is silent (staging already
|
|
471
|
-
// notified) and the value it computed is gone. The new owner needs it
|
|
472
|
-
// too, for the same reason, unless it is mainline — mainline publishes
|
|
473
|
-
// what it computes. A previous owner that was mainline, or already
|
|
474
|
-
// committed, left nothing to protect.
|
|
475
|
-
let n = e.pn;
|
|
476
|
-
if (n !== activeTransition) {
|
|
477
|
-
e.pn = activeTransition;
|
|
478
|
-
if (n !== null && (n = currentTransition(n)) !== activeTransition && !n.Rn) {
|
|
479
|
-
(n.Dn ??= []).push(e);
|
|
480
|
-
if (activeTransition !== null) (activeTransition.Dn ??= []).push(e);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
}
|
|
349
|
+
// Lane work's run is the lane's (released at its reveal) — a first
|
|
350
|
+
// pass under a lane too: `effect()` skips the synchronous first run of
|
|
351
|
+
// a lane's node.
|
|
352
|
+
if (!t || S !== null) globalQueue.enqueue(n, e.J ??= GlobalQueue.X.bind(null, e), S);
|
|
484
353
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
//
|
|
493
|
-
//
|
|
494
|
-
//
|
|
495
|
-
//
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
//
|
|
510
|
-
//
|
|
511
|
-
|
|
512
|
-
|
|
354
|
+
// Lanes. A written guess's own pass from the frame: its source
|
|
355
|
+
// recomputed it — the truth (A18: "the source is whatever recomputes the
|
|
356
|
+
// node"). It stages under the lane's parent whether or not it changed (a
|
|
357
|
+
// confirm is a landing too — the lane's end commits it) and notifies
|
|
358
|
+
// only a correction: an equal truth re-runs nothing (lanes.ts). (As the
|
|
359
|
+
// lane's own work the lane judged it — `laneStage`.)
|
|
360
|
+
if (!t && S === null && e.u & CONFIG_GUESS && GlobalQueue.Qe(e, I, c)) ; else if (c) ; else if (o) {
|
|
361
|
+
// L2: a first pass is born held — staged, committed with the
|
|
362
|
+
// transaction, its effect's first run the landing's (A29; `effect()`
|
|
363
|
+
// skips the synchronous first run on a staged value) — when the flush
|
|
364
|
+
// has joined a transaction and either the pass read a held node (it
|
|
365
|
+
// derives from that world — the join merged the node's transaction
|
|
366
|
+
// into the flush's), or — a verdict lane's mount, mainline — read a
|
|
367
|
+
// staging of this flush (the same world before the seam parks it; the
|
|
368
|
+
// mount is not shown ahead of it: #3851), or a pass created it (ruling
|
|
369
|
+
// A: a held pass's children are the transaction's). Any other mount
|
|
370
|
+
// that read a staging does not join by being new (2026-10-07): it
|
|
371
|
+
// publishes and re-derives if the flush parks. A node created outside any pass
|
|
372
|
+
// that read only the committed world (root setup, a mount, an effect
|
|
373
|
+
// callback) is nobody's frame and publishes directly, as does a first
|
|
374
|
+
// pass that runs before anything joins: the pass's input, not a verdict
|
|
375
|
+
// after it. An effect still carrying an uncommitted staged value
|
|
376
|
+
// re-stages: the commit applies the latest pass, not the born-held one.
|
|
377
|
+
if (S !== null) {
|
|
378
|
+
// Lane work: the lane's value — into the slot while the lane has not
|
|
379
|
+
// revealed (its reveal shows it), as its staging once it has (the
|
|
380
|
+
// next reveal promotes it; the screen keeps the revealed value). An
|
|
381
|
+
// effect's value slot is private: the run the lane holds is what
|
|
382
|
+
// shows it — unless the effect was born held, whose first run is the
|
|
383
|
+
// commit's (A29): it re-stages, as below.
|
|
384
|
+
if (n && e.Ae === NOT_PENDING) e.pe = I; else if (n || S.ve) e.Ae = I; else e.m.Z = I;
|
|
385
|
+
} else if (t ? !((flushTransaction !== null || passTx !== null) && (f || E && e.R & REACTIVE_STAGED_READ || (creatorPass(r)?.R ?? 0) & REACTIVE_JOINED)) : n && e.Ae === NOT_PENDING) {
|
|
386
|
+
// A first pass publishes directly. So does an effect: its value slot
|
|
387
|
+
// is private (only its own run reads it), and the staging round-trip
|
|
388
|
+
// (queuePendingNode + commitPendingNodes) paid per effect on the
|
|
389
|
+
// plain path is pure overhead.
|
|
390
|
+
// NOTE (stage-3, 2026-08-21): a quiet-world MEMO direct-commit was
|
|
391
|
+
// attempted here and REVERTED — memo staging is load-bearing beyond
|
|
392
|
+
// transitions: mid-batch pulls (read-triggered recomputes before
|
|
393
|
+
// sources commit) must see the fresh value while PLAIN reads stay
|
|
394
|
+
// committed until flush (#3009 purity). The pending round-trip is
|
|
395
|
+
// that separation; it cannot be skipped on any path a pull can reach.
|
|
396
|
+
e.pe = I;
|
|
513
397
|
} else {
|
|
514
|
-
e.
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
//
|
|
521
|
-
//
|
|
522
|
-
//
|
|
523
|
-
//
|
|
524
|
-
|
|
525
|
-
e.we = R;
|
|
526
|
-
R.Gn.push(e);
|
|
527
|
-
}
|
|
528
|
-
if (t) R.In.add(e);
|
|
529
|
-
// Under a boundary that has not revealed, a held first value is
|
|
530
|
-
// something not ready under it (#3540): the boundary collects this
|
|
531
|
-
// node as a source and shows its fallback; the source stays
|
|
532
|
-
// collected while born held (CollectionQueue._checkSources) and
|
|
533
|
-
// is released by the commit that initializes it. A boundary that
|
|
534
|
-
// already shows content is not told — it holds like any reader.
|
|
535
|
-
if (underFreshLoadingBoundary(e)) e.T.notify(e, STATUS_PENDING, STATUS_PENDING, new NotReadyError(e));
|
|
398
|
+
e.Ae = I;
|
|
399
|
+
// Born held: in the transaction from birth, so a read of it this
|
|
400
|
+
// tick is a read of its world (the mount-during-a-hold case), not
|
|
401
|
+
// only after the seam parks it.
|
|
402
|
+
if (t) {
|
|
403
|
+
holdNode(e, flushTransaction ?? passTx);
|
|
404
|
+
// Born into the future: no committed value until the landing
|
|
405
|
+
// (`commitPendingNode` initializes it) — every reader of it
|
|
406
|
+
// derives from the future (`read`), an untracked one throws
|
|
407
|
+
// (A19 exc. 1).
|
|
408
|
+
e.G |= STATUS_UNINITIALIZED;
|
|
536
409
|
}
|
|
537
|
-
// A window landing that gets held re-opens the window until the hold
|
|
538
|
-
// commits — the verdict's held-value branch is window-gated (#2990).
|
|
539
|
-
if (_) e.ve = true;
|
|
540
|
-
// A staged sync recompute is a write path like setSignal/asyncWrite,
|
|
541
|
-
// so sync derivations of held sources stay visible to isPending()/latest()
|
|
542
|
-
// (#2831). Both companion writes are transition-scoped (optimistic) and
|
|
543
|
-
// auto-revert/re-derive at commit. Not gated on an active transition:
|
|
544
|
-
// a plain flush can still become a hold after this recompute — an
|
|
545
|
-
// async memo downstream pends and the batch is adopted into a
|
|
546
|
-
// transaction (scheduler.enterTransition) — and nothing re-derives
|
|
547
|
-
// the companion at adoption, so a memo held that way read
|
|
548
|
-
// isPending() false while its held source read true (#3413).
|
|
549
|
-
if (e.C & CONFIG_HAS_COMPANIONS && GlobalQueue.Ve !== null) GlobalQueue.Ve(e, N);
|
|
550
410
|
}
|
|
551
411
|
// insertSubs only walks _subs (no scheduling of its own), so a
|
|
552
412
|
// subscriber-less node has nothing to notify.
|
|
553
|
-
if (e.
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
// source is this node's own async or an upstream node it derives from
|
|
558
|
-
// synchronously makes no difference — "the source recomputed". The
|
|
559
|
-
// override stays displayed until the commit; the graph moves to the
|
|
560
|
-
// staged truth now (plain channel, lane demoted). Ordering: "a new
|
|
561
|
-
// value from the source" postdates the override — an override written
|
|
562
|
-
// in this same tick (optimisticWrite stamps `_overrideTime`) is the
|
|
563
|
-
// newer intent over whatever this pass derives from the batch's staged
|
|
564
|
-
// inputs, and is not superseded by it.
|
|
565
|
-
else if (l && !i && e.o.hn !== clock) GlobalQueue.ke(e, N);
|
|
566
|
-
} else if (l) {
|
|
567
|
-
// Unchanged value (equals the override) recomputed while the override
|
|
568
|
-
// is active: _value may still be stale, so hold the authoritative value
|
|
569
|
-
// for commit on its own transition's schedule — invisibly (A17/A18).
|
|
570
|
-
if (e._e === NOT_PENDING) queuePendingNode(e);
|
|
571
|
-
e._e = N;
|
|
572
|
-
if (_) e.ve = true;
|
|
573
|
-
// see the held branch above (#2990)
|
|
574
|
-
// A confirmation after a supersession restores the override as the
|
|
575
|
-
// graph's value and notifies; a plain confirmation wakes only an
|
|
576
|
-
// authoritative-view reader (until()'s predicate, refresh()'s waiter)
|
|
577
|
-
// that observed this node past its override — "authoritative arrival
|
|
578
|
-
// equal to the override" is exactly the acknowledgment it waits for;
|
|
579
|
-
// A17 silence holds for every ordinary subscriber. Both live in the
|
|
580
|
-
// engine's supersedeOverride.
|
|
581
|
-
GlobalQueue.ke(e, N);
|
|
582
|
-
} else if (e.rn != I) {
|
|
583
|
-
for (let n = e.u; n !== null; n = n.Ae) {
|
|
584
|
-
insertIntoHeapHeight(n.ge, queueFor(n.ge));
|
|
413
|
+
if (e.t !== null) {
|
|
414
|
+
insertSubs(e);
|
|
415
|
+
// Lane work re-staged: the lane's members re-derive as its work.
|
|
416
|
+
if (S !== null) laneDirty(e, S);
|
|
585
417
|
}
|
|
418
|
+
} else if (e.Le != a) {
|
|
419
|
+
for (let t = e.t; t !== null; t = t.l) insertIntoHeapHeight(t.o, dirtyQueue);
|
|
586
420
|
}
|
|
587
421
|
// Silent recovery: errored → unchanged value fires no notification, but
|
|
588
422
|
// dependents still holding the propagated error consumed their dirty flag
|
|
589
423
|
// in an errored run and may sit on stale commits (#2949). Changed-value
|
|
590
424
|
// recoveries ride insertSubs above; a comparator throw re-errored the node
|
|
591
425
|
// (el._x?._error re-set), so this only runs on a genuinely clean recovery.
|
|
592
|
-
if (!
|
|
593
|
-
if (
|
|
426
|
+
if (!o && !e.m?.V) {
|
|
427
|
+
if (s !== undefined) settleErroredDependents(e, s);
|
|
594
428
|
// Self-registration (this node's own superseded flight) is the #3181
|
|
595
429
|
// sweep's business below — retiring it here too would walk twice.
|
|
596
|
-
if (
|
|
430
|
+
if (l) for (const t of l) if (t !== e) settlePendingSource(e, t);
|
|
597
431
|
}
|
|
598
432
|
// #3181: a synchronous settle supersedes the old landing callback, so
|
|
599
433
|
// recompute owns its pending-source sweep. An uninitialized node without
|
|
600
434
|
// a replacement source still has no truth to reveal and must stay parked.
|
|
601
|
-
if (
|
|
602
|
-
settlePendingSource(e);
|
|
603
|
-
// The superseded flight will not enter its waiting transactions at
|
|
604
|
-
// landing. Recheck them now so an unchanged value cannot leave their
|
|
605
|
-
// writes parked after the last pending source has settled.
|
|
606
|
-
wakeParked();
|
|
607
|
-
}
|
|
435
|
+
if (_ && !(e.G & (STATUS_PENDING | STATUS_UNINITIALIZED))) settlePendingSource(e);
|
|
608
436
|
}
|
|
609
|
-
// A
|
|
610
|
-
//
|
|
611
|
-
//
|
|
612
|
-
//
|
|
613
|
-
//
|
|
614
|
-
|
|
615
|
-
//
|
|
616
|
-
//
|
|
617
|
-
//
|
|
618
|
-
//
|
|
619
|
-
//
|
|
620
|
-
//
|
|
621
|
-
// not the reporter's stamp: the transaction waiting on it registered it
|
|
622
|
-
// without stamping it. One idle pass per parked transaction; done ones
|
|
623
|
-
// return at re-entry. Effects only — reporters register from render-effect
|
|
624
|
-
// notification (INV-3).
|
|
625
|
-
// (`_depsTail` was reset at the top of the pass; TS keeps that narrowing.)
|
|
626
|
-
const D = e.Nn;
|
|
627
|
-
if (t && (s && !(e.h & STATUS_PENDING) || (D === null ? e.Ie !== null : D.Ne !== null))) wakeParked();
|
|
628
|
-
// Dependencies are the committed frame's until it is replaced (A30, #3410; the
|
|
629
|
-
// deps twin of the held children above): a pass that staged its value
|
|
630
|
-
// leaves the previous pass's tail linked for `commitPendingNode` to trim,
|
|
631
|
-
// so a write to a dependency the committed value still derives from
|
|
632
|
-
// reaches this node — and joins its hold if the stage is transaction-held
|
|
633
|
-
// by then (a plain flush decides nothing here: the transaction that holds
|
|
634
|
-
// the pass may open later in the same flush). A pass that published
|
|
635
|
-
// directly (a first pass, a lane's own reveal) trims now. An errored pass
|
|
636
|
-
// (a throw, NotReady included, or a comparator throw above) keeps its full
|
|
437
|
+
// A first pass that went pending where the born-held arm would have held
|
|
438
|
+
// its value (it read a held node, or a verdict lane's mount read a staging,
|
|
439
|
+
// #3851) is born into that transaction without holding it: the hold never
|
|
440
|
+
// waits for a first load (the direction rule), but the answer lands into it
|
|
441
|
+
// while it is live (A29, #3800).
|
|
442
|
+
if (t && S === null && (f || E && e.R & REACTIVE_STAGED_READ) && e.G & STATUS_PENDING) ext(e).Re = flushTransaction ?? passTx;
|
|
443
|
+
// Dependencies are the committed frame's until it is replaced (A30, #3410):
|
|
444
|
+
// a pass that staged its value leaves the previous pass's tail linked for
|
|
445
|
+
// `commitPendingNode` to trim, so a write to a dependency the committed
|
|
446
|
+
// value still derives from reaches this node until the commit. A pass that
|
|
447
|
+
// published directly, or changed nothing, trims now. An errored pass (a
|
|
448
|
+
// throw, NotReady included, or a comparator throw above) keeps its full
|
|
637
449
|
// list as before — `_depsTail` marks where it stopped — and the commit
|
|
638
450
|
// skips it by the same `_error`. An effect's frame is the run its value is
|
|
639
|
-
// applied by, not the value slot (#3438): a
|
|
640
|
-
//
|
|
641
|
-
//
|
|
642
|
-
//
|
|
643
|
-
//
|
|
644
|
-
//
|
|
645
|
-
//
|
|
646
|
-
//
|
|
647
|
-
//
|
|
648
|
-
if (!e.
|
|
649
|
-
if (
|
|
650
|
-
}
|
|
651
|
-
currentOptimisticLane = O;
|
|
652
|
-
// A parked LANE frame is not a hold (#3662): its drain is the effect's own
|
|
653
|
-
// run, not a commit — the node is neither queued nor stamped for it, and
|
|
654
|
-
// the release below (for transaction zombies) leaves it parked.
|
|
655
|
-
const G = (e.C & CONFIG_LANE_FRAME) !== 0;
|
|
656
|
-
const h = e._e !== NOT_PENDING || !G && e.o !== null && (e.o._n !== null || e.o.fn !== null) || (e.h & (STATUS_PENDING | STATUS_UNINITIALIZED)) !== 0;
|
|
657
|
-
// Override-covered holds (hasOverride) always queue: their commit belongs
|
|
658
|
-
// to their own transition's schedule (A18 re-rule) and is unobservable
|
|
659
|
-
// under the override (A17). Revert no longer commits anything, so an
|
|
660
|
-
// unqueued covered hold would leak (INV-7) once the revert clears
|
|
661
|
-
// _transition.
|
|
662
|
-
|
|
663
|
-
// While a pass's result waits on a commit, its children (and `_disposal`)
|
|
664
|
-
// wait with it, and a re-run may tear them down immediately
|
|
665
|
-
// (CONFIG_HELD_CHILDREN, #3404). One exception: a transaction-owned effect
|
|
666
|
-
// recomputed mainline (contested, #3322) published its value directly — a
|
|
667
|
-
// `_pendingValue` left from an earlier held pass is that transaction's,
|
|
668
|
-
// not this one's — so this pass's children are the frame's, and any
|
|
669
|
-
// zombies deferred at the top are superseded on that same frame. Its
|
|
670
|
-
// commit rides the transaction, not this flush: release them here rather
|
|
671
|
-
// than let two generations render at once. A LANE pass is the same case
|
|
672
|
-
// (#3662): it direct-commits ahead of its transaction, so its children are
|
|
673
|
-
// the frame's too. Left flagged for an OLDER frame's zombies, the stamped
|
|
674
|
-
// transaction's same-flush re-run below disposed the lane's freshly built
|
|
675
|
-
// children (an insert's inner effect, its run still queued in the lane)
|
|
676
|
-
// and held their replacements for a commit that never came.
|
|
677
|
-
let P = h && (!n || R !== null || (e.h & STATUS_PENDING) !== 0);
|
|
678
|
-
if (P && (!e.we || l)) queuePendingNode(e); else if (P && (activeTransition === null || i) && !(e.h & (STATUS_PENDING | STATUS_UNINITIALIZED))) {
|
|
679
|
-
P = false;
|
|
680
|
-
if (!G) disposeChildren(e, false, true);
|
|
451
|
+
// applied by, not the value slot (#3438): a pass that still owes a run
|
|
452
|
+
// (`_modified`) has not replaced what the last run published, so its tail
|
|
453
|
+
// waits for `runEffect` to trim once the run applies. A pass that changed
|
|
454
|
+
// nothing replaced nothing either (#3469): it cannot know at its tail
|
|
455
|
+
// whether the flush that ran it will park with its inputs held, so the
|
|
456
|
+
// trim waits on the flush's verdict (`heldTrim`: trimmed at the commit,
|
|
457
|
+
// kept at a park — one spurious recompute at most). A creation pass and a
|
|
458
|
+
// tracked effect trim now: their frames are replaceable like a direct
|
|
459
|
+
// commit, and a tracked effect's spurious run would be user-visible.
|
|
460
|
+
if (!e.m?.V && e.Ae === NOT_PENDING && !(n && e.Fe)) {
|
|
461
|
+
if (t || n === EFFECT_TRACKED) trimStaleDeps(e); else heldTrim(e);
|
|
681
462
|
}
|
|
682
|
-
|
|
683
|
-
//
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
e.pn = n;
|
|
463
|
+
// A staged value, a parked frame (L2: the commit retires it), or status the
|
|
464
|
+
// commit sweep must settle (a pending or uninitialized pass), queues the
|
|
465
|
+
// node for this flush's commit. A first pass queues only when pending or
|
|
466
|
+
// born held: otherwise its value published directly. A queued pass's
|
|
467
|
+
// children are uncommitted (CONFIG_STAGED) until that commit.
|
|
468
|
+
if (e.Ae !== NOT_PENDING || e.m !== null && (e.m.Me !== null || e.m.Be !== null) || (e.G & (STATUS_PENDING | STATUS_UNINITIALIZED)) !== 0 && (!t || (e.G & STATUS_PENDING) !== 0)) {
|
|
469
|
+
e.u |= CONFIG_STAGED;
|
|
470
|
+
// Lane work is the lane's to reveal (its seam), not this flush's commit.
|
|
471
|
+
if (S === null) queuePendingNode(e);
|
|
692
472
|
}
|
|
473
|
+
setPassLane(E);
|
|
693
474
|
// Missed-wake reschedule (see the finally above): values this pass read
|
|
694
475
|
// before the nested commit are stale, so run again now that the heap will
|
|
695
476
|
// accept the node. Equality gates stop same-value landings from cascading,
|
|
696
477
|
// and a re-run only latches again if another nested commit changes a dep
|
|
697
478
|
// beneath it — convergent unless deps genuinely keep changing.
|
|
698
|
-
if (
|
|
479
|
+
if (N) {
|
|
699
480
|
enqueueSub(e);
|
|
700
481
|
schedule();
|
|
701
482
|
}
|
|
@@ -708,38 +489,38 @@ function updateIfNecessary(e) {
|
|
|
708
489
|
// (#3037); readers meanwhile serve the values the pass has so far.
|
|
709
490
|
// Never recompute a DISPOSED node either: recompute rewrites _flags and
|
|
710
491
|
// would resurrect it (#2983) — readers serve its last value.
|
|
711
|
-
if (e.
|
|
712
|
-
if (e.
|
|
713
|
-
for (let
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
updateIfNecessary(i);
|
|
492
|
+
if (e.R & (REACTIVE_RECOMPUTING_DEPS | REACTIVE_DISPOSED)) return;
|
|
493
|
+
if (e.R & REACTIVE_CHECK) {
|
|
494
|
+
for (let t = e._; t; t = t.p) {
|
|
495
|
+
const n = t.I;
|
|
496
|
+
if (n.re) {
|
|
497
|
+
updateIfNecessary(n);
|
|
718
498
|
}
|
|
719
|
-
if (e.
|
|
499
|
+
if (e.R & REACTIVE_DIRTY) {
|
|
720
500
|
break;
|
|
721
501
|
}
|
|
722
502
|
}
|
|
723
503
|
}
|
|
724
|
-
if (e.
|
|
504
|
+
if (e.R & REACTIVE_DIRTY || e.m?.V && e.Ne < clock && !e.m?.De) {
|
|
725
505
|
recompute(e);
|
|
726
506
|
}
|
|
727
507
|
// The guard above refused an already-disposed node; the recompute it just
|
|
728
508
|
// ran may have disposed it (#3621) — carry the flag, or it comes back alive.
|
|
729
|
-
// The manual-write
|
|
730
|
-
// node's staging is a PROPOSAL,
|
|
731
|
-
//
|
|
732
|
-
//
|
|
733
|
-
//
|
|
734
|
-
|
|
509
|
+
// The manual-write mark is state, not scheduling (#3612, A34 rule B): it
|
|
510
|
+
// says the node's staging is a PROPOSAL, lifted by a pass that re-derives
|
|
511
|
+
// or by the commit — a pull that recomputed nothing must not. Nor may it
|
|
512
|
+
// erase the last pass's verdicts for the landing (a stale reader's
|
|
513
|
+
// REACTIVE_FRAME_READ — a verdict reader pulled by a sibling before the
|
|
514
|
+
// landing lost its re-derivation; the lane reads likewise).
|
|
515
|
+
e.R = e.R & (REACTIVE_SNAPSHOT_STALE | REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT | REACTIVE_ZOMBIE | REACTIVE_DISPOSED | REACTIVE_MANUAL_WRITE | REACTIVE_FRAME_READ | REACTIVE_STAGED_READ | REACTIVE_LANE_READ | REACTIVE_SCREEN_READ | REACTIVE_PROBE_UNANSWERED);
|
|
735
516
|
}
|
|
736
517
|
|
|
737
|
-
function computed(e,
|
|
738
|
-
const
|
|
518
|
+
function computed(e, t) {
|
|
519
|
+
const n = t?.transparent ?? false;
|
|
739
520
|
// `in` (not `!== undefined`): an explicit `loadingValue: undefined` on a
|
|
740
521
|
// `T | undefined` node is a real commit #0. The typeof guard tolerates
|
|
741
522
|
// non-object option values that older call shapes force through `as any`.
|
|
742
|
-
const
|
|
523
|
+
const E = t !== null && typeof t === "object" && "loadingValue" in t;
|
|
743
524
|
// Two literals, one per tier, selected at build time (the observe flag is
|
|
744
525
|
// a literal after replacement; the untaken branch is dead code). The observe
|
|
745
526
|
// literal is the prod literal plus its `_name` slot — a slot in the
|
|
@@ -749,43 +530,40 @@ function computed(e, n) {
|
|
|
749
530
|
// two in sync — the dist artifact test pins observe's key set to prod's
|
|
750
531
|
// plus `_name`.
|
|
751
532
|
const u = {
|
|
752
|
-
id: inheritId(
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
Je: context?.Je ?? defaultContext,
|
|
758
|
-
En: 0,
|
|
759
|
-
he: e,
|
|
760
|
-
ce: i ? n.loadingValue : undefined,
|
|
761
|
-
rn: 0,
|
|
762
|
-
Pn: undefined,
|
|
763
|
-
Fn: null,
|
|
764
|
-
Ie: null,
|
|
765
|
-
Nn: null,
|
|
533
|
+
id: inheritId(t, n, context),
|
|
534
|
+
u: (n ? CONFIG_TRANSPARENT : 0) | (t?.ownedWrite ? CONFIG_OWNED_WRITE : 0) | (!context || t?.lazy ? CONFIG_AUTO_DISPOSE : 0) | (t?.sync ? CONFIG_SYNC : 0) | (t?.ie ? CONFIG_NO_SNAPSHOT : 0) | (t?.we ?? 0) | (snapshotCaptureActive && ownerInSnapshotScope(context) ? CONFIG_IN_SNAPSHOT_SCOPE : 0),
|
|
535
|
+
We: t?.equals ?? isEqual,
|
|
536
|
+
Pe: null,
|
|
537
|
+
U: context?.U ?? defaultContext,
|
|
766
538
|
Ye: 0,
|
|
767
|
-
|
|
768
|
-
|
|
539
|
+
re: e,
|
|
540
|
+
pe: E ? t.loadingValue : undefined,
|
|
541
|
+
Le: 0,
|
|
542
|
+
je: undefined,
|
|
543
|
+
Ke: null,
|
|
544
|
+
_: null,
|
|
545
|
+
S: null,
|
|
546
|
+
Ge: 0,
|
|
547
|
+
t: null,
|
|
548
|
+
qe: null,
|
|
769
549
|
_parent: context,
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
550
|
+
me: null,
|
|
551
|
+
Je: null,
|
|
552
|
+
ge: null,
|
|
553
|
+
R: t?.lazy ? REACTIVE_LAZY : REACTIVE_NONE,
|
|
774
554
|
// A loadingValue node is born committed: commit #0 is already in _value.
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
// Cold machinery (async/transition/optimistic/verdict slots) lives one
|
|
782
|
-
// hop away in the lazily-allocated extension — the core literal MUST
|
|
555
|
+
G: E ? 0 : STATUS_UNINITIALIZED,
|
|
556
|
+
Ne: clock,
|
|
557
|
+
Ae: NOT_PENDING,
|
|
558
|
+
ze: -1,
|
|
559
|
+
_e: E,
|
|
560
|
+
// Cold machinery (async slots) lives one hop away in the lazily-allocated extension — the core literal MUST
|
|
783
561
|
// stay under V8's in-object boundary (§12: past ~39 fields every
|
|
784
562
|
// allocation spills to a backing store and creation cost ~4x's).
|
|
785
|
-
|
|
563
|
+
m: null
|
|
786
564
|
};
|
|
787
|
-
if (
|
|
788
|
-
setupComputedNode(u,
|
|
565
|
+
if (t?.unobserved) ext(u).Xe = t.unobserved;
|
|
566
|
+
setupComputedNode(u, t);
|
|
789
567
|
return u;
|
|
790
568
|
}
|
|
791
569
|
|
|
@@ -793,269 +571,274 @@ function computed(e, n) {
|
|
|
793
571
|
* computeds — `_x` access stays monomorphic). Installers write through
|
|
794
572
|
* this; hot paths read `el._x?._field` gated by the _config presence bits.
|
|
795
573
|
* Never call ext() just to store a field's default. */ function ext(e) {
|
|
796
|
-
return e.
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
i: null,
|
|
815
|
-
Hn: undefined,
|
|
816
|
-
sn: undefined,
|
|
817
|
-
fn: null,
|
|
818
|
-
_n: null,
|
|
819
|
-
Un: undefined
|
|
574
|
+
return e.m ??= {
|
|
575
|
+
De: null,
|
|
576
|
+
Te: null,
|
|
577
|
+
V: undefined,
|
|
578
|
+
Ie: undefined,
|
|
579
|
+
Se: undefined,
|
|
580
|
+
Xe: undefined,
|
|
581
|
+
xe: undefined,
|
|
582
|
+
Me: null,
|
|
583
|
+
Be: null,
|
|
584
|
+
ke: null,
|
|
585
|
+
Re: null,
|
|
586
|
+
be: false,
|
|
587
|
+
$e: NOT_PENDING,
|
|
588
|
+
et: -1,
|
|
589
|
+
Oe: 0,
|
|
590
|
+
Z: NOT_PENDING,
|
|
591
|
+
T: 0
|
|
820
592
|
};
|
|
821
593
|
}
|
|
822
594
|
|
|
595
|
+
/** A tracked read of a held node (the reader derives from its transaction's
|
|
596
|
+
* world): the reading pass is marked as having read it (born-held decision
|
|
597
|
+
* in `recompute`), and the flush joins the node's transaction — unless the
|
|
598
|
+
* reader is a render effect. A render effect is the frame, not a derivation
|
|
599
|
+
* (rule 3): in that transaction's own flush, or born into it (uninitialized,
|
|
600
|
+
* A29), it reads the staged value and holds nothing of its own; otherwise it
|
|
601
|
+
* reads the committed value instead (`frameRead`). A node born into the
|
|
602
|
+
* future has no committed value: every reader joins it. A first pass is
|
|
603
|
+
* something not ready under a loading boundary that has not shown content:
|
|
604
|
+
* the boundary collects it and shows its fallback, and the pass is the
|
|
605
|
+
* boundary's, not the tick's (A29's boundary exemption, #3540). */ function joinPass(e, t) {
|
|
606
|
+
e.R |= REACTIVE_JOINED;
|
|
607
|
+
if (t.G & STATUS_UNINITIALIZED || e.i !== EFFECT_RENDER) joinPassTx(txOf(t), GlobalQueue.ce?.(e));
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/** A15's stale reader (shared-hole and reveal corollaries): a render effect
|
|
611
|
+
* reading a node held by a transaction that is not the flush's. It is served
|
|
612
|
+
* the committed value — a pending one's too — publishes mainline, and is
|
|
613
|
+
* re-derived after that transaction's landing (`_reruns`,
|
|
614
|
+
* REACTIVE_FRAME_READ) so the frame catches up with it once it is the
|
|
615
|
+
* committed world. Not a frame born into that transaction (held and never
|
|
616
|
+
* committed — created by one of its held passes, A29): that one reads its
|
|
617
|
+
* transaction's values and keeps staging. Not of a flight whose inputs are
|
|
618
|
+
* already visible (CONFIG_INPUTS_PUBLISHED, #3305): its committed value
|
|
619
|
+
* would tear against them, so the reveal observes the flight instead. Once
|
|
620
|
+
* per pass.
|
|
621
|
+
*
|
|
622
|
+
* Lane work is a stale reader too (maintainer, 2026-10-01: a lane sees the
|
|
623
|
+
* screen plus its own guesses). A held write is held because showing it
|
|
624
|
+
* would tear against the rest of its frame; a lane revealing a derivation
|
|
625
|
+
* of it would show it anyway, beside inputs still committed elsewhere on
|
|
626
|
+
* the page. The guess is the one value the user opted into predicting. So
|
|
627
|
+
* a lane pass reading a transaction's held node — its parent's or any
|
|
628
|
+
* other's — derives from the committed value and is re-derived at that
|
|
629
|
+
* landing. The case read-through was built for — a corrected guess whose
|
|
630
|
+
* downstream async must refetch with the truth at once, while another of
|
|
631
|
+
* the parent's flights is still up — needs none of this: the correction
|
|
632
|
+
* dissolves the lane, and the refetching pass is the parent's own, reading
|
|
633
|
+
* the truth as a member (`joinPass`). */ function frameRead(e, t) {
|
|
634
|
+
// Frame readers: a render effect, a verdict reader (CONFIG_VERDICT — it
|
|
635
|
+
// reads the screen like one: `[isPending(x), x()]` never pairs the fresh
|
|
636
|
+
// value with pending, A10, because the reader never sees the fresh value),
|
|
637
|
+
// and lane work (a lane sees the screen plus its own guesses). Not a
|
|
638
|
+
// mount's memo (2026-10-02, considered and reverted): a memo is not a
|
|
639
|
+
// leaf — the transaction's own later passes read it — so a mainline mount's
|
|
640
|
+
// derivations carry the future (A29, born held); only its direct bindings
|
|
641
|
+
// read the screen. Lane work with no committed value yet reads a flight
|
|
642
|
+
// as a mount's memo does: it enters, and the boundary it mounts catches
|
|
643
|
+
// the pending (#3540).
|
|
644
|
+
const n = e.u & CONFIG_VERDICT;
|
|
645
|
+
if ((passLane === null || e.G & STATUS_UNINITIALIZED && t.G & STATUS_PENDING) && !n && (e.i !== EFFECT_RENDER || t.u & CONFIG_INPUTS_PUBLISHED)) return false;
|
|
646
|
+
const E = txOf(t);
|
|
647
|
+
// Lane work and verdict readers are never the transaction's pass, whichever
|
|
648
|
+
// flush runs it: a node T holds re-enters T when it re-runs (`recompute`'s
|
|
649
|
+
// head), and the pass may then read a guess and become the lane's.
|
|
650
|
+
if (E === flushTransaction && passLane === null && !n || e.G & STATUS_UNINITIALIZED && e.u & CONFIG_HELD && txOf(e) === E) return false;
|
|
651
|
+
staleReader(e, E);
|
|
652
|
+
return true;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/** The computed whose pass a creation under `owner` belongs to (a root's is
|
|
656
|
+
* its nearest computed ancestor's), or null outside every pass. */ function creatorPass(e) {
|
|
657
|
+
return e !== null && e.Et ? e.ut : e;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/** L2 — park the previous pass's frame for this node's commit: the children
|
|
661
|
+
* (already allocated — nothing new) and the `_disposal` list move to the
|
|
662
|
+
* extension, keep reacting from the heap, and die when the commit publishes
|
|
663
|
+
* the frame that replaces them (`commitPendingNode`) or when the owner does. */ function parkChildren(e) {
|
|
664
|
+
markDisposal(e);
|
|
665
|
+
const t = ext(e);
|
|
666
|
+
t.Be = e.Pe;
|
|
667
|
+
t.Me = e.ge;
|
|
668
|
+
e.Pe = null;
|
|
669
|
+
e.ge = null;
|
|
670
|
+
e.Ye = 0;
|
|
671
|
+
}
|
|
672
|
+
|
|
823
673
|
/**
|
|
824
674
|
* Build an Effect node with all effect-specific fields baked into a single object literal,
|
|
825
675
|
* so V8 sees the full hidden class shape at construction time. Effects always run in lazy
|
|
826
676
|
* mode (recompute is called explicitly by `effect()`), so we hardcode the lazy bits and skip
|
|
827
677
|
* the auto-dispose CONFIG bit (effect() previously cleared it post-construction).
|
|
828
|
-
*/ function createEffectNode(e,
|
|
829
|
-
const
|
|
678
|
+
*/ function createEffectNode(e, t, n, E, u) {
|
|
679
|
+
const s = u?.transparent ?? false;
|
|
830
680
|
// Prod and observe boilerplates — see computed() for why the observe tier
|
|
831
681
|
// gets its `_name` as a literal slot rather than a write after the fact.
|
|
832
682
|
// The default label is the node kind (tracked effects relabel their computed
|
|
833
683
|
// in trackedEffect); the wrappers in signals.ts no longer spread a name into
|
|
834
684
|
// the options to get it.
|
|
835
|
-
const
|
|
836
|
-
id: inheritId(u,
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
Je: context?.Je ?? defaultContext,
|
|
842
|
-
En: 0,
|
|
843
|
-
he: e,
|
|
844
|
-
ce: undefined,
|
|
845
|
-
rn: 0,
|
|
846
|
-
Pn: undefined,
|
|
847
|
-
Fn: null,
|
|
848
|
-
Ie: null,
|
|
849
|
-
Nn: null,
|
|
685
|
+
const i = {
|
|
686
|
+
id: inheritId(u, s, context),
|
|
687
|
+
u: (s ? CONFIG_TRANSPARENT : 0) | (u?.ownedWrite ? CONFIG_OWNED_WRITE : 0) | (u?.sync ? CONFIG_SYNC : 0) | (u?.we ?? 0) | (snapshotCaptureActive && ownerInSnapshotScope(context) ? CONFIG_IN_SNAPSHOT_SCOPE : 0),
|
|
688
|
+
We: false,
|
|
689
|
+
Pe: null,
|
|
690
|
+
U: context?.U ?? defaultContext,
|
|
850
691
|
Ye: 0,
|
|
851
|
-
|
|
852
|
-
|
|
692
|
+
re: e,
|
|
693
|
+
pe: undefined,
|
|
694
|
+
Le: 0,
|
|
695
|
+
je: undefined,
|
|
696
|
+
Ke: null,
|
|
697
|
+
_: null,
|
|
698
|
+
S: null,
|
|
699
|
+
Ge: 0,
|
|
700
|
+
t: null,
|
|
701
|
+
qe: null,
|
|
853
702
|
_parent: context,
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
pn: null,
|
|
871
|
-
o: null
|
|
703
|
+
me: null,
|
|
704
|
+
Je: null,
|
|
705
|
+
ge: null,
|
|
706
|
+
R: REACTIVE_LAZY,
|
|
707
|
+
G: STATUS_UNINITIALIZED,
|
|
708
|
+
Ne: clock,
|
|
709
|
+
Ae: NOT_PENDING,
|
|
710
|
+
ze: -1,
|
|
711
|
+
_e: false,
|
|
712
|
+
Fe: false,
|
|
713
|
+
Ze: undefined,
|
|
714
|
+
st: t,
|
|
715
|
+
it: n,
|
|
716
|
+
lt: undefined,
|
|
717
|
+
i: E,
|
|
718
|
+
m: null
|
|
872
719
|
};
|
|
873
720
|
// Effects dispatch status through the SHARED notifier (statusNotifierOf,
|
|
874
721
|
// keyed off _type) — storing it per node forced a full NodeExtension
|
|
875
722
|
// allocation on EVERY effect at creation (an alloc + 19 field stores,
|
|
876
723
|
// +23% effect creation, caught by the creation benches). Only genuinely
|
|
877
724
|
// per-node channels (boundaries) live on _x.
|
|
878
|
-
if (u?.unobserved) ext(
|
|
879
|
-
setupComputedNode(
|
|
880
|
-
return
|
|
725
|
+
if (u?.unobserved) ext(i).Xe = u.unobserved;
|
|
726
|
+
setupComputedNode(i, lazyOptions);
|
|
727
|
+
return i;
|
|
881
728
|
}
|
|
882
729
|
|
|
883
730
|
/**
|
|
884
731
|
* The shared status notifier for effect nodes, installed once by effect.ts
|
|
885
732
|
* at module evaluation (`this`-dispatched — one function serves every
|
|
886
|
-
* effect, so nodes never store it).
|
|
887
|
-
*
|
|
733
|
+
* effect, so nodes never store it). CARVE 4: the boundaries' per-node
|
|
734
|
+
* channel (`_x._notifyStatus`) went with them; effects are the only
|
|
735
|
+
* display consumers.
|
|
888
736
|
*/ let effectStatusNotify = null;
|
|
889
737
|
|
|
890
738
|
function setEffectStatusNotify(e) {
|
|
891
739
|
effectStatusNotify = e;
|
|
892
740
|
}
|
|
893
741
|
|
|
894
|
-
/** Resolve a node's status notifier:
|
|
895
|
-
*
|
|
896
|
-
*
|
|
897
|
-
*
|
|
898
|
-
|
|
899
|
-
const n = e.o?.S;
|
|
900
|
-
if (n !== undefined) return n;
|
|
901
|
-
return e.je ? effectStatusNotify ?? undefined : undefined;
|
|
742
|
+
/** Resolve a node's status notifier: effect nodes (`_type` — EFFECT_PURE is
|
|
743
|
+
* 0, and only effect literals carry the field) get the shared notifier.
|
|
744
|
+
* Presence doubles as the "display consumer" membership test in the status
|
|
745
|
+
* walks, exactly as the per-node field did when every effect carried one. */ function statusNotifierOf(e) {
|
|
746
|
+
return e.i ? effectStatusNotify ?? undefined : undefined;
|
|
902
747
|
}
|
|
903
748
|
|
|
904
749
|
const lazyOptions = {
|
|
905
750
|
lazy: true
|
|
906
751
|
};
|
|
907
752
|
|
|
908
|
-
function setupComputedNode(e,
|
|
909
|
-
e.
|
|
910
|
-
const
|
|
753
|
+
function setupComputedNode(e, t) {
|
|
754
|
+
e.Ke = e;
|
|
755
|
+
const n = context?.Et ? context.ut : context;
|
|
911
756
|
if (context) linkChild(context, e);
|
|
912
|
-
if (
|
|
913
|
-
|
|
914
|
-
!
|
|
915
|
-
if (snapshotCaptureActive && !
|
|
916
|
-
if (!(e.
|
|
917
|
-
ext(e).
|
|
918
|
-
e.
|
|
757
|
+
if (n) e.Le = n.Le + 1;
|
|
758
|
+
GlobalQueue._t?.(e);
|
|
759
|
+
!t?.lazy && recompute(e, true);
|
|
760
|
+
if (snapshotCaptureActive && !t?.lazy) {
|
|
761
|
+
if (!(e.G & STATUS_PENDING) && !(e.u & CONFIG_NO_SNAPSHOT)) {
|
|
762
|
+
ext(e).xe = e.pe === undefined ? NO_SNAPSHOT : e.pe;
|
|
763
|
+
e.u |= CONFIG_HAS_SNAPSHOT;
|
|
919
764
|
snapshotSources.add(e);
|
|
920
765
|
}
|
|
921
766
|
}
|
|
922
767
|
}
|
|
923
768
|
|
|
924
|
-
function signal(e,
|
|
769
|
+
function signal(e, t) {
|
|
925
770
|
// Prod and observe boilerplates — see computed(). The observe literal adds
|
|
926
771
|
// `_name` and `_owner` (the creating owner, stamped by registerGraph for
|
|
927
772
|
// createSignal nodes so ownerPath can locate signal subjects; null here,
|
|
928
773
|
// and staying null on internal signals — one shape either way).
|
|
929
|
-
const
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
Ue: t?.o?.i || null,
|
|
938
|
-
Yn: null,
|
|
939
|
-
_e: NOT_PENDING,
|
|
774
|
+
const n = {
|
|
775
|
+
We: t?.equals ?? isEqual,
|
|
776
|
+
u: (t?.ownedWrite ? CONFIG_OWNED_WRITE : 0) | (t?.ie ? CONFIG_NO_SNAPSHOT : 0),
|
|
777
|
+
pe: e,
|
|
778
|
+
t: null,
|
|
779
|
+
qe: null,
|
|
780
|
+
Ne: clock,
|
|
781
|
+
Ae: NOT_PENDING,
|
|
940
782
|
// Signal-literal diet (§12e): NO _time/_fn/_statusFlags slots. Stores
|
|
941
783
|
// materialize one signal per touched leaf, so signal bytes are store
|
|
942
784
|
// bytes. _time is write-only on signals (every read site is computed-
|
|
943
785
|
// typed error-retry gating); _fn/_statusFlags read falsy-identically as
|
|
944
786
|
// missing properties on the shared paths (undefined masks to 0).
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
o: null
|
|
787
|
+
ze: -1,
|
|
788
|
+
m: null
|
|
948
789
|
};
|
|
949
|
-
if (
|
|
950
|
-
if (
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
snapshotSources.add(i);
|
|
790
|
+
if (t?.unobserved) ext(n).Xe = t.unobserved;
|
|
791
|
+
if (snapshotCaptureActive && !(n.u & CONFIG_NO_SNAPSHOT)) {
|
|
792
|
+
ext(n).xe = e === undefined ? NO_SNAPSHOT : e;
|
|
793
|
+
n.u |= CONFIG_HAS_SNAPSHOT;
|
|
794
|
+
snapshotSources.add(n);
|
|
955
795
|
}
|
|
956
|
-
return
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
// ---------------------------------------------------------------------------
|
|
960
|
-
// SLOT SIGNALS (store leaves) — the create-floor diet. Store mounts
|
|
961
|
-
// materialize one signal per touched leaf (~13 × rows on dbmon), so per-node
|
|
962
|
-
// allocations are mount bytes: the generic path costs an options object, an
|
|
963
|
-
// equals closure, an unobserved closure, a NodeExtension to hold it, and
|
|
964
|
-
// three post-construction expandos (acc/px/pxv → hidden-class transitions).
|
|
965
|
-
// slotSignal bakes everything into ONE literal: `_host`/`_key` backrefs
|
|
966
|
-
// replace the closures (equals is a method call — `this` is the node; the
|
|
967
|
-
// unobserved sweep dispatches CONFIG_SLOT_NODE to one shared hook), and the
|
|
968
|
-
// store's wrap-cache fields are pre-shaped.
|
|
969
|
-
/** The shared slot-node unobserved handler — a live binding read directly by
|
|
970
|
-
* the sweep sites (no wrapper frame, no null check: a CONFIG_SLOT_NODE node
|
|
971
|
-
* existing implies the store module loaded and registered the hook). */ let slotUnobservedHook;
|
|
972
|
-
|
|
973
|
-
/** Install the shared slot-node unobserved handler (store module, once). */ function setSlotUnobserved(e) {
|
|
974
|
-
slotUnobservedHook = e;
|
|
796
|
+
return n;
|
|
975
797
|
}
|
|
976
798
|
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
* unlinks in O(1) — the chain is walked per mark of the projection and
|
|
980
|
-
* would otherwise grow by one node per leaf ever read (#3351). */ function linkFirewallChild(e, n) {
|
|
981
|
-
const t = n.Ue;
|
|
982
|
-
if (t !== null) t.Yn = n;
|
|
983
|
-
ext(e).i = n;
|
|
984
|
-
e.C |= CONFIG_FW_CHILDREN;
|
|
799
|
+
function isEqual(e, t) {
|
|
800
|
+
return e === t;
|
|
985
801
|
}
|
|
986
802
|
|
|
987
|
-
/**
|
|
988
|
-
*
|
|
989
|
-
*
|
|
990
|
-
*
|
|
991
|
-
*
|
|
992
|
-
*
|
|
993
|
-
*
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
const
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
function slotSignal(e, n, t, i, u, l = null) {
|
|
1010
|
-
// Prod and observe boilerplates — see computed(). The store relabels the
|
|
1011
|
-
// observe slot (`store.<key>`) when the attribution engine is installed.
|
|
1012
|
-
const r = {
|
|
1013
|
-
xe: n,
|
|
1014
|
-
C: CONFIG_OWNED_WRITE | CONFIG_SLOT_NODE,
|
|
1015
|
-
ce: e,
|
|
1016
|
-
u: null,
|
|
1017
|
-
mn: null,
|
|
1018
|
-
be: clock,
|
|
1019
|
-
De: l,
|
|
1020
|
-
Ue: l?.o?.i || null,
|
|
1021
|
-
Yn: null,
|
|
1022
|
-
_e: NOT_PENDING,
|
|
1023
|
-
we: null,
|
|
1024
|
-
vn: -1,
|
|
1025
|
-
o: null,
|
|
1026
|
-
// Slot backrefs: what the equals/unobserved closures used to capture.
|
|
1027
|
-
Bn: t,
|
|
1028
|
-
Kn: i,
|
|
1029
|
-
// Store read-path caches, pre-shaped (were post-construction expandos).
|
|
803
|
+
/** A store slot node (CONFIG_SLOT_NODE): the whole node in ONE literal — the
|
|
804
|
+
* target and key as back-refs in place of closures (`equals` is a method
|
|
805
|
+
* call, `this` the node; the unobserved sweep dispatches to one shared hook,
|
|
806
|
+
* graph.ts), the store's wrap cache (`px`/`pxv`: the proxy last served for
|
|
807
|
+
* this key and the raw it wrapped — one pointer compare replaces a WeakMap
|
|
808
|
+
* lookup per read) and the accessor verdict (`acc`) pre-shaped. No options
|
|
809
|
+
* object, no NodeExtension, no post-construction expandos. `ownedWrite` is
|
|
810
|
+
* baked in: the setter carries the owned-scope guard; node-level writes are
|
|
811
|
+
* the store's notification machinery. The observe literal adds the label
|
|
812
|
+
* slot (the store relabels it `store.<key>` when the engine is installed). */ function slotSignal(e, t, n, E, u) {
|
|
813
|
+
const s = {
|
|
814
|
+
We: t,
|
|
815
|
+
u: CONFIG_OWNED_WRITE | CONFIG_SLOT_NODE,
|
|
816
|
+
pe: e,
|
|
817
|
+
t: null,
|
|
818
|
+
qe: null,
|
|
819
|
+
Ne: clock,
|
|
820
|
+
Ae: NOT_PENDING,
|
|
821
|
+
ze: -1,
|
|
822
|
+
m: null,
|
|
823
|
+
ot: n,
|
|
824
|
+
rt: E,
|
|
1030
825
|
acc: u,
|
|
1031
826
|
px: undefined,
|
|
1032
827
|
pxv: undefined
|
|
1033
828
|
};
|
|
1034
|
-
|
|
1035
|
-
if (snapshotCaptureActive && !((l?.h ?? 0) & STATUS_PENDING)) {
|
|
1036
|
-
ext(r).sn = e === undefined ? NO_SNAPSHOT : e;
|
|
1037
|
-
r.C |= CONFIG_HAS_SNAPSHOT;
|
|
1038
|
-
snapshotSources.add(r);
|
|
1039
|
-
}
|
|
1040
|
-
return r;
|
|
829
|
+
return s;
|
|
1041
830
|
}
|
|
1042
831
|
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
function optimisticComputed(e, n) {
|
|
1051
|
-
const t = computed(e, n);
|
|
1052
|
-
ext(t).Fe = NOT_PENDING;
|
|
1053
|
-
t.C |= CONFIG_OPTIMISTIC;
|
|
1054
|
-
return t;
|
|
1055
|
-
}
|
|
832
|
+
/**
|
|
833
|
+
* When set to a component name string, any reactive read that is not inside a nested tracking
|
|
834
|
+
* scope will log a dev-mode warning. Managed automatically by `untrack(fn, strictReadLabel)`.
|
|
835
|
+
*/
|
|
836
|
+
/** The verdict windows' read (verdict.ts), installed while a `latest` or
|
|
837
|
+
* `isPending` window is open and null otherwise: `read` dispatches to it
|
|
838
|
+
* then, and a program that never imports them never has one. */ let verdict = null;
|
|
1056
839
|
|
|
1057
|
-
function
|
|
1058
|
-
|
|
840
|
+
function setVerdict(e) {
|
|
841
|
+
verdict = e;
|
|
1059
842
|
}
|
|
1060
843
|
|
|
1061
844
|
/**
|
|
@@ -1079,15 +862,15 @@ function isEqual(e, n) {
|
|
|
1079
862
|
* }
|
|
1080
863
|
* );
|
|
1081
864
|
* ```
|
|
1082
|
-
*/ function untrack(e,
|
|
1083
|
-
if (GlobalQueue.
|
|
1084
|
-
const
|
|
865
|
+
*/ function untrack(e, t) {
|
|
866
|
+
if (GlobalQueue.It === null && !tracking && true) return e();
|
|
867
|
+
const n = tracking;
|
|
1085
868
|
tracking = false;
|
|
1086
869
|
try {
|
|
1087
|
-
if (GlobalQueue.
|
|
870
|
+
if (GlobalQueue.It) return GlobalQueue.It(e);
|
|
1088
871
|
return e();
|
|
1089
872
|
} finally {
|
|
1090
|
-
tracking =
|
|
873
|
+
tracking = n;
|
|
1091
874
|
}
|
|
1092
875
|
}
|
|
1093
876
|
|
|
@@ -1103,630 +886,327 @@ function isEqual(e, n) {
|
|
|
1103
886
|
* born-held tree would otherwise pull the mounting pass into the hold).
|
|
1104
887
|
*/ let spectating = false;
|
|
1105
888
|
|
|
1106
|
-
/**
|
|
1107
|
-
* Evaluates `fn` untracked, recording nothing on the current `context`: no
|
|
1108
|
-
* untracked-pending re-run link, no transaction entry. For bookkeeping reads
|
|
1109
|
-
* made on behalf of no node — see `spectating`.
|
|
1110
|
-
*/ function spectate(e) {
|
|
1111
|
-
const n = spectating;
|
|
1112
|
-
spectating = true;
|
|
1113
|
-
try {
|
|
1114
|
-
return untrack(e);
|
|
1115
|
-
} finally {
|
|
1116
|
-
spectating = n;
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
889
|
/**
|
|
1121
890
|
* Bring a computed to a readable state: lazy/disposed nodes are (re)computed;
|
|
1122
|
-
*
|
|
1123
|
-
*
|
|
1124
|
-
*/ function prepareComputed(e,
|
|
1125
|
-
if (e.
|
|
1126
|
-
e.
|
|
891
|
+
* `refresh` additionally pulls the node fully up to date so its status flags
|
|
892
|
+
* reflect the current graph.
|
|
893
|
+
*/ function prepareComputed(e, t) {
|
|
894
|
+
if (e.R & REACTIVE_LAZY) {
|
|
895
|
+
e.R &= ~REACTIVE_LAZY;
|
|
1127
896
|
recompute(e, true);
|
|
1128
|
-
} else if (e.
|
|
897
|
+
} else if (e.R & REACTIVE_DISPOSED) {
|
|
1129
898
|
// Two disposal lifecycles share the flag (#3024). Observation-lifecycle
|
|
1130
899
|
// nodes (CONFIG_AUTO_DISPOSE) are dormant — torn down by unobserved()
|
|
1131
900
|
// when the last subscriber left — and reads reawaken them; that is the
|
|
1132
901
|
// pay-for-use contract. Owner-lifecycle nodes are dead: recomputing would
|
|
1133
902
|
// re-run user code in a torn-down tree (and discard manual writes on
|
|
1134
903
|
// derived-writable signals), so reads return the last committed value.
|
|
1135
|
-
if (e.
|
|
1136
|
-
const
|
|
1137
|
-
if (
|
|
904
|
+
if (e.u & CONFIG_AUTO_DISPOSE) {
|
|
905
|
+
const t = e._parent;
|
|
906
|
+
if (t !== null) {
|
|
1138
907
|
// A dormant node was off the chain when its owner died, so the strip
|
|
1139
908
|
// in disposeChildren missed it: freeze here instead (#3024).
|
|
1140
|
-
if (
|
|
1141
|
-
e.
|
|
909
|
+
if (t.R & REACTIVE_DISPOSED) {
|
|
910
|
+
e.u &= ~CONFIG_AUTO_DISPOSE;
|
|
1142
911
|
return;
|
|
1143
912
|
}
|
|
1144
|
-
// A zombie never left its chain
|
|
1145
|
-
//
|
|
1146
|
-
|
|
913
|
+
// A zombie never left its chain (the parked frame is drained whole,
|
|
914
|
+
// and its members skip the splice): relinking would put it on the
|
|
915
|
+
// live chain too.
|
|
916
|
+
if (!(e.R & REACTIVE_ZOMBIE)) linkChild(t, e);
|
|
1147
917
|
}
|
|
1148
918
|
recompute(e, true);
|
|
1149
919
|
}
|
|
1150
|
-
} else
|
|
1151
|
-
updateIfNecessary(e);
|
|
1152
|
-
}
|
|
920
|
+
} else ;
|
|
1153
921
|
}
|
|
1154
922
|
|
|
923
|
+
// CARVE 3: until()'s authoritative-view wakeup (notifyAuthoritativeObservers /
|
|
924
|
+
// installAuthoritativeRead), the stale-of-foreign clause (heldFromStale,
|
|
925
|
+
// recordStaleReplay, ownsHold) and the transaction entry on a staged read
|
|
926
|
+
// (enterStagedRead, stagedEntry / born held, underFreshLoadingBoundary) went
|
|
927
|
+
// with the transactions.
|
|
1155
928
|
/**
|
|
1156
|
-
*
|
|
1157
|
-
*
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
/**
|
|
1161
|
-
* read()'s plain-signal fast path as a standalone entry for hot callers
|
|
1162
|
-
* (store traps). Safe to substitute for read() only because the bail
|
|
1163
|
-
* conditions mirror read()'s prelude and fast-path guard exactly: the
|
|
1164
|
-
* latestRead and pendingCheck windows run side-effectful hooks before the
|
|
1165
|
-
* fast path, `_fn` nodes need prepareComputed, and firewall / override /
|
|
1166
|
-
* snapshot / transition / lane / dev-strictRead state all take the full
|
|
1167
|
-
* resolution. Anything slow returns READ_SLOW; the caller then calls read().
|
|
1168
|
-
*/
|
|
1169
|
-
/**
|
|
1170
|
-
* Wake only authoritative-view readers (until() predicates) subscribed to `el`.
|
|
1171
|
-
* The A17-silent ack paths — an authoritative arrival equal to the active
|
|
1172
|
-
* override — use this so the predicate re-evaluates without re-firing
|
|
1173
|
-
* ordinary subscribers whose visible (override) value did not change.
|
|
1174
|
-
* Pay-for-use: reached through GlobalQueue._notifyAuthoritativeObservers,
|
|
1175
|
-
* installed at first until() call — apps that never use until() shake it.
|
|
1176
|
-
*/ function notifyAuthoritativeObservers(e) {
|
|
1177
|
-
for (let n = e.u; n !== null; n = n.Ae) {
|
|
1178
|
-
const e = n.ge;
|
|
1179
|
-
if (!(e.C & CONFIG_AUTHORITATIVE_READ)) continue;
|
|
1180
|
-
// Missed-wake latch (#3037), same contract as insertSubs: the reader may
|
|
1181
|
-
// itself have pulled this recompute (updateIfNecessary from its own
|
|
1182
|
-
// read), and the heap refuses RECOMPUTING nodes — latch so recompute's
|
|
1183
|
-
// tail reschedules it with the staged value visible.
|
|
1184
|
-
if (e.oe & REACTIVE_RECOMPUTING_DEPS && n.Be === e.Ye && n !== e.Nn) e.oe |= REACTIVE_MISSED_WAKE;
|
|
1185
|
-
enqueueSub(e);
|
|
1186
|
-
}
|
|
1187
|
-
schedule();
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
/** Installs the authoritative-reader wakeup hook. Idempotent; called by every
|
|
1191
|
-
* creator of a CONFIG_AUTHORITATIVE_READ computation — until() and refresh() —
|
|
1192
|
-
* before its first read (same late-binding contract as the optimistic engine;
|
|
1193
|
-
* the gating bit is only ever set by such a read, so the `!` call sites are
|
|
1194
|
-
* safe once every setter installs, #3303). */ function installAuthoritativeRead() {
|
|
1195
|
-
if (GlobalQueue.zn === null) GlobalQueue.zn = notifyAuthoritativeObservers;
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
/**
|
|
1199
|
-
* Stale-reader term of the value selections below: a render effect reading a
|
|
1200
|
-
* node some OTHER live transaction has staged sees the committed value. The
|
|
1201
|
-
* commit is silent — the staging walk was the notification — so a reader
|
|
1202
|
-
* that linked AFTER that walk (an effect created during the hold, a store
|
|
1203
|
-
* key first read under it) would show the old value past the reveal: record
|
|
1204
|
-
* it for the transaction's commit replay (the `_gatedSubs` contract lanes
|
|
1205
|
-
* already use). An effect the transaction itself computed re-derives at its
|
|
1206
|
-
* commit on its own (parked run, or the contested re-derive, #3322) and is
|
|
1207
|
-
* not recorded — replaying it too would publish the frame twice.
|
|
1208
|
-
*
|
|
1209
|
-
* Flight twin (the pending-branch carve-out): the reader is served the
|
|
1210
|
-
* node's committed, pre-flight value and now observes that flight — A15:
|
|
1211
|
-
* async work observed by a reader settles as one unit with the writes that
|
|
1212
|
-
* asked it — so it joins the transaction's reporters for the node. The
|
|
1213
|
-
* reporter the transaction recorded when the flight started may be gone (a
|
|
1214
|
-
* keyed remount disposed it, #3374); a completion check that found no live
|
|
1215
|
-
* reporter committed the writes ahead of the answer, tearing the new
|
|
1216
|
-
* reader's frame (`Count: 1` beside `Details: 0`). Joins an entry the
|
|
1217
|
-
* transaction already holds; a flight nobody had observed yet has none (the
|
|
1218
|
-
* reader is its first observer — a conditional that just revealed it, #3458)
|
|
1219
|
-
* and is notified up the reader's own queue chain under that transaction,
|
|
1220
|
-
* the one sanctioned registration site (INV-3): a collecting boundary above
|
|
1221
|
-
* the reader consumes it as it would any pending, an unboundaried reader
|
|
1222
|
-
* opens the entry — and the transaction, judged complete on its other
|
|
1223
|
-
* flights, revealed the inputs beside the reader's pre-flight value
|
|
1224
|
-
* otherwise (`Count: 1 | A: 1` beside `B: 0`). A staged signal or a settled
|
|
1225
|
-
* node registers nothing. Every reporter dies with its reader
|
|
1226
|
-
* (reporterBlocksSource: the read linked it as a dep). The node's own entry
|
|
1227
|
-
* is the only one that can matter: a chain's intermediate memo is re-pulled
|
|
1228
|
-
* by the read (updateIfNecessary's retry) and enters the transaction, so the
|
|
1229
|
-
* reader holds through the normal path; a node with its own flight that is
|
|
1230
|
-
* also pending on an upstream re-ask blocks through that flight until it
|
|
1231
|
-
* lands, and its landing re-runs the reader into the normal path.
|
|
1232
|
-
*/
|
|
1233
|
-
/** The replay half of the stale-of-foreign clause (A15 / A26): a stale reader
|
|
1234
|
-
* served the committed value because `txn` holds what it read re-runs at
|
|
1235
|
-
* txn's commit, when the value it was denied becomes the frame — unless its
|
|
1236
|
-
* own last value already came from that transaction. One registration for
|
|
1237
|
-
* the node path (heldFromStale) and the store's backing paths, which have
|
|
1238
|
-
* no node to carry the hold (heldFromReader, the adoption hold view). */ function recordStaleReplay(e, n) {
|
|
1239
|
-
const t = n.pn;
|
|
1240
|
-
if (t == null || currentTransition(t) !== e) e.In.add(n);
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
/**
|
|
1244
|
-
* The ownership relation (DESIGN-CONSOLIDATION §6, ruled 2026-09-17): is
|
|
1245
|
-
* `hold` part of the running pass's world? A plain reader's world is the
|
|
1246
|
-
* transaction it runs under, through merges. A lane reader's world is its
|
|
1247
|
-
* lane AND the transition that owns the lane — the one asymmetry between a
|
|
1248
|
-
* lane and a separate transaction (a lane sees what lands from its parent as
|
|
1249
|
-
* its own; a separate transaction would wait for the parent to settle) —
|
|
1250
|
-
* see `ownsLane` in lanes.ts, built on this. One relation for the
|
|
1251
|
-
* stale-of-foreign clause (heldFromStale), the lane arm (readsHeldCommitted)
|
|
1252
|
-
* and the store's backing holds (foreignHold); `serve` has no lane arm of
|
|
1253
|
-
* its own, the lane's extra visibility lives here.
|
|
1254
|
-
*/ function ownsHold(e) {
|
|
1255
|
-
return activeTransition !== null && currentTransition(e) === currentTransition(activeTransition);
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
function heldFromStale(e, n) {
|
|
1259
|
-
const t = e.we;
|
|
1260
|
-
if (t === null || ownsHold(t)) return false;
|
|
1261
|
-
const i = currentTransition(t);
|
|
1262
|
-
recordStaleReplay(i, n);
|
|
1263
|
-
const u = i.le.get(e);
|
|
1264
|
-
if (u) u.add(n); else if (e.h & STATUS_PENDING) runInTransition(i, () => n.T.notify(n, STATUS_PENDING, STATUS_PENDING, e.o._));
|
|
1265
|
-
return true;
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
/**
|
|
1269
|
-
* A tracked computation about to be served a live transaction's staged value
|
|
1270
|
-
* derives from that transaction's world, so it enters the transaction and
|
|
1271
|
-
* this pass's result is held with it (A29, #3408). The write side (`setSignal`)
|
|
1272
|
-
* and a stamped node's recompute already enter; a reader that only now
|
|
1273
|
-
* starts reading the held node — a conditional memo whose branch flipped —
|
|
1274
|
-
* was the gap: it published a value derived from the staged world into the
|
|
1275
|
-
* mainline frame. Not for a probe (`isPending(() => x())` observes, it does
|
|
1276
|
-
* not derive) and a no-op for the ambient batch (`_transition` null) or the
|
|
1277
|
-
* transaction already active.
|
|
1278
|
-
*/
|
|
1279
|
-
/** The transaction a pass running OUTSIDE a flush was served a staged value
|
|
1280
|
-
* from (A29, creation-time form). Inside a flush the pass enters through
|
|
1281
|
-
* initTransition; outside one — a memo or effect created from mainline code
|
|
1282
|
-
* while a hold is live — entering would leave `activeTransition` and the
|
|
1283
|
-
* batch pointed at the transaction for the rest of the synchronous block,
|
|
1284
|
-
* so an unrelated write made after the mount was held with someone else's
|
|
1285
|
-
* action. The entry is the pass's alone: recompute stages the node into the
|
|
1286
|
-
* transaction (born held) and mainline is never touched.
|
|
1287
|
-
*
|
|
1288
|
-
* A pass under a FRESH loading boundary takes this path inside a flush too
|
|
1289
|
-
* (#3540). Born held is right for a plain memo or effect: published, its
|
|
1290
|
-
* value would tear the frame. A boundary that has not revealed yet is the
|
|
1291
|
-
* exception by definition — its job is to catch what is not ready under it
|
|
1292
|
-
* rather than let it hold: the pass is staged into the transaction as
|
|
1293
|
-
* above, and the boundary is told (recompute's born-held arm notifies it
|
|
1294
|
-
* with a `NotReadyError` sourced at the node) so it shows its fallback now
|
|
1295
|
-
* and reveals the staged result at the commit.
|
|
1296
|
-
* Entering instead adopted the whole flush into the hold — a `Show` that
|
|
1297
|
-
* flipped mainline to mount a `Loading` over a held value waited for the
|
|
1298
|
-
* hold with it. A boundary that already shows content keeps the entering
|
|
1299
|
-
* path: it has content to keep, and holds like any reader. */ let stagedEntry = null;
|
|
1300
|
-
|
|
1301
|
-
/** Is `el` routed to a loading boundary that still shows its fallback — the
|
|
1302
|
-
* nearest pending-collecting queue up its chain is uninitialized? (Measured
|
|
1303
|
-
* 2026-09-18: relocating the walk behind a `GlobalQueue` slot installed by
|
|
1304
|
-
* boundaries.ts saved ~8 B on the core floor and cost boundary-using apps
|
|
1305
|
-
* 50–70 B — the indirection's tokens outweigh the walk. Kept inline.) */ function underFreshLoadingBoundary(e) {
|
|
1306
|
-
for (let n = e.T; n !== null; n = n._parent) if (n.te & STATUS_PENDING) return !n.q;
|
|
1307
|
-
return false;
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
function enterStagedRead(e, n = e.we) {
|
|
1311
|
-
if (!n || n === activeTransition || pendingCheckActive) return;
|
|
1312
|
-
// A companion (the latest() shadow, the isPending() verdict signal) is the
|
|
1313
|
-
// engine's mirror of the flushed world — reading it, or being it, is an
|
|
1314
|
-
// observation, not a derivation from the hold: latest(x) never enters x's
|
|
1315
|
-
// transaction, and the shadow's own pass never enters either (it would
|
|
1316
|
-
// flip activeTransition under the reader that pulled it). (`el` is null for
|
|
1317
|
-
// a store backing served under a hold — no node, the transaction is the
|
|
1318
|
-
// fold's.)
|
|
1319
|
-
if (e?.o?.kn || context?.o?.kn) return;
|
|
1320
|
-
// A bookkeeping read (`spectate`) is nobody's derivation: it compares or
|
|
1321
|
-
// probes, and enters nothing — the boundary priming read of a born-held
|
|
1322
|
-
// tree must not enter the creator's pass into the hold (#3540).
|
|
1323
|
-
if (spectating) return;
|
|
1324
|
-
// Verdict machinery (GlobalQueue._verdictPull: companion creation and the
|
|
1325
|
-
// latest()/isPending() pulls — the latest() shadow is created before it is
|
|
1326
|
-
// marked optimistic, so the bit alone cannot tell) and optimistic nodes
|
|
1327
|
-
// (own lane posture, A31) read staged truth by design; they keep the
|
|
1328
|
-
// entering path.
|
|
1329
|
-
// (`context` is non-null here: every caller selected a value for a reader.)
|
|
1330
|
-
const t = context;
|
|
1331
|
-
const i = activeTransition === null && !globalQueue.Jn;
|
|
1332
|
-
// Verdict pulls are observations, not derivations: a latest() /
|
|
1333
|
-
// isPending() call from mainline must never enter a transaction (it
|
|
1334
|
-
// would capture the rest of the caller's synchronous block).
|
|
1335
|
-
if (i && GlobalQueue.Xn) return;
|
|
1336
|
-
if (t.oe & REACTIVE_RECOMPUTING_DEPS && !(t.C & CONFIG_OPTIMISTIC) && (stagedEntry === null || stagedEntry === n) && (i || !GlobalQueue.Xn && underFreshLoadingBoundary(t))) {
|
|
1337
|
-
stagedEntry = n;
|
|
1338
|
-
return;
|
|
1339
|
-
}
|
|
1340
|
-
globalQueue.initTransition(n);
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
/**
|
|
1344
|
-
* Rule 1 (value selection), the full arm: does this reader see a STAGED
|
|
1345
|
-
* node's COMMITTED value? One implementation of the rule the fast paths
|
|
1346
|
-
* (readNodeFast, read's fast block) carry as their trivial ternary and that
|
|
1347
|
-
* every slow site — read's tail, the store's backing selection, the lane and
|
|
1348
|
-
* verdict arms — used to restate by hand (docs/DESIGN-CONSOLIDATION.md, move 3b). In order:
|
|
929
|
+
* Rule 1 (value selection): does this reader see a STAGED node's COMMITTED
|
|
930
|
+
* value? One implementation of the rule the fast paths (read's fast block)
|
|
931
|
+
* carry as their trivial ternary. In order:
|
|
1349
932
|
* - no reader at all (an untracked read) — the committed frame;
|
|
1350
|
-
* - a reader under an optimistic lane the engine says reads committed
|
|
1351
|
-
* (laneReadsCommitted: another lane's hold, #3460);
|
|
1352
933
|
* - nothing staged;
|
|
1353
934
|
* - a children-forbidden reader (createTrackedEffect / onSettled: the frame,
|
|
1354
|
-
* never the graph — A32)
|
|
1355
|
-
*
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
* - HELD truth (#3164, CONFIG_HELD_TRUTH) read by a LANE pass: staged
|
|
1359
|
-
* confirming truth — fold-staged onto an armed family, or entangle-stolen
|
|
1360
|
-
* by an awaited until() — is masked from lane passes only, owning
|
|
1361
|
-
* transaction or not. A lane applies its frame display-ahead at the park,
|
|
1362
|
-
* so a lane pass served the truth would paint the confirmation beside the
|
|
1363
|
-
* optimism it confirms (`saving=true` beside the saved row — the #3164
|
|
1364
|
-
* tear); it keeps committed and is re-run by the reveal's post-revert
|
|
1365
|
-
* wake. Every other deriving reader falls through to A29 below: the truth
|
|
1366
|
-
* is a staged value like any other, and the pass that derives from it is
|
|
1367
|
-
* held with it — including the retaining transaction's own passes, which
|
|
1368
|
-
* a superseded override already hands the truth (#3568: masking them
|
|
1369
|
-
* composed the landed `length` with rows still masked to committed).
|
|
1370
|
-
* latest() and authoritative readers (until()'s predicate) tunnel
|
|
1371
|
-
* through — the tunnel that keeps the hold deadlock-free.
|
|
1372
|
-
* False means the reader derives from the staged value and enters its
|
|
1373
|
-
* transaction (enterStagedRead, A29).
|
|
1374
|
-
*/ function readerSeesCommitted(e, n, t, i) {
|
|
1375
|
-
return !!(!n || currentOptimisticLane !== null && GlobalQueue.$n(e, t, n) || e._e === NOT_PENDING || n.C & CONFIG_CHILDREN_FORBIDDEN || stale && !i && heldFromStale(e, n) || e.C & CONFIG_HELD_TRUTH && currentOptimisticLane !== null && !latestReadActive && !(n.C & CONFIG_AUTHORITATIVE_READ));
|
|
935
|
+
* never the graph — A32).
|
|
936
|
+
* False means the reader derives from the staged value.
|
|
937
|
+
*/ function readerSeesCommitted(e, t) {
|
|
938
|
+
return !!(!t || e.Ae === NOT_PENDING || t.u & CONFIG_CHILDREN_FORBIDDEN);
|
|
1376
939
|
}
|
|
1377
940
|
|
|
1378
|
-
/** A28 — set when a node is staged (queuePendingNode)
|
|
1379
|
-
*
|
|
1380
|
-
*
|
|
1381
|
-
*
|
|
1382
|
-
*
|
|
941
|
+
/** A28 — set when a node is staged (queuePendingNode) OUTSIDE a flush;
|
|
942
|
+
* cleared when the next flush begins. The read sites test this one module
|
|
943
|
+
* boolean instead of `globalQueue._running`: inside a flush it is false and
|
|
944
|
+
* the A28 arm costs nothing; outside, only a tick with unflushed writes pays
|
|
945
|
+
* the staged-node check. */ let unflushedStaged = false;
|
|
1383
946
|
|
|
1384
947
|
function markUnflushedStaged() {
|
|
1385
948
|
unflushedStaged = true;
|
|
1386
949
|
}
|
|
1387
950
|
|
|
1388
|
-
/** A28 — a write becomes visible at flush. Outside a flush, a node holding
|
|
1389
|
-
*
|
|
1390
|
-
*
|
|
1391
|
-
*
|
|
1392
|
-
*
|
|
1393
|
-
*
|
|
1394
|
-
|
|
951
|
+
/** A28 — a write becomes visible at flush. Outside a flush, a node holding a
|
|
952
|
+
* staged value was written since the last flush: staging commits at flush
|
|
953
|
+
* end, so nothing else leaves a node in this state. Inside a flush the rule
|
|
954
|
+
* does not apply (A28 (4): promoted within the round). The value an
|
|
955
|
+
* unflushed node serves is its committed value, or NOT_PENDING when nothing
|
|
956
|
+
* is unflushed. Exempt: promoted writes (A28 (4): a write issued inside a
|
|
957
|
+
* recompute is promoted at that recompute's end — boundary and loading
|
|
958
|
+
* machinery, signals declared for in-computation writes). */ function unflushedValue(e) {
|
|
959
|
+
if (globalQueue.ee || e.Ae === NOT_PENDING || e.u & CONFIG_PROMOTED) return NOT_PENDING;
|
|
960
|
+
// A held node (L2) carries a staged value between flushes too, but it was
|
|
961
|
+
// flushed — and parked. Not an unflushed write — unless rewritten since:
|
|
962
|
+
// then the flushed staging is what the world sees until the next flush.
|
|
963
|
+
if (e.u & CONFIG_HELD) return e.m.et === clock ? e.m.$e : NOT_PENDING;
|
|
964
|
+
return e.pe;
|
|
1395
965
|
}
|
|
1396
966
|
|
|
1397
|
-
/**
|
|
1398
|
-
*
|
|
1399
|
-
*
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
// Ambient, or adopted by a transaction before any flush carried the staging
|
|
1407
|
-
// (CONFIG_ADOPTED_UNFLUSHED): nothing flushed is staged — the committed
|
|
1408
|
-
// value answers (the caller's notion of committed: a store node's backing).
|
|
1409
|
-
// A held node: unflushed only if rewritten since the last flush (stash).
|
|
1410
|
-
if (e.we === null || e.C & CONFIG_ADOPTED_UNFLUSHED) return n;
|
|
1411
|
-
return e.o === null ? NOT_PENDING : e.o.bn;
|
|
967
|
+
/** A28: a held node rewritten outside a flush keeps the staging the last
|
|
968
|
+
* flush left (`_flushed`) until the flush that carries the rewrite — the
|
|
969
|
+
* stash is stamped with the clock, which that flush advances. */ function stashFlushed(e) {
|
|
970
|
+
const t = e.m;
|
|
971
|
+
if (t.et !== clock) {
|
|
972
|
+
t.$e = e.Ae;
|
|
973
|
+
t.et = clock;
|
|
974
|
+
unflushedStaged = true;
|
|
975
|
+
}
|
|
1412
976
|
}
|
|
1413
977
|
|
|
1414
|
-
/** Held nodes rewritten since the last flush (setSignal); the flush clears
|
|
1415
|
-
* their stash — from then on latest() answers with the rewrite. */ const unflushedRewrites = [];
|
|
1416
|
-
|
|
1417
978
|
/** Nodes written inside a creation-time recompute (CONFIG_PROMOTED). */ const promotedWrites = [];
|
|
1418
979
|
|
|
1419
|
-
/** A28 (5): an optimistic write becomes the ACTIVE override at the flush that
|
|
1420
|
-
* carries it. `_overrideTime` is stamped with `clock` at the write and `clock`
|
|
1421
|
-
* advances after every flush, so "this tick, outside a flush" is unflushed. */ function unflushedOverride(e) {
|
|
1422
|
-
// Companions are optimistic signals written by the engine (see unflushed).
|
|
1423
|
-
return !globalQueue.Jn && e.o?.hn === clock && !e.o?.kn;
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
/** Active optimistic override on an armed node (an armed slot idles at
|
|
1427
|
-
* NOT_PENDING; undefined = unarmed plain node). The writer's own channels —
|
|
1428
|
-
* the draft, `in`/keys inside the setter — compose on this regardless of
|
|
1429
|
-
* flush state. */ function hasActiveOverride(e) {
|
|
1430
|
-
const n = e.o;
|
|
1431
|
-
return n !== null && n.Fe !== undefined && n.Fe !== NOT_PENDING;
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
/** The override a READER sees: installed, and carried by a flush (A28 (5) —
|
|
1435
|
-
* an optimistic write is a write; until its flush no reader sees it). One
|
|
1436
|
-
* implementation for read()'s override arm, the verdict channels
|
|
1437
|
-
* (latestRead, computePendingState) and the store's selection
|
|
1438
|
-
* (docs/DESIGN-CONSOLIDATION.md, move 3b). */ function visibleOverride(e) {
|
|
1439
|
-
return hasActiveOverride(e) && !unflushedOverride(e);
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
980
|
/** A derivation served the committed value because of an unflushed write
|
|
1443
981
|
* (A28) must run again in the flush that carries it — the late-linker case
|
|
1444
982
|
* (#3337's reason to defer the walk): it linked after the write walked. */ function markLateLinker(e) {
|
|
1445
983
|
// The pass's own tail re-enqueues on this latch (recompute's finally) —
|
|
1446
984
|
// a direct enqueue here would be wiped by the pass's flag reset.
|
|
1447
|
-
e.
|
|
985
|
+
e.R |= REACTIVE_MISSED_WAKE;
|
|
1448
986
|
return true;
|
|
1449
987
|
}
|
|
1450
988
|
|
|
1451
|
-
/** Companion-bearing nodes written outside a flush (setSignal); the flush
|
|
1452
|
-
* that carries their writes re-syncs their companions (A28). */ const unflushedCompanions = [];
|
|
1453
|
-
|
|
1454
989
|
function resyncUnflushedCompanions() {
|
|
1455
990
|
unflushedStaged = false;
|
|
1456
|
-
// Length-guarded: the common flush has nothing here, and must allocate nothing.
|
|
1457
991
|
// Length-guarded: the common flush has nothing here and allocates nothing.
|
|
1458
|
-
if (
|
|
1459
|
-
for (const e of
|
|
1460
|
-
unflushedRewrites.length = 0;
|
|
1461
|
-
}
|
|
1462
|
-
if (promotedWrites.length !== 0) {
|
|
1463
|
-
for (const e of promotedWrites) e.C &= ~CONFIG_PROMOTED;
|
|
992
|
+
if (promotedWrites.length !== 0) {
|
|
993
|
+
for (const e of promotedWrites) e.u &= ~CONFIG_PROMOTED;
|
|
1464
994
|
promotedWrites.length = 0;
|
|
1465
995
|
}
|
|
1466
|
-
if (unflushedCompanions.length !== 0) {
|
|
1467
|
-
for (const e of unflushedCompanions) GlobalQueue.Ve(e, e._e !== NOT_PENDING ? e._e : e.ce);
|
|
1468
|
-
unflushedCompanions.length = 0;
|
|
1469
|
-
}
|
|
1470
996
|
}
|
|
1471
997
|
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
//
|
|
1481
|
-
//
|
|
1482
|
-
//
|
|
1483
|
-
//
|
|
1484
|
-
//
|
|
1485
|
-
//
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
//
|
|
1489
|
-
|
|
1490
|
-
return !n || e._e === NOT_PENDING || n.C & CONFIG_CHILDREN_FORBIDDEN || stale && heldFromStale(e, n) ? e.ce : (enterStagedRead(e),
|
|
1491
|
-
e._e);
|
|
998
|
+
/** A tracked read's pull of a computed: bring it current when the flush has
|
|
999
|
+
* reached its height (or the reader is a fresh-pull waiter), and sit the
|
|
1000
|
+
* reader above it. */ function pullComputed(e, t) {
|
|
1001
|
+
if (e.Le >= dirtyQueue.He) {
|
|
1002
|
+
markNode(t);
|
|
1003
|
+
markHeap(dirtyQueue);
|
|
1004
|
+
updateIfNecessary(e);
|
|
1005
|
+
}
|
|
1006
|
+
// Fresh-pull readers (awaitable refresh's waiter) recompute a dirty
|
|
1007
|
+
// source inline even when the height gate defers to the flush: the
|
|
1008
|
+
// waiter must park on the re-ask's window (or serve its sync answer),
|
|
1009
|
+
// never read the PRE-re-ask value as settled. Self-guarded: a clean
|
|
1010
|
+
// node no-ops and updateIfNecessary refuses disposed nodes (#2983) —
|
|
1011
|
+
// a dead target serves its last value, which is already quiescent.
|
|
1012
|
+
else if (t.u & CONFIG_FRESH_READ) updateIfNecessary(e);
|
|
1013
|
+
const n = e.Le;
|
|
1014
|
+
// parent check is shallow, might need to be recursive
|
|
1015
|
+
if (n >= t.Le && e._parent !== t) t.Le = n + 1;
|
|
1492
1016
|
}
|
|
1493
1017
|
|
|
1494
1018
|
function read(e) {
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
//
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
//
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
GlobalQueue.nt(e, n, u, i);
|
|
1510
|
-
} else if (typeof t.he === "function") {
|
|
1511
|
-
prepareComputed(e, false);
|
|
1512
|
-
}
|
|
1513
|
-
if (!t.he && u === e && e.o?.Fe === undefined && e.o?.sn === undefined && activeTransition === null && currentOptimisticLane === null && !snapshotCaptureActive && (!unflushedStaged || e._e === NOT_PENDING) && // A28, see readNodeFast
|
|
1019
|
+
let t = context;
|
|
1020
|
+
if (t?.Et) t = t.ut;
|
|
1021
|
+
const n = e;
|
|
1022
|
+
// CARVE 1: `owner` was `el._firewall || el` — a store leaf's status,
|
|
1023
|
+
// height and error were read off its projection computed. (Typed loosely
|
|
1024
|
+
// as the `||` expression was: a signal's `_statusFlags`/`_height` read as
|
|
1025
|
+
// undefined and mask to 0 on every site below.)
|
|
1026
|
+
const E = e;
|
|
1027
|
+
if (typeof n.re === "function") prepareComputed(e);
|
|
1028
|
+
// The verdict windows (`latest`, `isPending`; verdict.ts): one cold path,
|
|
1029
|
+
// off this one, present only while a window is open.
|
|
1030
|
+
if (verdict !== null) return verdict(e, t);
|
|
1031
|
+
if (!n.re && e.m?.xe === undefined && !snapshotCaptureActive && (!unflushedStaged || e.Ae === NOT_PENDING) && // A28, see readNodeFast
|
|
1032
|
+
!(e.u & CONFIG_OVERRIDE) && // lanes: the slow path's one arm
|
|
1514
1033
|
true) {
|
|
1515
|
-
if (
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
// Fresh-pull readers (awaitable refresh's waiter) recompute a dirty
|
|
1531
|
-
// source inline even when the height gate defers to the flush: the
|
|
1532
|
-
// waiter must park on the re-ask's window (or serve its sync answer),
|
|
1533
|
-
// never read the PRE-re-ask value as settled. Self-guarded: a clean
|
|
1534
|
-
// node no-ops and updateIfNecessary refuses disposed nodes (#2983) —
|
|
1535
|
-
// a dead target serves its last value, which is already quiescent.
|
|
1536
|
-
else if (n.C & CONFIG_FRESH_READ) updateIfNecessary(u);
|
|
1537
|
-
const i = u.rn;
|
|
1538
|
-
// parent check is shallow, might need to be recursive
|
|
1539
|
-
if (i >= n.rn && e._parent !== n) {
|
|
1540
|
-
n.rn = i + 1;
|
|
1034
|
+
if (t) {
|
|
1035
|
+
if (tracking) link(e, t);
|
|
1036
|
+
// L2: a pass that reads something already in the future joins it —
|
|
1037
|
+
// the one mechanism behind "a write that reaches the future joins
|
|
1038
|
+
// it". Tracked or not (`untrack` is about dependencies, not about
|
|
1039
|
+
// which world a pass derives from — posture-store-parity S4/S5): a
|
|
1040
|
+
// derivation of a held write published mainline would tear. Frame
|
|
1041
|
+
// readers (children-forbidden, A32) see committed below and stay
|
|
1042
|
+
// out; a render effect outside a parking flush sees committed and
|
|
1043
|
+
// stays out too (rule 3, `frameRead`). The pass remembers it read the
|
|
1044
|
+
// future (REACTIVE_JOINED): a first pass that did is born held (A29),
|
|
1045
|
+
// wherever it was created. Lane work sees the screen (`frameRead`).
|
|
1046
|
+
if (e.u & CONFIG_HELD && !(t.u & CONFIG_CHILDREN_FORBIDDEN)) {
|
|
1047
|
+
if (frameRead(t, e)) return e.pe;
|
|
1048
|
+
joinPass(t, e);
|
|
1541
1049
|
}
|
|
1542
1050
|
}
|
|
1051
|
+
// Committed visibility for untracked and children-forbidden readers.
|
|
1052
|
+
if (!t || e.Ae === NOT_PENDING || t.u & CONFIG_CHILDREN_FORBIDDEN) return e.pe;
|
|
1053
|
+
// (A plain signal is never uninitialized — the carve-out is `serve`'s.)
|
|
1054
|
+
if (t.u & CONFIG_VERDICT && stagedScreen(t)) return e.pe;
|
|
1055
|
+
stagedRead(t);
|
|
1056
|
+
return e.Ae;
|
|
1057
|
+
}
|
|
1058
|
+
// Rule 3: this read serves the committed value to a render effect outside a
|
|
1059
|
+
// parking flush (decided after the pull below — a pull can join).
|
|
1060
|
+
let u = false;
|
|
1061
|
+
if (t) {
|
|
1062
|
+
if (tracking) {
|
|
1063
|
+
link(e, t);
|
|
1064
|
+
if (E.re) pullComputed(E, t);
|
|
1065
|
+
}
|
|
1066
|
+
// L2, as in the fast block above (tracked or not). A node born into the
|
|
1067
|
+
// future (uninitialized) has no committed value: every reader derives
|
|
1068
|
+
// from the future there, a render effect included (A29: a stale reader
|
|
1069
|
+
// of it cannot fall back to the committed frame and enters instead).
|
|
1070
|
+
if (e.u & CONFIG_HELD && !(e.u & CONFIG_OVERRIDE) && !(t.u & CONFIG_CHILDREN_FORBIDDEN)) {
|
|
1071
|
+
if (E.G & STATUS_UNINITIALIZED || !frameRead(t, e)) joinPass(t, e); else u = true;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
// Lanes: a lane's node (after the pull — the node is current). NOT_PENDING
|
|
1075
|
+
// falls through: lane work's read of a pending member throws like any.
|
|
1076
|
+
if (e.u & CONFIG_OVERRIDE) {
|
|
1077
|
+
const n = GlobalQueue.Nt(t, e);
|
|
1078
|
+
if (n !== NOT_PENDING) return n;
|
|
1079
|
+
}
|
|
1080
|
+
// A stale reader of a held flight (rule 3, A15's reveal corollary) is served
|
|
1081
|
+
// the committed value — coherent with the frame, whose inputs are the
|
|
1082
|
+
// committed ones too — and does not go pending on it. So is lane work
|
|
1083
|
+
// reading a flight that is not the lane's own (the parent's, or
|
|
1084
|
+
// mainline's): a lane breaks out of its parent's hold and waits only on
|
|
1085
|
+
// what derives from the guess (A31: "under a lane, a pending node on no
|
|
1086
|
+
// lane serves its committed value").
|
|
1087
|
+
// A verdict reader likewise (CONFIG_VERDICT): a frame reader sees the
|
|
1088
|
+
// screen, and for a flight the screen is the committed value — a render
|
|
1089
|
+
// effect keeps its DOM by throwing, a memo has no DOM and is handed the
|
|
1090
|
+
// value. `[isPending(x), x()]` reads `[true, stale]` in either order (A10)
|
|
1091
|
+
// — unless the flight committed beneath inputs already on screen
|
|
1092
|
+
// (`observeFlight`).
|
|
1093
|
+
if (E.G & STATUS_PENDING && !u && !(e.u & CONFIG_OVERRIDE) && !(E.G & STATUS_UNINITIALIZED)) {
|
|
1094
|
+
// A reader with no committed value yet sees the flight pending: a
|
|
1095
|
+
// boundary a lane mounts shows its fallback (A29's boundary exemption).
|
|
1096
|
+
if (passLane !== null && !(t?.G & STATUS_UNINITIALIZED)) u = true; else if (t !== null && t.u & CONFIG_VERDICT) u = GlobalQueue.ft(t, E);
|
|
1543
1097
|
}
|
|
1544
|
-
if (
|
|
1545
|
-
// A reader landing on a pending node throws
|
|
1546
|
-
//
|
|
1547
|
-
//
|
|
1548
|
-
//
|
|
1549
|
-
//
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
// flight's inputs are themselves unpublished: the stamp alone does not
|
|
1553
|
-
// say so (it is pending-node bookkeeping), so it is refused when the
|
|
1554
|
-
// inputs are on screen — committed by a batch that left the flight in
|
|
1555
|
-
// the air (CONFIG_INPUTS_PUBLISHED, #3305) or revealed through a lane
|
|
1556
|
-
// (optimistic / latest, #3334) — and the reader holds instead. An
|
|
1557
|
-
// UNINITIALIZED node has no committed value to show and holds too
|
|
1558
|
-
// (firewall-backed store reads always did; plain memos since the #3043
|
|
1559
|
-
// port): falling through served `undefined` as if settled and stranded
|
|
1560
|
-
// the reader outside both transactions, so it never re-ran.
|
|
1561
|
-
if (n && !(stale && !(u.h & STATUS_UNINITIALIZED) && !(u.C & CONFIG_INPUTS_PUBLISHED) && !(u.C & CONFIG_HAS_LANE && GlobalQueue.tt(u)) && heldFromStale(u, n))) {
|
|
1562
|
-
// Per-lane suspension lives with the engine (a non-null lane implies it
|
|
1563
|
-
// is installed): under a lane, only same-lane pending async without an
|
|
1564
|
-
// active override throws — plus uninitialized sources regardless of
|
|
1565
|
-
// lane (#3276); that check rides laneSuspends so floor bundles don't
|
|
1566
|
-
// pay for it.
|
|
1567
|
-
if (currentOptimisticLane === null || GlobalQueue.it(u)) {
|
|
1098
|
+
if (E.G & STATUS_PENDING && !u) {
|
|
1099
|
+
// A reader landing on a pending node throws; an untracked read of an
|
|
1100
|
+
// UNINITIALIZED node has no committed value to serve and throws too. A
|
|
1101
|
+
// children-forbidden reader (createTrackedEffect / onSettled) sees the
|
|
1102
|
+
// frame, not the graph (A32): the committed value, and the NotReady only
|
|
1103
|
+
// where there is none (uninitialized).
|
|
1104
|
+
if (t) {
|
|
1105
|
+
if (!(t.u & CONFIG_CHILDREN_FORBIDDEN) || E.G & STATUS_UNINITIALIZED) {
|
|
1568
1106
|
// An untracked read of a pending node still re-runs its reader when
|
|
1569
1107
|
// the node settles — unless nobody is reading (`spectating`, #3528)
|
|
1570
1108
|
// or the reader is the node itself.
|
|
1571
|
-
if (!tracking && !spectating && e !==
|
|
1572
|
-
throw
|
|
1109
|
+
if (!tracking && !spectating && e !== t) link(e, t);
|
|
1110
|
+
throw E.m?.V;
|
|
1573
1111
|
}
|
|
1574
|
-
} else if (
|
|
1575
|
-
|
|
1576
|
-
// read with no reader identity (#3648 follow-up, A18 (d)): a memo
|
|
1577
|
-
// whose first landing rode its lane (asyncWrite's lane branch →
|
|
1578
|
-
// `laneOverride`) has no `_value` — the flag stays set until the lane's
|
|
1579
|
-
// commit promotes the override — yet the override IS the displayed
|
|
1580
|
-
// value of a pending node (A18 (c), the screen keeps it until the
|
|
1581
|
-
// commit), exactly as an initialized node re-deriving under its override
|
|
1582
|
-
// displays it. "Uninitialized must suspend" (#3276, A19 exception 1) was
|
|
1583
|
-
// written for a node with NOTHING to show; this node has the override.
|
|
1584
|
-
// The arm fires in the body-end window: the source override superseded
|
|
1585
|
-
// (A18 body-end, #3427), the memo re-deriving on the plain channel and
|
|
1586
|
-
// held, its own slot still armed. Fall through to serve()'s override
|
|
1587
|
-
// arm. Readers WITH identity are untouched: a tracked lane reader keeps
|
|
1588
|
-
// the override (A17), an off-lane one suspends (#3651, `overrideRead`).
|
|
1589
|
-
!(hasActiveOverride(e) && e.C & CONFIG_DERIVED_OVERRIDE)) {
|
|
1590
|
-
throw u.o?._;
|
|
1112
|
+
} else if (E.G & STATUS_UNINITIALIZED) {
|
|
1113
|
+
throw E.m?.V;
|
|
1591
1114
|
}
|
|
1592
1115
|
}
|
|
1593
|
-
//
|
|
1594
|
-
//
|
|
1595
|
-
|
|
1596
|
-
// serving node values (the seed, or last-good data after a failed refetch).
|
|
1597
|
-
if (u.he && u.h & STATUS_ERROR) {
|
|
1116
|
+
// An errored derive throws for every late reader instead of silently
|
|
1117
|
+
// serving node values (memo parity, #2897 ruling).
|
|
1118
|
+
if (E.re && E.G & STATUS_ERROR) {
|
|
1598
1119
|
// Only a genuine reactive re-read may retry an errored async source:
|
|
1599
1120
|
// - tracking: owned/tracked scope only (never events / `untrack` / effect side-effect phase)
|
|
1600
|
-
// - !pendingCheckActive: an `isPending` probe observes the error, never refetches
|
|
1601
1121
|
// - owner._time < clock: only on a later cycle than the one the error was found
|
|
1602
|
-
if (tracking &&
|
|
1603
|
-
recompute(
|
|
1122
|
+
if (tracking && E.Ne < clock) {
|
|
1123
|
+
recompute(E);
|
|
1604
1124
|
return read(e);
|
|
1605
|
-
} else throw
|
|
1125
|
+
} else throw E.m?.V;
|
|
1606
1126
|
}
|
|
1607
|
-
if (snapshotCaptureActive &&
|
|
1608
|
-
const
|
|
1609
|
-
if (
|
|
1610
|
-
const
|
|
1611
|
-
const u = e.
|
|
1612
|
-
if (u !==
|
|
1613
|
-
return
|
|
1127
|
+
if (snapshotCaptureActive && t && t.u & CONFIG_IN_SNAPSHOT_SCOPE) {
|
|
1128
|
+
const n = e.m?.xe;
|
|
1129
|
+
if (n !== undefined) {
|
|
1130
|
+
const E = n === NO_SNAPSHOT ? undefined : n;
|
|
1131
|
+
const u = e.Ae !== NOT_PENDING ? e.Ae : e.pe;
|
|
1132
|
+
if (u !== E) t.R |= REACTIVE_SNAPSHOT_STALE;
|
|
1133
|
+
return E;
|
|
1614
1134
|
}
|
|
1615
1135
|
}
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
// sweep registration when the arm was inline; keep that.
|
|
1620
|
-
!visibleOverride(e)) {
|
|
1136
|
+
if (u) return e.pe;
|
|
1137
|
+
const s = serve(e, t);
|
|
1138
|
+
if (!t && typeof n.re === "function" && e.u & CONFIG_AUTO_DISPOSE && !(E.G & STATUS_PENDING) && !e.t) {
|
|
1621
1139
|
// Deferred, not inline (#3078): an inline unobserved() here made untracked
|
|
1622
1140
|
// reads destructive — dispose on this read, full revival recompute on the
|
|
1623
1141
|
// next — so consecutive reads could answer differently with no write in
|
|
1624
|
-
// between
|
|
1142
|
+
// between.
|
|
1625
1143
|
// The sweep at flush finalization re-validates and reclaims; schedule()
|
|
1626
1144
|
// guarantees that flush happens even if nothing else is queued.
|
|
1627
1145
|
dormantNodes.add(e);
|
|
1628
1146
|
schedule();
|
|
1629
1147
|
}
|
|
1630
|
-
return
|
|
1148
|
+
return s;
|
|
1631
1149
|
}
|
|
1632
1150
|
|
|
1633
1151
|
/**
|
|
1634
1152
|
* Rule 1, the one slow implementation (DESIGN-CONSOLIDATION move 3b, step
|
|
1635
1153
|
* 6c): the value a reader `c` (null = untracked, no pass) is served from
|
|
1636
|
-
* `el
|
|
1637
|
-
*
|
|
1638
|
-
*
|
|
1639
|
-
* served for one). Called by read()'s slow tail and by the store's untracked
|
|
1640
|
-
* node path (nodeValue); the fast paths (readNodeFast, read's fast block)
|
|
1641
|
-
* keep their trivial ternary by design (perf, see the doc). Arms, in order:
|
|
1642
|
-
* - the override (A17), routed through the engine for a tracked reader under
|
|
1643
|
-
* a lane or a supersession (A18), an authoritative reader marked instead;
|
|
1644
|
-
* - the lane entanglement gate (committed, recorded for replay);
|
|
1645
|
-
* - a node born held has nothing for an untracked reader (A19 exception 1);
|
|
1154
|
+
* `el`. Called by read()'s slow tail; the fast path (read's fast block) keeps
|
|
1155
|
+
* its trivial ternary by design (perf, see the doc). Arms, in order:
|
|
1156
|
+
* - a node born staged has nothing for an untracked reader (A19 exception 1);
|
|
1646
1157
|
* - an unflushed write serves committed and re-runs the reader in the
|
|
1647
1158
|
* carrying flush (A28);
|
|
1648
|
-
* - readerSeesCommitted, else the staged value
|
|
1649
|
-
*/ function serve(e,
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
// A17-silent "landing equals override" paths notify this node's subs so
|
|
1660
|
-
// the reader re-runs when truth arrives.
|
|
1661
|
-
// A28 (5): an optimistic write written this tick, outside a flush, is not
|
|
1662
|
-
// yet the active override — fall through to the normal selection (the
|
|
1663
|
-
// authoritative mark below still applies: until() must wake on landing).
|
|
1664
|
-
if (!(n && n.C & CONFIG_AUTHORITATIVE_READ) && !unflushedOverride(e)) {
|
|
1665
|
-
// A tracked read of an override is the engine's selection (a lane or a
|
|
1666
|
-
// supersession implies the engine): a render effect OFF the override's
|
|
1667
|
-
// held lane sees the committed value (#3460, lanes mirror transitions);
|
|
1668
|
-
// a node whose own source answered with a DIFFERENT value hands a
|
|
1669
|
-
// tracked reader the staged truth (A18 supersession, #3331). Untracked
|
|
1670
|
-
// reads display the override.
|
|
1671
|
-
if (n && e.C & (CONFIG_HAS_LANE | CONFIG_OVERRIDE_SUPERSEDED)) return GlobalQueue.ut(e, n);
|
|
1672
|
-
return unwrapOverride(e.o?.Fe);
|
|
1673
|
-
}
|
|
1674
|
-
e.C |= CONFIG_AUTHORITATIVE_OBSERVED;
|
|
1675
|
-
}
|
|
1676
|
-
// Entanglement gate: a reader recomputing under an optimistic lane that reads
|
|
1677
|
-
// a pending mid-transition write sees the committed value. Projection-store
|
|
1678
|
-
// manual writes use the firewall's manual-write flag to opt into this path.
|
|
1679
|
-
// Async drivers are not under an optimistic lane and so bypass this, reading
|
|
1680
|
-
// _pendingValue for correct fetching. The sub is recorded for replay at commit
|
|
1681
|
-
// so it re-runs with the new committed view. (Gate details live with the
|
|
1682
|
-
// engine — a non-null lane implies it is installed.)
|
|
1683
|
-
if (currentOptimisticLane !== null && activeTransition !== null && n !== null && GlobalQueue.lt(e, t, n)) {
|
|
1684
|
-
return i;
|
|
1685
|
-
}
|
|
1686
|
-
// In optimistic lane context, return _value for optimistic/lane-assigned signals
|
|
1687
|
-
// and for regular signals in stale mode (render effects). Non-stale readers (user
|
|
1688
|
-
// effects) see _pendingValue so that latest() and direct reads stay consistent.
|
|
1689
|
-
// (The lane-context clause lives with the engine.) Children-forbidden readers
|
|
1690
|
-
// (createTrackedEffect / onSettled callbacks) get committed visibility — see
|
|
1691
|
-
// readNodeFast (#3006).
|
|
1692
|
-
// A node born held (recompute) has a staged value and no committed one: a
|
|
1693
|
-
// stale reader cannot fall back to the committed frame, so it takes the
|
|
1694
|
-
// staged value and enters like a tracked reader (A29); an untracked reader
|
|
1695
|
-
// has nothing to serve and holds (A19 exception 1) — a bookkeeping read
|
|
1696
|
-
// (`spectate`) likewise: it derives nothing, so it cannot enter, and a
|
|
1697
|
-
// held-only value is simply not ready to it.
|
|
1698
|
-
const u = e._e !== NOT_PENDING && (e.h & STATUS_UNINITIALIZED) !== 0;
|
|
1699
|
-
if (u && (!n || spectating)) throw new NotReadyError(null);
|
|
1700
|
-
const l = n && unflushedStaged ? unflushedValue(e, i) : NOT_PENDING;
|
|
1701
|
-
if (l !== NOT_PENDING) {
|
|
1702
|
-
markLateLinker(n);
|
|
1703
|
-
if (pendingCheckActive) GlobalQueue.rt(e, l);
|
|
1704
|
-
return l;
|
|
1159
|
+
* - readerSeesCommitted, else the staged value.
|
|
1160
|
+
*/ function serve(e, t) {
|
|
1161
|
+
// A node born staged (recompute) has a staged value and no committed one:
|
|
1162
|
+
// an untracked reader has nothing to serve and holds (A19 exception 1) — a
|
|
1163
|
+
// bookkeeping read (`spectate`) likewise, and a children-forbidden reader
|
|
1164
|
+
// (A32: the frame, which has nothing here).
|
|
1165
|
+
if (e.Ae !== NOT_PENDING && e.G & STATUS_UNINITIALIZED && (!t || spectating || t.u & CONFIG_CHILDREN_FORBIDDEN)) throw new NotReadyError(null);
|
|
1166
|
+
const n = t && unflushedStaged ? unflushedValue(e) : NOT_PENDING;
|
|
1167
|
+
if (n !== NOT_PENDING) {
|
|
1168
|
+
markLateLinker(t);
|
|
1169
|
+
return n;
|
|
1705
1170
|
}
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
return r;
|
|
1171
|
+
if (readerSeesCommitted(e, t)) return e.pe;
|
|
1172
|
+
if (t.u & CONFIG_VERDICT && !(e.G & STATUS_UNINITIALIZED) && stagedScreen(t)) return e.pe;
|
|
1173
|
+
stagedRead(t, e);
|
|
1174
|
+
return e.Ae;
|
|
1711
1175
|
}
|
|
1712
1176
|
|
|
1713
|
-
/**
|
|
1714
|
-
*
|
|
1715
|
-
*
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1177
|
+
/** A pass read a staging of this flush: it derives from what the flush may
|
|
1178
|
+
* yet hold (REACTIVE_STAGED_READ — the seam decides). Lane work too (plan sec. 28, a
|
|
1179
|
+
* lane sees the screen plus its own guesses): the staging is the screen if
|
|
1180
|
+
* the frame commits — one pass, the common case — and a held write if it
|
|
1181
|
+
* parks, which the seam repairs (`stagedReaders`): the pass re-derives on
|
|
1182
|
+
* the committed world and its lane's runs wait that round, so the held
|
|
1183
|
+
* write never shows through the lane. A verdict lane's work likewise: the
|
|
1184
|
+
* lane holds verdicts, not the frame's other stagings (#3851) — except a
|
|
1185
|
+
* verdict reader, which answered for itself (the lane seam, lanes.ts). Not
|
|
1186
|
+
* a read of a node born staged: it has no committed value to re-derive on,
|
|
1187
|
+
* and a re-run would read the same staging and re-queue every round. */ function stagedRead(e, t) {
|
|
1188
|
+
e.R |= REACTIVE_STAGED_READ;
|
|
1189
|
+
if (passLane !== null && !(t?.G & STATUS_UNINITIALIZED)) stagedReaders.push(e);
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
/** A10 for a staged node: a verdict reader (the pass entered a window) that
|
|
1193
|
+
* also reads a frame's proposal plainly sees the screen — `[latest(q), q()]`
|
|
1194
|
+
* is `[b, a]` — once the frame has a transaction, and re-derives when it
|
|
1195
|
+
* lands: at this very seam if nothing holds it (the stale run is void,
|
|
1196
|
+
* #3322 — one run, on the committed world), or with the hold. Before any
|
|
1197
|
+
* transaction the answer is the seam's and the reader watches it
|
|
1198
|
+
* (verdict.ts). A node born into the future has no screen: its staging is
|
|
1199
|
+
* its only value (A29). */ function stagedScreen(e) {
|
|
1200
|
+
if (flushTransaction === null) return false;
|
|
1201
|
+
staleReader(e, flushTransaction);
|
|
1202
|
+
return true;
|
|
1723
1203
|
}
|
|
1724
1204
|
|
|
1725
1205
|
/** A28 (4) — written inside a recompute that runs OUTSIDE a flush (a
|
|
1726
1206
|
* creation-time compute): promoted at that pass's end, visible to the rest of
|
|
1727
1207
|
* the block. Cold: only contextual writes reach here. */ function notePromotedWrite(e) {
|
|
1728
|
-
if (globalQueue.
|
|
1729
|
-
e.
|
|
1208
|
+
if (globalQueue.ee || e.u & CONFIG_PROMOTED) return;
|
|
1209
|
+
e.u |= CONFIG_PROMOTED;
|
|
1730
1210
|
promotedWrites.push(e);
|
|
1731
1211
|
}
|
|
1732
1212
|
|
|
@@ -1736,52 +1216,29 @@ function read(e) {
|
|
|
1736
1216
|
* async landing (asyncWrite), and a value arriving from async during the pass
|
|
1737
1217
|
* REVEALS — the creation-time arm skips pending computeds for the same
|
|
1738
1218
|
* reason. Firewall leaves belong to a projection whose compute is the tree's
|
|
1739
|
-
* own work, captured (or deliberately not) at creation. */ function captureWriteSnapshot(e,
|
|
1740
|
-
if (e.
|
|
1741
|
-
ext(e).
|
|
1742
|
-
e.
|
|
1219
|
+
* own work, captured (or deliberately not) at creation. */ function captureWriteSnapshot(e, t) {
|
|
1220
|
+
if (e.u & CONFIG_NO_SNAPSHOT || e.re !== undefined || e.m?.xe !== undefined) return;
|
|
1221
|
+
ext(e).xe = t === undefined ? NO_SNAPSHOT : t;
|
|
1222
|
+
e.u |= CONFIG_HAS_SNAPSHOT;
|
|
1743
1223
|
snapshotSources.add(e);
|
|
1744
1224
|
}
|
|
1745
1225
|
|
|
1746
|
-
function setSignal(e,
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
// a
|
|
1750
|
-
//
|
|
1751
|
-
//
|
|
1752
|
-
|
|
1753
|
-
//
|
|
1754
|
-
//
|
|
1755
|
-
//
|
|
1756
|
-
//
|
|
1757
|
-
|
|
1758
|
-
// the write before it reaches here — see heldDerivation — and re-derive
|
|
1759
|
-
// under the hold instead of masking; the join stands either way.
|
|
1760
|
-
if (e.we && activeTransition !== e.we) {
|
|
1761
|
-
if (globalQueue.Jn) globalQueue.initTransition(e.we); else {
|
|
1762
|
-
batchJoins.push(e.we);
|
|
1763
|
-
// dupes: a bare return in initTransition
|
|
1764
|
-
schedule();
|
|
1765
|
-
}
|
|
1766
|
-
}
|
|
1767
|
-
// The optimistic write path lives with the engine: only optimisticSignal /
|
|
1768
|
-
// optimisticComputed callers and optimistic store nodes carry an
|
|
1769
|
-
// _overrideValue slot (flagged by CONFIG_OPTIMISTIC — a masked read of the
|
|
1770
|
-
// always-present config instead of a missing-property probe), and every
|
|
1771
|
-
// module that installs one installs the engine first.
|
|
1772
|
-
if (e.C & CONFIG_OPTIMISTIC) {
|
|
1773
|
-
if (!projectionWriteActive) return GlobalQueue.ot(e, n);
|
|
1774
|
-
// An authoritative store landing on an override-covered node: the store
|
|
1775
|
-
// twin of asyncWrite's override branch, decided by the engine (#3331).
|
|
1776
|
-
const t = e.o?.Fe;
|
|
1777
|
-
if (t !== undefined && t !== NOT_PENDING) return GlobalQueue.st(e, n);
|
|
1778
|
-
}
|
|
1779
|
-
const t = e._e === NOT_PENDING ? e.ce : e._e;
|
|
1780
|
-
if (typeof n === "function") n = n(t);
|
|
1226
|
+
function setSignal(e, t) {
|
|
1227
|
+
const n = e.Ae === NOT_PENDING ? e.pe : e.Ae;
|
|
1228
|
+
if (typeof t === "function") t = t(n);
|
|
1229
|
+
// Lanes: a write landing on a guess is its truth (A18 — an async guess's
|
|
1230
|
+
// own landing), judged against the guess; one landing on a lane's
|
|
1231
|
+
// derivation (its flight) is the lane's staging (lanes.ts).
|
|
1232
|
+
if (e.u & CONFIG_OVERRIDE) return GlobalQueue.Tt(e, t);
|
|
1233
|
+
// L2 (T4) / A34 (1): a write to a node whose staged state is held is a
|
|
1234
|
+
// second proposal for the slot — the same value again or another — and
|
|
1235
|
+
// the two cannot finish at different times: the writer's tick joins the
|
|
1236
|
+
// hold, before the equality gate.
|
|
1237
|
+
if (e.u & CONFIG_HELD) joinFuture(txOf(e));
|
|
1781
1238
|
// Uninitialized check first: the first commit has no previous value, so the
|
|
1782
1239
|
// user comparator must not run against `undefined` (matches recompute).
|
|
1783
|
-
const
|
|
1784
|
-
if (!
|
|
1240
|
+
const E = !!(e.G & STATUS_UNINITIALIZED) || !e.We || !e.We(n, t);
|
|
1241
|
+
if (!E) return t;
|
|
1785
1242
|
// A write during hydration's snapshot capture to a source that has no
|
|
1786
1243
|
// snapshot — created BEFORE capture began (module-level state: an identity
|
|
1787
1244
|
// minted from onSettled in the pass, a preference read from storage) —
|
|
@@ -1791,94 +1248,58 @@ function setSignal(e, n) {
|
|
|
1791
1248
|
// pass whose DOM writes are skipped, and a component rendered later in the
|
|
1792
1249
|
// pass reads a value the server never had. Store leaves written here are
|
|
1793
1250
|
// plain signals and qualify the same way.
|
|
1794
|
-
if (snapshotCaptureActive) captureWriteSnapshot(e,
|
|
1795
|
-
const u = e.
|
|
1251
|
+
if (snapshotCaptureActive) captureWriteSnapshot(e, n);
|
|
1252
|
+
const u = e.Ae !== NOT_PENDING;
|
|
1796
1253
|
if (!u) queuePendingNode(e);
|
|
1797
|
-
// A28
|
|
1798
|
-
//
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
else if (e.we !== null) stashHeldRewrite(e);
|
|
1802
|
-
e._e = n;
|
|
1254
|
+
// A28: a held node rewritten outside a flush keeps its flushed staging
|
|
1255
|
+
// for every reader until the flush that carries the rewrite.
|
|
1256
|
+
else if (e.u & CONFIG_HELD && !globalQueue.ee) stashFlushed(e);
|
|
1257
|
+
e.Ae = t;
|
|
1803
1258
|
if (context !== null) notePromotedWrite(e);
|
|
1804
|
-
// syncCompanions only pokes _pendingSignal/_latestValueComputed — with
|
|
1805
|
-
// neither companion present the call is a guaranteed no-op (companions are
|
|
1806
|
-
// only ever created, never removed, and creating one installs the hook and
|
|
1807
|
-
// sets CONFIG_HAS_COMPANIONS — one masked read replaces two optional-field
|
|
1808
|
-
// probes on every write).
|
|
1809
|
-
if (e.C & CONFIG_HAS_COMPANIONS && GlobalQueue.Ve !== null) {
|
|
1810
|
-
GlobalQueue.Ve(e, n);
|
|
1811
|
-
// A28 (2): the verdict computed here is the PRE-flush one (an unflushed
|
|
1812
|
-
// write is not pending); the flush that carries the write re-syncs so
|
|
1813
|
-
// the companions mirror the flushed world. Only companion nodes pay.
|
|
1814
|
-
if (!globalQueue.Jn) unflushedCompanions.push(e);
|
|
1815
|
-
}
|
|
1816
1259
|
// _time is a computed-only slot (§12e): writing it on a signal would fork
|
|
1817
1260
|
// the lean shape. Every read site is computed-typed.
|
|
1818
|
-
if (e.
|
|
1261
|
+
if (e.re !== undefined) e.Ne = clock;
|
|
1819
1262
|
// Staged-rewrite fast path (§12d): a re-write to a node whose subscribers
|
|
1820
1263
|
// were already walked — and where nothing has recomputed or linked since
|
|
1821
1264
|
// (epoch) — re-stages the value and stops. The walk is idempotent (subs
|
|
1822
|
-
// marked, heap entries flag-guarded, effects queued once)
|
|
1823
|
-
|
|
1824
|
-
if (u && e.vn === notifyEpoch && currentOptimisticLane === null && !reaskArmed) return n;
|
|
1265
|
+
// marked, heap entries flag-guarded, effects queued once).
|
|
1266
|
+
if (u && e.ze === notifyEpoch) return t;
|
|
1825
1267
|
insertSubs(e);
|
|
1826
1268
|
schedule();
|
|
1827
|
-
return
|
|
1269
|
+
return t;
|
|
1828
1270
|
}
|
|
1829
1271
|
|
|
1830
1272
|
/**
|
|
1831
|
-
*
|
|
1832
|
-
*
|
|
1833
|
-
*
|
|
1834
|
-
*
|
|
1835
|
-
*
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1273
|
+
* User-facing setter for the memo form of `createSignal(fn)`. A write applies
|
|
1274
|
+
* first, then derivations re-run (A34 as amended 2026-10-01, rule B; core
|
|
1275
|
+
* R31): the write stages like any other, and a source change — in this flush
|
|
1276
|
+
* or a later one, under a hold or on mainline — re-derives with the staged
|
|
1277
|
+
* write as `prev`. The write never refuses the re-run (the frame-scoped mask
|
|
1278
|
+
* of #3733/#3740 and #2692's "write wins the tick" before it are gone; call
|
|
1279
|
+
* order inside a flush was never observable) and on its own never causes one.
|
|
1280
|
+
* REACTIVE_MANUAL_WRITE only marks the staging as a user proposal — the A34
|
|
1281
|
+
* (1)/(3) discriminator — until a pass re-derives it or the commit lands it.
|
|
1282
|
+
*/ function setMemo(e, t) {
|
|
1283
|
+
// A34 (3), #3612: is `el`'s staging a derivation another transaction holds
|
|
1284
|
+
// — held, not a manual proposal, and the writer not that transaction
|
|
1285
|
+
// (mainline, or a flush joined elsewhere)? A held pass result is nobody's
|
|
1286
|
+
// proposal: a setter reaching it composes on the committed frame it was
|
|
1287
|
+
// written against and becomes `prev` for the hold's re-derivation, instead
|
|
1288
|
+
// of replacing it. A write made under the hold carries the mark and keeps
|
|
1289
|
+
// (1)'s last-write-wins. Only the user setter asks; an async landing
|
|
1290
|
+
// writing a held node is the transaction's own work.
|
|
1291
|
+
const n = e.u & CONFIG_HELD && !(e.R & REACTIVE_MANUAL_WRITE) && txOf(e) !== flushTransaction;
|
|
1292
|
+
// The writer read the committed frame; its updater composes on it.
|
|
1293
|
+
if (n && typeof t === "function") t = t(e.pe);
|
|
1294
|
+
const E = setSignal(e, t);
|
|
1295
|
+
if (n) {
|
|
1296
|
+
// The one write that re-runs: the staging it replaced was derived from
|
|
1297
|
+
// inputs the writer never saw, so the hold re-derives over the write.
|
|
1298
|
+
e.R = e.R & ~REACTIVE_CHECK | REACTIVE_DIRTY;
|
|
1299
|
+
insertIntoHeap(e, dirtyQueue);
|
|
1840
1300
|
schedule();
|
|
1841
|
-
}
|
|
1842
|
-
|
|
1843
|
-
e.ct = clock;
|
|
1844
|
-
}
|
|
1845
|
-
|
|
1846
|
-
/** A34 amendment (#3612) — is `el`'s staging a DERIVATION another transaction
|
|
1847
|
-
* holds: stamped by a transaction that is not the writer's, and not a manual
|
|
1848
|
-
* proposal (the mask, on the node or — a store leaf — its firewall)? #2692's
|
|
1849
|
-
* "manual write wins" is a rule for one synchronous frame; across a hold the
|
|
1850
|
-
* held pass result is nobody's proposal, and a user setter reaching it
|
|
1851
|
-
* composes on the committed frame it was written against and becomes `prev`
|
|
1852
|
-
* for the transaction's re-derivation (rederiveHeld) instead of replacing it.
|
|
1853
|
-
* Writes made under the holding transaction masked the node and keep
|
|
1854
|
-
* A34(1)'s last-write-wins. Only the user setters ask; an async landing or a
|
|
1855
|
-
* companion writing a stamped node is the transaction's own work. */ function heldDerivation(e) {
|
|
1856
|
-
return e.we !== null && activeTransition !== e.we && !((e.De || e).oe & REACTIVE_MANUAL_WRITE);
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1859
|
-
/** The held-derivation write's second half: the node re-derives under its
|
|
1860
|
-
* hold with the written staging as the pass's `prev`. Nothing is masked. The
|
|
1861
|
-
* write took the A34 join (setSignal), which scheduled the flush that drains
|
|
1862
|
-
* this; recompute re-enters the stamp. */ function rederiveHeld(e) {
|
|
1863
|
-
e.oe |= REACTIVE_DIRTY;
|
|
1864
|
-
// over CHECK: the heap visit recomputes, not re-checks
|
|
1865
|
-
enqueueSub(e);
|
|
1866
|
-
}
|
|
1867
|
-
|
|
1868
|
-
/**
|
|
1869
|
-
* User-facing setter for the memo form of `createSignal(fn)`. Behaves like
|
|
1870
|
-
* `setSignal`, but also cancels any pending recompute of the memo so the
|
|
1871
|
-
* manual value wins over a value that would otherwise be produced by an
|
|
1872
|
-
* upstream change in the same tick. Across a hold the write is not a
|
|
1873
|
-
* proposal: a memo another transaction holds as a pass result composes on the
|
|
1874
|
-
* committed value and re-derives under the hold with the write as `prev`
|
|
1875
|
-
* (A34 amendment, #3612; heldDerivation).
|
|
1876
|
-
*/ function setMemo(e, n) {
|
|
1877
|
-
const t = heldDerivation(e);
|
|
1878
|
-
if (t && typeof n === "function") n = n(e.ce);
|
|
1879
|
-
const i = setSignal(e, n);
|
|
1880
|
-
t ? rederiveHeld(e) : suppressComputedRecompute(e);
|
|
1881
|
-
return i;
|
|
1301
|
+
} else if (e.Ae !== NOT_PENDING) e.R |= REACTIVE_MANUAL_WRITE;
|
|
1302
|
+
return E;
|
|
1882
1303
|
}
|
|
1883
1304
|
|
|
1884
1305
|
/**
|
|
@@ -1899,27 +1320,23 @@ function setSignal(e, n) {
|
|
|
1899
1320
|
* setTimeout(() => runWithOwner(owner, fn), ms);
|
|
1900
1321
|
* }
|
|
1901
1322
|
* ```
|
|
1902
|
-
*/ function runWithOwner(e,
|
|
1903
|
-
const
|
|
1904
|
-
const
|
|
1323
|
+
*/ function runWithOwner(e, t) {
|
|
1324
|
+
const n = context;
|
|
1325
|
+
const E = tracking;
|
|
1905
1326
|
context = e;
|
|
1906
1327
|
tracking = false;
|
|
1907
1328
|
try {
|
|
1908
|
-
return
|
|
1329
|
+
return t();
|
|
1909
1330
|
} finally {
|
|
1910
|
-
context =
|
|
1911
|
-
tracking =
|
|
1331
|
+
context = n;
|
|
1332
|
+
tracking = E;
|
|
1912
1333
|
}
|
|
1913
1334
|
}
|
|
1914
1335
|
|
|
1915
|
-
function staleValues(e,
|
|
1916
|
-
const t = stale;
|
|
1917
|
-
stale = n;
|
|
1336
|
+
function staleValues(e, t = true) {
|
|
1918
1337
|
try {
|
|
1919
1338
|
return e();
|
|
1920
|
-
} finally {
|
|
1921
|
-
stale = t;
|
|
1922
|
-
}
|
|
1339
|
+
} finally {}
|
|
1923
1340
|
}
|
|
1924
1341
|
|
|
1925
1342
|
/**
|
|
@@ -1927,42 +1344,19 @@ function staleValues(e, n = true) {
|
|
|
1927
1344
|
* it validates the target, marks through here, then builds the quiescence
|
|
1928
1345
|
* promise on the resolve()/until() effect machinery). Flags the node's next
|
|
1929
1346
|
* recompute as a quiet re-ask and schedules it; no-ops for non-derived or
|
|
1930
|
-
* disposed targets
|
|
1347
|
+
* disposed targets.
|
|
1931
1348
|
*/ function markRefresh(e) {
|
|
1932
|
-
if (typeof e.
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
e.oe &= ~REACTIVE_MANUAL_WRITE;
|
|
1942
|
-
// The lift falls through to the re-ask classification below. The held
|
|
1943
|
-
// write's value change already rides the transaction; the refetch it
|
|
1944
|
-
// asks for is the same question with unchanged inputs. Skipping the
|
|
1945
|
-
// mark here classified that refetch as a NEW question, which pends
|
|
1946
|
-
// every leaf (3.1) — an action doing setStore + yield + refresh(store)
|
|
1947
|
-
// lit up every sibling row, and affects() could not narrow it (a mark
|
|
1948
|
-
// only turns pending on). Same-question motion stays silent (3.4);
|
|
1949
|
-
// the written slot and any declared mark carry the pending instead.
|
|
1950
|
-
}
|
|
1951
|
-
// A refresh with no value-change dirt already queued is a re-ask of the
|
|
1952
|
-
// same question: mark it so the recompute classifies any resulting
|
|
1953
|
-
// pending window as quiet (not pending). If the node is already dirty
|
|
1954
|
-
// from a real input change, the question changed — don't mark.
|
|
1955
|
-
// REACTIVE_IN_HEAP counts as dirt: insertSubs schedules subscribers by
|
|
1956
|
-
// heap insertion alone (no DIRTY/CHECK flag), so a same-batch value
|
|
1957
|
-
// change followed by refresh() must not be laundered into a quiet re-ask.
|
|
1958
|
-
if (!(e.oe & (REACTIVE_DIRTY | REACTIVE_CHECK | REACTIVE_IN_HEAP))) {
|
|
1959
|
-
e.oe |= REACTIVE_REASK;
|
|
1960
|
-
armReaskClear();
|
|
1961
|
-
}
|
|
1962
|
-
e.oe = e.oe & ~REACTIVE_CHECK | REACTIVE_DIRTY;
|
|
1963
|
-
insertIntoHeap(e, queueFor(e));
|
|
1349
|
+
if (typeof e.re === "function" && !(e.R & REACTIVE_DISPOSED)) {
|
|
1350
|
+
// A manual write never refuses the re-run (A34 rule B): a refresh in the
|
|
1351
|
+
// write's own frame re-asks with the write as `prev`, like any source
|
|
1352
|
+
// change (#3026 generalized).
|
|
1353
|
+
// The re-ask of an answered question (A19 exc. 2): the next pass, going
|
|
1354
|
+
// pending, classifies its flight quiet for the verdict. Not when an
|
|
1355
|
+
// input already changed this tick — that pass asks a new question.
|
|
1356
|
+
e.R = e.R & ~REACTIVE_CHECK | REACTIVE_DIRTY | (e.R & (REACTIVE_DIRTY | REACTIVE_CHECK | REACTIVE_IN_HEAP) ? 0 : REACTIVE_REASK);
|
|
1357
|
+
insertIntoHeap(e, dirtyQueue);
|
|
1964
1358
|
schedule();
|
|
1965
1359
|
}
|
|
1966
1360
|
}
|
|
1967
1361
|
|
|
1968
|
-
export {
|
|
1362
|
+
export { clearSnapshots, computed, context, createEffectNode, effectStatusNotify, ext, isEqual, markLateLinker, markRefresh, markSnapshotScope, markUnflushedStaged, notePromotedWrite, prepareComputed, pullComputed, read, readerSeesCommitted, recompute, releaseSnapshotScope, resyncUnflushedCompanions, runWithOwner, serve, setEffectStatusNotify, setMemo, setSignal, setSnapshotCapture, setVerdict, signal, slotSignal, snapshotCaptureActive, snapshotSources, spectating, stagedRead, stagedScreen, staleValues, stashFlushed, statusNotifierOf, tracking, unflushedStaged, unflushedValue, untrack, verdict };
|