@solidjs/signals 2.0.0-rc.7 → 2.0.0-rc.9

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 (134) hide show
  1. package/dist/dev-shared.js +6357 -0
  2. package/dist/dev.attribution.js +2485 -0
  3. package/dist/dev.js +2851 -7027
  4. package/dist/observe/affects.js +129 -0
  5. package/dist/observe/attribution.js +7 -0
  6. package/dist/observe/boundaries.js +641 -0
  7. package/dist/observe/core/action.js +177 -0
  8. package/dist/observe/core/async.js +846 -0
  9. package/dist/observe/core/attribution-costs.js +66 -0
  10. package/dist/observe/core/attribution-feedback.js +282 -0
  11. package/dist/observe/core/attribution-hooks.js +82 -0
  12. package/dist/observe/core/attribution-queries.js +28 -0
  13. package/dist/observe/core/attribution.js +2095 -0
  14. package/dist/observe/core/constants.js +248 -0
  15. package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
  16. package/dist/observe/core/core.js +1789 -0
  17. package/dist/observe/core/dev.js +293 -0
  18. package/dist/observe/core/effect.js +195 -0
  19. package/dist/observe/core/error-hooks.js +71 -0
  20. package/dist/observe/core/error.js +80 -0
  21. package/dist/observe/core/external.js +98 -0
  22. package/dist/observe/core/graph.js +155 -0
  23. package/dist/observe/core/heap.js +147 -0
  24. package/dist/observe/core/invariants.js +45 -0
  25. package/dist/observe/core/lanes.js +205 -0
  26. package/dist/observe/core/optimistic.js +585 -0
  27. package/dist/observe/core/owner.js +322 -0
  28. package/dist/observe/core/scheduler.js +1428 -0
  29. package/dist/observe/core/verdict.js +669 -0
  30. package/dist/observe/index.js +59 -0
  31. package/dist/observe/map.js +484 -0
  32. package/dist/{types-cjs/signals.d.cts → observe/signals.js} +311 -317
  33. package/dist/observe/store/index.js +40 -0
  34. package/dist/observe/store/next/optimistic.js +660 -0
  35. package/dist/observe/store/next/projection.js +255 -0
  36. package/dist/observe/store/next/reconcile.js +375 -0
  37. package/dist/observe/store/next/store.js +2327 -0
  38. package/dist/observe/store/next/target.js +51 -0
  39. package/dist/observe/store/store.js +325 -0
  40. package/dist/observe/store/storePath.js +103 -0
  41. package/dist/observe/store/utils.js +1023 -0
  42. package/dist/prod/attribution.js +41 -0
  43. package/dist/prod/boundaries.js +128 -76
  44. package/dist/prod/core/action.js +65 -37
  45. package/dist/prod/core/async.js +324 -172
  46. package/dist/prod/core/constants.js +57 -1
  47. package/dist/prod/core/context.js +3 -3
  48. package/dist/prod/core/core.js +1003 -364
  49. package/dist/prod/core/dev.js +17 -1
  50. package/dist/prod/core/effect.js +76 -42
  51. package/dist/prod/core/error-hooks.js +71 -0
  52. package/dist/prod/core/external.js +4 -4
  53. package/dist/prod/core/graph.js +37 -37
  54. package/dist/prod/core/heap.js +61 -56
  55. package/dist/prod/core/lanes.js +107 -63
  56. package/dist/prod/core/optimistic.js +374 -93
  57. package/dist/prod/core/owner.js +62 -46
  58. package/dist/prod/core/scheduler.js +653 -286
  59. package/dist/prod/core/verdict.js +245 -127
  60. package/dist/prod/index.js +15 -5
  61. package/dist/prod/map.js +292 -141
  62. package/dist/prod/signals.js +29 -16
  63. package/dist/prod/store/next/optimistic.js +77 -55
  64. package/dist/prod/store/next/projection.js +31 -20
  65. package/dist/prod/store/next/reconcile.js +87 -84
  66. package/dist/prod/store/next/store.js +718 -401
  67. package/dist/prod/store/next/target.js +32 -10
  68. package/dist/prod/store/store.js +12 -14
  69. package/dist/prod/store/utils.js +950 -130
  70. package/dist/types/attribution.d.ts +20 -0
  71. package/dist/types/attribution.prod.d.ts +22 -0
  72. package/dist/types/boundaries.d.ts +10 -1
  73. package/dist/types/core/action.d.ts +12 -5
  74. package/dist/types/core/async.d.ts +1 -1
  75. package/dist/types/core/attribution-costs.d.ts +35 -0
  76. package/dist/types/core/attribution-feedback.d.ts +133 -0
  77. package/dist/types/core/attribution-hooks.d.ts +147 -9
  78. package/dist/types/core/attribution-queries.d.ts +10 -0
  79. package/dist/types/core/attribution.d.ts +216 -182
  80. package/dist/types/core/constants.d.ts +56 -0
  81. package/dist/types/core/core.d.ts +190 -2
  82. package/dist/types/core/dev.d.ts +246 -28
  83. package/dist/types/core/effect.d.ts +8 -1
  84. package/dist/types/core/error-hooks.d.ts +71 -0
  85. package/dist/types/core/index.d.ts +4 -1
  86. package/dist/types/core/invariants.d.ts +4 -0
  87. package/dist/types/core/lanes.d.ts +39 -5
  88. package/dist/types/core/scheduler.d.ts +153 -0
  89. package/dist/types/core/types.d.ts +32 -9
  90. package/dist/types/index.d.ts +10 -3
  91. package/dist/types/map.d.ts +2 -0
  92. package/dist/types/signals.d.ts +8 -0
  93. package/dist/types/store/index.d.ts +2 -0
  94. package/dist/types/store/next/optimistic.d.ts +1 -1
  95. package/dist/types/store/next/store.d.ts +11 -5
  96. package/dist/types/store/next/target.d.ts +37 -10
  97. package/dist/types/store/utils.d.ts +178 -0
  98. package/package.json +21 -17
  99. package/dist/node.cjs +0 -10541
  100. package/dist/node.dev.cjs +0 -13724
  101. package/dist/types-cjs/affects.d.cts +0 -47
  102. package/dist/types-cjs/boundaries.d.cts +0 -175
  103. package/dist/types-cjs/core/action.d.cts +0 -64
  104. package/dist/types-cjs/core/async.d.cts +0 -23
  105. package/dist/types-cjs/core/attribution-hooks.d.cts +0 -127
  106. package/dist/types-cjs/core/attribution.d.cts +0 -495
  107. package/dist/types-cjs/core/constants.d.cts +0 -159
  108. package/dist/types-cjs/core/core.d.cts +0 -185
  109. package/dist/types-cjs/core/dev.d.cts +0 -136
  110. package/dist/types-cjs/core/effect.d.cts +0 -30
  111. package/dist/types-cjs/core/error.d.cts +0 -56
  112. package/dist/types-cjs/core/external.d.cts +0 -15
  113. package/dist/types-cjs/core/graph.d.cts +0 -28
  114. package/dist/types-cjs/core/heap.d.cts +0 -24
  115. package/dist/types-cjs/core/index.d.cts +0 -13
  116. package/dist/types-cjs/core/invariants.d.cts +0 -59
  117. package/dist/types-cjs/core/lanes.d.cts +0 -54
  118. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  119. package/dist/types-cjs/core/owner.d.cts +0 -124
  120. package/dist/types-cjs/core/scheduler.d.cts +0 -236
  121. package/dist/types-cjs/core/types.d.cts +0 -204
  122. package/dist/types-cjs/core/verdict.d.cts +0 -2
  123. package/dist/types-cjs/index.d.cts +0 -10
  124. package/dist/types-cjs/map.d.cts +0 -69
  125. package/dist/types-cjs/package.json +0 -3
  126. package/dist/types-cjs/store/index.d.cts +0 -18
  127. package/dist/types-cjs/store/next/optimistic.d.cts +0 -25
  128. package/dist/types-cjs/store/next/projection.d.cts +0 -8
  129. package/dist/types-cjs/store/next/reconcile.d.cts +0 -10
  130. package/dist/types-cjs/store/next/store.d.cts +0 -121
  131. package/dist/types-cjs/store/next/target.d.cts +0 -166
  132. package/dist/types-cjs/store/store.d.cts +0 -143
  133. package/dist/types-cjs/store/storePath.d.cts +0 -58
  134. package/dist/types-cjs/store/utils.d.cts +0 -74
