kerfjs 5.0.0-beta.13 → 5.0.0-beta.131

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 (94) hide show
  1. package/CHANGELOG.md +3384 -108
  2. package/README.md +101 -37
  3. package/ai/cursorrules +127 -68
  4. package/ai/manifest.json +36 -7
  5. package/ai/skill.md +167 -86
  6. package/ai/ui-skill.md +18 -0
  7. package/dist/actions.d.ts +1 -1
  8. package/dist/actions.js +10 -6
  9. package/dist/actions.js.map +1 -1
  10. package/dist/array-signal.js +1 -1
  11. package/dist/async.d.ts +7 -3
  12. package/dist/async.js +39 -22
  13. package/dist/async.js.map +1 -1
  14. package/dist/attach.js +1 -66
  15. package/dist/attach.js.map +1 -1
  16. package/dist/{chunk-GY4XV2UV.js → chunk-4TX6YJDM.js} +10 -3
  17. package/dist/chunk-4TX6YJDM.js.map +1 -0
  18. package/dist/{chunk-SVATPF5R.js → chunk-5QDM6HPD.js} +637 -277
  19. package/dist/chunk-5QDM6HPD.js.map +1 -0
  20. package/dist/{chunk-QIP723L4.js → chunk-5WRGJZV6.js} +3 -2
  21. package/dist/chunk-5WRGJZV6.js.map +1 -0
  22. package/dist/chunk-AP2FT33F.js +87 -0
  23. package/dist/chunk-AP2FT33F.js.map +1 -0
  24. package/dist/chunk-BTOKH5FA.js +70 -0
  25. package/dist/chunk-BTOKH5FA.js.map +1 -0
  26. package/dist/{chunk-ZDCJZCNO.js → chunk-GGADRIQO.js} +168 -97
  27. package/dist/chunk-GGADRIQO.js.map +1 -0
  28. package/dist/chunk-KOEGJCIS.js +65 -0
  29. package/dist/chunk-KOEGJCIS.js.map +1 -0
  30. package/dist/{chunk-HW7KSM2Y.js → chunk-KUHXPPJ4.js} +1 -1
  31. package/dist/chunk-KUHXPPJ4.js.map +1 -0
  32. package/dist/{chunk-UZJ6I4T6.js → chunk-MK42GLPV.js} +1 -1
  33. package/dist/chunk-MK42GLPV.js.map +1 -0
  34. package/dist/chunk-N4VHHOCM.js +27 -0
  35. package/dist/chunk-N4VHHOCM.js.map +1 -0
  36. package/dist/{chunk-V46JKE44.js → chunk-NRPLVJVR.js} +43 -14
  37. package/dist/chunk-NRPLVJVR.js.map +1 -0
  38. package/dist/{chunk-LVH3GC6B.js → chunk-QOAB2ESQ.js} +3 -3
  39. package/dist/chunk-QOAB2ESQ.js.map +1 -0
  40. package/dist/{chunk-KZJXHFIB.js → chunk-V322Z7FX.js} +5 -5
  41. package/dist/chunk-V322Z7FX.js.map +1 -0
  42. package/dist/{delegate-CL9VTZFb.d.ts → delegate--CrfgYtC.d.ts} +0 -34
  43. package/dist/dev.d.ts +46 -15
  44. package/dist/dev.js +185 -40
  45. package/dist/dev.js.map +1 -1
  46. package/dist/html.js +20 -8
  47. package/dist/html.js.map +1 -1
  48. package/dist/index.d.ts +98 -13
  49. package/dist/index.js +49 -21
  50. package/dist/index.js.map +1 -1
  51. package/dist/jsx-runtime.d.ts +25 -10
  52. package/dist/jsx-runtime.js +1 -1
  53. package/dist/list.d.ts +7 -3
  54. package/dist/list.js +236 -78
  55. package/dist/list.js.map +1 -1
  56. package/dist/overlay.d.ts +287 -142
  57. package/dist/overlay.js +1040 -369
  58. package/dist/overlay.js.map +1 -1
  59. package/dist/remount.js +2 -2
  60. package/dist/remount.js.map +1 -1
  61. package/dist/router.d.ts +22 -6
  62. package/dist/router.js +58 -19
  63. package/dist/router.js.map +1 -1
  64. package/dist/scope.d.ts +45 -8
  65. package/dist/scope.js +69 -30
  66. package/dist/scope.js.map +1 -1
  67. package/dist/testing.js +1 -1
  68. package/dist/timing.d.ts +17 -7
  69. package/dist/timing.js +8 -3
  70. package/dist/timing.js.map +1 -1
  71. package/llms.txt +17 -6
  72. package/package.json +48 -12
  73. package/setup/apply.mjs +202 -0
  74. package/setup/cli.mjs +95 -0
  75. package/setup/common.mjs +91 -0
  76. package/setup/detect.mjs +274 -0
  77. package/setup/index.d.mts +39 -0
  78. package/setup/index.mjs +1290 -0
  79. package/setup/jsonc.mjs +201 -0
  80. package/setup/state.schema.json +57 -0
  81. package/setup/ui-baseline.mjs +210 -0
  82. package/dist/chunk-GY4XV2UV.js.map +0 -1
  83. package/dist/chunk-HW7KSM2Y.js.map +0 -1
  84. package/dist/chunk-KPXIOG2C.js +0 -54
  85. package/dist/chunk-KPXIOG2C.js.map +0 -1
  86. package/dist/chunk-KZJXHFIB.js.map +0 -1
  87. package/dist/chunk-LVH3GC6B.js.map +0 -1
  88. package/dist/chunk-QIP723L4.js.map +0 -1
  89. package/dist/chunk-SVATPF5R.js.map +0 -1
  90. package/dist/chunk-U6FK33SG.js +0 -20
  91. package/dist/chunk-U6FK33SG.js.map +0 -1
  92. package/dist/chunk-UZJ6I4T6.js.map +0 -1
  93. package/dist/chunk-V46JKE44.js.map +0 -1
  94. package/dist/chunk-ZDCJZCNO.js.map +0 -1
