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

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 (65) hide show
  1. package/dist/dev.js +2033 -1291
  2. package/dist/node.cjs +1821 -2401
  3. package/dist/node.dev.cjs +13724 -0
  4. package/dist/prod/boundaries.js +3 -1
  5. package/dist/prod/core/async.js +6 -1
  6. package/dist/prod/core/attribution-hooks.js +3 -0
  7. package/dist/prod/core/constants.js +9 -1
  8. package/dist/prod/core/context.js +10 -16
  9. package/dist/prod/core/core.js +215 -139
  10. package/dist/prod/core/dev.js +2 -0
  11. package/dist/prod/core/effect.js +37 -28
  12. package/dist/prod/core/external.js +2 -2
  13. package/dist/prod/core/graph.js +35 -31
  14. package/dist/prod/core/heap.js +34 -40
  15. package/dist/prod/core/lanes.js +41 -27
  16. package/dist/prod/core/optimistic.js +42 -32
  17. package/dist/prod/core/owner.js +32 -32
  18. package/dist/prod/core/scheduler.js +140 -154
  19. package/dist/prod/core/verdict.js +31 -34
  20. package/dist/prod/index.js +0 -2
  21. package/dist/prod/map.js +104 -94
  22. package/dist/prod/signals.js +51 -34
  23. package/dist/prod/store/next/optimistic.js +153 -172
  24. package/dist/prod/store/next/reconcile.js +140 -288
  25. package/dist/prod/store/next/store.js +307 -237
  26. package/dist/prod/store/store.js +2 -2
  27. package/dist/types/core/attribution-hooks.d.ts +64 -0
  28. package/dist/types/core/attribution.d.ts +265 -9
  29. package/dist/types/core/constants.d.ts +8 -0
  30. package/dist/types/core/core.d.ts +12 -3
  31. package/dist/types/core/dev.d.ts +49 -8
  32. package/dist/types/core/heap.d.ts +5 -3
  33. package/dist/types/core/invariants.d.ts +1 -1
  34. package/dist/types/core/lanes.d.ts +10 -0
  35. package/dist/types/core/scheduler.d.ts +9 -4
  36. package/dist/types/signals.d.ts +10 -0
  37. package/dist/types/store/index.d.ts +3 -6
  38. package/dist/types/store/next/optimistic.d.ts +4 -2
  39. package/dist/types/store/next/reconcile.d.ts +5 -12
  40. package/dist/types/store/next/store.d.ts +3 -9
  41. package/dist/types/store/next/target.d.ts +20 -46
  42. package/dist/types/store/store.d.ts +14 -9
  43. package/dist/types-cjs/core/attribution-hooks.d.cts +64 -0
  44. package/dist/types-cjs/core/attribution.d.cts +265 -9
  45. package/dist/types-cjs/core/constants.d.cts +8 -0
  46. package/dist/types-cjs/core/core.d.cts +12 -3
  47. package/dist/types-cjs/core/dev.d.cts +49 -8
  48. package/dist/types-cjs/core/heap.d.cts +5 -3
  49. package/dist/types-cjs/core/invariants.d.cts +1 -1
  50. package/dist/types-cjs/core/lanes.d.cts +10 -0
  51. package/dist/types-cjs/core/scheduler.d.cts +9 -4
  52. package/dist/types-cjs/signals.d.cts +10 -0
  53. package/dist/types-cjs/store/index.d.cts +3 -6
  54. package/dist/types-cjs/store/next/optimistic.d.cts +4 -2
  55. package/dist/types-cjs/store/next/reconcile.d.cts +5 -12
  56. package/dist/types-cjs/store/next/store.d.cts +3 -9
  57. package/dist/types-cjs/store/next/target.d.cts +20 -46
  58. package/dist/types-cjs/store/store.d.cts +14 -9
  59. package/package.json +3 -2
  60. package/dist/prod/store/next/patch-hooks.js +0 -13
  61. package/dist/prod/store/next/patch.js +0 -614
  62. package/dist/types/store/next/patch-hooks.d.ts +0 -41
  63. package/dist/types/store/next/patch.d.ts +0 -91
  64. package/dist/types-cjs/store/next/patch-hooks.d.cts +0 -41
  65. package/dist/types-cjs/store/next/patch.d.cts +0 -91
@@ -1,6 +1,6 @@
1
1
  import { TimeoutError } from "./core/error.js";
2
2
 
3
- import { computed, optimisticComputed, setSignal, optimisticSignal, runWithOwner, setMemo, signal, markRefresh, installAuthoritativeRead, read, untrack } from "./core/core.js";
3
+ import { computed, optimisticComputed, setSignal, optimisticSignal, runWithOwner, setMemo, signal, installAuthoritativeRead, markRefresh, read, untrack } from "./core/core.js";
4
4
 
