@solidjs/signals 2.0.0-rc.2 → 2.0.0-rc.20

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 (198) hide show
  1. package/dist/dev-shared.js +6505 -0
  2. package/dist/dev.attribution.js +3484 -0
  3. package/dist/dev.js +10227 -9508
  4. package/dist/observe/affects-marks.js +86 -0
  5. package/dist/observe/affects.js +112 -0
  6. package/dist/observe/attribution.js +7 -0
  7. package/dist/observe/boundaries.js +696 -0
  8. package/dist/observe/core/action.js +182 -0
  9. package/dist/observe/core/async.js +824 -0
  10. package/dist/observe/core/attribution-costs.js +66 -0
  11. package/dist/observe/core/attribution-feedback.js +280 -0
  12. package/dist/observe/core/attribution-hooks.js +83 -0
  13. package/dist/observe/core/attribution-queries.js +43 -0
  14. package/dist/observe/core/attribution.js +3079 -0
  15. package/dist/observe/core/constants.js +269 -0
  16. package/dist/observe/core/context.js +63 -0
  17. package/dist/observe/core/copies.js +10 -0
  18. package/dist/observe/core/core.js +1707 -0
  19. package/dist/observe/core/dev.js +394 -0
  20. package/dist/observe/core/effect.js +193 -0
  21. package/dist/observe/core/error-hooks.js +71 -0
  22. package/dist/observe/core/error.js +82 -0
  23. package/dist/observe/core/external.js +97 -0
  24. package/dist/observe/core/graph.js +162 -0
  25. package/dist/observe/core/heap.js +124 -0
  26. package/dist/observe/core/identities.js +62 -0
  27. package/dist/observe/core/invariants.js +12 -0
  28. package/dist/observe/core/lanes.js +972 -0
  29. package/dist/observe/core/owner.js +371 -0
  30. package/dist/observe/core/scheduler.js +1157 -0
  31. package/dist/observe/core/truth.js +47 -0
  32. package/dist/observe/core/verdict.js +470 -0
  33. package/dist/observe/deferred.js +186 -0
  34. package/dist/observe/flatten.js +79 -0
  35. package/dist/observe/from.js +248 -0
  36. package/dist/observe/index.js +71 -0
  37. package/dist/observe/map.js +593 -0
  38. package/dist/observe/reveal.js +212 -0
  39. package/dist/observe/signals.js +717 -0
  40. package/dist/observe/store/affects.js +142 -0
  41. package/dist/observe/store/edges.js +39 -0
  42. package/dist/observe/store/hooks.js +16 -0
  43. package/dist/observe/store/index.js +47 -0
  44. package/dist/observe/store/optimistic.js +713 -0
  45. package/dist/observe/store/projection.js +345 -0
  46. package/dist/observe/store/reconcile.js +281 -0
  47. package/dist/observe/store/store.js +2127 -0
  48. package/dist/observe/store/storePath.js +103 -0
  49. package/dist/observe/store/target.js +46 -0
  50. package/dist/observe/store/types.js +83 -0
  51. package/dist/observe/store/utils.js +1063 -0
  52. package/dist/prod/affects-marks.js +86 -0
  53. package/dist/prod/affects.js +98 -112
  54. package/dist/prod/attribution.js +45 -0
  55. package/dist/prod/boundaries.js +578 -468
  56. package/dist/prod/core/action.js +92 -59
  57. package/dist/prod/core/async.js +522 -336
  58. package/dist/prod/core/attribution-hooks.js +3 -0
  59. package/dist/prod/core/constants.js +168 -44
  60. package/dist/prod/core/context.js +12 -16
  61. package/dist/prod/core/copies.js +10 -0
  62. package/dist/prod/core/core.js +1345 -627
  63. package/dist/prod/core/dev.js +123 -1
  64. package/dist/prod/core/effect.js +113 -80
  65. package/dist/prod/core/error-hooks.js +71 -0
  66. package/dist/prod/core/error.js +18 -4
  67. package/dist/prod/core/external.js +6 -7
  68. package/dist/prod/core/graph.js +119 -72
  69. package/dist/prod/core/heap.js +85 -109
  70. package/dist/prod/core/identities.js +62 -0
  71. package/dist/prod/core/invariants.js +1 -32
  72. package/dist/prod/core/lanes.js +931 -132
  73. package/dist/prod/core/owner.js +192 -129
  74. package/dist/prod/core/scheduler.js +948 -642
  75. package/dist/prod/core/truth.js +47 -0
  76. package/dist/prod/core/verdict.js +409 -420
  77. package/dist/prod/deferred.js +184 -0
  78. package/dist/prod/flatten.js +77 -0
  79. package/dist/prod/from.js +248 -0
  80. package/dist/prod/index.js +40 -16
  81. package/dist/prod/map.js +481 -211
  82. package/dist/prod/reveal.js +212 -0
  83. package/dist/prod/signals.js +401 -84
  84. package/dist/prod/store/affects.js +142 -0
  85. package/dist/prod/store/edges.js +39 -0
  86. package/dist/prod/store/hooks.js +16 -0
  87. package/dist/prod/store/index.js +27 -18
  88. package/dist/prod/store/optimistic.js +707 -0
  89. package/dist/prod/store/projection.js +331 -0
  90. package/dist/prod/store/reconcile.js +281 -0
  91. package/dist/prod/store/store.js +1952 -267
  92. package/dist/prod/store/storePath.js +1 -1
  93. package/dist/prod/store/target.js +43 -0
  94. package/dist/prod/store/types.js +83 -0
  95. package/dist/prod/store/utils.js +997 -138
  96. package/dist/types/affects-marks.d.ts +14 -0
  97. package/dist/types/affects.d.ts +12 -30
  98. package/dist/types/attribution.d.ts +19 -0
  99. package/dist/types/attribution.prod.d.ts +22 -0
  100. package/dist/types/boundaries.d.ts +99 -124
  101. package/dist/types/carved.d.ts +1 -0
  102. package/dist/types/core/action.d.ts +23 -9
  103. package/dist/types/core/async.d.ts +34 -6
  104. package/dist/types/core/attribution-costs.d.ts +35 -0
  105. package/dist/types/core/attribution-feedback.d.ts +133 -0
  106. package/dist/types/core/attribution-hooks.d.ts +307 -8
  107. package/dist/types/core/attribution-queries.d.ts +24 -0
  108. package/dist/types/core/attribution.d.ts +802 -72
  109. package/dist/types/core/constants.d.ts +195 -38
  110. package/dist/types/core/copies.d.ts +54 -0
  111. package/dist/types/core/core.d.ts +295 -65
  112. package/dist/types/core/dev.d.ts +509 -22
  113. package/dist/types/core/effect.d.ts +1 -1
  114. package/dist/types/core/error-hooks.d.ts +71 -0
  115. package/dist/types/core/error.d.ts +18 -1
  116. package/dist/types/core/graph.d.ts +40 -1
  117. package/dist/types/core/heap.d.ts +5 -5
  118. package/dist/types/core/identities.d.ts +17 -0
  119. package/dist/types/core/index.d.ts +11 -7
  120. package/dist/types/core/invariants.d.ts +1 -26
  121. package/dist/types/core/lanes.d.ts +74 -43
  122. package/dist/types/core/owner.d.ts +27 -9
  123. package/dist/types/core/scheduler.d.ts +353 -102
  124. package/dist/types/core/truth.d.ts +18 -0
  125. package/dist/types/core/types.d.ts +97 -71
  126. package/dist/types/core/verdict.d.ts +35 -0
  127. package/dist/types/deferred.d.ts +28 -0
  128. package/dist/types/flatten.d.ts +8 -0
  129. package/dist/types/from.d.ts +47 -0
  130. package/dist/types/index.d.ts +33 -7
  131. package/dist/types/map.d.ts +4 -2
  132. package/dist/types/reveal.d.ts +19 -0
  133. package/dist/types/signals.d.ts +196 -45
  134. package/dist/types/store/affects.d.ts +12 -0
  135. package/dist/types/store/edges.d.ts +9 -0
  136. package/dist/types/store/hooks.d.ts +62 -0
  137. package/dist/types/store/index.d.ts +42 -15
  138. package/dist/types/store/optimistic.d.ts +24 -45
  139. package/dist/types/store/projection.d.ts +17 -68
  140. package/dist/types/store/reconcile.d.ts +3 -46
  141. package/dist/types/store/store.d.ts +133 -136
  142. package/dist/types/store/storePath.d.ts +1 -1
  143. package/dist/types/store/target.d.ts +166 -0
  144. package/dist/types/store/types.d.ts +105 -0
  145. package/dist/types/store/utils.d.ts +188 -0
  146. package/package.json +31 -26
  147. package/dist/node.cjs +0 -8745
  148. package/dist/prod/core/optimistic.js +0 -265
  149. package/dist/prod/store/next/optimistic.js +0 -385
  150. package/dist/prod/store/next/projection.js +0 -172
  151. package/dist/prod/store/next/reconcile.js +0 -331
  152. package/dist/prod/store/next/store.js +0 -1499
  153. package/dist/prod/store/next/target.js +0 -20
  154. package/dist/types/core/optimistic.d.ts +0 -6
  155. package/dist/types/store/next/optimistic.d.ts +0 -20
  156. package/dist/types/store/next/projection.d.ts +0 -8
  157. package/dist/types/store/next/reconcile.d.ts +0 -3
  158. package/dist/types/store/next/store.d.ts +0 -77
  159. package/dist/types/store/next/target.d.ts +0 -117
  160. package/dist/types-cjs/affects.d.cts +0 -47
  161. package/dist/types-cjs/boundaries.d.cts +0 -175
  162. package/dist/types-cjs/core/action.d.cts +0 -64
  163. package/dist/types-cjs/core/async.d.cts +0 -21
  164. package/dist/types-cjs/core/attribution-hooks.d.cts +0 -52
  165. package/dist/types-cjs/core/attribution.d.cts +0 -186
  166. package/dist/types-cjs/core/constants.d.cts +0 -97
  167. package/dist/types-cjs/core/context.d.cts +0 -36
  168. package/dist/types-cjs/core/core.d.cts +0 -163
  169. package/dist/types-cjs/core/dev.d.cts +0 -81
  170. package/dist/types-cjs/core/effect.d.cts +0 -30
  171. package/dist/types-cjs/core/error.d.cts +0 -47
  172. package/dist/types-cjs/core/external.d.cts +0 -15
  173. package/dist/types-cjs/core/graph.d.cts +0 -6
  174. package/dist/types-cjs/core/heap.d.cts +0 -22
  175. package/dist/types-cjs/core/index.d.cts +0 -13
  176. package/dist/types-cjs/core/invariants.d.cts +0 -59
  177. package/dist/types-cjs/core/lanes.d.cts +0 -44
  178. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  179. package/dist/types-cjs/core/owner.d.cts +0 -124
  180. package/dist/types-cjs/core/scheduler.d.cts +0 -180
  181. package/dist/types-cjs/core/types.d.cts +0 -192
  182. package/dist/types-cjs/core/verdict.d.cts +0 -2
  183. package/dist/types-cjs/index.d.cts +0 -10
  184. package/dist/types-cjs/map.d.cts +0 -69
  185. package/dist/types-cjs/package.json +0 -3
  186. package/dist/types-cjs/signals.d.cts +0 -624
  187. package/dist/types-cjs/store/index.d.cts +0 -19
  188. package/dist/types-cjs/store/next/optimistic.d.cts +0 -20
  189. package/dist/types-cjs/store/next/projection.d.cts +0 -8
  190. package/dist/types-cjs/store/next/reconcile.d.cts +0 -3
  191. package/dist/types-cjs/store/next/store.d.cts +0 -77
  192. package/dist/types-cjs/store/next/target.d.cts +0 -117
  193. package/dist/types-cjs/store/optimistic.d.cts +0 -45
  194. package/dist/types-cjs/store/projection.d.cts +0 -70
  195. package/dist/types-cjs/store/reconcile.d.cts +0 -46
  196. package/dist/types-cjs/store/store.d.cts +0 -138
  197. package/dist/types-cjs/store/storePath.d.cts +0 -58
  198. package/dist/types-cjs/store/utils.d.cts +0 -74
