@solidjs/signals 2.0.0-rc.11 → 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 +2056 -3773
- package/dist/dev.attribution.js +159 -91
- package/dist/dev.js +7263 -8384
- 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 +271 -199
- package/dist/observe/core/constants.js +115 -178
- package/dist/observe/core/context.js +3 -3
- package/dist/observe/core/core.js +840 -1428
- package/dist/observe/core/dev.js +41 -18
- 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 -177
- package/dist/prod/core/context.js +3 -3
- package/dist/prod/core/core.js +852 -1448
- 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 +48 -1
- package/dist/types/core/attribution.d.ts +29 -9
- package/dist/types/core/constants.d.ts +125 -171
- package/dist/types/core/core.d.ts +104 -264
- package/dist/types/core/dev.d.ts +60 -7
- 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 +6 -6
- 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 +7 -5
- package/dist/types/reveal.d.ts +19 -0
- package/dist/types/signals.d.ts +53 -92
- 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 -2480
- 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 -2356
- 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 -143
- package/dist/types/store/next/target.d.ts +0 -196
|
@@ -1,34 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defaultContext, CONFIG_TRANSPARENT, REACTIVE_DISPOSED, STATUS_PENDING, REACTIVE_FRAME_READ, CONFIG_AUTO_DISPOSE, REACTIVE_ZOMBIE } from "./constants.js";
|
|
2
2
|
|
|
3
|
-
import { context, runWithOwner,
|
|
3
|
+
import { context, runWithOwner, tracking } from "./core.js";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { registerRoot, unregisterRoot } from "./dev.js";
|
|
6
6
|
|
|
7
7
|
import { clearDeps, unobserved } from "./graph.js";
|
|
8
8
|
|
|
9
|
-
import { deleteFromHeap
|
|
9
|
+
import { deleteFromHeap } from "./heap.js";
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { schedule, dirtyQueue } from "./scheduler.js";
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
// L2 (step 2): the parked frame. A pass parks the previous frame's children
|
|
14
|
+
// and `_disposal` list on `_x._pendingFirstChild` / `_x._pendingDisposal`
|
|
15
|
+
// (`parkChildren`, core.ts); they keep reacting until the node's commit
|
|
16
|
+
// disposes them (`zombie` walk below) or the owner dies. `markDisposal` flags
|
|
17
|
+
// the parked subtree REACTIVE_ZOMBIE: the splice guard and the reawaken path
|
|
18
|
+
// key off it, and the heap defers a zombie's recompute past the seam (no
|
|
19
|
+
// second heap — the deferral list in scheduler.ts).
|
|
16
20
|
function markDisposal(e) {
|
|
17
|
-
let n = e.
|
|
21
|
+
let n = e.sn;
|
|
18
22
|
while (n) {
|
|
19
|
-
|
|
20
|
-
n.oe = e | REACTIVE_ZOMBIE;
|
|
21
|
-
// migrate height-adjust entries too, not just recompute entries: every
|
|
22
|
-
// `deleteFromHeap` call site picks the queue from the zombie flag, so a
|
|
23
|
-
// node left physically linked in `dirtyQueue` after being zombified gets
|
|
24
|
-
// unlinked from the wrong queue on dispose, corrupting the bucket and
|
|
25
|
-
// livelocking the next `runHeap` that reaches it (#2759)
|
|
26
|
-
if (e & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT)) {
|
|
27
|
-
deleteFromHeap(n, e & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
28
|
-
if (e & REACTIVE_IN_HEAP) insertIntoHeap(n, zombieQueue); else insertIntoHeapHeight(n, zombieQueue);
|
|
29
|
-
}
|
|
23
|
+
n.R |= REACTIVE_ZOMBIE;
|
|
30
24
|
markDisposal(n);
|
|
31
|
-
n = n.
|
|
25
|
+
n = n.rn;
|
|
32
26
|
}
|
|
33
27
|
}
|
|
34
28
|
|
|
@@ -39,47 +33,35 @@ function dispose(e) {
|
|
|
39
33
|
// left queued would be recomputed and resurrected by the next flush (#2983)
|
|
40
34
|
// — dep unlinking, child disposal) is exactly unobserved()'s body; only
|
|
41
35
|
// this flag distinguishes death from dormancy.
|
|
42
|
-
e.
|
|
36
|
+
e.u &= ~CONFIG_AUTO_DISPOSE;
|
|
43
37
|
unobserved(e);
|
|
44
38
|
}
|
|
45
39
|
|
|
46
40
|
function disposeChildren(e, n = false, t) {
|
|
47
|
-
const i = e.
|
|
41
|
+
const i = e.R;
|
|
48
42
|
if (i & REACTIVE_DISPOSED) return;
|
|
49
|
-
// A
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
if (n && !t && e.
|
|
43
|
+
// A parked frame dies with its owner (#3024): the commit that would retire
|
|
44
|
+
// it never comes once the node is DISPOSED, so it drains here or its
|
|
45
|
+
// cleanups never run and it stays subscribed, rerunning in a torn-down
|
|
46
|
+
// tree (#3561). Death only (`self`): a re-pass leaves the frame reacting
|
|
47
|
+
// until the commit.
|
|
48
|
+
if (n && !t && e.m !== null && (e.m.St !== null || e.m.ct !== null)) disposeChildren(e, false, true);
|
|
55
49
|
if (n) {
|
|
56
|
-
e.
|
|
57
|
-
if (e._parent === null && e.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// one of them outlives its source the same way (INV-9's rationale). The
|
|
67
|
-
// firewall knows which leaves carry companions (CONFIG_CHILD_COMPANIONS,
|
|
68
|
-
// #3038): snap them with it — the snap retires a shadow whose firewall is
|
|
69
|
-
// disposed (spec O5).
|
|
70
|
-
if (n.C & CONFIG_CHILD_COMPANIONS) n.o.xt.forEach(GlobalQueue.Qn);
|
|
71
|
-
// A pending reader parked in a transaction may be the only thing holding
|
|
72
|
-
// it (#3372): its death is a completion event the transaction must be
|
|
73
|
-
// re-judged for, and nothing else re-enters a parked transaction.
|
|
74
|
-
const t = n.me;
|
|
75
|
-
if (t && n.S & STATUS_PENDING && !wokenTransitions.includes(t)) wokenTransitions.push(t),
|
|
76
|
-
schedule();
|
|
50
|
+
e.R = i | REACTIVE_DISPOSED;
|
|
51
|
+
if (e._parent === null && e.Ht) unregisterRoot(e);
|
|
52
|
+
}
|
|
53
|
+
if (n && e.re) {
|
|
54
|
+
if (e.m !== null) e.m.De = null;
|
|
55
|
+
// A death that can unblock the future (L2, `futureBlocked`): a held
|
|
56
|
+
// flight's — a transaction's or a lane's (its `_x._transaction`) — or a
|
|
57
|
+
// stale reader's (REACTIVE_FRAME_READ — a frame that derived from one).
|
|
58
|
+
// Nothing else re-examines a dead node, so make sure a seam comes.
|
|
59
|
+
if (e.G & STATUS_PENDING && e.m?._t != null || i & REACTIVE_FRAME_READ) schedule();
|
|
77
60
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const e = o;
|
|
61
|
+
let r = t ? e.m.St : e.sn;
|
|
62
|
+
if (t) e.m.St = null; else e.sn = null;
|
|
63
|
+
while (r) {
|
|
64
|
+
const e = r;
|
|
83
65
|
// Owner teardown is death regardless of the child's own lifecycle
|
|
84
66
|
// (#3024): strip AUTO_DISPOSE so a post-disposal read freezes at the
|
|
85
67
|
// last committed value instead of reawakening in a torn-down tree.
|
|
@@ -87,7 +69,7 @@ function disposeChildren(e, n = false, t) {
|
|
|
87
69
|
// disposeChildren call early-returns on REACTIVE_DISPOSED) die too.
|
|
88
70
|
// Only unobserved()'s own node keeps its dormancy — it is never in
|
|
89
71
|
// this loop; its children are rebuilt fresh on reawaken.
|
|
90
|
-
e.
|
|
72
|
+
e.u &= ~CONFIG_AUTO_DISPOSE;
|
|
91
73
|
// Heap removal must not be gated on `_deps`: a dependency-free
|
|
92
74
|
// computation queued by refresh() has a null dep list but still sits in
|
|
93
75
|
// the dirty heap, and left there the post-disposal flush recomputes it —
|
|
@@ -95,50 +77,49 @@ function disposeChildren(e, n = false, t) {
|
|
|
95
77
|
// comes back to life (post-unmount runs, leaked cleanups, #2983).
|
|
96
78
|
// deleteFromHeap self-guards on the in-heap flags (and tolerates plain
|
|
97
79
|
// Owners, whose _flags is undefined), so no gate here.
|
|
98
|
-
deleteFromHeap(e,
|
|
80
|
+
deleteFromHeap(e, dirtyQueue);
|
|
99
81
|
clearDeps(e);
|
|
100
82
|
// The chain is detached above so a node a cleanup links mid-drain lands
|
|
101
83
|
// on the fresh head and survives. Pointing each drained child's prev at
|
|
102
84
|
// itself routes its later splice onto the detached chain, never the head,
|
|
103
85
|
// and keeps the dev owner-chain-head invariant honest for those children.
|
|
104
|
-
|
|
105
|
-
disposeChildren(
|
|
86
|
+
r.Gt = r;
|
|
87
|
+
disposeChildren(r, true);
|
|
106
88
|
// Read after, not before: a sibling this disposal made dormant spliced
|
|
107
89
|
// itself out of the detached chain, and a cleanup may then have linked
|
|
108
90
|
// it at the fresh head, which rewrote the `_nextSibling` a pre-read
|
|
109
91
|
// would still be holding.
|
|
110
|
-
|
|
92
|
+
r = r.rn;
|
|
111
93
|
}
|
|
112
|
-
if (t)
|
|
113
|
-
if (e.o !== null) e.o.dt = null;
|
|
114
|
-
} else e.Nt = 0;
|
|
94
|
+
if (!t) e.Ct = 0;
|
|
115
95
|
// O(1) splice out of parent's chain on individual dispose. Skipped during
|
|
116
|
-
// batch dispose (parent already disposed) and zombie
|
|
117
|
-
// parent's
|
|
118
|
-
// walks that already advanced past us
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
if (
|
|
124
|
-
|
|
96
|
+
// batch dispose (parent already disposed) and for a zombie (it sits on the
|
|
97
|
+
// parent's parked frame, drained whole by the commit). We leave
|
|
98
|
+
// node._nextSibling intact so outer walks that already advanced past us
|
|
99
|
+
// still reach later siblings.
|
|
100
|
+
if (n && !t && !(i & REACTIVE_ZOMBIE) && e._parent !== null && !(e._parent.R & REACTIVE_DISPOSED)) {
|
|
101
|
+
const n = e.Gt;
|
|
102
|
+
const t = e.rn;
|
|
103
|
+
if (n !== null) n.rn = t; else e._parent.sn = t;
|
|
104
|
+
if (t !== null) t.Gt = n;
|
|
105
|
+
e.Gt = null;
|
|
125
106
|
}
|
|
126
107
|
runDisposal(e, t);
|
|
127
108
|
// Final effect-returned cleanup fires at true disposal, after `_disposal`
|
|
128
109
|
// to mirror rerun ordering (compute-phase teardown first, cleanup last).
|
|
129
|
-
if (n && e.
|
|
130
|
-
const n = e.
|
|
131
|
-
e.
|
|
110
|
+
if (n && e.kt) {
|
|
111
|
+
const n = e.kt;
|
|
112
|
+
e.kt = undefined;
|
|
132
113
|
n();
|
|
133
114
|
}
|
|
134
115
|
}
|
|
135
116
|
|
|
136
117
|
function linkChild(e, n) {
|
|
137
|
-
const t = e.
|
|
138
|
-
n.
|
|
139
|
-
n.
|
|
140
|
-
if (t !== null) t.
|
|
141
|
-
e.
|
|
118
|
+
const t = e.sn;
|
|
119
|
+
n.Gt = null;
|
|
120
|
+
n.rn = t;
|
|
121
|
+
if (t !== null) t.Gt = n;
|
|
122
|
+
e.sn = n;
|
|
142
123
|
}
|
|
143
124
|
|
|
144
125
|
function runDisposal(e, n) {
|
|
@@ -148,9 +129,9 @@ function runDisposal(e, n) {
|
|
|
148
129
|
// walk ran every entry a second time. Detached, the re-entrant drain finds
|
|
149
130
|
// nothing. The same shape latched a throwing cleanup: the list survived the
|
|
150
131
|
// throw and every later drain re-ran and re-threw it.
|
|
151
|
-
const t = n ? e.
|
|
132
|
+
const t = n ? e.m.ct : e.Pe;
|
|
152
133
|
if (!t) return;
|
|
153
|
-
if (n) e.
|
|
134
|
+
if (n) e.m.ct = null; else e.Pe = null;
|
|
154
135
|
if (Array.isArray(t)) {
|
|
155
136
|
// Unwind order (#3572, restores 1.x #1562): later registrations run
|
|
156
137
|
// before earlier ones. Children have already been disposed by the caller,
|
|
@@ -167,8 +148,8 @@ function runDisposal(e, n) {
|
|
|
167
148
|
|
|
168
149
|
function childId(e, n) {
|
|
169
150
|
let t = e;
|
|
170
|
-
while (t.
|
|
171
|
-
if (t.id != null) return formatId(t.id, n ? t.
|
|
151
|
+
while (t.u & CONFIG_TRANSPARENT && t._parent) t = t._parent;
|
|
152
|
+
if (t.id != null) return formatId(t.id, n ? t.Ct++ : t.Ct);
|
|
172
153
|
throw new Error("");
|
|
173
154
|
}
|
|
174
155
|
|
|
@@ -219,7 +200,6 @@ function formatId(e, n) {
|
|
|
219
200
|
* }
|
|
220
201
|
* ```
|
|
221
202
|
*/ function getObserver() {
|
|
222
|
-
if (pendingCheckActive || latestReadActive) return PENDING_OWNER;
|
|
223
203
|
return tracking ? context : null;
|
|
224
204
|
}
|
|
225
205
|
|
|
@@ -249,14 +229,14 @@ function formatId(e, n) {
|
|
|
249
229
|
* checks. `cleanup()` is the unchecked primitive used by internals.
|
|
250
230
|
*/ function cleanup(e) {
|
|
251
231
|
if (!context) return e;
|
|
252
|
-
if (!context.
|
|
232
|
+
if (!context.Pe) context.Pe = e; else if (Array.isArray(context.Pe)) context.Pe.push(e); else context.Pe = [ context.Pe, e ];
|
|
253
233
|
return e;
|
|
254
234
|
}
|
|
255
235
|
|
|
256
236
|
/**
|
|
257
|
-
* Returns `true` if the owner has been disposed
|
|
258
|
-
*
|
|
259
|
-
*
|
|
237
|
+
* Returns `true` if the owner has been disposed. Pair with a captured owner
|
|
238
|
+
* to bail out of late callbacks whose surrounding component already
|
|
239
|
+
* unmounted.
|
|
260
240
|
*
|
|
261
241
|
* @example
|
|
262
242
|
* ```ts
|
|
@@ -269,7 +249,7 @@ function formatId(e, n) {
|
|
|
269
249
|
* }
|
|
270
250
|
* ```
|
|
271
251
|
*/ function isDisposed(e) {
|
|
272
|
-
return !!(e.
|
|
252
|
+
return !!(e.R & REACTIVE_DISPOSED);
|
|
273
253
|
}
|
|
274
254
|
|
|
275
255
|
function disposeRootSelf(e = true) {
|
|
@@ -292,17 +272,16 @@ function disposeRootSelf(e = true) {
|
|
|
292
272
|
// is a plain store rather than a shape fork between labelled and plain roots.
|
|
293
273
|
const i = {
|
|
294
274
|
id: inheritId(e, t, n),
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
o: null,
|
|
275
|
+
u: t ? CONFIG_TRANSPARENT : 0,
|
|
276
|
+
Ht: true,
|
|
277
|
+
gt: n?.Ht ? n.gt : n,
|
|
278
|
+
sn: null,
|
|
279
|
+
rn: null,
|
|
280
|
+
Gt: null,
|
|
281
|
+
Pe: null,
|
|
282
|
+
U: n?.U || defaultContext,
|
|
283
|
+
Ct: 0,
|
|
284
|
+
m: null,
|
|
306
285
|
_parent: n,
|
|
307
286
|
dispose: disposeRootSelf,
|
|
308
287
|
_name: undefined
|