@solidjs/signals 2.0.0-rc.0 → 2.0.0-rc.10

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 (149) hide show
  1. package/README.md +1 -1
  2. package/dist/dev-shared.js +7138 -0
  3. package/dist/dev.attribution.js +3307 -0
  4. package/dist/dev.js +8076 -6692
  5. package/dist/observe/affects.js +129 -0
  6. package/dist/observe/attribution.js +7 -0
  7. package/dist/observe/boundaries.js +793 -0
  8. package/dist/observe/core/action.js +177 -0
  9. package/dist/observe/core/async.js +849 -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 +2904 -0
  15. package/dist/observe/core/constants.js +283 -0
  16. package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
  17. package/dist/observe/core/core.js +1999 -0
  18. package/dist/observe/core/dev.js +343 -0
  19. package/dist/observe/core/effect.js +200 -0
  20. package/dist/observe/core/error-hooks.js +71 -0
  21. package/dist/observe/core/error.js +80 -0
  22. package/dist/observe/core/external.js +98 -0
  23. package/dist/observe/core/graph.js +155 -0
  24. package/dist/observe/core/heap.js +147 -0
  25. package/dist/observe/core/invariants.js +45 -0
  26. package/dist/observe/core/lanes.js +205 -0
  27. package/dist/observe/core/optimistic.js +627 -0
  28. package/dist/observe/core/owner.js +353 -0
  29. package/dist/observe/core/scheduler.js +1547 -0
  30. package/dist/observe/core/verdict.js +674 -0
  31. package/dist/observe/index.js +59 -0
  32. package/dist/observe/map.js +484 -0
  33. package/dist/observe/signals.js +731 -0
  34. package/dist/observe/store/index.js +44 -0
  35. package/dist/observe/store/next/optimistic.js +717 -0
  36. package/dist/observe/store/next/projection.js +266 -0
  37. package/dist/observe/store/next/reconcile.js +375 -0
  38. package/dist/observe/store/next/store.js +2480 -0
  39. package/dist/observe/store/next/target.js +51 -0
  40. package/dist/observe/store/store.js +331 -0
  41. package/dist/observe/store/storePath.js +103 -0
  42. package/dist/observe/store/utils.js +1070 -0
  43. package/dist/prod/affects.js +10 -9
  44. package/dist/prod/attribution.js +45 -0
  45. package/dist/prod/boundaries.js +388 -178
  46. package/dist/prod/core/action.js +65 -37
  47. package/dist/prod/core/async.js +477 -208
  48. package/dist/prod/core/attribution-hooks.js +3 -0
  49. package/dist/prod/core/constants.js +186 -1
  50. package/dist/prod/core/context.js +10 -16
  51. package/dist/prod/core/core.js +1556 -415
  52. package/dist/prod/core/dev.js +18 -1
  53. package/dist/prod/core/effect.js +119 -79
  54. package/dist/prod/core/error-hooks.js +71 -0
  55. package/dist/prod/core/error.js +13 -1
  56. package/dist/prod/core/external.js +4 -4
  57. package/dist/prod/core/graph.js +105 -54
  58. package/dist/prod/core/heap.js +72 -65
  59. package/dist/prod/core/invariants.js +3 -2
  60. package/dist/prod/core/lanes.js +117 -52
  61. package/dist/prod/core/optimistic.js +474 -103
  62. package/dist/prod/core/owner.js +131 -84
  63. package/dist/prod/core/scheduler.js +1013 -248
  64. package/dist/prod/core/verdict.js +418 -113
  65. package/dist/prod/index.js +25 -13
  66. package/dist/prod/map.js +314 -151
  67. package/dist/prod/signals.js +382 -32
  68. package/dist/prod/store/index.js +38 -0
  69. package/dist/prod/store/next/optimistic.js +710 -0
  70. package/dist/prod/store/next/projection.js +257 -0
  71. package/dist/prod/store/next/reconcile.js +373 -0
  72. package/dist/prod/store/next/store.js +2356 -0
  73. package/dist/prod/store/next/target.js +51 -0
  74. package/dist/prod/store/store.js +129 -881
  75. package/dist/prod/store/utils.js +982 -242
  76. package/dist/types/attribution.d.ts +19 -0
  77. package/dist/types/attribution.prod.d.ts +22 -0
  78. package/dist/types/boundaries.d.ts +78 -5
  79. package/dist/types/core/action.d.ts +12 -5
  80. package/dist/types/core/async.d.ts +3 -1
  81. package/dist/types/core/attribution-costs.d.ts +35 -0
  82. package/dist/types/core/attribution-feedback.d.ts +133 -0
  83. package/dist/types/core/attribution-hooks.d.ts +304 -0
  84. package/dist/types/core/attribution-queries.d.ts +24 -0
  85. package/dist/types/core/attribution.d.ts +892 -0
  86. package/dist/types/core/constants.d.ts +179 -0
  87. package/dist/types/core/core.d.ts +305 -23
  88. package/dist/types/core/dev.d.ts +421 -8
  89. package/dist/types/core/effect.d.ts +8 -1
  90. package/dist/types/core/error-hooks.d.ts +71 -0
  91. package/dist/types/core/error.d.ts +9 -0
  92. package/dist/types/core/graph.d.ts +23 -0
  93. package/dist/types/core/heap.d.ts +5 -3
  94. package/dist/types/core/index.d.ts +6 -3
  95. package/dist/types/core/invariants.d.ts +5 -1
  96. package/dist/types/core/lanes.d.ts +51 -19
  97. package/dist/types/core/owner.d.ts +15 -3
  98. package/dist/types/core/scheduler.d.ts +252 -3
  99. package/dist/types/core/types.d.ts +124 -41
  100. package/dist/types/index.d.ts +18 -5
  101. package/dist/types/map.d.ts +2 -0
  102. package/dist/types/signals.d.ts +164 -13
  103. package/dist/types/store/index.d.ts +16 -5
  104. package/dist/types/store/next/optimistic.d.ts +25 -0
  105. package/dist/types/store/next/projection.d.ts +27 -0
  106. package/dist/types/store/next/reconcile.d.ts +10 -0
  107. package/dist/types/store/next/store.d.ts +143 -0
  108. package/dist/types/store/next/target.d.ts +196 -0
  109. package/dist/types/store/store.d.ts +46 -112
  110. package/dist/types/store/utils.d.ts +188 -40
  111. package/package.json +32 -26
  112. package/dist/node.cjs +0 -7938
  113. package/dist/prod/store/optimistic.js +0 -217
  114. package/dist/prod/store/projection.js +0 -231
  115. package/dist/prod/store/reconcile.js +0 -707
  116. package/dist/types/store/optimistic.d.ts +0 -45
  117. package/dist/types/store/projection.d.ts +0 -70
  118. package/dist/types/store/reconcile.d.ts +0 -46
  119. package/dist/types-cjs/affects.d.cts +0 -47
  120. package/dist/types-cjs/boundaries.d.cts +0 -175
  121. package/dist/types-cjs/core/action.d.cts +0 -64
  122. package/dist/types-cjs/core/async.d.cts +0 -21
  123. package/dist/types-cjs/core/constants.d.cts +0 -71
  124. package/dist/types-cjs/core/core.d.cts +0 -148
  125. package/dist/types-cjs/core/dev.d.cts +0 -64
  126. package/dist/types-cjs/core/effect.d.cts +0 -30
  127. package/dist/types-cjs/core/error.d.cts +0 -47
  128. package/dist/types-cjs/core/external.d.cts +0 -15
  129. package/dist/types-cjs/core/graph.d.cts +0 -5
  130. package/dist/types-cjs/core/heap.d.cts +0 -22
  131. package/dist/types-cjs/core/index.d.cts +0 -13
  132. package/dist/types-cjs/core/invariants.d.cts +0 -59
  133. package/dist/types-cjs/core/lanes.d.cts +0 -56
  134. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  135. package/dist/types-cjs/core/owner.d.cts +0 -124
  136. package/dist/types-cjs/core/scheduler.d.cts +0 -170
  137. package/dist/types-cjs/core/types.d.cts +0 -148
  138. package/dist/types-cjs/core/verdict.d.cts +0 -2
  139. package/dist/types-cjs/index.d.cts +0 -10
  140. package/dist/types-cjs/map.d.cts +0 -69
  141. package/dist/types-cjs/package.json +0 -3
  142. package/dist/types-cjs/signals.d.cts +0 -605
  143. package/dist/types-cjs/store/index.d.cts +0 -9
  144. package/dist/types-cjs/store/optimistic.d.cts +0 -45
  145. package/dist/types-cjs/store/projection.d.cts +0 -70
  146. package/dist/types-cjs/store/reconcile.d.cts +0 -46
  147. package/dist/types-cjs/store/store.d.cts +0 -213
  148. package/dist/types-cjs/store/storePath.d.cts +0 -58
  149. package/dist/types-cjs/store/utils.d.cts +0 -114
