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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/dev-shared.js +6357 -0
  2. package/dist/dev.attribution.js +2485 -0
  3. package/dist/dev.js +2851 -7027
  4. package/dist/observe/affects.js +129 -0
  5. package/dist/observe/attribution.js +7 -0
  6. package/dist/observe/boundaries.js +641 -0
  7. package/dist/observe/core/action.js +177 -0
  8. package/dist/observe/core/async.js +846 -0
  9. package/dist/observe/core/attribution-costs.js +66 -0
  10. package/dist/observe/core/attribution-feedback.js +282 -0
  11. package/dist/observe/core/attribution-hooks.js +82 -0
  12. package/dist/observe/core/attribution-queries.js +28 -0
  13. package/dist/observe/core/attribution.js +2095 -0
  14. package/dist/observe/core/constants.js +248 -0
  15. package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
  16. package/dist/observe/core/core.js +1789 -0
  17. package/dist/observe/core/dev.js +293 -0
  18. package/dist/observe/core/effect.js +195 -0
  19. package/dist/observe/core/error-hooks.js +71 -0
  20. package/dist/observe/core/error.js +80 -0
  21. package/dist/observe/core/external.js +98 -0
  22. package/dist/observe/core/graph.js +155 -0
  23. package/dist/observe/core/heap.js +147 -0
  24. package/dist/observe/core/invariants.js +45 -0
  25. package/dist/observe/core/lanes.js +205 -0
  26. package/dist/observe/core/optimistic.js +585 -0
  27. package/dist/observe/core/owner.js +322 -0
  28. package/dist/observe/core/scheduler.js +1428 -0
  29. package/dist/observe/core/verdict.js +669 -0
  30. package/dist/observe/index.js +59 -0
  31. package/dist/observe/map.js +484 -0
  32. package/dist/{types-cjs/signals.d.cts → observe/signals.js} +311 -317
  33. package/dist/observe/store/index.js +40 -0
  34. package/dist/observe/store/next/optimistic.js +660 -0
  35. package/dist/observe/store/next/projection.js +255 -0
  36. package/dist/observe/store/next/reconcile.js +375 -0
  37. package/dist/observe/store/next/store.js +2327 -0
  38. package/dist/observe/store/next/target.js +51 -0
  39. package/dist/observe/store/store.js +325 -0
  40. package/dist/observe/store/storePath.js +103 -0
  41. package/dist/observe/store/utils.js +1023 -0
  42. package/dist/prod/attribution.js +41 -0
  43. package/dist/prod/boundaries.js +128 -76
  44. package/dist/prod/core/action.js +65 -37
  45. package/dist/prod/core/async.js +324 -172
  46. package/dist/prod/core/constants.js +57 -1
  47. package/dist/prod/core/context.js +3 -3
  48. package/dist/prod/core/core.js +1003 -364
  49. package/dist/prod/core/dev.js +17 -1
  50. package/dist/prod/core/effect.js +76 -42
  51. package/dist/prod/core/error-hooks.js +71 -0
  52. package/dist/prod/core/external.js +4 -4
  53. package/dist/prod/core/graph.js +37 -37
  54. package/dist/prod/core/heap.js +61 -56
  55. package/dist/prod/core/lanes.js +107 -63
  56. package/dist/prod/core/optimistic.js +374 -93
  57. package/dist/prod/core/owner.js +62 -46
  58. package/dist/prod/core/scheduler.js +653 -286
  59. package/dist/prod/core/verdict.js +245 -127
  60. package/dist/prod/index.js +15 -5
  61. package/dist/prod/map.js +292 -141
  62. package/dist/prod/signals.js +29 -16
  63. package/dist/prod/store/next/optimistic.js +77 -55
  64. package/dist/prod/store/next/projection.js +31 -20
  65. package/dist/prod/store/next/reconcile.js +87 -84
  66. package/dist/prod/store/next/store.js +718 -401
  67. package/dist/prod/store/next/target.js +32 -10
  68. package/dist/prod/store/store.js +12 -14
  69. package/dist/prod/store/utils.js +950 -130
  70. package/dist/types/attribution.d.ts +20 -0
  71. package/dist/types/attribution.prod.d.ts +22 -0
  72. package/dist/types/boundaries.d.ts +10 -1
  73. package/dist/types/core/action.d.ts +12 -5
  74. package/dist/types/core/async.d.ts +1 -1
  75. package/dist/types/core/attribution-costs.d.ts +35 -0
  76. package/dist/types/core/attribution-feedback.d.ts +133 -0
  77. package/dist/types/core/attribution-hooks.d.ts +147 -9
  78. package/dist/types/core/attribution-queries.d.ts +10 -0
  79. package/dist/types/core/attribution.d.ts +216 -182
  80. package/dist/types/core/constants.d.ts +56 -0
  81. package/dist/types/core/core.d.ts +190 -2
  82. package/dist/types/core/dev.d.ts +246 -28
  83. package/dist/types/core/effect.d.ts +8 -1
  84. package/dist/types/core/error-hooks.d.ts +71 -0
  85. package/dist/types/core/index.d.ts +4 -1
  86. package/dist/types/core/invariants.d.ts +4 -0
  87. package/dist/types/core/lanes.d.ts +39 -5
  88. package/dist/types/core/scheduler.d.ts +153 -0
  89. package/dist/types/core/types.d.ts +32 -9
  90. package/dist/types/index.d.ts +10 -3
  91. package/dist/types/map.d.ts +2 -0
  92. package/dist/types/signals.d.ts +8 -0
  93. package/dist/types/store/index.d.ts +2 -0
  94. package/dist/types/store/next/optimistic.d.ts +1 -1
  95. package/dist/types/store/next/store.d.ts +11 -5
  96. package/dist/types/store/next/target.d.ts +37 -10
  97. package/dist/types/store/utils.d.ts +178 -0
  98. package/package.json +21 -17
  99. package/dist/node.cjs +0 -10541
  100. package/dist/node.dev.cjs +0 -13724
  101. package/dist/types-cjs/affects.d.cts +0 -47
  102. package/dist/types-cjs/boundaries.d.cts +0 -175
  103. package/dist/types-cjs/core/action.d.cts +0 -64
  104. package/dist/types-cjs/core/async.d.cts +0 -23
  105. package/dist/types-cjs/core/attribution-hooks.d.cts +0 -127
  106. package/dist/types-cjs/core/attribution.d.cts +0 -495
  107. package/dist/types-cjs/core/constants.d.cts +0 -159
  108. package/dist/types-cjs/core/core.d.cts +0 -185
  109. package/dist/types-cjs/core/dev.d.cts +0 -136
  110. package/dist/types-cjs/core/effect.d.cts +0 -30
  111. package/dist/types-cjs/core/error.d.cts +0 -56
  112. package/dist/types-cjs/core/external.d.cts +0 -15
  113. package/dist/types-cjs/core/graph.d.cts +0 -28
  114. package/dist/types-cjs/core/heap.d.cts +0 -24
  115. package/dist/types-cjs/core/index.d.cts +0 -13
  116. package/dist/types-cjs/core/invariants.d.cts +0 -59
  117. package/dist/types-cjs/core/lanes.d.cts +0 -54
  118. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  119. package/dist/types-cjs/core/owner.d.cts +0 -124
  120. package/dist/types-cjs/core/scheduler.d.cts +0 -236
  121. package/dist/types-cjs/core/types.d.cts +0 -204
  122. package/dist/types-cjs/core/verdict.d.cts +0 -2
  123. package/dist/types-cjs/index.d.cts +0 -10
  124. package/dist/types-cjs/map.d.cts +0 -69
  125. package/dist/types-cjs/package.json +0 -3
  126. package/dist/types-cjs/store/index.d.cts +0 -18
  127. package/dist/types-cjs/store/next/optimistic.d.cts +0 -25
  128. package/dist/types-cjs/store/next/projection.d.cts +0 -8
  129. package/dist/types-cjs/store/next/reconcile.d.cts +0 -10
  130. package/dist/types-cjs/store/next/store.d.cts +0 -121
  131. package/dist/types-cjs/store/next/target.d.cts +0 -166
  132. package/dist/types-cjs/store/store.d.cts +0 -143
  133. package/dist/types-cjs/store/storePath.d.cts +0 -58
  134. package/dist/types-cjs/store/utils.d.cts +0 -74
