@farm.js/react 0.1.0-beta.13 → 0.1.0-beta.15
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/dist/compiler-runtime.cjs +296 -89
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.mjs +296 -89
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/index.cjs +11 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +11 -2
- package/dist/index.mjs.map +1 -1
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1969,10 +1969,7 @@ function normalizedStaticRangeBindingValue(binding, value) {
|
|
|
1969
1969
|
}
|
|
1970
1970
|
function applyStaticRangeBindings(bindings, segments, values) {
|
|
1971
1971
|
const activeBindings = bindings || [];
|
|
1972
|
-
|
|
1973
|
-
values.push(...activeBindings.map(() => UNSET_STATIC_RANGE_BINDING));
|
|
1974
|
-
}
|
|
1975
|
-
if (values.length !== activeBindings.length) return false;
|
|
1972
|
+
const targets = [];
|
|
1976
1973
|
for (let index = 0; index < activeBindings.length; index += 1) {
|
|
1977
1974
|
const binding = activeBindings[index];
|
|
1978
1975
|
if (!Number.isSafeInteger(binding.segment) || binding.segment < 0 || !Number.isSafeInteger(binding.sibling) || binding.sibling < 0) {
|
|
@@ -1980,19 +1977,31 @@ function applyStaticRangeBindings(bindings, segments, values) {
|
|
|
1980
1977
|
}
|
|
1981
1978
|
const sibling = segments[binding.segment]?.[binding.sibling];
|
|
1982
1979
|
const target = sibling && findCompilerHostTarget(sibling, binding.path);
|
|
1983
|
-
if (!target)
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1980
|
+
if (!target || binding.kind !== "text" && (binding.kind !== "style" && binding.kind !== "attribute" || !binding.name)) {
|
|
1981
|
+
return false;
|
|
1982
|
+
}
|
|
1983
|
+
targets[index] = target;
|
|
1984
|
+
}
|
|
1985
|
+
const initializesValues = values.length === 0 && activeBindings.length > 0;
|
|
1986
|
+
if (!initializesValues && values.length !== activeBindings.length) return false;
|
|
1987
|
+
const nextValues = [];
|
|
1988
|
+
for (let index = 0; index < activeBindings.length; index += 1) {
|
|
1989
|
+
const binding = activeBindings[index];
|
|
1990
|
+
nextValues[index] = normalizedStaticRangeBindingValue(binding, binding.read());
|
|
1991
|
+
}
|
|
1992
|
+
for (let index = 0; index < activeBindings.length; index += 1) {
|
|
1993
|
+
const binding = activeBindings[index];
|
|
1994
|
+
const value = nextValues[index];
|
|
1995
|
+
const previous = initializesValues ? UNSET_STATIC_RANGE_BINDING : values[index];
|
|
1996
|
+
if (Object.is(previous, value)) continue;
|
|
1987
1997
|
values[index] = value;
|
|
1998
|
+
const target = targets[index];
|
|
1988
1999
|
if (binding.kind === "text") {
|
|
1989
2000
|
target.textContent = value;
|
|
1990
|
-
} else if (binding.kind === "style"
|
|
1991
|
-
updateStyle(target, binding.name,
|
|
1992
|
-
} else if (binding.kind === "attribute" && binding.name) {
|
|
1993
|
-
updateAttribute(target, binding.name, rawValue);
|
|
2001
|
+
} else if (binding.kind === "style") {
|
|
2002
|
+
updateStyle(target, binding.name, value);
|
|
1994
2003
|
} else {
|
|
1995
|
-
|
|
2004
|
+
updateAttribute(target, binding.name, value);
|
|
1996
2005
|
}
|
|
1997
2006
|
}
|
|
1998
2007
|
return true;
|
|
@@ -2248,52 +2257,87 @@ function readKeyedRowBindingValues(props, item, index) {
|
|
|
2248
2257
|
);
|
|
2249
2258
|
}
|
|
2250
2259
|
function applyKeyedRowBindings(props, instance, item, index) {
|
|
2260
|
+
if (props.bindings.length < 2) {
|
|
2261
|
+
if (props.bindings.length === 1) applyKeyedRowBinding(props, instance, item, index, 0);
|
|
2262
|
+
return;
|
|
2263
|
+
}
|
|
2264
|
+
const nextValues = readKeyedRowBindingValues(props, item, index);
|
|
2265
|
+
let targets;
|
|
2251
2266
|
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
2252
|
-
|
|
2267
|
+
if (Object.is(instance.values[bindingIndex], nextValues[bindingIndex])) continue;
|
|
2268
|
+
targets || (targets = []);
|
|
2269
|
+
targets[bindingIndex] = findCompilerHostTarget(
|
|
2270
|
+
instance.element,
|
|
2271
|
+
props.bindings[bindingIndex].path
|
|
2272
|
+
);
|
|
2273
|
+
}
|
|
2274
|
+
if (!targets) return;
|
|
2275
|
+
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
2276
|
+
const value = nextValues[bindingIndex];
|
|
2277
|
+
if (Object.is(instance.values[bindingIndex], value)) continue;
|
|
2278
|
+
commitKeyedRowBinding(
|
|
2279
|
+
props.bindings[bindingIndex],
|
|
2280
|
+
instance,
|
|
2281
|
+
bindingIndex,
|
|
2282
|
+
value,
|
|
2283
|
+
targets[bindingIndex]
|
|
2284
|
+
);
|
|
2253
2285
|
}
|
|
2254
2286
|
}
|
|
2255
2287
|
function applyKeyedRowBinding(props, instance, item, index, bindingIndex) {
|
|
2256
2288
|
const binding = props.bindings[bindingIndex];
|
|
2257
|
-
const
|
|
2258
|
-
const value = normalizedKeyedRowBindingValue(binding, rawValue);
|
|
2289
|
+
const value = normalizedKeyedRowBindingValue(binding, binding.read(item, index));
|
|
2259
2290
|
if (Object.is(instance.values[bindingIndex], value)) return;
|
|
2260
|
-
instance.values[bindingIndex] = value;
|
|
2261
2291
|
const target = findCompilerHostTarget(instance.element, binding.path);
|
|
2292
|
+
commitKeyedRowBinding(binding, instance, bindingIndex, value, target);
|
|
2293
|
+
}
|
|
2294
|
+
function commitKeyedRowBinding(binding, instance, bindingIndex, value, target) {
|
|
2295
|
+
instance.values[bindingIndex] = value;
|
|
2262
2296
|
if (!target) return;
|
|
2263
2297
|
if (binding.kind === "text") {
|
|
2264
2298
|
target.textContent = value;
|
|
2265
2299
|
} else if (binding.kind === "style" && binding.name) {
|
|
2266
|
-
updateStyle(target, binding.name,
|
|
2300
|
+
updateStyle(target, binding.name, value);
|
|
2267
2301
|
} else if (binding.kind === "attribute" && binding.name) {
|
|
2268
|
-
updateAttribute(target, binding.name,
|
|
2302
|
+
updateAttribute(target, binding.name, value);
|
|
2269
2303
|
}
|
|
2270
2304
|
}
|
|
2305
|
+
function prepareKeyedRowBindingUpdate(props, instance, item, index, bindingIndex) {
|
|
2306
|
+
const binding = props.bindings[bindingIndex];
|
|
2307
|
+
const rawValue = binding.read(item, index);
|
|
2308
|
+
const value = normalizedKeyedRowBindingValue(binding, rawValue);
|
|
2309
|
+
if (Object.is(instance.values[bindingIndex], value)) return null;
|
|
2310
|
+
const target = findCompilerHostTarget(instance.element, binding.path);
|
|
2311
|
+
if (!target || binding.kind !== "text" && !binding.name) return void 0;
|
|
2312
|
+
return [bindingIndex, target, value];
|
|
2313
|
+
}
|
|
2271
2314
|
function prepareKeyedRowBindingUpdates(props, instance, item, index) {
|
|
2272
2315
|
const updates = [];
|
|
2273
2316
|
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
2274
|
-
const
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
if (Object.is(instance.values[bindingIndex], value)) continue;
|
|
2278
|
-
const target = findCompilerHostTarget(instance.element, binding.path);
|
|
2279
|
-
if (!target || binding.kind !== "text" && !binding.name) return void 0;
|
|
2280
|
-
updates.push([bindingIndex, rawValue, target, value]);
|
|
2317
|
+
const update = prepareKeyedRowBindingUpdate(props, instance, item, index, bindingIndex);
|
|
2318
|
+
if (update === void 0) return void 0;
|
|
2319
|
+
if (update) updates.push(update);
|
|
2281
2320
|
}
|
|
2282
2321
|
return updates;
|
|
2283
2322
|
}
|
|
2284
2323
|
function applyPreparedKeyedRowBindingUpdates(props, instance, updates) {
|
|
2285
|
-
for (const [bindingIndex,
|
|
2286
|
-
|
|
2287
|
-
instance.values[bindingIndex] = value;
|
|
2288
|
-
if (binding.kind === "text") {
|
|
2289
|
-
target.textContent = value;
|
|
2290
|
-
} else if (binding.kind === "style") {
|
|
2291
|
-
updateStyle(target, binding.name, rawValue);
|
|
2292
|
-
} else {
|
|
2293
|
-
updateAttribute(target, binding.name, rawValue);
|
|
2294
|
-
}
|
|
2324
|
+
for (const [bindingIndex, target, value] of updates) {
|
|
2325
|
+
commitKeyedRowBinding(props.bindings[bindingIndex], instance, bindingIndex, value, target);
|
|
2295
2326
|
}
|
|
2296
2327
|
}
|
|
2328
|
+
function prepareKeyedRowBindingSetUpdates(props, instances, rows) {
|
|
2329
|
+
const preparedInstances = [];
|
|
2330
|
+
const preparedUpdates = [];
|
|
2331
|
+
for (let index = 0; index < rows.items.length; index += 1) {
|
|
2332
|
+
const instance = instances.get(rows.keys[index]);
|
|
2333
|
+
if (!instance) return void 0;
|
|
2334
|
+
const updates = prepareKeyedRowBindingUpdates(props, instance, rows.items[index], index);
|
|
2335
|
+
if (!updates) return void 0;
|
|
2336
|
+
preparedInstances.push(instance);
|
|
2337
|
+
preparedUpdates.push(updates);
|
|
2338
|
+
}
|
|
2339
|
+
return [preparedInstances, preparedUpdates];
|
|
2340
|
+
}
|
|
2297
2341
|
function keyedRowConditionalSnapshot(conditional, item, index) {
|
|
2298
2342
|
const test = conditional.test(item, index);
|
|
2299
2343
|
if (conditional.logical && !test) {
|
|
@@ -2353,6 +2397,35 @@ function applyHostConditionalBindings(branch, instance) {
|
|
|
2353
2397
|
}
|
|
2354
2398
|
}
|
|
2355
2399
|
}
|
|
2400
|
+
function prepareHostConditionalBindings(branch, instance) {
|
|
2401
|
+
for (let bindingIndex = 0; bindingIndex < branch.bindings.length; bindingIndex += 1) {
|
|
2402
|
+
const binding = branch.bindings[bindingIndex];
|
|
2403
|
+
const rawValue = binding.read();
|
|
2404
|
+
const target = findCompilerHostTarget(instance.element, binding.path);
|
|
2405
|
+
if (!target || binding.kind !== "text" && (binding.kind !== "style" && binding.kind !== "attribute" || !binding.name)) {
|
|
2406
|
+
return false;
|
|
2407
|
+
}
|
|
2408
|
+
instance.values[bindingIndex] = [
|
|
2409
|
+
target,
|
|
2410
|
+
normalizedHostConditionalBindingValue(binding, rawValue)
|
|
2411
|
+
];
|
|
2412
|
+
}
|
|
2413
|
+
return true;
|
|
2414
|
+
}
|
|
2415
|
+
function applyPreparedHostConditionalBindings(branch, instance) {
|
|
2416
|
+
for (let bindingIndex = 0; bindingIndex < branch.bindings.length; bindingIndex += 1) {
|
|
2417
|
+
const binding = branch.bindings[bindingIndex];
|
|
2418
|
+
const [target, value] = instance.values[bindingIndex];
|
|
2419
|
+
instance.values[bindingIndex] = value;
|
|
2420
|
+
if (binding.kind === "text") {
|
|
2421
|
+
target.textContent = value;
|
|
2422
|
+
} else if (binding.kind === "style") {
|
|
2423
|
+
updateStyle(target, binding.name, value);
|
|
2424
|
+
} else {
|
|
2425
|
+
updateAttribute(target, binding.name, value);
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2356
2429
|
var UNSET_HOST_CONDITIONAL_BINDING = /* @__PURE__ */ Symbol("unset host conditional binding");
|
|
2357
2430
|
function mountCompilerHostTree(owner, element, descriptor, onFallback) {
|
|
2358
2431
|
if (!matchesCompilerHostElement(element, descriptor)) return null;
|
|
@@ -2440,7 +2513,7 @@ function mountCompilerHostTree(owner, element, descriptor, onFallback) {
|
|
|
2440
2513
|
}
|
|
2441
2514
|
};
|
|
2442
2515
|
}
|
|
2443
|
-
function mountCompilerHostInstance(owner, element, descriptor, branch, onFallback) {
|
|
2516
|
+
function mountCompilerHostInstance(owner, element, descriptor, branch, onFallback, applyBindingsImmediately = true) {
|
|
2444
2517
|
const scope = mountCompilerHostTree(owner, element, descriptor, onFallback);
|
|
2445
2518
|
if (!scope) return null;
|
|
2446
2519
|
const instance = {
|
|
@@ -2448,6 +2521,7 @@ function mountCompilerHostInstance(owner, element, descriptor, branch, onFallbac
|
|
|
2448
2521
|
scope,
|
|
2449
2522
|
values: branch.bindings.map(() => UNSET_HOST_CONDITIONAL_BINDING)
|
|
2450
2523
|
};
|
|
2524
|
+
if (!applyBindingsImmediately) return instance;
|
|
2451
2525
|
try {
|
|
2452
2526
|
applyHostConditionalBindings(branch, instance);
|
|
2453
2527
|
} catch (error) {
|
|
@@ -2554,13 +2628,19 @@ var CompilerNestedConditionalRanges = class {
|
|
|
2554
2628
|
element,
|
|
2555
2629
|
descriptor,
|
|
2556
2630
|
selection.branch,
|
|
2557
|
-
this.onFallback
|
|
2631
|
+
this.onFallback,
|
|
2632
|
+
false
|
|
2633
|
+
// Commit only after every sibling range validates.
|
|
2558
2634
|
);
|
|
2559
2635
|
if (!host) {
|
|
2560
2636
|
this.cleanup();
|
|
2561
2637
|
return false;
|
|
2562
2638
|
}
|
|
2563
2639
|
this.instances.push({ key: selection.key, host });
|
|
2640
|
+
if (!prepareHostConditionalBindings(selection.branch, host)) {
|
|
2641
|
+
this.cleanup();
|
|
2642
|
+
return false;
|
|
2643
|
+
}
|
|
2564
2644
|
cursor += 1;
|
|
2565
2645
|
}
|
|
2566
2646
|
const trailingEnd = cursor + this.block.trailing;
|
|
@@ -2573,6 +2653,13 @@ var CompilerNestedConditionalRanges = class {
|
|
|
2573
2653
|
this.cleanup();
|
|
2574
2654
|
return false;
|
|
2575
2655
|
}
|
|
2656
|
+
for (let index = 0; index < selections.length; index += 1) {
|
|
2657
|
+
const selection = selections[index];
|
|
2658
|
+
const instance = this.instances[index];
|
|
2659
|
+
if (selection.kind === "branch" && instance) {
|
|
2660
|
+
applyPreparedHostConditionalBindings(selection.branch, instance.host);
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2576
2663
|
this.unsubscribe = this.owner.subscribe(this.block.id, this.refresh);
|
|
2577
2664
|
return true;
|
|
2578
2665
|
}
|
|
@@ -2741,6 +2828,7 @@ var CompilerNestedKeyedRanges = class {
|
|
|
2741
2828
|
const elements = [...this.root.children];
|
|
2742
2829
|
const descriptors = flattenCompilerHostElements(materializeCompilerHostChildren(this.host));
|
|
2743
2830
|
if (elements.length !== descriptors.length) return false;
|
|
2831
|
+
const preparedBindings = [];
|
|
2744
2832
|
let cursor = 0;
|
|
2745
2833
|
for (let rangeIndex = 0; rangeIndex < this.block.ranges.length; rangeIndex += 1) {
|
|
2746
2834
|
const range = this.block.ranges[rangeIndex];
|
|
@@ -2757,6 +2845,8 @@ var CompilerNestedKeyedRanges = class {
|
|
|
2757
2845
|
this.staticSegments.push(elements.slice(cursor, staticEnd));
|
|
2758
2846
|
cursor = staticEnd;
|
|
2759
2847
|
const instances = /* @__PURE__ */ new Map();
|
|
2848
|
+
this.instances.push(instances);
|
|
2849
|
+
const rangeBindingUpdates = [];
|
|
2760
2850
|
for (let index = 0; index < rows.items.length; index += 1) {
|
|
2761
2851
|
const element = elements[cursor + index];
|
|
2762
2852
|
if (!element) {
|
|
@@ -2769,7 +2859,7 @@ var CompilerNestedKeyedRanges = class {
|
|
|
2769
2859
|
this.cleanup();
|
|
2770
2860
|
return false;
|
|
2771
2861
|
}
|
|
2772
|
-
|
|
2862
|
+
const instance = {
|
|
2773
2863
|
key: rows.keys[index],
|
|
2774
2864
|
element,
|
|
2775
2865
|
scope,
|
|
@@ -2777,10 +2867,23 @@ var CompilerNestedKeyedRanges = class {
|
|
|
2777
2867
|
item: rows.items[index],
|
|
2778
2868
|
index,
|
|
2779
2869
|
conditionalValues: /* @__PURE__ */ new Map()
|
|
2780
|
-
}
|
|
2781
|
-
|
|
2870
|
+
};
|
|
2871
|
+
let bindingUpdates;
|
|
2872
|
+
try {
|
|
2873
|
+
bindingUpdates = prepareKeyedRowBindingUpdates(range, instance, rows.items[index], index);
|
|
2874
|
+
} catch (error) {
|
|
2875
|
+
scope.cleanup();
|
|
2876
|
+
throw error;
|
|
2877
|
+
}
|
|
2878
|
+
if (!bindingUpdates) {
|
|
2879
|
+
scope.cleanup();
|
|
2880
|
+
this.cleanup();
|
|
2881
|
+
return false;
|
|
2882
|
+
}
|
|
2883
|
+
instances.set(rows.keys[index], instance);
|
|
2884
|
+
rangeBindingUpdates.push(bindingUpdates);
|
|
2782
2885
|
}
|
|
2783
|
-
|
|
2886
|
+
preparedBindings.push(rangeBindingUpdates);
|
|
2784
2887
|
cursor += rows.items.length;
|
|
2785
2888
|
}
|
|
2786
2889
|
const trailingEnd = cursor + this.block.trailing;
|
|
@@ -2793,6 +2896,18 @@ var CompilerNestedKeyedRanges = class {
|
|
|
2793
2896
|
this.cleanup();
|
|
2794
2897
|
return false;
|
|
2795
2898
|
}
|
|
2899
|
+
for (let rangeIndex = 0; rangeIndex < this.block.ranges.length; rangeIndex += 1) {
|
|
2900
|
+
const range = this.block.ranges[rangeIndex];
|
|
2901
|
+
let rowIndex = 0;
|
|
2902
|
+
for (const instance of this.instances[rangeIndex].values()) {
|
|
2903
|
+
applyPreparedKeyedRowBindingUpdates(
|
|
2904
|
+
range,
|
|
2905
|
+
instance,
|
|
2906
|
+
preparedBindings[rangeIndex][rowIndex]
|
|
2907
|
+
);
|
|
2908
|
+
rowIndex += 1;
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2796
2911
|
this.unsubscribe = this.owner.subscribe(this.block.id, this.refresh);
|
|
2797
2912
|
return true;
|
|
2798
2913
|
}
|
|
@@ -2986,6 +3101,7 @@ var CompilerNestedMixedRanges = class {
|
|
|
2986
3101
|
const elements = [...this.root.children];
|
|
2987
3102
|
const descriptors = flattenCompilerHostElements(this.host.children);
|
|
2988
3103
|
if (elements.length !== descriptors.length) return false;
|
|
3104
|
+
const preparedKeyedBindings = [];
|
|
2989
3105
|
let cursor = 0;
|
|
2990
3106
|
for (let rangeIndex = 0; rangeIndex < this.block.ranges.length; rangeIndex += 1) {
|
|
2991
3107
|
const range = this.block.ranges[rangeIndex];
|
|
@@ -3017,7 +3133,9 @@ var CompilerNestedMixedRanges = class {
|
|
|
3017
3133
|
element,
|
|
3018
3134
|
descriptor,
|
|
3019
3135
|
snapshot.selection.branch,
|
|
3020
|
-
this.onFallback
|
|
3136
|
+
this.onFallback,
|
|
3137
|
+
false
|
|
3138
|
+
// Commit only after every sibling range validates.
|
|
3021
3139
|
);
|
|
3022
3140
|
if (!host) {
|
|
3023
3141
|
this.cleanup();
|
|
@@ -3027,6 +3145,10 @@ var CompilerNestedMixedRanges = class {
|
|
|
3027
3145
|
kind: "conditional",
|
|
3028
3146
|
value: { key: snapshot.selection.key, host }
|
|
3029
3147
|
});
|
|
3148
|
+
if (!prepareHostConditionalBindings(snapshot.selection.branch, host)) {
|
|
3149
|
+
this.cleanup();
|
|
3150
|
+
return false;
|
|
3151
|
+
}
|
|
3030
3152
|
cursor += 1;
|
|
3031
3153
|
continue;
|
|
3032
3154
|
}
|
|
@@ -3035,6 +3157,8 @@ var CompilerNestedMixedRanges = class {
|
|
|
3035
3157
|
return false;
|
|
3036
3158
|
}
|
|
3037
3159
|
const keyedInstances = /* @__PURE__ */ new Map();
|
|
3160
|
+
this.instances.push({ kind: "keyed", value: keyedInstances });
|
|
3161
|
+
const keyedBindingUpdates = [];
|
|
3038
3162
|
for (let index = 0; index < snapshot.rows.items.length; index += 1) {
|
|
3039
3163
|
const element = elements[cursor + index];
|
|
3040
3164
|
if (!element) {
|
|
@@ -3056,15 +3180,27 @@ var CompilerNestedMixedRanges = class {
|
|
|
3056
3180
|
index,
|
|
3057
3181
|
conditionalValues: /* @__PURE__ */ new Map()
|
|
3058
3182
|
};
|
|
3183
|
+
let bindingUpdates;
|
|
3059
3184
|
try {
|
|
3060
|
-
|
|
3185
|
+
bindingUpdates = prepareKeyedRowBindingUpdates(
|
|
3186
|
+
range,
|
|
3187
|
+
instance,
|
|
3188
|
+
snapshot.rows.items[index],
|
|
3189
|
+
index
|
|
3190
|
+
);
|
|
3061
3191
|
} catch (error) {
|
|
3062
3192
|
scope.cleanup();
|
|
3063
3193
|
throw error;
|
|
3064
3194
|
}
|
|
3195
|
+
if (!bindingUpdates) {
|
|
3196
|
+
scope.cleanup();
|
|
3197
|
+
this.cleanup();
|
|
3198
|
+
return false;
|
|
3199
|
+
}
|
|
3065
3200
|
keyedInstances.set(snapshot.rows.keys[index], instance);
|
|
3201
|
+
keyedBindingUpdates.push(bindingUpdates);
|
|
3066
3202
|
}
|
|
3067
|
-
|
|
3203
|
+
preparedKeyedBindings[rangeIndex] = keyedBindingUpdates;
|
|
3068
3204
|
cursor += snapshot.rows.items.length;
|
|
3069
3205
|
}
|
|
3070
3206
|
const trailingEnd = cursor + this.block.trailing;
|
|
@@ -3077,6 +3213,22 @@ var CompilerNestedMixedRanges = class {
|
|
|
3077
3213
|
this.cleanup();
|
|
3078
3214
|
return false;
|
|
3079
3215
|
}
|
|
3216
|
+
for (let index = 0; index < snapshots.length; index += 1) {
|
|
3217
|
+
const snapshot = snapshots[index];
|
|
3218
|
+
const instance = this.instances[index];
|
|
3219
|
+
if (snapshot.kind === "conditional" && snapshot.selection.kind === "branch" && instance?.kind === "conditional" && instance.value) {
|
|
3220
|
+
applyPreparedHostConditionalBindings(snapshot.selection.branch, instance.value.host);
|
|
3221
|
+
} else if (snapshot.kind === "keyed" && instance?.kind === "keyed") {
|
|
3222
|
+
const range = this.block.ranges[index];
|
|
3223
|
+
const bindingUpdates = preparedKeyedBindings[index];
|
|
3224
|
+
if (range.kind !== "keyed") continue;
|
|
3225
|
+
let rowIndex = 0;
|
|
3226
|
+
for (const row of instance.value.values()) {
|
|
3227
|
+
applyPreparedKeyedRowBindingUpdates(range, row, bindingUpdates[rowIndex]);
|
|
3228
|
+
rowIndex += 1;
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3080
3232
|
this.unsubscribe = this.owner.subscribe(this.block.id, this.refresh);
|
|
3081
3233
|
return true;
|
|
3082
3234
|
}
|
|
@@ -3607,7 +3759,9 @@ function createConditionalRangesBlockComponent(owner) {
|
|
|
3607
3759
|
element,
|
|
3608
3760
|
descriptor,
|
|
3609
3761
|
selection.branch,
|
|
3610
|
-
this.requestNestedFallback
|
|
3762
|
+
this.requestNestedFallback,
|
|
3763
|
+
false
|
|
3764
|
+
// Commit only after every sibling range validates.
|
|
3611
3765
|
);
|
|
3612
3766
|
if (!host) {
|
|
3613
3767
|
cleanupInstances();
|
|
@@ -3617,6 +3771,15 @@ function createConditionalRangesBlockComponent(owner) {
|
|
|
3617
3771
|
key: selection.key,
|
|
3618
3772
|
host
|
|
3619
3773
|
});
|
|
3774
|
+
try {
|
|
3775
|
+
if (!prepareHostConditionalBindings(selection.branch, host)) {
|
|
3776
|
+
cleanupInstances();
|
|
3777
|
+
return false;
|
|
3778
|
+
}
|
|
3779
|
+
} catch (error) {
|
|
3780
|
+
cleanupInstances();
|
|
3781
|
+
throw error;
|
|
3782
|
+
}
|
|
3620
3783
|
cursor += 1;
|
|
3621
3784
|
}
|
|
3622
3785
|
if (cursor + props.trailing !== elements.length) {
|
|
@@ -3624,9 +3787,21 @@ function createConditionalRangesBlockComponent(owner) {
|
|
|
3624
3787
|
return false;
|
|
3625
3788
|
}
|
|
3626
3789
|
staticSegments.push(elements.slice(cursor));
|
|
3627
|
-
|
|
3790
|
+
try {
|
|
3791
|
+
if (!applyStaticRangeBindings(props.bindings, staticSegments, staticValues)) {
|
|
3792
|
+
cleanupInstances();
|
|
3793
|
+
return false;
|
|
3794
|
+
}
|
|
3795
|
+
for (let index = 0; index < selections.length; index += 1) {
|
|
3796
|
+
const selection = selections[index];
|
|
3797
|
+
const instance = instances[index];
|
|
3798
|
+
if (selection.kind === "branch" && instance) {
|
|
3799
|
+
applyPreparedHostConditionalBindings(selection.branch, instance.host);
|
|
3800
|
+
}
|
|
3801
|
+
}
|
|
3802
|
+
} catch (error) {
|
|
3628
3803
|
cleanupInstances();
|
|
3629
|
-
|
|
3804
|
+
throw error;
|
|
3630
3805
|
}
|
|
3631
3806
|
for (const instance of this.rangeInstances) instance?.host.scope?.cleanup();
|
|
3632
3807
|
this.staticSegments = staticSegments;
|
|
@@ -6095,6 +6270,7 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6095
6270
|
nextMapLookupTargets.set(bindingIndex, snapshot);
|
|
6096
6271
|
}
|
|
6097
6272
|
}
|
|
6273
|
+
let preparedBindingUpdates;
|
|
6098
6274
|
for (const bindingIndex of affectedBindingIndices) {
|
|
6099
6275
|
const binding = this.currentProps.bindings[bindingIndex];
|
|
6100
6276
|
const identityTarget = binding.identityTarget;
|
|
@@ -6115,52 +6291,32 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6115
6291
|
const canTargetMapLookup = Boolean(
|
|
6116
6292
|
mapLookupTarget && binding.dependencies?.length === 1 && binding.dependencies[0] === mapLookupTarget.dependency && dirtyState.has(mapLookupTarget.dependency) && previousMapLookupTarget?.eligible && nextMapLookupTarget?.eligible
|
|
6117
6293
|
);
|
|
6294
|
+
let selectedKeys;
|
|
6295
|
+
let selectedCount;
|
|
6118
6296
|
if (canTargetMapLookup && previousMapLookupTarget && nextMapLookupTarget) {
|
|
6119
6297
|
const keys = keyedMapLookupChangedKeys(previousMapLookupTarget, nextMapLookupTarget);
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
if (instance) {
|
|
6123
|
-
applyKeyedRowBinding(
|
|
6124
|
-
this.currentProps,
|
|
6125
|
-
instance,
|
|
6126
|
-
instance.item,
|
|
6127
|
-
instance.index,
|
|
6128
|
-
bindingIndex
|
|
6129
|
-
);
|
|
6130
|
-
}
|
|
6131
|
-
}
|
|
6298
|
+
selectedKeys = keys;
|
|
6299
|
+
selectedCount = keys.size;
|
|
6132
6300
|
} else if (canTargetMembership && previousMembershipTarget && nextMembershipTarget) {
|
|
6133
6301
|
const keys = keyedMembershipChangedKeys(previousMembershipTarget, nextMembershipTarget);
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
if (instance) {
|
|
6137
|
-
applyKeyedRowBinding(
|
|
6138
|
-
this.currentProps,
|
|
6139
|
-
instance,
|
|
6140
|
-
instance.item,
|
|
6141
|
-
instance.index,
|
|
6142
|
-
bindingIndex
|
|
6143
|
-
);
|
|
6144
|
-
}
|
|
6145
|
-
}
|
|
6302
|
+
selectedKeys = keys;
|
|
6303
|
+
selectedCount = keys.size;
|
|
6146
6304
|
} else if (canTargetIdentity && previousIdentityTarget && nextIdentityTarget) {
|
|
6147
6305
|
const keys = /* @__PURE__ */ new Set();
|
|
6148
6306
|
if (previousIdentityTarget.key !== void 0) keys.add(previousIdentityTarget.key);
|
|
6149
6307
|
if (nextIdentityTarget.key !== void 0) keys.add(nextIdentityTarget.key);
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
if (instance) {
|
|
6153
|
-
applyKeyedRowBinding(
|
|
6154
|
-
this.currentProps,
|
|
6155
|
-
instance,
|
|
6156
|
-
instance.item,
|
|
6157
|
-
instance.index,
|
|
6158
|
-
bindingIndex
|
|
6159
|
-
);
|
|
6160
|
-
}
|
|
6161
|
-
}
|
|
6308
|
+
selectedKeys = keys;
|
|
6309
|
+
selectedCount = keys.size;
|
|
6162
6310
|
} else {
|
|
6163
|
-
|
|
6311
|
+
selectedKeys = this.instances.keys();
|
|
6312
|
+
selectedCount = this.instances.size;
|
|
6313
|
+
}
|
|
6314
|
+
const prepare = affectedBindingIndices.length > 1 || selectedCount > 1;
|
|
6315
|
+
if (prepare) preparedBindingUpdates || (preparedBindingUpdates = []);
|
|
6316
|
+
for (const key of selectedKeys) {
|
|
6317
|
+
const instance = this.instances.get(key);
|
|
6318
|
+
if (!instance) continue;
|
|
6319
|
+
if (!prepare) {
|
|
6164
6320
|
applyKeyedRowBinding(
|
|
6165
6321
|
this.currentProps,
|
|
6166
6322
|
instance,
|
|
@@ -6168,8 +6324,37 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6168
6324
|
instance.index,
|
|
6169
6325
|
bindingIndex
|
|
6170
6326
|
);
|
|
6327
|
+
continue;
|
|
6171
6328
|
}
|
|
6329
|
+
const update = prepareKeyedRowBindingUpdate(
|
|
6330
|
+
this.currentProps,
|
|
6331
|
+
instance,
|
|
6332
|
+
instance.item,
|
|
6333
|
+
instance.index,
|
|
6334
|
+
bindingIndex
|
|
6335
|
+
);
|
|
6336
|
+
if (update === void 0) {
|
|
6337
|
+
this.activateFallback(afterCommit);
|
|
6338
|
+
return true;
|
|
6339
|
+
}
|
|
6340
|
+
if (update) preparedBindingUpdates.push([instance, update]);
|
|
6341
|
+
}
|
|
6342
|
+
}
|
|
6343
|
+
if (preparedBindingUpdates) {
|
|
6344
|
+
for (const [instance, [bindingIndex, target, value]] of preparedBindingUpdates) {
|
|
6345
|
+
commitKeyedRowBinding(
|
|
6346
|
+
this.currentProps.bindings[bindingIndex],
|
|
6347
|
+
instance,
|
|
6348
|
+
bindingIndex,
|
|
6349
|
+
value,
|
|
6350
|
+
target
|
|
6351
|
+
);
|
|
6172
6352
|
}
|
|
6353
|
+
}
|
|
6354
|
+
for (const bindingIndex of affectedBindingIndices) {
|
|
6355
|
+
const nextIdentityTarget = nextIdentityTargets.get(bindingIndex);
|
|
6356
|
+
const nextMembershipTarget = nextMembershipTargets.get(bindingIndex);
|
|
6357
|
+
const nextMapLookupTarget = nextMapLookupTargets.get(bindingIndex);
|
|
6173
6358
|
if (nextIdentityTarget) this.identityTargets.set(bindingIndex, nextIdentityTarget);
|
|
6174
6359
|
else this.identityTargets.delete(bindingIndex);
|
|
6175
6360
|
if (nextMembershipTarget) {
|
|
@@ -6193,10 +6378,16 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6193
6378
|
if (rows.keys[index] !== key) return false;
|
|
6194
6379
|
index += 1;
|
|
6195
6380
|
}
|
|
6381
|
+
const shouldPrepareBindings = rows.items.length > 1 && this.currentProps.bindings.length > 0 && !this.currentProps.hostBlocks;
|
|
6382
|
+
const preparedBindings = shouldPrepareBindings ? prepareKeyedRowBindingSetUpdates(this.currentProps, this.instances, rows) : void 0;
|
|
6383
|
+
if (shouldPrepareBindings && !preparedBindings) {
|
|
6384
|
+
this.activateFallback(afterCommit);
|
|
6385
|
+
return true;
|
|
6386
|
+
}
|
|
6196
6387
|
const conditionalChanges = [];
|
|
6197
6388
|
for (index = 0; index < rows.items.length; index += 1) {
|
|
6198
6389
|
const key = rows.keys[index];
|
|
6199
|
-
const existing = this.instances.get(key);
|
|
6390
|
+
const existing = preparedBindings?.[0][index] || this.instances.get(key);
|
|
6200
6391
|
if (!existing) return false;
|
|
6201
6392
|
if (this.currentProps.hostBlocks) {
|
|
6202
6393
|
const descriptor = this.currentProps.create(rows.items[index], index);
|
|
@@ -6205,7 +6396,12 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6205
6396
|
return true;
|
|
6206
6397
|
}
|
|
6207
6398
|
}
|
|
6208
|
-
|
|
6399
|
+
const bindingUpdates = preparedBindings?.[1][index];
|
|
6400
|
+
if (bindingUpdates) {
|
|
6401
|
+
applyPreparedKeyedRowBindingUpdates(this.currentProps, existing, bindingUpdates);
|
|
6402
|
+
} else {
|
|
6403
|
+
applyKeyedRowBindings(this.currentProps, existing, rows.items[index], index);
|
|
6404
|
+
}
|
|
6209
6405
|
const conditionalValues = this.readConditionalValues(
|
|
6210
6406
|
this.currentProps,
|
|
6211
6407
|
rows.items[index],
|
|
@@ -6242,10 +6438,16 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6242
6438
|
const removedKey = previousKeys[removedIndex];
|
|
6243
6439
|
const removed = this.instances.get(removedKey);
|
|
6244
6440
|
if (!removed) return false;
|
|
6441
|
+
const shouldPrepareBindings = rows.items.length > 1 && this.currentProps.bindings.length > 0 && !this.currentProps.hostBlocks;
|
|
6442
|
+
const preparedBindings = shouldPrepareBindings ? prepareKeyedRowBindingSetUpdates(this.currentProps, this.instances, rows) : void 0;
|
|
6443
|
+
if (shouldPrepareBindings && !preparedBindings) {
|
|
6444
|
+
this.activateFallback(afterCommit);
|
|
6445
|
+
return true;
|
|
6446
|
+
}
|
|
6245
6447
|
const conditionalChanges = [];
|
|
6246
6448
|
for (let index = 0; index < rows.items.length; index += 1) {
|
|
6247
6449
|
const key = rows.keys[index];
|
|
6248
|
-
const existing = this.instances.get(key);
|
|
6450
|
+
const existing = preparedBindings?.[0][index] || this.instances.get(key);
|
|
6249
6451
|
if (!existing) return false;
|
|
6250
6452
|
if (this.currentProps.hostBlocks) {
|
|
6251
6453
|
const descriptor = this.currentProps.create(rows.items[index], index);
|
|
@@ -6254,7 +6456,12 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6254
6456
|
return true;
|
|
6255
6457
|
}
|
|
6256
6458
|
}
|
|
6257
|
-
|
|
6459
|
+
const bindingUpdates = preparedBindings?.[1][index];
|
|
6460
|
+
if (bindingUpdates) {
|
|
6461
|
+
applyPreparedKeyedRowBindingUpdates(this.currentProps, existing, bindingUpdates);
|
|
6462
|
+
} else {
|
|
6463
|
+
applyKeyedRowBindings(this.currentProps, existing, rows.items[index], index);
|
|
6464
|
+
}
|
|
6258
6465
|
const conditionalValues = this.readConditionalValues(
|
|
6259
6466
|
this.currentProps,
|
|
6260
6467
|
rows.items[index],
|