package/dist/list.js CHANGED
@@ -1,9 +1,9 @@
1
- import { ARRAY_SIGNAL_BRAND } from './chunk-LVH3GC6B.js';
2
- import { captureFocus, restoreFocus, moveNode, mount } from './chunk-SVATPF5R.js';
1
+ import { ARRAY_SIGNAL_BRAND } from './chunk-QOAB2ESQ.js';
2
+ import { captureFocus, restoreFocus, moveNode, mount } from './chunk-5QDM6HPD.js';
3
+ import { itemVersion } from './chunk-5WRGJZV6.js';
3
4
 
4
5
 
5
-
6
- import { effect } from './chunk-U6FK33SG.js';
6
+ import { effect } from './chunk-N4VHHOCM.js';
7
7
 
8
8
 
9
9
 
@@ -23,11 +23,13 @@ function createListRowController(options) {
23
23
  return null;
24
24
  };
25
25
  const makeRow = (item) => {
26
+ const version = itemVersion(item);
26
27
  const elementRow = asElementRow(render(item));
27
28
  if (elementRow !== null) {
28
29
  return {
29
30
  el: elementRow.el,
30
31
  item,
32
+ version,
31
33
  dispose: elementRow.dispose,
32
34
  elementMode: true,
33
35
  update: elementRow.update
@@ -35,14 +37,16 @@ function createListRowController(options) {
35
37
  }
36
38
  const el = document.createElement(tag);
37
39
  const dispose2 = mount(el, () => render(item));
38
- return { el, item, dispose: dispose2, elementMode: false };
40
+ return { el, item, version, dispose: dispose2, elementMode: false };
39
41
  };
40
42
  const reconcileItem = (row, item) => {
41
- if (row.item === item) return row;
43
+ const version = itemVersion(item);
44
+ if (row.item === item && row.version === version) return row;
42
45
  const oldKey = key(row.item);
43
46
  const newKey = key(item);
44
47
  if (row.elementMode) {
45
48
  row.item = item;
49
+ row.version = version;
46
50
  if (newKey !== oldKey) {
47
51
  rows.delete(oldKey);
48
52
  rows.set(newKey, row);
@@ -50,6 +54,12 @@ function createListRowController(options) {
50
54
  row.update?.(item);
51
55
  return row;
52
56
  }
57
+ if (row.item === item) {
58
+ row.dispose();
59
+ row.dispose = mount(row.el, () => render(item));
60
+ row.version = version;
61
+ return row;
62
+ }
53
63
  row.dispose();
54
64
  row.el.remove();
55
65
  rows.delete(oldKey);
@@ -87,7 +97,8 @@ function createListRowController(options) {
87
97
  let ref = endAnchor();
88
98
  for (let index = order.length - 1; index >= 0; index--) {
89
99
  const el = order[index].el;
90
- if (el.parentNode !== container || el.nextSibling !== ref) moveNode(container, el, ref);
100
+ if (el.parentNode !== container || el.nextSibling !== ref)
101
+ moveNode(container, el, ref);
91
102
  ref = el;
92
103
  }
93
104
  });
@@ -95,26 +106,41 @@ function createListRowController(options) {
95
106
  const applyPatches = (patches) => {
96
107
  preserveFocus(() => {
97
108
  for (const patch of patches) {
98
- if (patch.type === "insert") {
99
- const row = makeRow(patch.item);
100
- rows.set(key(patch.item), row);
101
- order.splice(patch.index, 0, row);
102
- container.insertBefore(row.el, order[patch.index + 1]?.el ?? endAnchor());
103
- } else if (patch.type === "remove") {
104
- const [row] = order.splice(patch.index, 1);
105
- row.dispose();
106
- row.el.remove();
107
- rows.delete(key(row.item));
108
- } else if (patch.type === "move") {
109
- const [row] = order.splice(patch.from, 1);
110
- order.splice(patch.to, 0, row);
111
- moveNode(container, row.el, order[patch.to + 1]?.el ?? endAnchor());
112
- } else if (patch.type === "update") {
113
- const current = order[patch.index];
114
- const row = reconcileItem(current, patch.item);
115
- if (row !== current) {
116
- order[patch.index] = row;
117
- container.insertBefore(row.el, order[patch.index + 1]?.el ?? endAnchor());
109
+ switch (patch.type) {
110
+ case "insert": {
111
+ const row = makeRow(patch.item);
112
+ rows.set(key(patch.item), row);
113
+ order.splice(patch.index, 0, row);
114
+ container.insertBefore(
115
+ row.el,
116
+ order[patch.index + 1]?.el ?? endAnchor()
117
+ );
118
+ break;
119
+ }
120
+ case "remove": {
121
+ const [row] = order.splice(patch.index, 1);
122
+ row.dispose();
123
+ row.el.remove();
124
+ rows.delete(key(row.item));
125
+ break;
126
+ }
127
+ case "move": {
128
+ const [row] = order.splice(patch.from, 1);
129
+ order.splice(patch.to, 0, row);
130
+ moveNode(container, row.el, order[patch.to + 1]?.el ?? endAnchor());
131
+ break;
132
+ }
133
+ case "update": {
134
+ const current = order[patch.index];
135
+ const row = reconcileItem(current, patch.item);
136
+ if (row !== current) {
137
+ order[patch.index] = row;
138
+ container.insertBefore(
139
+ row.el,
140
+ order[patch.index + 1]?.el ?? endAnchor()
141
+ );
142
+ }
143
+ break;
118
144
  }
119
145
  }
120
146
  }
@@ -132,30 +158,83 @@ function createListRowController(options) {
132
158
  }
133
159
 
134
160
  // src/list-virtualization-controller.ts
161
+ var FIXED = 0;
162
+ var DECLARED = 1;
163
+ var MEASURED = 2;
164
+ function assertHeight(value, what) {
165
+ if (!(typeof value === "number" && value >= 0 && value < Infinity))
166
+ throw new RangeError(
167
+ `bindList: ${what} must be a finite height >= 0 (got ${String(value)})`
168
+ );
169
+ return value;
170
+ }
171
+ function heightModelOf(virtualize) {
172
+ const { rowHeight } = virtualize;
173
+ switch (typeof rowHeight) {
174
+ case "number":
175
+ if (assertHeight(rowHeight, "rowHeight") === 0 && virtualize.mode !== "content-visibility")
176
+ throw new RangeError(
177
+ "bindList: a fixed rowHeight must be > 0 in window mode"
178
+ );
179
+ return { kind: FIXED, px: rowHeight };
180
+ case "function":
181
+ return { kind: DECLARED, at: rowHeight };
182
+ default: {
183
+ const estimate = rowHeight?.estimate;
184
+ if (typeof estimate !== "function")
185
+ assertHeight(estimate, "rowHeight.estimate");
186
+ return { kind: MEASURED, estimate: rowHeight.estimate };
187
+ }
188
+ }
189
+ }
190
+ function validateCounts(virtualize) {
191
+ const { overscan, minRows } = virtualize;
192
+ for (const [name, count] of [
193
+ ["overscan", overscan],
194
+ ["minRows", minRows]
195
+ ]) {
196
+ if (count !== void 0 && !(Number.isInteger(count) && count >= 0))
197
+ throw new RangeError(
198
+ `bindList: virtualize.${name} must be an integer >= 0 (got ${count})`
199
+ );
200
+ }
201
+ }
135
202
  function createListVirtualizationController(options) {
136
203
  const { parent, container, virtualize, key, rows } = options;
204
+ validateCounts(virtualize);
137
205
  const overscan = virtualize.overscan ?? 3;
138
- const { minRows, rowHeight } = virtualize;
206
+ const { minRows } = virtualize;
139
207
  const contentVisibility = virtualize.mode === "content-visibility";
140
- const fixedHeight = typeof rowHeight === "number" ? rowHeight : null;
141
- const measuring = typeof rowHeight === "object" && rowHeight !== null;
208
+ const model = heightModelOf(virtualize);
142
209
  const measured = /* @__PURE__ */ new Map();
143
210
  const indexByKey = /* @__PURE__ */ new Map();
144
211
  const renderSubscribers = /* @__PURE__ */ new Set();
145
212
  let items = [];
146
213
  let offsets = [0];
147
214
  let heightsDirty = true;
148
- let pendingAnchorDelta = 0;
215
+ const pendingAnchorBaselines = /* @__PURE__ */ new Map();
149
216
  let rafPending = false;
150
217
  let disposed = false;
151
- const estimateAt = (index) => {
152
- const estimate = rowHeight.estimate;
153
- return typeof estimate === "function" ? estimate(items[index], index) : estimate;
218
+ let frozen = false;
219
+ const estimateOf = (estimate, index) => typeof estimate === "function" ? assertHeight(
220
+ estimate(items[index], index),
221
+ `rowHeight.estimate(item, ${index})`
222
+ ) : estimate;
223
+ const heightAt = (index) => {
224
+ switch (model.kind) {
225
+ case FIXED:
226
+ return model.px;
227
+ case DECLARED:
228
+ return assertHeight(
229
+ model.at(items[index], index),
230
+ `rowHeight(item, ${index})`
231
+ );
232
+ case MEASURED:
233
+ return measured.get(key(items[index])) ?? estimateOf(model.estimate, index);
234
+ }
154
235
  };
155
- const variableHeightAt = fixedHeight !== null ? null : measuring ? (index) => measured.get(key(items[index])) ?? estimateAt(index) : (index) => rowHeight(items[index], index);
156
- const intrinsicSizeAt = (index) => fixedHeight ?? variableHeightAt(index);
157
236
  const rebuildOffsets = () => {
158
- const heightAt = variableHeightAt;
237
+ const measuring = model.kind === MEASURED;
159
238
  offsets = new Array(items.length + 1);
160
239
  offsets[0] = 0;
161
240
  if (measuring) indexByKey.clear();
@@ -167,6 +246,9 @@ function createListVirtualizationController(options) {
167
246
  for (const rowKey of measured.keys()) {
168
247
  if (!indexByKey.has(rowKey)) measured.delete(rowKey);
169
248
  }
249
+ for (const rowKey of pendingAnchorBaselines.keys()) {
250
+ if (!indexByKey.has(rowKey)) pendingAnchorBaselines.delete(rowKey);
251
+ }
170
252
  }
171
253
  };
172
254
  const findStart = (target, total) => {
@@ -190,10 +272,10 @@ function createListVirtualizationController(options) {
190
272
  return low;
191
273
  };
192
274
  const sizeRows = (start2) => {
193
- if (measuring) return;
275
+ if (model.kind === MEASURED) return;
194
276
  for (let index = 0; index < rows.order.length; index++) {
195
277
  const absoluteIndex = start2 + index;
196
- const height = fixedHeight ?? offsets[absoluteIndex + 1] - offsets[absoluteIndex];
278
+ const height = model.kind === FIXED ? model.px : offsets[absoluteIndex + 1] - offsets[absoluteIndex];
197
279
  rows.order[index].el.style.height = `${height}px`;
198
280
  }
199
281
  };
@@ -203,7 +285,7 @@ function createListVirtualizationController(options) {
203
285
  for (let index = 0; index < rows.order.length; index++) {
204
286
  const el = rows.order[index].el;
205
287
  el.style.contentVisibility = "auto";
206
- el.style.containIntrinsicSize = `0 ${intrinsicSizeAt(index)}px`;
288
+ el.style.containIntrinsicSize = `0 ${heightAt(index)}px`;
207
289
  }
208
290
  return;
209
291
  }
@@ -213,7 +295,7 @@ function createListVirtualizationController(options) {
213
295
  let padTop;
214
296
  let padBottom;
215
297
  if (minRows !== void 0 && total < minRows) {
216
- if (fixedHeight === null && heightsDirty) {
298
+ if (model.kind !== FIXED && heightsDirty) {
217
299
  rebuildOffsets();
218
300
  heightsDirty = false;
219
301
  }
@@ -221,22 +303,32 @@ function createListVirtualizationController(options) {
221
303
  end = total;
222
304
  padTop = 0;
223
305
  padBottom = 0;
224
- } else if (fixedHeight !== null) {
225
- const viewportBottom = parent.scrollTop + parent.clientHeight;
226
- start2 = Math.max(0, Math.floor(parent.scrollTop / fixedHeight) - overscan);
227
- end = Math.min(total, Math.ceil(viewportBottom / fixedHeight) + overscan);
228
- padTop = start2 * fixedHeight;
229
- padBottom = Math.max(0, total - end) * fixedHeight;
230
306
  } else {
231
- if (heightsDirty) {
232
- rebuildOffsets();
233
- heightsDirty = false;
307
+ const { scrollTop } = parent;
308
+ const viewportBottom = scrollTop + parent.clientHeight;
309
+ switch (model.kind) {
310
+ case FIXED: {
311
+ const { px } = model;
312
+ start2 = Math.min(
313
+ total,
314
+ Math.max(0, Math.floor(scrollTop / px) - overscan)
315
+ );
316
+ end = Math.min(total, Math.ceil(viewportBottom / px) + overscan);
317
+ padTop = start2 * px;
318
+ padBottom = Math.max(0, total - end) * px;
319
+ break;
320
+ }
321
+ case DECLARED:
322
+ case MEASURED:
323
+ if (heightsDirty) {
324
+ rebuildOffsets();
325
+ heightsDirty = false;
326
+ }
327
+ start2 = Math.max(0, findStart(scrollTop, total) - overscan);
328
+ end = Math.min(total, findEnd(viewportBottom, total) + overscan);
329
+ padTop = offsets[start2];
330
+ padBottom = offsets[total] - offsets[end];
234
331
  }
235
- const viewportBottom = parent.scrollTop + parent.clientHeight;
236
- start2 = Math.max(0, findStart(parent.scrollTop, total) - overscan);
237
- end = Math.min(total, findEnd(viewportBottom, total) + overscan);
238
- padTop = offsets[start2];
239
- padBottom = offsets[total] - offsets[end];
240
332
  }
241
333
  rows.sync(items.slice(start2, end));
242
334
  sizeRows(start2);
@@ -245,20 +337,37 @@ function createListVirtualizationController(options) {
245
337
  for (const callback of renderSubscribers) callback();
246
338
  };
247
339
  const render = (nextItems) => {
340
+ const wasFrozen = frozen;
248
341
  items = nextItems;
249
342
  heightsDirty = true;
343
+ frozen = false;
344
+ if (wasFrozen && pendingAnchorBaselines.size > 0) applyAnchorCorrection();
250
345
  renderCurrent();
251
346
  };
347
+ const reject = () => {
348
+ frozen = true;
349
+ };
350
+ const applyAnchorCorrection = () => {
351
+ if (heightsDirty) {
352
+ rebuildOffsets();
353
+ heightsDirty = false;
354
+ }
355
+ let delta = 0;
356
+ for (const [rowKey, baseline] of pendingAnchorBaselines) {
357
+ const index = indexByKey.get(rowKey);
358
+ if (offsets[index] + baseline <= parent.scrollTop)
359
+ delta += offsets[index + 1] - offsets[index] - baseline;
360
+ }
361
+ pendingAnchorBaselines.clear();
362
+ if (delta !== 0) parent.scrollTop += delta;
363
+ };
252
364
  const scheduleRender = () => {
253
365
  if (rafPending) return;
254
366
  rafPending = true;
255
367
  globalThis.requestAnimationFrame(() => {
256
368
  rafPending = false;
257
- if (disposed) return;
258
- if (pendingAnchorDelta !== 0) {
259
- parent.scrollTop += pendingAnchorDelta;
260
- pendingAnchorDelta = 0;
261
- }
369
+ if (disposed || frozen) return;
370
+ if (pendingAnchorBaselines.size > 0) applyAnchorCorrection();
262
371
  renderCurrent();
263
372
  });
264
373
  };
@@ -269,13 +378,15 @@ function createListVirtualizationController(options) {
269
378
  resizeObserver?.observe(parent);
270
379
  };
271
380
  const setHeight = (rowKey, height) => {
272
- if (!measuring || contentVisibility) return;
381
+ assertHeight(height, "setHeight()");
382
+ if (model.kind !== MEASURED || contentVisibility) return;
273
383
  const index = indexByKey.get(rowKey);
274
384
  if (index === void 0) return;
275
- const oldHeight = measured.get(rowKey) ?? estimateAt(index);
385
+ const oldHeight = measured.get(rowKey) ?? offsets[index + 1] - offsets[index];
276
386
  if (height === oldHeight) return;
277
387
  measured.set(rowKey, height);
278
- if (offsets[index + 1] <= parent.scrollTop) pendingAnchorDelta += height - oldHeight;
388
+ if (!pendingAnchorBaselines.has(rowKey))
389
+ pendingAnchorBaselines.set(rowKey, oldHeight);
279
390
  heightsDirty = true;
280
391
  scheduleRender();
281
392
  };
@@ -289,7 +400,15 @@ function createListVirtualizationController(options) {
289
400
  resizeObserver?.disconnect();
290
401
  renderSubscribers.clear();
291
402
  };
292
- return { contentVisibility, render, start, setHeight, onRender, dispose };
403
+ return {
404
+ contentVisibility,
405
+ render,
406
+ reject,
407
+ start,
408
+ setHeight,
409
+ onRender,
410
+ dispose
411
+ };
293
412
  }
294
413
 
295
414
  // src/list.ts
@@ -309,30 +428,54 @@ function assertUniqueListKeys(items, key) {
309
428
  firstIndex.set(rowKey, index);
310
429
  }
311
430
  }
431
+ function resolvePatchConsumer(source) {
432
+ const branded = source;
433
+ if (branded[ARRAY_SIGNAL_BRAND] !== true) return void 0;
434
+ const consume = branded._consumePatches;
435
+ if (typeof consume !== "function") {
436
+ throw new TypeError(
437
+ "bindList: source carries the arraySignal brand but has no _consumePatches() queue"
438
+ );
439
+ }
440
+ return consume.bind(source);
441
+ }
312
442
  function bindList(parent, source, options) {
313
443
  const { key, render, tag = "div", virtualize, before } = options;
314
444
  let firstRender = true;
315
445
  let forceSnapshot = false;
316
- const patchSource = source;
317
- const granularEligible = virtualize === void 0 && patchSource[ARRAY_SIGNAL_BRAND] === true;
446
+ const consumePatches = virtualize === void 0 ? resolvePatchConsumer(source) : void 0;
318
447
  const container = virtualize === void 0 ? parent : document.createElement("div");
319
448
  if (virtualize !== void 0) {
320
- if (virtualize.containerClass !== void 0) container.className = virtualize.containerClass;
321
- if (virtualize.containerId !== void 0) container.id = virtualize.containerId;
449
+ if (virtualize.containerClass !== void 0)
450
+ container.className = virtualize.containerClass;
451
+ if (virtualize.containerId !== void 0)
452
+ container.id = virtualize.containerId;
322
453
  }
323
454
  const endAnchor = () => {
324
455
  if (virtualize !== void 0 || before === void 0) return null;
325
456
  return (typeof before === "function" ? before() : before) ?? null;
326
457
  };
327
- const rows = createListRowController({ container, key, render, tag, endAnchor });
328
- const virtualization = virtualize === void 0 ? void 0 : createListVirtualizationController({ parent, container, virtualize, key, rows });
458
+ const rows = createListRowController({
459
+ container,
460
+ key,
461
+ render,
462
+ tag,
463
+ endAnchor
464
+ });
465
+ const virtualization = virtualize === void 0 ? void 0 : createListVirtualizationController({
466
+ parent,
467
+ container,
468
+ virtualize,
469
+ key,
470
+ rows
471
+ });
329
472
  const renderItems = (items) => {
330
473
  if (virtualization !== void 0) {
331
474
  virtualization.render(items);
332
475
  return;
333
476
  }
334
- if (granularEligible) {
335
- const patches = patchSource._consumePatches();
477
+ if (consumePatches !== void 0) {
478
+ const patches = consumePatches();
336
479
  if (!firstRender && !forceSnapshot && patches.length > 0 && !patches.some((patch) => patch.type === "replace")) {
337
480
  try {
338
481
  rows.applyPatches(patches);
@@ -343,23 +486,37 @@ function bindList(parent, source, options) {
343
486
  return;
344
487
  }
345
488
  }
346
- rows.sync(items);
489
+ try {
490
+ rows.sync(items);
491
+ } catch (error) {
492
+ forceSnapshot = true;
493
+ throw error;
494
+ }
347
495
  firstRender = false;
348
496
  forceSnapshot = false;
349
497
  };
350
- const stopEffect = effect(() => {
498
+ const track = () => {
351
499
  const items = source.value;
352
500
  try {
353
501
  assertUniqueListKeys(items, key);
354
502
  } catch (error) {
355
- if (granularEligible) {
356
- patchSource._consumePatches();
503
+ virtualization?.reject();
504
+ if (consumePatches !== void 0) {
505
+ consumePatches();
357
506
  forceSnapshot = true;
358
507
  }
359
508
  throw error;
360
509
  }
361
510
  renderItems(items);
362
- });
511
+ };
512
+ let stopEffect;
513
+ try {
514
+ stopEffect = effect(track);
515
+ } catch (error) {
516
+ rows.dispose(true);
517
+ virtualization?.dispose();
518
+ throw error;
519
+ }
363
520
  if (virtualization !== void 0) {
364
521
  parent.appendChild(container);
365
522
  virtualization.start();
@@ -395,7 +552,8 @@ function observeRowHeights(handle) {
395
552
  const observer = new RO((entries) => {
396
553
  for (const entry of entries) {
397
554
  const k = keyByEl.get(entry.target);
398
- if (k !== void 0) handle.setHeight(k, entry.target.offsetHeight);
555
+ if (k !== void 0)
556
+ handle.setHeight(k, entry.target.offsetHeight);
399
557
  }
400
558
  });
401
559
  const resync = () => {