@solidjs/signals 2.0.0-rc.13 → 2.0.0-rc.14

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 (118) hide show
  1. package/dist/dev-shared.js +2000 -3768
  2. package/dist/dev.attribution.js +132 -79
  3. package/dist/dev.js +7226 -8488
  4. package/dist/observe/affects.js +125 -104
  5. package/dist/observe/boundaries.js +458 -665
  6. package/dist/observe/core/action.js +63 -66
  7. package/dist/observe/core/async.js +240 -383
  8. package/dist/observe/core/attribution-queries.js +1 -1
  9. package/dist/observe/core/attribution.js +240 -183
  10. package/dist/observe/core/constants.js +115 -187
  11. package/dist/observe/core/context.js +3 -3
  12. package/dist/observe/core/core.js +840 -1438
  13. package/dist/observe/core/dev.js +3 -3
  14. package/dist/observe/core/effect.js +75 -86
  15. package/dist/observe/core/external.js +5 -5
  16. package/dist/observe/core/graph.js +61 -70
  17. package/dist/observe/core/heap.js +75 -98
  18. package/dist/observe/core/invariants.js +1 -34
  19. package/dist/observe/core/lanes.js +704 -181
  20. package/dist/observe/core/owner.js +80 -101
  21. package/dist/observe/core/scheduler.js +708 -1351
  22. package/dist/observe/core/verdict.js +302 -621
  23. package/dist/observe/flatten.js +79 -0
  24. package/dist/observe/index.js +15 -13
  25. package/dist/observe/map.js +232 -235
  26. package/dist/observe/reveal.js +212 -0
  27. package/dist/observe/signals.js +133 -215
  28. package/dist/observe/store/affects.js +135 -0
  29. package/dist/observe/store/index.js +29 -24
  30. package/dist/observe/store/optimistic.js +538 -0
  31. package/dist/observe/store/projection.js +302 -0
  32. package/dist/observe/store/reconcile.js +257 -0
  33. package/dist/observe/store/store.js +1945 -277
  34. package/dist/observe/store/storePath.js +1 -1
  35. package/dist/{prod/store/next → observe/store}/target.js +17 -18
  36. package/dist/observe/store/types.js +73 -0
  37. package/dist/observe/store/utils.js +1 -13
  38. package/dist/prod/affects.js +127 -106
  39. package/dist/prod/boundaries.js +442 -654
  40. package/dist/prod/core/action.js +71 -74
  41. package/dist/prod/core/async.js +307 -442
  42. package/dist/prod/core/constants.js +112 -186
  43. package/dist/prod/core/context.js +3 -3
  44. package/dist/prod/core/core.js +852 -1458
  45. package/dist/prod/core/effect.js +88 -99
  46. package/dist/prod/core/external.js +5 -5
  47. package/dist/prod/core/graph.js +61 -70
  48. package/dist/prod/core/heap.js +75 -98
  49. package/dist/prod/core/invariants.js +1 -32
  50. package/dist/prod/core/lanes.js +666 -181
  51. package/dist/prod/core/owner.js +75 -96
  52. package/dist/prod/core/scheduler.js +677 -1332
  53. package/dist/prod/core/verdict.js +297 -621
  54. package/dist/prod/flatten.js +77 -0
  55. package/dist/prod/index.js +15 -13
  56. package/dist/prod/map.js +143 -146
  57. package/dist/prod/reveal.js +212 -0
  58. package/dist/prod/signals.js +144 -226
  59. package/dist/prod/store/affects.js +135 -0
  60. package/dist/prod/store/index.js +28 -19
  61. package/dist/prod/store/optimistic.js +533 -0
  62. package/dist/prod/store/projection.js +295 -0
  63. package/dist/prod/store/reconcile.js +257 -0
  64. package/dist/prod/store/store.js +1840 -272
  65. package/dist/prod/store/storePath.js +1 -1
  66. package/dist/{observe/store/next → prod/store}/target.js +13 -17
  67. package/dist/prod/store/types.js +73 -0
  68. package/dist/prod/store/utils.js +1 -11
  69. package/dist/types/affects.d.ts +11 -30
  70. package/dist/types/boundaries.d.ts +62 -176
  71. package/dist/types/carved.d.ts +1 -0
  72. package/dist/types/core/action.d.ts +5 -6
  73. package/dist/types/core/async.d.ts +10 -5
  74. package/dist/types/core/attribution-hooks.d.ts +20 -1
  75. package/dist/types/core/attribution.d.ts +20 -9
  76. package/dist/types/core/constants.d.ts +125 -180
  77. package/dist/types/core/core.d.ts +104 -264
  78. package/dist/types/core/dev.d.ts +2 -2
  79. package/dist/types/core/effect.d.ts +0 -7
  80. package/dist/types/core/graph.d.ts +7 -1
  81. package/dist/types/core/heap.d.ts +5 -7
  82. package/dist/types/core/index.d.ts +5 -5
  83. package/dist/types/core/invariants.d.ts +0 -29
  84. package/dist/types/core/lanes.d.ts +65 -87
  85. package/dist/types/core/owner.d.ts +3 -3
  86. package/dist/types/core/scheduler.d.ts +249 -331
  87. package/dist/types/core/types.d.ts +51 -85
  88. package/dist/types/core/verdict.d.ts +3 -0
  89. package/dist/types/flatten.d.ts +8 -0
  90. package/dist/types/index.d.ts +6 -4
  91. package/dist/types/reveal.d.ts +19 -0
  92. package/dist/types/signals.d.ts +35 -91
  93. package/dist/types/store/affects.d.ts +1 -0
  94. package/dist/types/store/index.d.ts +35 -15
  95. package/dist/types/store/optimistic.d.ts +23 -0
  96. package/dist/types/store/projection.d.ts +18 -0
  97. package/dist/types/store/reconcile.d.ts +3 -0
  98. package/dist/types/store/store.d.ts +165 -143
  99. package/dist/types/store/storePath.d.ts +1 -1
  100. package/dist/types/store/target.d.ts +151 -0
  101. package/dist/types/store/types.d.ts +84 -0
  102. package/package.json +1 -1
  103. package/dist/observe/core/optimistic.js +0 -669
  104. package/dist/observe/store/next/optimistic.js +0 -717
  105. package/dist/observe/store/next/projection.js +0 -266
  106. package/dist/observe/store/next/reconcile.js +0 -375
  107. package/dist/observe/store/next/store.js +0 -2608
  108. package/dist/prod/core/optimistic.js +0 -658
  109. package/dist/prod/store/next/optimistic.js +0 -710
  110. package/dist/prod/store/next/projection.js +0 -257
  111. package/dist/prod/store/next/reconcile.js +0 -373
  112. package/dist/prod/store/next/store.js +0 -2484
  113. package/dist/types/core/optimistic.d.ts +0 -6
  114. package/dist/types/store/next/optimistic.d.ts +0 -25
  115. package/dist/types/store/next/projection.d.ts +0 -27
  116. package/dist/types/store/next/reconcile.d.ts +0 -10
  117. package/dist/types/store/next/store.d.ts +0 -145
  118. package/dist/types/store/next/target.d.ts +0 -196
