@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
|
@@ -1975,10 +1975,7 @@ function normalizedStaticRangeBindingValue(binding, value) {
|
|
|
1975
1975
|
}
|
|
1976
1976
|
function applyStaticRangeBindings(bindings, segments, values) {
|
|
1977
1977
|
const activeBindings = bindings || [];
|
|
1978
|
-
|
|
1979
|
-
values.push(...activeBindings.map(() => UNSET_STATIC_RANGE_BINDING));
|
|
1980
|
-
}
|
|
1981
|
-
if (values.length !== activeBindings.length) return false;
|
|
1978
|
+
const targets = [];
|
|
1982
1979
|
for (let index = 0; index < activeBindings.length; index += 1) {
|
|
1983
1980
|
const binding = activeBindings[index];
|
|
1984
1981
|
if (!Number.isSafeInteger(binding.segment) || binding.segment < 0 || !Number.isSafeInteger(binding.sibling) || binding.sibling < 0) {
|
|
@@ -1986,19 +1983,31 @@ function applyStaticRangeBindings(bindings, segments, values) {
|
|
|
1986
1983
|
}
|
|
1987
1984
|
const sibling = segments[binding.segment]?.[binding.sibling];
|
|
1988
1985
|
const target = sibling && findCompilerHostTarget(sibling, binding.path);
|
|
1989
|
-
if (!target)
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1986
|
+
if (!target || binding.kind !== "text" && (binding.kind !== "style" && binding.kind !== "attribute" || !binding.name)) {
|
|
1987
|
+
return false;
|
|
1988
|
+
}
|
|
1989
|
+
targets[index] = target;
|
|
1990
|
+
}
|
|
1991
|
+
const initializesValues = values.length === 0 && activeBindings.length > 0;
|
|
1992
|
+
if (!initializesValues && values.length !== activeBindings.length) return false;
|
|
1993
|
+
const nextValues = [];
|
|
1994
|
+
for (let index = 0; index < activeBindings.length; index += 1) {
|
|
1995
|
+
const binding = activeBindings[index];
|
|
1996
|
+
nextValues[index] = normalizedStaticRangeBindingValue(binding, binding.read());
|
|
1997
|
+
}
|
|
1998
|
+
for (let index = 0; index < activeBindings.length; index += 1) {
|
|
1999
|
+
const binding = activeBindings[index];
|
|
2000
|
+
const value = nextValues[index];
|
|
2001
|
+
const previous = initializesValues ? UNSET_STATIC_RANGE_BINDING : values[index];
|
|
2002
|
+
if (Object.is(previous, value)) continue;
|
|
1993
2003
|
values[index] = value;
|
|
2004
|
+
const target = targets[index];
|
|
1994
2005
|
if (binding.kind === "text") {
|
|
1995
2006
|
target.textContent = value;
|
|
1996
|
-
} else if (binding.kind === "style"
|
|
1997
|
-
updateStyle(target, binding.name,
|
|
1998
|
-
} else if (binding.kind === "attribute" && binding.name) {
|
|
1999
|
-
updateAttribute(target, binding.name, rawValue);
|
|
2007
|
+
} else if (binding.kind === "style") {
|
|
2008
|
+
updateStyle(target, binding.name, value);
|
|
2000
2009
|
} else {
|
|
2001
|
-
|
|
2010
|
+
updateAttribute(target, binding.name, value);
|
|
2002
2011
|
}
|
|
2003
2012
|
}
|
|
2004
2013
|
return true;
|
|
@@ -2254,52 +2263,87 @@ function readKeyedRowBindingValues(props, item, index) {
|
|
|
2254
2263
|
);
|
|
2255
2264
|
}
|
|
2256
2265
|
function applyKeyedRowBindings(props, instance, item, index) {
|
|
2266
|
+
if (props.bindings.length < 2) {
|
|
2267
|
+
if (props.bindings.length === 1) applyKeyedRowBinding(props, instance, item, index, 0);
|
|
2268
|
+
return;
|
|
2269
|
+
}
|
|
2270
|
+
const nextValues = readKeyedRowBindingValues(props, item, index);
|
|
2271
|
+
let targets;
|
|
2257
2272
|
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
2258
|
-
|
|
2273
|
+
if (Object.is(instance.values[bindingIndex], nextValues[bindingIndex])) continue;
|
|
2274
|
+
targets || (targets = []);
|
|
2275
|
+
targets[bindingIndex] = findCompilerHostTarget(
|
|
2276
|
+
instance.element,
|
|
2277
|
+
props.bindings[bindingIndex].path
|
|
2278
|
+
);
|
|
2279
|
+
}
|
|
2280
|
+
if (!targets) return;
|
|
2281
|
+
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
2282
|
+
const value = nextValues[bindingIndex];
|
|
2283
|
+
if (Object.is(instance.values[bindingIndex], value)) continue;
|
|
2284
|
+
commitKeyedRowBinding(
|
|
2285
|
+
props.bindings[bindingIndex],
|
|
2286
|
+
instance,
|
|
2287
|
+
bindingIndex,
|
|
2288
|
+
value,
|
|
2289
|
+
targets[bindingIndex]
|
|
2290
|
+
);
|
|
2259
2291
|
}
|
|
2260
2292
|
}
|
|
2261
2293
|
function applyKeyedRowBinding(props, instance, item, index, bindingIndex) {
|
|
2262
2294
|
const binding = props.bindings[bindingIndex];
|
|
2263
|
-
const
|
|
2264
|
-
const value = normalizedKeyedRowBindingValue(binding, rawValue);
|
|
2295
|
+
const value = normalizedKeyedRowBindingValue(binding, binding.read(item, index));
|
|
2265
2296
|
if (Object.is(instance.values[bindingIndex], value)) return;
|
|
2266
|
-
instance.values[bindingIndex] = value;
|
|
2267
2297
|
const target = findCompilerHostTarget(instance.element, binding.path);
|
|
2298
|
+
commitKeyedRowBinding(binding, instance, bindingIndex, value, target);
|
|
2299
|
+
}
|
|
2300
|
+
function commitKeyedRowBinding(binding, instance, bindingIndex, value, target) {
|
|
2301
|
+
instance.values[bindingIndex] = value;
|
|
2268
2302
|
if (!target) return;
|
|
2269
2303
|
if (binding.kind === "text") {
|
|
2270
2304
|
target.textContent = value;
|
|
2271
2305
|
} else if (binding.kind === "style" && binding.name) {
|
|
2272
|
-
updateStyle(target, binding.name,
|
|
2306
|
+
updateStyle(target, binding.name, value);
|
|
2273
2307
|
} else if (binding.kind === "attribute" && binding.name) {
|
|
2274
|
-
updateAttribute(target, binding.name,
|
|
2308
|
+
updateAttribute(target, binding.name, value);
|
|
2275
2309
|
}
|
|
2276
2310
|
}
|
|
2311
|
+
function prepareKeyedRowBindingUpdate(props, instance, item, index, bindingIndex) {
|
|
2312
|
+
const binding = props.bindings[bindingIndex];
|
|
2313
|
+
const rawValue = binding.read(item, index);
|
|
2314
|
+
const value = normalizedKeyedRowBindingValue(binding, rawValue);
|
|
2315
|
+
if (Object.is(instance.values[bindingIndex], value)) return null;
|
|
2316
|
+
const target = findCompilerHostTarget(instance.element, binding.path);
|
|
2317
|
+
if (!target || binding.kind !== "text" && !binding.name) return void 0;
|
|
2318
|
+
return [bindingIndex, target, value];
|
|
2319
|
+
}
|
|
2277
2320
|
function prepareKeyedRowBindingUpdates(props, instance, item, index) {
|
|
2278
2321
|
const updates = [];
|
|
2279
2322
|
for (let bindingIndex = 0; bindingIndex < props.bindings.length; bindingIndex += 1) {
|
|
2280
|
-
const
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
if (Object.is(instance.values[bindingIndex], value)) continue;
|
|
2284
|
-
const target = findCompilerHostTarget(instance.element, binding.path);
|
|
2285
|
-
if (!target || binding.kind !== "text" && !binding.name) return void 0;
|
|
2286
|
-
updates.push([bindingIndex, rawValue, target, value]);
|
|
2323
|
+
const update = prepareKeyedRowBindingUpdate(props, instance, item, index, bindingIndex);
|
|
2324
|
+
if (update === void 0) return void 0;
|
|
2325
|
+
if (update) updates.push(update);
|
|
2287
2326
|
}
|
|
2288
2327
|
return updates;
|
|
2289
2328
|
}
|
|
2290
2329
|
function applyPreparedKeyedRowBindingUpdates(props, instance, updates) {
|
|
2291
|
-
for (const [bindingIndex,
|
|
2292
|
-
|
|
2293
|
-
instance.values[bindingIndex] = value;
|
|
2294
|
-
if (binding.kind === "text") {
|
|
2295
|
-
target.textContent = value;
|
|
2296
|
-
} else if (binding.kind === "style") {
|
|
2297
|
-
updateStyle(target, binding.name, rawValue);
|
|
2298
|
-
} else {
|
|
2299
|
-
updateAttribute(target, binding.name, rawValue);
|
|
2300
|
-
}
|
|
2330
|
+
for (const [bindingIndex, target, value] of updates) {
|
|
2331
|
+
commitKeyedRowBinding(props.bindings[bindingIndex], instance, bindingIndex, value, target);
|
|
2301
2332
|
}
|
|
2302
2333
|
}
|
|
2334
|
+
function prepareKeyedRowBindingSetUpdates(props, instances, rows) {
|
|
2335
|
+
const preparedInstances = [];
|
|
2336
|
+
const preparedUpdates = [];
|
|
2337
|
+
for (let index = 0; index < rows.items.length; index += 1) {
|
|
2338
|
+
const instance = instances.get(rows.keys[index]);
|
|
2339
|
+
if (!instance) return void 0;
|
|
2340
|
+
const updates = prepareKeyedRowBindingUpdates(props, instance, rows.items[index], index);
|
|
2341
|
+
if (!updates) return void 0;
|
|
2342
|
+
preparedInstances.push(instance);
|
|
2343
|
+
preparedUpdates.push(updates);
|
|
2344
|
+
}
|
|
2345
|
+
return [preparedInstances, preparedUpdates];
|
|
2346
|
+
}
|
|
2303
2347
|
function keyedRowConditionalSnapshot(conditional, item, index) {
|
|
2304
2348
|
const test = conditional.test(item, index);
|
|
2305
2349
|
if (conditional.logical && !test) {
|
|
@@ -2359,6 +2403,35 @@ function applyHostConditionalBindings(branch, instance) {
|
|
|
2359
2403
|
}
|
|
2360
2404
|
}
|
|
2361
2405
|
}
|
|
2406
|
+
function prepareHostConditionalBindings(branch, instance) {
|
|
2407
|
+
for (let bindingIndex = 0; bindingIndex < branch.bindings.length; bindingIndex += 1) {
|
|
2408
|
+
const binding = branch.bindings[bindingIndex];
|
|
2409
|
+
const rawValue = binding.read();
|
|
2410
|
+
const target = findCompilerHostTarget(instance.element, binding.path);
|
|
2411
|
+
if (!target || binding.kind !== "text" && (binding.kind !== "style" && binding.kind !== "attribute" || !binding.name)) {
|
|
2412
|
+
return false;
|
|
2413
|
+
}
|
|
2414
|
+
instance.values[bindingIndex] = [
|
|
2415
|
+
target,
|
|
2416
|
+
normalizedHostConditionalBindingValue(binding, rawValue)
|
|
2417
|
+
];
|
|
2418
|
+
}
|
|
2419
|
+
return true;
|
|
2420
|
+
}
|
|
2421
|
+
function applyPreparedHostConditionalBindings(branch, instance) {
|
|
2422
|
+
for (let bindingIndex = 0; bindingIndex < branch.bindings.length; bindingIndex += 1) {
|
|
2423
|
+
const binding = branch.bindings[bindingIndex];
|
|
2424
|
+
const [target, value] = instance.values[bindingIndex];
|
|
2425
|
+
instance.values[bindingIndex] = value;
|
|
2426
|
+
if (binding.kind === "text") {
|
|
2427
|
+
target.textContent = value;
|
|
2428
|
+
} else if (binding.kind === "style") {
|
|
2429
|
+
updateStyle(target, binding.name, value);
|
|
2430
|
+
} else {
|
|
2431
|
+
updateAttribute(target, binding.name, value);
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2362
2435
|
var UNSET_HOST_CONDITIONAL_BINDING = /* @__PURE__ */ Symbol("unset host conditional binding");
|
|
2363
2436
|
function mountCompilerHostTree(owner, element, descriptor, onFallback) {
|
|
2364
2437
|
if (!matchesCompilerHostElement(element, descriptor)) return null;
|
|
@@ -2446,7 +2519,7 @@ function mountCompilerHostTree(owner, element, descriptor, onFallback) {
|
|
|
2446
2519
|
}
|
|
2447
2520
|
};
|
|
2448
2521
|
}
|
|
2449
|
-
function mountCompilerHostInstance(owner, element, descriptor, branch, onFallback) {
|
|
2522
|
+
function mountCompilerHostInstance(owner, element, descriptor, branch, onFallback, applyBindingsImmediately = true) {
|
|
2450
2523
|
const scope = mountCompilerHostTree(owner, element, descriptor, onFallback);
|
|
2451
2524
|
if (!scope) return null;
|
|
2452
2525
|
const instance = {
|
|
@@ -2454,6 +2527,7 @@ function mountCompilerHostInstance(owner, element, descriptor, branch, onFallbac
|
|
|
2454
2527
|
scope,
|
|
2455
2528
|
values: branch.bindings.map(() => UNSET_HOST_CONDITIONAL_BINDING)
|
|
2456
2529
|
};
|
|
2530
|
+
if (!applyBindingsImmediately) return instance;
|
|
2457
2531
|
try {
|
|
2458
2532
|
applyHostConditionalBindings(branch, instance);
|
|
2459
2533
|
} catch (error) {
|
|
@@ -2560,13 +2634,19 @@ var CompilerNestedConditionalRanges = class {
|
|
|
2560
2634
|
element,
|
|
2561
2635
|
descriptor,
|
|
2562
2636
|
selection.branch,
|
|
2563
|
-
this.onFallback
|
|
2637
|
+
this.onFallback,
|
|
2638
|
+
false
|
|
2639
|
+
// Commit only after every sibling range validates.
|
|
2564
2640
|
);
|
|
2565
2641
|
if (!host) {
|
|
2566
2642
|
this.cleanup();
|
|
2567
2643
|
return false;
|
|
2568
2644
|
}
|
|
2569
2645
|
this.instances.push({ key: selection.key, host });
|
|
2646
|
+
if (!prepareHostConditionalBindings(selection.branch, host)) {
|
|
2647
|
+
this.cleanup();
|
|
2648
|
+
return false;
|
|
2649
|
+
}
|
|
2570
2650
|
cursor += 1;
|
|
2571
2651
|
}
|
|
2572
2652
|
const trailingEnd = cursor + this.block.trailing;
|
|
@@ -2579,6 +2659,13 @@ var CompilerNestedConditionalRanges = class {
|
|
|
2579
2659
|
this.cleanup();
|
|
2580
2660
|
return false;
|
|
2581
2661
|
}
|
|
2662
|
+
for (let index = 0; index < selections.length; index += 1) {
|
|
2663
|
+
const selection = selections[index];
|
|
2664
|
+
const instance = this.instances[index];
|
|
2665
|
+
if (selection.kind === "branch" && instance) {
|
|
2666
|
+
applyPreparedHostConditionalBindings(selection.branch, instance.host);
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2582
2669
|
this.unsubscribe = this.owner.subscribe(this.block.id, this.refresh);
|
|
2583
2670
|
return true;
|
|
2584
2671
|
}
|
|
@@ -2747,6 +2834,7 @@ var CompilerNestedKeyedRanges = class {
|
|
|
2747
2834
|
const elements = [...this.root.children];
|
|
2748
2835
|
const descriptors = flattenCompilerHostElements(materializeCompilerHostChildren(this.host));
|
|
2749
2836
|
if (elements.length !== descriptors.length) return false;
|
|
2837
|
+
const preparedBindings = [];
|
|
2750
2838
|
let cursor = 0;
|
|
2751
2839
|
for (let rangeIndex = 0; rangeIndex < this.block.ranges.length; rangeIndex += 1) {
|
|
2752
2840
|
const range = this.block.ranges[rangeIndex];
|
|
@@ -2763,6 +2851,8 @@ var CompilerNestedKeyedRanges = class {
|
|
|
2763
2851
|
this.staticSegments.push(elements.slice(cursor, staticEnd));
|
|
2764
2852
|
cursor = staticEnd;
|
|
2765
2853
|
const instances = /* @__PURE__ */ new Map();
|
|
2854
|
+
this.instances.push(instances);
|
|
2855
|
+
const rangeBindingUpdates = [];
|
|
2766
2856
|
for (let index = 0; index < rows.items.length; index += 1) {
|
|
2767
2857
|
const element = elements[cursor + index];
|
|
2768
2858
|
if (!element) {
|
|
@@ -2775,7 +2865,7 @@ var CompilerNestedKeyedRanges = class {
|
|
|
2775
2865
|
this.cleanup();
|
|
2776
2866
|
return false;
|
|
2777
2867
|
}
|
|
2778
|
-
|
|
2868
|
+
const instance = {
|
|
2779
2869
|
key: rows.keys[index],
|
|
2780
2870
|
element,
|
|
2781
2871
|
scope,
|
|
@@ -2783,10 +2873,23 @@ var CompilerNestedKeyedRanges = class {
|
|
|
2783
2873
|
item: rows.items[index],
|
|
2784
2874
|
index,
|
|
2785
2875
|
conditionalValues: /* @__PURE__ */ new Map()
|
|
2786
|
-
}
|
|
2787
|
-
|
|
2876
|
+
};
|
|
2877
|
+
let bindingUpdates;
|
|
2878
|
+
try {
|
|
2879
|
+
bindingUpdates = prepareKeyedRowBindingUpdates(range, instance, rows.items[index], index);
|
|
2880
|
+
} catch (error) {
|
|
2881
|
+
scope.cleanup();
|
|
2882
|
+
throw error;
|
|
2883
|
+
}
|
|
2884
|
+
if (!bindingUpdates) {
|
|
2885
|
+
scope.cleanup();
|
|
2886
|
+
this.cleanup();
|
|
2887
|
+
return false;
|
|
2888
|
+
}
|
|
2889
|
+
instances.set(rows.keys[index], instance);
|
|
2890
|
+
rangeBindingUpdates.push(bindingUpdates);
|
|
2788
2891
|
}
|
|
2789
|
-
|
|
2892
|
+
preparedBindings.push(rangeBindingUpdates);
|
|
2790
2893
|
cursor += rows.items.length;
|
|
2791
2894
|
}
|
|
2792
2895
|
const trailingEnd = cursor + this.block.trailing;
|
|
@@ -2799,6 +2902,18 @@ var CompilerNestedKeyedRanges = class {
|
|
|
2799
2902
|
this.cleanup();
|
|
2800
2903
|
return false;
|
|
2801
2904
|
}
|
|
2905
|
+
for (let rangeIndex = 0; rangeIndex < this.block.ranges.length; rangeIndex += 1) {
|
|
2906
|
+
const range = this.block.ranges[rangeIndex];
|
|
2907
|
+
let rowIndex = 0;
|
|
2908
|
+
for (const instance of this.instances[rangeIndex].values()) {
|
|
2909
|
+
applyPreparedKeyedRowBindingUpdates(
|
|
2910
|
+
range,
|
|
2911
|
+
instance,
|
|
2912
|
+
preparedBindings[rangeIndex][rowIndex]
|
|
2913
|
+
);
|
|
2914
|
+
rowIndex += 1;
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2802
2917
|
this.unsubscribe = this.owner.subscribe(this.block.id, this.refresh);
|
|
2803
2918
|
return true;
|
|
2804
2919
|
}
|
|
@@ -2992,6 +3107,7 @@ var CompilerNestedMixedRanges = class {
|
|
|
2992
3107
|
const elements = [...this.root.children];
|
|
2993
3108
|
const descriptors = flattenCompilerHostElements(this.host.children);
|
|
2994
3109
|
if (elements.length !== descriptors.length) return false;
|
|
3110
|
+
const preparedKeyedBindings = [];
|
|
2995
3111
|
let cursor = 0;
|
|
2996
3112
|
for (let rangeIndex = 0; rangeIndex < this.block.ranges.length; rangeIndex += 1) {
|
|
2997
3113
|
const range = this.block.ranges[rangeIndex];
|
|
@@ -3023,7 +3139,9 @@ var CompilerNestedMixedRanges = class {
|
|
|
3023
3139
|
element,
|
|
3024
3140
|
descriptor,
|
|
3025
3141
|
snapshot.selection.branch,
|
|
3026
|
-
this.onFallback
|
|
3142
|
+
this.onFallback,
|
|
3143
|
+
false
|
|
3144
|
+
// Commit only after every sibling range validates.
|
|
3027
3145
|
);
|
|
3028
3146
|
if (!host) {
|
|
3029
3147
|
this.cleanup();
|
|
@@ -3033,6 +3151,10 @@ var CompilerNestedMixedRanges = class {
|
|
|
3033
3151
|
kind: "conditional",
|
|
3034
3152
|
value: { key: snapshot.selection.key, host }
|
|
3035
3153
|
});
|
|
3154
|
+
if (!prepareHostConditionalBindings(snapshot.selection.branch, host)) {
|
|
3155
|
+
this.cleanup();
|
|
3156
|
+
return false;
|
|
3157
|
+
}
|
|
3036
3158
|
cursor += 1;
|
|
3037
3159
|
continue;
|
|
3038
3160
|
}
|
|
@@ -3041,6 +3163,8 @@ var CompilerNestedMixedRanges = class {
|
|
|
3041
3163
|
return false;
|
|
3042
3164
|
}
|
|
3043
3165
|
const keyedInstances = /* @__PURE__ */ new Map();
|
|
3166
|
+
this.instances.push({ kind: "keyed", value: keyedInstances });
|
|
3167
|
+
const keyedBindingUpdates = [];
|
|
3044
3168
|
for (let index = 0; index < snapshot.rows.items.length; index += 1) {
|
|
3045
3169
|
const element = elements[cursor + index];
|
|
3046
3170
|
if (!element) {
|
|
@@ -3062,15 +3186,27 @@ var CompilerNestedMixedRanges = class {
|
|
|
3062
3186
|
index,
|
|
3063
3187
|
conditionalValues: /* @__PURE__ */ new Map()
|
|
3064
3188
|
};
|
|
3189
|
+
let bindingUpdates;
|
|
3065
3190
|
try {
|
|
3066
|
-
|
|
3191
|
+
bindingUpdates = prepareKeyedRowBindingUpdates(
|
|
3192
|
+
range,
|
|
3193
|
+
instance,
|
|
3194
|
+
snapshot.rows.items[index],
|
|
3195
|
+
index
|
|
3196
|
+
);
|
|
3067
3197
|
} catch (error) {
|
|
3068
3198
|
scope.cleanup();
|
|
3069
3199
|
throw error;
|
|
3070
3200
|
}
|
|
3201
|
+
if (!bindingUpdates) {
|
|
3202
|
+
scope.cleanup();
|
|
3203
|
+
this.cleanup();
|
|
3204
|
+
return false;
|
|
3205
|
+
}
|
|
3071
3206
|
keyedInstances.set(snapshot.rows.keys[index], instance);
|
|
3207
|
+
keyedBindingUpdates.push(bindingUpdates);
|
|
3072
3208
|
}
|
|
3073
|
-
|
|
3209
|
+
preparedKeyedBindings[rangeIndex] = keyedBindingUpdates;
|
|
3074
3210
|
cursor += snapshot.rows.items.length;
|
|
3075
3211
|
}
|
|
3076
3212
|
const trailingEnd = cursor + this.block.trailing;
|
|
@@ -3083,6 +3219,22 @@ var CompilerNestedMixedRanges = class {
|
|
|
3083
3219
|
this.cleanup();
|
|
3084
3220
|
return false;
|
|
3085
3221
|
}
|
|
3222
|
+
for (let index = 0; index < snapshots.length; index += 1) {
|
|
3223
|
+
const snapshot = snapshots[index];
|
|
3224
|
+
const instance = this.instances[index];
|
|
3225
|
+
if (snapshot.kind === "conditional" && snapshot.selection.kind === "branch" && instance?.kind === "conditional" && instance.value) {
|
|
3226
|
+
applyPreparedHostConditionalBindings(snapshot.selection.branch, instance.value.host);
|
|
3227
|
+
} else if (snapshot.kind === "keyed" && instance?.kind === "keyed") {
|
|
3228
|
+
const range = this.block.ranges[index];
|
|
3229
|
+
const bindingUpdates = preparedKeyedBindings[index];
|
|
3230
|
+
if (range.kind !== "keyed") continue;
|
|
3231
|
+
let rowIndex = 0;
|
|
3232
|
+
for (const row of instance.value.values()) {
|
|
3233
|
+
applyPreparedKeyedRowBindingUpdates(range, row, bindingUpdates[rowIndex]);
|
|
3234
|
+
rowIndex += 1;
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
}
|
|
3086
3238
|
this.unsubscribe = this.owner.subscribe(this.block.id, this.refresh);
|
|
3087
3239
|
return true;
|
|
3088
3240
|
}
|
|
@@ -3613,7 +3765,9 @@ function createConditionalRangesBlockComponent(owner) {
|
|
|
3613
3765
|
element,
|
|
3614
3766
|
descriptor,
|
|
3615
3767
|
selection.branch,
|
|
3616
|
-
this.requestNestedFallback
|
|
3768
|
+
this.requestNestedFallback,
|
|
3769
|
+
false
|
|
3770
|
+
// Commit only after every sibling range validates.
|
|
3617
3771
|
);
|
|
3618
3772
|
if (!host) {
|
|
3619
3773
|
cleanupInstances();
|
|
@@ -3623,6 +3777,15 @@ function createConditionalRangesBlockComponent(owner) {
|
|
|
3623
3777
|
key: selection.key,
|
|
3624
3778
|
host
|
|
3625
3779
|
});
|
|
3780
|
+
try {
|
|
3781
|
+
if (!prepareHostConditionalBindings(selection.branch, host)) {
|
|
3782
|
+
cleanupInstances();
|
|
3783
|
+
return false;
|
|
3784
|
+
}
|
|
3785
|
+
} catch (error) {
|
|
3786
|
+
cleanupInstances();
|
|
3787
|
+
throw error;
|
|
3788
|
+
}
|
|
3626
3789
|
cursor += 1;
|
|
3627
3790
|
}
|
|
3628
3791
|
if (cursor + props.trailing !== elements.length) {
|
|
@@ -3630,9 +3793,21 @@ function createConditionalRangesBlockComponent(owner) {
|
|
|
3630
3793
|
return false;
|
|
3631
3794
|
}
|
|
3632
3795
|
staticSegments.push(elements.slice(cursor));
|
|
3633
|
-
|
|
3796
|
+
try {
|
|
3797
|
+
if (!applyStaticRangeBindings(props.bindings, staticSegments, staticValues)) {
|
|
3798
|
+
cleanupInstances();
|
|
3799
|
+
return false;
|
|
3800
|
+
}
|
|
3801
|
+
for (let index = 0; index < selections.length; index += 1) {
|
|
3802
|
+
const selection = selections[index];
|
|
3803
|
+
const instance = instances[index];
|
|
3804
|
+
if (selection.kind === "branch" && instance) {
|
|
3805
|
+
applyPreparedHostConditionalBindings(selection.branch, instance.host);
|
|
3806
|
+
}
|
|
3807
|
+
}
|
|
3808
|
+
} catch (error) {
|
|
3634
3809
|
cleanupInstances();
|
|
3635
|
-
|
|
3810
|
+
throw error;
|
|
3636
3811
|
}
|
|
3637
3812
|
for (const instance of this.rangeInstances) instance?.host.scope?.cleanup();
|
|
3638
3813
|
this.staticSegments = staticSegments;
|
|
@@ -6101,6 +6276,7 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6101
6276
|
nextMapLookupTargets.set(bindingIndex, snapshot);
|
|
6102
6277
|
}
|
|
6103
6278
|
}
|
|
6279
|
+
let preparedBindingUpdates;
|
|
6104
6280
|
for (const bindingIndex of affectedBindingIndices) {
|
|
6105
6281
|
const binding = this.currentProps.bindings[bindingIndex];
|
|
6106
6282
|
const identityTarget = binding.identityTarget;
|
|
@@ -6121,52 +6297,32 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6121
6297
|
const canTargetMapLookup = Boolean(
|
|
6122
6298
|
mapLookupTarget && binding.dependencies?.length === 1 && binding.dependencies[0] === mapLookupTarget.dependency && dirtyState.has(mapLookupTarget.dependency) && previousMapLookupTarget?.eligible && nextMapLookupTarget?.eligible
|
|
6123
6299
|
);
|
|
6300
|
+
let selectedKeys;
|
|
6301
|
+
let selectedCount;
|
|
6124
6302
|
if (canTargetMapLookup && previousMapLookupTarget && nextMapLookupTarget) {
|
|
6125
6303
|
const keys = keyedMapLookupChangedKeys(previousMapLookupTarget, nextMapLookupTarget);
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
if (instance) {
|
|
6129
|
-
applyKeyedRowBinding(
|
|
6130
|
-
this.currentProps,
|
|
6131
|
-
instance,
|
|
6132
|
-
instance.item,
|
|
6133
|
-
instance.index,
|
|
6134
|
-
bindingIndex
|
|
6135
|
-
);
|
|
6136
|
-
}
|
|
6137
|
-
}
|
|
6304
|
+
selectedKeys = keys;
|
|
6305
|
+
selectedCount = keys.size;
|
|
6138
6306
|
} else if (canTargetMembership && previousMembershipTarget && nextMembershipTarget) {
|
|
6139
6307
|
const keys = keyedMembershipChangedKeys(previousMembershipTarget, nextMembershipTarget);
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
if (instance) {
|
|
6143
|
-
applyKeyedRowBinding(
|
|
6144
|
-
this.currentProps,
|
|
6145
|
-
instance,
|
|
6146
|
-
instance.item,
|
|
6147
|
-
instance.index,
|
|
6148
|
-
bindingIndex
|
|
6149
|
-
);
|
|
6150
|
-
}
|
|
6151
|
-
}
|
|
6308
|
+
selectedKeys = keys;
|
|
6309
|
+
selectedCount = keys.size;
|
|
6152
6310
|
} else if (canTargetIdentity && previousIdentityTarget && nextIdentityTarget) {
|
|
6153
6311
|
const keys = /* @__PURE__ */ new Set();
|
|
6154
6312
|
if (previousIdentityTarget.key !== void 0) keys.add(previousIdentityTarget.key);
|
|
6155
6313
|
if (nextIdentityTarget.key !== void 0) keys.add(nextIdentityTarget.key);
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
if (instance) {
|
|
6159
|
-
applyKeyedRowBinding(
|
|
6160
|
-
this.currentProps,
|
|
6161
|
-
instance,
|
|
6162
|
-
instance.item,
|
|
6163
|
-
instance.index,
|
|
6164
|
-
bindingIndex
|
|
6165
|
-
);
|
|
6166
|
-
}
|
|
6167
|
-
}
|
|
6314
|
+
selectedKeys = keys;
|
|
6315
|
+
selectedCount = keys.size;
|
|
6168
6316
|
} else {
|
|
6169
|
-
|
|
6317
|
+
selectedKeys = this.instances.keys();
|
|
6318
|
+
selectedCount = this.instances.size;
|
|
6319
|
+
}
|
|
6320
|
+
const prepare = affectedBindingIndices.length > 1 || selectedCount > 1;
|
|
6321
|
+
if (prepare) preparedBindingUpdates || (preparedBindingUpdates = []);
|
|
6322
|
+
for (const key of selectedKeys) {
|
|
6323
|
+
const instance = this.instances.get(key);
|
|
6324
|
+
if (!instance) continue;
|
|
6325
|
+
if (!prepare) {
|
|
6170
6326
|
applyKeyedRowBinding(
|
|
6171
6327
|
this.currentProps,
|
|
6172
6328
|
instance,
|
|
@@ -6174,8 +6330,37 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6174
6330
|
instance.index,
|
|
6175
6331
|
bindingIndex
|
|
6176
6332
|
);
|
|
6333
|
+
continue;
|
|
6177
6334
|
}
|
|
6335
|
+
const update = prepareKeyedRowBindingUpdate(
|
|
6336
|
+
this.currentProps,
|
|
6337
|
+
instance,
|
|
6338
|
+
instance.item,
|
|
6339
|
+
instance.index,
|
|
6340
|
+
bindingIndex
|
|
6341
|
+
);
|
|
6342
|
+
if (update === void 0) {
|
|
6343
|
+
this.activateFallback(afterCommit);
|
|
6344
|
+
return true;
|
|
6345
|
+
}
|
|
6346
|
+
if (update) preparedBindingUpdates.push([instance, update]);
|
|
6347
|
+
}
|
|
6348
|
+
}
|
|
6349
|
+
if (preparedBindingUpdates) {
|
|
6350
|
+
for (const [instance, [bindingIndex, target, value]] of preparedBindingUpdates) {
|
|
6351
|
+
commitKeyedRowBinding(
|
|
6352
|
+
this.currentProps.bindings[bindingIndex],
|
|
6353
|
+
instance,
|
|
6354
|
+
bindingIndex,
|
|
6355
|
+
value,
|
|
6356
|
+
target
|
|
6357
|
+
);
|
|
6178
6358
|
}
|
|
6359
|
+
}
|
|
6360
|
+
for (const bindingIndex of affectedBindingIndices) {
|
|
6361
|
+
const nextIdentityTarget = nextIdentityTargets.get(bindingIndex);
|
|
6362
|
+
const nextMembershipTarget = nextMembershipTargets.get(bindingIndex);
|
|
6363
|
+
const nextMapLookupTarget = nextMapLookupTargets.get(bindingIndex);
|
|
6179
6364
|
if (nextIdentityTarget) this.identityTargets.set(bindingIndex, nextIdentityTarget);
|
|
6180
6365
|
else this.identityTargets.delete(bindingIndex);
|
|
6181
6366
|
if (nextMembershipTarget) {
|
|
@@ -6199,10 +6384,16 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6199
6384
|
if (rows.keys[index] !== key) return false;
|
|
6200
6385
|
index += 1;
|
|
6201
6386
|
}
|
|
6387
|
+
const shouldPrepareBindings = rows.items.length > 1 && this.currentProps.bindings.length > 0 && !this.currentProps.hostBlocks;
|
|
6388
|
+
const preparedBindings = shouldPrepareBindings ? prepareKeyedRowBindingSetUpdates(this.currentProps, this.instances, rows) : void 0;
|
|
6389
|
+
if (shouldPrepareBindings && !preparedBindings) {
|
|
6390
|
+
this.activateFallback(afterCommit);
|
|
6391
|
+
return true;
|
|
6392
|
+
}
|
|
6202
6393
|
const conditionalChanges = [];
|
|
6203
6394
|
for (index = 0; index < rows.items.length; index += 1) {
|
|
6204
6395
|
const key = rows.keys[index];
|
|
6205
|
-
const existing = this.instances.get(key);
|
|
6396
|
+
const existing = preparedBindings?.[0][index] || this.instances.get(key);
|
|
6206
6397
|
if (!existing) return false;
|
|
6207
6398
|
if (this.currentProps.hostBlocks) {
|
|
6208
6399
|
const descriptor = this.currentProps.create(rows.items[index], index);
|
|
@@ -6211,7 +6402,12 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6211
6402
|
return true;
|
|
6212
6403
|
}
|
|
6213
6404
|
}
|
|
6214
|
-
|
|
6405
|
+
const bindingUpdates = preparedBindings?.[1][index];
|
|
6406
|
+
if (bindingUpdates) {
|
|
6407
|
+
applyPreparedKeyedRowBindingUpdates(this.currentProps, existing, bindingUpdates);
|
|
6408
|
+
} else {
|
|
6409
|
+
applyKeyedRowBindings(this.currentProps, existing, rows.items[index], index);
|
|
6410
|
+
}
|
|
6215
6411
|
const conditionalValues = this.readConditionalValues(
|
|
6216
6412
|
this.currentProps,
|
|
6217
6413
|
rows.items[index],
|
|
@@ -6248,10 +6444,16 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6248
6444
|
const removedKey = previousKeys[removedIndex];
|
|
6249
6445
|
const removed = this.instances.get(removedKey);
|
|
6250
6446
|
if (!removed) return false;
|
|
6447
|
+
const shouldPrepareBindings = rows.items.length > 1 && this.currentProps.bindings.length > 0 && !this.currentProps.hostBlocks;
|
|
6448
|
+
const preparedBindings = shouldPrepareBindings ? prepareKeyedRowBindingSetUpdates(this.currentProps, this.instances, rows) : void 0;
|
|
6449
|
+
if (shouldPrepareBindings && !preparedBindings) {
|
|
6450
|
+
this.activateFallback(afterCommit);
|
|
6451
|
+
return true;
|
|
6452
|
+
}
|
|
6251
6453
|
const conditionalChanges = [];
|
|
6252
6454
|
for (let index = 0; index < rows.items.length; index += 1) {
|
|
6253
6455
|
const key = rows.keys[index];
|
|
6254
|
-
const existing = this.instances.get(key);
|
|
6456
|
+
const existing = preparedBindings?.[0][index] || this.instances.get(key);
|
|
6255
6457
|
if (!existing) return false;
|
|
6256
6458
|
if (this.currentProps.hostBlocks) {
|
|
6257
6459
|
const descriptor = this.currentProps.create(rows.items[index], index);
|
|
@@ -6260,7 +6462,12 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6260
6462
|
return true;
|
|
6261
6463
|
}
|
|
6262
6464
|
}
|
|
6263
|
-
|
|
6465
|
+
const bindingUpdates = preparedBindings?.[1][index];
|
|
6466
|
+
if (bindingUpdates) {
|
|
6467
|
+
applyPreparedKeyedRowBindingUpdates(this.currentProps, existing, bindingUpdates);
|
|
6468
|
+
} else {
|
|
6469
|
+
applyKeyedRowBindings(this.currentProps, existing, rows.items[index], index);
|
|
6470
|
+
}
|
|
6264
6471
|
const conditionalValues = this.readConditionalValues(
|
|
6265
6472
|
this.currentProps,
|
|
6266
6473
|
rows.items[index],
|