@solidjs/signals 2.0.0-rc.15 → 2.0.0-rc.16
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 +785 -367
- package/dist/dev.attribution.js +75 -52
- package/dist/dev.js +1120 -567
- package/dist/observe/affects-marks.js +86 -0
- package/dist/observe/affects.js +22 -73
- package/dist/observe/boundaries.js +191 -189
- package/dist/observe/core/async.js +175 -131
- package/dist/observe/core/attribution-queries.js +1 -1
- package/dist/observe/core/attribution.js +176 -159
- package/dist/observe/core/constants.js +17 -3
- package/dist/observe/core/context.js +3 -3
- package/dist/observe/core/core.js +503 -363
- package/dist/observe/core/dev.js +66 -38
- package/dist/observe/core/effect.js +48 -48
- package/dist/observe/core/error.js +5 -3
- package/dist/observe/core/external.js +5 -6
- package/dist/observe/core/graph.js +57 -43
- package/dist/observe/core/heap.js +33 -33
- package/dist/observe/core/identities.js +62 -0
- package/dist/observe/core/lanes.js +226 -259
- package/dist/observe/core/owner.js +62 -50
- package/dist/observe/core/scheduler.js +319 -171
- package/dist/observe/core/truth.js +45 -0
- package/dist/observe/core/verdict.js +88 -50
- package/dist/observe/deferred.js +184 -0
- package/dist/observe/index.js +7 -1
- package/dist/observe/map.js +345 -260
- package/dist/observe/reveal.js +76 -76
- package/dist/observe/signals.js +41 -30
- package/dist/observe/store/affects.js +6 -6
- package/dist/observe/store/edges.js +39 -0
- package/dist/observe/store/optimistic.js +41 -36
- package/dist/observe/store/projection.js +68 -55
- package/dist/observe/store/store.js +157 -104
- package/dist/prod/affects-marks.js +86 -0
- package/dist/prod/affects.js +23 -72
- package/dist/prod/boundaries.js +155 -153
- package/dist/prod/core/async.js +171 -127
- package/dist/prod/core/constants.js +17 -3
- package/dist/prod/core/context.js +3 -3
- package/dist/prod/core/core.js +478 -342
- package/dist/prod/core/effect.js +68 -68
- package/dist/prod/core/error.js +5 -3
- package/dist/prod/core/external.js +5 -6
- package/dist/prod/core/graph.js +57 -43
- package/dist/prod/core/heap.js +38 -38
- package/dist/prod/core/identities.js +62 -0
- package/dist/prod/core/lanes.js +217 -250
- package/dist/prod/core/owner.js +62 -51
- package/dist/prod/core/scheduler.js +310 -162
- package/dist/prod/core/truth.js +45 -0
- package/dist/prod/core/verdict.js +87 -49
- package/dist/prod/deferred.js +182 -0
- package/dist/prod/index.js +7 -1
- package/dist/prod/map.js +360 -275
- package/dist/prod/reveal.js +76 -76
- package/dist/prod/signals.js +41 -30
- package/dist/prod/store/affects.js +6 -6
- package/dist/prod/store/edges.js +39 -0
- package/dist/prod/store/optimistic.js +37 -33
- package/dist/prod/store/projection.js +25 -19
- package/dist/prod/store/store.js +142 -96
- package/dist/types/affects-marks.d.ts +14 -0
- package/dist/types/boundaries.d.ts +1 -1
- package/dist/types/core/async.d.ts +10 -0
- package/dist/types/core/constants.d.ts +13 -1
- package/dist/types/core/core.d.ts +44 -2
- package/dist/types/core/dev.d.ts +43 -13
- package/dist/types/core/graph.d.ts +11 -0
- package/dist/types/core/identities.d.ts +17 -0
- package/dist/types/core/index.d.ts +2 -1
- package/dist/types/core/lanes.d.ts +2 -14
- package/dist/types/core/owner.d.ts +5 -3
- package/dist/types/core/scheduler.d.ts +47 -28
- package/dist/types/core/truth.d.ts +16 -0
- package/dist/types/core/types.d.ts +21 -0
- package/dist/types/core/verdict.d.ts +32 -0
- package/dist/types/deferred.d.ts +28 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/map.d.ts +2 -2
- package/dist/types/signals.d.ts +28 -7
- package/dist/types/store/edges.d.ts +9 -0
- package/dist/types/store/index.d.ts +10 -3
- package/dist/types/store/optimistic.d.ts +3 -2
- package/dist/types/store/projection.d.ts +4 -3
- package/dist/types/store/store.d.ts +1 -1
- package/dist/types/store/target.d.ts +16 -8
- package/dist/types/store/types.d.ts +14 -0
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defaultContext, CONFIG_TRANSPARENT, REACTIVE_DISPOSED, STATUS_PENDING, REACTIVE_FRAME_READ,
|
|
1
|
+
import { defaultContext, CONFIG_TRANSPARENT, REACTIVE_NONE, REACTIVE_DISPOSED, CONFIG_AUTO_DISPOSE, STATUS_PENDING, REACTIVE_FRAME_READ, REACTIVE_ZOMBIE } from "./constants.js";
|
|
2
2
|
|
|
3
3
|
import { context, runWithOwner, tracking } from "./core.js";
|
|
4
4
|
|
|
5
5
|
import { registerRoot, unregisterRoot } from "./dev.js";
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { unobserved, clearDeps } from "./graph.js";
|
|
8
8
|
|
|
9
9
|
import { deleteFromHeap } from "./heap.js";
|
|
10
10
|
|
|
@@ -18,11 +18,11 @@ import { schedule, dirtyQueue } from "./scheduler.js";
|
|
|
18
18
|
// key off it, and the heap defers a zombie's recompute past the seam (no
|
|
19
19
|
// second heap — the deferral list in scheduler.ts).
|
|
20
20
|
function markDisposal(e) {
|
|
21
|
-
let n = e.
|
|
21
|
+
let n = e.ze;
|
|
22
22
|
while (n) {
|
|
23
23
|
n.R |= REACTIVE_ZOMBIE;
|
|
24
24
|
markDisposal(n);
|
|
25
|
-
n = n.
|
|
25
|
+
n = n.Xe;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -33,7 +33,7 @@ function dispose(e) {
|
|
|
33
33
|
// left queued would be recomputed and resurrected by the next flush (#2983)
|
|
34
34
|
// — dep unlinking, child disposal) is exactly unobserved()'s body; only
|
|
35
35
|
// this flag distinguishes death from dormancy.
|
|
36
|
-
e.
|
|
36
|
+
e.l &= ~CONFIG_AUTO_DISPOSE;
|
|
37
37
|
unobserved(e);
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -45,21 +45,21 @@ function disposeChildren(e, n = false, t) {
|
|
|
45
45
|
// cleanups never run and it stays subscribed, rerunning in a torn-down
|
|
46
46
|
// tree (#3561). Death only (`self`): a re-pass leaves the frame reacting
|
|
47
47
|
// until the commit.
|
|
48
|
-
if (n && !t && e.
|
|
48
|
+
if (n && !t && e.T !== null && (e.T.Nt !== null || e.T.ft !== null)) disposeChildren(e, false, true);
|
|
49
49
|
if (n) {
|
|
50
50
|
e.R = i | REACTIVE_DISPOSED;
|
|
51
|
-
if (e._parent === null && e.
|
|
51
|
+
if (e._parent === null && e.Pt) unregisterRoot(e);
|
|
52
52
|
}
|
|
53
|
-
if (n && e.
|
|
54
|
-
if (e.
|
|
53
|
+
if (n && e.X) {
|
|
54
|
+
if (e.T !== null) e.T.Se = null;
|
|
55
55
|
// A death that can unblock the future (L2, `futureBlocked`): a held
|
|
56
56
|
// flight's — a transaction's or a lane's (its `_x._transaction`) — or a
|
|
57
57
|
// stale reader's (REACTIVE_FRAME_READ — a frame that derived from one).
|
|
58
58
|
// Nothing else re-examines a dead node, so make sure a seam comes.
|
|
59
|
-
if (e.
|
|
59
|
+
if (e.m & STATUS_PENDING && e.T?.Je != null || i & REACTIVE_FRAME_READ) schedule();
|
|
60
60
|
}
|
|
61
|
-
let r = t ? e.
|
|
62
|
-
if (t) e.
|
|
61
|
+
let r = t ? e.T.Nt : e.ze;
|
|
62
|
+
if (t) e.T.Nt = null; else e.ze = null;
|
|
63
63
|
while (r) {
|
|
64
64
|
const e = r;
|
|
65
65
|
// Owner teardown is death regardless of the child's own lifecycle
|
|
@@ -69,7 +69,7 @@ function disposeChildren(e, n = false, t) {
|
|
|
69
69
|
// disposeChildren call early-returns on REACTIVE_DISPOSED) die too.
|
|
70
70
|
// Only unobserved()'s own node keeps its dormancy — it is never in
|
|
71
71
|
// this loop; its children are rebuilt fresh on reawaken.
|
|
72
|
-
e.
|
|
72
|
+
e.l &= ~CONFIG_AUTO_DISPOSE;
|
|
73
73
|
// Heap removal must not be gated on `_deps`: a dependency-free
|
|
74
74
|
// computation queued by refresh() has a null dep list but still sits in
|
|
75
75
|
// the dirty heap, and left there the post-disposal flush recomputes it —
|
|
@@ -83,26 +83,26 @@ function disposeChildren(e, n = false, t) {
|
|
|
83
83
|
// on the fresh head and survives. Pointing each drained child's prev at
|
|
84
84
|
// itself routes its later splice onto the detached chain, never the head,
|
|
85
85
|
// and keeps the dev owner-chain-head invariant honest for those children.
|
|
86
|
-
r.
|
|
86
|
+
r.Ct = r;
|
|
87
87
|
disposeChildren(r, true);
|
|
88
88
|
// Read after, not before: a sibling this disposal made dormant spliced
|
|
89
89
|
// itself out of the detached chain, and a cleanup may then have linked
|
|
90
90
|
// it at the fresh head, which rewrote the `_nextSibling` a pre-read
|
|
91
91
|
// would still be holding.
|
|
92
|
-
r = r.
|
|
92
|
+
r = r.Xe;
|
|
93
93
|
}
|
|
94
|
-
if (!t) e.
|
|
94
|
+
if (!t) e.ct = 0;
|
|
95
95
|
// O(1) splice out of parent's chain on individual dispose. Skipped during
|
|
96
96
|
// batch dispose (parent already disposed) and for a zombie (it sits on the
|
|
97
97
|
// parent's parked frame, drained whole by the commit). We leave
|
|
98
98
|
// node._nextSibling intact so outer walks that already advanced past us
|
|
99
99
|
// still reach later siblings.
|
|
100
100
|
if (n && !t && !(i & REACTIVE_ZOMBIE) && e._parent !== null && !(e._parent.R & REACTIVE_DISPOSED)) {
|
|
101
|
-
const n = e.
|
|
102
|
-
const t = e.
|
|
103
|
-
if (n !== null) n.
|
|
104
|
-
if (t !== null) t.
|
|
105
|
-
e.
|
|
101
|
+
const n = e.Ct;
|
|
102
|
+
const t = e.Xe;
|
|
103
|
+
if (n !== null) n.Xe = t; else e._parent.ze = t;
|
|
104
|
+
if (t !== null) t.Ct = n;
|
|
105
|
+
e.Ct = null;
|
|
106
106
|
}
|
|
107
107
|
runDisposal(e, t);
|
|
108
108
|
// Final effect-returned cleanup fires at true disposal, after `_disposal`
|
|
@@ -115,11 +115,11 @@ function disposeChildren(e, n = false, t) {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
function linkChild(e, n) {
|
|
118
|
-
const t = e.
|
|
119
|
-
n.
|
|
120
|
-
n.
|
|
121
|
-
if (t !== null) t.
|
|
122
|
-
e.
|
|
118
|
+
const t = e.ze;
|
|
119
|
+
n.Ct = null;
|
|
120
|
+
n.Xe = t;
|
|
121
|
+
if (t !== null) t.Ct = n;
|
|
122
|
+
e.ze = n;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
function runDisposal(e, n) {
|
|
@@ -129,9 +129,9 @@ function runDisposal(e, n) {
|
|
|
129
129
|
// walk ran every entry a second time. Detached, the re-entrant drain finds
|
|
130
130
|
// nothing. The same shape latched a throwing cleanup: the list survived the
|
|
131
131
|
// throw and every later drain re-ran and re-threw it.
|
|
132
|
-
const t = n ? e.
|
|
132
|
+
const t = n ? e.T.ft : e.rt;
|
|
133
133
|
if (!t) return;
|
|
134
|
-
if (n) e.
|
|
134
|
+
if (n) e.T.ft = null; else e.rt = null;
|
|
135
135
|
if (Array.isArray(t)) {
|
|
136
136
|
// Unwind order (#3572, restores 1.x #1562): later registrations run
|
|
137
137
|
// before earlier ones. Children have already been disposed by the caller,
|
|
@@ -148,8 +148,8 @@ function runDisposal(e, n) {
|
|
|
148
148
|
|
|
149
149
|
function childId(e, n) {
|
|
150
150
|
let t = e;
|
|
151
|
-
while (t.
|
|
152
|
-
if (t.id != null) return formatId(t.id, n ? t.
|
|
151
|
+
while (t.l & CONFIG_TRANSPARENT && t._parent) t = t._parent;
|
|
152
|
+
if (t.id != null) return formatId(t.id, n ? t.ct++ : t.ct);
|
|
153
153
|
throw new Error("");
|
|
154
154
|
}
|
|
155
155
|
|
|
@@ -226,10 +226,12 @@ function formatId(e, n) {
|
|
|
226
226
|
/**
|
|
227
227
|
* Low-level: registers `fn` as a disposal callback on the current owner.
|
|
228
228
|
* Most code should use `onCleanup()` from `solid-js`, which adds dev-mode
|
|
229
|
-
* checks. `cleanup()` is the unchecked primitive used by internals
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
* checks. `cleanup()` is the unchecked primitive used by internals; `owner`
|
|
230
|
+
* (internal) targets a specific owner's disposal list instead of the ambient
|
|
231
|
+
* one.
|
|
232
|
+
*/ function cleanup(e, n = context) {
|
|
233
|
+
if (!n) return e;
|
|
234
|
+
if (!n.rt) n.rt = e; else if (Array.isArray(n.rt)) n.rt.push(e); else n.rt = [ n.rt, e ];
|
|
233
235
|
return e;
|
|
234
236
|
}
|
|
235
237
|
|
|
@@ -267,24 +269,31 @@ function disposeRootSelf(e = true) {
|
|
|
267
269
|
const n = context;
|
|
268
270
|
const t = e?.transparent ?? false;
|
|
269
271
|
// Prod and observe boilerplates (see core.ts computed()). The observe
|
|
270
|
-
// literal carries the `_name`
|
|
271
|
-
// component label (`owner._name = "<App>"
|
|
272
|
-
//
|
|
272
|
+
// literal carries the `_name` and `_loc` slots the rendering layer fills
|
|
273
|
+
// with the component label and JSX site (`owner._name = "<App>"`,
|
|
274
|
+
// `owner._loc = "src/App.tsx:3:5"`) — slots, so labelling a root is a
|
|
275
|
+
// plain store rather than a shape fork between labelled and plain roots.
|
|
273
276
|
const i = {
|
|
274
277
|
id: inheritId(e, t, n),
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
278
|
+
l: t ? CONFIG_TRANSPARENT : 0,
|
|
279
|
+
// Present from birth: disposeChildren marks death here on roots too, and
|
|
280
|
+
// a first store of a missing property is a shape transition plus a
|
|
281
|
+
// properties-store allocation per root — on a 100×4 table teardown that
|
|
282
|
+
// was 12 KB and most of disposal's time (2026-10-17).
|
|
283
|
+
R: REACTIVE_NONE,
|
|
284
|
+
Pt: true,
|
|
285
|
+
Ht: n?.Pt ? n.Ht : n,
|
|
286
|
+
ze: null,
|
|
287
|
+
Xe: null,
|
|
288
|
+
Ct: null,
|
|
289
|
+
rt: null,
|
|
290
|
+
A: n?.A || defaultContext,
|
|
291
|
+
ct: 0,
|
|
292
|
+
T: null,
|
|
285
293
|
_parent: n,
|
|
286
294
|
dispose: disposeRootSelf,
|
|
287
|
-
_name: undefined
|
|
295
|
+
_name: undefined,
|
|
296
|
+
_loc: undefined
|
|
288
297
|
};
|
|
289
298
|
if (n) linkChild(n, i); else registerRoot(i);
|
|
290
299
|
return i;
|
|
@@ -323,10 +332,13 @@ function disposeRootSelf(e = true) {
|
|
|
323
332
|
* const detached = runWithOwner(null, () => createRoot(d => d));
|
|
324
333
|
* ```
|
|
325
334
|
*
|
|
326
|
-
* @description https://
|
|
335
|
+
* @description https://v2.solidjs.com/reference/solid-js/advanced/owner-introspection/create-root
|
|
327
336
|
*/ function createRoot(e, n) {
|
|
328
337
|
const t = createOwner(n);
|
|
329
|
-
|
|
338
|
+
// A bound function, not an arrow: an arrow would share this scope, which
|
|
339
|
+
// holds `init`, so keeping `dispose` would keep `init` and all it closes
|
|
340
|
+
// over alive (#4095).
|
|
341
|
+
return runWithOwner(t, () => e(disposeRootSelf.bind(t, true)));
|
|
330
342
|
}
|
|
331
343
|
|
|
332
344
|
export { cleanup, createOwner, createRoot, dispose, disposeChildren, getNextChildId, getObserver, getOwner, inheritId, isDisposed, linkChild, markDisposal, peekNextChildId };
|