@farm.js/react 0.1.0-beta.17 → 0.1.0-beta.19
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 +310 -156
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +5 -1
- package/dist/compiler-runtime.d.ts +5 -1
- package/dist/compiler-runtime.mjs +307 -157
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/vite.cjs +13 -1
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +13 -1
- package/dist/vite.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -2254,6 +2254,249 @@ function keyedMapLookupChangedKeys(previousSnapshot, nextSnapshot) {
|
|
|
2254
2254
|
}
|
|
2255
2255
|
return keys;
|
|
2256
2256
|
}
|
|
2257
|
+
function createSingleKindKeyedTargetRuntime(props, kind, snapshot, changedKeys) {
|
|
2258
|
+
if (!props.bindings.some(
|
|
2259
|
+
(binding) => binding.identityTarget || binding.membershipTarget || binding.mapLookupTarget
|
|
2260
|
+
))
|
|
2261
|
+
return void 0;
|
|
2262
|
+
const previous = /* @__PURE__ */ new Map();
|
|
2263
|
+
let next = /* @__PURE__ */ new Map();
|
|
2264
|
+
const compatible = (binding) => (kind === "identityTarget" || !binding.identityTarget) && (kind === "membershipTarget" || !binding.membershipTarget) && (kind === "mapLookupTarget" || !binding.mapLookupTarget);
|
|
2265
|
+
return {
|
|
2266
|
+
hasSafeTargets(props2, dirtyState) {
|
|
2267
|
+
for (const binding of props2.bindings) {
|
|
2268
|
+
if (!compatible(binding)) return false;
|
|
2269
|
+
const target = binding[kind];
|
|
2270
|
+
if (kind !== "identityTarget" && target && (!dirtyState || dirtyState.has(target.dependency)) && !snapshot(target.read()).eligible)
|
|
2271
|
+
return false;
|
|
2272
|
+
}
|
|
2273
|
+
return true;
|
|
2274
|
+
},
|
|
2275
|
+
commit(props2, dirtyState) {
|
|
2276
|
+
if (!dirtyState) previous.clear();
|
|
2277
|
+
for (let index = 0; index < props2.bindings.length; index++) {
|
|
2278
|
+
const target = props2.bindings[index][kind];
|
|
2279
|
+
if (!target) previous.delete(index);
|
|
2280
|
+
else if (!dirtyState || dirtyState.has(target.dependency))
|
|
2281
|
+
previous.set(index, snapshot(target.read()));
|
|
2282
|
+
}
|
|
2283
|
+
},
|
|
2284
|
+
prepare(props2, indices) {
|
|
2285
|
+
next = /* @__PURE__ */ new Map();
|
|
2286
|
+
for (const index of indices) {
|
|
2287
|
+
const binding = props2.bindings[index];
|
|
2288
|
+
if (!compatible(binding)) return false;
|
|
2289
|
+
const target = binding[kind];
|
|
2290
|
+
if (!target) continue;
|
|
2291
|
+
const value = snapshot(target.read(), previous.get(index));
|
|
2292
|
+
if (kind !== "identityTarget" && !value.eligible) return false;
|
|
2293
|
+
next.set(index, value);
|
|
2294
|
+
}
|
|
2295
|
+
return true;
|
|
2296
|
+
},
|
|
2297
|
+
select(props2, index, dirtyState, fallbackKeys, fallbackCount) {
|
|
2298
|
+
const binding = props2.bindings[index];
|
|
2299
|
+
const target = binding[kind];
|
|
2300
|
+
const before = previous.get(index);
|
|
2301
|
+
const after = next.get(index);
|
|
2302
|
+
if (target && binding.dependencies?.length === 1 && binding.dependencies[0] === target.dependency && dirtyState.has(target.dependency) && before?.eligible && after?.eligible) {
|
|
2303
|
+
const keys = changedKeys(before, after);
|
|
2304
|
+
return { keys, count: keys.size };
|
|
2305
|
+
}
|
|
2306
|
+
return { keys: fallbackKeys, count: fallbackCount };
|
|
2307
|
+
},
|
|
2308
|
+
commitPrepared(indices) {
|
|
2309
|
+
for (const index of indices) {
|
|
2310
|
+
const value = next.get(index);
|
|
2311
|
+
if (value) previous.set(index, value);
|
|
2312
|
+
else previous.delete(index);
|
|
2313
|
+
}
|
|
2314
|
+
},
|
|
2315
|
+
clear() {
|
|
2316
|
+
previous.clear();
|
|
2317
|
+
next.clear();
|
|
2318
|
+
}
|
|
2319
|
+
};
|
|
2320
|
+
}
|
|
2321
|
+
function createKeyedIdentityTargetRuntime(props) {
|
|
2322
|
+
return createSingleKindKeyedTargetRuntime(
|
|
2323
|
+
props,
|
|
2324
|
+
"identityTarget",
|
|
2325
|
+
keyedIdentityTargetSnapshot,
|
|
2326
|
+
(previous, next) => {
|
|
2327
|
+
const keys = /* @__PURE__ */ new Set();
|
|
2328
|
+
if (previous.key !== void 0) keys.add(previous.key);
|
|
2329
|
+
if (next.key !== void 0) keys.add(next.key);
|
|
2330
|
+
return keys;
|
|
2331
|
+
}
|
|
2332
|
+
);
|
|
2333
|
+
}
|
|
2334
|
+
function createKeyedMembershipTargetRuntime(props) {
|
|
2335
|
+
return createSingleKindKeyedTargetRuntime(
|
|
2336
|
+
props,
|
|
2337
|
+
"membershipTarget",
|
|
2338
|
+
keyedMembershipTargetSnapshot,
|
|
2339
|
+
keyedMembershipChangedKeys
|
|
2340
|
+
);
|
|
2341
|
+
}
|
|
2342
|
+
function createKeyedMapLookupTargetRuntime(props) {
|
|
2343
|
+
return createSingleKindKeyedTargetRuntime(
|
|
2344
|
+
props,
|
|
2345
|
+
"mapLookupTarget",
|
|
2346
|
+
keyedMapLookupTargetSnapshot,
|
|
2347
|
+
keyedMapLookupChangedKeys
|
|
2348
|
+
);
|
|
2349
|
+
}
|
|
2350
|
+
function createKeyedTargetRuntime(props) {
|
|
2351
|
+
if (!props.bindings.some(
|
|
2352
|
+
(binding) => binding.identityTarget || binding.membershipTarget || binding.mapLookupTarget
|
|
2353
|
+
)) {
|
|
2354
|
+
return void 0;
|
|
2355
|
+
}
|
|
2356
|
+
const identityTargets = /* @__PURE__ */ new Map();
|
|
2357
|
+
const membershipTargets = /* @__PURE__ */ new Map();
|
|
2358
|
+
const mapLookupTargets = /* @__PURE__ */ new Map();
|
|
2359
|
+
let nextIdentityTargets = /* @__PURE__ */ new Map();
|
|
2360
|
+
let nextMembershipTargets = /* @__PURE__ */ new Map();
|
|
2361
|
+
let nextMapLookupTargets = /* @__PURE__ */ new Map();
|
|
2362
|
+
return {
|
|
2363
|
+
hasSafeTargets(props2, dirtyState) {
|
|
2364
|
+
for (const binding of props2.bindings) {
|
|
2365
|
+
const membershipTarget = binding.membershipTarget;
|
|
2366
|
+
if (membershipTarget && (!dirtyState || dirtyState.has(membershipTarget.dependency)) && !keyedMembershipTargetSnapshot(membershipTarget.read()).eligible) {
|
|
2367
|
+
return false;
|
|
2368
|
+
}
|
|
2369
|
+
const mapLookupTarget = binding.mapLookupTarget;
|
|
2370
|
+
if (mapLookupTarget && (!dirtyState || dirtyState.has(mapLookupTarget.dependency)) && !keyedMapLookupTargetSnapshot(mapLookupTarget.read()).eligible) {
|
|
2371
|
+
return false;
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
return true;
|
|
2375
|
+
},
|
|
2376
|
+
commit(props2, dirtyState) {
|
|
2377
|
+
if (!dirtyState) {
|
|
2378
|
+
identityTargets.clear();
|
|
2379
|
+
membershipTargets.clear();
|
|
2380
|
+
mapLookupTargets.clear();
|
|
2381
|
+
}
|
|
2382
|
+
for (let bindingIndex = 0; bindingIndex < props2.bindings.length; bindingIndex += 1) {
|
|
2383
|
+
const binding = props2.bindings[bindingIndex];
|
|
2384
|
+
const identityTarget = binding.identityTarget;
|
|
2385
|
+
if (!identityTarget) {
|
|
2386
|
+
identityTargets.delete(bindingIndex);
|
|
2387
|
+
} else if (!dirtyState || dirtyState.has(identityTarget.dependency)) {
|
|
2388
|
+
identityTargets.set(bindingIndex, keyedIdentityTargetSnapshot(identityTarget.read()));
|
|
2389
|
+
}
|
|
2390
|
+
const membershipTarget = binding.membershipTarget;
|
|
2391
|
+
if (!membershipTarget) {
|
|
2392
|
+
membershipTargets.delete(bindingIndex);
|
|
2393
|
+
} else if (!dirtyState || dirtyState.has(membershipTarget.dependency)) {
|
|
2394
|
+
membershipTargets.set(
|
|
2395
|
+
bindingIndex,
|
|
2396
|
+
keyedMembershipTargetSnapshot(membershipTarget.read())
|
|
2397
|
+
);
|
|
2398
|
+
}
|
|
2399
|
+
const mapLookupTarget = binding.mapLookupTarget;
|
|
2400
|
+
if (!mapLookupTarget) {
|
|
2401
|
+
mapLookupTargets.delete(bindingIndex);
|
|
2402
|
+
} else if (!dirtyState || dirtyState.has(mapLookupTarget.dependency)) {
|
|
2403
|
+
mapLookupTargets.set(bindingIndex, keyedMapLookupTargetSnapshot(mapLookupTarget.read()));
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
},
|
|
2407
|
+
prepare(props2, bindingIndices) {
|
|
2408
|
+
nextIdentityTargets = /* @__PURE__ */ new Map();
|
|
2409
|
+
nextMembershipTargets = /* @__PURE__ */ new Map();
|
|
2410
|
+
nextMapLookupTargets = /* @__PURE__ */ new Map();
|
|
2411
|
+
for (const bindingIndex of bindingIndices) {
|
|
2412
|
+
const binding = props2.bindings[bindingIndex];
|
|
2413
|
+
if (binding.identityTarget) {
|
|
2414
|
+
nextIdentityTargets.set(
|
|
2415
|
+
bindingIndex,
|
|
2416
|
+
keyedIdentityTargetSnapshot(binding.identityTarget.read())
|
|
2417
|
+
);
|
|
2418
|
+
}
|
|
2419
|
+
if (binding.membershipTarget) {
|
|
2420
|
+
const snapshot = keyedMembershipTargetSnapshot(
|
|
2421
|
+
binding.membershipTarget.read(),
|
|
2422
|
+
membershipTargets.get(bindingIndex)
|
|
2423
|
+
);
|
|
2424
|
+
if (!snapshot.eligible) return false;
|
|
2425
|
+
nextMembershipTargets.set(bindingIndex, snapshot);
|
|
2426
|
+
}
|
|
2427
|
+
if (binding.mapLookupTarget) {
|
|
2428
|
+
const snapshot = keyedMapLookupTargetSnapshot(
|
|
2429
|
+
binding.mapLookupTarget.read(),
|
|
2430
|
+
mapLookupTargets.get(bindingIndex)
|
|
2431
|
+
);
|
|
2432
|
+
if (!snapshot.eligible) return false;
|
|
2433
|
+
nextMapLookupTargets.set(bindingIndex, snapshot);
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
return true;
|
|
2437
|
+
},
|
|
2438
|
+
select(props2, bindingIndex, dirtyState, fallbackKeys, fallbackCount) {
|
|
2439
|
+
const binding = props2.bindings[bindingIndex];
|
|
2440
|
+
const identityTarget = binding.identityTarget;
|
|
2441
|
+
const previousIdentityTarget = identityTargets.get(bindingIndex);
|
|
2442
|
+
const nextIdentityTarget = nextIdentityTargets.get(bindingIndex);
|
|
2443
|
+
const canTargetIdentity = Boolean(
|
|
2444
|
+
identityTarget && binding.dependencies?.length === 1 && binding.dependencies[0] === identityTarget.dependency && dirtyState.has(identityTarget.dependency) && previousIdentityTarget?.eligible && nextIdentityTarget?.eligible
|
|
2445
|
+
);
|
|
2446
|
+
const membershipTarget = binding.membershipTarget;
|
|
2447
|
+
const previousMembershipTarget = membershipTargets.get(bindingIndex);
|
|
2448
|
+
const nextMembershipTarget = nextMembershipTargets.get(bindingIndex);
|
|
2449
|
+
const canTargetMembership = Boolean(
|
|
2450
|
+
membershipTarget && binding.dependencies?.length === 1 && binding.dependencies[0] === membershipTarget.dependency && dirtyState.has(membershipTarget.dependency) && previousMembershipTarget?.eligible && nextMembershipTarget?.eligible
|
|
2451
|
+
);
|
|
2452
|
+
const mapLookupTarget = binding.mapLookupTarget;
|
|
2453
|
+
const previousMapLookupTarget = mapLookupTargets.get(bindingIndex);
|
|
2454
|
+
const nextMapLookupTarget = nextMapLookupTargets.get(bindingIndex);
|
|
2455
|
+
const canTargetMapLookup = Boolean(
|
|
2456
|
+
mapLookupTarget && binding.dependencies?.length === 1 && binding.dependencies[0] === mapLookupTarget.dependency && dirtyState.has(mapLookupTarget.dependency) && previousMapLookupTarget?.eligible && nextMapLookupTarget?.eligible
|
|
2457
|
+
);
|
|
2458
|
+
if (canTargetMapLookup && previousMapLookupTarget && nextMapLookupTarget) {
|
|
2459
|
+
const keys = keyedMapLookupChangedKeys(previousMapLookupTarget, nextMapLookupTarget);
|
|
2460
|
+
return { keys, count: keys.size };
|
|
2461
|
+
}
|
|
2462
|
+
if (canTargetMembership && previousMembershipTarget && nextMembershipTarget) {
|
|
2463
|
+
const keys = keyedMembershipChangedKeys(previousMembershipTarget, nextMembershipTarget);
|
|
2464
|
+
return { keys, count: keys.size };
|
|
2465
|
+
}
|
|
2466
|
+
if (canTargetIdentity && previousIdentityTarget && nextIdentityTarget) {
|
|
2467
|
+
const keys = /* @__PURE__ */ new Set();
|
|
2468
|
+
if (previousIdentityTarget.key !== void 0) keys.add(previousIdentityTarget.key);
|
|
2469
|
+
if (nextIdentityTarget.key !== void 0) keys.add(nextIdentityTarget.key);
|
|
2470
|
+
return { keys, count: keys.size };
|
|
2471
|
+
}
|
|
2472
|
+
return { keys: fallbackKeys, count: fallbackCount };
|
|
2473
|
+
},
|
|
2474
|
+
commitPrepared(bindingIndices) {
|
|
2475
|
+
for (const bindingIndex of bindingIndices) {
|
|
2476
|
+
const nextIdentityTarget = nextIdentityTargets.get(bindingIndex);
|
|
2477
|
+
const nextMembershipTarget = nextMembershipTargets.get(bindingIndex);
|
|
2478
|
+
const nextMapLookupTarget = nextMapLookupTargets.get(bindingIndex);
|
|
2479
|
+
if (nextIdentityTarget) identityTargets.set(bindingIndex, nextIdentityTarget);
|
|
2480
|
+
else identityTargets.delete(bindingIndex);
|
|
2481
|
+
if (nextMembershipTarget) {
|
|
2482
|
+
membershipTargets.set(bindingIndex, nextMembershipTarget);
|
|
2483
|
+
} else {
|
|
2484
|
+
membershipTargets.delete(bindingIndex);
|
|
2485
|
+
}
|
|
2486
|
+
if (nextMapLookupTarget) {
|
|
2487
|
+
mapLookupTargets.set(bindingIndex, nextMapLookupTarget);
|
|
2488
|
+
} else {
|
|
2489
|
+
mapLookupTargets.delete(bindingIndex);
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
},
|
|
2493
|
+
clear() {
|
|
2494
|
+
identityTargets.clear();
|
|
2495
|
+
membershipTargets.clear();
|
|
2496
|
+
mapLookupTargets.clear();
|
|
2497
|
+
}
|
|
2498
|
+
};
|
|
2499
|
+
}
|
|
2257
2500
|
function normalizedKeyedRowBindingValue(binding, value) {
|
|
2258
2501
|
return binding.kind === "text" ? renderTextValue(value) : value;
|
|
2259
2502
|
}
|
|
@@ -5745,7 +5988,7 @@ function createKeyedRowHostRuntime() {
|
|
|
5745
5988
|
mount: (element, descriptor, requestFallback) => mountCompilerHostTree(owner, element, descriptor, requestFallback)
|
|
5746
5989
|
};
|
|
5747
5990
|
}
|
|
5748
|
-
function
|
|
5991
|
+
function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
5749
5992
|
class FarmKeyedRowsBlock extends React__default.default.Component {
|
|
5750
5993
|
constructor() {
|
|
5751
5994
|
super(...arguments);
|
|
@@ -5759,9 +6002,7 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
5759
6002
|
this.currentProps = this.props;
|
|
5760
6003
|
this.definitionVersion = owner.getDefinitionVersion?.();
|
|
5761
6004
|
this.instances = /* @__PURE__ */ new Map();
|
|
5762
|
-
this.
|
|
5763
|
-
this.membershipTargets = /* @__PURE__ */ new Map();
|
|
5764
|
-
this.mapLookupTargets = /* @__PURE__ */ new Map();
|
|
6005
|
+
this.keyedTargets = options.keyedTargets?.(this.props);
|
|
5765
6006
|
this.renderVersion = 0;
|
|
5766
6007
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
5767
6008
|
this.conditionalListeners = /* @__PURE__ */ new Map();
|
|
@@ -6075,64 +6316,11 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6075
6316
|
this.currentProps.items(),
|
|
6076
6317
|
this.instances
|
|
6077
6318
|
);
|
|
6078
|
-
this.
|
|
6079
|
-
}
|
|
6080
|
-
hasSafeMembershipTargets(dirtyState) {
|
|
6081
|
-
for (const binding of this.currentProps.bindings) {
|
|
6082
|
-
const target = binding.membershipTarget;
|
|
6083
|
-
if (!target || dirtyState && !dirtyState.has(target.dependency)) continue;
|
|
6084
|
-
if (!keyedMembershipTargetSnapshot(target.read()).eligible) return false;
|
|
6085
|
-
}
|
|
6086
|
-
return true;
|
|
6087
|
-
}
|
|
6088
|
-
hasSafeMapLookupTargets(dirtyState) {
|
|
6089
|
-
for (const binding of this.currentProps.bindings) {
|
|
6090
|
-
const target = binding.mapLookupTarget;
|
|
6091
|
-
if (!target || dirtyState && !dirtyState.has(target.dependency)) continue;
|
|
6092
|
-
if (!keyedMapLookupTargetSnapshot(target.read()).eligible) return false;
|
|
6093
|
-
}
|
|
6094
|
-
return true;
|
|
6095
|
-
}
|
|
6096
|
-
commitKeyedTargets(dirtyState) {
|
|
6097
|
-
if (!dirtyState) {
|
|
6098
|
-
this.identityTargets.clear();
|
|
6099
|
-
this.membershipTargets.clear();
|
|
6100
|
-
this.mapLookupTargets.clear();
|
|
6101
|
-
}
|
|
6102
|
-
for (let bindingIndex = 0; bindingIndex < this.currentProps.bindings.length; bindingIndex += 1) {
|
|
6103
|
-
const binding = this.currentProps.bindings[bindingIndex];
|
|
6104
|
-
const identityTarget = binding.identityTarget;
|
|
6105
|
-
if (!identityTarget) {
|
|
6106
|
-
this.identityTargets.delete(bindingIndex);
|
|
6107
|
-
} else if (!dirtyState || dirtyState.has(identityTarget.dependency)) {
|
|
6108
|
-
this.identityTargets.set(
|
|
6109
|
-
bindingIndex,
|
|
6110
|
-
keyedIdentityTargetSnapshot(identityTarget.read())
|
|
6111
|
-
);
|
|
6112
|
-
}
|
|
6113
|
-
const membershipTarget = binding.membershipTarget;
|
|
6114
|
-
if (!membershipTarget) {
|
|
6115
|
-
this.membershipTargets.delete(bindingIndex);
|
|
6116
|
-
} else if (!dirtyState || dirtyState.has(membershipTarget.dependency)) {
|
|
6117
|
-
this.membershipTargets.set(
|
|
6118
|
-
bindingIndex,
|
|
6119
|
-
keyedMembershipTargetSnapshot(membershipTarget.read())
|
|
6120
|
-
);
|
|
6121
|
-
}
|
|
6122
|
-
const mapLookupTarget = binding.mapLookupTarget;
|
|
6123
|
-
if (!mapLookupTarget) {
|
|
6124
|
-
this.mapLookupTargets.delete(bindingIndex);
|
|
6125
|
-
} else if (!dirtyState || dirtyState.has(mapLookupTarget.dependency)) {
|
|
6126
|
-
this.mapLookupTargets.set(
|
|
6127
|
-
bindingIndex,
|
|
6128
|
-
keyedMapLookupTargetSnapshot(mapLookupTarget.read())
|
|
6129
|
-
);
|
|
6130
|
-
}
|
|
6131
|
-
}
|
|
6319
|
+
this.keyedTargets?.commit(this.currentProps, dirtyState);
|
|
6132
6320
|
}
|
|
6133
6321
|
adopt() {
|
|
6134
6322
|
if (!this.root) return false;
|
|
6135
|
-
if (
|
|
6323
|
+
if (this.keyedTargets && !this.keyedTargets.hasSafeTargets(this.currentProps)) return false;
|
|
6136
6324
|
const rows = this.readRows(this.currentProps);
|
|
6137
6325
|
const elements = [...this.root.children];
|
|
6138
6326
|
if (!rows || rows.items.length !== elements.length) return false;
|
|
@@ -6240,81 +6428,22 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6240
6428
|
affectedBindingIndices.push(bindingIndex);
|
|
6241
6429
|
}
|
|
6242
6430
|
}
|
|
6243
|
-
const
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
const binding = this.currentProps.bindings[bindingIndex];
|
|
6248
|
-
if (binding.identityTarget) {
|
|
6249
|
-
nextIdentityTargets.set(
|
|
6250
|
-
bindingIndex,
|
|
6251
|
-
keyedIdentityTargetSnapshot(binding.identityTarget.read())
|
|
6252
|
-
);
|
|
6253
|
-
}
|
|
6254
|
-
if (binding.membershipTarget) {
|
|
6255
|
-
const snapshot = keyedMembershipTargetSnapshot(
|
|
6256
|
-
binding.membershipTarget.read(),
|
|
6257
|
-
this.membershipTargets.get(bindingIndex)
|
|
6258
|
-
);
|
|
6259
|
-
if (!snapshot.eligible) {
|
|
6260
|
-
this.activateFallback(afterCommit);
|
|
6261
|
-
return true;
|
|
6262
|
-
}
|
|
6263
|
-
nextMembershipTargets.set(bindingIndex, snapshot);
|
|
6264
|
-
}
|
|
6265
|
-
if (binding.mapLookupTarget) {
|
|
6266
|
-
const snapshot = keyedMapLookupTargetSnapshot(
|
|
6267
|
-
binding.mapLookupTarget.read(),
|
|
6268
|
-
this.mapLookupTargets.get(bindingIndex)
|
|
6269
|
-
);
|
|
6270
|
-
if (!snapshot.eligible) {
|
|
6271
|
-
this.activateFallback(afterCommit);
|
|
6272
|
-
return true;
|
|
6273
|
-
}
|
|
6274
|
-
nextMapLookupTargets.set(bindingIndex, snapshot);
|
|
6275
|
-
}
|
|
6431
|
+
const targetsPrepared = this.keyedTargets?.prepare(this.currentProps, affectedBindingIndices);
|
|
6432
|
+
if (targetsPrepared === false) {
|
|
6433
|
+
this.activateFallback(afterCommit);
|
|
6434
|
+
return true;
|
|
6276
6435
|
}
|
|
6277
6436
|
let preparedBindingUpdates;
|
|
6278
6437
|
for (const bindingIndex of affectedBindingIndices) {
|
|
6279
|
-
const
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
);
|
|
6286
|
-
const membershipTarget = binding.membershipTarget;
|
|
6287
|
-
const previousMembershipTarget = this.membershipTargets.get(bindingIndex);
|
|
6288
|
-
const nextMembershipTarget = nextMembershipTargets.get(bindingIndex);
|
|
6289
|
-
const canTargetMembership = Boolean(
|
|
6290
|
-
membershipTarget && binding.dependencies?.length === 1 && binding.dependencies[0] === membershipTarget.dependency && dirtyState.has(membershipTarget.dependency) && previousMembershipTarget?.eligible && nextMembershipTarget?.eligible
|
|
6291
|
-
);
|
|
6292
|
-
const mapLookupTarget = binding.mapLookupTarget;
|
|
6293
|
-
const previousMapLookupTarget = this.mapLookupTargets.get(bindingIndex);
|
|
6294
|
-
const nextMapLookupTarget = nextMapLookupTargets.get(bindingIndex);
|
|
6295
|
-
const canTargetMapLookup = Boolean(
|
|
6296
|
-
mapLookupTarget && binding.dependencies?.length === 1 && binding.dependencies[0] === mapLookupTarget.dependency && dirtyState.has(mapLookupTarget.dependency) && previousMapLookupTarget?.eligible && nextMapLookupTarget?.eligible
|
|
6438
|
+
const selection = this.keyedTargets?.select(
|
|
6439
|
+
this.currentProps,
|
|
6440
|
+
bindingIndex,
|
|
6441
|
+
dirtyState,
|
|
6442
|
+
this.instances.keys(),
|
|
6443
|
+
this.instances.size
|
|
6297
6444
|
);
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
if (canTargetMapLookup && previousMapLookupTarget && nextMapLookupTarget) {
|
|
6301
|
-
const keys = keyedMapLookupChangedKeys(previousMapLookupTarget, nextMapLookupTarget);
|
|
6302
|
-
selectedKeys = keys;
|
|
6303
|
-
selectedCount = keys.size;
|
|
6304
|
-
} else if (canTargetMembership && previousMembershipTarget && nextMembershipTarget) {
|
|
6305
|
-
const keys = keyedMembershipChangedKeys(previousMembershipTarget, nextMembershipTarget);
|
|
6306
|
-
selectedKeys = keys;
|
|
6307
|
-
selectedCount = keys.size;
|
|
6308
|
-
} else if (canTargetIdentity && previousIdentityTarget && nextIdentityTarget) {
|
|
6309
|
-
const keys = /* @__PURE__ */ new Set();
|
|
6310
|
-
if (previousIdentityTarget.key !== void 0) keys.add(previousIdentityTarget.key);
|
|
6311
|
-
if (nextIdentityTarget.key !== void 0) keys.add(nextIdentityTarget.key);
|
|
6312
|
-
selectedKeys = keys;
|
|
6313
|
-
selectedCount = keys.size;
|
|
6314
|
-
} else {
|
|
6315
|
-
selectedKeys = this.instances.keys();
|
|
6316
|
-
selectedCount = this.instances.size;
|
|
6317
|
-
}
|
|
6445
|
+
const selectedKeys = selection?.keys || this.instances.keys();
|
|
6446
|
+
const selectedCount = selection?.count ?? this.instances.size;
|
|
6318
6447
|
const prepare = affectedBindingIndices.length > 1 || selectedCount > 1;
|
|
6319
6448
|
if (prepare) preparedBindingUpdates || (preparedBindingUpdates = []);
|
|
6320
6449
|
for (const key of selectedKeys) {
|
|
@@ -6355,23 +6484,7 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6355
6484
|
);
|
|
6356
6485
|
}
|
|
6357
6486
|
}
|
|
6358
|
-
|
|
6359
|
-
const nextIdentityTarget = nextIdentityTargets.get(bindingIndex);
|
|
6360
|
-
const nextMembershipTarget = nextMembershipTargets.get(bindingIndex);
|
|
6361
|
-
const nextMapLookupTarget = nextMapLookupTargets.get(bindingIndex);
|
|
6362
|
-
if (nextIdentityTarget) this.identityTargets.set(bindingIndex, nextIdentityTarget);
|
|
6363
|
-
else this.identityTargets.delete(bindingIndex);
|
|
6364
|
-
if (nextMembershipTarget) {
|
|
6365
|
-
this.membershipTargets.set(bindingIndex, nextMembershipTarget);
|
|
6366
|
-
} else {
|
|
6367
|
-
this.membershipTargets.delete(bindingIndex);
|
|
6368
|
-
}
|
|
6369
|
-
if (nextMapLookupTarget) {
|
|
6370
|
-
this.mapLookupTargets.set(bindingIndex, nextMapLookupTarget);
|
|
6371
|
-
} else {
|
|
6372
|
-
this.mapLookupTargets.delete(bindingIndex);
|
|
6373
|
-
}
|
|
6374
|
-
}
|
|
6487
|
+
this.keyedTargets?.commitPrepared(affectedBindingIndices);
|
|
6375
6488
|
afterCommit?.();
|
|
6376
6489
|
return true;
|
|
6377
6490
|
}
|
|
@@ -6438,7 +6551,13 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6438
6551
|
else removed.push(instance);
|
|
6439
6552
|
}
|
|
6440
6553
|
if (nextIndex !== rows.keys.length) return false;
|
|
6441
|
-
const shouldPrepareBindings =
|
|
6554
|
+
const shouldPrepareBindings = this.currentProps.bindings.length > 0 && !this.currentProps.hostBlocks;
|
|
6555
|
+
if (shouldPrepareBindings && rows.items.length === 1 && this.currentProps.bindings.some(
|
|
6556
|
+
(binding) => !findCompilerHostTarget(this.instances.get(rows.keys[0]).element, binding.path)
|
|
6557
|
+
)) {
|
|
6558
|
+
this.activateFallback(afterCommit);
|
|
6559
|
+
return true;
|
|
6560
|
+
}
|
|
6442
6561
|
const preparedBindings = shouldPrepareBindings ? prepareKeyedRowBindingSetUpdates(this.currentProps, this.instances, rows) : void 0;
|
|
6443
6562
|
if (shouldPrepareBindings && !preparedBindings) {
|
|
6444
6563
|
this.activateFallback(afterCommit);
|
|
@@ -6504,11 +6623,7 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6504
6623
|
this.forceUpdate(afterCommit);
|
|
6505
6624
|
return;
|
|
6506
6625
|
}
|
|
6507
|
-
if (!this.
|
|
6508
|
-
this.activateFallback(afterCommit);
|
|
6509
|
-
return;
|
|
6510
|
-
}
|
|
6511
|
-
if (!this.hasSafeMapLookupTargets(dirtyState)) {
|
|
6626
|
+
if (this.keyedTargets && !this.keyedTargets.hasSafeTargets(this.currentProps, dirtyState)) {
|
|
6512
6627
|
this.activateFallback(afterCommit);
|
|
6513
6628
|
return;
|
|
6514
6629
|
}
|
|
@@ -6660,6 +6775,7 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6660
6775
|
const willBeReactOwned = this.hasReactOwnedRows(nextProps);
|
|
6661
6776
|
const definitionChanged = this.definitionVersion !== owner.getDefinitionVersion?.();
|
|
6662
6777
|
this.currentProps = nextProps;
|
|
6778
|
+
this.keyedTargets || (this.keyedTargets = options.keyedTargets?.(nextProps));
|
|
6663
6779
|
if (this.state.fallback && nextState.fallback) {
|
|
6664
6780
|
const unsafeKeys = this.hasUnsafeFallbackKeys();
|
|
6665
6781
|
if (unsafeKeys || this.fallbackKeysWereUnsafe) this.fallbackVersion += 1;
|
|
@@ -6695,9 +6811,7 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6695
6811
|
this.id = void 0;
|
|
6696
6812
|
this.cleanupHostScopes();
|
|
6697
6813
|
this.instances.clear();
|
|
6698
|
-
this.
|
|
6699
|
-
this.membershipTargets.clear();
|
|
6700
|
-
this.mapLookupTargets.clear();
|
|
6814
|
+
this.keyedTargets?.clear();
|
|
6701
6815
|
this.instancesByElement = /* @__PURE__ */ new WeakMap();
|
|
6702
6816
|
this.eventHandlers.clear();
|
|
6703
6817
|
this.conditionalListeners.clear();
|
|
@@ -6720,6 +6834,12 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6720
6834
|
FarmKeyedRowsBlock.displayName = "FarmCompiledKeyedRows";
|
|
6721
6835
|
return FarmKeyedRowsBlock;
|
|
6722
6836
|
}
|
|
6837
|
+
function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
6838
|
+
return createKeyedRowsBlockComponentCore(owner, {
|
|
6839
|
+
...options,
|
|
6840
|
+
keyedTargets: createKeyedTargetRuntime
|
|
6841
|
+
});
|
|
6842
|
+
}
|
|
6723
6843
|
function createKeyedRangesBlockComponent(owner) {
|
|
6724
6844
|
class FarmKeyedRangesBlock extends React__default.default.Component {
|
|
6725
6845
|
constructor() {
|
|
@@ -7195,6 +7315,36 @@ var keyedRowsRuntimeFeature = {
|
|
|
7195
7315
|
KeyedRows: createKeyedRowsBlockComponent(owner)
|
|
7196
7316
|
})
|
|
7197
7317
|
};
|
|
7318
|
+
var keyedRowsPlainRuntimeFeature = {
|
|
7319
|
+
name: "keyed-rows:plain",
|
|
7320
|
+
create: (owner) => ({
|
|
7321
|
+
KeyedRows: createKeyedRowsBlockComponentCore(owner)
|
|
7322
|
+
})
|
|
7323
|
+
};
|
|
7324
|
+
var keyedRowsIdentityRuntimeFeature = {
|
|
7325
|
+
name: "keyed-rows:identity",
|
|
7326
|
+
create: (owner) => ({
|
|
7327
|
+
KeyedRows: createKeyedRowsBlockComponentCore(owner, {
|
|
7328
|
+
keyedTargets: createKeyedIdentityTargetRuntime
|
|
7329
|
+
})
|
|
7330
|
+
})
|
|
7331
|
+
};
|
|
7332
|
+
var keyedRowsMembershipRuntimeFeature = {
|
|
7333
|
+
name: "keyed-rows:membership",
|
|
7334
|
+
create: (owner) => ({
|
|
7335
|
+
KeyedRows: createKeyedRowsBlockComponentCore(owner, {
|
|
7336
|
+
keyedTargets: createKeyedMembershipTargetRuntime
|
|
7337
|
+
})
|
|
7338
|
+
})
|
|
7339
|
+
};
|
|
7340
|
+
var keyedRowsMapLookupRuntimeFeature = {
|
|
7341
|
+
name: "keyed-rows:map-lookup",
|
|
7342
|
+
create: (owner) => ({
|
|
7343
|
+
KeyedRows: createKeyedRowsBlockComponentCore(owner, {
|
|
7344
|
+
keyedTargets: createKeyedMapLookupTargetRuntime
|
|
7345
|
+
})
|
|
7346
|
+
})
|
|
7347
|
+
};
|
|
7198
7348
|
var keyedRowsHintedRuntimeFeature = {
|
|
7199
7349
|
name: "keyed-rows:hinted",
|
|
7200
7350
|
create: (owner) => ({
|
|
@@ -8425,8 +8575,12 @@ exports.keyedRowsHostStructuralPrependHintedRuntimeFeature = keyedRowsHostStruct
|
|
|
8425
8575
|
exports.keyedRowsHostStructuralPrependMapHintedRuntimeFeature = keyedRowsHostStructuralPrependMapHintedRuntimeFeature;
|
|
8426
8576
|
exports.keyedRowsHostWindowEveryHintedRuntimeFeature = keyedRowsHostWindowEveryHintedRuntimeFeature;
|
|
8427
8577
|
exports.keyedRowsHostWindowPositionHintedRuntimeFeature = keyedRowsHostWindowPositionHintedRuntimeFeature;
|
|
8578
|
+
exports.keyedRowsIdentityRuntimeFeature = keyedRowsIdentityRuntimeFeature;
|
|
8579
|
+
exports.keyedRowsMapLookupRuntimeFeature = keyedRowsMapLookupRuntimeFeature;
|
|
8428
8580
|
exports.keyedRowsMapReorderHintedRuntimeFeature = keyedRowsMapReorderHintedRuntimeFeature;
|
|
8429
8581
|
exports.keyedRowsMappedRollingWindowHintedRuntimeFeature = keyedRowsMappedRollingWindowHintedRuntimeFeature;
|
|
8582
|
+
exports.keyedRowsMembershipRuntimeFeature = keyedRowsMembershipRuntimeFeature;
|
|
8583
|
+
exports.keyedRowsPlainRuntimeFeature = keyedRowsPlainRuntimeFeature;
|
|
8430
8584
|
exports.keyedRowsPositionHintedRuntimeFeature = keyedRowsPositionHintedRuntimeFeature;
|
|
8431
8585
|
exports.keyedRowsPrependHintedRuntimeFeature = keyedRowsPrependHintedRuntimeFeature;
|
|
8432
8586
|
exports.keyedRowsReorderHintedRuntimeFeature = keyedRowsReorderHintedRuntimeFeature;
|