@@ -1,129 +1,150 @@
1
- import { forEachDependent } from "./core/async.js";
1
+ import { $REFRESH, CONFIG_VERDICT, STATUS_PENDING, CONFIG_SLOT_NODE, STATUS_ERROR, REACTIVE_RECOMPUTING_DEPS } from "./core/constants.js";
2
2
 
3
- import { ext, statusNotifierOf } from "./core/core.js";
4
-
5
- import { $REFRESH, STATUS_PENDING } from "./core/constants.js";
3
+ import { ext } from "./core/core.js";
6
4
 
7
5
  import "./core/dev.js";
8
6
 
9
- import { NotReadyError } from "./core/error.js";
10
-
11
- import { GlobalQueue, globalQueue, schedule, shiftAffectsMarks } from "./core/scheduler.js";
12
-
13
- import "./core/verdict.js";
14
-
15
- import "./core/effect.js";
16
-
17
- import "./core/invariants.js";
18
-
19
- import { $TARGET, getStoreAffectsNodes } from "./store/store.js";
7
+ import { enqueueSub } from "./core/heap.js";
8
+
9
+ import { GlobalQueue, schedule, resolveTx, flushTransaction } from "./core/scheduler.js";
10
+
11
+ import { $TARGET } from "./store/types.js";
12
+
13
+ // `affects()` — the declaration verb of the pending model (A24 (4), ruled
14
+ // 2026-07-13; the #2893 audit corollaries; rebuilt on L2 2026-10-02 as ruled:
15
+ // transaction-inert).
16
+ // A mark is a declared in-flight change: the marked node — and everything
17
+ // derived from it — reads pending (`isPending` → true) from the declaration
18
+ // until the surrounding transaction lands (an ambient mark, declared outside
19
+ // one, releases at the next seam). The marked values stay readable: no reader
20
+ // suspends on a mark, a mark holds nothing and entangles nothing — it is not
21
+ // a node of its transaction (`blocked` never sees it), and a reader of marked
22
+ // data joins nothing through it. A mark is never a re-ask, so a declared
23
+ // reload's own `refresh()` cannot silence it; a real error outranks it.
24
+ // Representation: a count on the marked node (`_x._marks`), listed with its
25
+ // scope (the transaction's `_marks`, or the ambient list). Coverage of the
26
+ // derivations is pull-derived at probe time — `isPending`'s read walks the
27
+ // probed node's dependencies for a marked one (verdict.ts → `_marked`) — so
28
+ // nothing is stored downstream and a mid-window recompute strands nothing.
29
+ // The push half is the verdict readers' re-derivation at registration and at
30
+ // release (`repoll`): the only notification a mark makes.
31
+ // Installed on `GlobalQueue` when imported: a program that never declares a
32
+ // mark carries none of this.
33
+ /** Live marks, every scope — the gate on the probe's walk. */
34
+ let active = 0;
35
+
36
+ /** Marks declared outside a transaction: released at the next seam. */ const ambient = [];
37
+
38
+ /** The verdict readers downstream of `node` — through derivations, stopping
39
+ * at effects — re-derive: the mark's one notification (a probe's answer
40
+ * changed with no value notifying anyone). */ function repoll(e, t = new Set) {
41
+ for (let n = e.t; n !== null; n = n.l) {
42
+ const e = n.o;
43
+ if (t.has(e)) continue;
44
+ t.add(e);
45
+ if (e.u & CONFIG_VERDICT) enqueueSub(e);
46
+ if (!e.i) repoll(e, t);
47
+ }
48
+ }
20
49
 
