@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/boundaries.js
CHANGED
|
@@ -1,567 +1,489 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { STATUS_PENDING, STATUS_ERROR, CONFIG_REDERIVE, REACTIVE_DISPOSED, STATUS_UNINITIALIZED, CONFIG_HELD, REACTIVE_ZOMBIE, CONFIG_VERDICT, REACTIVE_LANE_READ, CONFIG_OVERRIDE, EFFECT_USER, EFFECT_TRACKED } from "./core/constants.js";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { createOwner, cleanup } from "./core/owner.js";
|
|
6
|
-
|
|
7
|
-
import { Queue, transitions, reporterBlocksSource, wakeParked, schedule, queueRearm, haltReactivity } from "./core/scheduler.js";
|
|
3
|
+
import { signal, runWithOwner, computed, read, setSignal, recompute } from "./core/core.js";
|
|
8
4
|
|
|
9
|
-
import {
|
|
5
|
+
import { NotReadyError, unwrapStatusError } from "./core/error.js";
|
|
10
6
|
|
|
11
|
-
import {
|
|
7
|
+
import { reportClientError } from "./core/error-hooks.js";
|
|
12
8
|
|
|
13
|
-
import "./core/
|
|
9
|
+
import { link } from "./core/graph.js";
|
|
14
10
|
|
|
15
11
|
import { enqueueSub } from "./core/heap.js";
|
|
16
12
|
|
|
17
|
-
import "./core/
|
|
13
|
+
import { createOwner, getOwner, cleanup } from "./core/owner.js";
|
|
18
14
|
|
|
19
|
-
import "./core/
|
|
15
|
+
import { globalQueue, haltReactivity, passLane, joinFuture, GlobalQueue, flushTransaction, schedule, setPassLane, txOf } from "./core/scheduler.js";
|
|
20
16
|
|
|
21
|
-
import {
|
|
17
|
+
import { flatten } from "./flatten.js";
|
|
22
18
|
|
|
23
19
|
import { accessor } from "./signals.js";
|
|
24
20
|
|
|
25
|
-
function boundaryComputed(e, t) {
|
|
26
|
-
const r = computed(e, {
|
|
27
|
-
lazy: true
|
|
28
|
-
});
|
|
29
|
-
ext(r).S = (e, t) => {
|
|
30
|
-
// Use passed values if provided, otherwise read from node
|
|
31
|
-
const n = e !== undefined ? e : r.h;
|
|
32
|
-
const i = t !== undefined ? t : r.o?._;
|
|
33
|
-
// Notify both status dimensions like a render effect does; the queue chain
|
|
34
|
-
// consumes this boundary's own type and forwards the remainder upward until
|
|
35
|
-
// a boundary that handles it is found.
|
|
36
|
-
r.h &= ~r.R;
|
|
37
|
-
const s = r.T.notify(r, STATUS_PENDING | STATUS_ERROR, n, i);
|
|
38
|
-
// The queue is the only propagation channel: a foreign status must not stay
|
|
39
|
-
// reader-visible on the tree, or reads re-throw it across the boundary and
|
|
40
|
-
// link unrelated ambient contexts (the #2809 nested-boundary loop). Deps are
|
|
41
|
-
// untouched, so the tree still recomputes when the foreign source settles.
|
|
42
|
-
const o = n & ~r.R & (STATUS_PENDING | STATUS_ERROR);
|
|
43
|
-
if (o) {
|
|
44
|
-
r.h &= ~o;
|
|
45
|
-
if (r.o?._ === i && !(r.h & (STATUS_PENDING | STATUS_ERROR))) if (r.o !== null) r.o._ = undefined;
|
|
46
|
-
}
|
|
47
|
-
// An ERROR the chain could not deliver to any boundary is uncaught. The
|
|
48
|
-
// scrub above already removed it from reader-visible state, so without
|
|
49
|
-
// escalation here it would vanish entirely (#2884) — halt-and-throw,
|
|
50
|
-
// exactly like an unhandled effect error.
|
|
51
|
-
if (!s && n & STATUS_ERROR) {
|
|
52
|
-
haltReactivity(unwrapStatusError(i));
|
|
53
|
-
throw i;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
r.R = t;
|
|
57
|
-
r.C &= ~CONFIG_AUTO_DISPOSE;
|
|
58
|
-
recompute(r, true);
|
|
59
|
-
return r;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
21
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* pending, or landed; an optimistic write notifies like any other) and
|
|
67
|
-
* queues the boundary for re-arming once this pass's heap has run
|
|
68
|
-
* (scheduler.ts `pendingRearms`: the re-arm needs what the notifying write
|
|
69
|
-
* put in flight, which this pass — at the height of its reads — runs ahead
|
|
70
|
-
* of). The value is never compared: a thunk that returns a fresh object per
|
|
71
|
-
* run but reads nothing reactive never re-arms, and one that returns the
|
|
72
|
-
* same constant re-arms whenever a read source changes. A zero-argument
|
|
73
|
-
* function is an accessor, tracked like any other.
|
|
22
|
+
* Boundaries — the display consumers between a frame reader and the root:
|
|
23
|
+
* `createLoadingBoundary` (`<Loading>`) and `createErrorBoundary`
|
|
24
|
+
* (`<Errored>`).
|
|
74
25
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
26
|
+
* A boundary is an owner whose context names it (`BOUNDARY`), so every node
|
|
27
|
+
* created under it finds it in O(1) and the enclosing boundaries through
|
|
28
|
+
* `_parent`; a `tree` (the content, flattened) and an `output` that shows
|
|
29
|
+
* the tree or the fallback. The output is a frame reader (CONFIG_REDERIVE):
|
|
30
|
+
* status reaching it from its content re-derives it instead of marking it,
|
|
31
|
+
* and its pass decides.
|
|
81
32
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (r & STATUS_PENDING) {
|
|
113
|
-
i.h &= ~STATUS_PENDING;
|
|
114
|
-
if (i.o?._ instanceof NotReadyError) i.o._ = undefined;
|
|
115
|
-
enqueueSub(i);
|
|
116
|
-
schedule();
|
|
117
|
-
}
|
|
118
|
-
if (r & STATUS_ERROR) {
|
|
119
|
-
const e = t !== undefined ? t : i.o?._;
|
|
120
|
-
i.h &= ~STATUS_ERROR;
|
|
121
|
-
if (i.o?._ === e && i.o !== null) i.o._ = undefined;
|
|
122
|
-
if (!i.T.notify(i, STATUS_ERROR, r, e)) {
|
|
123
|
-
haltReactivity(unwrapStatusError(e));
|
|
124
|
-
throw e;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
i.C &= ~CONFIG_AUTO_DISPOSE;
|
|
129
|
-
recompute(i, true);
|
|
130
|
-
return i;
|
|
131
|
-
}
|
|
33
|
+
* Status protocol (B5). A frame reader under a boundary that goes pending or
|
|
34
|
+
* errors tells `GlobalQueue.notify`, which asks `catchStatus` before the
|
|
35
|
+
* root: the nearest boundary of that status that is collecting — an error
|
|
36
|
+
* boundary always; a loading boundary that has not shown content yet, or
|
|
37
|
+
* whose `on` just changed — records the reader and shows its fallback, and
|
|
38
|
+
* the root never hears of it (no transaction is opened: A33, a fallback-
|
|
39
|
+
* caught flight holds nothing). A loading boundary showing content forwards:
|
|
40
|
+
* the root holds the frame as for any reader. The tree's own status takes
|
|
41
|
+
* the same route from the output's pass (`read(tree)` throws it).
|
|
42
|
+
*
|
|
43
|
+
* The hold (`blocked`, scheduler.ts) asks `hidden`: a reader behind a
|
|
44
|
+
* fallback — any boundary on its chain whose last pass chose the fallback —
|
|
45
|
+
* is not on screen and holds nothing. An error boundary flipping to its
|
|
46
|
+
* fallback is the same as a loading one resetting: every reader under it
|
|
47
|
+
* stops counting, and a flight whose only visible reader that was loses its
|
|
48
|
+
* hold (maintainer, 2026-10-01).
|
|
49
|
+
*
|
|
50
|
+
* Reveal. The seam (`boundarySeam`) drops readers that settled, died, or
|
|
51
|
+
* landed and committed; a fallback with none left re-derives its output,
|
|
52
|
+
* which reads the tree again. A reader that landed but is held (CONFIG_HELD,
|
|
53
|
+
* its value staged in a transaction) is not settled: the content reveals at
|
|
54
|
+
* the commit, with the rest of the frame (#3540).
|
|
55
|
+
*
|
|
56
|
+
* `on` (loading only): a tracked function whose reads re-arm the boundary.
|
|
57
|
+
* A pass of it after the mount arms the boundary for the flush: anything
|
|
58
|
+
* pending under it — already (its forwarded readers), or going pending later
|
|
59
|
+
* in the same heap — is collected and the fallback shows now, with the
|
|
60
|
+
* change's frame; nothing pending, and the arm is a no-op at the seam.
|
|
61
|
+
*/
|
|
62
|
+
/** Context key: the nearest boundary of a node, inherited at creation. */ const BOUNDARY = Symbol("");
|
|
132
63
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
cleanup(() => i.removeChild(e.T));
|
|
137
|
-
// Named for the observe tier's owner paths: user content under a boundary
|
|
138
|
-
// is owned by `children`, and the boundary's own two nodes read as
|
|
139
|
-
// structure rather than as anonymous `computed`s between `<Loading>` and
|
|
140
|
-
// the content (`<App> › <Loading> › children › <Feed>`).
|
|
141
|
-
return runWithOwner(e, () => {
|
|
142
|
-
// The call, not the argument, is gated: `computed(fn, void 0)` would keep
|
|
143
|
-
// a trailing argument in the prod artifact.
|
|
144
|
-
const e = false ? computed(t, {
|
|
145
|
-
name: "children"
|
|
146
|
-
}) : computed(t);
|
|
147
|
-
return boundaryComputed(() => flatten(read(e)), n);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
64
|
+
/** Context key: the reveal controller a Loading boundary created here is a
|
|
65
|
+
* slot of (reveal.ts); a boundary clears it for its content — only direct
|
|
66
|
+
* children are slots. */ const REVEAL = Symbol("");
|
|
150
67
|
|
|
151
|
-
|
|
68
|
+
let revealHooks = null;
|
|
152
69
|
|
|
153
|
-
|
|
70
|
+
function setRevealHooks(e) {
|
|
71
|
+
revealHooks = e;
|
|
72
|
+
}
|
|
154
73
|
|
|
155
|
-
|
|
74
|
+
/** Boundaries with readers to sweep (or an arm to resolve) at the seam. */ const collecting = new Set;
|
|
156
75
|
|
|
157
|
-
const
|
|
76
|
+
const boundaryOf = e => e.U[BOUNDARY];
|
|
158
77
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
78
|
+
/** Catches what reaches it: an error boundary always; a loading one until it
|
|
79
|
+
* has shown content, or while re-armed. */ const isCollecting = e => e.i === STATUS_ERROR || !e.L || e.k;
|
|
162
80
|
|
|
163
|
-
|
|
164
|
-
|
|
81
|
+
/** The reader goes to the fallback: recorded, and the output re-derives
|
|
82
|
+
* (a no-op while the output's own pass is running — its post-check
|
|
83
|
+
* decides). */ function caught(e, n, r) {
|
|
84
|
+
if (e.i === STATUS_ERROR) {
|
|
85
|
+
// An error boundary waits on what THREW (`StatusError.source`), not on
|
|
86
|
+
// the reader that saw it: the reader recovers the moment a refetch
|
|
87
|
+
// starts (its boundary catches the pending), while the error is settled
|
|
88
|
+
// only when its source is neither errored nor in flight. `reset` re-runs
|
|
89
|
+
// the same node.
|
|
90
|
+
r ??= n.m?.V;
|
|
91
|
+
n = r?.source ?? n;
|
|
92
|
+
const t = unwrapStatusError(r);
|
|
93
|
+
setSignal(e.V, t);
|
|
94
|
+
reportClientError(t, e.v, n);
|
|
95
|
+
}
|
|
96
|
+
e.H.add(n);
|
|
97
|
+
collecting.add(e);
|
|
98
|
+
if (e.k) flip(e);
|
|
99
|
+
// Already showing the fallback: one more reader to wait on changes
|
|
100
|
+
// nothing on screen. The fallback is instantiated once per show — a later
|
|
101
|
+
// error reaches it through the `error` accessor, which is why it is one.
|
|
102
|
+
if (!e.P) redraw(e);
|
|
103
|
+
if (e.B !== null) revealHooks.j(e.B);
|
|
165
104
|
}
|
|
166
105
|
|
|
167
|
-
|
|
168
|
-
|
|
106
|
+
/** A re-armed boundary found something pending: fresh again, and the swap
|
|
107
|
+
* the arming pass asked for is that pass's lane's (if any): the output is
|
|
108
|
+
* the lane's work from its next pass's head — not a re-pass of the
|
|
109
|
+
* transaction holding its pending content, which would entangle that
|
|
110
|
+
* transaction with the arming frame's (#3540 `on: () => latest(dep)`). */ function flip(e) {
|
|
111
|
+
e.L = false;
|
|
112
|
+
e.Z = e.W;
|
|
113
|
+
if (e.Z !== null && e.K !== null) GlobalQueue.M(e.K, e.Z, true, false);
|
|
169
114
|
}
|
|
170
115
|
|
|
171
|
-
function
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (!r && e.j === t) e.j = undefined;
|
|
176
|
-
return e.B(r, n);
|
|
116
|
+
function redraw(e) {
|
|
117
|
+
if (e.K !== null && !(e.K.R & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE))) {
|
|
118
|
+
enqueueSub(e.K);
|
|
119
|
+
schedule();
|
|
177
120
|
}
|
|
178
|
-
if (!r && e.W === t && e.q) e.W = undefined;
|
|
179
121
|
}
|
|
180
122
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
H
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
K=true;
|
|
196
|
-
X=false;
|
|
197
|
-
constructor(e, t) {
|
|
198
|
-
this.V = e;
|
|
199
|
-
this.F = t;
|
|
200
|
-
}
|
|
201
|
-
Y(e) {
|
|
202
|
-
for (let t = 0; t < this.Z.length; t++) {
|
|
203
|
-
const r = this.Z[t];
|
|
204
|
-
if ((isRevealController(r) ? r.j : r.W) !== this) continue;
|
|
205
|
-
if (e(r) === false) return false;
|
|
206
|
-
}
|
|
207
|
-
return true;
|
|
208
|
-
}
|
|
209
|
-
I() {
|
|
210
|
-
return this.Y(isSlotReady);
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* "Minimally ready" = this group has something visible to show under its own policy.
|
|
214
|
-
* Used by an enclosing `together` group to decide when it can release.
|
|
215
|
-
* - `together`: every direct slot is minimally ready.
|
|
216
|
-
* - `sequential`: the first owned slot is minimally ready (frontier can advance).
|
|
217
|
-
* - `natural`: any owned slot is minimally ready.
|
|
218
|
-
*/ D() {
|
|
219
|
-
const e = untrack(this.V);
|
|
220
|
-
if (e === "together") return this.Y(isSlotMinimallyReady);
|
|
221
|
-
if (e === "natural") {
|
|
222
|
-
let e = false;
|
|
223
|
-
let t = false;
|
|
224
|
-
this.Y(r => {
|
|
225
|
-
e = true;
|
|
226
|
-
if (isSlotMinimallyReady(r)) {
|
|
227
|
-
t = true;
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
return !e || t;
|
|
123
|
+
/** GlobalQueue._catch: status from a frame reader, nearest boundary first.
|
|
124
|
+
* A loading boundary on the way records a pending reader whether or not it
|
|
125
|
+
* catches it (its `on` may collect it later). */ function catchStatus(e, n, r) {
|
|
126
|
+
if (n === 0) {
|
|
127
|
+
// A status cleared. Judged by the node's status now, against each
|
|
128
|
+
// boundary's own rule (`unsettled`) — the error path clears pending
|
|
129
|
+
// first and the node is still errored then. The last reader a fallback
|
|
130
|
+
// waited on settling re-derives the output now, in the same heap (a
|
|
131
|
+
// held reader's landing has joined its transaction, so the content
|
|
132
|
+
// lands with its run, not a round after). Others still waiting: nothing
|
|
133
|
+
// on screen changes, the fallback stays as it is.
|
|
134
|
+
if (collecting.size !== 0) for (let n = boundaryOf(e); n !== undefined; n = n._parent ?? undefined) if (!(e.G & unsettled(n)) && n.H.delete(e) && n.H.size === 0) {
|
|
135
|
+
if (n.P) redraw(n);
|
|
136
|
+
if (n.B !== null) revealHooks.j(n.B);
|
|
232
137
|
}
|
|
233
|
-
|
|
234
|
-
let t = true;
|
|
235
|
-
this.Y(e => {
|
|
236
|
-
t = isSlotMinimallyReady(e);
|
|
237
|
-
return false;
|
|
238
|
-
});
|
|
239
|
-
return t;
|
|
240
|
-
}
|
|
241
|
-
$(e) {
|
|
242
|
-
if (this.Z.includes(e)) return;
|
|
243
|
-
this.Z.push(e);
|
|
244
|
-
const t = untrack(this.V);
|
|
245
|
-
setSignal(e.P, true), setSignal(e.L, t === "sequential" ? !!untrack(this.F) : false);
|
|
246
|
-
untrack(() => this.B());
|
|
247
|
-
}
|
|
248
|
-
ee(e) {
|
|
249
|
-
const t = this.Z.indexOf(e);
|
|
250
|
-
if (t >= 0) this.Z.splice(t, 1);
|
|
251
|
-
untrack(() => this.B());
|
|
138
|
+
return false;
|
|
252
139
|
}
|
|
253
|
-
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
try {
|
|
259
|
-
const r = e ?? read(this.P), n = untrack(this.V), i = n === "sequential" && !!untrack(this.F), s = t ?? i;
|
|
260
|
-
if (r) {
|
|
261
|
-
// Held by an outer group. Propagate the hold (and whatever collapsed policy
|
|
262
|
-
// the outer asked for) down the whole subtree. Inner order is ignored while
|
|
263
|
-
// held; it resumes once the outer releases us.
|
|
264
|
-
this.Y(e => setSlotState(e, this, true, s));
|
|
265
|
-
} else if (n === "natural") {
|
|
266
|
-
// Each child reveals based on its own readiness. A nested controller slot
|
|
267
|
-
// is released to run its own order locally — we bypass setSlotState for it
|
|
268
|
-
// so the parent backpointer survives for upward readiness notifications.
|
|
269
|
-
this.Y(e => {
|
|
270
|
-
if (isRevealController(e)) {
|
|
271
|
-
setSignal(e.L, false);
|
|
272
|
-
setSignal(e.P, false);
|
|
273
|
-
e.B(false, false);
|
|
274
|
-
} else {
|
|
275
|
-
setSlotState(e, this, !isSlotReady(e), false);
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
} else if (n === "together") {
|
|
279
|
-
// Release when every direct slot is minimally ready (has something to show
|
|
280
|
-
// under its own order). A fully-ready inner together is minimally ready;
|
|
281
|
-
// sequential's first slot being ready is minimally ready; natural having any
|
|
282
|
-
// ready child is minimally ready. This lets `together` guarantee a single
|
|
283
|
-
// cohesive reveal without waiting for every grandchild.
|
|
284
|
-
const e = this.Y(isSlotMinimallyReady);
|
|
285
|
-
this.Y(t => setSlotState(t, this, !e, false));
|
|
286
|
-
} else {
|
|
287
|
-
let e = false;
|
|
288
|
-
this.Y(t => {
|
|
289
|
-
if (e) return setSlotState(t, this, true, i);
|
|
290
|
-
if (isSlotReady(t)) return setSlotState(t, this, false, false);
|
|
291
|
-
e = true;
|
|
292
|
-
// Frontier slot. For a leaf, holding `_disabled=true` is what keeps its
|
|
293
|
-
// fallback visible. For a composite, we instead release it so it runs
|
|
294
|
-
// its own order locally — its leaves will each show their own fallback
|
|
295
|
-
// until their data lands. Outer still waits on full readiness before
|
|
296
|
-
// advancing past this slot, and we bypass setSlotState so the parent
|
|
297
|
-
// backpointer survives for upward readiness notifications.
|
|
298
|
-
if (isRevealController(t)) {
|
|
299
|
-
setSignal(t.L, false);
|
|
300
|
-
setSignal(t.P, false);
|
|
301
|
-
t.B(false, false);
|
|
302
|
-
} else {
|
|
303
|
-
setSlotState(t, this, true, false);
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
} finally {
|
|
308
|
-
this.J = this.I();
|
|
309
|
-
this.K = this.D();
|
|
310
|
-
this.X = false;
|
|
140
|
+
for (let t = boundaryOf(e); t !== undefined; t = t._parent ?? undefined) {
|
|
141
|
+
if (!(t.i & n)) continue;
|
|
142
|
+
if (isCollecting(t)) {
|
|
143
|
+
caught(t, e, r);
|
|
144
|
+
return true;
|
|
311
145
|
}
|
|
312
|
-
|
|
146
|
+
t.H.add(e);
|
|
147
|
+
collecting.add(t);
|
|
313
148
|
}
|
|
149
|
+
return false;
|
|
314
150
|
}
|
|
315
151
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
152
|
+
/** The nearest boundary on `r`'s chain showing its fallback, if any. */ function hiddenBy(e) {
|
|
153
|
+
for (let n = boundaryOf(e); n !== undefined; n = n._parent ?? undefined) if (n.P) return n;
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** GlobalQueue._hidden: behind a fallback. */ function hidden(e) {
|
|
158
|
+
return hiddenBy(e) !== undefined;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** GlobalQueue._heldRun: a queued run behind a fallback waits for the reveal
|
|
162
|
+
* (maintainer, 2026-10-02: the queue is held, the synchronous first render
|
|
163
|
+
* goes through). A user effect's, which would read a DOM that is not
|
|
164
|
+
* attached ("many depend on reading the DOM, something that can't happen
|
|
165
|
+
* off screen"); a render effect's update too — a Portal or a head-tag
|
|
166
|
+
* library writes outside the hidden subtree, and a queued render run is
|
|
167
|
+
* what mounts them. A user effect's first run is scheduled like every other,
|
|
168
|
+
* so a mount under a fallback defers it too; a render effect's first run is
|
|
169
|
+
* synchronous on creation and never comes here. The run's `_modified` stays
|
|
170
|
+
* set; the reveal re-queues it by type (`release`), and a boundary above
|
|
171
|
+
* still showing its fallback holds it again then. */ function heldRun(e) {
|
|
172
|
+
const n = hiddenBy(e);
|
|
173
|
+
if (n === undefined) return false;
|
|
174
|
+
(n.Y ??= new Set).add(e);
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** The reveal: the runs held behind the fallback are this flush's, each in
|
|
179
|
+
* its own phase — render updates with the frame that attaches the content,
|
|
180
|
+
* user effects after it. */ function release(e) {
|
|
181
|
+
if (e.Y === null) return;
|
|
182
|
+
for (const n of e.Y) {
|
|
183
|
+
const e = n.i;
|
|
184
|
+
globalQueue.enqueue(e === EFFECT_TRACKED ? EFFECT_USER : e, e === EFFECT_TRACKED ? n.q : n.J ??= GlobalQueue.X.bind(null, n));
|
|
346
185
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
if (
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
// counting without being pruned yet (its flight landed this pass):
|
|
369
|
-
// `reporterBlocksSource` is the verdict's own test.
|
|
370
|
-
const t = new Set;
|
|
371
|
-
for (const e of transitions) for (const [r, n] of e.le) {
|
|
372
|
-
for (const e of n) if (this.ae(e) && reporterBlocksSource(e, r)) {
|
|
373
|
-
t.add(r);
|
|
374
|
-
e.o?.ue?.forEach(e => t.add(e));
|
|
186
|
+
e.Y = null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Drop the readers that settled or died. Settled: a loading reader no
|
|
190
|
+
* longer pending; an error's source neither errored nor in flight. A reader
|
|
191
|
+
* that landed but is held (its value staged in a transaction) is not: the
|
|
192
|
+
* content reveals at the commit, with its run. The tree is: the output reads
|
|
193
|
+
* it and enters the transaction itself (its committed value shows until the
|
|
194
|
+
* landing). */ const unsettled = e => e.i === STATUS_ERROR ? STATUS_ERROR | STATUS_PENDING : STATUS_PENDING;
|
|
195
|
+
|
|
196
|
+
function prune(e, n) {
|
|
197
|
+
const r = unsettled(e);
|
|
198
|
+
for (const t of e.H) {
|
|
199
|
+
if (t.R & REACTIVE_DISPOSED) e.H.delete(t); else if (!(t.G & r)) {
|
|
200
|
+
if (t !== e.$ && (t.u & (CONFIG_HELD | CONFIG_OVERRIDE)) === CONFIG_HELD) {
|
|
201
|
+
// Landed, held: the content is that transaction's — the output's
|
|
202
|
+
// pass enters it and the reveal lands with the reader's run. The
|
|
203
|
+
// seam, past its park decision, waits for the commit instead. (A
|
|
204
|
+
// lane's reader reveals with the lane, this round.)
|
|
205
|
+
if (!n) continue;
|
|
206
|
+
joinFuture(txOf(t));
|
|
375
207
|
}
|
|
376
|
-
|
|
377
|
-
if (!t.size) return;
|
|
378
|
-
this.q = false;
|
|
379
|
-
this.U = t;
|
|
380
|
-
this.v = true;
|
|
381
|
-
this.fe(e);
|
|
382
|
-
// Those readers are behind the fallback now: they stop blocking
|
|
383
|
-
// (`reporterBlocksSource`), and the transactions they were holding must
|
|
384
|
-
// be re-judged for it (A33, #3375) — the active one by the verdict that
|
|
385
|
-
// follows this drain, parked ones by the wake. A live action keeps its
|
|
386
|
-
// transaction parked regardless (transitionComplete): its batch commits
|
|
387
|
-
// when it settles, intact.
|
|
388
|
-
wakeParked();
|
|
389
|
-
}
|
|
390
|
-
/** Show the fallback: the swap the output pass selects on. Staged, it is
|
|
391
|
-
* the frame's and lands with its commit. Re-armed from a lane pass
|
|
392
|
-
* (`lane`), it is the current frame's — committed outright, as the lane's
|
|
393
|
-
* view already is on screen — and shown through the lane: the output pass
|
|
394
|
-
* publishes a derived override and its readers run from the lane's queue,
|
|
395
|
-
* at the park, ahead of the transaction (a lane pass reads staged plain
|
|
396
|
-
* writes committed, so a staged swap would be invisible to it). */ fe(e) {
|
|
397
|
-
if (e === null) setSignal(this.P, true); else {
|
|
398
|
-
this.P.ce = true;
|
|
399
|
-
notifyOnLane(this.P, e);
|
|
208
|
+
e.H.delete(t);
|
|
400
209
|
}
|
|
401
210
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
211
|
+
return e.H.size;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** Reveal order: a slot is ready when its content can show — it has shown
|
|
215
|
+
* content, or nothing under it is unready (the tree neither pending nor
|
|
216
|
+
* born held, no reader waited on). */ function ready(e) {
|
|
217
|
+
return e.L || !(e.$.G & STATUS_PENDING) && !(e.$.u & CONFIG_HELD && (e.K === null || e.K.G & STATUS_UNINITIALIZED)) && prune(e, false) === 0;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** GlobalQueue._boundarySeam, end of the seam: readers that settled, died,
|
|
221
|
+
* or landed and committed are dropped; a fallback with none left reveals
|
|
222
|
+
* next round. An arm resolves: nothing collected, nothing happened. */ function boundarySeam() {
|
|
223
|
+
for (const e of collecting) {
|
|
224
|
+
const n = e.K.R;
|
|
225
|
+
if (n & REACTIVE_DISPOSED) {
|
|
226
|
+
collecting.delete(e);
|
|
227
|
+
continue;
|
|
409
228
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
// reaches the `Errored` that catches it natively, and `flags & collectionType`
|
|
419
|
-
// keeps this boundary from collecting a node that isn't actually pending.
|
|
420
|
-
// Symmetrically, a pending inside an `Errored` forwards on the PENDING
|
|
421
|
-
// dimension, while a status already caught by an inner boundary arrives with
|
|
422
|
-
// its dimension consumed from the mask and is correctly not re-routed
|
|
423
|
-
// (the Loading > Errored > content composition escape, #2856).
|
|
424
|
-
if (this.te & STATUS_PENDING && this.q) return super.notify(e, t, r, n);
|
|
425
|
-
if (r & this.te) {
|
|
426
|
-
this.v = true;
|
|
427
|
-
const t = n?.source || e.o?._?.source;
|
|
428
|
-
if (t) {
|
|
429
|
-
const r = this.U.size === 0;
|
|
430
|
-
this.U.add(t);
|
|
431
|
-
// A collecting boundary waits on everything the effect is pending on,
|
|
432
|
-
// not only the source this notification carries. Status propagation
|
|
433
|
-
// dedupes on the effect's `_pendingSources`: a source it already
|
|
434
|
-
// carries (a flight that started before an `on` reset cleared the
|
|
435
|
-
// set) is never re-reported, and that source's later re-flight
|
|
436
|
-
// stays invisible — the boundary revealed when its one collected
|
|
437
|
-
// source settled while the effect was still pending (#3375).
|
|
438
|
-
if (this.te & STATUS_PENDING) e.o?.ue?.forEach(e => this.U.add(e));
|
|
439
|
-
if (r) {
|
|
440
|
-
setSignal(this.P, true);
|
|
441
|
-
}
|
|
442
|
-
if (this.te & STATUS_ERROR) {
|
|
443
|
-
const e = unwrapStatusError(t.o?._);
|
|
444
|
-
setSignal(this._, e);
|
|
445
|
-
// The client error hook: this boundary renders its fallback for
|
|
446
|
-
// it — the one road a rendered failure took that no global handler
|
|
447
|
-
// ever saw. `source` is the computation that threw (the status
|
|
448
|
-
// wrapper's, made at the first landing and kept downstream), so the
|
|
449
|
-
// hook hears where it broke as well as where it was met. Once per
|
|
450
|
-
// error object; a `reset()` re-collecting the same failure says
|
|
451
|
-
// nothing new.
|
|
452
|
-
reportClientError(e, this.ie, t);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
229
|
+
// A parked frame's boundary (zombie) keeps its state for its revival.
|
|
230
|
+
if (n & REACTIVE_ZOMBIE) continue;
|
|
231
|
+
prune(e, false);
|
|
232
|
+
e.k = false;
|
|
233
|
+
if (e.H.size === 0) {
|
|
234
|
+
collecting.delete(e);
|
|
235
|
+
if (e.P) redraw(e);
|
|
236
|
+
if (e.B !== null) revealHooks.j(e.B);
|
|
455
237
|
}
|
|
456
|
-
t &= ~this.te;
|
|
457
|
-
return t ? super.notify(e, t, r, n) : true;
|
|
458
238
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** The `on` pass is a verdict's: it probed itself (CONFIG_VERDICT), or it
|
|
242
|
+
* read a memo that did (#3528's `createMemo(() => isPending(m2))`) — its
|
|
243
|
+
* swap is display-ahead either way. */ function verdictDerived(e) {
|
|
244
|
+
if (e.u & CONFIG_VERDICT) return true;
|
|
245
|
+
for (let n = e._; n !== null; n = n.p) if (n.I.u & CONFIG_VERDICT) return true;
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** `on` changed after the mount: fresh again if anything under it is
|
|
250
|
+
* pending now; collecting for the rest of the flush either way. */ function arm(e) {
|
|
251
|
+
if (!e.L) {
|
|
252
|
+
// Already re-armed and on its fallback, as the frame's work — and the
|
|
253
|
+
// `on` pass arms again as lane work: its verdict was provisional (a
|
|
254
|
+
// memo of `isPending(m2)` is a watcher until the flush parks, then the
|
|
255
|
+
// holder's verdict lane's — verdict.ts), and the swap it asked for is
|
|
256
|
+
// display-ahead after all (#3528). Re-home the swap: the output re-runs
|
|
257
|
+
// as the lane's, shown now beside the held frame.
|
|
258
|
+
if (e.P && e.Z === null && e.W === null && passLane !== null) {
|
|
259
|
+
e.W = passLane;
|
|
260
|
+
// The swap the frame's pass staged (held with the frame) is void: the
|
|
261
|
+
// lane's pass stages it anew (`flip` lists the output in the lane,
|
|
262
|
+
// which voids its staging), as a watcher's provisional value is
|
|
263
|
+
// voided at the seam (verdict.ts `verdictSeam`).
|
|
264
|
+
flip(e);
|
|
265
|
+
redraw(e);
|
|
465
266
|
}
|
|
466
|
-
return
|
|
267
|
+
return;
|
|
467
268
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
269
|
+
e.k = true;
|
|
270
|
+
// A verdict read in `on` (`isPending`) whose frame has no transaction
|
|
271
|
+
// yet: the swap is still display-ahead — the frame gets one now (it lands
|
|
272
|
+
// at this very seam if nothing holds it), and the swap is its verdict
|
|
273
|
+
// lane's work, shown ahead of the frame's own runs (#3528).
|
|
274
|
+
let n = passLane;
|
|
275
|
+
if (n === null && globalQueue.ee && verdictDerived(getOwner())) {
|
|
276
|
+
joinFuture(null);
|
|
277
|
+
n = GlobalQueue.ne(flushTransaction);
|
|
477
278
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
* boundary stages `_disabled` false with the frame and the output re-runs
|
|
486
|
-
* in this heap: it reads the tree and drops the fallback's read (recompute
|
|
487
|
-
* settles a pass's outgoing pending sources), so the verdict sees the
|
|
488
|
-
* release. A boundary showing a ready fallback parks nothing and keeps the
|
|
489
|
-
* commit sweep's reveal. */ Re() {
|
|
490
|
-
if (this.q || !(this.ne.h & STATUS_PENDING)) return;
|
|
491
|
-
this.Ee();
|
|
492
|
-
}
|
|
493
|
-
Ee() {
|
|
494
|
-
for (const e of this.U) if (this.de(e)) this.U.delete(e);
|
|
495
|
-
if (!this.U.size) {
|
|
496
|
-
if (this.te & STATUS_PENDING && this.v && !this.q && this.re) {
|
|
497
|
-
this.v = !!(this.re.h & this.te);
|
|
498
|
-
} else {
|
|
499
|
-
this.v = false;
|
|
500
|
-
}
|
|
501
|
-
if (!this.v) {
|
|
502
|
-
setSignal(this.P, false);
|
|
503
|
-
}
|
|
279
|
+
e.W = n;
|
|
280
|
+
collecting.add(e);
|
|
281
|
+
for (const n of e.H) {
|
|
282
|
+
if (n.G & STATUS_PENDING && !(n.R & REACTIVE_DISPOSED)) {
|
|
283
|
+
flip(e);
|
|
284
|
+
redraw(e);
|
|
285
|
+
return;
|
|
504
286
|
}
|
|
505
|
-
if (_revealUsed) this.W?.B();
|
|
506
287
|
}
|
|
507
288
|
}
|
|
508
289
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
290
|
+
/** The error boundary's `reset`: re-run what threw (a comparator throw
|
|
291
|
+
* names a signal — nothing to re-run). */ function reset(e) {
|
|
292
|
+
// A snapshot: a source failing again is caught — and re-added — mid-walk.
|
|
293
|
+
for (const n of [ ...e.H ]) if (n.re !== undefined && !(n.R & REACTIVE_DISPOSED)) recompute(n);
|
|
294
|
+
schedule();
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function createBoundary(e, n, r, t) {
|
|
298
|
+
const l = createOwner();
|
|
299
|
+
const o = {
|
|
300
|
+
i: e,
|
|
301
|
+
_parent: boundaryOf(l) ?? null,
|
|
302
|
+
v: l,
|
|
303
|
+
$: null,
|
|
304
|
+
K: null,
|
|
305
|
+
H: new Set,
|
|
306
|
+
L: false,
|
|
307
|
+
k: false,
|
|
308
|
+
W: null,
|
|
309
|
+
Z: null,
|
|
310
|
+
P: false,
|
|
311
|
+
Y: null,
|
|
312
|
+
B: null,
|
|
313
|
+
te: false,
|
|
314
|
+
le: false,
|
|
315
|
+
V: e === STATUS_ERROR ? signal(undefined, ERROR_SIGNAL) : null,
|
|
316
|
+
oe: r
|
|
317
|
+
};
|
|
318
|
+
const u = e === STATUS_PENDING ? l.U[REVEAL] : null;
|
|
319
|
+
if (getOwner()) cleanup(() => {
|
|
320
|
+
collecting.delete(o);
|
|
321
|
+
if (u) revealHooks.ue(u, o);
|
|
517
322
|
});
|
|
518
323
|
// The `on` dependencies live OUTSIDE the boundary, as the condition of a
|
|
519
|
-
// `<Show>` wrapping it would: created before the owner's
|
|
520
|
-
//
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
324
|
+
// `<Show>` wrapping it would: created before the owner's context names it.
|
|
325
|
+
// A source of it going pending re-runs it (CONFIG_REDERIVE) rather than
|
|
326
|
+
// marking it: the pass catches the NotReady — it is a notification, it
|
|
327
|
+
// does not suspend the parent — and re-arms.
|
|
328
|
+
if (t) {
|
|
329
|
+
let e = false;
|
|
330
|
+
runWithOwner(l, () => computed(() => {
|
|
331
|
+
try {
|
|
332
|
+
t();
|
|
333
|
+
} catch (e) {
|
|
334
|
+
if (!(e instanceof NotReadyError)) {
|
|
335
|
+
if (!globalQueue.notify(getOwner(), STATUS_ERROR, STATUS_ERROR, e)) {
|
|
336
|
+
haltReactivity(e);
|
|
337
|
+
throw e;
|
|
338
|
+
}
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (e) arm(o); else e = true;
|
|
343
|
+
})).u |= CONFIG_REDERIVE;
|
|
344
|
+
}
|
|
345
|
+
const a = {
|
|
346
|
+
...l.U,
|
|
347
|
+
[BOUNDARY]: o
|
|
348
|
+
};
|
|
349
|
+
if (revealHooks !== null) a[REVEAL] = null;
|
|
350
|
+
l.U = a;
|
|
351
|
+
const i = runWithOwner(l, () => {
|
|
352
|
+
const e = false ? computed(n, {
|
|
353
|
+
name: "children"
|
|
354
|
+
}) : computed(n);
|
|
355
|
+
return false ? computed(() => flatten(read(e)), {
|
|
356
|
+
name: "boundary"
|
|
357
|
+
}) : computed(() => flatten(read(e)));
|
|
358
|
+
});
|
|
359
|
+
o.$ = i;
|
|
360
|
+
// A slot of the reveal order in its context (reveal.ts): gated until the
|
|
361
|
+
// controller releases it — before the output's first pass.
|
|
362
|
+
if (u) revealHooks.ae(u, o);
|
|
363
|
+
const f = computed(() => {
|
|
364
|
+
// Reveal order (reveal.ts): a gated slot shows its fallback — or, in a
|
|
365
|
+
// collapsed tail, nothing — whatever its content's state; the
|
|
366
|
+
// controller is told the pass ran (its readiness may have changed) and
|
|
367
|
+
// releases it in turn.
|
|
368
|
+
if (o.te) {
|
|
369
|
+
// Linked without being read: the tree settling (or changing)
|
|
370
|
+
// re-derives this pass, which is how the controller hears of it.
|
|
371
|
+
// It may release this very slot (the frontier whose content just
|
|
372
|
+
// settled): the pass goes on to show it — the redraw it asks for is
|
|
373
|
+
// refused mid-pass and not needed.
|
|
374
|
+
link(i, getOwner());
|
|
375
|
+
if (o.B !== null) revealHooks.j(o.B);
|
|
376
|
+
if (o.te) {
|
|
377
|
+
if (o.le) {
|
|
378
|
+
o.P = true;
|
|
379
|
+
return undefined;
|
|
380
|
+
}
|
|
381
|
+
return fallback(o);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
// A tree carrying a status is not read: an errored memo's reactive
|
|
385
|
+
// re-read retries it (`read`), and neither a fallback re-rendering nor
|
|
386
|
+
// passing the error by may re-run the content; a pending one read as
|
|
387
|
+
// lane work would serve its committed value (A31) — the swap a
|
|
388
|
+
// display-ahead `on` causes is the lane's, and must still be the
|
|
389
|
+
// fallback. Linked, so its recovery re-derives this pass; read again
|
|
390
|
+
// once clean.
|
|
391
|
+
const n = i.G & (STATUS_PENDING | STATUS_ERROR);
|
|
392
|
+
if (n !== 0) {
|
|
393
|
+
link(i, getOwner());
|
|
394
|
+
if (n & e) {
|
|
395
|
+
if (isCollecting(o)) {
|
|
396
|
+
caught(o, i, undefined);
|
|
397
|
+
return fallback(o);
|
|
398
|
+
}
|
|
399
|
+
// Forwarded: a loading boundary showing content keeps it and
|
|
400
|
+
// holds the frame like any reader (recorded for its `on`).
|
|
401
|
+
o.H.add(i);
|
|
402
|
+
collecting.add(o);
|
|
403
|
+
}
|
|
404
|
+
// A pending passes an error boundary by (A6); an error, a loading
|
|
405
|
+
// one; a loading boundary showing content forwards its pending.
|
|
406
|
+
throw i.m.V;
|
|
407
|
+
}
|
|
408
|
+
if (isCollecting(o)) {
|
|
409
|
+
// A29's boundary exemption (#3540): a boundary MOUNTED over a held
|
|
410
|
+
// value (its first pass; a first pass under it that read a hold was
|
|
411
|
+
// collected, `joinPass` — the tree's own, or a render effect's that
|
|
412
|
+
// binds the content) shows its fallback now and the content at the
|
|
413
|
+
// commit — entering the transaction would make the output itself
|
|
414
|
+
// born held, and nothing would show until the commit. The seam
|
|
415
|
+
// keeps a held reader until it is committed, then re-derives this
|
|
416
|
+
// pass. A boundary with a committed value reads a held tree and
|
|
417
|
+
// enters: the outside sees its committed value until the landing,
|
|
418
|
+
// which reveals the content — a fallback staged earlier is replaced
|
|
419
|
+
// ahead of the commit and never shown.
|
|
420
|
+
const e = getOwner();
|
|
421
|
+
if (o.H.size !== 0 && e.G & STATUS_UNINITIALIZED && !(e.u & CONFIG_HELD)) return fallback(o);
|
|
422
|
+
// Readers under it still unready: the fallback, the tree untouched.
|
|
423
|
+
// The seam re-derives this pass when they settle.
|
|
424
|
+
if (prune(o, true) !== 0) return fallback(o);
|
|
425
|
+
}
|
|
426
|
+
let r;
|
|
529
427
|
try {
|
|
530
|
-
read(
|
|
531
|
-
} catch (
|
|
532
|
-
if (
|
|
428
|
+
r = read(i);
|
|
429
|
+
} catch (n) {
|
|
430
|
+
if (n instanceof NotReadyError ? e === STATUS_PENDING : e === STATUS_ERROR) {
|
|
431
|
+
if (isCollecting(o)) {
|
|
432
|
+
caught(o, i, n);
|
|
433
|
+
return fallback(o);
|
|
434
|
+
}
|
|
435
|
+
// Forwarded: a loading boundary showing content keeps it and
|
|
436
|
+
// holds the frame like any reader (recorded for its `on`).
|
|
437
|
+
o.H.add(i);
|
|
438
|
+
collecting.add(o);
|
|
439
|
+
}
|
|
440
|
+
// A pending passes an error boundary by (A6).
|
|
441
|
+
throw n;
|
|
533
442
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
if (!read(s.P)) {
|
|
547
|
-
const e = read(o);
|
|
548
|
-
if (!untrack(() => read(s.P))) return s.q = true, e;
|
|
443
|
+
// Readers under it still unready (caught before, or while the read
|
|
444
|
+
// ran the content at a mount): the fallback.
|
|
445
|
+
if (isCollecting(o) && o.H.size !== 0) return fallback(o);
|
|
446
|
+
o.L = true;
|
|
447
|
+
o.P = false;
|
|
448
|
+
release(o);
|
|
449
|
+
// Shown: the slot leaves its reveal order (a later re-arm gates nobody
|
|
450
|
+
// else; the frontier moves on).
|
|
451
|
+
if (o.B !== null) {
|
|
452
|
+
const e = o.B;
|
|
453
|
+
o.B = null;
|
|
454
|
+
revealHooks.j(e);
|
|
549
455
|
}
|
|
550
|
-
|
|
551
|
-
// renderer treats the hole as empty, so the cast never leaks to users
|
|
552
|
-
// outside a `createRevealOrder` scope.
|
|
553
|
-
if (_revealUsed && read(s.L)) return undefined;
|
|
554
|
-
return r(s);
|
|
456
|
+
return r;
|
|
555
457
|
},
|
|
556
|
-
// Boundary structure, not a user source: its value is fallback-or-content
|
|
557
|
-
// legitimately swaps mid-hydration (
|
|
558
|
-
// by snapshot capture.
|
|
559
|
-
// capture can't rely on PENDING to skip this node the way it used to.
|
|
458
|
+
// Boundary structure, not a user source: its value is fallback-or-content
|
|
459
|
+
// and legitimately swaps mid-hydration (resume), so it must never be
|
|
460
|
+
// frozen by snapshot capture.
|
|
560
461
|
{
|
|
561
|
-
|
|
562
|
-
})
|
|
462
|
+
ie: true
|
|
463
|
+
});
|
|
464
|
+
f.u |= CONFIG_REDERIVE;
|
|
465
|
+
o.K = f;
|
|
466
|
+
return accessor(f);
|
|
563
467
|
}
|
|
564
468
|
|
|
469
|
+
function fallback(e) {
|
|
470
|
+
// The swap a display-ahead re-arm asked for: this pass is the lane's — a
|
|
471
|
+
// lane read by construction (REACTIVE_LANE_READ: `recompute`'s tail keeps
|
|
472
|
+
// the pass in the lane).
|
|
473
|
+
if (e.Z !== null) {
|
|
474
|
+
setPassLane(e.Z);
|
|
475
|
+
e.K.R |= REACTIVE_LANE_READ;
|
|
476
|
+
e.Z = null;
|
|
477
|
+
}
|
|
478
|
+
e.P = true;
|
|
479
|
+
return e.oe(e);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
const ERROR_SIGNAL = {
|
|
483
|
+
ownedWrite: true,
|
|
484
|
+
ie: true
|
|
485
|
+
};
|
|
486
|
+
|
|
565
487
|
/**
|
|
566
488
|
* Lower-level primitive that backs the `<Loading>` flow control. Catches
|
|
567
489
|
* pending async reads inside `fn` and renders `fallback` until they settle.
|
|
@@ -603,8 +525,8 @@ function createCollectionBoundary(e, t, r, n) {
|
|
|
603
525
|
* ) as unknown as JSX.Element;
|
|
604
526
|
* }
|
|
605
527
|
* ```
|
|
606
|
-
*/ function createLoadingBoundary(e,
|
|
607
|
-
return
|
|
528
|
+
*/ function createLoadingBoundary(e, n, r) {
|
|
529
|
+
return createBoundary(STATUS_PENDING, e, () => n(), r?.on);
|
|
608
530
|
}
|
|
609
531
|
|
|
610
532
|
/**
|
|
@@ -629,154 +551,20 @@ function createCollectionBoundary(e, t, r, n) {
|
|
|
629
551
|
* ) as unknown as JSX.Element;
|
|
630
552
|
* }
|
|
631
553
|
* ```
|
|
632
|
-
*/ function createErrorBoundary(e,
|
|
633
|
-
return
|
|
554
|
+
*/ function createErrorBoundary(e, n) {
|
|
555
|
+
return createBoundary(STATUS_ERROR, e, e => n(accessor(e.V), () => reset(e)));
|
|
634
556
|
}
|
|
635
557
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
* Accepts reactive accessors:
|
|
640
|
-
* - `order`: `"sequential"` (default) | `"together"` | `"natural"`.
|
|
641
|
-
* - `"sequential"` — classic frontier reveal: siblings reveal in registration order
|
|
642
|
-
* as each resolves; later siblings stay hidden until earlier ones complete.
|
|
643
|
-
* - `"together"` — every direct slot stays on its fallback until the whole group
|
|
644
|
-
* is "minimally ready" (each direct slot has produced its own first visible
|
|
645
|
-
* content under its own order), then the whole group releases at once.
|
|
646
|
-
* - `"natural"` — children reveal independently (as each resolves). At the top
|
|
647
|
-
* level this is a no-op compared to not using `createRevealOrder`; the mode
|
|
648
|
-
* exists for nesting, where the group registers as a single composite slot to
|
|
649
|
-
* any enclosing `createRevealOrder`.
|
|
650
|
-
* - `collapsed`: only meaningful when `order === "sequential"`. When set, tail siblings
|
|
651
|
-
* past the frontier suppress their own fallback output. Ignored under `"together"`
|
|
652
|
-
* and `"natural"` — those orders have no frontier.
|
|
653
|
-
*
|
|
654
|
-
* Nested `createRevealOrder` groups compose: the inner controller registers as a
|
|
655
|
-
* single slot in the outer controller and is held on its fallbacks until the outer
|
|
656
|
-
* releases that slot. Once released, the inner controller runs its own order locally
|
|
657
|
-
* over anything still pending. There is no opt-out from an outer hold.
|
|
658
|
-
*
|
|
659
|
-
* "Minimally ready" is what an order considers its first visible content:
|
|
660
|
-
* - `sequential` — frontier-0 is minimally ready (leaf: on resolve; nested: via its
|
|
661
|
-
* own minimal signal).
|
|
662
|
-
* - `together` — every direct slot is minimally ready.
|
|
663
|
-
* - `natural` — any direct slot has visible content (leaves on resolve; nested
|
|
664
|
-
* composites via their own minimal signal).
|
|
665
|
-
*
|
|
666
|
-
* @example
|
|
667
|
-
* ```ts
|
|
668
|
-
* // Primitive form of `<Reveal>` — coordinate sibling loading boundaries
|
|
669
|
-
* // programmatically. App code uses the JSX `<Reveal>` component instead.
|
|
670
|
-
* // Both options are accessors so they can react to state changes.
|
|
671
|
-
* createRevealOrder(
|
|
672
|
-
* () => renderSiblings(),
|
|
673
|
-
* { order: () => mode(), collapsed: () => true }
|
|
674
|
-
* );
|
|
675
|
-
* ```
|
|
676
|
-
*/ function createRevealOrder(e, t) {
|
|
677
|
-
_revealUsed = true;
|
|
678
|
-
const r = createOwner();
|
|
679
|
-
const n = getContext(RevealControllerContext);
|
|
680
|
-
const i = t?.order || SEQUENTIAL_ACCESSOR, s = t?.collapsed || FALSE_ACCESSOR;
|
|
681
|
-
const o = new RevealController(i, s);
|
|
682
|
-
setContext(RevealControllerContext, o, r);
|
|
683
|
-
return runWithOwner(r, () => {
|
|
684
|
-
const t = e();
|
|
685
|
-
const r = computed(() => {
|
|
686
|
-
i();
|
|
687
|
-
s();
|
|
688
|
-
o.B();
|
|
689
|
-
});
|
|
690
|
-
// Post-construction rather than an options argument, so the prod call
|
|
691
|
-
// keeps its shape; the observe node literal already carries the slot.
|
|
692
|
-
if (false) ;
|
|
693
|
-
if (n) {
|
|
694
|
-
o.j = n;
|
|
695
|
-
n.$(o);
|
|
696
|
-
cleanup(() => n.ee(o));
|
|
697
|
-
}
|
|
698
|
-
return t;
|
|
699
|
-
});
|
|
700
|
-
}
|
|
558
|
+
// Installed at module evaluation — present exactly when something imports a
|
|
559
|
+
// boundary. An app without one pays the three null checks and nothing else.
|
|
560
|
+
GlobalQueue.fe = catchStatus;
|
|
701
561
|
|
|
702
|
-
|
|
703
|
-
* Resolves a children value to its renderable form: unwraps zero-arg functions
|
|
704
|
-
* (accessors), recursively flattens arrays, and optionally skips
|
|
705
|
-
* non-rendering values (`null`, `undefined`, `true`, `false`, `""`).
|
|
706
|
-
*
|
|
707
|
-
* Used internally by flow components and by the renderer to walk a children
|
|
708
|
-
* tree. App code rarely needs this directly — see `children()` in `solid-js`
|
|
709
|
-
* for the user-facing helper that memoizes the result.
|
|
710
|
-
*
|
|
711
|
-
* @param children value or array of values to flatten
|
|
712
|
-
* @param options
|
|
713
|
-
* - `skipNonRendered` — drop values that won't render
|
|
714
|
-
* - `doNotUnwrap` — leave function children as-is (caller will resolve)
|
|
715
|
-
*
|
|
716
|
-
* @example
|
|
717
|
-
* ```ts
|
|
718
|
-
* // Custom renderer walking a children tree manually. Most authors should
|
|
719
|
-
* // use `children()` from solid-js, which memoizes the resolved value.
|
|
720
|
-
* function renderChildren(value: unknown): unknown {
|
|
721
|
-
* return flatten(value, { skipNonRendered: true });
|
|
722
|
-
* }
|
|
723
|
-
* ```
|
|
724
|
-
*/ function flatten(e, t) {
|
|
725
|
-
if (typeof e === "function" && !e.length) {
|
|
726
|
-
if (t?.doNotUnwrap) return e;
|
|
727
|
-
do {
|
|
728
|
-
e = e();
|
|
729
|
-
} while (typeof e === "function" && !e.length);
|
|
730
|
-
}
|
|
731
|
-
if (t?.skipNonRendered && (e == null || e === true || e === false || e === "")) return;
|
|
732
|
-
if (Array.isArray(e)) {
|
|
733
|
-
let r = [];
|
|
734
|
-
if (flattenArray(e, r, t)) {
|
|
735
|
-
return () => {
|
|
736
|
-
let e = [];
|
|
737
|
-
flattenArray(r, e, {
|
|
738
|
-
...t,
|
|
739
|
-
doNotUnwrap: false
|
|
740
|
-
});
|
|
741
|
-
return e;
|
|
742
|
-
};
|
|
743
|
-
}
|
|
744
|
-
return r;
|
|
745
|
-
}
|
|
746
|
-
return e;
|
|
747
|
-
}
|
|
562
|
+
GlobalQueue.ce = e => e.G & STATUS_UNINITIALIZED && catchStatus(e, STATUS_PENDING);
|
|
748
563
|
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
let n = e[s];
|
|
755
|
-
if (typeof n === "function" && !n.length) {
|
|
756
|
-
if (r?.doNotUnwrap) {
|
|
757
|
-
t.push(n);
|
|
758
|
-
i = true;
|
|
759
|
-
continue;
|
|
760
|
-
}
|
|
761
|
-
do {
|
|
762
|
-
n = n();
|
|
763
|
-
} while (typeof n === "function" && !n.length);
|
|
764
|
-
}
|
|
765
|
-
if (Array.isArray(n)) {
|
|
766
|
-
// OR, don't overwrite: an accessor already pushed under doNotUnwrap
|
|
767
|
-
// still needs the resolving wrapper even when a later sibling
|
|
768
|
-
// fragment contains no functions (#3133).
|
|
769
|
-
i = flattenArray(n, t, r) || i;
|
|
770
|
-
} else if (r?.skipNonRendered && (n == null || n === true || n === false || n === "")) {
|
|
771
|
-
// skip
|
|
772
|
-
} else t.push(n);
|
|
773
|
-
} catch (e) {
|
|
774
|
-
if (!(e instanceof NotReadyError)) throw e;
|
|
775
|
-
n = e;
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
if (n) throw n;
|
|
779
|
-
return i;
|
|
780
|
-
}
|
|
564
|
+
GlobalQueue.se = hidden;
|
|
565
|
+
|
|
566
|
+
GlobalQueue.Ee = boundarySeam;
|
|
567
|
+
|
|
568
|
+
GlobalQueue.de = heldRun;
|
|
781
569
|
|
|
782
|
-
export {
|
|
570
|
+
export { REVEAL, createErrorBoundary, createLoadingBoundary, prune, ready, redraw, revealHooks, setRevealHooks };
|