@farm.js/react 0.1.0-beta.6 → 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 +79 -13
- package/dist/compiler-runtime.cjs +713 -31
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +25 -3
- package/dist/compiler-runtime.d.ts +25 -3
- package/dist/compiler-runtime.mjs +695 -32
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/vite.cjs +206 -15
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +206 -15
- package/dist/vite.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -300,19 +300,62 @@ expose the site count as `keyedArrayRollingWindowHints`.
|
|
|
300
300
|
Native known-position updates can avoid a complete keyed scan too:
|
|
301
301
|
|
|
302
302
|
```tsx
|
|
303
|
-
setItems((current) => current.toSpliced(
|
|
304
|
-
setItems((current) => current.
|
|
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));
|
|
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));
|
|
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));
|
|
305
315
|
```
|
|
306
316
|
|
|
307
|
-
The compiler recognizes only a concise functional setter
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
317
|
+
The compiler recognizes only a concise functional setter and either a safe-integer literal or a
|
|
318
|
+
compiler-safe runtime position expression, such as an identifier, property read, arithmetic,
|
|
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.
|
|
316
359
|
|
|
317
360
|
A direct native reverse can carry its complete permutation to a separate optional runtime:
|
|
318
361
|
|
|
@@ -330,6 +373,26 @@ React-owned rows, and failed checks keep complete keyed reconciliation. Reports
|
|
|
330
373
|
count as `keyedArrayReorderHints`, and modules without one omit the reorder runtime. Farm does not
|
|
331
374
|
polyfill `Array.prototype.toReversed`.
|
|
332
375
|
|
|
376
|
+
A direct native immutable sort can use the same optional reorder runtime:
|
|
377
|
+
|
|
378
|
+
```tsx
|
|
379
|
+
setItems((current) => current.toSorted((left, right) => left.rank - right.rank));
|
|
380
|
+
setLabels((current) => current.toSorted());
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
Farm recognizes a concise functional setter with no comparator or an inline synchronous comparator
|
|
384
|
+
from the compiler-safe expression subset. It preserves the original method lookup, comparator,
|
|
385
|
+
stable native result, and errors. After the native sort runs, the runtime validates a committed
|
|
386
|
+
ordinary dense array, equal lengths, and a unique one-to-one item-identity permutation. It then
|
|
387
|
+
uses LIS to move only `n - LIS` keyed DOM nodes without rereading row keys, descriptors, or
|
|
388
|
+
bindings. The native sorting work itself is unchanged.
|
|
389
|
+
|
|
390
|
+
Index-aware or collection-reading rows, referenced comparators, block-bodied updaters, computed or
|
|
391
|
+
chained calls, custom methods, sparse or subclassed arrays, duplicate item identities, queued
|
|
392
|
+
uncommitted sorts, nested or React-owned rows, and failed checks keep complete keyed
|
|
393
|
+
reconciliation. Reports expose the site count as `keyedArraySortHints`; sort shares the optional
|
|
394
|
+
reorder runtime, and Farm does not polyfill `Array.prototype.toSorted`.
|
|
395
|
+
|
|
333
396
|
Concise immutable filters on a direct keyed array can carry removal positions into the same
|
|
334
397
|
optional runtime:
|
|
335
398
|
|
|
@@ -631,9 +694,12 @@ reasons aggregated by count. Its summary and per-module `optimizations` also rep
|
|
|
631
694
|
`keyedArrayAppendHints`, the number of compiler-proven direct keyed-array append sites; and
|
|
632
695
|
`keyedArrayFilterHints`, the number of compiler-proven direct keyed-array filter sites; and
|
|
633
696
|
`keyedArrayPrependHints`, the number of compiler-proven direct keyed-array prepend sites; and
|
|
634
|
-
`keyedArrayPositionHints`, the number of compiler-proven native
|
|
635
|
-
replacement sites
|
|
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
|
|
636
701
|
`keyedArrayReorderHints`, the number of compiler-proven direct native keyed-array reverse sites; and
|
|
702
|
+
`keyedArraySortHints`, the number of compiler-proven direct native keyed-array sort sites; and
|
|
637
703
|
`keyedArrayRollingWindowHints`, the number of compiler-proven retained-tail plus incoming-suffix
|
|
638
704
|
sites; and
|
|
639
705
|
`keyedArraySliceHints`, the number of compiler-proven direct keyed-array slice sites. A custom
|