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