@farm.js/react 0.1.0-beta.7 → 0.1.0-beta.8

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.
package/README.md CHANGED
@@ -301,24 +301,61 @@ Native known-position updates can avoid a complete keyed scan too:
301
301
 
302
302
  ```tsx
303
303
  setItems((current) => current.toSpliced(selectedIndex, 0, nextItem));
304
+ setItems((current) => current.toSpliced(selectedIndex, 0, nextA, nextB));
305
+ setItems((current) => current.toSpliced(selectedIndex, 0, ...incomingItems));
304
306
  setItems((current) => current.toSpliced(selectedIndex, 1));
307
+ setItems((current) => current.toSpliced(selectedIndex, 25));
308
+ setItems((current) => current.toSpliced(selectedIndex, 1, replacement));
309
+ setItems((current) => current.toSpliced(selectedIndex, 25, ...replacements));
305
310
  setItems((current) => current.with(selectedIndex, replacement));
311
+
312
+ // Two same-key windows may be queued before one compiler flush.
313
+ setItems((current) => current.toSpliced(firstIndex, 25, ...firstRefresh));
314
+ setItems((current) => current.toSpliced(secondIndex, 25, ...secondRefresh));
306
315
  ```
307
316
 
308
317
  The compiler recognizes only a concise functional setter and either a safe-integer literal or a
309
318
  compiler-safe runtime position expression, such as an identifier, property read, arithmetic,
310
- conditional, or safe `Math` call. The update must insert one item with zero removals, remove one
311
- item, or directly replace one item. Farm preserves method lookup, evaluates the position and
312
- remaining arguments once in their original order, executes the ordinary native call, and records
313
- metadata only after validating the committed native source, result, and actual safe-integer
314
- position. The runtime creates one inserted row, removes one known row, or patches/replaces one row
315
- at that position without rereading every existing key, descriptor, and binding. Surviving rows keep
316
- their DOM identity. Index-aware or collection-reading rows, custom methods, position expressions
317
- with user calls or mutations, runtime positions that are not safe integers, other `toSpliced()`
318
- forms, block-bodied updaters, unsafe incoming expressions, queued uncommitted updates, reused keys,
319
- nested or React-owned rows, and failed checks use complete keyed reconciliation. Reports expose the
320
- site count as `keyedArrayPositionHints`; the capability is tree-shaken from modules that do not emit
321
- it.
319
+ conditional, or safe `Math` call. The update must insert one or more compiler-safe items with zero
320
+ removals, remove one item or a fixed positive safe-integer literal range, replace one item through
321
+ either `toSpliced()` or `with()`, or replace a fixed positive safe-integer literal window with
322
+ compiler-safe explicit items or a safe spread. Farm preserves method lookup,
323
+ evaluates the position and remaining arguments once in their original order, executes the ordinary
324
+ native call, and records metadata only after validating the committed native source, result, and
325
+ actual safe-integer position and clamped removal count. A batch requires at least two evaluated
326
+ items at runtime. Exact-window replacement supports a safe spread that evaluates to zero, one, or
327
+ many items. A fresh-key window creates every incoming key, descriptor, binding snapshot, and
328
+ detached row before changing the live DOM, rejects key collisions, and mounts the complete batch
329
+ through one document fragment. It then removes only the replaced window. When the incoming window
330
+ has the same length and the same keys in the same order, Farm prepares every binding read and
331
+ changed DOM target across the complete window first, patches the existing rows in place, and
332
+ updates the stored row objects used by later events. That path creates no descriptors or DOM rows,
333
+ and preserves row identity, focus, and selection. A fixed-length window may instead reorder keys
334
+ from inside its own removed interval and mix them with globally fresh keys. Farm prepares all
335
+ reused binding updates, new descriptors, binding snapshots, and detached rows before the first DOM
336
+ write. It removes only retired rows, preserves each reused row, batches adjacent new rows in a
337
+ fragment, and applies LIS only to the reused part of that interval so it moves the fewest connected
338
+ rows needed by the local permutation. Rows outside the interval are not rerendered or rebound.
339
+ Multiple length-preserving same-key windows
340
+ queued before one compiler flush compose into one atomic refresh. Fixed-length queued windows may
341
+ mix same-key refreshes with globally new final keys, and both disjoint and overlapping windows are
342
+ supported. An overlapping position uses the last queued value; intermediate identities are never
343
+ mounted. Farm validates the complete chain and final key set, then prepares every touched key,
344
+ binding value, DOM target, new descriptor, binding snapshot, and disconnected DOM row before the
345
+ first write. It patches same-key positions and swaps only final fresh-key positions. Untouched rows
346
+ keep their identity and are not recreated. The runtime otherwise creates one inserted row,
347
+ removes only the known row or range, or patches/replaces one row at that position without rereading
348
+ every existing key, descriptor, and binding. Surviving rows keep their DOM identity. Index-aware or
349
+ collection-reading rows, custom methods, position expressions with user calls or mutations,
350
+ runtime positions that are not safe integers, dynamic, zero, negative, or fractional removal
351
+ counts, other `toSpliced()` forms, block-bodied updaters, unsafe incoming expressions, queued
352
+ chains containing a structural window or unhinted intermediate update, existing keys moved from
353
+ outside the removed interval, length-changing partially reused windows, duplicate final keys,
354
+ nested or React-owned rows, and failed checks use complete keyed reconciliation before the fast
355
+ path mutates the DOM.
356
+ Reports expose the site count as `keyedArrayPositionHints`. Batch insertion and exact-window
357
+ replacement use progressively separate optional runtime capabilities, so existing single-position
358
+ and batch-only bundles do not retain window validation or replacement code.
322
359
 
323
360
  A direct native reverse can carry its complete permutation to a separate optional runtime:
324
361
 
@@ -657,8 +694,10 @@ reasons aggregated by count. Its summary and per-module `optimizations` also rep
657
694
  `keyedArrayAppendHints`, the number of compiler-proven direct keyed-array append sites; and
658
695
  `keyedArrayFilterHints`, the number of compiler-proven direct keyed-array filter sites; and
659
696
  `keyedArrayPrependHints`, the number of compiler-proven direct keyed-array prepend sites; and
660
- `keyedArrayPositionHints`, the number of compiler-proven native exact-position insertion, removal,
661
- or replacement sites, including guarded compiler-safe runtime positions; and
697
+ `keyedArrayPositionHints`, the number of compiler-proven native exact-position insertion, single or
698
+ contiguous-range removal, single-row replacement, or exact-window replacement sites, including
699
+ guarded compiler-safe runtime positions;
700
+ and
662
701
  `keyedArrayReorderHints`, the number of compiler-proven direct native keyed-array reverse sites; and
663
702
  `keyedArraySortHints`, the number of compiler-proven direct native keyed-array sort sites; and
664
703
  `keyedArrayRollingWindowHints`, the number of compiler-proven retained-tail plus incoming-suffix