@solidjs/signals 2.0.0-rc.13 → 2.0.0-rc.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev-shared.js +2000 -3768
- package/dist/dev.attribution.js +132 -79
- package/dist/dev.js +7226 -8488
- package/dist/observe/affects.js +125 -104
- package/dist/observe/boundaries.js +458 -665
- package/dist/observe/core/action.js +63 -66
- package/dist/observe/core/async.js +240 -383
- package/dist/observe/core/attribution-queries.js +1 -1
- package/dist/observe/core/attribution.js +240 -183
- package/dist/observe/core/constants.js +115 -187
- package/dist/observe/core/context.js +3 -3
- package/dist/observe/core/core.js +840 -1438
- package/dist/observe/core/dev.js +3 -3
- package/dist/observe/core/effect.js +75 -86
- package/dist/observe/core/external.js +5 -5
- package/dist/observe/core/graph.js +61 -70
- package/dist/observe/core/heap.js +75 -98
- package/dist/observe/core/invariants.js +1 -34
- package/dist/observe/core/lanes.js +704 -181
- package/dist/observe/core/owner.js +80 -101
- package/dist/observe/core/scheduler.js +708 -1351
- package/dist/observe/core/verdict.js +302 -621
- package/dist/observe/flatten.js +79 -0
- package/dist/observe/index.js +15 -13
- package/dist/observe/map.js +232 -235
- package/dist/observe/reveal.js +212 -0
- package/dist/observe/signals.js +133 -215
- package/dist/observe/store/affects.js +135 -0
- package/dist/observe/store/index.js +29 -24
- package/dist/observe/store/optimistic.js +538 -0
- package/dist/observe/store/projection.js +302 -0
- package/dist/observe/store/reconcile.js +257 -0
- package/dist/observe/store/store.js +1945 -277
- package/dist/observe/store/storePath.js +1 -1
- package/dist/{prod/store/next → observe/store}/target.js +17 -18
- package/dist/observe/store/types.js +73 -0
- package/dist/observe/store/utils.js +1 -13
- package/dist/prod/affects.js +127 -106
- package/dist/prod/boundaries.js +442 -654
- package/dist/prod/core/action.js +71 -74
- package/dist/prod/core/async.js +307 -442
- package/dist/prod/core/constants.js +112 -186
- package/dist/prod/core/context.js +3 -3
- package/dist/prod/core/core.js +852 -1458
- package/dist/prod/core/effect.js +88 -99
- package/dist/prod/core/external.js +5 -5
- package/dist/prod/core/graph.js +61 -70
- package/dist/prod/core/heap.js +75 -98
- package/dist/prod/core/invariants.js +1 -32
- package/dist/prod/core/lanes.js +666 -181
- package/dist/prod/core/owner.js +75 -96
- package/dist/prod/core/scheduler.js +677 -1332
- package/dist/prod/core/verdict.js +297 -621
- package/dist/prod/flatten.js +77 -0
- package/dist/prod/index.js +15 -13
- package/dist/prod/map.js +143 -146
- package/dist/prod/reveal.js +212 -0
- package/dist/prod/signals.js +144 -226
- package/dist/prod/store/affects.js +135 -0
- package/dist/prod/store/index.js +28 -19
- package/dist/prod/store/optimistic.js +533 -0
- package/dist/prod/store/projection.js +295 -0
- package/dist/prod/store/reconcile.js +257 -0
- package/dist/prod/store/store.js +1840 -272
- package/dist/prod/store/storePath.js +1 -1
- package/dist/{observe/store/next → prod/store}/target.js +13 -17
- package/dist/prod/store/types.js +73 -0
- package/dist/prod/store/utils.js +1 -11
- package/dist/types/affects.d.ts +11 -30
- package/dist/types/boundaries.d.ts +62 -176
- package/dist/types/carved.d.ts +1 -0
- package/dist/types/core/action.d.ts +5 -6
- package/dist/types/core/async.d.ts +10 -5
- package/dist/types/core/attribution-hooks.d.ts +20 -1
- package/dist/types/core/attribution.d.ts +20 -9
- package/dist/types/core/constants.d.ts +125 -180
- package/dist/types/core/core.d.ts +104 -264
- package/dist/types/core/dev.d.ts +2 -2
- package/dist/types/core/effect.d.ts +0 -7
- package/dist/types/core/graph.d.ts +7 -1
- package/dist/types/core/heap.d.ts +5 -7
- package/dist/types/core/index.d.ts +5 -5
- package/dist/types/core/invariants.d.ts +0 -29
- package/dist/types/core/lanes.d.ts +65 -87
- package/dist/types/core/owner.d.ts +3 -3
- package/dist/types/core/scheduler.d.ts +249 -331
- package/dist/types/core/types.d.ts +51 -85
- package/dist/types/core/verdict.d.ts +3 -0
- package/dist/types/flatten.d.ts +8 -0
- package/dist/types/index.d.ts +6 -4
- package/dist/types/reveal.d.ts +19 -0
- package/dist/types/signals.d.ts +35 -91
- package/dist/types/store/affects.d.ts +1 -0
- package/dist/types/store/index.d.ts +35 -15
- package/dist/types/store/optimistic.d.ts +23 -0
- package/dist/types/store/projection.d.ts +18 -0
- package/dist/types/store/reconcile.d.ts +3 -0
- package/dist/types/store/store.d.ts +165 -143
- package/dist/types/store/storePath.d.ts +1 -1
- package/dist/types/store/target.d.ts +151 -0
- package/dist/types/store/types.d.ts +84 -0
- package/package.json +1 -1
- package/dist/observe/core/optimistic.js +0 -669
- package/dist/observe/store/next/optimistic.js +0 -717
- package/dist/observe/store/next/projection.js +0 -266
- package/dist/observe/store/next/reconcile.js +0 -375
- package/dist/observe/store/next/store.js +0 -2608
- package/dist/prod/core/optimistic.js +0 -658
- package/dist/prod/store/next/optimistic.js +0 -710
- package/dist/prod/store/next/projection.js +0 -257
- package/dist/prod/store/next/reconcile.js +0 -373
- package/dist/prod/store/next/store.js +0 -2484
- package/dist/types/core/optimistic.d.ts +0 -6
- package/dist/types/store/next/optimistic.d.ts +0 -25
- package/dist/types/store/next/projection.d.ts +0 -27
- package/dist/types/store/next/reconcile.d.ts +0 -10
- package/dist/types/store/next/store.d.ts +0 -145
- package/dist/types/store/next/target.d.ts +0 -196
package/dist/prod/core/effect.js
CHANGED
|
@@ -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 { unwrapStatusError, StatusError } from "./error.js";
|
|
6
6
|
|
|
@@ -8,75 +8,63 @@ import { trimStaleDeps } from "./graph.js";
|
|
|
8
8
|
|
|
9
9
|
import { enqueueSub } from "./heap.js";
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { globalQueue, schedule, GlobalQueue, haltReactivity } from "./scheduler.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Effects are the leaf nodes of our reactive graph. When their sources change, they are
|
|
15
15
|
* automatically added to the queue of effects to re-execute, which will cause them to fetch their
|
|
16
16
|
* sources and recompute
|
|
17
|
-
*/ function effect(t,
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
recompute(
|
|
21
|
-
// A first pass that
|
|
22
|
-
// staged
|
|
23
|
-
//
|
|
24
|
-
|
|
17
|
+
*/ function effect(e, t, u, E) {
|
|
18
|
+
const f = !!E?.user;
|
|
19
|
+
const r = createEffectNode(e, t, u, f ? EFFECT_USER : EFFECT_RENDER, E);
|
|
20
|
+
recompute(r, true);
|
|
21
|
+
// A first pass that read a staged value was staged itself (recompute: born
|
|
22
|
+
// staged); the flush's commit replays this effect. Its first run is not this
|
|
23
|
+
// creation's (A29). A lane's node likewise: its run is the lane's, queued
|
|
24
|
+
// by the pass and released at the reveal (lanes.ts).
|
|
25
|
+
!E?.defer && r.Ae === NOT_PENDING && !r.m?.ke?.Z && (r.i === EFFECT_USER || E?.schedule ? globalQueue.enqueue(r.i, runEffect.bind(null, r)) : runEffect(r, r.i));
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
function notifyEffectStatus(
|
|
28
|
+
function notifyEffectStatus(e, t) {
|
|
28
29
|
// Use passed values if provided, otherwise read from node
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
if (this.
|
|
30
|
+
const u = e !== undefined ? e : this.G;
|
|
31
|
+
const E = t !== undefined ? t : this.m?.V;
|
|
32
|
+
if (u & STATUS_ERROR) {
|
|
33
|
+
globalQueue.notify(this, STATUS_PENDING, 0);
|
|
34
|
+
if (this.i === EFFECT_USER) {
|
|
34
35
|
// The error handler is the error arm of the effect phase (#2840 ruling):
|
|
35
36
|
// queue it like the effect function. It runs in the same imperative,
|
|
36
|
-
// writable scope
|
|
37
|
-
// (or optimistic lane) defers it exactly as it defers the success arm.
|
|
38
|
-
// No payload is queued — the node already carries `_statusFlags`/`_error`,
|
|
37
|
+
// writable scope and throws escalate the same way. No payload is queued — the node already carries `_statusFlags`/`_error`,
|
|
39
38
|
// and the runner dispatches on them, so a recovery before the effect
|
|
40
39
|
// phase takes the success arm instead. Blocked forwards (explicit
|
|
41
40
|
// `status` arg without node-state writes) don't queue: the status
|
|
42
41
|
// re-propagates unblocked at commit.
|
|
43
|
-
if (this.
|
|
44
|
-
this.
|
|
45
|
-
|
|
42
|
+
if (this.G & STATUS_ERROR) {
|
|
43
|
+
this.Fe = true;
|
|
44
|
+
globalQueue.enqueue(this.i, this.J ??= runEffect.bind(null, this));
|
|
46
45
|
}
|
|
47
46
|
return;
|
|
48
47
|
}
|
|
49
|
-
if (!
|
|
50
|
-
haltReactivity(unwrapStatusError(
|
|
51
|
-
throw
|
|
48
|
+
if (!globalQueue.notify(this, STATUS_ERROR, STATUS_ERROR)) {
|
|
49
|
+
haltReactivity(unwrapStatusError(E));
|
|
50
|
+
throw E;
|
|
52
51
|
}
|
|
53
|
-
} else if (this.
|
|
54
|
-
|
|
52
|
+
} else if (this.i === EFFECT_RENDER) {
|
|
53
|
+
globalQueue.notify(this, STATUS_PENDING | STATUS_ERROR, u, E);
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
function runEffect(
|
|
59
|
-
if (!
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
// Lane exemption has one exception (#3331): a lane runner for an effect that
|
|
70
|
-
// no longer rides a lane — its optimistic source was superseded, so the lane
|
|
71
|
-
// has no optimistic view left to apply, and the value this effect now
|
|
72
|
-
// carries (or will, once its plain recompute lands) belongs to the still-held
|
|
73
|
-
// transaction. Hand the run to the regular queue, where the transaction's
|
|
74
|
-
// gate stashes it with the owner. Lane-less runners with no live owner
|
|
75
|
-
// (reverts, wake-only lanes) apply now.
|
|
76
|
-
if (t.pn !== null && !currentTransition(t.pn).Rn && (e & LANE_RUN ? !t.o?.me : activeTransition !== null)) {
|
|
77
|
-
t.T.enqueue(t.je, t.An);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
57
|
+
function runEffect(e, t) {
|
|
58
|
+
if (!e.Fe || e.R & REACTIVE_DISPOSED) return;
|
|
59
|
+
// A queued run behind a fallback (boundaries.ts) waits for the reveal: a
|
|
60
|
+
// user effect's, which would read a DOM that is not attached, and a render
|
|
61
|
+
// effect's update too (maintainer, 2026-10-02: "we held the queue but let
|
|
62
|
+
// the sync renders through… we definitely shouldn't be showing portals
|
|
63
|
+
// early") — a Portal's or head-tag's render effect writes outside the
|
|
64
|
+
// hidden subtree. The synchronous first render on creation is not a queued
|
|
65
|
+
// run and goes through. `_modified` stays set; the boundary re-queues the
|
|
66
|
+
// run (`release`).
|
|
67
|
+
if (GlobalQueue.de && GlobalQueue.de(e)) return;
|
|
80
68
|
// Error arm (#2840), user effects only: a compute-phase error that is still
|
|
81
69
|
// the node's settled state at effect time runs the bundle's error handler in
|
|
82
70
|
// this same imperative, writable scope. Unwrap the StatusError used for
|
|
@@ -87,93 +75,94 @@ function runEffect(t, e) {
|
|
|
87
75
|
// Render effects bypass: their errors route to boundaries synchronously in
|
|
88
76
|
// notifyEffectStatus, and a runner queued by an earlier valueChanged in the
|
|
89
77
|
// same flush must not be hijacked by a later-arriving error status.
|
|
90
|
-
if (
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
78
|
+
if (e.G & STATUS_ERROR && e.i === EFFECT_USER) {
|
|
79
|
+
const t = unwrapStatusError(e.m?.V);
|
|
80
|
+
e.Ze = e.pe;
|
|
81
|
+
e.Fe = false;
|
|
94
82
|
try {
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}) : console.error(
|
|
100
|
-
} catch (
|
|
101
|
-
if (!
|
|
102
|
-
haltReactivity(
|
|
103
|
-
throw
|
|
83
|
+
e.it ? e.it(t, () => {
|
|
84
|
+
const t = e.lt;
|
|
85
|
+
e.lt = undefined;
|
|
86
|
+
t?.();
|
|
87
|
+
}) : console.error(t);
|
|
88
|
+
} catch (t) {
|
|
89
|
+
if (!globalQueue.notify(e, STATUS_ERROR, STATUS_ERROR)) {
|
|
90
|
+
haltReactivity(t);
|
|
91
|
+
throw t;
|
|
104
92
|
}
|
|
105
93
|
}
|
|
106
94
|
return;
|
|
107
95
|
}
|
|
108
96
|
// Captured before the callback: its own throw errors the node below, but
|
|
109
97
|
// the compute pass that produced `_value` was clean, so its tail still goes.
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
|
|
98
|
+
const u = e.m?.V == null;
|
|
99
|
+
const E = e.lt;
|
|
100
|
+
e.lt = undefined;
|
|
113
101
|
try {
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
if (false &&
|
|
102
|
+
E?.();
|
|
103
|
+
const t = e.st(e.pe, e.Ze);
|
|
104
|
+
if (false && t !== undefined && typeof t !== "function") ;
|
|
117
105
|
// The final cleanup is invoked by disposeChildren at true disposal.
|
|
118
|
-
|
|
119
|
-
} catch (
|
|
120
|
-
ext(
|
|
121
|
-
|
|
122
|
-
if (!
|
|
123
|
-
haltReactivity(
|
|
124
|
-
throw
|
|
106
|
+
e.lt = t;
|
|
107
|
+
} catch (t) {
|
|
108
|
+
ext(e).V = new StatusError(e, t);
|
|
109
|
+
e.G |= STATUS_ERROR;
|
|
110
|
+
if (!globalQueue.notify(e, STATUS_ERROR, STATUS_ERROR)) {
|
|
111
|
+
haltReactivity(t);
|
|
112
|
+
throw t;
|
|
125
113
|
}
|
|
126
114
|
} finally {
|
|
127
|
-
|
|
128
|
-
|
|
115
|
+
e.Ze = e.pe;
|
|
116
|
+
e.Fe = false;
|
|
129
117
|
// The run applied: this is the frame now, so the dependency tail the
|
|
130
118
|
// compute pass left linked goes (A30, #3438 — `recompute` defers an
|
|
131
119
|
// effect's trim while a run is owed; the twin of `commitPendingNode`'s
|
|
132
120
|
// trim for a staged pass). An errored compute kept its full list with
|
|
133
121
|
// `_depsTail` marking where it stopped; leave it, as the commit does.
|
|
134
|
-
if (
|
|
122
|
+
if (u) trimStaleDeps(e);
|
|
135
123
|
}
|
|
136
124
|
}
|
|
137
125
|
|
|
138
|
-
GlobalQueue.
|
|
126
|
+
GlobalQueue.X = runEffect;
|
|
139
127
|
|
|
140
128
|
/**
|
|
141
129
|
* Internal tracked effect - bypasses heap, goes directly to effect queue.
|
|
142
130
|
* Runs as a leaf owner: child primitives and onCleanup are forbidden (false throws).
|
|
143
131
|
* Uses stale reads.
|
|
144
|
-
*/ function trackedEffect(
|
|
132
|
+
*/ function trackedEffect(e, t) {
|
|
145
133
|
const run = () => {
|
|
146
134
|
// `_modified` is NOT redundant with the heap: the heap dedups within a
|
|
147
|
-
// pass, but
|
|
148
|
-
// user queue, and this gate is what collapses them into one run
|
|
149
|
-
if (!
|
|
135
|
+
// pass, but several passes in one flush each enqueue `_run` into the same
|
|
136
|
+
// user queue, and this gate is what collapses them into one run.
|
|
137
|
+
if (!u.Fe || u.R & REACTIVE_DISPOSED) return;
|
|
138
|
+
if (GlobalQueue.de && GlobalQueue.de(u)) return;
|
|
150
139
|
try {
|
|
151
|
-
|
|
152
|
-
recompute(
|
|
140
|
+
u.Fe = false;
|
|
141
|
+
recompute(u);
|
|
153
142
|
} finally {}
|
|
154
143
|
};
|
|
155
|
-
const
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
144
|
+
const u = computed(() => {
|
|
145
|
+
const t = u.lt;
|
|
146
|
+
u.lt = undefined;
|
|
147
|
+
t?.();
|
|
148
|
+
const E = staleValues(e);
|
|
149
|
+
u.lt = E;
|
|
161
150
|
}, {
|
|
162
|
-
...
|
|
151
|
+
...t,
|
|
163
152
|
lazy: true
|
|
164
153
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
154
|
+
u.lt = undefined;
|
|
155
|
+
u.u = u.u & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
|
|
156
|
+
u.Fe = true;
|
|
157
|
+
u.i = EFFECT_TRACKED;
|
|
169
158
|
// Status dispatch rides the SHARED notifier (statusNotifierOf keys off
|
|
170
159
|
// _type): its error arm is behavior-identical to the closure that used to
|
|
171
160
|
// live here, without the per-node NodeExtension allocation.
|
|
172
|
-
|
|
161
|
+
u.q = run;
|
|
173
162
|
// The first run rides the heap like every wake (GlobalQueue._update), so a
|
|
174
163
|
// tracked effect created inside a render-effect callback runs after that
|
|
175
164
|
// pass's staged writes commit, not before.
|
|
176
|
-
enqueueSub(
|
|
165
|
+
enqueueSub(u);
|
|
177
166
|
schedule();
|
|
178
167
|
}
|
|
179
168
|
|
|
@@ -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._t = externalSourceConfig ? wireExternalSource : undefined;
|
|
68
|
+
GlobalQueue.It = externalSourceConfig ? externalUntrack : undefined;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
function enableExternalSource(e) {
|
package/dist/prod/core/graph.js
CHANGED
|
@@ -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.en;
|
|
24
|
+
if (l !== null) l.en = t; else n.qe = 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?.Xe?.();
|
|
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.Nn;
|
|
112
|
-
if (o !== null && o.Oe === e) {
|
|
113
|
-
o.ze &&= 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.ze = l;
|
|
118
|
+
l = o !== null ? o.p : n._;
|
|
119
|
+
if (l !== null && l.I === e) {
|
|
120
|
+
l.Ue = n.Ge;
|
|
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
|
-
ge: n,
|
|
143
|
-
Ne: s,
|
|
144
|
-
el: r,
|
|
145
|
-
Ae: null,
|
|
146
|
-
Be: n.Ye,
|
|
147
|
-
ze: l
|
|
130
|
+
const s = e.qe;
|
|
131
|
+
if (s !== null && s.o === n && (!t || s.Ue === n.Ge)) return;
|
|
132
|
+
const u = n.S = e.qe = {
|
|
133
|
+
I: e,
|
|
134
|
+
o: n,
|
|
135
|
+
p: l,
|
|
136
|
+
en: s,
|
|
137
|
+
l: null,
|
|
138
|
+
Ue: n.Ge
|
|
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 };
|