@farm.js/react 0.1.0-beta.23 → 0.1.0-beta.25
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 +19 -0
- package/dist/compiler-runtime.cjs +191 -27
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +4 -1
- package/dist/compiler-runtime.d.ts +4 -1
- package/dist/compiler-runtime.mjs +189 -28
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/vite.cjs +72 -9
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +72 -9
- package/dist/vite.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -289,6 +289,18 @@ itself, and failed runtime checks use complete keyed reconciliation. A key that
|
|
|
289
289
|
collection prevents hint emission entirely. The compiler report exposes the emitted-site count as
|
|
290
290
|
`keyedArrayAppendHints`.
|
|
291
291
|
|
|
292
|
+
When all keyed-row plans in a component are plain, target-free rows and the only emitted update
|
|
293
|
+
hints are appends, the compiler selects a smaller append-only runtime. This omits unused map-update
|
|
294
|
+
and keyed-target fast paths, not support for other state changes: opaque updates and rejected hints
|
|
295
|
+
still use complete keyed reconciliation. Mixed hints, targeted bindings, conditional rows, and host
|
|
296
|
+
blocks keep their existing runtime. No additional option is required.
|
|
297
|
+
|
|
298
|
+
The same component-wide proof selects a smaller removal-only runtime when the only emitted
|
|
299
|
+
update hints are `filter()` and/or `slice()`. It omits unused append, map-update, and keyed-target
|
|
300
|
+
fast paths while retaining complete keyed reconciliation for opaque updates or rejected hints.
|
|
301
|
+
A sibling list requiring broader hints, targeted bindings, conditional rows, or host blocks keeps
|
|
302
|
+
the existing combined runtime. This changes bundle selection, not native array or React semantics.
|
|
303
|
+
|
|
292
304
|
Adjacent removal and append setters can share the same committed-row proof:
|
|
293
305
|
|
|
294
306
|
```tsx
|
|
@@ -374,6 +386,13 @@ positions into the prepend. The runtime removes only rejected rows, preserves ev
|
|
|
374
386
|
node, and creates only the final prefix instead of rescanning and rebinding the whole result.
|
|
375
387
|
Multiple adjacent prepends share the same proof.
|
|
376
388
|
|
|
389
|
+
When every keyed list in a component is plain and has no targeted bindings, and prepend is
|
|
390
|
+
the only emitted update hint, Farm selects a smaller prepend-only runtime. It omits unused
|
|
391
|
+
target and map/append fast paths, but keeps the same prepend validation and complete keyed
|
|
392
|
+
reconciliation for opaque or rejected updates. Mixed hints, conditional/host rows, and targeted
|
|
393
|
+
bindings on any sibling list keep their existing runtime. This changes bundle size, not the
|
|
394
|
+
supported update semantics or the prepend algorithm.
|
|
395
|
+
|
|
377
396
|
The setter may be concise or use a block containing exactly one direct value-returning `return`.
|
|
378
397
|
Extra statements, conditional returns, and missing returns keep complete keyed reconciliation.
|
|
379
398
|
|
|
@@ -177,7 +177,8 @@ function compilerKeyedArrayFilterSurvivorsFromUpdate(update, sourceToken, expect
|
|
|
177
177
|
if (current.sourceToken !== sourceToken) return void 0;
|
|
178
178
|
updates.push(current);
|
|
179
179
|
}
|
|
180
|
-
let survivors = Array
|
|
180
|
+
let survivors = new Array(expectedLength);
|
|
181
|
+
for (let index = 0; index < expectedLength; index += 1) survivors[index] = index;
|
|
181
182
|
let keysStable = true;
|
|
182
183
|
for (let updateIndex = updates.length - 1; updateIndex >= 0; updateIndex -= 1) {
|
|
183
184
|
const current = updates[updateIndex];
|
|
@@ -2028,16 +2029,25 @@ function applyStaticRangeBindings(bindings, segments, values) {
|
|
|
2028
2029
|
return true;
|
|
2029
2030
|
}
|
|
2030
2031
|
var COMPILER_KEYED_ROLLING_WINDOW_DELTAS = /* @__PURE__ */ new WeakMap();
|
|
2032
|
+
var COMPILER_KEYED_APPEND_DELTAS = /* @__PURE__ */ new WeakMap();
|
|
2031
2033
|
function keyedRowInstancesByKey(instances) {
|
|
2032
2034
|
return new Map(instances.map((instance) => [instance.key, instance]));
|
|
2033
2035
|
}
|
|
2034
2036
|
var UNSET_KEYED_ROW_BINDING = /* @__PURE__ */ Symbol("unset interactive keyed-row binding");
|
|
2037
|
+
var KEYED_ROWS_MAX_MOVED = 64;
|
|
2035
2038
|
function keyedRowIdentity(key) {
|
|
2036
|
-
|
|
2039
|
+
if (typeof key === "number") return key;
|
|
2040
|
+
const text = String(key);
|
|
2041
|
+
const first = text.charCodeAt(0);
|
|
2042
|
+
if (first >= 48 && first <= 57 || first === 45 || first === 73 || first === 78) {
|
|
2043
|
+
const number = Number(text);
|
|
2044
|
+
if (String(number) === text) return number;
|
|
2045
|
+
}
|
|
2046
|
+
return text;
|
|
2037
2047
|
}
|
|
2038
2048
|
function keyedIdentityTargetSnapshot(value) {
|
|
2039
2049
|
const kind = typeof value;
|
|
2040
|
-
return value === null || value === void 0 || kind === "string" || kind === "number" || kind === "bigint" ? { eligible: true, key:
|
|
2050
|
+
return value === null || value === void 0 || kind === "string" || kind === "number" || kind === "bigint" ? { eligible: true, key: keyedRowIdentity(value) } : { eligible: false };
|
|
2041
2051
|
}
|
|
2042
2052
|
var NATIVE_SET_PROTOTYPE = Set.prototype;
|
|
2043
2053
|
var NATIVE_SET_ADD = Set.prototype.add;
|
|
@@ -2083,7 +2093,7 @@ function keyedMembershipDeltaSnapshot(value, previous) {
|
|
|
2083
2093
|
const before = keyedMembershipSnapshotHas(previous, key);
|
|
2084
2094
|
if (before === void 0) return void 0;
|
|
2085
2095
|
changes.set(key, present);
|
|
2086
|
-
if (before !== present) NATIVE_SET_ADD.call(targetedKeys,
|
|
2096
|
+
if (before !== present) NATIVE_SET_ADD.call(targetedKeys, keyedRowIdentity(key));
|
|
2087
2097
|
}
|
|
2088
2098
|
} catch {
|
|
2089
2099
|
return void 0;
|
|
@@ -2137,10 +2147,10 @@ function keyedMembershipChangedKeys(previousSnapshot, nextSnapshot) {
|
|
|
2137
2147
|
const keys = /* @__PURE__ */ new Set();
|
|
2138
2148
|
if (!previous || !next) return keys;
|
|
2139
2149
|
for (const value of previous) {
|
|
2140
|
-
if (!NATIVE_SET_HAS.call(next, value)) NATIVE_SET_ADD.call(keys,
|
|
2150
|
+
if (!NATIVE_SET_HAS.call(next, value)) NATIVE_SET_ADD.call(keys, keyedRowIdentity(value));
|
|
2141
2151
|
}
|
|
2142
2152
|
for (const value of next) {
|
|
2143
|
-
if (!NATIVE_SET_HAS.call(previous, value)) NATIVE_SET_ADD.call(keys,
|
|
2153
|
+
if (!NATIVE_SET_HAS.call(previous, value)) NATIVE_SET_ADD.call(keys, keyedRowIdentity(value));
|
|
2144
2154
|
}
|
|
2145
2155
|
return keys;
|
|
2146
2156
|
}
|
|
@@ -2201,7 +2211,7 @@ function keyedMapLookupDeltaSnapshot(value, previous) {
|
|
|
2201
2211
|
if (!before) return void 0;
|
|
2202
2212
|
changes.set(key, { present, ...present ? { value: entry } : {} });
|
|
2203
2213
|
if (before.present !== present || !Object.is(before.value, entry)) {
|
|
2204
|
-
NATIVE_SET_ADD.call(targetedKeys,
|
|
2214
|
+
NATIVE_SET_ADD.call(targetedKeys, keyedRowIdentity(key));
|
|
2205
2215
|
}
|
|
2206
2216
|
}
|
|
2207
2217
|
} catch {
|
|
@@ -2259,12 +2269,12 @@ function keyedMapLookupChangedKeys(previousSnapshot, nextSnapshot) {
|
|
|
2259
2269
|
if (!previous || !next) return keys;
|
|
2260
2270
|
for (const [key, value] of previous) {
|
|
2261
2271
|
if (!Object.is(value, NATIVE_MAP_GET.call(next, key))) {
|
|
2262
|
-
NATIVE_SET_ADD.call(keys,
|
|
2272
|
+
NATIVE_SET_ADD.call(keys, keyedRowIdentity(key));
|
|
2263
2273
|
}
|
|
2264
2274
|
}
|
|
2265
2275
|
for (const [key, value] of next) {
|
|
2266
2276
|
if (!Object.is(value, NATIVE_MAP_GET.call(previous, key))) {
|
|
2267
|
-
NATIVE_SET_ADD.call(keys,
|
|
2277
|
+
NATIVE_SET_ADD.call(keys, keyedRowIdentity(key));
|
|
2268
2278
|
}
|
|
2269
2279
|
}
|
|
2270
2280
|
return keys;
|
|
@@ -2636,17 +2646,34 @@ function prepareKeyedRowBindingUpdate(props, instance, item, index, bindingIndex
|
|
|
2636
2646
|
return [bindingIndex, target, value];
|
|
2637
2647
|
}
|
|
2638
2648
|
function prepareKeyedRowBindingUpdates(props, instance, item, index) {
|
|
2649
|
+
let first;
|
|
2639
2650
|
let updates;
|
|
2640
2651
|
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
2641
2652
|
const update = prepareKeyedRowBindingUpdate(props, instance, item, index, bindingIndex);
|
|
2642
2653
|
if (update === void 0) return void 0;
|
|
2643
|
-
if (update)
|
|
2654
|
+
if (update) {
|
|
2655
|
+
if (updates) updates.push(update);
|
|
2656
|
+
else if (first) {
|
|
2657
|
+
updates = [];
|
|
2658
|
+
updates.push(first);
|
|
2659
|
+
updates.push(update);
|
|
2660
|
+
} else first = update;
|
|
2661
|
+
}
|
|
2644
2662
|
}
|
|
2645
|
-
return updates || NO_KEYED_ROW_BINDING_UPDATES;
|
|
2663
|
+
return updates || first || NO_KEYED_ROW_BINDING_UPDATES;
|
|
2646
2664
|
}
|
|
2647
2665
|
var NO_KEYED_ROW_BINDING_UPDATES = [];
|
|
2648
2666
|
function applyPreparedKeyedRowBindingUpdates(props, instance, updates) {
|
|
2649
|
-
|
|
2667
|
+
if (typeof updates[0] === "number") {
|
|
2668
|
+
const [bindingIndex, target, value] = updates;
|
|
2669
|
+
commitKeyedRowBinding(props.bindings[bindingIndex], instance, bindingIndex, value, target);
|
|
2670
|
+
return;
|
|
2671
|
+
}
|
|
2672
|
+
for (const [
|
|
2673
|
+
bindingIndex,
|
|
2674
|
+
target,
|
|
2675
|
+
value
|
|
2676
|
+
] of updates) {
|
|
2650
2677
|
commitKeyedRowBinding(props.bindings[bindingIndex], instance, bindingIndex, value, target);
|
|
2651
2678
|
}
|
|
2652
2679
|
}
|
|
@@ -3920,7 +3947,7 @@ function createHostConditionalBlockComponent(owner) {
|
|
|
3920
3947
|
schedulePropSync() {
|
|
3921
3948
|
if (this.propSyncQueued) return;
|
|
3922
3949
|
this.propSyncQueued = true;
|
|
3923
|
-
|
|
3950
|
+
scheduleCompilerMicrotask(() => {
|
|
3924
3951
|
this.propSyncQueued = false;
|
|
3925
3952
|
if (this.mounted && !this.state.fallback) {
|
|
3926
3953
|
this.listen();
|
|
@@ -4378,6 +4405,18 @@ function reorderCompilerKeyedRows(root, instances, sequence, anchor) {
|
|
|
4378
4405
|
}
|
|
4379
4406
|
restoreCompilerFocus(activeElement);
|
|
4380
4407
|
}
|
|
4408
|
+
var RESOLVED_COMPILER_MICROTASK = Promise.resolve();
|
|
4409
|
+
function scheduleCompilerMicrotask(callback) {
|
|
4410
|
+
void RESOLVED_COMPILER_MICROTASK.then(() => {
|
|
4411
|
+
try {
|
|
4412
|
+
callback();
|
|
4413
|
+
} catch (error) {
|
|
4414
|
+
queueMicrotask(() => {
|
|
4415
|
+
throw error;
|
|
4416
|
+
});
|
|
4417
|
+
}
|
|
4418
|
+
});
|
|
4419
|
+
}
|
|
4381
4420
|
function compilerFocusedElement(root) {
|
|
4382
4421
|
const activeElement = root.ownerDocument.activeElement;
|
|
4383
4422
|
return activeElement && root.contains(activeElement) ? activeElement : null;
|
|
@@ -4406,6 +4445,11 @@ var keyedUpdateRuntime = {
|
|
|
4406
4445
|
commit: commitCompilerKeyedCollection,
|
|
4407
4446
|
reconcile: reconcileCompilerKeyedMapUpdate
|
|
4408
4447
|
};
|
|
4448
|
+
var keyedAppendOnlyUpdateRuntime = {
|
|
4449
|
+
append: reconcileCompilerKeyedArrayAppend,
|
|
4450
|
+
commit: commitCompilerKeyedCollection,
|
|
4451
|
+
reconcile: () => void 0
|
|
4452
|
+
};
|
|
4409
4453
|
var keyedFilterUpdateRuntime = {
|
|
4410
4454
|
...keyedUpdateRuntime,
|
|
4411
4455
|
filter: reconcileCompilerKeyedArrayFilter
|
|
@@ -4420,6 +4464,12 @@ var keyedPrependUpdateRuntime = {
|
|
|
4420
4464
|
...keyedUpdateRuntime,
|
|
4421
4465
|
prepend: reconcileCompilerKeyedArrayPrepend
|
|
4422
4466
|
};
|
|
4467
|
+
var keyedPrependOnlyUpdateRuntime = {
|
|
4468
|
+
append: () => void 0,
|
|
4469
|
+
commit: commitCompilerKeyedCollection,
|
|
4470
|
+
reconcile: () => void 0,
|
|
4471
|
+
prepend: reconcileCompilerKeyedArrayPrepend
|
|
4472
|
+
};
|
|
4423
4473
|
var keyedFilterPrependUpdateRuntime = {
|
|
4424
4474
|
...keyedFilterUpdateRuntime,
|
|
4425
4475
|
prepend: reconcileCompilerKeyedArrayPrepend
|
|
@@ -4631,13 +4681,14 @@ function reconcileCompilerKeyedArrayAppend(props, dirtyState, collectionToken, i
|
|
|
4631
4681
|
const finalValue = props.items();
|
|
4632
4682
|
const startIndex = compilerKeyedArrayAppendStart(finalValue, collectionToken, instances.size);
|
|
4633
4683
|
if (startIndex === void 0 || !Array.isArray(finalValue)) return void 0;
|
|
4634
|
-
const
|
|
4684
|
+
const appendedKeys = /* @__PURE__ */ new Set();
|
|
4635
4685
|
const appended = [];
|
|
4636
4686
|
try {
|
|
4637
4687
|
for (let index = startIndex; index < finalValue.length; index += 1) {
|
|
4638
4688
|
const item = finalValue[index];
|
|
4639
4689
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
4640
|
-
if (
|
|
4690
|
+
if (instances.has(key) || appendedKeys.has(key)) return void 0;
|
|
4691
|
+
appendedKeys.add(key);
|
|
4641
4692
|
const instance = createKeyedRowInstance(
|
|
4642
4693
|
props,
|
|
4643
4694
|
root.ownerDocument,
|
|
@@ -4646,7 +4697,6 @@ function reconcileCompilerKeyedArrayAppend(props, dirtyState, collectionToken, i
|
|
|
4646
4697
|
index
|
|
4647
4698
|
);
|
|
4648
4699
|
appended.push(instance);
|
|
4649
|
-
nextInstances.set(key, instance);
|
|
4650
4700
|
}
|
|
4651
4701
|
} catch {
|
|
4652
4702
|
return void 0;
|
|
@@ -4656,7 +4706,10 @@ function reconcileCompilerKeyedArrayAppend(props, dirtyState, collectionToken, i
|
|
|
4656
4706
|
for (const instance of appended) fragment.append(instance.element);
|
|
4657
4707
|
root.append(fragment);
|
|
4658
4708
|
}
|
|
4659
|
-
|
|
4709
|
+
const mutableInstances = instances;
|
|
4710
|
+
for (const instance of appended) mutableInstances.set(instance.key, instance);
|
|
4711
|
+
COMPILER_KEYED_APPEND_DELTAS.set(mutableInstances, appended);
|
|
4712
|
+
return mutableInstances;
|
|
4660
4713
|
}
|
|
4661
4714
|
function reconcileCompilerKeyedArrayStructuralAppend(props, dirtyState, collectionToken, instances, root, reactOwnedRows) {
|
|
4662
4715
|
if (reactOwnedRows || props.hostBlocks || (props.conditionals?.length || 0) > 0 || !props.filterIndexIndependent || props.collectionDependency === void 0) {
|
|
@@ -6139,8 +6192,16 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6139
6192
|
this.hasReactOwnedRows()
|
|
6140
6193
|
);
|
|
6141
6194
|
if (appendedInstances) {
|
|
6195
|
+
const appended = COMPILER_KEYED_APPEND_DELTAS.get(appendedInstances);
|
|
6196
|
+
COMPILER_KEYED_APPEND_DELTAS.delete(appendedInstances);
|
|
6142
6197
|
this.instances = appendedInstances instanceof Map ? appendedInstances : new Map(appendedInstances);
|
|
6143
|
-
|
|
6198
|
+
if (appended && this.elementIndexComplete) {
|
|
6199
|
+
for (const instance of appended) {
|
|
6200
|
+
this.instancesByElement.set(instance.element, instance);
|
|
6201
|
+
}
|
|
6202
|
+
} else {
|
|
6203
|
+
this.rebuildElementIndex(this.instances);
|
|
6204
|
+
}
|
|
6144
6205
|
this.commitCurrentCollection(dirtyState);
|
|
6145
6206
|
afterCommit?.();
|
|
6146
6207
|
return;
|
|
@@ -6256,15 +6317,41 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6256
6317
|
const keys = [];
|
|
6257
6318
|
const committedSize = this.instances.size;
|
|
6258
6319
|
let prefix = 0;
|
|
6320
|
+
let tracking = true;
|
|
6321
|
+
let moved;
|
|
6322
|
+
let displaced;
|
|
6259
6323
|
const committed = this.instances.keys();
|
|
6260
6324
|
for (let index = 0; index < items.length; index += 1) {
|
|
6261
6325
|
const key = keyedRowIdentity(props.rowKey(items[index], index));
|
|
6262
6326
|
keys.push(key);
|
|
6263
|
-
if (
|
|
6264
|
-
|
|
6327
|
+
if (!tracking || index >= committedSize) continue;
|
|
6328
|
+
const committedKey = committed.next().value;
|
|
6329
|
+
if (committedKey === key) {
|
|
6330
|
+
if (prefix === index) prefix += 1;
|
|
6331
|
+
continue;
|
|
6265
6332
|
}
|
|
6333
|
+
if (items.length !== committedSize || moved && moved.length === KEYED_ROWS_MAX_MOVED) {
|
|
6334
|
+
tracking = false;
|
|
6335
|
+
moved = displaced = void 0;
|
|
6336
|
+
continue;
|
|
6337
|
+
}
|
|
6338
|
+
(moved ?? (moved = [])).push(index);
|
|
6339
|
+
(displaced ?? (displaced = [])).push(committedKey);
|
|
6266
6340
|
}
|
|
6267
6341
|
if (prefix === committedSize && keys.length === committedSize) return { items, keys };
|
|
6342
|
+
if (moved && displaced) {
|
|
6343
|
+
const pending = /* @__PURE__ */ new Map();
|
|
6344
|
+
for (let index = 0; index < moved.length; index += 1) pending.set(displaced[index], index);
|
|
6345
|
+
const sources = [];
|
|
6346
|
+
for (const position of moved) {
|
|
6347
|
+
const source = pending.get(keys[position]);
|
|
6348
|
+
if (source === void 0) break;
|
|
6349
|
+
pending.delete(keys[position]);
|
|
6350
|
+
sources.push(source);
|
|
6351
|
+
}
|
|
6352
|
+
if (sources.length === moved.length)
|
|
6353
|
+
return { items, keys, moved: { positions: moved, sources } };
|
|
6354
|
+
}
|
|
6268
6355
|
if (prefix === committedSize && committedSize > 0) {
|
|
6269
6356
|
const tail = /* @__PURE__ */ new Set();
|
|
6270
6357
|
for (let index = committedSize; index < keys.length; index += 1) {
|
|
@@ -6526,22 +6613,35 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6526
6613
|
if (rows.keys[index] !== key) return false;
|
|
6527
6614
|
index += 1;
|
|
6528
6615
|
}
|
|
6616
|
+
const conditionalChanges = this.patchOrderedRows(
|
|
6617
|
+
rows,
|
|
6618
|
+
[...this.instances.values()],
|
|
6619
|
+
afterCommit
|
|
6620
|
+
);
|
|
6621
|
+
if (!conditionalChanges) return true;
|
|
6622
|
+
this.commitCurrentCollection(dirtyState);
|
|
6623
|
+
this.notifyConditionalChanges(conditionalChanges, afterCommit);
|
|
6624
|
+
return true;
|
|
6625
|
+
}
|
|
6626
|
+
// Rereads and patches every row as React would rerender it. `ordered` holds
|
|
6627
|
+
// the existing instance for each row. Returns undefined after activating
|
|
6628
|
+
// the fallback.
|
|
6629
|
+
patchOrderedRows(rows, ordered, afterCommit) {
|
|
6529
6630
|
const shouldPrepareBindings = rows.items.length > 1 && this.currentProps.bindings.length > 0 && !this.currentProps.hostBlocks;
|
|
6530
|
-
const ordered = [...this.instances.values()];
|
|
6531
6631
|
const preparedBindings = shouldPrepareBindings ? prepareKeyedRowBindingSetUpdates(this.currentProps, this.instances, rows, ordered) : void 0;
|
|
6532
6632
|
if (shouldPrepareBindings && !preparedBindings) {
|
|
6533
6633
|
this.activateFallback(afterCommit);
|
|
6534
|
-
return
|
|
6634
|
+
return void 0;
|
|
6535
6635
|
}
|
|
6536
6636
|
const conditionalChanges = [];
|
|
6537
|
-
for (index = 0; index < rows.items.length; index += 1) {
|
|
6637
|
+
for (let index = 0; index < rows.items.length; index += 1) {
|
|
6538
6638
|
const key = rows.keys[index];
|
|
6539
6639
|
const existing = ordered[index];
|
|
6540
6640
|
if (this.currentProps.hostBlocks) {
|
|
6541
6641
|
const descriptor = this.currentProps.create(rows.items[index], index);
|
|
6542
6642
|
if (!existing.scope?.update(descriptor)) {
|
|
6543
6643
|
this.activateFallback(afterCommit);
|
|
6544
|
-
return
|
|
6644
|
+
return void 0;
|
|
6545
6645
|
}
|
|
6546
6646
|
}
|
|
6547
6647
|
const bindingUpdates = preparedBindings?.[index];
|
|
@@ -6569,9 +6669,36 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6569
6669
|
existing.item = rows.items[index];
|
|
6570
6670
|
existing.index = index;
|
|
6571
6671
|
}
|
|
6672
|
+
return conditionalChanges;
|
|
6673
|
+
}
|
|
6674
|
+
// The same rows in a new order that differs only at the ascending `moved`
|
|
6675
|
+
// positions: patch every row, then move only moved rows outside a stable
|
|
6676
|
+
// subsequence. A moved row may stay put only when every position between
|
|
6677
|
+
// its committed and final place also moved; otherwise an unmoved row lies
|
|
6678
|
+
// between them and the order would be wrong. Inserting the rest from the
|
|
6679
|
+
// last position down puts each before its final next sibling.
|
|
6680
|
+
reconcileMovedRows(rows, moved, sources, afterCommit, dirtyState) {
|
|
6681
|
+
const ordered = [...this.instances.values()];
|
|
6682
|
+
for (const position of moved) ordered[position] = this.instances.get(rows.keys[position]);
|
|
6683
|
+
const conditionalChanges = this.patchOrderedRows(rows, ordered, afterCommit);
|
|
6684
|
+
if (!conditionalChanges) return;
|
|
6685
|
+
const sequence = sources.map(
|
|
6686
|
+
(source, index) => Math.abs(moved[source] - moved[index]) === Math.abs(source - index) ? source : -1
|
|
6687
|
+
);
|
|
6688
|
+
const stays = longestIncreasingSubsequencePositions(sequence);
|
|
6689
|
+
const root = this.root;
|
|
6690
|
+
const activeElement = compilerFocusedElement(root);
|
|
6691
|
+
for (let index = moved.length - 1; index >= 0; index -= 1) {
|
|
6692
|
+
if (stays[index]) continue;
|
|
6693
|
+
const position = moved[index];
|
|
6694
|
+
const element = ordered[position].element;
|
|
6695
|
+
const anchor = position + 1 < ordered.length ? ordered[position + 1].element : null;
|
|
6696
|
+
if (element.nextSibling !== anchor) root.insertBefore(element, anchor);
|
|
6697
|
+
}
|
|
6698
|
+
restoreCompilerFocus(activeElement);
|
|
6699
|
+
this.instances = keyedRowInstancesByKey(ordered);
|
|
6572
6700
|
this.commitCurrentCollection(dirtyState);
|
|
6573
6701
|
this.notifyConditionalChanges(conditionalChanges, afterCommit);
|
|
6574
|
-
return true;
|
|
6575
6702
|
}
|
|
6576
6703
|
// Keys are the committed keys plus new ones: patch every existing row like
|
|
6577
6704
|
// the complete path does, then create and append only the new rows.
|
|
@@ -6716,6 +6843,16 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6716
6843
|
return;
|
|
6717
6844
|
}
|
|
6718
6845
|
if (this.reconcileStableRows(rows, afterCommit, dirtyState)) return;
|
|
6846
|
+
if (rows.moved && !this.currentProps.hostBlocks) {
|
|
6847
|
+
this.reconcileMovedRows(
|
|
6848
|
+
rows,
|
|
6849
|
+
rows.moved.positions,
|
|
6850
|
+
rows.moved.sources,
|
|
6851
|
+
afterCommit,
|
|
6852
|
+
dirtyState
|
|
6853
|
+
);
|
|
6854
|
+
return;
|
|
6855
|
+
}
|
|
6719
6856
|
if (this.reconcileRemovals(rows, afterCommit, dirtyState)) return;
|
|
6720
6857
|
if (rows.appended && !this.currentProps.hostBlocks) {
|
|
6721
6858
|
this.reconcileAppendedRows(rows, afterCommit, dirtyState);
|
|
@@ -6855,7 +6992,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6855
6992
|
schedulePropSync() {
|
|
6856
6993
|
if (this.propSyncQueued) return;
|
|
6857
6994
|
this.propSyncQueued = true;
|
|
6858
|
-
|
|
6995
|
+
scheduleCompilerMicrotask(() => {
|
|
6859
6996
|
this.propSyncQueued = false;
|
|
6860
6997
|
if (this.mounted && !this.state.fallback) {
|
|
6861
6998
|
this.listen();
|
|
@@ -7443,6 +7580,14 @@ var keyedRowsHintedRuntimeFeature = {
|
|
|
7443
7580
|
})
|
|
7444
7581
|
})
|
|
7445
7582
|
};
|
|
7583
|
+
var keyedRowsAppendOnlyRuntimeFeature = {
|
|
7584
|
+
name: "keyed-rows:append-only",
|
|
7585
|
+
create: (owner) => ({
|
|
7586
|
+
KeyedRows: createKeyedRowsBlockComponentCore(owner, {
|
|
7587
|
+
keyedUpdates: keyedAppendOnlyUpdateRuntime
|
|
7588
|
+
})
|
|
7589
|
+
})
|
|
7590
|
+
};
|
|
7446
7591
|
var keyedRowsPositionHintedRuntimeFeature = {
|
|
7447
7592
|
name: "keyed-rows:position-hinted",
|
|
7448
7593
|
create: (owner) => ({
|
|
@@ -7531,6 +7676,14 @@ var keyedRowsFilterHintedRuntimeFeature = {
|
|
|
7531
7676
|
})
|
|
7532
7677
|
})
|
|
7533
7678
|
};
|
|
7679
|
+
var keyedRowsFilterOnlyRuntimeFeature = {
|
|
7680
|
+
name: "keyed-rows:filter-only",
|
|
7681
|
+
create: (owner) => ({
|
|
7682
|
+
KeyedRows: createKeyedRowsBlockComponentCore(owner, {
|
|
7683
|
+
keyedUpdates: keyedFilterOnlyUpdateRuntime
|
|
7684
|
+
})
|
|
7685
|
+
})
|
|
7686
|
+
};
|
|
7534
7687
|
var keyedRowsIdentityFilterHintedRuntimeFeature = {
|
|
7535
7688
|
name: "keyed-rows:identity-filter-hinted",
|
|
7536
7689
|
create: (owner) => ({
|
|
@@ -7589,6 +7742,14 @@ var keyedRowsPrependHintedRuntimeFeature = {
|
|
|
7589
7742
|
})
|
|
7590
7743
|
})
|
|
7591
7744
|
};
|
|
7745
|
+
var keyedRowsPrependOnlyRuntimeFeature = {
|
|
7746
|
+
name: "keyed-rows:prepend-only",
|
|
7747
|
+
create: (owner) => ({
|
|
7748
|
+
KeyedRows: createKeyedRowsBlockComponentCore(owner, {
|
|
7749
|
+
keyedUpdates: keyedPrependOnlyUpdateRuntime
|
|
7750
|
+
})
|
|
7751
|
+
})
|
|
7752
|
+
};
|
|
7592
7753
|
var keyedRowsFilterPrependHintedRuntimeFeature = {
|
|
7593
7754
|
name: "keyed-rows:filter-prepend-hinted",
|
|
7594
7755
|
create: (owner) => ({
|
|
@@ -8374,7 +8535,7 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
|
|
|
8374
8535
|
this.captureInputSelection();
|
|
8375
8536
|
if (!this.mounted || this.flushQueued) return;
|
|
8376
8537
|
this.flushQueued = true;
|
|
8377
|
-
|
|
8538
|
+
scheduleCompilerMicrotask(() => {
|
|
8378
8539
|
this.flushQueued = false;
|
|
8379
8540
|
this.flushBindingUpdates();
|
|
8380
8541
|
});
|
|
@@ -8623,6 +8784,7 @@ exports.hostConditionalRuntimeFeature = hostConditionalRuntimeFeature;
|
|
|
8623
8784
|
exports.keyedListRuntimeFeature = keyedListRuntimeFeature;
|
|
8624
8785
|
exports.keyedRangesRuntimeFeature = keyedRangesRuntimeFeature;
|
|
8625
8786
|
exports.keyedRowsAllHintedRuntimeFeature = keyedRowsAllHintedRuntimeFeature;
|
|
8787
|
+
exports.keyedRowsAppendOnlyRuntimeFeature = keyedRowsAppendOnlyRuntimeFeature;
|
|
8626
8788
|
exports.keyedRowsBatchEveryHintedRuntimeFeature = keyedRowsBatchEveryHintedRuntimeFeature;
|
|
8627
8789
|
exports.keyedRowsBatchPositionHintedRuntimeFeature = keyedRowsBatchPositionHintedRuntimeFeature;
|
|
8628
8790
|
exports.keyedRowsCompleteAllHintedRuntimeFeature = keyedRowsCompleteAllHintedRuntimeFeature;
|
|
@@ -8663,6 +8825,7 @@ exports.keyedRowsConditionalWindowEveryHintedRuntimeFeature = keyedRowsCondition
|
|
|
8663
8825
|
exports.keyedRowsConditionalWindowPositionHintedRuntimeFeature = keyedRowsConditionalWindowPositionHintedRuntimeFeature;
|
|
8664
8826
|
exports.keyedRowsEveryHintedRuntimeFeature = keyedRowsEveryHintedRuntimeFeature;
|
|
8665
8827
|
exports.keyedRowsFilterHintedRuntimeFeature = keyedRowsFilterHintedRuntimeFeature;
|
|
8828
|
+
exports.keyedRowsFilterOnlyRuntimeFeature = keyedRowsFilterOnlyRuntimeFeature;
|
|
8666
8829
|
exports.keyedRowsFilterPrependHintedRuntimeFeature = keyedRowsFilterPrependHintedRuntimeFeature;
|
|
8667
8830
|
exports.keyedRowsHintedRuntimeFeature = keyedRowsHintedRuntimeFeature;
|
|
8668
8831
|
exports.keyedRowsHostAllHintedRuntimeFeature = keyedRowsHostAllHintedRuntimeFeature;
|
|
@@ -8693,6 +8856,7 @@ exports.keyedRowsMembershipRuntimeFeature = keyedRowsMembershipRuntimeFeature;
|
|
|
8693
8856
|
exports.keyedRowsPlainRuntimeFeature = keyedRowsPlainRuntimeFeature;
|
|
8694
8857
|
exports.keyedRowsPositionHintedRuntimeFeature = keyedRowsPositionHintedRuntimeFeature;
|
|
8695
8858
|
exports.keyedRowsPrependHintedRuntimeFeature = keyedRowsPrependHintedRuntimeFeature;
|
|
8859
|
+
exports.keyedRowsPrependOnlyRuntimeFeature = keyedRowsPrependOnlyRuntimeFeature;
|
|
8696
8860
|
exports.keyedRowsReorderHintedRuntimeFeature = keyedRowsReorderHintedRuntimeFeature;
|
|
8697
8861
|
exports.keyedRowsRuntimeFeature = keyedRowsRuntimeFeature;
|
|
8698
8862
|
exports.keyedRowsStructuralAppendHintedRuntimeFeature = keyedRowsStructuralAppendHintedRuntimeFeature;
|