@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.
Files changed (89) hide show
  1. package/dist/dev-shared.js +785 -367
  2. package/dist/dev.attribution.js +75 -52
  3. package/dist/dev.js +1120 -567
  4. package/dist/observe/affects-marks.js +86 -0
  5. package/dist/observe/affects.js +22 -73
  6. package/dist/observe/boundaries.js +191 -189
  7. package/dist/observe/core/async.js +175 -131
  8. package/dist/observe/core/attribution-queries.js +1 -1
  9. package/dist/observe/core/attribution.js +176 -159
  10. package/dist/observe/core/constants.js +17 -3
  11. package/dist/observe/core/context.js +3 -3
  12. package/dist/observe/core/core.js +503 -363
  13. package/dist/observe/core/dev.js +66 -38
  14. package/dist/observe/core/effect.js +48 -48
  15. package/dist/observe/core/error.js +5 -3
  16. package/dist/observe/core/external.js +5 -6
  17. package/dist/observe/core/graph.js +57 -43
  18. package/dist/observe/core/heap.js +33 -33
  19. package/dist/observe/core/identities.js +62 -0
  20. package/dist/observe/core/lanes.js +226 -259
  21. package/dist/observe/core/owner.js +62 -50
  22. package/dist/observe/core/scheduler.js +319 -171
  23. package/dist/observe/core/truth.js +45 -0
  24. package/dist/observe/core/verdict.js +88 -50
  25. package/dist/observe/deferred.js +184 -0
  26. package/dist/observe/index.js +7 -1
  27. package/dist/observe/map.js +345 -260
  28. package/dist/observe/reveal.js +76 -76
  29. package/dist/observe/signals.js +41 -30
  30. package/dist/observe/store/affects.js +6 -6
  31. package/dist/observe/store/edges.js +39 -0
  32. package/dist/observe/store/optimistic.js +41 -36
  33. package/dist/observe/store/projection.js +68 -55
  34. package/dist/observe/store/store.js +157 -104
  35. package/dist/prod/affects-marks.js +86 -0
  36. package/dist/prod/affects.js +23 -72
  37. package/dist/prod/boundaries.js +155 -153
  38. package/dist/prod/core/async.js +171 -127
  39. package/dist/prod/core/constants.js +17 -3
  40. package/dist/prod/core/context.js +3 -3
  41. package/dist/prod/core/core.js +478 -342
  42. package/dist/prod/core/effect.js +68 -68
  43. package/dist/prod/core/error.js +5 -3
  44. package/dist/prod/core/external.js +5 -6
  45. package/dist/prod/core/graph.js +57 -43
  46. package/dist/prod/core/heap.js +38 -38
  47. package/dist/prod/core/identities.js +62 -0
  48. package/dist/prod/core/lanes.js +217 -250
  49. package/dist/prod/core/owner.js +62 -51
  50. package/dist/prod/core/scheduler.js +310 -162
  51. package/dist/prod/core/truth.js +45 -0
  52. package/dist/prod/core/verdict.js +87 -49
  53. package/dist/prod/deferred.js +182 -0
  54. package/dist/prod/index.js +7 -1
  55. package/dist/prod/map.js +360 -275
  56. package/dist/prod/reveal.js +76 -76
  57. package/dist/prod/signals.js +41 -30
  58. package/dist/prod/store/affects.js +6 -6
  59. package/dist/prod/store/edges.js +39 -0
  60. package/dist/prod/store/optimistic.js +37 -33
  61. package/dist/prod/store/projection.js +25 -19
  62. package/dist/prod/store/store.js +142 -96
  63. package/dist/types/affects-marks.d.ts +14 -0
  64. package/dist/types/boundaries.d.ts +1 -1
  65. package/dist/types/core/async.d.ts +10 -0
  66. package/dist/types/core/constants.d.ts +13 -1
  67. package/dist/types/core/core.d.ts +44 -2
  68. package/dist/types/core/dev.d.ts +43 -13
  69. package/dist/types/core/graph.d.ts +11 -0
  70. package/dist/types/core/identities.d.ts +17 -0
  71. package/dist/types/core/index.d.ts +2 -1
  72. package/dist/types/core/lanes.d.ts +2 -14
  73. package/dist/types/core/owner.d.ts +5 -3
  74. package/dist/types/core/scheduler.d.ts +47 -28
  75. package/dist/types/core/truth.d.ts +16 -0
  76. package/dist/types/core/types.d.ts +21 -0
  77. package/dist/types/core/verdict.d.ts +32 -0
  78. package/dist/types/deferred.d.ts +28 -0
  79. package/dist/types/index.d.ts +6 -0
  80. package/dist/types/map.d.ts +2 -2
  81. package/dist/types/signals.d.ts +28 -7
  82. package/dist/types/store/edges.d.ts +9 -0
  83. package/dist/types/store/index.d.ts +10 -3
  84. package/dist/types/store/optimistic.d.ts +3 -2
  85. package/dist/types/store/projection.d.ts +4 -3
  86. package/dist/types/store/store.d.ts +1 -1
  87. package/dist/types/store/target.d.ts +16 -8
  88. package/dist/types/store/types.d.ts +14 -0
  89. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
