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