@@ -0,0 +1,59 @@
1
+ export { ContextNotFoundError, NoOwnerError, NotReadyError, TimeoutError } from "./core/error.js";
2
+
3
+ export { clearSnapshots, isEqual, markSnapshotScope, releaseSnapshotScope, runWithOwner, setSnapshotCapture, untrack } from "./core/core.js";
4
+
5
+ export { enableExternalSource } from "./core/external.js";
6
+
7
+ export { createOwner, createRoot, getNextChildId, getObserver, getOwner, isDisposed, peekNextChildId } from "./core/owner.js";
8
+
9
+ export { createContext, getContext, setContext } from "./core/context.js";
10
+
11
+ export { $REFRESH, SUPPORTS_PROXY } from "./core/constants.js";
12
+
13
+ import "./core/invariants.js";
14
+
15
+ import { OBSERVE as OBSERVE$1 } from "./core/dev.js";
16
+
17
+ export { ownerPath } from "./core/dev.js";
18
+
19
+ export { ROOT_ERROR_HOOK, enforceLoadingBoundary, flush, resetErrorHalt } from "./core/scheduler.js";
20
+
21
+ export { isPending, latest } from "./core/verdict.js";
22
+
23
+ import "./core/effect.js";
24
+
25
+ export { action } from "./core/action.js";
26
+
27
+ export { configureClientErrors } from "./core/error-hooks.js";
28
+
29
+ export { createEffect, createMemo, createOptimistic, createReaction, createRenderEffect, createSignal, createTrackedEffect, onCleanup, onSettled, refresh, resolve, until } from "./signals.js";
30
+
31
+ export { affects } from "./affects.js";
32
+
33
+ export { mapArray, repeat } from "./map.js";
34
+
35
+ export { createStore, deep, reconcile, snapshot } from "./store/index.js";
36
+
37
+ export { createErrorBoundary, createLoadingBoundary, createRevealOrder, flatten } from "./boundaries.js";
38
+
39
+ export { $PROXY, $TARGET, $TRACK, isWrappable } from "./store/store.js";
40
+
41
+ export { MergeView, OmitView, SOURCE_MEMO, SOURCE_MERGE, SOURCE_OMIT, SOURCE_PLAIN, SOURCE_PROXY, hasStaticKeys, isStatic, merge, mergeSources, mergeView, omit, omitView, resolvedTable, sourceGet, sourceHas, sourceKeys, sourceOwners, viewOf } from "./store/utils.js";
42
+
43
+ export { createOptimisticStoreNext as createOptimisticStore } from "./store/next/optimistic.js";
44
+
45
+ export { createProjectionNext as createProjection } from "./store/next/projection.js";
46
+
47
+ export { storeHasFamily, storeHasOptimisticFamily, storeIsShallow } from "./store/next/store.js";
48
+
49
+ export { storePath } from "./store/storePath.js";
50
+
51
+ /**
52
+ * Observe tier (diagnostics channel, attribution hook slot + interaction
53
+ * frame): dev and observe builds. The attribution engine itself is the
54
+ * `@solidjs/signals/attribution` entry.
55
+ */ const OBSERVE = OBSERVE$1;
56
+
57
+ /** Dev tier (devtools hooks, graph traversal, console reporting): dev builds only. */ const DEV = undefined;
58
+
59
+ export { DEV, OBSERVE };
@@ -0,0 +1,484 @@
1
+ import { computed, runWithOwner, signal, setSignal } from "./core/core.js";
2
+
3
+ import { createOwner } from "./core/owner.js";
4
+
5
+ import "./core/scheduler.js";
6
+
7
+ import { CONFIG_AUTO_DISPOSE } from "./core/constants.js";
8
+
9
+ import { attrHooks } from "./core/attribution-hooks.js";
10
+
11
+ import "./core/invariants.js";
12
+
13
+ import "./core/dev.js";
14
+
15
+ import "./core/verdict.js";
16
+
17
+ import "./core/effect.js";
18
+
19
+ import { accessor } from "./signals.js";
20
+
21
+ import { $TRACK } from "./store/store.js";
22
+
23
+ import "./store/next/store.js";
24
+
25
+ function mapArray(t, s, e) {
26
+ const i = typeof e?.keyed === "function" ? e.keyed : undefined;
27
+ const r = s.length > 1;
28
+ const n = s;
29
+ const o = {
30
+ nt: createOwner(),
31
+ ts: 0,
32
+ ss: t,
33
+ es: [],
34
+ rs: n,
35
+ ns: [],
36
+ hs: [],
37
+ En: i,
38
+ fs: i || e?.keyed === false ? [] : undefined,
39
+ cs: r && e?.keyed !== false ? [] : undefined,
40
+ us: e?.keyed === false,
41
+ ls: e?.fallback
42
+ };
43
+ const h = computed(updateKeyedMap.bind(o), e?.name ? {
44
+ name: e.name
45
+ } : undefined);
46
+ // Untracked reads inside the internal owner resolve via _parentComputed; routing
47
+ // them through node lets store-proxy lookups see pending writes (not stale _value).
48
+ o.nt.fn = h;
49
+ h.C &= ~CONFIG_AUTO_DISPOSE;
50
+ return accessor(h);
51
+ }
52
+
53
+ const pureOptions = {
54
+ ownedWrite: true
55
+ };
56
+
57
+ function trySmallMove(t, s, e, i) {
58
+ const r = t.es;
59
+ const n = t.ts - 1;
60
+ const o = [];
61
+ const h = [];
62
+ const f = [];
63
+ // flat triples: oldStart, newStart, length
64
+ let c = 256;
65
+ let a = i;
66
+ let u = i;
67
+ let l = false;
68
+ while (a <= n && u <= e - 1) {
69
+ const t = r[a];
70
+ const i = s[u];
71
+ if (t === i) {
72
+ if (!l) {
73
+ f.push(a, u, 0);
74
+ l = true;
75
+ }
76
+ f[f.length - 1]++;
77
+ a++;
78
+ u++;
79
+ continue;
80
+ }
81
+ l = false;
82
+ // Bounded realignment lookahead, shorter distance wins.
83
+ let d = -1;
84
+ let p = Math.min(32 - o.length, n - a, c);
85
+ for (let t = 1; t <= p; t++) {
86
+ if (r[a + t] === i) {
87
+ d = t;
88
+ break;
89
+ }
90
+ }
91
+ c -= d === -1 ? p : d;
92
+ let w = -1;
93
+ p = Math.min(32 - h.length, e - 1 - u, c);
94
+ for (let e = 1; e <= p; e++) {
95
+ if (s[u + e] === t) {
96
+ w = e;
97
+ break;
98
+ }
99
+ }
100
+ c -= w === -1 ? p : w;
101
+ if (d !== -1 && (w === -1 || d <= w)) {
102
+ while (d-- > 0) o.push(a++);
103
+ continue;
104
+ }
105
+ if (w !== -1) {
106
+ while (w-- > 0) h.push(u++);
107
+ continue;
108
+ }
109
+ if (c <= 0 || o.length === 32 || h.length === 32) return false;
110
+ o.push(a++);
111
+ h.push(u++);
112
+ }
113
+ for (;a <= n; a++) {
114
+ if (o.length === 32) return false;
115
+ o.push(a);
116
+ }
117
+ for (;u <= e - 1; u++) {
118
+ if (h.length === 32) return false;
119
+ h.push(u);
120
+ }
121
+ return commitSmallMove(t, s, e, o, h, f);
122
+ }
123
+
124
+ /** PHASE 2 of the small-move path, in its OWN function so that a pass which
125
+ * only SCANS and bails (a full replace: the first structural pass of a page,
126
+ * typically) compiles nothing but the scan — V8 parses and compiles lazily
127
+ * per function, and cold `replace` measured +0.5 ms with both phases in one
128
+ * body. Pairs displaced sources with destinations (an unmatched destination
129
+ * is a replacement/insertion → general path), then commits: slice() the live
130
+ * arrays, copy shifted runs, patch displaced pairs, dispose leftovers. */ function commitSmallMove(t, s, e, i, r, n) {
131
+ const o = t.es;
132
+ let h;
133
+ let f;
134
+ let c;
135
+ if (r.length !== 0) {
136
+ c = new Array(i.length);
137
+ for (f = 0; f < r.length; f++) {
138
+ let t = -1;
139
+ for (h = 0; h < i.length; h++) {
140
+ if (!c[h] && o[i[h]] === s[r[f]]) {
141
+ t = h;
142
+ break;
143
+ }
144
+ }
145
+ if (t === -1) return false;
146
+ c[t] = true;
147
+ r[f] = r[f] << 6 | t;
148
+ // pack pairing (found < 32)
149
+ }
150
+ }
151
+ // DUPLICATES: the general path pairs equal identities by OCCURRENCE ORDER
152
+ // (the chained index map). Displaced↔displaced pairing above is ascending
153
+ // on both sides, so it agrees; but an aligned run was matched by POSITION,
154
+ // and if a displaced identity also occurs inside a run the two algorithms
155
+ // can hand different occurrences different owners (row-local state moves;
156
+ // a shrink could dispose the wrong one). Decline that case — general path.
157
+ if (i.length !== 0 || r.length !== 0) {
158
+ const t = new Set;
159
+ for (h = 0; h < i.length; h++) t.add(o[i[h]]);
160
+ for (f = 0; f < r.length; f++) t.add(s[r[f] >> 6]);
161
+ for (let s = 0; s < n.length; s += 3) {
162
+ const e = n[s];
163
+ for (let i = 0, r = n[s + 2]; i < r; i++) if (t.has(o[e + i])) return false;
164
+ }
165
+ }
166
+ const a = t.ns;
167
+ const u = t.hs;
168
+ const l = a.slice(0, e);
169
+ const d = u.slice(0, e);
170
+ for (let t = 0; t < n.length; t += 3) {
171
+ const s = n[t];
172
+ const e = n[t + 1];
173
+ if (s !== e) {
174
+ for (let i = 0; i < n[t + 2]; i++) {
175
+ l[e + i] = a[s + i];
176
+ d[e + i] = u[s + i];
177
+ }
178
+ }
179
+ }
180
+ for (f = 0; f < r.length; f++) {
181
+ const t = r[f] >> 6;
182
+ const s = i[r[f] & 63];
183
+ l[t] = a[s];
184
+ d[t] = u[s];
185
+ }
186
+ t.ns = l;
187
+ t.hs = d;
188
+ t.ts = e;
189
+ t.es = s.slice(0);
190
+ // Dispose unmatched sources LAST (general-path ordering).
191
+ for (h = 0; h < i.length; h++) {
192
+ if (c === undefined || !c[h]) u[i[h]].dispose();
193
+ }
194
+ return true;
195
+ }
196
+
197
+ function updateKeyedMap() {
198
+ const t = this.ss() || [], s = t.length;
199
+ t[$TRACK];
200
+ // top level tracking
201
+ runWithOwner(this.nt, () => {
202
+ let e, i, r, n,
203
+ // Mappers write freshly-created row/index signals into the STAGE
204
+ // arrays (`rows`/`indexes`), never into `this._rows`/`this._indexes`.
205
+ o = this.fs ? this.us ? () => {
206
+ r[i] = signal(t[i], pureOptions);
207
+ return this.rs(accessor(r[i]), i);
208
+ } : () => {
209
+ r[i] = signal(t[i], pureOptions);
210
+ n && (n[i] = signal(i, pureOptions));
211
+ return this.rs(accessor(r[i]), n ? accessor(n[i]) : undefined);
212
+ } : this.cs ? () => {
213
+ const s = t[i];
214
+ n[i] = signal(i, pureOptions);
215
+ return this.rs(s, accessor(n[i]));
216
+ } : () => {
217
+ const s = t[i];
218
+ return this.rs(s);
219
+ };
220
+ // fast path for empty arrays
221
+ if (s === 0) {
222
+ if (this.ts !== 0) {
223
+ this.nt.dispose(false);
224
+ this.hs = [];
225
+ this.es = [];
226
+ this.ns = [];
227
+ this.ts = 0;
228
+ this.fs && (this.fs = []);
229
+ this.cs && (this.cs = []);
230
+ }
231
+ if (this.ls && !this.ns[0]) {
232
+ // an aborted fallback attempt leaves an owner without a mapping;
233
+ // dispose it before re-creating
234
+ this.hs[0]?.dispose();
235
+ this.ns[0] = runWithOwner(this.hs[0] = createOwner(), this.ls);
236
+ }
237
+ }
238
+ // fast path for new create
239
+ else if (this.ts === 0) {
240
+ const h = new Array(s);
241
+ const f = new Array(s);
242
+ r = this.fs && new Array(s);
243
+ n = this.cs && new Array(s);
244
+ try {
245
+ for (i = 0; i < s; i++) h[i] = runWithOwner(f[i] = createOwner(), o);
246
+ } catch (t) {
247
+ for (e = 0; e <= i; e++) f[e]?.dispose();
248
+ throw t;
249
+ }
250
+ // commit
251
+ if (this.hs[0]) this.hs[0].dispose();
252
+ // previous fallback
253
+ this.ns = h;
254
+ this.hs = f;
255
+ r && (this.fs = r);
256
+ n && (this.cs = n);
257
+ this.es = t.slice(0);
258
+ this.ts = s;
259
+ } else {
260
+ let h, f, c, a, u, l, d, p, w,
261
+ // Dev (attribution engine installed): the items behind the exited and
262
+ // entered rows, for the list-identity census.
263
+ m, O;
264
+ // skip common prefix
265
+ for (h = 0, f = Math.min(this.ts, s); h < f && (this.es[h] === t[h] || this.fs && compare(this.En, this.es[h], t[h])); h++) {
266
+ if (this.fs) setSignal(this.fs[h], t[h]);
267
+ }
268
+ // skip common suffix — counted only; retained entries land in one pass
269
+ // at commit instead of being staged and copied twice
270
+ for (f = this.ts - 1, c = s - 1; f >= h && c >= h && (this.es[f] === t[c] || this.fs && compare(this.En, this.es[f], t[c])); f--,
271
+ c--) ;
272
+ // no structural change (every position matched in place at equal
273
+ // length — the common post-reconcile shape): keep the same mapped
274
+ // array identity so downstream consumers don't re-run at all
275
+ if (h === s && this.ts === s) {
276
+ this.es = t.slice(0);
277
+ return;
278
+ }
279
+ // SMALL-MOVE FAST PATH: extracted to its own function — inlining it
280
+ // here bloats updateKeyedMap past the JIT's optimization budget and
281
+ // deoptimizes the GENERAL path (measured 2x on reverse). Gated to
282
+ // LARGE trimmed windows: when the trims already shrank the window
283
+ // (plain removals, tail edits), the general path is window-
284
+ // proportional and cheap — the fast path would only re-walk what the
285
+ // trims proved.
286
+ if (s <= this.ts && f - h > 64 && this.fs === undefined && this.cs === undefined) {
287
+ // PROBE before the scan: a small move keeps a mid-window item within
288
+ // ±32 of its old position; a REPLACE (all fresh items — the shape
289
+ // every page's first structural pass usually is) has it nowhere.
290
+ // ~65 compares, no allocation, and the scan function is never
291
+ // compiled for a replace (its cold first-call compile was the cost).
292
+ const e = h + (c - h >> 1);
293
+ const i = t[e];
294
+ const r = Math.min(f, e + 32);
295
+ let n = Math.max(h, e - 32);
296
+ while (n <= r && this.es[n] !== i) n++;
297
+ if (n <= r && trySmallMove(this, t, s, h)) return;
298
+ }
299
+ const _ = s - this.ts;
300
+ const y = new Array(s);
301
+ const A = new Array(s);
302
+ r = this.fs ? new Array(s) : undefined;
303
+ n = this.cs ? new Array(s) : undefined;
304
+ // 0) prepare a map of all indices in the changed window of newItems,
305
+ // scanning backwards so we encounter them in natural order
306
+ l = new Map;
307
+ d = new Array(c + 1);
308
+ for (i = c; i >= h; i--) {
309
+ a = t[i];
310
+ u = this.En ? this.En(a) : a;
311
+ e = l.get(u);
312
+ d[i] = e === undefined ? -1 : e;
313
+ l.set(u, i);
314
+ }
315
+ // 1) step through the old changed window and see if items can be found
316
+ // in the new set; if so, stage them at their new positions; if not,
317
+ // queue them for disposal at commit
318
+ for (e = h; e <= f; e++) {
319
+ a = this.es[e];
320
+ u = this.En ? this.En(a) : a;
321
+ i = l.get(u);
322
+ if (i !== undefined && i !== -1) {
323
+ y[i] = this.ns[e];
324
+ A[i] = this.hs[e];
325
+ r && (r[i] = this.fs[e]);
326
+ n && (n[i] = this.cs[e]);
327
+ i = d[i];
328
+ l.set(u, i);
329
+ } else {
330
+ (p ??= []).push(this.hs[e]);
331
+ if (true && attrHooks !== null) (m ??= []).push(a);
332
+ }
333
+ }
334
+ // 2) create new rows into the temp arrays; an abort disposes only these
335
+ try {
336
+ for (i = h; i <= c; i++) {
337
+ if (A[i] !== undefined) continue;
338
+ (w ??= []).push(A[i] = createOwner());
339
+ if (true && attrHooks !== null) (O ??= []).push(t[i]);
340
+ y[i] = runWithOwner(A[i], o);
341
+ }
342
+ } catch (t) {
343
+ if (w) for (e = 0; e < w.length; e++) w[e].dispose();
344
+ throw t;
345
+ }
346
+ // 3) commit: land the retained prefix and suffix plus the staged window
347
+ // into the fresh arrays, swap them in (new identity for downstream
348
+ // change propagation), then dispose exited rows
349
+ for (e = 0; e < h; e++) {
350
+ y[e] = this.ns[e];
351
+ A[e] = this.hs[e];
352
+ r && (r[e] = this.fs[e]);
353
+ n && (n[e] = this.cs[e]);
354
+ }
355
+ for (i = h; i <= c; i++) {
356
+ if (r) setSignal(r[i], t[i]);
357
+ if (n) setSignal(n[i], i);
358
+ }
359
+ for (i = c + 1; i < s; i++) {
360
+ y[i] = this.ns[i - _];
361
+ A[i] = this.hs[i - _];
362
+ if (r) {
363
+ r[i] = this.fs[i - _];
364
+ setSignal(r[i], t[i]);
365
+ }
366
+ if (n) {
367
+ n[i] = this.cs[i - _];
368
+ if (_ !== 0) setSignal(n[i], i);
369
+ }
370
+ }
371
+ this.ns = y;
372
+ this.hs = A;
373
+ r && (this.fs = r);
374
+ n && (this.cs = n);
375
+ this.ts = s;
376
+ // save a copy of the mapped items for the next update
377
+ this.es = t.slice(0);
378
+ if (p) for (e = 0; e < p.length; e++) p[e].dispose();
379
+ if (true && attrHooks !== null && m !== undefined && O !== undefined) attrHooks.listChurn(this.nt.fn, m, O, s, this.En !== undefined);
380
+ }
381
+ });
382
+ return this.ns;
383
+ }
384
+
385
+ /**
386
+ * Reactively renders a callback `count` times, reusing previously-rendered
387
+ * entries when only the count changes. Underlying helper for `<Repeat>`.
388
+ *
389
+ * - `options.from` — start index (default `0`); useful for offset/windowed
390
+ * rendering.
391
+ * - `options.fallback` — accessor returning a value to show when count is `0`.
392
+ *
393
+ * @example
394
+ * ```ts
395
+ * const view = repeat(count, i => `Item ${i}`, { fallback: () => "empty" });
396
+ * ```
397
+ *
398
+ * @description https://docs.solidjs.com/reference/reactive-utilities/repeat
399
+ */ function repeat(t, s, e) {
400
+ const i = s;
401
+ const r = {
402
+ nt: createOwner(),
403
+ ts: 0,
404
+ ds: 0,
405
+ ps: t,
406
+ rs: i,
407
+ hs: [],
408
+ ns: [],
409
+ ws: e?.from,
410
+ ls: e?.fallback
411
+ };
412
+ const n = computed(updateRepeat.bind(r));
413
+ // Same as mapArray: untracked reads inside the internal owner resolve via
414
+ // _parentComputed, so async reads in row callbacks register with the node
415
+ // (pending tracking + post-settle retry) instead of vanishing.
416
+ r.nt.fn = n;
417
+ n.C &= ~CONFIG_AUTO_DISPOSE;
418
+ return accessor(n);
419
+ }
420
+
421
+ // Same staged-commit discipline as `updateKeyedMap` (#2903): the retained
422
+ // window overlap is copied into fresh arrays, missing indexes are created
423
+ // into them, and `this` is only touched — including disposal of rows leaving
424
+ // the window — after every `_map` call succeeded. A NotReadyError mid-pass
425
+ // disposes only the owners this pass created and leaves prior state intact
426
+ // for the post-settle retry. The overlap math also subsumes the previous
427
+ // disjoint-window/front-clear/end-clear/shift special cases.
428
+ function updateRepeat() {
429
+ const t = this.ps();
430
+ const s = this.ws?.() || 0;
431
+ runWithOwner(this.nt, () => {
432
+ if (t === 0) {
433
+ if (this.ts !== 0) {
434
+ this.nt.dispose(false);
435
+ this.hs = [];
436
+ this.ns = [];
437
+ this.ts = 0;
438
+ // Reset offset to match the cleared data (#2767, repro 2).
439
+ this.ds = 0;
440
+ }
441
+ if (this.ls && !this.ns[0]) {
442
+ // an aborted fallback attempt leaves an owner without a mapping;
443
+ // dispose it before re-creating
444
+ this.hs[0]?.dispose();
445
+ this.ns[0] = runWithOwner(this.hs[0] = createOwner(), this.ls);
446
+ }
447
+ return;
448
+ }
449
+ const e = s + t;
450
+ const i = this.ds + this.ts;
451
+ // Retained overlap [keepStart, keepEnd) in global indexes; empty when the
452
+ // windows are disjoint or when coming from empty/fallback.
453
+ const r = Math.max(s, this.ds);
454
+ const n = Math.min(e, i);
455
+ const o = new Array(t);
456
+ const h = new Array(t);
457
+ for (let t = r; t < n; t++) {
458
+ h[t - s] = this.hs[t - this.ds];
459
+ o[t - s] = this.ns[t - this.ds];
460
+ }
461
+ try {
462
+ for (let t = s; t < e; t++) {
463
+ if (t >= r && t < n) continue;
464
+ o[t - s] = runWithOwner(h[t - s] = createOwner(), () => this.rs(t));
465
+ }
466
+ } catch (t) {
467
+ for (let t = s; t < e; t++) if ((t < r || t >= n) && h[t - s]) h[t - s].dispose();
468
+ throw t;
469
+ }
470
+ // commit: dispose the previous fallback or the rows leaving the window
471
+ if (this.ts === 0) this.hs[0]?.dispose(); else for (let t = this.ds; t < i; t++) if (t < s || t >= e) this.hs[t - this.ds].dispose();
472
+ this.ns = o;
473
+ this.hs = h;
474
+ this.ds = s;
475
+ this.ts = t;
476
+ });
477
+ return this.ns;
478
+ }
479
+
480
+ function compare(t, s, e) {
481
+ return t ? t(s) === t(e) : true;
482
+ }
483
+
484
+ export { mapArray, repeat };