- import { defaultContext, CONFIG_TRANSPARENT, REACTIVE_DISPOSED, STATUS_PENDING, REACTIVE_FRAME_READ, CONFIG_AUTO_DISPOSE, REACTIVE_ZOMBIE } from "./constants.js";
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 { clearDeps, unobserved } from "./graph.js";
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.nn;
21
+ let n = e.ze;
22
22
  while (n) {
23
23
  n.R |= REACTIVE_ZOMBIE;
24
24
  markDisposal(n);
25
- n = n.tn;
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.i &= ~CONFIG_AUTO_DISPOSE;
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.m !== null && (e.m.St !== null || e.m.ct !== null)) disposeChildren(e, false, true);
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.Ht) unregisterRoot(e);
51
+ if (e._parent === null && e.Pt) unregisterRoot(e);
52
52
  }
53
- if (n && e.ee) {
54
- if (e.m !== null) e.m.Te = null;
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.S & STATUS_PENDING && e.m?._t != null || i & REACTIVE_FRAME_READ) schedule();
59
+ if (e.m & STATUS_PENDING && e.T?.Je != null || i & REACTIVE_FRAME_READ) schedule();
60
60
  }
61
- let r = t ? e.m.St : e.nn;
62
- if (t) e.m.St = null; else e.nn = null;
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.i &= ~CONFIG_AUTO_DISPOSE;
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.Gt = 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.tn;
92
+ r = r.Xe;
93
93
  }
94
- if (!t) e.dt = 0;
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.Gt;
102
- const t = e.tn;
103
- if (n !== null) n.tn = t; else e._parent.nn = t;
104
- if (t !== null) t.Gt = n;
105
- e.Gt = null;
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.nn;
119
- n.Gt = null;
120
- n.tn = t;
121
- if (t !== null) t.Gt = n;
122
- e.nn = n;
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.m.ct : e.Re;
132
+ const t = n ? e.T.ft : e.rt;
133
133
  if (!t) return;
134
- if (n) e.m.ct = null; else e.Re = null;
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.i & CONFIG_TRANSPARENT && t._parent) t = t._parent;
152
- if (t.id != null) return formatId(t.id, n ? t.dt++ : t.dt);
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
- */ function cleanup(e) {
231
- if (!context) return e;
232
- if (!context.Re) context.Re = e; else if (Array.isArray(context.Re)) context.Re.push(e); else context.Re = [ context.Re, e ];
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` slot the rendering layer fills with the
271
- // component label (`owner._name = "<App>"`) — a slot, so labelling a root
272
- // is a plain store rather than a shape fork between labelled and plain roots.
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
- i: t ? CONFIG_TRANSPARENT : 0,
276
- Ht: true,
277
- gt: n?.Ht ? n.gt : n,
278
- nn: null,
279
- tn: null,
280
- Gt: null,
281
- Re: null,
282
- D: n?.D || defaultContext,
283
- dt: 0,
284
- m: null,
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://docs.solidjs.com/reference/reactive-utilities/create-root
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
- return runWithOwner(t, () => e(() => t.dispose()));
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 };