@@ -1,4 +1,4 @@
1
- import { REACTIVE_DISPOSED, CONFIG_AUTO_DISPOSE, REACTIVE_ZOMBIE, REACTIVE_IN_HEAP, REACTIVE_IN_HEAP_HEIGHT, CONFIG_TRANSPARENT, defaultContext } from "./constants.js";
1
+ import { REACTIVE_DISPOSED, CONFIG_CHILD_COMPANIONS, STATUS_PENDING, CONFIG_AUTO_DISPOSE, REACTIVE_ZOMBIE, REACTIVE_IN_HEAP, REACTIVE_IN_HEAP_HEIGHT, CONFIG_TRANSPARENT, defaultContext } from "./constants.js";
2
2
 
3
3
  import { context, runWithOwner, pendingCheckActive, latestReadActive, tracking } from "./core.js";
4
4
 
@@ -6,16 +6,16 @@ import { clearDeps, unobserved } from "./graph.js";
6
6
 
7
7
  import { deleteFromHeap, queueFor, insertIntoHeap, insertIntoHeapHeight } from "./heap.js";
8
8
 
9
- import { GlobalQueue, zombieQueue, dirtyQueue, globalQueue } from "./scheduler.js";
9
+ import { GlobalQueue, wokenTransitions, schedule, zombieQueue, dirtyQueue, globalQueue } from "./scheduler.js";
10
10
 
