@farm.js/react 0.1.0-beta.21 → 0.1.0-beta.22
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 +27 -12
- 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 +43 -8
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +43 -8
- package/dist/vite.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -11,8 +11,14 @@ var React__default = /*#__PURE__*/_interopDefault(React);
|
|
|
11
11
|
|
|
12
12
|
// src/iterable.ts
|
|
13
13
|
var oneShotSnapshots = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
var arrayIterator = Array.prototype[Symbol.iterator];
|
|
14
15
|
function materializeIterable(source) {
|
|
15
16
|
if (source == null) return [];
|
|
17
|
+
if (Array.isArray(source) && Object.getPrototypeOf(source) === Array.prototype && source[Symbol.iterator] === arrayIterator) {
|
|
18
|
+
const items2 = [];
|
|
19
|
+
for (let index = 0; index < source.length; index += 1) items2.push(source[index]);
|
|
20
|
+
return items2;
|
|
21
|
+
}
|
|
16
22
|
const iterator = source[Symbol.iterator]();
|
|
17
23
|
const oneShot = iterator === source && (typeof source === "object" || typeof source === "function");
|
|
18
24
|
if (oneShot) {
|
|
@@ -1586,7 +1592,9 @@ function getCompilerHmrRegistry() {
|
|
|
1586
1592
|
return registry;
|
|
1587
1593
|
}
|
|
1588
1594
|
function renderTextValue(value) {
|
|
1589
|
-
if (Array.isArray(value))
|
|
1595
|
+
if (Array.isArray(value)) {
|
|
1596
|
+
return value.length === 1 ? renderTextValue(value[0]) : value.map(renderTextValue).join("");
|
|
1597
|
+
}
|
|
1590
1598
|
if (value === null || value === void 0 || typeof value === "boolean") return "";
|
|
1591
1599
|
return String(value);
|
|
1592
1600
|
}
|
|
@@ -1713,8 +1721,11 @@ function updateSelectValue(element, value) {
|
|
|
1713
1721
|
}
|
|
1714
1722
|
if (fallback) fallback.selected = true;
|
|
1715
1723
|
}
|
|
1724
|
+
function compilerAttributeName(name) {
|
|
1725
|
+
return name === "className" ? "class" : name === "htmlFor" ? "for" : name;
|
|
1726
|
+
}
|
|
1716
1727
|
function updateAttribute(element, name, value) {
|
|
1717
|
-
const attributeName = name
|
|
1728
|
+
const attributeName = compilerAttributeName(name);
|
|
1718
1729
|
const stringifiesBoolean = attributeName.startsWith("data-") || attributeName.startsWith("aria-");
|
|
1719
1730
|
if (name === "value" && (isInputElement(element) || isTextAreaElement(element))) {
|
|
1720
1731
|
const nextValue = value === null || value === void 0 ? "" : String(value);
|
|
@@ -1967,7 +1978,10 @@ function hasUnsafeCompilerFallbackKeys(descriptor) {
|
|
|
1967
1978
|
}
|
|
1968
1979
|
function findCompilerHostTarget(root, path) {
|
|
1969
1980
|
let current = root;
|
|
1970
|
-
for (const index of path)
|
|
1981
|
+
for (const index of path) {
|
|
1982
|
+
current = current && current.firstElementChild;
|
|
1983
|
+
for (let step = 0; step < index && current; step += 1) current = current.nextElementSibling;
|
|
1984
|
+
}
|
|
1971
1985
|
return current;
|
|
1972
1986
|
}
|
|
1973
1987
|
var UNSET_STATIC_RANGE_BINDING = /* @__PURE__ */ Symbol("unset static range binding");
|
|
@@ -2502,9 +2516,64 @@ function normalizedKeyedRowBindingValue(binding, value) {
|
|
|
2502
2516
|
return binding.kind === "text" ? renderTextValue(value) : value;
|
|
2503
2517
|
}
|
|
2504
2518
|
function readKeyedRowBindingValues(props, item, index) {
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2519
|
+
const values = [];
|
|
2520
|
+
for (const binding of props.bindings) {
|
|
2521
|
+
values.push(normalizedKeyedRowBindingValue(binding, binding.read(item, index)));
|
|
2522
|
+
}
|
|
2523
|
+
return values;
|
|
2524
|
+
}
|
|
2525
|
+
var KEYED_ROW_TEMPLATES = /* @__PURE__ */ new WeakMap();
|
|
2526
|
+
function createKeyedRowInstance(props, document, key, item, index) {
|
|
2527
|
+
const template = props.cloneRows && KEYED_ROW_TEMPLATES.get(props);
|
|
2528
|
+
const element = template ? template.cloneNode(true) : createCompilerHostElement(document, props.create(item, index));
|
|
2529
|
+
const instance = {
|
|
2530
|
+
key,
|
|
2531
|
+
element,
|
|
2532
|
+
values: readKeyedRowBindingValues(props, item, index),
|
|
2533
|
+
item,
|
|
2534
|
+
index,
|
|
2535
|
+
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
2536
|
+
};
|
|
2537
|
+
if (props.cloneRows) {
|
|
2538
|
+
const targets = [];
|
|
2539
|
+
let found = true;
|
|
2540
|
+
for (const binding of props.bindings) {
|
|
2541
|
+
const target = findCompilerHostTarget(element, binding.path);
|
|
2542
|
+
found && (found = target !== null);
|
|
2543
|
+
targets.push(target);
|
|
2544
|
+
}
|
|
2545
|
+
if (found) instance.targets = targets;
|
|
2546
|
+
if (template) {
|
|
2547
|
+
for (let bindingIndex = 0; bindingIndex < targets.length; bindingIndex += 1) {
|
|
2548
|
+
commitKeyedRowBinding(
|
|
2549
|
+
props.bindings[bindingIndex],
|
|
2550
|
+
instance,
|
|
2551
|
+
bindingIndex,
|
|
2552
|
+
instance.values[bindingIndex],
|
|
2553
|
+
targets[bindingIndex]
|
|
2554
|
+
);
|
|
2555
|
+
}
|
|
2556
|
+
} else {
|
|
2557
|
+
const skeleton = keyedRowTemplate(props, element, targets);
|
|
2558
|
+
if (skeleton) KEYED_ROW_TEMPLATES.set(props, skeleton);
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
return instance;
|
|
2562
|
+
}
|
|
2563
|
+
function keyedRowTemplate(props, element, targets) {
|
|
2564
|
+
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
2565
|
+
const binding = props.bindings[bindingIndex];
|
|
2566
|
+
const target = targets[bindingIndex];
|
|
2567
|
+
if (!target || binding.kind === "style") return void 0;
|
|
2568
|
+
if (binding.kind === "attribute" && !target.hasAttribute(compilerAttributeName(binding.name))) {
|
|
2569
|
+
return void 0;
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
const template = element.cloneNode(true);
|
|
2573
|
+
for (const binding of props.bindings) {
|
|
2574
|
+
if (binding.kind === "text") findCompilerHostTarget(template, binding.path).textContent = "";
|
|
2575
|
+
}
|
|
2576
|
+
return template;
|
|
2508
2577
|
}
|
|
2509
2578
|
function applyKeyedRowBindings(props, instance, item, index) {
|
|
2510
2579
|
if (props.bindings.length < 2) {
|
|
@@ -2516,10 +2585,7 @@ function applyKeyedRowBindings(props, instance, item, index) {
|
|
|
2516
2585
|
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
2517
2586
|
if (Object.is(instance.values[bindingIndex], nextValues[bindingIndex])) continue;
|
|
2518
2587
|
targets || (targets = []);
|
|
2519
|
-
targets[bindingIndex] =
|
|
2520
|
-
instance.element,
|
|
2521
|
-
props.bindings[bindingIndex].path
|
|
2522
|
-
);
|
|
2588
|
+
targets[bindingIndex] = keyedRowBindingTarget(props, instance, bindingIndex);
|
|
2523
2589
|
}
|
|
2524
2590
|
if (!targets) return;
|
|
2525
2591
|
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
@@ -2538,14 +2604,22 @@ function applyKeyedRowBinding(props, instance, item, index, bindingIndex) {
|
|
|
2538
2604
|
const binding = props.bindings[bindingIndex];
|
|
2539
2605
|
const value = normalizedKeyedRowBindingValue(binding, binding.read(item, index));
|
|
2540
2606
|
if (Object.is(instance.values[bindingIndex], value)) return;
|
|
2541
|
-
const target =
|
|
2607
|
+
const target = keyedRowBindingTarget(props, instance, bindingIndex);
|
|
2542
2608
|
commitKeyedRowBinding(binding, instance, bindingIndex, value, target);
|
|
2543
2609
|
}
|
|
2610
|
+
function keyedRowBindingTarget(props, instance, bindingIndex) {
|
|
2611
|
+
return instance.targets?.[bindingIndex] || findCompilerHostTarget(instance.element, props.bindings[bindingIndex].path);
|
|
2612
|
+
}
|
|
2544
2613
|
function commitKeyedRowBinding(binding, instance, bindingIndex, value, target) {
|
|
2545
2614
|
instance.values[bindingIndex] = value;
|
|
2546
2615
|
if (!target) return;
|
|
2547
2616
|
if (binding.kind === "text") {
|
|
2548
|
-
|
|
2617
|
+
const text = target.firstChild;
|
|
2618
|
+
if (value && text && text === target.lastChild && text.nodeType === 3) {
|
|
2619
|
+
text.data = value;
|
|
2620
|
+
} else {
|
|
2621
|
+
target.textContent = value;
|
|
2622
|
+
}
|
|
2549
2623
|
} else if (binding.kind === "style" && binding.name) {
|
|
2550
2624
|
updateStyle(target, binding.name, value);
|
|
2551
2625
|
} else if (binding.kind === "attribute" && binding.name) {
|
|
@@ -2557,28 +2631,29 @@ function prepareKeyedRowBindingUpdate(props, instance, item, index, bindingIndex
|
|
|
2557
2631
|
const rawValue = binding.read(item, index);
|
|
2558
2632
|
const value = normalizedKeyedRowBindingValue(binding, rawValue);
|
|
2559
2633
|
if (Object.is(instance.values[bindingIndex], value)) return null;
|
|
2560
|
-
const target =
|
|
2634
|
+
const target = keyedRowBindingTarget(props, instance, bindingIndex);
|
|
2561
2635
|
if (!target || binding.kind !== "text" && !binding.name) return void 0;
|
|
2562
2636
|
return [bindingIndex, target, value];
|
|
2563
2637
|
}
|
|
2564
2638
|
function prepareKeyedRowBindingUpdates(props, instance, item, index) {
|
|
2565
|
-
|
|
2639
|
+
let updates;
|
|
2566
2640
|
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
2567
2641
|
const update = prepareKeyedRowBindingUpdate(props, instance, item, index, bindingIndex);
|
|
2568
2642
|
if (update === void 0) return void 0;
|
|
2569
|
-
if (update) updates.push(update);
|
|
2643
|
+
if (update) (updates || (updates = [])).push(update);
|
|
2570
2644
|
}
|
|
2571
|
-
return updates;
|
|
2645
|
+
return updates || NO_KEYED_ROW_BINDING_UPDATES;
|
|
2572
2646
|
}
|
|
2647
|
+
var NO_KEYED_ROW_BINDING_UPDATES = [];
|
|
2573
2648
|
function applyPreparedKeyedRowBindingUpdates(props, instance, updates) {
|
|
2574
2649
|
for (const [bindingIndex, target, value] of updates) {
|
|
2575
2650
|
commitKeyedRowBinding(props.bindings[bindingIndex], instance, bindingIndex, value, target);
|
|
2576
2651
|
}
|
|
2577
2652
|
}
|
|
2578
|
-
function prepareKeyedRowBindingSetUpdates(props, instances, rows) {
|
|
2653
|
+
function prepareKeyedRowBindingSetUpdates(props, instances, rows, ordered) {
|
|
2579
2654
|
const preparedUpdates = [];
|
|
2580
2655
|
for (let index = 0; index < rows.items.length; index += 1) {
|
|
2581
|
-
const instance = instances.get(rows.keys[index]);
|
|
2656
|
+
const instance = ordered ? ordered[index] : instances.get(rows.keys[index]);
|
|
2582
2657
|
if (!instance) return void 0;
|
|
2583
2658
|
const updates = prepareKeyedRowBindingUpdates(props, instance, rows.items[index], index);
|
|
2584
2659
|
if (!updates) return void 0;
|
|
@@ -3231,7 +3306,7 @@ var CompilerNestedKeyedRanges = class {
|
|
|
3231
3306
|
let anchor = this.anchorAfter(rangeIndex);
|
|
3232
3307
|
for (let index = nextInstances.length - 1; index >= 0; index -= 1) {
|
|
3233
3308
|
const instance = nextInstances[index];
|
|
3234
|
-
if (sequence[index] < 0 || !stablePositions
|
|
3309
|
+
if (sequence[index] < 0 || !stablePositions[index] && instance.element.nextSibling !== anchor) {
|
|
3235
3310
|
this.root.insertBefore(instance.element, anchor);
|
|
3236
3311
|
}
|
|
3237
3312
|
anchor = instance.element;
|
|
@@ -3598,7 +3673,7 @@ var CompilerNestedMixedRanges = class {
|
|
|
3598
3673
|
let anchor = this.anchorAfter(rangeIndex);
|
|
3599
3674
|
for (let index = nextInstances.length - 1; index >= 0; index -= 1) {
|
|
3600
3675
|
const row = nextInstances[index];
|
|
3601
|
-
if (sequence[index] < 0 || !stablePositions
|
|
3676
|
+
if (sequence[index] < 0 || !stablePositions[index] && row.element.nextSibling !== anchor) {
|
|
3602
3677
|
this.root.insertBefore(row.element, anchor);
|
|
3603
3678
|
}
|
|
3604
3679
|
anchor = row.element;
|
|
@@ -4260,7 +4335,7 @@ function createConditionalRangesBlockComponent(owner) {
|
|
|
4260
4335
|
}
|
|
4261
4336
|
function longestIncreasingSubsequencePositions(sequence) {
|
|
4262
4337
|
const tails = [];
|
|
4263
|
-
const previous =
|
|
4338
|
+
const previous = new Int32Array(sequence.length).fill(-1);
|
|
4264
4339
|
for (let index = 0; index < sequence.length; index += 1) {
|
|
4265
4340
|
if (sequence[index] < 0) continue;
|
|
4266
4341
|
let low = 0;
|
|
@@ -4273,10 +4348,10 @@ function longestIncreasingSubsequencePositions(sequence) {
|
|
|
4273
4348
|
if (low > 0) previous[index] = tails[low - 1];
|
|
4274
4349
|
tails[low] = index;
|
|
4275
4350
|
}
|
|
4276
|
-
const positions =
|
|
4351
|
+
const positions = new Uint8Array(sequence.length);
|
|
4277
4352
|
let cursor = tails.at(-1) ?? -1;
|
|
4278
4353
|
while (cursor >= 0) {
|
|
4279
|
-
positions
|
|
4354
|
+
positions[cursor] = 1;
|
|
4280
4355
|
cursor = previous[cursor];
|
|
4281
4356
|
}
|
|
4282
4357
|
return positions;
|
|
@@ -4289,15 +4364,13 @@ function reorderCompilerKeyedRows(root, instances, sequence, anchor) {
|
|
|
4289
4364
|
if (sequence[index] < 0) {
|
|
4290
4365
|
let start = index;
|
|
4291
4366
|
while (start > 0 && sequence[start - 1] < 0) start -= 1;
|
|
4292
|
-
const fragment = root.ownerDocument.createDocumentFragment();
|
|
4293
4367
|
for (let itemIndex = start; itemIndex <= index; itemIndex += 1) {
|
|
4294
|
-
|
|
4368
|
+
root.insertBefore(instances[itemIndex].element, anchor);
|
|
4295
4369
|
}
|
|
4296
|
-
root.insertBefore(fragment, anchor);
|
|
4297
4370
|
anchor = instances[start].element;
|
|
4298
4371
|
index = start;
|
|
4299
4372
|
} else {
|
|
4300
|
-
if (!stablePositions
|
|
4373
|
+
if (!stablePositions[index] && instance.element.nextSibling !== anchor) {
|
|
4301
4374
|
root.insertBefore(instance.element, anchor);
|
|
4302
4375
|
}
|
|
4303
4376
|
anchor = instance.element;
|
|
@@ -4565,15 +4638,13 @@ function reconcileCompilerKeyedArrayAppend(props, dirtyState, collectionToken, i
|
|
|
4565
4638
|
const item = finalValue[index];
|
|
4566
4639
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
4567
4640
|
if (nextInstances.has(key)) return void 0;
|
|
4568
|
-
const
|
|
4569
|
-
|
|
4641
|
+
const instance = createKeyedRowInstance(
|
|
4642
|
+
props,
|
|
4643
|
+
root.ownerDocument,
|
|
4570
4644
|
key,
|
|
4571
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
4572
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
4573
4645
|
item,
|
|
4574
|
-
index
|
|
4575
|
-
|
|
4576
|
-
};
|
|
4646
|
+
index
|
|
4647
|
+
);
|
|
4577
4648
|
appended.push(instance);
|
|
4578
4649
|
nextInstances.set(key, instance);
|
|
4579
4650
|
}
|
|
@@ -4630,15 +4701,7 @@ function reconcileCompilerKeyedArrayStructuralAppend(props, dirtyState, collecti
|
|
|
4630
4701
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
4631
4702
|
if (knownKeys.has(key)) return void 0;
|
|
4632
4703
|
knownKeys.add(key);
|
|
4633
|
-
|
|
4634
|
-
appended.push({
|
|
4635
|
-
key,
|
|
4636
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
4637
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
4638
|
-
item,
|
|
4639
|
-
index,
|
|
4640
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
4641
|
-
});
|
|
4704
|
+
appended.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
4642
4705
|
}
|
|
4643
4706
|
} catch {
|
|
4644
4707
|
return void 0;
|
|
@@ -4739,15 +4802,7 @@ function reconcileCompilerKeyedArrayStructuralAppendMap(props, dirtyState, colle
|
|
|
4739
4802
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
4740
4803
|
if (instances.has(key) || appendedKeys.has(key)) return void 0;
|
|
4741
4804
|
appendedKeys.add(key);
|
|
4742
|
-
|
|
4743
|
-
appended.push({
|
|
4744
|
-
key,
|
|
4745
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
4746
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
4747
|
-
item,
|
|
4748
|
-
index,
|
|
4749
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
4750
|
-
});
|
|
4805
|
+
appended.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
4751
4806
|
}
|
|
4752
4807
|
} catch {
|
|
4753
4808
|
return void 0;
|
|
@@ -4845,15 +4900,7 @@ function reconcileCompilerKeyedArrayRollingWindow(props, dirtyState, collectionT
|
|
|
4845
4900
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
4846
4901
|
if (knownKeys.has(key)) return void 0;
|
|
4847
4902
|
knownKeys.add(key);
|
|
4848
|
-
|
|
4849
|
-
incoming.push({
|
|
4850
|
-
key,
|
|
4851
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
4852
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
4853
|
-
item,
|
|
4854
|
-
index,
|
|
4855
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
4856
|
-
});
|
|
4903
|
+
incoming.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
4857
4904
|
}
|
|
4858
4905
|
} catch {
|
|
4859
4906
|
return void 0;
|
|
@@ -4924,15 +4971,7 @@ function reconcileCompilerKeyedArrayMappedRollingWindow(props, dirtyState, colle
|
|
|
4924
4971
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
4925
4972
|
if (instances.has(key) || incomingKeys.has(key)) return void 0;
|
|
4926
4973
|
incomingKeys.add(key);
|
|
4927
|
-
|
|
4928
|
-
incoming.push({
|
|
4929
|
-
key,
|
|
4930
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
4931
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
4932
|
-
item,
|
|
4933
|
-
index,
|
|
4934
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
4935
|
-
});
|
|
4974
|
+
incoming.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
4936
4975
|
}
|
|
4937
4976
|
} catch {
|
|
4938
4977
|
return void 0;
|
|
@@ -5011,15 +5050,7 @@ function reconcileCompilerKeyedArrayPosition(props, dirtyState, collectionToken,
|
|
|
5011
5050
|
if (instances.has(key)) return void 0;
|
|
5012
5051
|
let inserted;
|
|
5013
5052
|
try {
|
|
5014
|
-
|
|
5015
|
-
inserted = {
|
|
5016
|
-
key,
|
|
5017
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5018
|
-
values: readKeyedRowBindingValues(props, item, update.position),
|
|
5019
|
-
item,
|
|
5020
|
-
index: update.position,
|
|
5021
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5022
|
-
};
|
|
5053
|
+
inserted = createKeyedRowInstance(props, root.ownerDocument, key, item, update.position);
|
|
5023
5054
|
} catch {
|
|
5024
5055
|
return void 0;
|
|
5025
5056
|
}
|
|
@@ -5043,15 +5074,7 @@ function reconcileCompilerKeyedArrayPosition(props, dirtyState, collectionToken,
|
|
|
5043
5074
|
if (instances.has(key)) return void 0;
|
|
5044
5075
|
let replacement;
|
|
5045
5076
|
try {
|
|
5046
|
-
|
|
5047
|
-
replacement = {
|
|
5048
|
-
key,
|
|
5049
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5050
|
-
values: readKeyedRowBindingValues(props, item, update.position),
|
|
5051
|
-
item,
|
|
5052
|
-
index: update.position,
|
|
5053
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5054
|
-
};
|
|
5077
|
+
replacement = createKeyedRowInstance(props, root.ownerDocument, key, item, update.position);
|
|
5055
5078
|
} catch {
|
|
5056
5079
|
return void 0;
|
|
5057
5080
|
}
|
|
@@ -5094,15 +5117,7 @@ function reconcileCompilerKeyedArrayBatchInsert(props, dirtyState, collectionTok
|
|
|
5094
5117
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
5095
5118
|
if (instances.has(key) || incomingKeys.has(key)) return void 0;
|
|
5096
5119
|
incomingKeys.add(key);
|
|
5097
|
-
|
|
5098
|
-
incoming.push({
|
|
5099
|
-
key,
|
|
5100
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5101
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
5102
|
-
item,
|
|
5103
|
-
index,
|
|
5104
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5105
|
-
});
|
|
5120
|
+
incoming.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
5106
5121
|
}
|
|
5107
5122
|
} catch {
|
|
5108
5123
|
return void 0;
|
|
@@ -5188,15 +5203,7 @@ function prepareCompilerKeyedArrayWindow(props, instances, previousInstances, ro
|
|
|
5188
5203
|
continue;
|
|
5189
5204
|
}
|
|
5190
5205
|
if (instances.has(key)) return void 0;
|
|
5191
|
-
|
|
5192
|
-
nextWindow.push({
|
|
5193
|
-
key,
|
|
5194
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5195
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
5196
|
-
item,
|
|
5197
|
-
index,
|
|
5198
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5199
|
-
});
|
|
5206
|
+
nextWindow.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
5200
5207
|
sequence.push(-1);
|
|
5201
5208
|
preparedBindings.push(void 0);
|
|
5202
5209
|
}
|
|
@@ -5326,20 +5333,12 @@ function reconcileCompilerKeyedArrayWindowReplace(props, dirtyState, collectionT
|
|
|
5326
5333
|
if (instances.has(key) || incomingKeys2.has(key)) return void 0;
|
|
5327
5334
|
incomingKeys2.add(key);
|
|
5328
5335
|
replacesRows = true;
|
|
5329
|
-
const descriptor = props.create(item, index);
|
|
5330
5336
|
prepared2.push([
|
|
5331
5337
|
index,
|
|
5332
5338
|
instance,
|
|
5333
5339
|
item,
|
|
5334
5340
|
void 0,
|
|
5335
|
-
|
|
5336
|
-
key,
|
|
5337
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5338
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
5339
|
-
item,
|
|
5340
|
-
index,
|
|
5341
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5342
|
-
}
|
|
5341
|
+
createKeyedRowInstance(props, root.ownerDocument, key, item, index)
|
|
5343
5342
|
]);
|
|
5344
5343
|
continue;
|
|
5345
5344
|
}
|
|
@@ -5677,15 +5676,7 @@ function reconcileCompilerKeyedArrayPrepend(props, dirtyState, collectionToken,
|
|
|
5677
5676
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
5678
5677
|
if (instances.has(key) || incomingKeys.has(key)) return void 0;
|
|
5679
5678
|
incomingKeys.add(key);
|
|
5680
|
-
|
|
5681
|
-
prepended.push({
|
|
5682
|
-
key,
|
|
5683
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5684
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
5685
|
-
item,
|
|
5686
|
-
index,
|
|
5687
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5688
|
-
});
|
|
5679
|
+
prepended.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
5689
5680
|
}
|
|
5690
5681
|
} catch {
|
|
5691
5682
|
return void 0;
|
|
@@ -5743,15 +5734,7 @@ function reconcileCompilerKeyedArrayStructuralPrepend(props, dirtyState, collect
|
|
|
5743
5734
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
5744
5735
|
if (knownKeys.has(key)) return void 0;
|
|
5745
5736
|
knownKeys.add(key);
|
|
5746
|
-
|
|
5747
|
-
prepended.push({
|
|
5748
|
-
key,
|
|
5749
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5750
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
5751
|
-
item,
|
|
5752
|
-
index,
|
|
5753
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5754
|
-
});
|
|
5737
|
+
prepended.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
5755
5738
|
}
|
|
5756
5739
|
} catch {
|
|
5757
5740
|
return void 0;
|
|
@@ -5862,15 +5845,7 @@ function reconcileCompilerKeyedArrayStructuralPrependMap(props, dirtyState, coll
|
|
|
5862
5845
|
const key = keyedRowIdentity(props.rowKey(item, index));
|
|
5863
5846
|
if (knownKeys.has(key)) return void 0;
|
|
5864
5847
|
knownKeys.add(key);
|
|
5865
|
-
|
|
5866
|
-
prepended.push({
|
|
5867
|
-
key,
|
|
5868
|
-
element: createCompilerHostElement(root.ownerDocument, descriptor),
|
|
5869
|
-
values: readKeyedRowBindingValues(props, item, index),
|
|
5870
|
-
item,
|
|
5871
|
-
index,
|
|
5872
|
-
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
5873
|
-
});
|
|
5848
|
+
prepended.push(createKeyedRowInstance(props, root.ownerDocument, key, item, index));
|
|
5874
5849
|
}
|
|
5875
5850
|
} catch {
|
|
5876
5851
|
return void 0;
|
|
@@ -5922,7 +5897,7 @@ function reconcileCompilerKeyedArrayFilter(props, dirtyState, collectionToken, i
|
|
|
5922
5897
|
return void 0;
|
|
5923
5898
|
}
|
|
5924
5899
|
const dependencies = props.dependencies || props.structureDependencies;
|
|
5925
|
-
const relevantDirty = (dependencies || []).filter((
|
|
5900
|
+
const relevantDirty = (dependencies || []).filter((index2) => dirtyState.has(index2));
|
|
5926
5901
|
if (relevantDirty.length !== 1 || relevantDirty[0] !== collectionDependency) {
|
|
5927
5902
|
return void 0;
|
|
5928
5903
|
}
|
|
@@ -5934,31 +5909,34 @@ function reconcileCompilerKeyedArrayFilter(props, dirtyState, collectionToken, i
|
|
|
5934
5909
|
);
|
|
5935
5910
|
if (!survivorResult || !Array.isArray(finalValue)) return void 0;
|
|
5936
5911
|
const { indices: survivorIndices, keysStable } = survivorResult;
|
|
5937
|
-
const
|
|
5938
|
-
|
|
5912
|
+
const removed = [];
|
|
5913
|
+
let cursor = 0;
|
|
5914
|
+
let sourceIndex = 0;
|
|
5939
5915
|
try {
|
|
5940
|
-
for (
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5916
|
+
for (const instance of instances.values()) {
|
|
5917
|
+
if (survivorIndices[cursor] !== sourceIndex) {
|
|
5918
|
+
removed.push(instance);
|
|
5919
|
+
} else {
|
|
5920
|
+
const item = finalValue[cursor];
|
|
5921
|
+
if (instance.index !== sourceIndex || !Object.is(instance.item, item) || !keysStable && keyedRowIdentity(props.rowKey(item, cursor)) !== instance.key) {
|
|
5922
|
+
return void 0;
|
|
5923
|
+
}
|
|
5924
|
+
cursor += 1;
|
|
5946
5925
|
}
|
|
5947
|
-
|
|
5926
|
+
sourceIndex += 1;
|
|
5948
5927
|
}
|
|
5949
5928
|
} catch {
|
|
5950
5929
|
return void 0;
|
|
5951
5930
|
}
|
|
5952
|
-
|
|
5953
|
-
for (
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
}
|
|
5958
|
-
for (let index = 0; index < survivors.length; index += 1) {
|
|
5959
|
-
survivors[index].index = index;
|
|
5931
|
+
if (cursor !== survivorIndices.length) return void 0;
|
|
5932
|
+
for (const instance of removed) {
|
|
5933
|
+
instance.scope?.cleanup();
|
|
5934
|
+
instance.element.remove();
|
|
5935
|
+
instances.delete(instance.key);
|
|
5960
5936
|
}
|
|
5961
|
-
|
|
5937
|
+
let index = 0;
|
|
5938
|
+
for (const instance of instances.values()) instance.index = index++;
|
|
5939
|
+
return instances;
|
|
5962
5940
|
}
|
|
5963
5941
|
function createKeyedRowConditionalRuntime() {
|
|
5964
5942
|
class FarmKeyedRowConditional extends React__default.default.Component {
|
|
@@ -6003,9 +5981,42 @@ function createKeyedRowConditionalRuntime() {
|
|
|
6003
5981
|
}
|
|
6004
5982
|
FarmKeyedRowConditional.displayName = "FarmCompiledKeyedRowConditional";
|
|
6005
5983
|
return {
|
|
6006
|
-
|
|
5984
|
+
element: (props) => React__default.default.createElement(FarmKeyedRowConditional, {
|
|
5985
|
+
key: `${props.rowKey}:${props.id}`,
|
|
5986
|
+
...props
|
|
5987
|
+
}),
|
|
6007
5988
|
readValues: readKeyedRowConditionalValues,
|
|
6008
|
-
changed: keyedRowConditionalChanged
|
|
5989
|
+
changed: keyedRowConditionalChanged,
|
|
5990
|
+
owner: (listeners) => ({
|
|
5991
|
+
subscribe(key, id, refresh) {
|
|
5992
|
+
let row = listeners.get(key);
|
|
5993
|
+
if (!row) {
|
|
5994
|
+
row = /* @__PURE__ */ new Map();
|
|
5995
|
+
listeners.set(key, row);
|
|
5996
|
+
}
|
|
5997
|
+
row.set(id, refresh);
|
|
5998
|
+
return () => {
|
|
5999
|
+
const current = listeners.get(key);
|
|
6000
|
+
if (current?.get(id) !== refresh) return;
|
|
6001
|
+
current.delete(id);
|
|
6002
|
+
if (current.size === 0) listeners.delete(key);
|
|
6003
|
+
};
|
|
6004
|
+
}
|
|
6005
|
+
}),
|
|
6006
|
+
notify(listeners, changes, afterCommit) {
|
|
6007
|
+
let pending = changes.length;
|
|
6008
|
+
const committed = () => {
|
|
6009
|
+
pending -= 1;
|
|
6010
|
+
if (pending === 0) afterCommit?.();
|
|
6011
|
+
};
|
|
6012
|
+
reactDom.flushSync(() => {
|
|
6013
|
+
for (const change of changes) {
|
|
6014
|
+
const refresh = listeners.get(change.key)?.get(change.id);
|
|
6015
|
+
if (refresh) refresh(change.item, change.index, committed);
|
|
6016
|
+
else committed();
|
|
6017
|
+
}
|
|
6018
|
+
});
|
|
6019
|
+
}
|
|
6009
6020
|
};
|
|
6010
6021
|
}
|
|
6011
6022
|
function createKeyedRowHostRuntime() {
|
|
@@ -6037,9 +6048,9 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6037
6048
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
6038
6049
|
this.conditionalListeners = /* @__PURE__ */ new Map();
|
|
6039
6050
|
this.instancesByElement = /* @__PURE__ */ new WeakMap();
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6051
|
+
// False after a rebuild without delegated events left surviving rows unindexed.
|
|
6052
|
+
this.elementIndexComplete = true;
|
|
6053
|
+
this.conditionalOwner = options.conditionals?.owner(this.conditionalListeners);
|
|
6043
6054
|
this.captureRoot = (root) => {
|
|
6044
6055
|
this.root = root;
|
|
6045
6056
|
};
|
|
@@ -6091,14 +6102,10 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6091
6102
|
}
|
|
6092
6103
|
};
|
|
6093
6104
|
this.rowConditional = (item, index, conditionalId, render) => {
|
|
6094
|
-
if (this.state.fallback) return render(item, index);
|
|
6095
|
-
|
|
6096
|
-
const Conditional = options.conditionals?.Component;
|
|
6097
|
-
if (!Conditional) return render(item, index);
|
|
6098
|
-
return React__default.default.createElement(Conditional, {
|
|
6099
|
-
key: `${key}:${conditionalId}`,
|
|
6105
|
+
if (this.state.fallback || !options.conditionals) return render(item, index);
|
|
6106
|
+
return options.conditionals.element({
|
|
6100
6107
|
owner: this.conditionalOwner,
|
|
6101
|
-
rowKey:
|
|
6108
|
+
rowKey: keyedRowIdentity(this.currentProps.rowKey(item, index)),
|
|
6102
6109
|
id: conditionalId,
|
|
6103
6110
|
renderVersion: this.renderVersion,
|
|
6104
6111
|
item,
|
|
@@ -6217,7 +6224,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6217
6224
|
);
|
|
6218
6225
|
if (filteredInstances) {
|
|
6219
6226
|
this.instances = filteredInstances;
|
|
6220
|
-
this.rebuildElementIndex(this.instances);
|
|
6227
|
+
if (!this.elementIndexComplete) this.rebuildElementIndex(this.instances);
|
|
6221
6228
|
this.pruneEventHandlers();
|
|
6222
6229
|
this.pruneConditionalListeners();
|
|
6223
6230
|
this.commitCurrentCollection(dirtyState);
|
|
@@ -6246,9 +6253,29 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6246
6253
|
}
|
|
6247
6254
|
readRows(props) {
|
|
6248
6255
|
const items = materializeIterable(props.items());
|
|
6249
|
-
const keys =
|
|
6250
|
-
|
|
6251
|
-
|
|
6256
|
+
const keys = [];
|
|
6257
|
+
const committedSize = this.instances.size;
|
|
6258
|
+
let prefix = 0;
|
|
6259
|
+
const committed = this.instances.keys();
|
|
6260
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
6261
|
+
const key = keyedRowIdentity(props.rowKey(items[index], index));
|
|
6262
|
+
keys.push(key);
|
|
6263
|
+
if (prefix === index && index < committedSize && committed.next().value === key) {
|
|
6264
|
+
prefix += 1;
|
|
6265
|
+
}
|
|
6266
|
+
}
|
|
6267
|
+
if (prefix === committedSize && keys.length === committedSize) return { items, keys };
|
|
6268
|
+
if (prefix === committedSize && committedSize > 0) {
|
|
6269
|
+
const tail = /* @__PURE__ */ new Set();
|
|
6270
|
+
for (let index = committedSize; index < keys.length; index += 1) {
|
|
6271
|
+
const key = keys[index];
|
|
6272
|
+
if (this.instances.has(key) || tail.has(key)) return null;
|
|
6273
|
+
tail.add(key);
|
|
6274
|
+
}
|
|
6275
|
+
return { items, keys, appended: true };
|
|
6276
|
+
}
|
|
6277
|
+
const keySet = new Set(keys);
|
|
6278
|
+
return keySet.size === keys.length ? { items, keys, keySet } : null;
|
|
6252
6279
|
}
|
|
6253
6280
|
usesDelegatedEvents(props = this.currentProps) {
|
|
6254
6281
|
return Boolean(
|
|
@@ -6257,7 +6284,8 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6257
6284
|
}
|
|
6258
6285
|
rebuildElementIndex(instances) {
|
|
6259
6286
|
this.instancesByElement = /* @__PURE__ */ new WeakMap();
|
|
6260
|
-
|
|
6287
|
+
this.elementIndexComplete = this.usesDelegatedEvents();
|
|
6288
|
+
if (!this.elementIndexComplete) return;
|
|
6261
6289
|
for (const instance of instances.values()) {
|
|
6262
6290
|
this.instancesByElement.set(instance.element, instance);
|
|
6263
6291
|
}
|
|
@@ -6299,20 +6327,6 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6299
6327
|
})
|
|
6300
6328
|
);
|
|
6301
6329
|
}
|
|
6302
|
-
subscribeToRowConditional(key, id, refresh) {
|
|
6303
|
-
let listeners = this.conditionalListeners.get(key);
|
|
6304
|
-
if (!listeners) {
|
|
6305
|
-
listeners = /* @__PURE__ */ new Map();
|
|
6306
|
-
this.conditionalListeners.set(key, listeners);
|
|
6307
|
-
}
|
|
6308
|
-
listeners.set(id, refresh);
|
|
6309
|
-
return () => {
|
|
6310
|
-
const current = this.conditionalListeners.get(key);
|
|
6311
|
-
if (current?.get(id) !== refresh) return;
|
|
6312
|
-
current.delete(id);
|
|
6313
|
-
if (current.size === 0) this.conditionalListeners.delete(key);
|
|
6314
|
-
};
|
|
6315
|
-
}
|
|
6316
6330
|
hasReactOwnedRows(props = this.currentProps) {
|
|
6317
6331
|
return Boolean(
|
|
6318
6332
|
props.conditionals?.length || props.events?.length && !this.usesDelegatedEvents(props)
|
|
@@ -6431,22 +6445,8 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6431
6445
|
});
|
|
6432
6446
|
}
|
|
6433
6447
|
notifyConditionalChanges(changes, afterCommit) {
|
|
6434
|
-
if (changes.length === 0)
|
|
6435
|
-
|
|
6436
|
-
return;
|
|
6437
|
-
}
|
|
6438
|
-
let pending = changes.length;
|
|
6439
|
-
const committed = () => {
|
|
6440
|
-
pending -= 1;
|
|
6441
|
-
if (pending === 0) afterCommit?.();
|
|
6442
|
-
};
|
|
6443
|
-
reactDom.flushSync(() => {
|
|
6444
|
-
for (const change of changes) {
|
|
6445
|
-
const refresh = this.conditionalListeners.get(change.key)?.get(change.id);
|
|
6446
|
-
if (refresh) refresh(change.item, change.index, committed);
|
|
6447
|
-
else committed();
|
|
6448
|
-
}
|
|
6449
|
-
});
|
|
6448
|
+
if (changes.length === 0) afterCommit?.();
|
|
6449
|
+
else options.conditionals.notify(this.conditionalListeners, changes, afterCommit);
|
|
6450
6450
|
}
|
|
6451
6451
|
refreshDirtyBindings(dirtyState, afterCommit) {
|
|
6452
6452
|
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)) {
|
|
@@ -6527,7 +6527,8 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6527
6527
|
index += 1;
|
|
6528
6528
|
}
|
|
6529
6529
|
const shouldPrepareBindings = rows.items.length > 1 && this.currentProps.bindings.length > 0 && !this.currentProps.hostBlocks;
|
|
6530
|
-
const
|
|
6530
|
+
const ordered = [...this.instances.values()];
|
|
6531
|
+
const preparedBindings = shouldPrepareBindings ? prepareKeyedRowBindingSetUpdates(this.currentProps, this.instances, rows, ordered) : void 0;
|
|
6531
6532
|
if (shouldPrepareBindings && !preparedBindings) {
|
|
6532
6533
|
this.activateFallback(afterCommit);
|
|
6533
6534
|
return true;
|
|
@@ -6535,8 +6536,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6535
6536
|
const conditionalChanges = [];
|
|
6536
6537
|
for (index = 0; index < rows.items.length; index += 1) {
|
|
6537
6538
|
const key = rows.keys[index];
|
|
6538
|
-
const existing =
|
|
6539
|
-
if (!existing) return false;
|
|
6539
|
+
const existing = ordered[index];
|
|
6540
6540
|
if (this.currentProps.hostBlocks) {
|
|
6541
6541
|
const descriptor = this.currentProps.create(rows.items[index], index);
|
|
6542
6542
|
if (!existing.scope?.update(descriptor)) {
|
|
@@ -6573,6 +6573,39 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6573
6573
|
this.notifyConditionalChanges(conditionalChanges, afterCommit);
|
|
6574
6574
|
return true;
|
|
6575
6575
|
}
|
|
6576
|
+
// Keys are the committed keys plus new ones: patch every existing row like
|
|
6577
|
+
// the complete path does, then create and append only the new rows.
|
|
6578
|
+
reconcileAppendedRows(rows, afterCommit, dirtyState) {
|
|
6579
|
+
const root = this.root;
|
|
6580
|
+
let index = 0;
|
|
6581
|
+
for (const existing of this.instances.values()) {
|
|
6582
|
+
applyKeyedRowBindings(this.currentProps, existing, rows.items[index], index);
|
|
6583
|
+
existing.item = rows.items[index];
|
|
6584
|
+
existing.index = index;
|
|
6585
|
+
index += 1;
|
|
6586
|
+
}
|
|
6587
|
+
const appended = [];
|
|
6588
|
+
for (; index < rows.items.length; index += 1) {
|
|
6589
|
+
appended.push(
|
|
6590
|
+
createKeyedRowInstance(
|
|
6591
|
+
this.currentProps,
|
|
6592
|
+
root.ownerDocument,
|
|
6593
|
+
rows.keys[index],
|
|
6594
|
+
rows.items[index],
|
|
6595
|
+
index
|
|
6596
|
+
)
|
|
6597
|
+
);
|
|
6598
|
+
}
|
|
6599
|
+
const indexElements = this.elementIndexComplete && this.usesDelegatedEvents();
|
|
6600
|
+
for (const instance of appended) {
|
|
6601
|
+
root.appendChild(instance.element);
|
|
6602
|
+
this.instances.set(instance.key, instance);
|
|
6603
|
+
if (indexElements) this.instancesByElement.set(instance.element, instance);
|
|
6604
|
+
}
|
|
6605
|
+
if (!indexElements) this.rebuildElementIndex(this.instances);
|
|
6606
|
+
this.commitCurrentCollection(dirtyState);
|
|
6607
|
+
afterCommit?.();
|
|
6608
|
+
}
|
|
6576
6609
|
reconcileRemovals(rows, afterCommit, dirtyState) {
|
|
6577
6610
|
if (this.hasReactOwnedRows() || rows.keys.length >= this.instances.size) return false;
|
|
6578
6611
|
const removed = [];
|
|
@@ -6675,6 +6708,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6675
6708
|
this.root.replaceChildren();
|
|
6676
6709
|
this.instances = /* @__PURE__ */ new Map();
|
|
6677
6710
|
this.instancesByElement = /* @__PURE__ */ new WeakMap();
|
|
6711
|
+
this.elementIndexComplete = true;
|
|
6678
6712
|
this.eventHandlers.clear();
|
|
6679
6713
|
this.conditionalListeners.clear();
|
|
6680
6714
|
this.commitCurrentCollection(dirtyState);
|
|
@@ -6683,7 +6717,11 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6683
6717
|
}
|
|
6684
6718
|
if (this.reconcileStableRows(rows, afterCommit, dirtyState)) return;
|
|
6685
6719
|
if (this.reconcileRemovals(rows, afterCommit, dirtyState)) return;
|
|
6686
|
-
|
|
6720
|
+
if (rows.appended && !this.currentProps.hostBlocks) {
|
|
6721
|
+
this.reconcileAppendedRows(rows, afterCommit, dirtyState);
|
|
6722
|
+
return;
|
|
6723
|
+
}
|
|
6724
|
+
const nextKeys = rows.keySet ?? new Set(rows.keys);
|
|
6687
6725
|
const hasSurvivingRows = rows.keys.some((key) => this.instances.has(key));
|
|
6688
6726
|
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;
|
|
6689
6727
|
if (preparedBindings === void 0) {
|
|
@@ -6692,7 +6730,8 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6692
6730
|
}
|
|
6693
6731
|
const oldIndices = /* @__PURE__ */ new Map();
|
|
6694
6732
|
if (hasSurvivingRows) {
|
|
6695
|
-
|
|
6733
|
+
let oldIndex = 0;
|
|
6734
|
+
for (const key of this.instances.keys()) oldIndices.set(key, oldIndex++);
|
|
6696
6735
|
}
|
|
6697
6736
|
for (const [key, instance] of this.instances) {
|
|
6698
6737
|
if (!nextKeys.has(key)) {
|
|
@@ -6700,7 +6739,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6700
6739
|
if (hasSurvivingRows) instance.element.remove();
|
|
6701
6740
|
}
|
|
6702
6741
|
}
|
|
6703
|
-
const sequence = hasSurvivingRows ? rows.keys.map((key) => oldIndices.get(key) ?? -1) :
|
|
6742
|
+
const sequence = hasSurvivingRows ? rows.keys.map((key) => oldIndices.get(key) ?? -1) : [];
|
|
6704
6743
|
const nextInstances = [];
|
|
6705
6744
|
const conditionalChanges = [];
|
|
6706
6745
|
for (let index = 0; index < rows.items.length; index += 1) {
|
|
@@ -6744,10 +6783,26 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6744
6783
|
nextInstances.push(existing);
|
|
6745
6784
|
continue;
|
|
6746
6785
|
}
|
|
6786
|
+
if (!this.currentProps.hostBlocks) {
|
|
6787
|
+
const instance = createKeyedRowInstance(
|
|
6788
|
+
this.currentProps,
|
|
6789
|
+
this.root.ownerDocument,
|
|
6790
|
+
key,
|
|
6791
|
+
rows.items[index],
|
|
6792
|
+
index
|
|
6793
|
+
);
|
|
6794
|
+
instance.conditionalValues = this.readConditionalValues(
|
|
6795
|
+
this.currentProps,
|
|
6796
|
+
rows.items[index],
|
|
6797
|
+
index
|
|
6798
|
+
);
|
|
6799
|
+
nextInstances.push(instance);
|
|
6800
|
+
continue;
|
|
6801
|
+
}
|
|
6747
6802
|
const descriptor = this.currentProps.create(rows.items[index], index);
|
|
6748
6803
|
const element = createCompilerHostElement(this.root.ownerDocument, descriptor);
|
|
6749
6804
|
const scope = this.mountRowHostScope(element, descriptor);
|
|
6750
|
-
if (
|
|
6805
|
+
if (!scope) {
|
|
6751
6806
|
for (const instance of nextInstances) {
|
|
6752
6807
|
if (!this.instances.has(instance.key)) instance.scope?.cleanup();
|
|
6753
6808
|
}
|
|
@@ -6769,14 +6824,21 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6769
6824
|
});
|
|
6770
6825
|
}
|
|
6771
6826
|
if (!hasSurvivingRows) {
|
|
6772
|
-
|
|
6773
|
-
for (const instance of nextInstances)
|
|
6774
|
-
this.root.replaceChildren(fragment);
|
|
6827
|
+
this.root.replaceChildren();
|
|
6828
|
+
for (const instance of nextInstances) this.root.appendChild(instance.element);
|
|
6775
6829
|
} else {
|
|
6776
6830
|
reorderCompilerKeyedRows(this.root, nextInstances, sequence, null);
|
|
6777
6831
|
}
|
|
6778
6832
|
this.instances = keyedRowInstancesByKey(nextInstances);
|
|
6779
|
-
this.
|
|
6833
|
+
if (hasSurvivingRows && this.elementIndexComplete && this.usesDelegatedEvents()) {
|
|
6834
|
+
for (let index = 0; index < nextInstances.length; index += 1) {
|
|
6835
|
+
if (sequence[index] < 0) {
|
|
6836
|
+
this.instancesByElement.set(nextInstances[index].element, nextInstances[index]);
|
|
6837
|
+
}
|
|
6838
|
+
}
|
|
6839
|
+
} else {
|
|
6840
|
+
this.rebuildElementIndex(this.instances);
|
|
6841
|
+
}
|
|
6780
6842
|
this.pruneEventHandlers();
|
|
6781
6843
|
this.pruneConditionalListeners();
|
|
6782
6844
|
this.commitCurrentCollection(dirtyState);
|
|
@@ -6849,6 +6911,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6849
6911
|
this.reactElements = [];
|
|
6850
6912
|
this.keyedTargets?.clear();
|
|
6851
6913
|
this.instancesByElement = /* @__PURE__ */ new WeakMap();
|
|
6914
|
+
this.elementIndexComplete = true;
|
|
6852
6915
|
this.eventHandlers.clear();
|
|
6853
6916
|
this.conditionalListeners.clear();
|
|
6854
6917
|
}
|
|
@@ -7000,25 +7063,16 @@ function createKeyedRangesBlockComponent(owner) {
|
|
|
7000
7063
|
nextInstances.push(existing);
|
|
7001
7064
|
continue;
|
|
7002
7065
|
}
|
|
7003
|
-
|
|
7004
|
-
this.root.ownerDocument,
|
|
7005
|
-
range.create(rows.items[index], index)
|
|
7066
|
+
nextInstances.push(
|
|
7067
|
+
createKeyedRowInstance(range, this.root.ownerDocument, key, rows.items[index], index)
|
|
7006
7068
|
);
|
|
7007
|
-
nextInstances.push({
|
|
7008
|
-
key,
|
|
7009
|
-
element,
|
|
7010
|
-
values: readKeyedRowBindingValues(range, rows.items[index], index),
|
|
7011
|
-
item: rows.items[index],
|
|
7012
|
-
index,
|
|
7013
|
-
conditionalValues: /* @__PURE__ */ new Map()
|
|
7014
|
-
});
|
|
7015
7069
|
}
|
|
7016
7070
|
let anchor = this.anchorAfter(rangeIndex);
|
|
7017
7071
|
for (let index = nextInstances.length - 1; index >= 0; index -= 1) {
|
|
7018
7072
|
const instance = nextInstances[index];
|
|
7019
7073
|
if (sequence[index] < 0) {
|
|
7020
7074
|
this.root.insertBefore(instance.element, anchor);
|
|
7021
|
-
} else if (!stablePositions
|
|
7075
|
+
} else if (!stablePositions[index] && instance.element.nextSibling !== anchor) {
|
|
7022
7076
|
this.root.insertBefore(instance.element, anchor);
|
|
7023
7077
|
}
|
|
7024
7078
|
anchor = instance.element;
|