@farm.js/react 0.1.0-beta.21 → 0.1.0-beta.23
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 +26 -11
- package/dist/compiler-runtime.cjs +285 -231
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +5 -0
- package/dist/compiler-runtime.d.ts +5 -0
- package/dist/compiler-runtime.mjs +285 -231
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/index.cjs +25 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.mjs +25 -2
- package/dist/index.mjs.map +1 -1
- package/dist/list.cjs +6 -0
- package/dist/list.cjs.map +1 -1
- package/dist/list.mjs +6 -0
- package/dist/list.mjs.map +1 -1
- package/dist/vite.cjs +88 -33
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +88 -33
- package/dist/vite.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -5,8 +5,14 @@ import { flushSync } from 'react-dom';
|
|
|
5
5
|
|
|
6
6
|
// src/iterable.ts
|
|
7
7
|
var oneShotSnapshots = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
var arrayIterator = Array.prototype[Symbol.iterator];
|
|
8
9
|
function materializeIterable(source) {
|
|
9
10
|
if (source == null) return [];
|
|
11
|
+
if (Array.isArray(source) && Object.getPrototypeOf(source) === Array.prototype && source[Symbol.iterator] === arrayIterator) {
|
|
12
|
+
const items2 = [];
|
|
13
|
+
for (let index = 0; index < source.length; index += 1) items2.push(source[index]);
|
|
14
|
+
return items2;
|
|
15
|
+
}
|
|
10
16
|
const iterator = source[Symbol.iterator]();
|
|
11
17
|
const oneShot = iterator === source && (typeof source === "object" || typeof source === "function");
|
|
12
18
|
if (oneShot) {
|
|
@@ -1580,7 +1586,9 @@ function getCompilerHmrRegistry() {
|
|
|
1580
1586
|
return registry;
|
|
1581
1587
|
}
|
|
1582
1588
|
function renderTextValue(value) {
|
|
1583
|
-
if (Array.isArray(value))
|
|
1589
|
+
if (Array.isArray(value)) {
|
|
1590
|
+
return value.length === 1 ? renderTextValue(value[0]) : value.map(renderTextValue).join("");
|
|
1591
|
+
}
|
|
1584
1592
|
if (value === null || value === void 0 || typeof value === "boolean") return "";
|
|
1585
1593
|
return String(value);
|
|
1586
1594
|
}
|
|
@@ -1707,8 +1715,11 @@ function updateSelectValue(element, value) {
|
|
|
1707
1715
|
}
|
|
1708
1716
|
if (fallback) fallback.selected = true;
|
|
1709
1717
|
}
|
|
1718
|
+
function compilerAttributeName(name) {
|
|
1719
|
+
return name === "className" ? "class" : name === "htmlFor" ? "for" : name;
|
|
1720
|
+
}
|
|
1710
1721
|
function updateAttribute(element, name, value) {
|
|
1711
|
-
const attributeName = name
|
|
1722
|
+
const attributeName = compilerAttributeName(name);
|
|
1712
1723
|
const stringifiesBoolean = attributeName.startsWith("data-") || attributeName.startsWith("aria-");
|
|
1713
1724
|
if (name === "value" && (isInputElement(element) || isTextAreaElement(element))) {
|
|
1714
1725
|
const nextValue = value === null || value === void 0 ? "" : String(value);
|
|
@@ -1961,7 +1972,10 @@ function hasUnsafeCompilerFallbackKeys(descriptor) {
|
|
|
1961
1972
|
}
|
|
1962
1973
|
function findCompilerHostTarget(root, path) {
|
|
1963
1974
|
let current = root;
|
|
1964
|
-
for (const index of path)
|
|
1975
|
+
for (const index of path) {
|
|
1976
|
+
current = current && current.firstElementChild;
|
|
1977
|
+
for (let step = 0; step < index && current; step += 1) current = current.nextElementSibling;
|
|
1978
|
+
}
|
|
1965
1979
|
return current;
|
|
1966
1980
|
}
|
|
1967
1981
|
var UNSET_STATIC_RANGE_BINDING = /* @__PURE__ */ Symbol("unset static range binding");
|
|
@@ -2496,9 +2510,64 @@ function normalizedKeyedRowBindingValue(binding, value) {
|
|
|
2496
2510
|
return binding.kind === "text" ? renderTextValue(value) : value;
|
|
2497
2511
|
}
|
|
2498
2512
|
function readKeyedRowBindingValues(props, item, index) {
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2513
|
+
const values = [];
|
|
2514
|
+
for (const binding of props.bindings) {
|
|
2515
|
+
values.push(normalizedKeyedRowBindingValue(binding, binding.read(item, index)));
|
|
2516
|
+
}
|
|
2517
|
+
return values;
|
|
2518
|
+
}
|
|
2519
|
+
var KEYED_ROW_TEMPLATES = /* @__PURE__ */ new WeakMap();
|
|
2520
|
+
function createKeyedRowInstance(props, document, key, item, index) {
|
|
2521
|
+
const template = props.cloneRows && KEYED_ROW_TEMPLATES.get(props);
|
|
2522
|
+
const element = template ? template.cloneNode(true) : createCompilerHostElement(document, props.create(item, index));
|
|
2523
|
+
const instance = {
|
|
2524
|
+
key,
|
|
2525
|
+
element,
|
|
2526
|
+
values: readKeyedRowBindingValues(props, item, index),
|
|
2527
|
+
item,
|
|
2528
|
+
index,
|
|
2529
|
+
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
2530
|
+
};
|
|
2531
|
+
if (props.cloneRows) {
|
|
2532
|
+
const targets = [];
|
|
2533
|
+
let found = true;
|
|
2534
|
+
for (const binding of props.bindings) {
|
|
2535
|
+
const target = findCompilerHostTarget(element, binding.path);
|
|
2536
|
+
found && (found = target !== null);
|
|
2537
|
+
targets.push(target);
|
|
2538
|
+
}
|
|
2539
|
+
if (found) instance.targets = targets;
|
|
2540
|
+
if (template) {
|
|
2541
|
+
for (let bindingIndex = 0; bindingIndex < targets.length; bindingIndex += 1) {
|
|
2542
|
+
commitKeyedRowBinding(
|
|
2543
|
+
props.bindings[bindingIndex],
|
|
2544
|
+
instance,
|
|
2545
|
+
bindingIndex,
|
|
2546
|
+
instance.values[bindingIndex],
|
|
2547
|
+
targets[bindingIndex]
|
|
2548
|
+
);
|
|
2549
|
+
}
|
|
2550
|
+
} else {
|
|
2551
|
+
const skeleton = keyedRowTemplate(props, element, targets);
|
|
2552
|
+
if (skeleton) KEYED_ROW_TEMPLATES.set(props, skeleton);
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
return instance;
|
|
2556
|
+
}
|
|
2557
|
+
function keyedRowTemplate(props, element, targets) {
|
|
2558
|
+
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
2559
|
+
const binding = props.bindings[bindingIndex];
|
|
2560
|
+
const target = targets[bindingIndex];
|
|
2561
|
+
if (!target || binding.kind === "style") return void 0;
|
|
2562
|
+
if (binding.kind === "attribute" && !target.hasAttribute(compilerAttributeName(binding.name))) {
|
|
2563
|
+
return void 0;
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
const template = element.cloneNode(true);
|
|
2567
|
+
for (const binding of props.bindings) {
|
|
2568
|
+
if (binding.kind === "text") findCompilerHostTarget(template, binding.path).textContent = "";
|
|
2569
|
+
}
|
|
2570
|
+
return template;
|
|
2502
2571
|
}
|
|
2503
2572
|
function applyKeyedRowBindings(props, instance, item, index) {
|
|
2504
2573
|
if (props.bindings.length < 2) {
|
|
@@ -2510,10 +2579,7 @@ function applyKeyedRowBindings(props, instance, item, index) {
|
|
|
2510
2579
|
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
2511
2580
|
if (Object.is(instance.values[bindingIndex], nextValues[bindingIndex])) continue;
|
|
2512
2581
|
targets || (targets = []);
|
|
2513
|
-
targets[bindingIndex] =
|
|
2514
|
-
instance.element,
|
|
2515
|
-
props.bindings[bindingIndex].path
|
|
2516
|
-
);
|
|
2582
|
+
targets[bindingIndex] = keyedRowBindingTarget(props, instance, bindingIndex);
|
|
2517
2583
|
}
|
|
2518
2584
|
if (!targets) return;
|
|
2519
2585
|
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
@@ -2532,14 +2598,22 @@ function applyKeyedRowBinding(props, instance, item, index, bindingIndex) {
|
|
|
2532
2598
|
const binding = props.bindings[bindingIndex];
|
|
2533
2599
|
const value = normalizedKeyedRowBindingValue(binding, binding.read(item, index));
|
|
2534
2600
|
if (Object.is(instance.values[bindingIndex], value)) return;
|
|
2535
|
-
const target =
|
|
2601
|
+
const target = keyedRowBindingTarget(props, instance, bindingIndex);
|
|
2536
2602
|
commitKeyedRowBinding(binding, instance, bindingIndex, value, target);
|
|
2537
2603
|
}
|
|
2604
|
+
function keyedRowBindingTarget(props, instance, bindingIndex) {
|
|
2605
|
+
return instance.targets?.[bindingIndex] || findCompilerHostTarget(instance.element, props.bindings[bindingIndex].path);
|
|
2606
|
+
}
|
|
2538
2607
|
function commitKeyedRowBinding(binding, instance, bindingIndex, value, target) {
|
|
2539
2608
|
instance.values[bindingIndex] = value;
|
|
2540
2609
|
if (!target) return;
|
|
2541
2610
|
if (binding.kind === "text") {
|
|
2542
|
-
|
|
2611
|
+
const text = target.firstChild;
|
|
2612
|
+
if (value && text && text === target.lastChild && text.nodeType === 3) {
|
|
2613
|
+
text.data = value;
|
|
2614
|
+
} else {
|
|
2615
|
+
target.textContent = value;
|
|
2616
|
+
}
|
|
2543
2617
|
} else if (binding.kind === "style" && binding.name) {
|
|
2544
2618
|
updateStyle(target, binding.name, value);
|
|
2545
2619
|
} else if (binding.kind === "attribute" && binding.name) {
|
|
@@ -2551,28 +2625,29 @@ function prepareKeyedRowBindingUpdate(props, instance, item, index, bindingIndex
|
|
|
2551
2625
|
const rawValue = binding.read(item, index);
|
|
2552
2626
|
const value = normalizedKeyedRowBindingValue(binding, rawValue);
|
|
2553
2627
|
if (Object.is(instance.values[bindingIndex], value)) return null;
|
|
2554
|
-
const target =
|
|
2628
|
+
const target = keyedRowBindingTarget(props, instance, bindingIndex);
|
|
2555
2629
|
if (!target || binding.kind !== "text" && !binding.name) return void 0;
|
|
2556
2630
|
return [bindingIndex, target, value];
|
|
2557
2631
|
}
|
|
2558
2632
|
function prepareKeyedRowBindingUpdates(props, instance, item, index) {
|
|
2559
|
-
|
|
2633
|
+
let updates;
|
|
2560
2634
|
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
2561
2635
|
const update = prepareKeyedRowBindingUpdate(props, instance, item, index, bindingIndex);
|
|
2562
2636
|
if (update === void 0) return void 0;
|
|
2563
|
-
if (update) updates.push(update);
|
|
2637
|
+
if (update) (updates || (updates = [])).push(update);
|
|
2564
2638
|
}
|
|
2565
|
-
return updates;
|
|
2639
|
+
return updates || NO_KEYED_ROW_BINDING_UPDATES;
|
|
2566
2640
|
}
|
|
2641
|
+
var NO_KEYED_ROW_BINDING_UPDATES = [];
|
|
2567
2642
|
function applyPreparedKeyedRowBindingUpdates(props, instance, updates) {
|
|
2568
2643
|
for (const [bindingIndex, target, value] of updates) {
|
|
2569
2644
|
commitKeyedRowBinding(props.bindings[bindingIndex], instance, bindingIndex, value, target);
|
|
2570
2645
|
}
|
|
2571
2646
|
}
|
|
2572
|
-
function prepareKeyedRowBindingSetUpdates(props, instances, rows) {
|
|
2647
|
+
function prepareKeyedRowBindingSetUpdates(props, instances, rows, ordered) {
|
|
2573
2648
|
const preparedUpdates = [];
|
|
2574
2649
|
for (let index = 0; index < rows.items.length; index += 1) {
|
|
2575
|
-
const instance = instances.get(rows.keys[index]);
|
|
2650
|
+
const instance = ordered ? ordered[index] : instances.get(rows.keys[index]);
|
|
2576
2651
|
if (!instance) return void 0;
|
|
2577
2652
|
const updates = prepareKeyedRowBindingUpdates(props, instance, rows.items[index], index);
|
|
2578
2653
|
if (!updates) return void 0;
|
|
@@ -3225,7 +3300,7 @@ var CompilerNestedKeyedRanges = class {
|
|
|
3225
3300
|
let anchor = this.anchorAfter(rangeIndex);
|
|
3226
3301
|
for (let index = nextInstances.length - 1; index >= 0; index -= 1) {
|
|
3227
3302
|
const instance = nextInstances[index];
|
|
3228
|
-
if (sequence[index] < 0 || !stablePositions
|
|
3303
|
+
if (sequence[index] < 0 || !stablePositions[index] && instance.element.nextSibling !== anchor) {
|
|
3229
3304
|
this.root.insertBefore(instance.element, anchor);
|
|
3230
3305
|
}
|
|
3231
3306
|
anchor = instance.element;
|
|
@@ -3592,7 +3667,7 @@ var CompilerNestedMixedRanges = class {
|
|
|
3592
3667
|
let anchor = this.anchorAfter(rangeIndex);
|
|
3593
3668
|
for (let index = nextInstances.length - 1; index >= 0; index -= 1) {
|
|
3594
3669
|
const row = nextInstances[index];
|
|
3595
|
-
if (sequence[index] < 0 || !stablePositions
|
|
3670
|
+
if (sequence[index] < 0 || !stablePositions[index] && row.element.nextSibling !== anchor) {
|
|
3596
3671
|
this.root.insertBefore(row.element, anchor);
|
|
3597
3672
|
}
|
|
3598
3673
|
anchor = row.element;
|
|
@@ -4254,7 +4329,7 @@ function createConditionalRangesBlockComponent(owner) {
|
|
|
4254
4329
|
}
|
|
4255
4330
|
function longestIncreasingSubsequencePositions(sequence) {
|
|
4256
4331
|
const tails = [];
|
|
4257
|
-
const previous =
|
|
4332
|
+
const previous = new Int32Array(sequence.length).fill(-1);
|
|
4258
4333
|
for (let index = 0; index < sequence.length; index += 1) {
|
|
4259
4334
|
if (sequence[index] < 0) continue;
|
|
4260
4335
|
let low = 0;
|
|
@@ -4267,10 +4342,10 @@ function longestIncreasingSubsequencePositions(sequence) {
|
|
|
4267
4342
|
if (low > 0) previous[index] = tails[low - 1];
|
|
4268
4343
|
tails[low] = index;
|
|
4269
4344
|
}
|
|
4270
|
-
const positions =
|
|
4345
|
+
const positions = new Uint8Array(sequence.length);
|
|
4271
4346
|
let cursor = tails.at(-1) ?? -1;
|
|
4272
4347
|
while (cursor >= 0) {
|
|
4273
|
-
positions
|
|
4348
|
+
positions[cursor] = 1;
|
|
4274
4349
|
cursor = previous[cursor];
|
|
4275
4350
|
}
|
|
4276
4351
|
return positions;
|
|
@@ -4283,15 +4358,13 @@ function reorderCompilerKeyedRows(root, instances, sequence, anchor) {
|
|
|
4283
4358
|
if (sequence[index] < 0) {
|
|
4284
4359
|
let start = index;
|
|
4285
4360
|
while (start > 0 && sequence[start - 1] < 0) start -= 1;
|
|
4286
|
-
const fragment = root.ownerDocument.createDocumentFragment();
|
|
4287
4361
|
for (let itemIndex = start; itemIndex <= index; itemIndex += 1) {
|
|
4288
|
-
|
|
4362
|
+
root.insertBefore(instances[itemIndex].element, anchor);
|
|
4289
4363
|
}
|
|
4290
|
-
root.insertBefore(fragment, anchor);
|
|
4291
4364
|
anchor = instances[start].element;
|
|
4292
4365
|
index = start;
|
|
4293
4366
|
} else {
|
|
4294
|
-
if (!stablePositions
|
|
4367
|
+
if (!stablePositions[index] && instance.element.nextSibling !== anchor) {
|
|
4295
4368
|
root.insertBefore(instance.element, anchor);
|
|
4296
4369
|
}
|
|
4297
4370
|
anchor = instance.element;
|
|
@@ -4559,15 +4632,13 @@ function reconcileCompilerKeyedArrayAppend(props, dirtyState, collectionToken, i
|
|
|
4559
4632
|
const item = finalValue[index];
|
|
4560
4633
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
4561
4634
|
if (nextInstances.has(key)) return void 0;
|
|
4562
|
-
const
|
|
4563
|
-
|
|
4635
|
+
const instance = createKeyedRowInstance(
|
|
4636
|
+
props,
|
|
4637
|
+
root.ownerDocument,
|
|
4564
4638
|
key,
|
|
4565
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
4566
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
4567
4639
|
item,
|
|
4568
|
-
index
|
|
4569
|
-
|
|
4570
|
-
};
|
|
4640
|
+
index
|
|
4641
|
+
);
|
|
4571
4642
|
appended.push(instance);
|
|
4572
4643
|
nextInstances.set(key, instance);
|
|
4573
4644
|
}
|
|
@@ -4624,15 +4695,7 @@ function reconcileCompilerKeyedArrayStructuralAppend(props, dirtyState, collecti
|
|
|
4624
4695
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
4625
4696
|
if (knownKeys.has(key)) return void 0;
|
|
4626
4697
|
knownKeys.add(key);
|
|
4627
|
-
|
|
4628
|
-
appended.push({
|
|
4629
|
-
key,
|
|
4630
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
4631
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
4632
|
-
item,
|
|
4633
|
-
index,
|
|
4634
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
4635
|
-
});
|
|
4698
|
+
appended.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
4636
4699
|
}
|
|
4637
4700
|
} catch {
|
|
4638
4701
|
return void 0;
|
|
@@ -4733,15 +4796,7 @@ function reconcileCompilerKeyedArrayStructuralAppendMap(props, dirtyState, colle
|
|
|
4733
4796
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
4734
4797
|
if (instances.has(key) || appendedKeys.has(key)) return void 0;
|
|
4735
4798
|
appendedKeys.add(key);
|
|
4736
|
-
|
|
4737
|
-
appended.push({
|
|
4738
|
-
key,
|
|
4739
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
4740
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
4741
|
-
item,
|
|
4742
|
-
index,
|
|
4743
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
4744
|
-
});
|
|
4799
|
+
appended.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
4745
4800
|
}
|
|
4746
4801
|
} catch {
|
|
4747
4802
|
return void 0;
|
|
@@ -4839,15 +4894,7 @@ function reconcileCompilerKeyedArrayRollingWindow(props, dirtyState, collectionT
|
|
|
4839
4894
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
4840
4895
|
if (knownKeys.has(key)) return void 0;
|
|
4841
4896
|
knownKeys.add(key);
|
|
4842
|
-
|
|
4843
|
-
incoming.push({
|
|
4844
|
-
key,
|
|
4845
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
4846
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
4847
|
-
item,
|
|
4848
|
-
index,
|
|
4849
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
4850
|
-
});
|
|
4897
|
+
incoming.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
4851
4898
|
}
|
|
4852
4899
|
} catch {
|
|
4853
4900
|
return void 0;
|
|
@@ -4918,15 +4965,7 @@ function reconcileCompilerKeyedArrayMappedRollingWindow(props, dirtyState, colle
|
|
|
4918
4965
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
4919
4966
|
if (instances.has(key) || incomingKeys.has(key)) return void 0;
|
|
4920
4967
|
incomingKeys.add(key);
|
|
4921
|
-
|
|
4922
|
-
incoming.push({
|
|
4923
|
-
key,
|
|
4924
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
4925
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
4926
|
-
item,
|
|
4927
|
-
index,
|
|
4928
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
4929
|
-
});
|
|
4968
|
+
incoming.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
4930
4969
|
}
|
|
4931
4970
|
} catch {
|
|
4932
4971
|
return void 0;
|
|
@@ -5005,15 +5044,7 @@ function reconcileCompilerKeyedArrayPosition(props, dirtyState, collectionToken,
|
|
|
5005
5044
|
if (instances.has(key)) return void 0;
|
|
5006
5045
|
let inserted;
|
|
5007
5046
|
try {
|
|
5008
|
-
|
|
5009
|
-
inserted = {
|
|
5010
|
-
key,
|
|
5011
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5012
|
-
values: readKeyedRowBindingValues(props, item, update.position),
|
|
5013
|
-
item,
|
|
5014
|
-
index: update.position,
|
|
5015
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5016
|
-
};
|
|
5047
|
+
inserted = createKeyedRowInstance(props, root.ownerDocument, key, item, update.position);
|
|
5017
5048
|
} catch {
|
|
5018
5049
|
return void 0;
|
|
5019
5050
|
}
|
|
@@ -5037,15 +5068,7 @@ function reconcileCompilerKeyedArrayPosition(props, dirtyState, collectionToken,
|
|
|
5037
5068
|
if (instances.has(key)) return void 0;
|
|
5038
5069
|
let replacement;
|
|
5039
5070
|
try {
|
|
5040
|
-
|
|
5041
|
-
replacement = {
|
|
5042
|
-
key,
|
|
5043
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5044
|
-
values: readKeyedRowBindingValues(props, item, update.position),
|
|
5045
|
-
item,
|
|
5046
|
-
index: update.position,
|
|
5047
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5048
|
-
};
|
|
5071
|
+
replacement = createKeyedRowInstance(props, root.ownerDocument, key, item, update.position);
|
|
5049
5072
|
} catch {
|
|
5050
5073
|
return void 0;
|
|
5051
5074
|
}
|
|
@@ -5088,15 +5111,7 @@ function reconcileCompilerKeyedArrayBatchInsert(props, dirtyState, collectionTok
|
|
|
5088
5111
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
5089
5112
|
if (instances.has(key) || incomingKeys.has(key)) return void 0;
|
|
5090
5113
|
incomingKeys.add(key);
|
|
5091
|
-
|
|
5092
|
-
incoming.push({
|
|
5093
|
-
key,
|
|
5094
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5095
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
5096
|
-
item,
|
|
5097
|
-
index,
|
|
5098
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5099
|
-
});
|
|
5114
|
+
incoming.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
5100
5115
|
}
|
|
5101
5116
|
} catch {
|
|
5102
5117
|
return void 0;
|
|
@@ -5182,15 +5197,7 @@ function prepareCompilerKeyedArrayWindow(props, instances, previousInstances, ro
|
|
|
5182
5197
|
continue;
|
|
5183
5198
|
}
|
|
5184
5199
|
if (instances.has(key)) return void 0;
|
|
5185
|
-
|
|
5186
|
-
nextWindow.push({
|
|
5187
|
-
key,
|
|
5188
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5189
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
5190
|
-
item,
|
|
5191
|
-
index,
|
|
5192
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5193
|
-
});
|
|
5200
|
+
nextWindow.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
5194
5201
|
sequence.push(-1);
|
|
5195
5202
|
preparedBindings.push(void 0);
|
|
5196
5203
|
}
|
|
@@ -5320,20 +5327,12 @@ function reconcileCompilerKeyedArrayWindowReplace(props, dirtyState, collectionT
|
|
|
5320
5327
|
if (instances.has(key) || incomingKeys2.has(key)) return void 0;
|
|
5321
5328
|
incomingKeys2.add(key);
|
|
5322
5329
|
replacesRows = true;
|
|
5323
|
-
const descriptor = props.create(item, index);
|
|
5324
5330
|
prepared2.push([
|
|
5325
5331
|
index,
|
|
5326
5332
|
instance,
|
|
5327
5333
|
item,
|
|
5328
5334
|
void 0,
|
|
5329
|
-
|
|
5330
|
-
key,
|
|
5331
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5332
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
5333
|
-
item,
|
|
5334
|
-
index,
|
|
5335
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5336
|
-
}
|
|
5335
|
+
createKeyedRowInstance(props, root.ownerDocument, key, item, index)
|
|
5337
5336
|
]);
|
|
5338
5337
|
continue;
|
|
5339
5338
|
}
|
|
@@ -5671,15 +5670,7 @@ function reconcileCompilerKeyedArrayPrepend(props, dirtyState, collectionToken,
|
|
|
5671
5670
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
5672
5671
|
if (instances.has(key) || incomingKeys.has(key)) return void 0;
|
|
5673
5672
|
incomingKeys.add(key);
|
|
5674
|
-
|
|
5675
|
-
prepended.push({
|
|
5676
|
-
key,
|
|
5677
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5678
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
5679
|
-
item,
|
|
5680
|
-
index,
|
|
5681
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5682
|
-
});
|
|
5673
|
+
prepended.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
5683
5674
|
}
|
|
5684
5675
|
} catch {
|
|
5685
5676
|
return void 0;
|
|
@@ -5737,15 +5728,7 @@ function reconcileCompilerKeyedArrayStructuralPrepend(props, dirtyState, collect
|
|
|
5737
5728
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
5738
5729
|
if (knownKeys.has(key)) return void 0;
|
|
5739
5730
|
knownKeys.add(key);
|
|
5740
|
-
|
|
5741
|
-
prepended.push({
|
|
5742
|
-
key,
|
|
5743
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5744
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
5745
|
-
item,
|
|
5746
|
-
index,
|
|
5747
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5748
|
-
});
|
|
5731
|
+
prepended.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
5749
5732
|
}
|
|
5750
5733
|
} catch {
|
|
5751
5734
|
return void 0;
|
|
@@ -5856,15 +5839,7 @@ function reconcileCompilerKeyedArrayStructuralPrependMap(props, dirtyState, coll
|
|
|
5856
5839
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
5857
5840
|
if (knownKeys.has(key)) return void 0;
|
|
5858
5841
|
knownKeys.add(key);
|
|
5859
|
-
|
|
5860
|
-
prepended.push({
|
|
5861
|
-
key,
|
|
5862
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5863
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
5864
|
-
item,
|
|
5865
|
-
index,
|
|
5866
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5867
|
-
});
|
|
5842
|
+
prepended.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
5868
5843
|
}
|
|
5869
5844
|
} catch {
|
|
5870
5845
|
return void 0;
|
|
@@ -5916,7 +5891,7 @@ function reconcileCompilerKeyedArrayFilter(props, dirtyState, collectionToken, i
|
|
|
5916
5891
|
return void 0;
|
|
5917
5892
|
}
|
|
5918
5893
|
const dependencies = props.dependencies || props.structureDependencies;
|
|
5919
|
-
const relevantDirty = (dependencies || []).filter((
|
|
5894
|
+
const relevantDirty = (dependencies || []).filter((index2) => dirtyState.has(index2));
|
|
5920
5895
|
if (relevantDirty.length !== 1 || relevantDirty[0] !== collectionDependency) {
|
|
5921
5896
|
return void 0;
|
|
5922
5897
|
}
|
|
@@ -5928,31 +5903,34 @@ function reconcileCompilerKeyedArrayFilter(props, dirtyState, collectionToken, i
|
|
|
5928
5903
|
);
|
|
5929
5904
|
if (!survivorResult || !Array.isArray(finalValue)) return void 0;
|
|
5930
5905
|
const { indices: survivorIndices, keysStable } = survivorResult;
|
|
5931
|
-
const
|
|
5932
|
-
|
|
5906
|
+
const removed = [];
|
|
5907
|
+
let cursor = 0;
|
|
5908
|
+
let sourceIndex = 0;
|
|
5933
5909
|
try {
|
|
5934
|
-
for (
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5910
|
+
for (const instance of instances.values()) {
|
|
5911
|
+
if (survivorIndices[cursor] !== sourceIndex) {
|
|
5912
|
+
removed.push(instance);
|
|
5913
|
+
} else {
|
|
5914
|
+
const item = finalValue[cursor];
|
|
5915
|
+
if (instance.index !== sourceIndex || !Object.is(instance.item, item) || !keysStable && keyedRowIdentity(props.rowKey(item, cursor)) !== instance.key) {
|
|
5916
|
+
return void 0;
|
|
5917
|
+
}
|
|
5918
|
+
cursor += 1;
|
|
5940
5919
|
}
|
|
5941
|
-
|
|
5920
|
+
sourceIndex += 1;
|
|
5942
5921
|
}
|
|
5943
5922
|
} catch {
|
|
5944
5923
|
return void 0;
|
|
5945
5924
|
}
|
|
5946
|
-
|
|
5947
|
-
for (
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
}
|
|
5952
|
-
for (let index = 0; index < survivors.length; index += 1) {
|
|
5953
|
-
survivors[index].index = index;
|
|
5925
|
+
if (cursor !== survivorIndices.length) return void 0;
|
|
5926
|
+
for (const instance of removed) {
|
|
5927
|
+
instance.scope?.cleanup();
|
|
5928
|
+
instance.element.remove();
|
|
5929
|
+
instances.delete(instance.key);
|
|
5954
5930
|
}
|
|
5955
|
-
|
|
5931
|
+
let index = 0;
|
|
5932
|
+
for (const instance of instances.values()) instance.index = index++;
|
|
5933
|
+
return instances;
|
|
5956
5934
|
}
|
|
5957
5935
|
function createKeyedRowConditionalRuntime() {
|
|
5958
5936
|
class FarmKeyedRowConditional extends React.Component {
|
|
@@ -5997,9 +5975,42 @@ function createKeyedRowConditionalRuntime() {
|
|
|
5997
5975
|
}
|
|
5998
5976
|
FarmKeyedRowConditional.displayName = "FarmCompiledKeyedRowConditional";
|
|
5999
5977
|
return {
|
|
6000
|
-
|
|
5978
|
+
element: (props) => React.createElement(FarmKeyedRowConditional, {
|
|
5979
|
+
key: `${props.rowKey}:${props.id}`,
|
|
5980
|
+
...props
|
|
5981
|
+
}),
|
|
6001
5982
|
readValues: readKeyedRowConditionalValues,
|
|
6002
|
-
changed: keyedRowConditionalChanged
|
|
5983
|
+
changed: keyedRowConditionalChanged,
|
|
5984
|
+
owner: (listeners) => ({
|
|
5985
|
+
subscribe(key, id, refresh) {
|
|
5986
|
+
let row = listeners.get(key);
|
|
5987
|
+
if (!row) {
|
|
5988
|
+
row = /* @__PURE__ */ new Map();
|
|
5989
|
+
listeners.set(key, row);
|
|
5990
|
+
}
|
|
5991
|
+
row.set(id, refresh);
|
|
5992
|
+
return () => {
|
|
5993
|
+
const current = listeners.get(key);
|
|
5994
|
+
if (current?.get(id) !== refresh) return;
|
|
5995
|
+
current.delete(id);
|
|
5996
|
+
if (current.size === 0) listeners.delete(key);
|
|
5997
|
+
};
|
|
5998
|
+
}
|
|
5999
|
+
}),
|
|
6000
|
+
notify(listeners, changes, afterCommit) {
|
|
6001
|
+
let pending = changes.length;
|
|
6002
|
+
const committed = () => {
|
|
6003
|
+
pending -= 1;
|
|
6004
|
+
if (pending === 0) afterCommit?.();
|
|
6005
|
+
};
|
|
6006
|
+
flushSync(() => {
|
|
6007
|
+
for (const change of changes) {
|
|
6008
|
+
const refresh = listeners.get(change.key)?.get(change.id);
|
|
6009
|
+
if (refresh) refresh(change.item, change.index, committed);
|
|
6010
|
+
else committed();
|
|
6011
|
+
}
|
|
6012
|
+
});
|
|
6013
|
+
}
|
|
6003
6014
|
};
|
|
6004
6015
|
}
|
|
6005
6016
|
function createKeyedRowHostRuntime() {
|
|
@@ -6031,9 +6042,9 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6031
6042
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
6032
6043
|
this.conditionalListeners = /* @__PURE__ */ new Map();
|
|
6033
6044
|
this.instancesByElement = /* @__PURE__ */ new WeakMap();
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6045
|
+
// False after a rebuild without delegated events left surviving rows unindexed.
|
|
6046
|
+
this.elementIndexComplete = true;
|
|
6047
|
+
this.conditionalOwner = options.conditionals?.owner(this.conditionalListeners);
|
|
6037
6048
|
this.captureRoot = (root) => {
|
|
6038
6049
|
this.root = root;
|
|
6039
6050
|
};
|
|
@@ -6085,14 +6096,10 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6085
6096
|
}
|
|
6086
6097
|
};
|
|
6087
6098
|
this.rowConditional = (item, index, conditionalId, render) => {
|
|
6088
|
-
if (this.state.fallback) return render(item, index);
|
|
6089
|
-
|
|
6090
|
-
const Conditional = options.conditionals?.Component;
|
|
6091
|
-
if (!Conditional) return render(item, index);
|
|
6092
|
-
return React.createElement(Conditional, {
|
|
6093
|
-
key: `${key}:${conditionalId}`,
|
|
6099
|
+
if (this.state.fallback || !options.conditionals) return render(item, index);
|
|
6100
|
+
return options.conditionals.element({
|
|
6094
6101
|
owner: this.conditionalOwner,
|
|
6095
|
-
rowKey:
|
|
6102
|
+
rowKey: keyedRowIdentity(this.currentProps.rowKey(item, index)),
|
|
6096
6103
|
id: conditionalId,
|
|
6097
6104
|
renderVersion: this.renderVersion,
|
|
6098
6105
|
item,
|
|
@@ -6211,7 +6218,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6211
6218
|
);
|
|
6212
6219
|
if (filteredInstances) {
|
|
6213
6220
|
this.instances = filteredInstances;
|
|
6214
|
-
this.rebuildElementIndex(this.instances);
|
|
6221
|
+
if (!this.elementIndexComplete) this.rebuildElementIndex(this.instances);
|
|
6215
6222
|
this.pruneEventHandlers();
|
|
6216
6223
|
this.pruneConditionalListeners();
|
|
6217
6224
|
this.commitCurrentCollection(dirtyState);
|
|
@@ -6240,9 +6247,29 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6240
6247
|
}
|
|
6241
6248
|
readRows(props) {
|
|
6242
6249
|
const items = materializeIterable(props.items());
|
|
6243
|
-
const keys =
|
|
6244
|
-
|
|
6245
|
-
|
|
6250
|
+
const keys = [];
|
|
6251
|
+
const committedSize = this.instances.size;
|
|
6252
|
+
let prefix = 0;
|
|
6253
|
+
const committed = this.instances.keys();
|
|
6254
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
6255
|
+
const key = keyedRowIdentity(props.rowKey(items[index], index));
|
|
6256
|
+
keys.push(key);
|
|
6257
|
+
if (prefix === index && index < committedSize && committed.next().value === key) {
|
|
6258
|
+
prefix += 1;
|
|
6259
|
+
}
|
|
6260
|
+
}
|
|
6261
|
+
if (prefix === committedSize && keys.length === committedSize) return { items, keys };
|
|
6262
|
+
if (prefix === committedSize && committedSize > 0) {
|
|
6263
|
+
const tail = /* @__PURE__ */ new Set();
|
|
6264
|
+
for (let index = committedSize; index < keys.length; index += 1) {
|
|
6265
|
+
const key = keys[index];
|
|
6266
|
+
if (this.instances.has(key) || tail.has(key)) return null;
|
|
6267
|
+
tail.add(key);
|
|
6268
|
+
}
|
|
6269
|
+
return { items, keys, appended: true };
|
|
6270
|
+
}
|
|
6271
|
+
const keySet = new Set(keys);
|
|
6272
|
+
return keySet.size === keys.length ? { items, keys, keySet } : null;
|
|
6246
6273
|
}
|
|
6247
6274
|
usesDelegatedEvents(props = this.currentProps) {
|
|
6248
6275
|
return Boolean(
|
|
@@ -6251,7 +6278,8 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6251
6278
|
}
|
|
6252
6279
|
rebuildElementIndex(instances) {
|
|
6253
6280
|
this.instancesByElement = /* @__PURE__ */ new WeakMap();
|
|
6254
|
-
|
|
6281
|
+
this.elementIndexComplete = this.usesDelegatedEvents();
|
|
6282
|
+
if (!this.elementIndexComplete) return;
|
|
6255
6283
|
for (const instance of instances.values()) {
|
|
6256
6284
|
this.instancesByElement.set(instance.element, instance);
|
|
6257
6285
|
}
|
|
@@ -6293,20 +6321,6 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6293
6321
|
})
|
|
6294
6322
|
);
|
|
6295
6323
|
}
|
|
6296
|
-
subscribeToRowConditional(key, id, refresh) {
|
|
6297
|
-
let listeners = this.conditionalListeners.get(key);
|
|
6298
|
-
if (!listeners) {
|
|
6299
|
-
listeners = /* @__PURE__ */ new Map();
|
|
6300
|
-
this.conditionalListeners.set(key, listeners);
|
|
6301
|
-
}
|
|
6302
|
-
listeners.set(id, refresh);
|
|
6303
|
-
return () => {
|
|
6304
|
-
const current = this.conditionalListeners.get(key);
|
|
6305
|
-
if (current?.get(id) !== refresh) return;
|
|
6306
|
-
current.delete(id);
|
|
6307
|
-
if (current.size === 0) this.conditionalListeners.delete(key);
|
|
6308
|
-
};
|
|
6309
|
-
}
|
|
6310
6324
|
hasReactOwnedRows(props = this.currentProps) {
|
|
6311
6325
|
return Boolean(
|
|
6312
6326
|
props.conditionals?.length || props.events?.length && !this.usesDelegatedEvents(props)
|
|
@@ -6425,22 +6439,8 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6425
6439
|
});
|
|
6426
6440
|
}
|
|
6427
6441
|
notifyConditionalChanges(changes, afterCommit) {
|
|
6428
|
-
if (changes.length === 0)
|
|
6429
|
-
|
|
6430
|
-
return;
|
|
6431
|
-
}
|
|
6432
|
-
let pending = changes.length;
|
|
6433
|
-
const committed = () => {
|
|
6434
|
-
pending -= 1;
|
|
6435
|
-
if (pending === 0) afterCommit?.();
|
|
6436
|
-
};
|
|
6437
|
-
flushSync(() => {
|
|
6438
|
-
for (const change of changes) {
|
|
6439
|
-
const refresh = this.conditionalListeners.get(change.key)?.get(change.id);
|
|
6440
|
-
if (refresh) refresh(change.item, change.index, committed);
|
|
6441
|
-
else committed();
|
|
6442
|
-
}
|
|
6443
|
-
});
|
|
6442
|
+
if (changes.length === 0) afterCommit?.();
|
|
6443
|
+
else options.conditionals.notify(this.conditionalListeners, changes, afterCommit);
|
|
6444
6444
|
}
|
|
6445
6445
|
refreshDirtyBindings(dirtyState, afterCommit) {
|
|
6446
6446
|
if (!this.mounted || !this.root || this.state.fallback || this.hasReactOwnedRows() || this.currentProps.hostBlocks || !this.currentProps.structureDependencies || this.currentProps.structureDependencies.some((dependency) => dirtyState.has(dependency)) || this.currentProps.bindings.some((binding) => binding.dependencies === void 0)) {
|
|
@@ -6521,7 +6521,8 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6521
6521
|
index += 1;
|
|
6522
6522
|
}
|
|
6523
6523
|
const shouldPrepareBindings = rows.items.length > 1 && this.currentProps.bindings.length > 0 && !this.currentProps.hostBlocks;
|
|
6524
|
-
const
|
|
6524
|
+
const ordered = [...this.instances.values()];
|
|
6525
|
+
const preparedBindings = shouldPrepareBindings ? prepareKeyedRowBindingSetUpdates(this.currentProps, this.instances, rows, ordered) : void 0;
|
|
6525
6526
|
if (shouldPrepareBindings && !preparedBindings) {
|
|
6526
6527
|
this.activateFallback(afterCommit);
|
|
6527
6528
|
return true;
|
|
@@ -6529,8 +6530,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6529
6530
|
const conditionalChanges = [];
|
|
6530
6531
|
for (index = 0; index < rows.items.length; index += 1) {
|
|
6531
6532
|
const key = rows.keys[index];
|
|
6532
|
-
const existing =
|
|
6533
|
-
if (!existing) return false;
|
|
6533
|
+
const existing = ordered[index];
|
|
6534
6534
|
if (this.currentProps.hostBlocks) {
|
|
6535
6535
|
const descriptor = this.currentProps.create(rows.items[index], index);
|
|
6536
6536
|
if (!existing.scope?.update(descriptor)) {
|
|
@@ -6567,6 +6567,39 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6567
6567
|
this.notifyConditionalChanges(conditionalChanges, afterCommit);
|
|
6568
6568
|
return true;
|
|
6569
6569
|
}
|
|
6570
|
+
// Keys are the committed keys plus new ones: patch every existing row like
|
|
6571
|
+
// the complete path does, then create and append only the new rows.
|
|
6572
|
+
reconcileAppendedRows(rows, afterCommit, dirtyState) {
|
|
6573
|
+
const root = this.root;
|
|
6574
|
+
let index = 0;
|
|
6575
|
+
for (const existing of this.instances.values()) {
|
|
6576
|
+
applyKeyedRowBindings(this.currentProps, existing, rows.items[index], index);
|
|
6577
|
+
existing.item = rows.items[index];
|
|
6578
|
+
existing.index = index;
|
|
6579
|
+
index += 1;
|
|
6580
|
+
}
|
|
6581
|
+
const appended = [];
|
|
6582
|
+
for (; index < rows.items.length; index += 1) {
|
|
6583
|
+
appended.push(
|
|
6584
|
+
createKeyedRowInstance(
|
|
6585
|
+
this.currentProps,
|
|
6586
|
+
root.ownerDocument,
|
|
6587
|
+
rows.keys[index],
|
|
6588
|
+
rows.items[index],
|
|
6589
|
+
index
|
|
6590
|
+
)
|
|
6591
|
+
);
|
|
6592
|
+
}
|
|
6593
|
+
const indexElements = this.elementIndexComplete && this.usesDelegatedEvents();
|
|
6594
|
+
for (const instance of appended) {
|
|
6595
|
+
root.appendChild(instance.element);
|
|
6596
|
+
this.instances.set(instance.key, instance);
|
|
6597
|
+
if (indexElements) this.instancesByElement.set(instance.element, instance);
|
|
6598
|
+
}
|
|
6599
|
+
if (!indexElements) this.rebuildElementIndex(this.instances);
|
|
6600
|
+
this.commitCurrentCollection(dirtyState);
|
|
6601
|
+
afterCommit?.();
|
|
6602
|
+
}
|
|
6570
6603
|
reconcileRemovals(rows, afterCommit, dirtyState) {
|
|
6571
6604
|
if (this.hasReactOwnedRows() || rows.keys.length >= this.instances.size) return false;
|
|
6572
6605
|
const removed = [];
|
|
@@ -6669,6 +6702,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6669
6702
|
this.root.replaceChildren();
|
|
6670
6703
|
this.instances = /* @__PURE__ */ new Map();
|
|
6671
6704
|
this.instancesByElement = /* @__PURE__ */ new WeakMap();
|
|
6705
|
+
this.elementIndexComplete = true;
|
|
6672
6706
|
this.eventHandlers.clear();
|
|
6673
6707
|
this.conditionalListeners.clear();
|
|
6674
6708
|
this.commitCurrentCollection(dirtyState);
|
|
@@ -6677,7 +6711,11 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6677
6711
|
}
|
|
6678
6712
|
if (this.reconcileStableRows(rows, afterCommit, dirtyState)) return;
|
|
6679
6713
|
if (this.reconcileRemovals(rows, afterCommit, dirtyState)) return;
|
|
6680
|
-
|
|
6714
|
+
if (rows.appended && !this.currentProps.hostBlocks) {
|
|
6715
|
+
this.reconcileAppendedRows(rows, afterCommit, dirtyState);
|
|
6716
|
+
return;
|
|
6717
|
+
}
|
|
6718
|
+
const nextKeys = rows.keySet ?? new Set(rows.keys);
|
|
6681
6719
|
const hasSurvivingRows = rows.keys.some((key) => this.instances.has(key));
|
|
6682
6720
|
const preparedBindings = nextKeys.size < this.instances.size && this.currentProps.bindings.length > 0 && !this.currentProps.hostBlocks && rows.keys.every((key) => this.instances.has(key)) ? prepareKeyedRowBindingSetUpdates(this.currentProps, this.instances, rows) : null;
|
|
6683
6721
|
if (preparedBindings === void 0) {
|
|
@@ -6686,7 +6724,8 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6686
6724
|
}
|
|
6687
6725
|
const oldIndices = /* @__PURE__ */ new Map();
|
|
6688
6726
|
if (hasSurvivingRows) {
|
|
6689
|
-
|
|
6727
|
+
let oldIndex = 0;
|
|
6728
|
+
for (const key of this.instances.keys()) oldIndices.set(key, oldIndex++);
|
|
6690
6729
|
}
|
|
6691
6730
|
for (const [key, instance] of this.instances) {
|
|
6692
6731
|
if (!nextKeys.has(key)) {
|
|
@@ -6694,7 +6733,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6694
6733
|
if (hasSurvivingRows) instance.element.remove();
|
|
6695
6734
|
}
|
|
6696
6735
|
}
|
|
6697
|
-
const sequence = hasSurvivingRows ? rows.keys.map((key) => oldIndices.get(key) ?? -1) :
|
|
6736
|
+
const sequence = hasSurvivingRows ? rows.keys.map((key) => oldIndices.get(key) ?? -1) : [];
|
|
6698
6737
|
const nextInstances = [];
|
|
6699
6738
|
const conditionalChanges = [];
|
|
6700
6739
|
for (let index = 0; index < rows.items.length; index += 1) {
|
|
@@ -6738,10 +6777,26 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6738
6777
|
nextInstances.push(existing);
|
|
6739
6778
|
continue;
|
|
6740
6779
|
}
|
|
6780
|
+
if (!this.currentProps.hostBlocks) {
|
|
6781
|
+
const instance = createKeyedRowInstance(
|
|
6782
|
+
this.currentProps,
|
|
6783
|
+
this.root.ownerDocument,
|
|
6784
|
+
key,
|
|
6785
|
+
rows.items[index],
|
|
6786
|
+
index
|
|
6787
|
+
);
|
|
6788
|
+
instance.conditionalValues = this.readConditionalValues(
|
|
6789
|
+
this.currentProps,
|
|
6790
|
+
rows.items[index],
|
|
6791
|
+
index
|
|
6792
|
+
);
|
|
6793
|
+
nextInstances.push(instance);
|
|
6794
|
+
continue;
|
|
6795
|
+
}
|
|
6741
6796
|
const descriptor = this.currentProps.create(rows.items[index], index);
|
|
6742
6797
|
const element = createCompilerHostElement(this.root.ownerDocument, descriptor);
|
|
6743
6798
|
const scope = this.mountRowHostScope(element, descriptor);
|
|
6744
|
-
if (
|
|
6799
|
+
if (!scope) {
|
|
6745
6800
|
for (const instance of nextInstances) {
|
|
6746
6801
|
if (!this.instances.has(instance.key)) instance.scope?.cleanup();
|
|
6747
6802
|
}
|
|
@@ -6763,14 +6818,21 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6763
6818
|
});
|
|
6764
6819
|
}
|
|
6765
6820
|
if (!hasSurvivingRows) {
|
|
6766
|
-
|
|
6767
|
-
for (const instance of nextInstances)
|
|
6768
|
-
this.root.replaceChildren(fragment);
|
|
6821
|
+
this.root.replaceChildren();
|
|
6822
|
+
for (const instance of nextInstances) this.root.appendChild(instance.element);
|
|
6769
6823
|
} else {
|
|
6770
6824
|
reorderCompilerKeyedRows(this.root, nextInstances, sequence, null);
|
|
6771
6825
|
}
|
|
6772
6826
|
this.instances = keyedRowInstancesByKey(nextInstances);
|
|
6773
|
-
this.
|
|
6827
|
+
if (hasSurvivingRows && this.elementIndexComplete && this.usesDelegatedEvents()) {
|
|
6828
|
+
for (let index = 0; index < nextInstances.length; index += 1) {
|
|
6829
|
+
if (sequence[index] < 0) {
|
|
6830
|
+
this.instancesByElement.set(nextInstances[index].element, nextInstances[index]);
|
|
6831
|
+
}
|
|
6832
|
+
}
|
|
6833
|
+
} else {
|
|
6834
|
+
this.rebuildElementIndex(this.instances);
|
|
6835
|
+
}
|
|
6774
6836
|
this.pruneEventHandlers();
|
|
6775
6837
|
this.pruneConditionalListeners();
|
|
6776
6838
|
this.commitCurrentCollection(dirtyState);
|
|
@@ -6843,6 +6905,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6843
6905
|
this.reactElements = [];
|
|
6844
6906
|
this.keyedTargets?.clear();
|
|
6845
6907
|
this.instancesByElement = /* @__PURE__ */ new WeakMap();
|
|
6908
|
+
this.elementIndexComplete = true;
|
|
6846
6909
|
this.eventHandlers.clear();
|
|
6847
6910
|
this.conditionalListeners.clear();
|
|
6848
6911
|
}
|
|
@@ -6994,25 +7057,16 @@ function createKeyedRangesBlockComponent(owner) {
|
|
|
6994
7057
|
nextInstances.push(existing);
|
|
6995
7058
|
continue;
|
|
6996
7059
|
}
|
|
6997
|
-
|
|
6998
|
-
this.root.ownerDocument,
|
|
6999
|
-
range.create(rows.items[index], index)
|
|
7060
|
+
nextInstances.push(
|
|
7061
|
+
createKeyedRowInstance(range, this.root.ownerDocument, key, rows.items[index], index)
|
|
7000
7062
|
);
|
|
7001
|
-
nextInstances.push({
|
|
7002
|
-
key,
|
|
7003
|
-
element,
|
|
7004
|
-
values: readKeyedRowBindingValues(range, rows.items[index], index),
|
|
7005
|
-
item: rows.items[index],
|
|
7006
|
-
index,
|
|
7007
|
-
conditionalValues: /* @__PURE__ */ new Map()
|
|
7008
|
-
});
|
|
7009
7063
|
}
|
|
7010
7064
|
let anchor = this.anchorAfter(rangeIndex);
|
|
7011
7065
|
for (let index = nextInstances.length - 1; index >= 0; index -= 1) {
|
|
7012
7066
|
const instance = nextInstances[index];
|
|
7013
7067
|
if (sequence[index] < 0) {
|
|
7014
7068
|
this.root.insertBefore(instance.element, anchor);
|
|
7015
|
-
} else if (!stablePositions
|
|
7069
|
+
} else if (!stablePositions[index] && instance.element.nextSibling !== anchor) {
|
|
7016
7070
|
this.root.insertBefore(instance.element, anchor);
|
|
7017
7071
|
}
|
|
7018
7072
|
anchor = instance.element;
|