@solidjs/signals 2.0.0-rc.8 → 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 (90) hide show
  1. package/dist/dev-shared.js +1399 -285
  2. package/dist/dev.attribution.js +459 -307
  3. package/dist/dev.js +1864 -435
  4. package/dist/observe/affects.js +3 -1
  5. package/dist/observe/attribution.js +7 -1
  6. package/dist/observe/boundaries.js +209 -154
  7. package/dist/observe/core/action.js +18 -8
  8. package/dist/observe/core/async.js +220 -110
  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 +23 -1
  12. package/dist/observe/core/attribution-queries.js +28 -0
  13. package/dist/observe/core/attribution.js +262 -485
  14. package/dist/observe/core/constants.js +34 -1
  15. package/dist/observe/core/context.js +3 -3
  16. package/dist/observe/core/core.js +867 -367
  17. package/dist/observe/core/dev.js +78 -17
  18. package/dist/observe/core/effect.js +67 -51
  19. package/dist/observe/core/error-hooks.js +71 -0
  20. package/dist/observe/core/external.js +4 -4
  21. package/dist/observe/core/graph.js +37 -37
  22. package/dist/observe/core/heap.js +45 -45
  23. package/dist/observe/core/invariants.js +2 -0
  24. package/dist/observe/core/lanes.js +86 -49
  25. package/dist/observe/core/optimistic.js +242 -95
  26. package/dist/observe/core/owner.js +98 -84
  27. package/dist/observe/core/scheduler.js +543 -305
  28. package/dist/observe/core/verdict.js +247 -129
  29. package/dist/observe/index.js +7 -3
  30. package/dist/observe/map.js +126 -124
  31. package/dist/observe/signals.js +33 -17
  32. package/dist/observe/store/index.js +2 -0
  33. package/dist/observe/store/next/optimistic.js +141 -132
  34. package/dist/observe/store/next/projection.js +34 -21
  35. package/dist/observe/store/next/reconcile.js +58 -56
  36. package/dist/observe/store/next/store.js +260 -146
  37. package/dist/observe/store/store.js +5 -3
  38. package/dist/observe/store/utils.js +948 -135
  39. package/dist/prod/attribution.js +26 -17
  40. package/dist/prod/boundaries.js +128 -76
  41. package/dist/prod/core/action.js +16 -8
  42. package/dist/prod/core/async.js +251 -143
  43. package/dist/prod/core/constants.js +34 -1
  44. package/dist/prod/core/context.js +3 -3
  45. package/dist/prod/core/core.js +843 -347
  46. package/dist/prod/core/dev.js +17 -1
  47. package/dist/prod/core/effect.js +48 -34
  48. package/dist/prod/core/error-hooks.js +71 -0
  49. package/dist/prod/core/external.js +4 -4
  50. package/dist/prod/core/graph.js +37 -37
  51. package/dist/prod/core/heap.js +45 -45
  52. package/dist/prod/core/lanes.js +90 -53
  53. package/dist/prod/core/optimistic.js +247 -100
  54. package/dist/prod/core/owner.js +57 -45
  55. package/dist/prod/core/scheduler.js +543 -305
  56. package/dist/prod/core/verdict.js +245 -127
  57. package/dist/prod/index.js +7 -3
  58. package/dist/prod/map.js +112 -112
  59. package/dist/prod/signals.js +28 -12
  60. package/dist/prod/store/next/optimistic.js +135 -128
  61. package/dist/prod/store/next/projection.js +31 -20
  62. package/dist/prod/store/next/store.js +325 -252
  63. package/dist/prod/store/store.js +2 -2
  64. package/dist/prod/store/utils.js +946 -135
  65. package/dist/types/attribution.d.ts +7 -2
  66. package/dist/types/attribution.prod.d.ts +10 -1
  67. package/dist/types/boundaries.d.ts +10 -1
  68. package/dist/types/core/action.d.ts +12 -5
  69. package/dist/types/core/attribution-costs.d.ts +35 -0
  70. package/dist/types/core/attribution-feedback.d.ts +133 -0
  71. package/dist/types/core/attribution-hooks.d.ts +28 -3
  72. package/dist/types/core/attribution-queries.d.ts +10 -0
  73. package/dist/types/core/attribution.d.ts +51 -172
  74. package/dist/types/core/constants.d.ts +33 -0
  75. package/dist/types/core/core.d.ts +186 -5
  76. package/dist/types/core/dev.d.ts +129 -9
  77. package/dist/types/core/error-hooks.d.ts +71 -0
  78. package/dist/types/core/index.d.ts +3 -1
  79. package/dist/types/core/invariants.d.ts +4 -0
  80. package/dist/types/core/lanes.d.ts +31 -4
  81. package/dist/types/core/scheduler.d.ts +95 -2
  82. package/dist/types/core/types.d.ts +3 -0
  83. package/dist/types/index.d.ts +2 -2
  84. package/dist/types/signals.d.ts +8 -0
  85. package/dist/types/store/index.d.ts +2 -1
  86. package/dist/types/store/next/optimistic.d.ts +1 -1
  87. package/dist/types/store/next/store.d.ts +6 -5
  88. package/dist/types/store/next/target.d.ts +1 -1
  89. package/dist/types/store/utils.d.ts +177 -6
  90. package/package.json +1 -1
@@ -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.Ye;
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.Ze;
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?.Le || t.o?.Qe) 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.Pe = null;
58
- let o = n ? e.o?.Xe ?? null : e.Ye;
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.Ze;
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.Xe = null;
95
+ if (e.o !== null) e.o.lt = null;
84
96
  } else {
85
- e.Ye = null;
86
- e.$e = 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.qe !== null && !(e.qe.ie & REACTIVE_DISPOSED)) {
93
- const t = e.St;
94
- const n = e.Ze;
95
- if (t !== null) t.Ze = n; else e.qe.Ye = n;
96
- if (n !== null) n.St = t;
97
- e.St = 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.Ht) {
103
- const t = e.Ht;
104
- e.Ht = 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?.Je : e.we;
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.Je = null;
122
- } else e.we = 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.qe) n = n.qe;
128
- if (n.id != null) return formatId(n.id, t ? n.$e++ : n.$e);
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.we) context.we = e; else if (Array.isArray(context.we)) context.we.push(e); else context.we = [ context.we, 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) {
@@ -250,27 +262,27 @@ function disposeRootSelf(e = true) {
250
262
  const i = {
251
263
  id: inheritId(e, n, t),
252
264
  T: n ? CONFIG_TRANSPARENT : 0,
253
- gt: true,
254
- bt: t?.gt ? t.bt : t,
255
- Ye: null,
256
- Ze: null,
257
- St: null,
258
- we: null,
265
+ xt: true,
266
+ Qt: t?.xt ? t.Qt : t,
267
+ Xe: null,
268
+ $e: null,
269
+ Dt: null,
270
+ ke: null,
259
271
  C: t?.C ?? globalQueue,
260
- xe: t?.xe || defaultContext,
261
- $e: 0,
272
+ ze: t?.ze || defaultContext,
273
+ ut: 0,
262
274
  o: null,
263
- qe: t,
275
+ _parent: t,
264
276
  dispose: disposeRootSelf
265
277
  };
266
278
  if (t) {
267
- const e = t.Ye;
279
+ const e = t.Xe;
268
280
  if (e === null) {
269
- t.Ye = i;
281
+ t.Xe = i;
270
282
  } else {
271
- i.Ze = e;
272
- e.St = i;
273
- t.Ye = i;
283
+ i.$e = e;
284
+ e.Dt = i;
285
+ t.Xe = i;
274
286
  }
275
287
  }
276
288
  return i;