21
- /**
22
- * The counting half of a mark, shared by direct registration and store-scope
23
- * inheritance (a node created inside a live keyless mark's identity scope).
24
- * A mark is ONLY this count: coverage of everything derived from the node is
25
- * pull-derived by the verdict layer's `markWalk` (dep-graph reachability), so
26
- * nothing is stored downstream and nothing can be stranded or stripped by
27
- * mid-window recomputes.
28
- */ function markAffects(e) {
29
- ext(e).t = (e.o?.t || 0) + 1;
30
- shiftAffectsMarks(1);
50
+ /** A node is covered by a live mark iff it carries one, or derives — through
51
+ * its current dependencies — from one that does. A real error outranks an
52
+ * inherited mark (A24 (c)): coverage does not flow through an errored node
53
+ * (a direct mark on one still reads pending). Mid-recompute, only the
54
+ * validated prefix of the dependency list is this pass's. */ function marked(e, t) {
55
+ if (e.m !== null && e.m.T !== 0) return true;
56
+ const n = e;
57
+ if (n.G & STATUS_ERROR || t.has(e)) return false;
58
+ t.add(e);
59
+ const r = n.R & REACTIVE_RECOMPUTING_DEPS ? n.S : undefined;
60
+ if (r !== null) for (let e = n._ ?? null; e !== null; e = e.p) {
61
+ if (marked(e.I, t)) return true;
62
+ if (e === r) break;
63
+ }
64
+ return false;
31
65
  }
32
66
 
33
- /**
34
- * Boundary visual channel: within a transaction, a live mark holds Loading
35
- * fallbacks / reveal ordering the way real in-flight async would — but the
36
- * notification is tagged visibility-only at the source (`_markVisual`), so
37
- * the root queue never registers reporters from it: marks are invisible to
38
- * ALL completion and settlement accounting by construction. Boundaries hold
39
- * the marked node in `_sources` while `_affectsCount` is live; the release
40
- * sweep (finalizePureQueue re-checks boundary children after mark release)
41
- * is the display-state update point. Ambient marks release inside the same
42
- * flush that would surface them, before effects run — verdict-only, netting
43
- * no visual change.
44
- */ function notifyMarkBoundaries(e) {
45
- if (!e.u && !e.o?.i) return;
46
- const r = new NotReadyError(e);
47
- r.l = true;
48
- const t = new Set;
49
- const visit = e => {
50
- if (t.has(e)) return;
51
- t.add(e);
52
- // Display consumers (render effects, boundary computeds) act on the
53
- // notification; descent stops there, exactly like the status rails.
54
- const o = statusNotifierOf(e);
55
- if (o) {
56
- o.call(e, STATUS_PENDING, r);
57
- return;
67
+ /** Releases one scope's marks (a landed transaction's, the ambient list at
68
+ * the seam): a node whose last mark drops re-derives its verdict readers. */ function release(e) {
69
+ for (let t = 0; t < e.length; t++) {
70
+ const n = e[t];
71
+ active--;
72
+ if (--n.m.T === 0) {
73
+ repoll(n);
74
+ // A store mark's carrier: its scope (and the marks the nodes born in
75
+ // its window inherited) goes with it.
76
+ GlobalQueue.N?.(n);
58
77
  }
59
- forEachDependent(e, visit);
60
- };
61
- forEachDependent(e, visit);
78
+ }
79
+ e.length = 0;
62
80
  }
63
81
 
64
- /**
65
- * Registers one `affects()` mark on a node: counts it, records the
66
- * registration with the current transaction (after initTransition the queue's
67
- * batch IS the active transition, mirroring `_optimisticNodes`), re-derives
68
- * every downstream verdict companion (the mark channel's only push — verdict
69
- * pokes, not state), and notifies boundary display state. Both walks run on
70
- * every registration (not just the first): subscribers gained since an
71
- * earlier overlapping registration get covered, and dedup stops re-descent.
72
- */ function registerAffectsMark(e) {
73
- markAffects(e);
74
- globalQueue.m.A.push(e);
75
- // Companions only exist once the verdict layer (isPending/latest) loaded;
76
- // without them there is no materialized verdict to poke.
77
- GlobalQueue.k !== null && GlobalQueue.k(e);
78
- notifyMarkBoundaries(e);
79
- schedule();
82
+ /** One registration: a count on the node, listed with the scope — the
83
+ * flush's transaction, or the ambient list (released at the seam). */ function register(e) {
84
+ mark(e);
85
+ const t = flushTransaction;
86
+ if (t === null) ambient.push(e); else {
87
+ const n = resolveTx(t);
88
+ (n.T ??= []).push(e);
89
+ }
90
+ repoll(e);
80
91
  }
81
92
 
82
- /**
83
- * Releases one registration. When the node's last mark drops, re-derives
84
- * every downstream verdict through the settlement snap (committed, not
85
- * transition-scoped — release runs inside queue finalization, where a
86
- * setSignal would open a fresh override window that nothing settles).
87
- */ function releaseAffectsMark(e) {
88
- shiftAffectsMarks(-1);
89
- e.o.t--;
90
- if (!e.o.t) {
91
- GlobalQueue.k !== null && GlobalQueue.k(e, true);
92
- GlobalQueue.p?.(e);
93
- }
93
+ function mark(e) {
94
+ ext(e).T++;
95
+ active++;
94
96
  }
95
97
 
96
- /**
97
- * Releases one batch of affects marks (a settling transaction's, or the
98
- * ambient batch at a plain flush end).
99
- */ function releaseAffectsMarks(e) {
100
- for (let r = 0; r < e.length; r++) releaseAffectsMark(e[r]);
101
- e.length = 0;
98
+ function affects(e, t) {
99
+ // A store (the store half, store/affects.ts): the slot's leaf, or the
100
+ // record's carrier and every live node under it.
101
+ const n = e?.[$TARGET];
102
+ if (n !== undefined) {
103
+ const e = GlobalQueue.O(n, t);
104
+ for (let t = 0; t < e.length; t++) register(e[t]);
105
+ schedule();
106
+ return;
107
+ }
108
+ const r = e?.[$REFRESH];
109
+ if (!r) {
110
+ return;
111
+ }
112
+ register(r);
113
+ schedule();
102
114
  }
103
115
 
104
- // Late installation (same pattern as `GlobalQueue._update`): the mark engine
105
- // lives with the feature so graphs that never declare a mark never ship it.
106
- // Each call site is gated by state only this module creates (a non-empty
107
- // `_affectsNodes` batch, a live scope in the store's `affectsScopes`), so the
108
- // hooks are installed before the first time any of them can fire.
109
- GlobalQueue.G = releaseAffectsMarks;
116
+ GlobalQueue.C = e => active !== 0 && marked(e, new Set);
110
117
 
111
- GlobalQueue.M = markAffects;
118
+ GlobalQueue.h = mark;
112
119
 
113
- GlobalQueue.j = releaseAffectsMark;
120
+ GlobalQueue.A = release;
114
121
 
115
- function affects(e, r) {
116
- const t = e?.[$TARGET];
117
- if (t) {
118
- const e = getStoreAffectsNodes(t, r);
119
- for (let r = 0; r < e.length; r++) registerAffectsMark(e[r]);
122
+ GlobalQueue.D = e => {
123
+ if (ambient.length === 0) return;
124
+ // The flush parked: the declaration's window is the frame's — the marks
125
+ // are its transaction's ("nothing async below ⇒ no window").
126
+ if (e !== null) {
127
+ const t = e.T ??= [];
128
+ for (let e = 0; e < ambient.length; e++) t.push(ambient[e]);
129
+ ambient.length = 0;
120
130
  return;
121
131
  }
122
- const o = e?.[$REFRESH];
123
- if (o) {
124
- registerAffectsMark(o);
125
- return;
132
+ // Nothing parked, but a marked node's own flight is up (a declared
133
+ // reload's quiet re-ask — the node's, or a store leaf's family derive):
134
+ // the window is the flight's; the mark stays to the seam after the
135
+ // landing. The rest release: verdict-only, nothing to show.
136
+ let t = 0;
137
+ const n = [];
138
+ for (let e = 0; e < ambient.length; e++) {
139
+ const r = ambient[e];
140
+ if (inFlight(r)) ambient[t++] = r; else n.push(r);
126
141
  }
142
+ ambient.length = t;
143
+ if (n.length !== 0) release(n);
144
+ };
145
+
146
+ function inFlight(e) {
147
+ return (e.G & STATUS_PENDING) !== 0 || (e.u & CONFIG_SLOT_NODE) !== 0 && GlobalQueue.F?.(e) === true;
127
148
  }
128
149
 
129
150
  export { affects };