11
11
  const PENDING_OWNER = {};
12
12
 
13
13
  // Dummy owner to trigger store's read() path
14
14
  function markDisposal(e) {
15
- let t = e.Qe;
15
+ let t = e.Xe;
16
16
  while (t) {
17
- const e = t.ie;
18
- t.ie = e | REACTIVE_ZOMBIE;
17
+ const e = t.ue;
18
+ t.ue = e | REACTIVE_ZOMBIE;
19
19
  // migrate height-adjust entries too, not just recompute entries: every
20
20
  // `deleteFromHeap` call site picks the queue from the zombie flag, so a
21
21
  // node left physically linked in `dirtyQueue` after being zombified gets
@@ -26,7 +26,7 @@ function markDisposal(e) {
26
26
  if (e & REACTIVE_IN_HEAP) insertIntoHeap(t, zombieQueue); else insertIntoHeapHeight(t, zombieQueue);
27
27
  }
28
28
  markDisposal(t);
29
- t = t.We;
29
+ t = t.$e;
30
30
  }
31
31
  }
32
32
 
@@ -42,22 +42,34 @@ function dispose(e) {
42
42
  }
43
43
 
44
44
  function disposeChildren(e, t = false, n) {
45
- const i = e.ie;
45
+ const i = e.ue;
46
46
  if (i & REACTIVE_DISPOSED) return;
47
47
  if (t) {
48
- e.ie = i | REACTIVE_DISPOSED;
48
+ e.ue = i | REACTIVE_DISPOSED;
49
49
  // Companions are created detached and outlive their owner, but a verdict
50
50
  // must not: a disposed source can never settle, so an isPending companion
51
51
  // latched `true` here would hold a spinner forever (INV-9, the PR #2845
52
52
  // edge). Snap runs after the DISPOSED flag is set so the oracle reads
53
53
  // false, and notifies subscribers still watching the companion.
54
54
  const t = e;
55
- if (t.o?.ye || t.o?.Ce) GlobalQueue.un(t);
55
+ if (t.o?.je || t.o?.xe) GlobalQueue.En(t);
56
+ // A firewall's leaves have no lifecycle of their own, so a companion on
57
+ // one of them outlives its source the same way (INV-9's rationale). The
58
+ // firewall knows which leaves carry companions (CONFIG_CHILD_COMPANIONS,
59
+ // #3038): snap them with it — the snap retires a shadow whose firewall is
60
+ // disposed (spec O5).
61
+ if (t.T & CONFIG_CHILD_COMPANIONS) t.o.bt.forEach(GlobalQueue.En);
62
+ // A pending reader parked in a transaction may be the only thing holding
63
+ // it (#3372): its death is a completion event the transaction must be
64
+ // re-judged for, and nothing else re-enters a parked transaction.
65
+ const n = t.Ge;
66
+ if (n && t.S & STATUS_PENDING && !wokenTransitions.includes(n)) wokenTransitions.push(n),
67
+ schedule();
56
68
  }
57
- if (t && e.oe && e.o !== null) e.o.Ie = null;
58
- let o = n ? e.o?.Ke ?? null : e.Qe;
69
+ if (t && e.ce && e.o !== null) e.o.Re = null;
70
+ let o = n ? e.o?.lt ?? null : e.Xe;
59
71
  while (o) {
60
- const e = o.We;
72
+ const e = o.$e;
61
73
  const t = o;
62
74
  // Owner teardown is death regardless of the child's own lifecycle
63
75
  // (#3024): strip AUTO_DISPOSE so a post-disposal read freezes at the
@@ -80,34 +92,34 @@ function disposeChildren(e, t = false, n) {
80
92
  o = e;
81
93
  }
82
94
  if (n) {
83
- if (e.o !== null) e.o.Ke = null;
95
+ if (e.o !== null) e.o.lt = null;
84
96
  } else {
85
- e.Qe = null;
86
- e.je = 0;
97
+ e.Xe = null;
98
+ e.ut = 0;
87
99
  }
88
100
  // O(1) splice out of parent's chain on individual dispose. Skipped during
89
101
  // batch dispose (parent already disposed) and zombie disposal (node sits on
90
102
  // parent's _pendingFirstChild). We leave node._nextSibling intact so outer
91
103
  // walks that already advanced past us still reach later siblings.
92
- if (t && !n && !(i & REACTIVE_ZOMBIE) && e.Le !== null && !(e.Le.ie & REACTIVE_DISPOSED)) {
93
- const t = e.It;
94
- const n = e.We;
95
- if (t !== null) t.We = n; else e.Le.Qe = n;
96
- if (n !== null) n.It = t;
97
- e.It = null;
104
+ if (t && !n && !(i & REACTIVE_ZOMBIE) && e._parent !== null && !(e._parent.ue & REACTIVE_DISPOSED)) {
105
+ const t = e.Dt;
106
+ const n = e.$e;
107
+ if (t !== null) t.$e = n; else e._parent.Xe = n;
108
+ if (n !== null) n.Dt = t;
109
+ e.Dt = null;
98
110
  }
99
111
  runDisposal(e, n);
100
112
  // Final effect-returned cleanup fires at true disposal, after `_disposal`
101
113
  // to mirror rerun ordering (compute-phase teardown first, cleanup last).
102
- if (t && e.Gt) {
103
- const t = e.Gt;
104
- e.Gt = undefined;
114
+ if (t && e.yt) {
115
+ const t = e.yt;
116
+ e.yt = undefined;
105
117
  t();
106
118
  }
107
119
  }
108
120
 
109
121
  function runDisposal(e, t) {
110
- let n = t ? e.o?.Ze : e.Ge;
122
+ let n = t ? e.o?.it : e.ke;
111
123
  if (!n) return;
112
124
  if (Array.isArray(n)) {
113
125
  for (let e = 0; e < n.length; e++) {
@@ -118,14 +130,14 @@ function runDisposal(e, t) {
118
130
  n.call(n);
119
131
  }
120
132
  if (t) {
121
- if (e.o !== null) e.o.Ze = null;
122
- } else e.Ge = null;
133
+ if (e.o !== null) e.o.it = null;
134
+ } else e.ke = null;
123
135
  }
124
136
 
125
137
  function childId(e, t) {
126
138
  let n = e;
127
- while (n.T & CONFIG_TRANSPARENT && n.Le) n = n.Le;
128
- if (n.id != null) return formatId(n.id, t ? n.je++ : n.je);
139
+ while (n.T & CONFIG_TRANSPARENT && n._parent) n = n._parent;
140
+ if (n.id != null) return formatId(n.id, t ? n.ut++ : n.ut);
129
141
  throw new Error("");
130
142
  }
131
143
 
@@ -206,7 +218,7 @@ function formatId(e, t) {
206
218
  * checks. `cleanup()` is the unchecked primitive used by internals.
207
219
  */ function cleanup(e) {
208
220
  if (!context) return e;
209
- if (!context.Ge) context.Ge = e; else if (Array.isArray(context.Ge)) context.Ge.push(e); else context.Ge = [ context.Ge, e ];
221
+ if (!context.ke) context.ke = e; else if (Array.isArray(context.ke)) context.ke.push(e); else context.ke = [ context.ke, e ];
210
222
  return e;
211
223
  }
212
224
 
@@ -226,7 +238,7 @@ function formatId(e, t) {
226
238
  * }
227
239
  * ```
228
240
  */ function isDisposed(e) {
229
- return !!(e.ie & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE));
241
+ return !!(e.ue & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE));
230
242
  }
231
243
 
232
244
  function disposeRootSelf(e = true) {
@@ -243,30 +255,34 @@ function disposeRootSelf(e = true) {
243
255
  */ function createOwner(e) {
244
256
  const t = context;
245
257
  const n = e?.transparent ?? false;
246
- const i = {
258
+ // Prod and observe boilerplates (see core.ts computed()). The observe
259
+ // literal carries the `_name` slot the rendering layer fills with the
260
+ // component label (`owner._name = "<App>"`) — a slot, so labelling a root
261
+ // is a plain store rather than a shape fork between labelled and plain roots.
262
+ const i = {
247
263
  id: inheritId(e, n, t),
248
264
  T: n ? CONFIG_TRANSPARENT : 0,
249
- Dt: true,
250
- Pt: t?.Dt ? t.Pt : t,
251
- Qe: null,
252
- We: null,
253
- It: null,
254
- Ge: null,
265
+ xt: true,
266
+ Qt: t?.xt ? t.Qt : t,
267
+ Xe: null,
268
+ $e: null,
269
+ Dt: null,
270
+ ke: null,
255
271
  C: t?.C ?? globalQueue,
256
- we: t?.we || defaultContext,
257
- je: 0,
272
+ ze: t?.ze || defaultContext,
273
+ ut: 0,
258
274
  o: null,
259
- Le: t,
275
+ _parent: t,
260
276
  dispose: disposeRootSelf
261
277
  };
262
278
  if (t) {
263
- const e = t.Qe;
279
+ const e = t.Xe;
264
280
  if (e === null) {
265
- t.Qe = i;
281
+ t.Xe = i;
266
282
  } else {
267
- i.We = e;
268
- e.It = i;
269
- t.Qe = i;
283
+ i.$e = e;
284
+ e.Dt = i;
285
+ t.Xe = i;
270
286
  }
271
287
  }
272
288
  return i;