5
5
  import { cleanup, createRoot, getOwner, dispose, getObserver } from "./core/owner.js";
6
6
 
@@ -188,6 +188,16 @@ function createMemo(e, t) {
188
188
  * Creates a tracked reactive effect where dependency tracking and side effects happen
189
189
  * in the same scope.
190
190
  *
191
+ * @deprecated Do not use in new code. For a side effect that follows reactive
192
+ * state, use `createEffect(compute, effect)` — it separates tracking from the
193
+ * side effect, knows its dependencies before it runs, and participates in
194
+ * async and transitions. For one-time DOM work after render (measuring,
195
+ * attaching third-party widgets to a ref), use `onSettled`. Tracking from
196
+ * inside the effect phase — the only thing this primitive adds — is retained
197
+ * solely to ease 1.x migration: it runs beside user-effect callbacks after
198
+ * values commit, never holds a transition, and cannot observe a write staged
199
+ * earlier in the same flush by a signal it has not read yet.
200
+ *
191
201
  * WARNING: Because tracking and effects happen in the same scope, this primitive
192
202
  * may run multiple times for a single change or show tearing (reading inconsistent
193
203
  * state). Use only when dynamic subscription patterns require same-scope tracking.
@@ -256,15 +266,15 @@ function createMemo(e, t) {
256
266
  // sources stayed live (firing the callback for replaced dependencies), each
257
267
  // accumulated arm delivered its own fire, and un-fired arms leaked as live
258
268
  // effect nodes until the owner disposed (#2861).
259
- let o;
260
- return i => {
261
- if (o) {
262
- dispose(o);
263
- o = undefined;
269
+ let i;
270
+ return o => {
271
+ if (i) {
272
+ dispose(i);
273
+ i = undefined;
264
274
  }
265
275
  runWithOwner(r, () => {
266
- effect(() => (i(), o = getOwner()), t => {
267
- o = undefined;
276
+ effect(() => (o(), i = getOwner()), t => {
277
+ i = undefined;
268
278
  n?.();
269
279
  const r = (e.effect || e)?.();
270
280
  if (false && r !== undefined && typeof r !== "function") ;
@@ -318,11 +328,11 @@ function createMemo(e, t) {
318
328
  // still runs in place (under the transaction's view when created inside
319
329
  // an action step), and status/boundary notifications keep their normal
320
330
  // route through the inherited queue.
321
- const o = getOwner();
322
- const i = new MicrotaskQueue;
323
- i.ke = o.C;
331
+ const i = getOwner();
332
+ const o = new MicrotaskQueue;
333
+ o.Le = i.C;
324
334
  // notify() forwards up the normal chain
325
- o.C = i;
335
+ i.C = o;
326
336
  // A user effect rather than a bare computed: computeds are pull-based and
327
337
  // are only re-enqueued when a pending source *resolves* — a rejection just
328
338
  // marks them errored, so nothing would re-run and the promise would never
@@ -342,7 +352,7 @@ function createMemo(e, t) {
342
352
  // stale mainline value and resolves with old data.
343
353
  {
344
354
  user: true,
345
- dt: CONFIG_DIRECT_COMMIT
355
+ At: CONFIG_DIRECT_COMMIT
346
356
  });
347
357
  });
348
358
  });
@@ -410,7 +420,14 @@ function createMemo(e, t) {
410
420
  // own eager compute is untouched: created after a refresh it still settles
411
421
  // stale-while-revalidate (#2930) — its contract is "first settled value",
412
422
  // not "next quiescent state".
413
- markRefresh(t);
423
+
424
+ // An authoritative reader is woken through a late-bound hook when the truth
425
+ // lands EQUAL to a standing override (the A17-silent path). Every setter of
426
+ // that reader bit must install it — until() does, and this waiter is the
427
+ // other one (#3303: refresh of an optimistic in an app that never called
428
+ // until() dereferenced the null hook).
429
+ installAuthoritativeRead();
430
+ markRefresh(t);
414
431
  const n = new Promise((n, r) => {
415
432
  queueMicrotask(() => {
416
433
  // No createRoot: the microtask has no ambient owner, so the effect is
@@ -423,24 +440,24 @@ function createMemo(e, t) {
423
440
  // Typed as the effect node, not Owner: the capture runs inside the
424
441
  // effect's own compute, where the ambient owner IS the effect —
425
442
  // exactly what dispose() takes.
426
- let o = null;
443
+ let i = null;
427
444
  const make = () => effect(() => {
428
- if (o === null) {
429
- o = getOwner();
445
+ if (i === null) {
446
+ i = getOwner();
430
447
  const e = new MicrotaskQueue;
431
- e.ke = o.C;
432
- o.C = e;
448
+ e.Le = i.C;
449
+ i.C = e;
433
450
  }
434
451
  return read(t);
435
452
  }, t => {
436
453
  n(typeof e === "function" ? t : e);
437
- dispose(o);
454
+ dispose(i);
438
455
  }, e => {
439
456
  r(e);
440
- dispose(o);
457
+ dispose(i);
441
458
  }, {
442
459
  user: true,
443
- dt: CONFIG_DIRECT_COMMIT | CONFIG_AUTHORITATIVE_READ | CONFIG_FRESH_READ
460
+ At: CONFIG_DIRECT_COMMIT | CONFIG_AUTHORITATIVE_READ | CONFIG_FRESH_READ
444
461
  });
445
462
  make();
446
463
  });
@@ -515,9 +532,9 @@ function createMemo(e, t) {
515
532
  // write flips it truthy, that transition merges here and reveals at the
516
533
  // joint settle instead of painting the confirmation under live optimism.
517
534
  const n = activeTransition;
518
- return new Promise((r, o) => {
519
- const i = t?.signal;
520
- if (i?.aborted) return o(i.reason);
535
+ return new Promise((r, i) => {
536
+ const o = t?.signal;
537
+ if (o?.aborted) return i(o.reason);
521
538
  createRoot(c => {
522
539
  // Same delivery contract as resolve() (#2930): effect applies ride a
523
540
  // microtask so the promise can settle while the transaction the caller
@@ -525,13 +542,13 @@ function createMemo(e, t) {
525
542
  // entire point of the hold.
526
543
  const s = getOwner();
527
544
  const u = new MicrotaskQueue;
528
- u.ke = s.C;
545
+ u.Le = s.C;
529
546
  s.C = u;
530
547
  let f;
531
548
  let a;
532
549
  const settle = e => {
533
550
  if (f !== undefined) clearTimeout(f);
534
- if (a !== undefined) i.removeEventListener("abort", a);
551
+ if (a !== undefined) o.removeEventListener("abort", a);
535
552
  e();
536
553
  c();
537
554
  };
@@ -547,7 +564,7 @@ function createMemo(e, t) {
547
564
  // Falsy is "not yet": keep the subscription live and wait for the
548
565
  // next evaluation. Only a truthy settled value resolves.
549
566
  if (e) settle(() => r(e));
550
- }, e => settle(() => o(e)),
567
+ }, e => settle(() => i(e)),
551
568
  // AUTHORITATIVE_READ: overrides invisible to the predicate.
552
569
  // DIRECT_COMMIT: truth that stages into the held transaction (a
553
570
  // refresh the action issued) must flow through to the microtask
@@ -555,12 +572,12 @@ function createMemo(e, t) {
555
572
  // the hold itself is keeping uncommitted.
556
573
  {
557
574
  user: true,
558
- dt: CONFIG_AUTHORITATIVE_READ | CONFIG_DIRECT_COMMIT
575
+ At: CONFIG_AUTHORITATIVE_READ | CONFIG_DIRECT_COMMIT
559
576
  });
560
- if (t?.timeout !== undefined) f = setTimeout(() => settle(() => o(new TimeoutError)), t.timeout);
561
- if (i !== undefined) {
562
- a = () => settle(() => o(i.reason));
563
- i.addEventListener("abort", a, {
577
+ if (t?.timeout !== undefined) f = setTimeout(() => settle(() => i(new TimeoutError)), t.timeout);
578
+ if (o !== undefined) {
579
+ a = () => settle(() => i(o.reason));
580
+ o.addEventListener("abort", a, {
564
581
  once: true
565
582
  });
566
583
  }
@@ -677,7 +694,7 @@ function createOptimistic(e, t) {
677
694
  * on owner disposal
678
695
  */ function onSettled(e) {
679
696
  const t = getOwner();
680
- t && !(t.T & CONFIG_CHILDREN_FORBIDDEN) ? createTrackedEffect(() => untrack(e), undefined) : globalQueue.enqueue(EFFECT_USER, () => {
697
+ t && !(t.T & CONFIG_CHILDREN_FORBIDDEN) ? trackedEffect(() => untrack(e), undefined) : globalQueue.enqueue(EFFECT_USER, () => {
681
698
  // Unowned, out-of-band fire (no owner, or a children-forbidden one this
682
699
  // one-shot must not bind to): a returned cleanup has no lifecycle to
683
700
  // attach to. Reject it in dev; in production the return is simply