package/dist/prod/map.js CHANGED
@@ -1,220 +1,492 @@
1
1
  import { computed, runWithOwner, signal, setSignal } from "./core/core.js";
2
2
 
3
- import { createOwner } from "./core/owner.js";
4
-
5
- import "./core/scheduler.js";
3
+ import "./core/verdict.js";
6
4
 
7
5
  import { CONFIG_AUTO_DISPOSE } from "./core/constants.js";
8
6
 
9
- import "./core/invariants.js";
7
+ import { attrHooks } from "./core/attribution-hooks.js";
10
8
 
11
- import "./core/verdict.js";
9
+ import "./core/scheduler.js";
10
+
11
+ import { createOwner, getOwner } from "./core/owner.js";
12
12
 
13
13
  import "./core/effect.js";
14
14
 
15
15
  import { accessor } from "./signals.js";
16
16
 
17
- import { $TRACK } from "./store/store.js";
18
-
19
- import "./store/next/store.js";
17
+ import { $TRACK, shallowView, $TARGET } from "./store/types.js";
20
18
 
21
- function mapArray(t, s, i) {
22
- const e = typeof i?.keyed === "function" ? i.keyed : undefined;
23
- const r = s.length > 1;
24
- const n = s;
25
- const h = {
26
- jt: createOwner(),
27
- Wt: 0,
28
- xt: t,
29
- Kt: [],
30
- $t: n,
31
- qt: [],
32
- zt: [],
33
- Jt: e,
34
- Xt: e || i?.keyed === false ? [] : undefined,
35
- Yt: r && i?.keyed !== false ? [] : undefined,
36
- Zt: i?.keyed === false,
37
- ts: i?.fallback
19
+ function mapArray(t, e, i) {
20
+ const s = typeof i?.keyed === "function" ? i.keyed : undefined;
21
+ const n = e.length > 1;
22
+ const r = e;
23
+ const o = {
24
+ H: createOwner(),
25
+ it: 0,
26
+ st: t,
27
+ ot: [],
28
+ ft: r,
29
+ ht: [],
30
+ tn: [],
31
+ Xe: s,
32
+ ct: s || i?.keyed === false ? [] : undefined,
33
+ lt: n && i?.keyed !== false ? [] : undefined,
34
+ ut: i?.keyed === false,
35
+ L: i?.fallback
38
36
  };
39
- const o = computed(updateKeyedMap.bind(h));
40
- // Untracked reads inside the internal owner resolve via _parentComputed; routing
41
- // them through node lets store-proxy lookups see pending writes (not stale _value).
42
- h.jt.Ot = o;
43
- o.T &= ~CONFIG_AUTO_DISPOSE;
44
- return accessor(o);
37
+ const f = computed(updateKeyedMap.bind(o), undefined);
38
+ f.l &= ~CONFIG_AUTO_DISPOSE;
39
+ return accessor(f);
45
40
  }
46
41
 
47
42
  const pureOptions = {
48
43
  ownedWrite: true
49
44
  };
50
45
 
51
- // Exception safety (#2903): a map callback can throw NotReadyError mid-pass
52
- // (async read), and the computed re-runs the whole pass after settle. Every
53
- // pass therefore STAGES its work — new rows are created into temp arrays and
54
- // removals are deferred — and commits to `this` only after every mapper
55
- // succeeded. An aborted pass disposes just the owners it created and leaves
56
- // `_items`/`_mappings`/`_nodes`/`_rows`/`_indexes`/`_len` exactly as they
57
- // were, so the retry diffs against uncorrupted state. Consequence of the
58
- // strong-abort ordering: removed rows now dispose AFTER the pass's new rows
59
- // are created (you cannot destroy state before knowing the pass will land).
46
+ function trySmallMove(t, e, i, s) {
47
+ const n = t.ot;
48
+ const r = t.it - 1;
49
+ const o = [];
50
+ const f = [];
51
+ const h = [];
52
+ // flat triples: oldStart, newStart, length
53
+ let c = 256;
54
+ let a = s;
55
+ let l = s;
56
+ let u = false;
57
+ while (a <= r && l <= i - 1) {
58
+ const t = n[a];
59
+ const s = e[l];
60
+ if (t === s) {
61
+ if (!u) {
62
+ h.push(a, l, 0);
63
+ u = true;
64
+ }
65
+ h[h.length - 1]++;
66
+ a++;
67
+ l++;
68
+ continue;
69
+ }
70
+ u = false;
71
+ // Bounded realignment lookahead, shorter distance wins.
72
+ let w = -1;
73
+ let d = Math.min(32 - o.length, r - a, c);
74
+ for (let t = 1; t <= d; t++) {
75
+ if (n[a + t] === s) {
76
+ w = t;
77
+ break;
78
+ }
79
+ }
80
+ c -= w === -1 ? d : w;
81
+ let p = -1;
82
+ d = Math.min(32 - f.length, i - 1 - l, c);
83
+ for (let i = 1; i <= d; i++) {
84
+ if (e[l + i] === t) {
85
+ p = i;
86
+ break;
87
+ }
88
+ }
89
+ c -= p === -1 ? d : p;
90
+ if (w !== -1 && (p === -1 || w <= p)) {
91
+ while (w-- > 0) o.push(a++);
92
+ continue;
93
+ }
94
+ if (p !== -1) {
95
+ while (p-- > 0) f.push(l++);
96
+ continue;
97
+ }
98
+ if (c <= 0 || o.length === 32 || f.length === 32) return false;
99
+ o.push(a++);
100
+ f.push(l++);
101
+ }
102
+ for (;a <= r; a++) {
103
+ if (o.length === 32) return false;
104
+ o.push(a);
105
+ }
106
+ for (;l <= i - 1; l++) {
107
+ if (f.length === 32) return false;
108
+ f.push(l);
109
+ }
110
+ return commitSmallMove(t, e, i, o, f, h);
111
+ }
112
+
113
+ /** PHASE 2 of the small-move path, in its OWN function so that a pass which
114
+ * only SCANS and bails (a full replace: the first structural pass of a page,
115
+ * typically) compiles nothing but the scan — V8 parses and compiles lazily
116
+ * per function, and cold `replace` measured +0.5 ms with both phases in one
117
+ * body. Pairs displaced sources with destinations (an unmatched destination
118
+ * is a replacement/insertion → general path), then commits: slice() the live
119
+ * arrays, copy shifted runs, patch displaced pairs, dispose leftovers. */ function commitSmallMove(t, e, i, s, n, r) {
120
+ const o = t.ot;
121
+ let f;
122
+ let h;
123
+ let c;
124
+ if (n.length !== 0) {
125
+ c = new Array(s.length);
126
+ for (h = 0; h < n.length; h++) {
127
+ let t = -1;
128
+ for (f = 0; f < s.length; f++) {
129
+ if (!c[f] && o[s[f]] === e[n[h]]) {
130
+ t = f;
131
+ break;
132
+ }
133
+ }
134
+ if (t === -1) return false;
135
+ c[t] = true;
136
+ n[h] = n[h] << 6 | t;
137
+ // pack pairing (found < 32)
138
+ }
139
+ }
140
+ // DUPLICATES: the general path pairs equal identities by OCCURRENCE ORDER
141
+ // (the chained index map). Displaced↔displaced pairing above is ascending
142
+ // on both sides, so it agrees; but an aligned run was matched by POSITION,
143
+ // and if a displaced identity also occurs inside a run the two algorithms
144
+ // can hand different occurrences different owners (row-local state moves;
145
+ // a shrink could dispose the wrong one). Decline that case — general path.
146
+ if (s.length !== 0 || n.length !== 0) {
147
+ const t = new Set;
148
+ for (f = 0; f < s.length; f++) t.add(o[s[f]]);
149
+ for (h = 0; h < n.length; h++) t.add(e[n[h] >> 6]);
150
+ for (let e = 0; e < r.length; e += 3) {
151
+ const i = r[e];
152
+ for (let s = 0, n = r[e + 2]; s < n; s++) if (t.has(o[i + s])) return false;
153
+ }
154
+ }
155
+ const a = t.ht;
156
+ const l = t.tn;
157
+ const u = a.slice(0, i);
158
+ const w = l.slice(0, i);
159
+ for (let t = 0; t < r.length; t += 3) {
160
+ const e = r[t];
161
+ const i = r[t + 1];
162
+ if (e !== i) {
163
+ for (let s = 0; s < r[t + 2]; s++) {
164
+ u[i + s] = a[e + s];
165
+ w[i + s] = l[e + s];
166
+ }
167
+ }
168
+ }
169
+ for (h = 0; h < n.length; h++) {
170
+ const t = n[h] >> 6;
171
+ const e = s[n[h] & 63];
172
+ u[t] = a[e];
173
+ w[t] = l[e];
174
+ }
175
+ t.ht = u;
176
+ t.tn = w;
177
+ t.it = i;
178
+ t.ot = e.slice(0);
179
+ // Dispose unmatched sources LAST (general-path ordering).
180
+ for (f = 0; f < s.length; f++) {
181
+ if (c === undefined || !c[f]) l[s[f]].dispose();
182
+ }
183
+ return true;
184
+ }
185
+
186
+ /** Stage a PURE REMOVAL without the key map: when the new window is the old
187
+ * window with items dropped, in order (one-item removals, every-nth, the
188
+ * table filters), a two-pointer walk lands every survivor in the window
189
+ * stage with one key call per item and returns the leavers; a shape that is
190
+ * not an ordered subsequence returns null with the node stage cleared, and
191
+ * the map path below starts from scratch (it rewrites every window slot of
192
+ * `temp` / `rows` / `indexes`, so only `tempNodes`' `!== undefined` probe
193
+ * needs the reset). The stage arrays are scratch — nothing live is touched. */ function stageRemoval(t, e, i, s, n, r, o, f, h) {
194
+ const c = t.Xe;
195
+ const a = t.ot;
196
+ const l = t.tn;
197
+ const u = [];
198
+ let w = i;
199
+ for (let d = i; d <= n; w++, d++) {
200
+ const n = c ? c(e[d]) : e[d];
201
+ while (w <= s && (c ? c(a[w]) : a[w]) !== n) u.push(l[w++]);
202
+ if (w > s) {
203
+ o.fill(undefined);
204
+ return null;
205
+ }
206
+ r[d] = t.ht[w];
207
+ o[d - i] = l[w];
208
+ if (f) f[d - i] = t.ct[w];
209
+ if (h) h[d - i] = t.lt[w];
210
+ }
211
+ for (;w <= s; w++) u.push(l[w]);
212
+ return u;
213
+ }
214
+
215
+ /** Land a staged window into the live bookkeeping arrays in place: shift the
216
+ * suffix by `dif` (a loop walked from the side that never overwrites an
217
+ * unread slot), take the window from the stage, write survivors' row and
218
+ * index signals. Its own function so the general path's body stays under
219
+ * the JIT's optimization budget — the inlined commit measured ~10% slower on
220
+ * full-window reorders (the small-move note has the same finding). */ function commitWindow(t, e, i, s, n, r, o, f, h) {
221
+ const c = t.tn;
222
+ const a = t.ct;
223
+ const l = t.lt;
224
+ const u = t.it;
225
+ const w = i - u;
226
+ let d, p;
227
+ if (w > 0) {
228
+ // Grow first: a store past the end from the top is a third slower than
229
+ // filling a pre-sized tail (measured on 1k refs, 2026-10-15).
230
+ c.length = i;
231
+ if (a) a.length = i;
232
+ if (l) l.length = i;
233
+ for (d = u - 1, p = i - 1; d > n; d--, p--) {
234
+ c[p] = c[d];
235
+ if (a) a[p] = a[d];
236
+ if (l) l[p] = l[d];
237
+ }
238
+ } else if (w < 0) {
239
+ for (d = n + 1, p = r + 1; d < u; d++, p++) {
240
+ c[p] = c[d];
241
+ if (a) a[p] = a[d];
242
+ if (l) l[p] = l[d];
243
+ }
244
+ c.length = i;
245
+ if (a) a.length = i;
246
+ if (l) l.length = i;
247
+ }
248
+ for (p = s; p <= r; p++) {
249
+ c[p] = o[p - s];
250
+ if (a) setSignal(a[p] = f[p - s], e[p]);
251
+ if (l) setSignal(l[p] = h[p - s], p);
252
+ }
253
+ for (p = r + 1; p < i; p++) {
254
+ if (a) setSignal(a[p], e[p]);
255
+ if (l && w !== 0) setSignal(l[p], p);
256
+ }
257
+ }
258
+
60
259
  function updateKeyedMap() {
61
- const t = this.xt() || [], s = t.length;
260
+ // Untracked reads inside the internal owner resolve via _parentComputed:
261
+ // routed through the node, a store-proxy lookup sees pending writes (not a
262
+ // stale _value) and an async read in a row callback registers the node as
263
+ // the flight's reader (pending tracking + post-settle retry) instead of
264
+ // vanishing. Set per pass: the first pass runs inside `computed()`, before
265
+ // the node exists to the caller.
266
+ this.H.Ke = getOwner();
267
+ let t = this.st() || [];
62
268
  t[$TRACK];
63
- // top level tracking
64
- runWithOwner(this.jt, () => {
65
- let i, e, r, n,
269
+ // top level tracking (a store array's container node)
270
+ // A shallow store array diffs its backing: its slots are raw records, and
271
+ // a trap per slot read was most of a one-row write on a 1k-row list.
272
+ t = shallowView?.(t[$TARGET]) ?? t;
273
+ const e = t.length;
274
+ runWithOwner(this.H, () => {
275
+ let i, s,
276
+ // The stage slot a mapper writes its row/index signal into: `j` on the
277
+ // create-all path, `j - start` on the general path, whose stage arrays
278
+ // are sized to the changed WINDOW, not the list.
279
+ n, r, o,
66
280
  // Mappers write freshly-created row/index signals into the STAGE
67
281
  // arrays (`rows`/`indexes`), never into `this._rows`/`this._indexes`.
68
- h = this.Xt ? this.Zt ? () => {
69
- r[e] = signal(t[e], pureOptions);
70
- return this.$t(accessor(r[e]), e);
282
+ f = this.ct ? this.ut ? () => {
283
+ r[n] = signal(t[s], pureOptions);
284
+ return this.ft(accessor(r[n]), s);
71
285
  } : () => {
72
- r[e] = signal(t[e], pureOptions);
73
- n && (n[e] = signal(e, pureOptions));
74
- return this.$t(accessor(r[e]), n ? accessor(n[e]) : undefined);
75
- } : this.Yt ? () => {
76
- const s = t[e];
77
- n[e] = signal(e, pureOptions);
78
- return this.$t(s, accessor(n[e]));
286
+ r[n] = signal(t[s], pureOptions);
287
+ o && (o[n] = signal(s, pureOptions));
288
+ return this.ft(accessor(r[n]), o ? accessor(o[n]) : undefined);
289
+ } : this.lt ? () => {
290
+ const e = t[s];
291
+ o[n] = signal(s, pureOptions);
292
+ return this.ft(e, accessor(o[n]));
79
293
  } : () => {
80
- const s = t[e];
81
- return this.$t(s);
294
+ const e = t[s];
295
+ return this.ft(e);
82
296
  };
83
297
  // fast path for empty arrays
84
- if (s === 0) {
85
- if (this.Wt !== 0) {
86
- this.jt.dispose(false);
87
- this.zt = [];
88
- this.Kt = [];
89
- this.qt = [];
90
- this.Wt = 0;
91
- this.Xt && (this.Xt = []);
92
- this.Yt && (this.Yt = []);
298
+ if (e === 0) {
299
+ if (this.it !== 0) {
300
+ this.H.dispose(false);
301
+ this.tn = [];
302
+ this.ot = [];
303
+ this.ht = [];
304
+ this.it = 0;
305
+ this.ct && (this.ct = []);
306
+ this.lt && (this.lt = []);
93
307
  }
94
- if (this.ts && !this.qt[0]) {
308
+ if (this.L && !this.ht.length) {
95
309
  // an aborted fallback attempt leaves an owner without a mapping;
96
310
  // dispose it before re-creating
97
- this.zt[0]?.dispose();
98
- this.qt[0] = runWithOwner(this.zt[0] = createOwner(), this.ts);
311
+ this.tn[0]?.dispose();
312
+ this.ht[0] = runWithOwner(this.tn[0] = createOwner(), this.L);
99
313
  }
100
314
  }
101
315
  // fast path for new create
102
- else if (this.Wt === 0) {
103
- const o = new Array(s);
104
- const c = new Array(s);
105
- r = this.Xt && new Array(s);
106
- n = this.Yt && new Array(s);
316
+ else if (this.it === 0) {
317
+ const h = new Array(e);
318
+ const c = new Array(e);
319
+ r = this.ct && new Array(e);
320
+ o = this.lt && new Array(e);
107
321
  try {
108
- for (e = 0; e < s; e++) o[e] = runWithOwner(c[e] = createOwner(), h);
322
+ for (s = 0; s < e; s++) {
323
+ n = s;
324
+ h[s] = runWithOwner(c[s] = createOwner(), f);
325
+ }
109
326
  } catch (t) {
110
- for (i = 0; i <= e; i++) c[i]?.dispose();
327
+ for (i = 0; i <= s; i++) c[i]?.dispose();
111
328
  throw t;
112
329
  }
113
330
  // commit
114
- if (this.zt[0]) this.zt[0].dispose();
331
+ if (this.tn[0]) this.tn[0].dispose();
115
332
  // previous fallback
116
- this.qt = o;
117
- this.zt = c;
118
- r && (this.Xt = r);
119
- n && (this.Yt = n);
120
- this.Kt = t.slice(0);
121
- this.Wt = s;
333
+ this.ht = h;
334
+ this.tn = c;
335
+ r && (this.ct = r);
336
+ o && (this.lt = o);
337
+ this.ot = t.slice(0);
338
+ this.it = e;
122
339
  } else {
123
- let o, c, a, f, u, p, w, l, d;
340
+ let h, c, a, l, u, w, d, p, m,
341
+ // Dev (attribution engine installed): the items behind the exited and
342
+ // entered rows, for the list-identity census.
343
+ O, _;
344
+ // The pass's write to a per-slot signal (a row accessor in index mode,
345
+ // an index accessor in keyed mode). The list's frame lives in these
346
+ // writes as much as in the computed's result, so under a LANE pass they
347
+ // are the lane's frame too (F1): a plain `setSignal` staged them into
348
+ // the action's transaction and the row readers were served the
349
+ // committed value until the action landed — `<For>` without `keyed`
350
+ // showed the pre-action list for the whole action while the keyed modes
351
+ // showed the optimistic one. The engine publishes the write as a
352
+ // derived override on the slot (lanes stage, A17) and lands or
353
+ // supersedes it when a plain pass later writes a slot still carrying
354
+ // one (A18) — `landOnOverride`'s slot arm. Decided once per pass, not
355
+ // per slot: a lane pass marks the map (`_laneSlots`: its slots may
356
+ // carry overrides), a marked map routes every slot write through the
357
+ // engine while any lane is live — a slot's override resolves with its
358
+ // lane's transaction, or with the batch for an orphan lane
359
+ // (resolveOptimisticNodes, then cleanupCompletedLanes, both before the
360
+ // completion wakes any recompute), so a pass that finds no lane live
361
+ // knows the slots are clean and drops the mark — and an unmarked map
362
+ // takes `setSignal` directly. The engine is installed whenever a lane
363
+ // is active.
364
+ // CARVE 2: the lane-slot arm (`_landOnOverride`, F1) went with the engine.
365
+ const y = setSignal;
124
366
  // skip common prefix
125
- for (o = 0, c = Math.min(this.Wt, s); o < c && (this.Kt[o] === t[o] || this.Xt && compare(this.Jt, this.Kt[o], t[o])); o++) {
126
- if (this.Xt) setSignal(this.Xt[o], t[o]);
367
+ for (h = 0, c = Math.min(this.it, e); h < c && (this.ot[h] === t[h] || this.ct && compare(this.Xe, this.ot[h], t[h])); h++) {
368
+ if (this.ct) y(this.ct[h], t[h]);
127
369
  }
128
370
  // skip common suffix — counted only; retained entries land in one pass
129
371
  // at commit instead of being staged and copied twice
130
- for (c = this.Wt - 1, a = s - 1; c >= o && a >= o && (this.Kt[c] === t[a] || this.Xt && compare(this.Jt, this.Kt[c], t[a])); c--,
372
+ for (c = this.it - 1, a = e - 1; c >= h && a >= h && (this.ot[c] === t[a] || this.ct && compare(this.Xe, this.ot[c], t[a])); c--,
131
373
  a--) ;
132
374
  // no structural change (every position matched in place at equal
133
375
  // length — the common post-reconcile shape): keep the same mapped
134
376
  // array identity so downstream consumers don't re-run at all
135
- if (o === s && this.Wt === s) {
136
- this.Kt = t.slice(0);
377
+ if (h === e && this.it === e) {
378
+ this.ot = t.slice(0);
137
379
  return;
138
380
  }
139
- const O = s - this.Wt;
140
- const m = new Array(s);
141
- const _ = new Array(s);
142
- r = this.Xt ? new Array(s) : undefined;
143
- n = this.Yt ? new Array(s) : undefined;
144
- // 0) prepare a map of all indices in the changed window of newItems,
145
- // scanning backwards so we encounter them in natural order
146
- p = new Map;
147
- w = new Array(a + 1);
148
- for (e = a; e >= o; e--) {
149
- f = t[e];
150
- u = this.Jt ? this.Jt(f) : f;
151
- i = p.get(u);
152
- w[e] = i === undefined ? -1 : i;
153
- p.set(u, e);
381
+ // SMALL-MOVE FAST PATH: extracted to its own function — inlining it
382
+ // here bloats updateKeyedMap past the JIT's optimization budget and
383
+ // deoptimizes the GENERAL path (measured 2x on reverse). Gated to
384
+ // LARGE trimmed windows: when the trims already shrank the window
385
+ // (plain removals, tail edits), the general path is window-
386
+ // proportional and cheap — the fast path would only re-walk what the
387
+ // trims proved.
388
+ if (e <= this.it && c - h > 64 && this.ct === undefined && this.lt === undefined) {
389
+ // PROBE before the scan: a small move keeps a mid-window item within
390
+ // ±32 of its old position; a REPLACE (all fresh items — the shape
391
+ // every page's first structural pass usually is) has it nowhere.
392
+ // ~65 compares, no allocation, and the scan function is never
393
+ // compiled for a replace (its cold first-call compile was the cost).
394
+ const i = h + (a - h >> 1);
395
+ const s = t[i];
396
+ const n = Math.min(c, i + 32);
397
+ let r = Math.max(h, i - 32);
398
+ while (r <= n && this.ot[r] !== s) r++;
399
+ if (r <= n && trySmallMove(this, t, e, h)) return;
154
400
  }
155
- // 1) step through the old changed window and see if items can be found
156
- // in the new set; if so, stage them at their new positions; if not,
157
- // queue them for disposal at commit
158
- for (i = o; i <= c; i++) {
159
- f = this.Kt[i];
160
- u = this.Jt ? this.Jt(f) : f;
161
- e = p.get(u);
162
- if (e !== undefined && e !== -1) {
163
- m[e] = this.qt[i];
164
- _[e] = this.zt[i];
165
- r && (r[e] = this.Xt[i]);
166
- n && (n[e] = this.Yt[i]);
167
- e = w[e];
168
- p.set(u, e);
169
- } else (l ??= []).push(this.zt[i]);
170
- }
171
- // 2) create new rows into the temp arrays; an abort disposes only these
172
- try {
173
- for (e = o; e <= a; e++) {
174
- if (_[e] !== undefined) continue;
175
- (d ??= []).push(_[e] = createOwner());
176
- m[e] = runWithOwner(_[e], h);
401
+ const A = e - this.it;
402
+ // WINDOW-SIZED STAGING, IN-PLACE COMMIT (2026-10-15). The strong-abort
403
+ // contract (#2903) only needs the pass to touch nothing live before
404
+ // every mapper has succeeded; it never needed four fresh newLen-sized
405
+ // arrays. Only the changed window [start, newEnd] is staged — the
406
+ // prefix and suffix are, by construction, the rows that did not move
407
+ // relative to each other — and at commit the bookkeeping arrays
408
+ // (`_nodes`, `_rows`, `_indexes`) take the window in place with the
409
+ // suffix shifted by a plain loop (`copyWithin` is a generic
410
+ // per-element builtin in V8 — 30× slower than the loop on 1k refs,
411
+ // measured 2026-10-15). `_mappings` alone is
412
+ // rebuilt: its fresh identity is the change signal downstream relies
413
+ // on. A one-row edit on a 500-row list used to allocate ~20 KB of
414
+ // staging plus a position-sized chain array per commit (uibench's
415
+ // one-item tree ops at 4–6× Octane, jfb-reorder `removefirst` at
416
+ // 2.5×); now it stages one slot.
417
+ const g = a - h + 1;
418
+ const S = new Array(e);
419
+ const M = new Array(g);
420
+ r = this.ct ? new Array(g) : undefined;
421
+ o = this.lt ? new Array(g) : undefined;
422
+ // A shrinking pass is tried as a pure removal first (stageRemoval: no
423
+ // key map, one key call per item); anything else takes the map path.
424
+ const k = A < 0 ? stageRemoval(this, t, h, c, a, S, M, r, o) : null;
425
+ if (k !== null) {
426
+ // (The list-churn census below wants removals AND creations in one
427
+ // pass; a pure removal has none, so no item ledger is kept here.)
428
+ if (k.length !== 0) p = k;
429
+ } else {
430
+ // 0) prepare a map of all indices in the changed window of newItems,
431
+ // scanning backwards so we encounter them in natural order
432
+ w = new Map;
433
+ d = new Array(g);
434
+ for (s = a; s >= h; s--) {
435
+ l = t[s];
436
+ u = this.Xe ? this.Xe(l) : l;
437
+ i = w.get(u);
438
+ d[s - h] = i === undefined ? -1 : i;
439
+ w.set(u, s);
177
440
  }
178
- } catch (t) {
179
- if (d) for (i = 0; i < d.length; i++) d[i].dispose();
180
- throw t;
181
- }
182
- // 3) commit: land the retained prefix and suffix plus the staged window
183
- // into the fresh arrays, swap them in (new identity for downstream
184
- // change propagation), then dispose exited rows
185
- for (i = 0; i < o; i++) {
186
- m[i] = this.qt[i];
187
- _[i] = this.zt[i];
188
- r && (r[i] = this.Xt[i]);
189
- n && (n[i] = this.Yt[i]);
190
- }
191
- for (e = o; e <= a; e++) {
192
- if (r) setSignal(r[e], t[e]);
193
- if (n) setSignal(n[e], e);
194
- }
195
- for (e = a + 1; e < s; e++) {
196
- m[e] = this.qt[e - O];
197
- _[e] = this.zt[e - O];
198
- if (r) {
199
- r[e] = this.Xt[e - O];
200
- setSignal(r[e], t[e]);
441
+ // 1) step through the old changed window and see if items can be found
442
+ // in the new set; if so, stage them at their new positions; if not,
443
+ // queue them for disposal at commit
444
+ for (i = h; i <= c; i++) {
445
+ l = this.ot[i];
446
+ u = this.Xe ? this.Xe(l) : l;
447
+ s = w.get(u);
448
+ if (s !== undefined && s !== -1) {
449
+ S[s] = this.ht[i];
450
+ M[s - h] = this.tn[i];
451
+ r && (r[s - h] = this.ct[i]);
452
+ o && (o[s - h] = this.lt[i]);
453
+ s = d[s - h];
454
+ w.set(u, s);
455
+ } else {
456
+ (p ??= []).push(this.tn[i]);
457
+ if (false && attrHooks !== null) ;
458
+ }
201
459
  }
202
- if (n) {
203
- n[e] = this.Yt[e - O];
204
- if (O !== 0) setSignal(n[e], e);
460
+ // 2) create new rows into the window stage; an abort disposes only these
461
+ try {
462
+ for (s = h; s <= a; s++) {
463
+ if (M[s - h] !== undefined) continue;
464
+ (m ??= []).push(M[s - h] = createOwner());
465
+ if (false && attrHooks !== null) ;
466
+ n = s - h;
467
+ S[s] = runWithOwner(M[s - h], f);
468
+ }
469
+ } catch (t) {
470
+ if (m) for (i = 0; i < m.length; i++) m[i].dispose();
471
+ throw t;
205
472
  }
206
473
  }
207
- this.qt = m;
208
- this.zt = _;
209
- r && (this.Xt = r);
210
- n && (this.Yt = n);
211
- this.Wt = s;
474
+ // 3) commit: the retained prefix and suffix land in the fresh mapped
475
+ // array; the bookkeeping arrays take the staged window IN PLACE (own
476
+ // function: kept out of this body on purpose, see commitWindow); then
477
+ // the exited rows dispose
478
+ for (i = 0; i < h; i++) S[i] = this.ht[i];
479
+ for (s = a + 1; s < e; s++) S[s] = this.ht[s - A];
480
+ commitWindow(this, t, e, h, c, a, M, r, o);
481
+ this.ht = S;
482
+ this.it = e;
212
483
  // save a copy of the mapped items for the next update
213
- this.Kt = t.slice(0);
214
- if (l) for (i = 0; i < l.length; i++) l[i].dispose();
484
+ this.ot = t.slice(0);
485
+ if (p) for (i = 0; i < p.length; i++) p[i].dispose();
486
+ if (false && attrHooks !== null && O !== undefined && _ !== undefined) ;
215
487
  }
216
488
  });
217
- return this.qt;
489
+ return this.ht;
218
490
  }
219
491
 
220
492
  /**
@@ -230,27 +502,23 @@ function updateKeyedMap() {
230
502
  * const view = repeat(count, i => `Item ${i}`, { fallback: () => "empty" });
231
503
  * ```
232
504
  *
233
- * @description https://docs.solidjs.com/reference/reactive-utilities/repeat
234
- */ function repeat(t, s, i) {
235
- const e = s;
236
- const r = {
237
- jt: createOwner(),
238
- Wt: 0,
239
- ss: 0,
240
- es: t,
241
- $t: e,
242
- zt: [],
243
- qt: [],
244
- rs: i?.from,
245
- ts: i?.fallback
505
+ * @description https://v2.solidjs.com/reference/solid-js/advanced/jsx-component-primitives/repeat
506
+ */ function repeat(t, e, i) {
507
+ const s = e;
508
+ const n = {
509
+ H: createOwner(),
510
+ it: 0,
511
+ wt: 0,
512
+ dt: t,
513
+ ft: s,
514
+ tn: [],
515
+ ht: [],
516
+ Ot: i?.from,
517
+ L: i?.fallback
246
518
  };
247
- const n = computed(updateRepeat.bind(r));
248
- // Same as mapArray: untracked reads inside the internal owner resolve via
249
- // _parentComputed, so async reads in row callbacks register with the node
250
- // (pending tracking + post-settle retry) instead of vanishing.
251
- r.jt.Ot = n;
252
- n.T &= ~CONFIG_AUTO_DISPOSE;
253
- return accessor(n);
519
+ const r = computed(updateRepeat.bind(n));
520
+ r.l &= ~CONFIG_AUTO_DISPOSE;
521
+ return accessor(r);
254
522
  }
255
523
 
256
524
  // Same staged-commit discipline as `updateKeyedMap` (#2903): the retained
@@ -261,59 +529,61 @@ function updateKeyedMap() {
261
529
  // for the post-settle retry. The overlap math also subsumes the previous
262
530
  // disjoint-window/front-clear/end-clear/shift special cases.
263
531
  function updateRepeat() {
264
- const t = this.es();
265
- const s = this.rs?.() || 0;
266
- runWithOwner(this.jt, () => {
532
+ // As in updateKeyedMap: the node is the row callbacks' reader, per pass.
533
+ this.H.Ke = getOwner();
534
+ const t = this.dt();
535
+ const e = this.Ot?.() || 0;
536
+ runWithOwner(this.H, () => {
267
537
  if (t === 0) {
268
- if (this.Wt !== 0) {
269
- this.jt.dispose(false);
270
- this.zt = [];
271
- this.qt = [];
272
- this.Wt = 0;
538
+ if (this.it !== 0) {
539
+ this.H.dispose(false);
540
+ this.tn = [];
541
+ this.ht = [];
542
+ this.it = 0;
273
543
  // Reset offset to match the cleared data (#2767, repro 2).
274
- this.ss = 0;
544
+ this.wt = 0;
275
545
  }
276
- if (this.ts && !this.qt[0]) {
546
+ if (this.L && !this.ht.length) {
277
547
  // an aborted fallback attempt leaves an owner without a mapping;
278
548
  // dispose it before re-creating
279
- this.zt[0]?.dispose();
280
- this.qt[0] = runWithOwner(this.zt[0] = createOwner(), this.ts);
549
+ this.tn[0]?.dispose();
550
+ this.ht[0] = runWithOwner(this.tn[0] = createOwner(), this.L);
281
551
  }
282
552
  return;
283
553
  }
284
- const i = s + t;
285
- const e = this.ss + this.Wt;
554
+ const i = e + t;
555
+ const s = this.wt + this.it;
286
556
  // Retained overlap [keepStart, keepEnd) in global indexes; empty when the
287
557
  // windows are disjoint or when coming from empty/fallback.
288
- const r = Math.max(s, this.ss);
289
- const n = Math.min(i, e);
290
- const h = new Array(t);
558
+ const n = Math.max(e, this.wt);
559
+ const r = Math.min(i, s);
291
560
  const o = new Array(t);
292
- for (let t = r; t < n; t++) {
293
- o[t - s] = this.zt[t - this.ss];
294
- h[t - s] = this.qt[t - this.ss];
561
+ const f = new Array(t);
562
+ for (let t = n; t < r; t++) {
563
+ f[t - e] = this.tn[t - this.wt];
564
+ o[t - e] = this.ht[t - this.wt];
295
565
  }
296
566
  try {
297
- for (let t = s; t < i; t++) {
298
- if (t >= r && t < n) continue;
299
- h[t - s] = runWithOwner(o[t - s] = createOwner(), () => this.$t(t));
567
+ for (let t = e; t < i; t++) {
568
+ if (t >= n && t < r) continue;
569
+ o[t - e] = runWithOwner(f[t - e] = createOwner(), () => this.ft(t));
300
570
  }
301
571
  } catch (t) {
302
- for (let t = s; t < i; t++) if ((t < r || t >= n) && o[t - s]) o[t - s].dispose();
572
+ for (let t = e; t < i; t++) if ((t < n || t >= r) && f[t - e]) f[t - e].dispose();
303
573
  throw t;
304
574
  }
305
575
  // commit: dispose the previous fallback or the rows leaving the window
306
- if (this.Wt === 0) this.zt[0]?.dispose(); else for (let t = this.ss; t < e; t++) if (t < s || t >= i) this.zt[t - this.ss].dispose();
307
- this.qt = h;
308
- this.zt = o;
309
- this.ss = s;
310
- this.Wt = t;
576
+ if (this.it === 0) this.tn[0]?.dispose(); else for (let t = this.wt; t < s; t++) if (t < e || t >= i) this.tn[t - this.wt].dispose();
577
+ this.ht = o;
578
+ this.tn = f;
579
+ this.wt = e;
580
+ this.it = t;
311
581
  });
312
- return this.qt;
582
+ return this.ht;
313
583
  }
314
584
 
315
- function compare(t, s, i) {
316
- return t ? t(s) === t(i) : true;
585
+ function compare(t, e, i) {
586
+ return t ? t(e) === t(i) : true;
317
587
  }
318
588
 
319
589
  export { mapArray, repeat };