package/dist/prod/map.js CHANGED
@@ -6,6 +6,8 @@ import "./core/scheduler.js";
6
6
 
7
7
  import { CONFIG_AUTO_DISPOSE } from "./core/constants.js";
8
8
 
9
+ import { attrHooks } from "./core/attribution-hooks.js";
10
+
9
11
  import "./core/invariants.js";
10
12
 
11
13
  import "./core/verdict.js";
@@ -16,203 +18,364 @@ import { accessor } from "./signals.js";
16
18
 
17
19
  import { $TRACK } from "./store/store.js";
18
20
 
21
+ import "./store/next/store.js";
22
+
19
23
  function mapArray(t, s, i) {
20
24
  const e = typeof i?.keyed === "function" ? i.keyed : undefined;
21
25
  const r = s.length > 1;
22
26
  const n = s;
23
- const h = {
24
- wt: createOwner(),
25
- jt: 0,
26
- Wt: t,
27
- Mt: [],
28
- Kt: n,
29
- xt: [],
30
- Ut: [],
31
- $t: e,
32
- qt: e || i?.keyed === false ? [] : undefined,
33
- zt: r && i?.keyed !== false ? [] : undefined,
34
- Bt: i?.keyed === false,
35
- Ht: i?.fallback
27
+ const o = {
28
+ ie: createOwner(),
29
+ wt: 0,
30
+ Ot: t,
31
+ yt: [],
32
+ At: n,
33
+ St: [],
34
+ gt: [],
35
+ Kn: e,
36
+ Mt: e || i?.keyed === false ? [] : undefined,
37
+ jt: r && i?.keyed !== false ? [] : undefined,
38
+ kt: i?.keyed === false,
39
+ Wt: i?.fallback
36
40
  };
37
- const o = computed(updateKeyedMap.bind(h));
41
+ const h = computed(updateKeyedMap.bind(o), undefined);
38
42
  // Untracked reads inside the internal owner resolve via _parentComputed; routing
39
43
  // them through node lets store-proxy lookups see pending writes (not stale _value).
40
- h.wt.dt = o;
41
- o.T &= ~CONFIG_AUTO_DISPOSE;
42
- return accessor(o);
44
+ o.ie.qn = h;
45
+ h.C &= ~CONFIG_AUTO_DISPOSE;
46
+ return accessor(h);
43
47
  }
44
48
 
45
49
  const pureOptions = {
46
50
  ownedWrite: true
47
51
  };
48
52
 
49
- // Exception safety (#2903): a map callback can throw NotReadyError mid-pass
50
- // (async read), and the computed re-runs the whole pass after settle. Every
51
- // pass therefore STAGES its work — new rows are created into temp arrays and
52
- // removals are deferred — and commits to `this` only after every mapper
53
- // succeeded. An aborted pass disposes just the owners it created and leaves
54
- // `_items`/`_mappings`/`_nodes`/`_rows`/`_indexes`/`_len` exactly as they
55
- // were, so the retry diffs against uncorrupted state. Consequence of the
56
- // strong-abort ordering: removed rows now dispose AFTER the pass's new rows
57
- // are created (you cannot destroy state before knowing the pass will land).
53
+ function trySmallMove(t, s, i, e) {
54
+ const r = t.yt;
55
+ const n = t.wt - 1;
56
+ const o = [];
57
+ const h = [];
58
+ const f = [];
59
+ // flat triples: oldStart, newStart, length
60
+ let c = 256;
61
+ let a = e;
62
+ let l = e;
63
+ let u = false;
64
+ while (a <= n && l <= i - 1) {
65
+ const t = r[a];
66
+ const e = s[l];
67
+ if (t === e) {
68
+ if (!u) {
69
+ f.push(a, l, 0);
70
+ u = true;
71
+ }
72
+ f[f.length - 1]++;
73
+ a++;
74
+ l++;
75
+ continue;
76
+ }
77
+ u = false;
78
+ // Bounded realignment lookahead, shorter distance wins.
79
+ let p = -1;
80
+ let d = Math.min(32 - o.length, n - a, c);
81
+ for (let t = 1; t <= d; t++) {
82
+ if (r[a + t] === e) {
83
+ p = t;
84
+ break;
85
+ }
86
+ }
87
+ c -= p === -1 ? d : p;
88
+ let w = -1;
89
+ d = Math.min(32 - h.length, i - 1 - l, c);
90
+ for (let i = 1; i <= d; i++) {
91
+ if (s[l + i] === t) {
92
+ w = i;
93
+ break;
94
+ }
95
+ }
96
+ c -= w === -1 ? d : w;
97
+ if (p !== -1 && (w === -1 || p <= w)) {
98
+ while (p-- > 0) o.push(a++);
99
+ continue;
100
+ }
101
+ if (w !== -1) {
102
+ while (w-- > 0) h.push(l++);
103
+ continue;
104
+ }
105
+ if (c <= 0 || o.length === 32 || h.length === 32) return false;
106
+ o.push(a++);
107
+ h.push(l++);
108
+ }
109
+ for (;a <= n; a++) {
110
+ if (o.length === 32) return false;
111
+ o.push(a);
112
+ }
113
+ for (;l <= i - 1; l++) {
114
+ if (h.length === 32) return false;
115
+ h.push(l);
116
+ }
117
+ return commitSmallMove(t, s, i, o, h, f);
118
+ }
119
+
120
+ /** PHASE 2 of the small-move path, in its OWN function so that a pass which
121
+ * only SCANS and bails (a full replace: the first structural pass of a page,
122
+ * typically) compiles nothing but the scan — V8 parses and compiles lazily
123
+ * per function, and cold `replace` measured +0.5 ms with both phases in one
124
+ * body. Pairs displaced sources with destinations (an unmatched destination
125
+ * is a replacement/insertion → general path), then commits: slice() the live
126
+ * arrays, copy shifted runs, patch displaced pairs, dispose leftovers. */ function commitSmallMove(t, s, i, e, r, n) {
127
+ const o = t.yt;
128
+ let h;
129
+ let f;
130
+ let c;
131
+ if (r.length !== 0) {
132
+ c = new Array(e.length);
133
+ for (f = 0; f < r.length; f++) {
134
+ let t = -1;
135
+ for (h = 0; h < e.length; h++) {
136
+ if (!c[h] && o[e[h]] === s[r[f]]) {
137
+ t = h;
138
+ break;
139
+ }
140
+ }
141
+ if (t === -1) return false;
142
+ c[t] = true;
143
+ r[f] = r[f] << 6 | t;
144
+ // pack pairing (found < 32)
145
+ }
146
+ }
147
+ // DUPLICATES: the general path pairs equal identities by OCCURRENCE ORDER
148
+ // (the chained index map). Displaced↔displaced pairing above is ascending
149
+ // on both sides, so it agrees; but an aligned run was matched by POSITION,
150
+ // and if a displaced identity also occurs inside a run the two algorithms
151
+ // can hand different occurrences different owners (row-local state moves;
152
+ // a shrink could dispose the wrong one). Decline that case — general path.
153
+ if (e.length !== 0 || r.length !== 0) {
154
+ const t = new Set;
155
+ for (h = 0; h < e.length; h++) t.add(o[e[h]]);
156
+ for (f = 0; f < r.length; f++) t.add(s[r[f] >> 6]);
157
+ for (let s = 0; s < n.length; s += 3) {
158
+ const i = n[s];
159
+ for (let e = 0, r = n[s + 2]; e < r; e++) if (t.has(o[i + e])) return false;
160
+ }
161
+ }
162
+ const a = t.St;
163
+ const l = t.gt;
164
+ const u = a.slice(0, i);
165
+ const p = l.slice(0, i);
166
+ for (let t = 0; t < n.length; t += 3) {
167
+ const s = n[t];
168
+ const i = n[t + 1];
169
+ if (s !== i) {
170
+ for (let e = 0; e < n[t + 2]; e++) {
171
+ u[i + e] = a[s + e];
172
+ p[i + e] = l[s + e];
173
+ }
174
+ }
175
+ }
176
+ for (f = 0; f < r.length; f++) {
177
+ const t = r[f] >> 6;
178
+ const s = e[r[f] & 63];
179
+ u[t] = a[s];
180
+ p[t] = l[s];
181
+ }
182
+ t.St = u;
183
+ t.gt = p;
184
+ t.wt = i;
185
+ t.yt = s.slice(0);
186
+ // Dispose unmatched sources LAST (general-path ordering).
187
+ for (h = 0; h < e.length; h++) {
188
+ if (c === undefined || !c[h]) l[e[h]].dispose();
189
+ }
190
+ return true;
191
+ }
192
+
58
193
  function updateKeyedMap() {
59
- const t = this.Wt() || [], s = t.length;
194
+ const t = this.Ot() || [], s = t.length;
60
195
  t[$TRACK];
61
196
  // top level tracking
62
- runWithOwner(this.wt, () => {
197
+ runWithOwner(this.ie, () => {
63
198
  let i, e, r, n,
64
199
  // Mappers write freshly-created row/index signals into the STAGE
65
200
  // arrays (`rows`/`indexes`), never into `this._rows`/`this._indexes`.
66
- h = this.qt ? this.Bt ? () => {
201
+ o = this.Mt ? this.kt ? () => {
67
202
  r[e] = signal(t[e], pureOptions);
68
- return this.Kt(accessor(r[e]), e);
203
+ return this.At(accessor(r[e]), e);
69
204
  } : () => {
70
205
  r[e] = signal(t[e], pureOptions);
71
206
  n && (n[e] = signal(e, pureOptions));
72
- return this.Kt(accessor(r[e]), n ? accessor(n[e]) : undefined);
73
- } : this.zt ? () => {
207
+ return this.At(accessor(r[e]), n ? accessor(n[e]) : undefined);
208
+ } : this.jt ? () => {
74
209
  const s = t[e];
75
210
  n[e] = signal(e, pureOptions);
76
- return this.Kt(s, accessor(n[e]));
211
+ return this.At(s, accessor(n[e]));
77
212
  } : () => {
78
213
  const s = t[e];
79
- return this.Kt(s);
214
+ return this.At(s);
80
215
  };
81
216
  // fast path for empty arrays
82
217
  if (s === 0) {
83
- if (this.jt !== 0) {
84
- this.wt.dispose(false);
85
- this.Ut = [];
86
- this.Mt = [];
87
- this.xt = [];
88
- this.jt = 0;
89
- this.qt && (this.qt = []);
90
- this.zt && (this.zt = []);
218
+ if (this.wt !== 0) {
219
+ this.ie.dispose(false);
220
+ this.gt = [];
221
+ this.yt = [];
222
+ this.St = [];
223
+ this.wt = 0;
224
+ this.Mt && (this.Mt = []);
225
+ this.jt && (this.jt = []);
91
226
  }
92
- if (this.Ht && !this.xt[0]) {
227
+ if (this.Wt && !this.St[0]) {
93
228
  // an aborted fallback attempt leaves an owner without a mapping;
94
229
  // dispose it before re-creating
95
- this.Ut[0]?.dispose();
96
- this.xt[0] = runWithOwner(this.Ut[0] = createOwner(), this.Ht);
230
+ this.gt[0]?.dispose();
231
+ this.St[0] = runWithOwner(this.gt[0] = createOwner(), this.Wt);
97
232
  }
98
233
  }
99
234
  // fast path for new create
100
- else if (this.jt === 0) {
101
- const o = new Array(s);
102
- const c = new Array(s);
103
- r = this.qt && new Array(s);
104
- n = this.zt && new Array(s);
235
+ else if (this.wt === 0) {
236
+ const h = new Array(s);
237
+ const f = new Array(s);
238
+ r = this.Mt && new Array(s);
239
+ n = this.jt && new Array(s);
105
240
  try {
106
- for (e = 0; e < s; e++) o[e] = runWithOwner(c[e] = createOwner(), h);
241
+ for (e = 0; e < s; e++) h[e] = runWithOwner(f[e] = createOwner(), o);
107
242
  } catch (t) {
108
- for (i = 0; i <= e; i++) c[i]?.dispose();
243
+ for (i = 0; i <= e; i++) f[i]?.dispose();
109
244
  throw t;
110
245
  }
111
246
  // commit
112
- if (this.Ut[0]) this.Ut[0].dispose();
247
+ if (this.gt[0]) this.gt[0].dispose();
113
248
  // previous fallback
114
- this.xt = o;
115
- this.Ut = c;
116
- r && (this.qt = r);
117
- n && (this.zt = n);
118
- this.Mt = t.slice(0);
119
- this.jt = s;
249
+ this.St = h;
250
+ this.gt = f;
251
+ r && (this.Mt = r);
252
+ n && (this.jt = n);
253
+ this.yt = t.slice(0);
254
+ this.wt = s;
120
255
  } else {
121
- let o, c, a, f, u, p, w, l, d;
256
+ let h, f, c, a, l, u, p, d, w,
257
+ // Dev (attribution engine installed): the items behind the exited and
258
+ // entered rows, for the list-identity census.
259
+ m, O;
122
260
  // skip common prefix
123
- for (o = 0, c = Math.min(this.jt, s); o < c && (this.Mt[o] === t[o] || this.qt && compare(this.$t, this.Mt[o], t[o])); o++) {
124
- if (this.qt) setSignal(this.qt[o], t[o]);
261
+ for (h = 0, f = Math.min(this.wt, s); h < f && (this.yt[h] === t[h] || this.Mt && compare(this.Kn, this.yt[h], t[h])); h++) {
262
+ if (this.Mt) setSignal(this.Mt[h], t[h]);
125
263
  }
126
264
  // skip common suffix — counted only; retained entries land in one pass
127
265
  // at commit instead of being staged and copied twice
128
- for (c = this.jt - 1, a = s - 1; c >= o && a >= o && (this.Mt[c] === t[a] || this.qt && compare(this.$t, this.Mt[c], t[a])); c--,
129
- a--) ;
266
+ for (f = this.wt - 1, c = s - 1; f >= h && c >= h && (this.yt[f] === t[c] || this.Mt && compare(this.Kn, this.yt[f], t[c])); f--,
267
+ c--) ;
130
268
  // no structural change (every position matched in place at equal
131
269
  // length — the common post-reconcile shape): keep the same mapped
132
270
  // array identity so downstream consumers don't re-run at all
133
- if (o === s && this.jt === s) {
134
- this.Mt = t.slice(0);
271
+ if (h === s && this.wt === s) {
272
+ this.yt = t.slice(0);
135
273
  return;
136
274
  }
137
- const O = s - this.jt;
138
- const m = new Array(s);
139
- const _ = new Array(s);
140
- r = this.qt ? new Array(s) : undefined;
141
- n = this.zt ? new Array(s) : undefined;
275
+ // SMALL-MOVE FAST PATH: extracted to its own function — inlining it
276
+ // here bloats updateKeyedMap past the JIT's optimization budget and
277
+ // deoptimizes the GENERAL path (measured 2x on reverse). Gated to
278
+ // LARGE trimmed windows: when the trims already shrank the window
279
+ // (plain removals, tail edits), the general path is window-
280
+ // proportional and cheap — the fast path would only re-walk what the
281
+ // trims proved.
282
+ if (s <= this.wt && f - h > 64 && this.Mt === undefined && this.jt === undefined) {
283
+ // PROBE before the scan: a small move keeps a mid-window item within
284
+ // ±32 of its old position; a REPLACE (all fresh items — the shape
285
+ // every page's first structural pass usually is) has it nowhere.
286
+ // ~65 compares, no allocation, and the scan function is never
287
+ // compiled for a replace (its cold first-call compile was the cost).
288
+ const i = h + (c - h >> 1);
289
+ const e = t[i];
290
+ const r = Math.min(f, i + 32);
291
+ let n = Math.max(h, i - 32);
292
+ while (n <= r && this.yt[n] !== e) n++;
293
+ if (n <= r && trySmallMove(this, t, s, h)) return;
294
+ }
295
+ const _ = s - this.wt;
296
+ const y = new Array(s);
297
+ const A = new Array(s);
298
+ r = this.Mt ? new Array(s) : undefined;
299
+ n = this.jt ? new Array(s) : undefined;
142
300
  // 0) prepare a map of all indices in the changed window of newItems,
143
301
  // scanning backwards so we encounter them in natural order
144
- p = new Map;
145
- w = new Array(a + 1);
146
- for (e = a; e >= o; e--) {
147
- f = t[e];
148
- u = this.$t ? this.$t(f) : f;
149
- i = p.get(u);
150
- w[e] = i === undefined ? -1 : i;
151
- p.set(u, e);
302
+ u = new Map;
303
+ p = new Array(c + 1);
304
+ for (e = c; e >= h; e--) {
305
+ a = t[e];
306
+ l = this.Kn ? this.Kn(a) : a;
307
+ i = u.get(l);
308
+ p[e] = i === undefined ? -1 : i;
309
+ u.set(l, e);
152
310
  }
153
311
  // 1) step through the old changed window and see if items can be found
154
312
  // in the new set; if so, stage them at their new positions; if not,
155
313
  // queue them for disposal at commit
156
- for (i = o; i <= c; i++) {
157
- f = this.Mt[i];
158
- u = this.$t ? this.$t(f) : f;
159
- e = p.get(u);
314
+ for (i = h; i <= f; i++) {
315
+ a = this.yt[i];
316
+ l = this.Kn ? this.Kn(a) : a;
317
+ e = u.get(l);
160
318
  if (e !== undefined && e !== -1) {
161
- m[e] = this.xt[i];
162
- _[e] = this.Ut[i];
163
- r && (r[e] = this.qt[i]);
164
- n && (n[e] = this.zt[i]);
165
- e = w[e];
166
- p.set(u, e);
167
- } else (l ??= []).push(this.Ut[i]);
319
+ y[e] = this.St[i];
320
+ A[e] = this.gt[i];
321
+ r && (r[e] = this.Mt[i]);
322
+ n && (n[e] = this.jt[i]);
323
+ e = p[e];
324
+ u.set(l, e);
325
+ } else {
326
+ (d ??= []).push(this.gt[i]);
327
+ if (false && attrHooks !== null) ;
328
+ }
168
329
  }
169
330
  // 2) create new rows into the temp arrays; an abort disposes only these
170
331
  try {
171
- for (e = o; e <= a; e++) {
172
- if (_[e] !== undefined) continue;
173
- (d ??= []).push(_[e] = createOwner());
174
- m[e] = runWithOwner(_[e], h);
332
+ for (e = h; e <= c; e++) {
333
+ if (A[e] !== undefined) continue;
334
+ (w ??= []).push(A[e] = createOwner());
335
+ if (false && attrHooks !== null) ;
336
+ y[e] = runWithOwner(A[e], o);
175
337
  }
176
338
  } catch (t) {
177
- if (d) for (i = 0; i < d.length; i++) d[i].dispose();
339
+ if (w) for (i = 0; i < w.length; i++) w[i].dispose();
178
340
  throw t;
179
341
  }
180
342
  // 3) commit: land the retained prefix and suffix plus the staged window
181
343
  // into the fresh arrays, swap them in (new identity for downstream
182
344
  // change propagation), then dispose exited rows
183
- for (i = 0; i < o; i++) {
184
- m[i] = this.xt[i];
185
- _[i] = this.Ut[i];
186
- r && (r[i] = this.qt[i]);
187
- n && (n[i] = this.zt[i]);
345
+ for (i = 0; i < h; i++) {
346
+ y[i] = this.St[i];
347
+ A[i] = this.gt[i];
348
+ r && (r[i] = this.Mt[i]);
349
+ n && (n[i] = this.jt[i]);
188
350
  }
189
- for (e = o; e <= a; e++) {
351
+ for (e = h; e <= c; e++) {
190
352
  if (r) setSignal(r[e], t[e]);
191
353
  if (n) setSignal(n[e], e);
192
354
  }
193
- for (e = a + 1; e < s; e++) {
194
- m[e] = this.xt[e - O];
195
- _[e] = this.Ut[e - O];
355
+ for (e = c + 1; e < s; e++) {
356
+ y[e] = this.St[e - _];
357
+ A[e] = this.gt[e - _];
196
358
  if (r) {
197
- r[e] = this.qt[e - O];
359
+ r[e] = this.Mt[e - _];
198
360
  setSignal(r[e], t[e]);
199
361
  }
200
362
  if (n) {
201
- n[e] = this.zt[e - O];
202
- if (O !== 0) setSignal(n[e], e);
363
+ n[e] = this.jt[e - _];
364
+ if (_ !== 0) setSignal(n[e], e);
203
365
  }
204
366
  }
205
- this.xt = m;
206
- this.Ut = _;
207
- r && (this.qt = r);
208
- n && (this.zt = n);
209
- this.jt = s;
367
+ this.St = y;
368
+ this.gt = A;
369
+ r && (this.Mt = r);
370
+ n && (this.jt = n);
371
+ this.wt = s;
210
372
  // save a copy of the mapped items for the next update
211
- this.Mt = t.slice(0);
212
- if (l) for (i = 0; i < l.length; i++) l[i].dispose();
373
+ this.yt = t.slice(0);
374
+ if (d) for (i = 0; i < d.length; i++) d[i].dispose();
375
+ if (false && attrHooks !== null && m !== undefined && O !== undefined) ;
213
376
  }
214
377
  });
215
- return this.xt;
378
+ return this.St;
216
379
  }
217
380
 
218
381
  /**
@@ -232,22 +395,22 @@ function updateKeyedMap() {
232
395
  */ function repeat(t, s, i) {
233
396
  const e = s;
234
397
  const r = {
235
- wt: createOwner(),
236
- jt: 0,
237
- Jt: 0,
238
- Vt: t,
239
- Kt: e,
240
- Ut: [],
241
- xt: [],
242
- Xt: i?.from,
243
- Ht: i?.fallback
398
+ ie: createOwner(),
399
+ wt: 0,
400
+ bt: 0,
401
+ It: t,
402
+ At: e,
403
+ gt: [],
404
+ St: [],
405
+ vt: i?.from,
406
+ Wt: i?.fallback
244
407
  };
245
408
  const n = computed(updateRepeat.bind(r));
246
409
  // Same as mapArray: untracked reads inside the internal owner resolve via
247
410
  // _parentComputed, so async reads in row callbacks register with the node
248
411
  // (pending tracking + post-settle retry) instead of vanishing.
249
- r.wt.dt = n;
250
- n.T &= ~CONFIG_AUTO_DISPOSE;
412
+ r.ie.qn = n;
413
+ n.C &= ~CONFIG_AUTO_DISPOSE;
251
414
  return accessor(n);
252
415
  }
253
416
 
@@ -259,55 +422,55 @@ function updateKeyedMap() {
259
422
  // for the post-settle retry. The overlap math also subsumes the previous
260
423
  // disjoint-window/front-clear/end-clear/shift special cases.
261
424
  function updateRepeat() {
262
- const t = this.Vt();
263
- const s = this.Xt?.() || 0;
264
- runWithOwner(this.wt, () => {
425
+ const t = this.It();
426
+ const s = this.vt?.() || 0;
427
+ runWithOwner(this.ie, () => {
265
428
  if (t === 0) {
266
- if (this.jt !== 0) {
267
- this.wt.dispose(false);
268
- this.Ut = [];
269
- this.xt = [];
270
- this.jt = 0;
429
+ if (this.wt !== 0) {
430
+ this.ie.dispose(false);
431
+ this.gt = [];
432
+ this.St = [];
433
+ this.wt = 0;
271
434
  // Reset offset to match the cleared data (#2767, repro 2).
272
- this.Jt = 0;
435
+ this.bt = 0;
273
436
  }
274
- if (this.Ht && !this.xt[0]) {
437
+ if (this.Wt && !this.St[0]) {
275
438
  // an aborted fallback attempt leaves an owner without a mapping;
276
439
  // dispose it before re-creating
277
- this.Ut[0]?.dispose();
278
- this.xt[0] = runWithOwner(this.Ut[0] = createOwner(), this.Ht);
440
+ this.gt[0]?.dispose();
441
+ this.St[0] = runWithOwner(this.gt[0] = createOwner(), this.Wt);
279
442
  }
280
443
  return;
281
444
  }
282
445
  const i = s + t;
283
- const e = this.Jt + this.jt;
446
+ const e = this.bt + this.wt;
284
447
  // Retained overlap [keepStart, keepEnd) in global indexes; empty when the
285
448
  // windows are disjoint or when coming from empty/fallback.
286
- const r = Math.max(s, this.Jt);
449
+ const r = Math.max(s, this.bt);
287
450
  const n = Math.min(i, e);
288
- const h = new Array(t);
289
451
  const o = new Array(t);
452
+ const h = new Array(t);
290
453
  for (let t = r; t < n; t++) {
291
- o[t - s] = this.Ut[t - this.Jt];
292
- h[t - s] = this.xt[t - this.Jt];
454
+ h[t - s] = this.gt[t - this.bt];
455
+ o[t - s] = this.St[t - this.bt];
293
456
  }
294
457
  try {
295
458
  for (let t = s; t < i; t++) {
296
459
  if (t >= r && t < n) continue;
297
- h[t - s] = runWithOwner(o[t - s] = createOwner(), () => this.Kt(t));
460
+ o[t - s] = runWithOwner(h[t - s] = createOwner(), () => this.At(t));
298
461
  }
299
462
  } catch (t) {
300
- for (let t = s; t < i; t++) if ((t < r || t >= n) && o[t - s]) o[t - s].dispose();
463
+ for (let t = s; t < i; t++) if ((t < r || t >= n) && h[t - s]) h[t - s].dispose();
301
464
  throw t;
302
465
  }
303
466
  // commit: dispose the previous fallback or the rows leaving the window
304
- if (this.jt === 0) this.Ut[0]?.dispose(); else for (let t = this.Jt; t < e; t++) if (t < s || t >= i) this.Ut[t - this.Jt].dispose();
305
- this.xt = h;
306
- this.Ut = o;
307
- this.Jt = s;
308
- this.jt = t;
467
+ if (this.wt === 0) this.gt[0]?.dispose(); else for (let t = this.bt; t < e; t++) if (t < s || t >= i) this.gt[t - this.bt].dispose();
468
+ this.St = o;
469
+ this.gt = h;
470
+ this.bt = s;
471
+ this.wt = t;
309
472
  });
310
- return this.xt;
473
+ return this.St;
311
474
  }
312
475
 
313
476
  function compare(t, s, i) {