@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/observe/core/dev.js
CHANGED
|
@@ -149,7 +149,7 @@ let hasExclusions = false;
|
|
|
149
149
|
|
|
150
150
|
function isExcluded(e) {
|
|
151
151
|
if (!hasExclusions || !e) return false;
|
|
152
|
-
let n = "_parent" in e ? e : e.
|
|
152
|
+
let n = "_parent" in e ? e : e.H ?? null;
|
|
153
153
|
for (;n !== null; n = n._parent) {
|
|
154
154
|
const e = markedOwners.get(n);
|
|
155
155
|
if (e !== undefined) return e;
|
|
@@ -175,7 +175,7 @@ const DEV = undefined;
|
|
|
175
175
|
* Public as `OBSERVE.ownerPath`; the core's own sites import it directly.
|
|
176
176
|
*/ function ownerPath(e) {
|
|
177
177
|
if (!e) return undefined;
|
|
178
|
-
let n = "_parent" in e ? e : e.
|
|
178
|
+
let n = "_parent" in e ? e : e.H ?? null;
|
|
179
179
|
const t = [];
|
|
180
180
|
for (;n !== null; n = n._parent) {
|
|
181
181
|
const e = n._name;
|
|
@@ -246,7 +246,7 @@ const DEV = undefined;
|
|
|
246
246
|
* locate signal subjects. The per-owner `_signals` list and the devtools
|
|
247
247
|
* `onGraph` hook are dev-tier — the observe build pays one property write.
|
|
248
248
|
*/ function registerGraph(e, n) {
|
|
249
|
-
e.
|
|
249
|
+
e.H = n;
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NOT_PENDING, EFFECT_USER, CONFIG_AUTO_DISPOSE, CONFIG_CHILDREN_FORBIDDEN, EFFECT_TRACKED, EFFECT_RENDER, REACTIVE_DISPOSED, STATUS_ERROR, STATUS_PENDING } from "./constants.js";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { createEffectNode, recompute, computed, staleValues, ext, setEffectStatusNotify } from "./core.js";
|
|
4
4
|
|
|
5
5
|
import { attrHooks } from "./attribution-hooks.js";
|
|
6
6
|
|
|
@@ -12,75 +12,63 @@ import { trimStaleDeps } from "./graph.js";
|
|
|
12
12
|
|
|
13
13
|
import { enqueueSub } from "./heap.js";
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { globalQueue, schedule, GlobalQueue, haltReactivity } from "./scheduler.js";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Effects are the leaf nodes of our reactive graph. When their sources change, they are
|
|
19
19
|
* automatically added to the queue of effects to re-execute, which will cause them to fetch their
|
|
20
20
|
* sources and recompute
|
|
21
|
-
*/ function effect(t, e,
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
recompute(
|
|
25
|
-
// A first pass that
|
|
26
|
-
// staged
|
|
27
|
-
//
|
|
28
|
-
|
|
21
|
+
*/ function effect(t, e, u, o) {
|
|
22
|
+
const E = !!o?.user;
|
|
23
|
+
const r = createEffectNode(t, e, u, E ? EFFECT_USER : EFFECT_RENDER, o);
|
|
24
|
+
recompute(r, true);
|
|
25
|
+
// A first pass that read a staged value was staged itself (recompute: born
|
|
26
|
+
// staged); the flush's commit replays this effect. Its first run is not this
|
|
27
|
+
// creation's (A29). A lane's node likewise: its run is the lane's, queued
|
|
28
|
+
// by the pass and released at the reveal (lanes.ts).
|
|
29
|
+
!o?.defer && r.Ae === NOT_PENDING && !r.m?._t?.Z && (r.i === EFFECT_USER || o?.schedule ? globalQueue.enqueue(r.i, runEffect.bind(null, r)) : runEffect(r, r.i));
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
function notifyEffectStatus(t, e) {
|
|
32
33
|
// Use passed values if provided, otherwise read from node
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
if (this.
|
|
34
|
+
const u = t !== undefined ? t : this.G;
|
|
35
|
+
const o = e !== undefined ? e : this.m?.v;
|
|
36
|
+
if (u & STATUS_ERROR) {
|
|
37
|
+
globalQueue.notify(this, STATUS_PENDING, 0);
|
|
38
|
+
if (this.i === EFFECT_USER) {
|
|
38
39
|
// The error handler is the error arm of the effect phase (#2840 ruling):
|
|
39
40
|
// queue it like the effect function. It runs in the same imperative,
|
|
40
|
-
// writable scope
|
|
41
|
-
// (or optimistic lane) defers it exactly as it defers the success arm.
|
|
42
|
-
// No payload is queued — the node already carries `_statusFlags`/`_error`,
|
|
41
|
+
// writable scope and throws escalate the same way. No payload is queued — the node already carries `_statusFlags`/`_error`,
|
|
43
42
|
// and the runner dispatches on them, so a recovery before the effect
|
|
44
43
|
// phase takes the success arm instead. Blocked forwards (explicit
|
|
45
44
|
// `status` arg without node-state writes) don't queue: the status
|
|
46
45
|
// re-propagates unblocked at commit.
|
|
47
|
-
if (this.
|
|
48
|
-
this.
|
|
49
|
-
|
|
46
|
+
if (this.G & STATUS_ERROR) {
|
|
47
|
+
this.lt = true;
|
|
48
|
+
globalQueue.enqueue(this.i, this.J ??= runEffect.bind(null, this));
|
|
50
49
|
}
|
|
51
50
|
return;
|
|
52
51
|
}
|
|
53
|
-
if (!
|
|
54
|
-
haltReactivity(unwrapStatusError(
|
|
55
|
-
throw
|
|
52
|
+
if (!globalQueue.notify(this, STATUS_ERROR, STATUS_ERROR)) {
|
|
53
|
+
haltReactivity(unwrapStatusError(o));
|
|
54
|
+
throw o;
|
|
56
55
|
}
|
|
57
|
-
} else if (this.
|
|
58
|
-
|
|
56
|
+
} else if (this.i === EFFECT_RENDER) {
|
|
57
|
+
globalQueue.notify(this, STATUS_PENDING | STATUS_ERROR, u, o);
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
function runEffect(t, e) {
|
|
63
|
-
if (!t.
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
// Lane exemption has one exception (#3331): a lane runner for an effect that
|
|
74
|
-
// no longer rides a lane — its optimistic source was superseded, so the lane
|
|
75
|
-
// has no optimistic view left to apply, and the value this effect now
|
|
76
|
-
// carries (or will, once its plain recompute lands) belongs to the still-held
|
|
77
|
-
// transaction. Hand the run to the regular queue, where the transaction's
|
|
78
|
-
// gate stashes it with the owner. Lane-less runners with no live owner
|
|
79
|
-
// (reverts, wake-only lanes) apply now.
|
|
80
|
-
if (t.Gt !== null && !currentTransition(t.Gt).Dt && (e & LANE_RUN ? !t.o?.Ce : activeTransition !== null)) {
|
|
81
|
-
t.T.enqueue(t.He, t.Ct);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
62
|
+
if (!t.lt || t.R & REACTIVE_DISPOSED) return;
|
|
63
|
+
// A queued run behind a fallback (boundaries.ts) waits for the reveal: a
|
|
64
|
+
// user effect's, which would read a DOM that is not attached, and a render
|
|
65
|
+
// effect's update too (maintainer, 2026-10-02: "we held the queue but let
|
|
66
|
+
// the sync renders through… we definitely shouldn't be showing portals
|
|
67
|
+
// early") — a Portal's or head-tag's render effect writes outside the
|
|
68
|
+
// hidden subtree. The synchronous first render on creation is not a queued
|
|
69
|
+
// run and goes through. `_modified` stays set; the boundary re-queues the
|
|
70
|
+
// run (`release`).
|
|
71
|
+
if (GlobalQueue.de && GlobalQueue.de(t)) return;
|
|
84
72
|
// Error arm (#2840), user effects only: a compute-phase error that is still
|
|
85
73
|
// the node's settled state at effect time runs the bundle's error handler in
|
|
86
74
|
// this same imperative, writable scope. Unwrap the StatusError used for
|
|
@@ -91,18 +79,18 @@ function runEffect(t, e) {
|
|
|
91
79
|
// Render effects bypass: their errors route to boundaries synchronously in
|
|
92
80
|
// notifyEffectStatus, and a runner queued by an earlier valueChanged in the
|
|
93
81
|
// same flush must not be hijacked by a later-arriving error status.
|
|
94
|
-
if (t.
|
|
95
|
-
const e = unwrapStatusError(t.
|
|
96
|
-
t.
|
|
97
|
-
t.
|
|
82
|
+
if (t.G & STATUS_ERROR && t.i === EFFECT_USER) {
|
|
83
|
+
const e = unwrapStatusError(t.m?.v);
|
|
84
|
+
t.Nt = t.pe;
|
|
85
|
+
t.lt = false;
|
|
98
86
|
try {
|
|
99
|
-
t.
|
|
100
|
-
const e = t.
|
|
101
|
-
t.
|
|
87
|
+
t.Lt ? t.Lt(e, () => {
|
|
88
|
+
const e = t.kt;
|
|
89
|
+
t.kt = undefined;
|
|
102
90
|
e?.();
|
|
103
91
|
}) : console.error(e);
|
|
104
92
|
} catch (e) {
|
|
105
|
-
if (!
|
|
93
|
+
if (!globalQueue.notify(t, STATUS_ERROR, STATUS_ERROR)) {
|
|
106
94
|
haltReactivity(e);
|
|
107
95
|
throw e;
|
|
108
96
|
}
|
|
@@ -111,43 +99,43 @@ function runEffect(t, e) {
|
|
|
111
99
|
}
|
|
112
100
|
// Captured before the callback: its own throw errors the node below, but
|
|
113
101
|
// the compute pass that produced `_value` was clean, so its tail still goes.
|
|
114
|
-
const
|
|
102
|
+
const u = t.m?.v == null;
|
|
115
103
|
// Observe tier, like its `effectRunEnd` twin below: the frame the engine
|
|
116
104
|
// opens here is what stamps the callback's writes as the effect's (the
|
|
117
105
|
// cascade an observer reports) and what times the callback (the `effect`
|
|
118
106
|
// record) — facts a production observer needs, not only a dev console.
|
|
119
107
|
if (attrHooks !== null) attrHooks.effectRunStart(t);
|
|
120
|
-
const
|
|
121
|
-
t.
|
|
108
|
+
const o = t.kt;
|
|
109
|
+
t.kt = undefined;
|
|
122
110
|
try {
|
|
123
|
-
|
|
124
|
-
const e = t.
|
|
111
|
+
o?.();
|
|
112
|
+
const e = t.Ut(t.pe, t.Nt);
|
|
125
113
|
if (false && e !== undefined && typeof e !== "function") ;
|
|
126
114
|
// The final cleanup is invoked by disposeChildren at true disposal.
|
|
127
|
-
t.
|
|
115
|
+
t.kt = e;
|
|
128
116
|
} catch (e) {
|
|
129
|
-
ext(t).
|
|
130
|
-
t.
|
|
131
|
-
if (!
|
|
117
|
+
ext(t).v = new StatusError(t, e);
|
|
118
|
+
t.G |= STATUS_ERROR;
|
|
119
|
+
if (!globalQueue.notify(t, STATUS_ERROR, STATUS_ERROR)) {
|
|
132
120
|
haltReactivity(e);
|
|
133
121
|
throw e;
|
|
134
122
|
}
|
|
135
123
|
} finally {
|
|
136
|
-
t.
|
|
137
|
-
t.
|
|
124
|
+
t.Nt = t.pe;
|
|
125
|
+
t.lt = false;
|
|
138
126
|
// The run applied: this is the frame now, so the dependency tail the
|
|
139
127
|
// compute pass left linked goes (A30, #3438 — `recompute` defers an
|
|
140
128
|
// effect's trim while a run is owed; the twin of `commitPendingNode`'s
|
|
141
129
|
// trim for a staged pass). An errored compute kept its full list with
|
|
142
130
|
// `_depsTail` marking where it stopped; leave it, as the commit does.
|
|
143
|
-
if (
|
|
131
|
+
if (u) trimStaleDeps(t);
|
|
144
132
|
}
|
|
145
133
|
// Outside the try (see the rule in attribution-hooks.ts). Reached whether or
|
|
146
134
|
// not the callback threw — a throw that escapes the catch above halts.
|
|
147
135
|
if (attrHooks !== null) attrHooks.effectRunEnd(t);
|
|
148
136
|
}
|
|
149
137
|
|
|
150
|
-
GlobalQueue.
|
|
138
|
+
GlobalQueue.X = runEffect;
|
|
151
139
|
|
|
152
140
|
/**
|
|
153
141
|
* Internal tracked effect - bypasses heap, goes directly to effect queue.
|
|
@@ -156,39 +144,40 @@ GlobalQueue.Rt = runEffect;
|
|
|
156
144
|
*/ function trackedEffect(t, e) {
|
|
157
145
|
const run = () => {
|
|
158
146
|
// `_modified` is NOT redundant with the heap: the heap dedups within a
|
|
159
|
-
// pass, but
|
|
160
|
-
// user queue, and this gate is what collapses them into one run
|
|
161
|
-
if (!
|
|
147
|
+
// pass, but several passes in one flush each enqueue `_run` into the same
|
|
148
|
+
// user queue, and this gate is what collapses them into one run.
|
|
149
|
+
if (!u.lt || u.R & REACTIVE_DISPOSED) return;
|
|
150
|
+
if (GlobalQueue.de && GlobalQueue.de(u)) return;
|
|
162
151
|
try {
|
|
163
|
-
|
|
164
|
-
recompute(
|
|
152
|
+
u.lt = false;
|
|
153
|
+
recompute(u);
|
|
165
154
|
} finally {}
|
|
166
155
|
};
|
|
167
|
-
const
|
|
168
|
-
const e =
|
|
169
|
-
|
|
156
|
+
const u = computed(() => {
|
|
157
|
+
const e = u.kt;
|
|
158
|
+
u.kt = undefined;
|
|
170
159
|
e?.();
|
|
171
|
-
const
|
|
172
|
-
|
|
160
|
+
const o = staleValues(t);
|
|
161
|
+
u.kt = o;
|
|
173
162
|
}, {
|
|
174
163
|
...e,
|
|
175
164
|
lazy: true
|
|
176
165
|
});
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
166
|
+
u.kt = undefined;
|
|
167
|
+
u.u = u.u & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
|
|
168
|
+
u.lt = true;
|
|
169
|
+
u.i = EFFECT_TRACKED;
|
|
181
170
|
// Observe-tier label: the computed literal defaulted its `_name` slot to
|
|
182
171
|
// "computed"; relabel by kind (a store into the slot, not a new field).
|
|
183
|
-
if (e?.name === undefined)
|
|
172
|
+
if (e?.name === undefined) u._name = "trackedEffect";
|
|
184
173
|
// Status dispatch rides the SHARED notifier (statusNotifierOf keys off
|
|
185
174
|
// _type): its error arm is behavior-identical to the closure that used to
|
|
186
175
|
// live here, without the per-node NodeExtension allocation.
|
|
187
|
-
|
|
176
|
+
u.q = run;
|
|
188
177
|
// The first run rides the heap like every wake (GlobalQueue._update), so a
|
|
189
178
|
// tracked effect created inside a render-effect callback runs after that
|
|
190
179
|
// pass's staged writes commit, not before.
|
|
191
|
-
enqueueSub(
|
|
180
|
+
enqueueSub(u);
|
|
192
181
|
schedule();
|
|
193
182
|
}
|
|
194
183
|
|
|
@@ -46,11 +46,11 @@ function wireExternalSource(e) {
|
|
|
46
46
|
equals: false,
|
|
47
47
|
ownedWrite: true
|
|
48
48
|
});
|
|
49
|
-
const r = externalSourceConfig.factory(e.
|
|
49
|
+
const r = externalSourceConfig.factory(e.re, () => {
|
|
50
50
|
setSignal(n, undefined);
|
|
51
51
|
});
|
|
52
52
|
cleanup(() => r.dispose());
|
|
53
|
-
e.
|
|
53
|
+
e.re = e => {
|
|
54
54
|
read(n);
|
|
55
55
|
return r.track(e);
|
|
56
56
|
};
|
|
@@ -61,11 +61,11 @@ function externalUntrack(e) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// The hooks mirror the config's liveness exactly (installed on enable,
|
|
64
|
-
// removed on reset) so core's
|
|
64
|
+
// removed on reset) so core's presence checks stay equivalent to the old
|
|
65
65
|
// `externalSourceConfig` truthiness checks.
|
|
66
66
|
function syncExternalHooks() {
|
|
67
|
-
GlobalQueue.
|
|
68
|
-
GlobalQueue.
|
|
67
|
+
GlobalQueue.xt = externalSourceConfig ? wireExternalSource : undefined;
|
|
68
|
+
GlobalQueue.Wt = externalSourceConfig ? externalUntrack : undefined;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
function enableExternalSource(e) {
|
|
@@ -1,47 +1,54 @@
|
|
|
1
1
|
import { CONFIG_AUTO_DISPOSE, STATUS_PENDING, REACTIVE_DISPOSED, REACTIVE_ZOMBIE, CONFIG_SLOT_NODE, REACTIVE_RECOMPUTING_DEPS } from "./constants.js";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { deleteFromHeap, queueFor } from "./heap.js";
|
|
3
|
+
import { deleteFromHeap } from "./heap.js";
|
|
6
4
|
|
|
7
5
|
import { disposeChildren } from "./owner.js";
|
|
8
6
|
|
|
9
|
-
import { bumpNotifyEpoch } from "./scheduler.js";
|
|
7
|
+
import { bumpNotifyEpoch, dirtyQueue } from "./scheduler.js";
|
|
8
|
+
|
|
9
|
+
/** The store's shared slot-node release handler (store/store.ts installs it
|
|
10
|
+
* once) — a live binding read directly by the sweep site: no wrapper frame,
|
|
11
|
+
* no null check (a CONFIG_SLOT_NODE node existing implies the store module
|
|
12
|
+
* loaded and registered it). */ let slotUnobservedHook;
|
|
13
|
+
|
|
14
|
+
function setSlotUnobserved(e) {
|
|
15
|
+
slotUnobservedHook = e;
|
|
16
|
+
}
|
|
10
17
|
|
|
11
18
|
// https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L100
|
|
12
19
|
function unlinkSubs(e) {
|
|
13
|
-
const n = e.
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
if (
|
|
19
|
-
n.
|
|
20
|
-
if (
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
if (n.
|
|
20
|
+
const n = e.I;
|
|
21
|
+
const o = e.p;
|
|
22
|
+
const l = e.l;
|
|
23
|
+
const t = e.ln;
|
|
24
|
+
if (l !== null) l.ln = t; else n.Dt = t;
|
|
25
|
+
if (t !== null) t.l = l; else {
|
|
26
|
+
n.t = l;
|
|
27
|
+
if (l === null) {
|
|
28
|
+
// Store slot nodes dispatch to the ONE shared hook — no per-node
|
|
29
|
+
// unobserved closure, no NodeExtension to hold it.
|
|
30
|
+
if (n.u & CONFIG_SLOT_NODE) slotUnobservedHook(n); else n.m?.Ft?.();
|
|
24
31
|
// No more subscribers; only tear down if CONFIG_AUTO_DISPOSE is set.
|
|
25
|
-
// A pending node is exempt: its in-flight async work
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
32
|
+
// A pending node is exempt: its in-flight async work is an observer —
|
|
33
|
+
// tearing down would orphan the work and re-execute it on the next
|
|
34
|
+
// read. The settle path runs this same last-one-out check when that
|
|
35
|
+
// observer releases (the untracked-read dormancy sweep guards on
|
|
36
|
+
// pending identically).
|
|
30
37
|
const e = n;
|
|
31
|
-
e.
|
|
38
|
+
e.re && e.u & CONFIG_AUTO_DISPOSE && !(e.R & REACTIVE_ZOMBIE) && !(e.G & STATUS_PENDING) && unobserved(e);
|
|
32
39
|
}
|
|
33
40
|
}
|
|
34
|
-
return
|
|
41
|
+
return o;
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
function trimStaleDeps(e) {
|
|
38
|
-
const n = e.
|
|
39
|
-
let
|
|
40
|
-
if (
|
|
45
|
+
const n = e.S;
|
|
46
|
+
let o = n !== null ? n.p : e._;
|
|
47
|
+
if (o !== null) {
|
|
41
48
|
do {
|
|
42
|
-
|
|
43
|
-
} while (
|
|
44
|
-
if (n !== null) n.
|
|
49
|
+
o = unlinkSubs(o);
|
|
50
|
+
} while (o !== null);
|
|
51
|
+
if (n !== null) n.p = null; else e._ = null;
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
54
|
|
|
@@ -50,17 +57,17 @@ function trimStaleDeps(e) {
|
|
|
50
57
|
// and skipping early also avoids adding one (hidden-class churn) via the
|
|
51
58
|
// null-out below.
|
|
52
59
|
function clearDeps(e) {
|
|
53
|
-
let n = e.
|
|
60
|
+
let n = e._;
|
|
54
61
|
if (!n) return;
|
|
55
62
|
do {
|
|
56
63
|
n = unlinkSubs(n);
|
|
57
64
|
} while (n !== null);
|
|
58
|
-
e.
|
|
59
|
-
e.
|
|
65
|
+
e._ = null;
|
|
66
|
+
e.S = null;
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
function unobserved(e) {
|
|
63
|
-
deleteFromHeap(e,
|
|
70
|
+
deleteFromHeap(e, dirtyQueue);
|
|
64
71
|
clearDeps(e);
|
|
65
72
|
disposeChildren(e, true);
|
|
66
73
|
}
|
|
@@ -94,7 +101,7 @@ function sweepDormant() {
|
|
|
94
101
|
// is an observer; the settle path re-runs last-one-out), lost its
|
|
95
102
|
// AUTO_DISPOSE bit (owner teardown strips it, #3024), or already been
|
|
96
103
|
// torn down.
|
|
97
|
-
if (!e.
|
|
104
|
+
if (!e.t && e.u & CONFIG_AUTO_DISPOSE && !(e.G & STATUS_PENDING) && !(e.R & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE))) {
|
|
98
105
|
unobserved(e);
|
|
99
106
|
}
|
|
100
107
|
}
|
|
@@ -102,26 +109,16 @@ function sweepDormant() {
|
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
// https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L52
|
|
105
|
-
function link(e, n
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// read order within the computation.
|
|
111
|
-
const o = n.Je;
|
|
112
|
-
if (o !== null && o.De === e) {
|
|
113
|
-
o.Be &&= l;
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
let s = null;
|
|
117
|
-
const t = n.oe & REACTIVE_RECOMPUTING_DEPS;
|
|
112
|
+
function link(e, n) {
|
|
113
|
+
const o = n.S;
|
|
114
|
+
if (o !== null && o.I === e) return;
|
|
115
|
+
let l = null;
|
|
116
|
+
const t = n.R & REACTIVE_RECOMPUTING_DEPS;
|
|
118
117
|
if (t) {
|
|
119
|
-
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
n.
|
|
123
|
-
// First touch of this pass: the previous pass's label is stale.
|
|
124
|
-
s.Be = l;
|
|
118
|
+
l = o !== null ? o.p : n._;
|
|
119
|
+
if (l !== null && l.I === e) {
|
|
120
|
+
l.Ue = n.he;
|
|
121
|
+
n.S = l;
|
|
125
122
|
return;
|
|
126
123
|
}
|
|
127
124
|
}
|
|
@@ -130,26 +127,20 @@ function link(e, n, l = false) {
|
|
|
130
127
|
// [deps.._depsTail] prefix — the O(1) equivalent of scanning the dep list
|
|
131
128
|
// (the old alien-signals `isValidLink` walk, O(n²) when a computation
|
|
132
129
|
// re-reads earlier deps non-consecutively, e.g. store leaf reads).
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
Ae: n,
|
|
143
|
-
Ie: s,
|
|
144
|
-
jn: r,
|
|
145
|
-
Pe: null,
|
|
146
|
-
Ze: n.We,
|
|
147
|
-
Be: l
|
|
130
|
+
const s = e.Dt;
|
|
131
|
+
if (s !== null && s.o === n && (!t || s.Ue === n.he)) return;
|
|
132
|
+
const u = n.S = e.Dt = {
|
|
133
|
+
I: e,
|
|
134
|
+
o: n,
|
|
135
|
+
p: l,
|
|
136
|
+
ln: s,
|
|
137
|
+
l: null,
|
|
138
|
+
Ue: n.he
|
|
148
139
|
};
|
|
149
|
-
if (o !== null) o.
|
|
150
|
-
if (
|
|
140
|
+
if (o !== null) o.p = u; else n._ = u;
|
|
141
|
+
if (s !== null) s.l = u; else e.t = u;
|
|
151
142
|
// New subscriber edge: staged-rewrite skips (§12d) must not miss it.
|
|
152
143
|
bumpNotifyEpoch();
|
|
153
144
|
}
|
|
154
145
|
|
|
155
|
-
export { clearDeps, dormantNodes, link, sweepDormant, trimStaleDeps, unlinkSubs, unobserved };
|
|
146
|
+
export { clearDeps, dormantNodes, link, setSlotUnobserved, slotUnobservedHook, sweepDormant, trimStaleDeps, unlinkSubs, unobserved };
|