@farm.js/react 0.1.0-beta.40 → 0.1.0-beta.41
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 +109 -18
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +8 -1
- package/dist/compiler-runtime.d.ts +8 -1
- package/dist/compiler-runtime.mjs +109 -18
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs.map +1 -1
- package/dist/vite.cjs +196 -134
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +196 -134
- package/dist/vite.mjs.map +1 -1
- package/package.json +2 -2
package/dist/vite.mjs
CHANGED
|
@@ -3499,6 +3499,33 @@ function reactOwnedAttribute(name, attribute) {
|
|
|
3499
3499
|
if (name === "defaultValue" || name === "defaultChecked") return true;
|
|
3500
3500
|
return (name === "spellCheck" || name === "draggable" || name === "contentEditable") && !types.isStringLiteral(attribute.value);
|
|
3501
3501
|
}
|
|
3502
|
+
function keyedRowFieldReason(element) {
|
|
3503
|
+
const tag = element.openingElement.name.name;
|
|
3504
|
+
const attributeNames = new Set(
|
|
3505
|
+
element.openingElement.attributes.filter((attribute) => types.isJSXAttribute(attribute)).map(jsxAttributeName).filter((name) => name !== void 0)
|
|
3506
|
+
);
|
|
3507
|
+
const controlled = attributeNames.has("value") || attributeNames.has("checked");
|
|
3508
|
+
if (attributeNames.has("contentEditable")) {
|
|
3509
|
+
return "content-editable keyed rows require React ownership";
|
|
3510
|
+
}
|
|
3511
|
+
if (tag === "input" && controlled) {
|
|
3512
|
+
const type = jsxAttribute(element, "type");
|
|
3513
|
+
const staticType = staticJsxAttributeString(type);
|
|
3514
|
+
if (type && staticType === void 0) {
|
|
3515
|
+
return "controlled keyed row inputs require a static type";
|
|
3516
|
+
}
|
|
3517
|
+
if (attributeNames.has("value") && staticType?.toLowerCase() === "file") {
|
|
3518
|
+
return "file inputs require React ownership";
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3521
|
+
if (tag === "textarea" && controlled && meaningfulJsxChildren(element).length > 0) {
|
|
3522
|
+
return "controlled keyed row textareas cannot also use children";
|
|
3523
|
+
}
|
|
3524
|
+
if (tag === "select" && controlled && controlledSelectHasDynamicOptions(element)) {
|
|
3525
|
+
return "controlled keyed row selects require static options";
|
|
3526
|
+
}
|
|
3527
|
+
return void 0;
|
|
3528
|
+
}
|
|
3502
3529
|
function keyedRowEventHandler(attribute) {
|
|
3503
3530
|
if (!types.isJSXExpressionContainer(attribute.value) || !types.isArrowFunctionExpression(attribute.value.expression) && !types.isFunctionExpression(attribute.value.expression)) {
|
|
3504
3531
|
return "interactive compiled keyed rows require inline synchronous event handlers";
|
|
@@ -3514,31 +3541,52 @@ function keyedRowEventHandler(attribute) {
|
|
|
3514
3541
|
if (unsupported) return `interactive compiled keyed row handlers cannot use ${unsupported}`;
|
|
3515
3542
|
return handler;
|
|
3516
3543
|
}
|
|
3517
|
-
function
|
|
3544
|
+
function forEachKeyedRowElement(row, visit) {
|
|
3545
|
+
const walk = (element, location) => {
|
|
3546
|
+
visit(element, location);
|
|
3547
|
+
let elementIndex = 0;
|
|
3548
|
+
element.children.forEach((child, childIndex) => {
|
|
3549
|
+
if (types.isJSXElement(child)) {
|
|
3550
|
+
if (isHostElement(child))
|
|
3551
|
+
walk(child, location ? `${location}.${elementIndex}` : `${elementIndex}`);
|
|
3552
|
+
elementIndex += 1;
|
|
3553
|
+
return;
|
|
3554
|
+
}
|
|
3555
|
+
if (!types.isJSXExpressionContainer(child) || types.isJSXEmptyExpression(child.expression)) return;
|
|
3556
|
+
const shape = conditionalBlockShape(child.expression);
|
|
3557
|
+
if (shape?.truthy) walk(shape.truthy, `${location}/${childIndex}t`);
|
|
3558
|
+
if (shape?.falsy) walk(shape.falsy, `${location}/${childIndex}f`);
|
|
3559
|
+
});
|
|
3560
|
+
};
|
|
3561
|
+
walk(row, "");
|
|
3562
|
+
}
|
|
3563
|
+
function hostBlockKeyedRowEvents(row, compilerSetters) {
|
|
3518
3564
|
const events = [];
|
|
3519
|
-
const
|
|
3565
|
+
const elements = /* @__PURE__ */ new Map();
|
|
3566
|
+
const attributes = /* @__PURE__ */ new Set();
|
|
3567
|
+
let supported = true;
|
|
3568
|
+
forEachKeyedRowElement(row, (element, location) => {
|
|
3569
|
+
if (keyedRowFieldReason(element)) supported = false;
|
|
3520
3570
|
for (const attribute of element.openingElement.attributes) {
|
|
3521
3571
|
if (!types.isJSXAttribute(attribute)) continue;
|
|
3522
3572
|
const name = jsxAttributeName(attribute);
|
|
3523
3573
|
if (!name || !/^on[A-Z]/.test(name)) continue;
|
|
3524
3574
|
const handler = keyedRowEventHandler(attribute);
|
|
3525
|
-
if (typeof handler === "string")
|
|
3575
|
+
if (typeof handler === "string") {
|
|
3576
|
+
supported = false;
|
|
3577
|
+
continue;
|
|
3578
|
+
}
|
|
3579
|
+
elements.set(element, [...elements.get(element) || [], events.length]);
|
|
3580
|
+
attributes.add(attribute);
|
|
3526
3581
|
events.push({
|
|
3527
3582
|
id: events.length,
|
|
3528
|
-
|
|
3583
|
+
location,
|
|
3529
3584
|
name,
|
|
3530
3585
|
value: stabilizeDeferredEventCurrentTarget(handler, compilerSetters)
|
|
3531
3586
|
});
|
|
3532
3587
|
}
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
if (!types.isJSXElement(child)) continue;
|
|
3536
|
-
if (!visit(child, [...path, elementIndex])) return false;
|
|
3537
|
-
elementIndex += 1;
|
|
3538
|
-
}
|
|
3539
|
-
return true;
|
|
3540
|
-
};
|
|
3541
|
-
return visit(row, []) ? events : void 0;
|
|
3588
|
+
});
|
|
3589
|
+
return supported ? { events, elements, attributes } : void 0;
|
|
3542
3590
|
}
|
|
3543
3591
|
function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters, keyedTargetReactiveByValue) {
|
|
3544
3592
|
if (renderCallback.async || renderCallback.generator || renderCallback.params.length < 1 || renderCallback.params.length > 2 || !types.isIdentifier(renderCallback.params[0]) || renderCallback.params[1] !== void 0 && !types.isIdentifier(renderCallback.params[1])) {
|
|
@@ -3565,29 +3613,8 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
|
|
|
3565
3613
|
if (tag.name === "title" || tag.name === "meta") {
|
|
3566
3614
|
return "document metadata requires React ownership";
|
|
3567
3615
|
}
|
|
3568
|
-
const
|
|
3569
|
-
|
|
3570
|
-
);
|
|
3571
|
-
const controlled = attributeNames.has("value") || attributeNames.has("checked");
|
|
3572
|
-
if (attributeNames.has("contentEditable")) {
|
|
3573
|
-
return "content-editable keyed rows require React ownership";
|
|
3574
|
-
}
|
|
3575
|
-
if (tag.name === "input" && controlled) {
|
|
3576
|
-
const type = jsxAttribute(element, "type");
|
|
3577
|
-
const staticType = staticJsxAttributeString(type);
|
|
3578
|
-
if (type && staticType === void 0) {
|
|
3579
|
-
return "controlled keyed row inputs require a static type";
|
|
3580
|
-
}
|
|
3581
|
-
if (attributeNames.has("value") && staticType?.toLowerCase() === "file") {
|
|
3582
|
-
return "file inputs require React ownership";
|
|
3583
|
-
}
|
|
3584
|
-
}
|
|
3585
|
-
if (tag.name === "textarea" && controlled && meaningfulJsxChildren(element).length > 0) {
|
|
3586
|
-
return "controlled keyed row textareas cannot also use children";
|
|
3587
|
-
}
|
|
3588
|
-
if (tag.name === "select" && controlled && controlledSelectHasDynamicOptions(element)) {
|
|
3589
|
-
return "controlled keyed row selects require static options";
|
|
3590
|
-
}
|
|
3616
|
+
const fieldReason = keyedRowFieldReason(element);
|
|
3617
|
+
if (fieldReason) return fieldReason;
|
|
3591
3618
|
for (const attribute of element.openingElement.attributes) {
|
|
3592
3619
|
if (types.isJSXSpreadAttribute(attribute)) {
|
|
3593
3620
|
return "compiled keyed rows do not support JSX attribute spreads";
|
|
@@ -3605,6 +3632,7 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
|
|
|
3605
3632
|
events.push({
|
|
3606
3633
|
id: events.length,
|
|
3607
3634
|
path: [...path],
|
|
3635
|
+
location: path.join("."),
|
|
3608
3636
|
name,
|
|
3609
3637
|
value: stabilizeDeferredEventCurrentTarget(handler, compilerSetters)
|
|
3610
3638
|
});
|
|
@@ -4249,7 +4277,8 @@ function analyzeRecursiveHostTree(branch, statesByValue, safeGlobals, listNames,
|
|
|
4249
4277
|
safeGlobals,
|
|
4250
4278
|
listNames,
|
|
4251
4279
|
id,
|
|
4252
|
-
allocateId
|
|
4280
|
+
allocateId,
|
|
4281
|
+
delegatedEvents
|
|
4253
4282
|
) : {
|
|
4254
4283
|
bindings: [],
|
|
4255
4284
|
plans: [],
|
|
@@ -4261,7 +4290,8 @@ function analyzeRecursiveHostTree(branch, statesByValue, safeGlobals, listNames,
|
|
|
4261
4290
|
safeGlobals,
|
|
4262
4291
|
listNames,
|
|
4263
4292
|
id,
|
|
4264
|
-
allocateId
|
|
4293
|
+
allocateId,
|
|
4294
|
+
delegatedEvents
|
|
4265
4295
|
) : {
|
|
4266
4296
|
bindings: [],
|
|
4267
4297
|
plans: [],
|
|
@@ -4443,71 +4473,20 @@ function analyzeRecursiveHostTree(branch, statesByValue, safeGlobals, listNames,
|
|
|
4443
4473
|
const reason = visit(branch, [], parent);
|
|
4444
4474
|
return { bindings, plans, blocks, reason };
|
|
4445
4475
|
}
|
|
4446
|
-
function jsxCanRenderElements(expression) {
|
|
4447
|
-
let found = false;
|
|
4448
|
-
traverse(expressionFile(cloneExpression(expression)), {
|
|
4449
|
-
JSXElement(path) {
|
|
4450
|
-
found = true;
|
|
4451
|
-
path.stop();
|
|
4452
|
-
},
|
|
4453
|
-
JSXFragment(path) {
|
|
4454
|
-
found = true;
|
|
4455
|
-
path.stop();
|
|
4456
|
-
}
|
|
4457
|
-
});
|
|
4458
|
-
return found;
|
|
4459
|
-
}
|
|
4460
|
-
function keyedRowEventPathIsStable(row, path) {
|
|
4461
|
-
let element = row;
|
|
4462
|
-
for (const index of path) {
|
|
4463
|
-
let seen = 0;
|
|
4464
|
-
let next;
|
|
4465
|
-
for (const child of element.children) {
|
|
4466
|
-
if (types.isJSXElement(child)) {
|
|
4467
|
-
if (!isHostElement(child)) return false;
|
|
4468
|
-
if (seen === index) {
|
|
4469
|
-
next = child;
|
|
4470
|
-
break;
|
|
4471
|
-
}
|
|
4472
|
-
seen += 1;
|
|
4473
|
-
continue;
|
|
4474
|
-
}
|
|
4475
|
-
if (types.isJSXFragment(child)) return false;
|
|
4476
|
-
if (types.isJSXExpressionContainer(child) && !types.isJSXEmptyExpression(child.expression) && jsxCanRenderElements(child.expression)) {
|
|
4477
|
-
return false;
|
|
4478
|
-
}
|
|
4479
|
-
}
|
|
4480
|
-
if (!next) return false;
|
|
4481
|
-
element = next;
|
|
4482
|
-
}
|
|
4483
|
-
return true;
|
|
4484
|
-
}
|
|
4485
4476
|
function analyzeCompilerOwnedKeyedRowHostBlocks(shape, container, statesByValue, safeGlobals, listNames, parent, allocateId, delegateWithoutReact = false) {
|
|
4486
|
-
const events = shape.rowReason ? staticKeyedRowEvents(
|
|
4487
|
-
shape.row,
|
|
4488
|
-
new Set([...statesByValue.values()].map((state) => state.setterName))
|
|
4489
|
-
) : shape.events;
|
|
4490
|
-
if (!events || events.length > 0 && (!canDelegateKeyedRowEvents(
|
|
4491
|
-
{ events, conditionals: [], source: container },
|
|
4492
|
-
delegateWithoutReact
|
|
4493
|
-
) || !events.every((event) => keyedRowEventPathIsStable(shape.row, event.path)))) {
|
|
4494
|
-
return void 0;
|
|
4495
|
-
}
|
|
4496
4477
|
const row = types.cloneNode(shape.row, true);
|
|
4497
4478
|
row.openingElement.attributes = row.openingElement.attributes.filter(
|
|
4498
4479
|
(attribute) => !types.isJSXAttribute(attribute) || jsxAttributeName(attribute) !== "key"
|
|
4499
4480
|
);
|
|
4500
|
-
const
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
}
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
}
|
|
4510
|
-
}
|
|
4481
|
+
const rowEvents = hostBlockKeyedRowEvents(
|
|
4482
|
+
row,
|
|
4483
|
+
new Set([...statesByValue.values()].map((state) => state.setterName))
|
|
4484
|
+
);
|
|
4485
|
+
if (!rowEvents || rowEvents.events.length > 0 && !canDelegateKeyedRowEvents(
|
|
4486
|
+
{ events: rowEvents.events, conditionals: [], source: container },
|
|
4487
|
+
delegateWithoutReact
|
|
4488
|
+
)) {
|
|
4489
|
+
return void 0;
|
|
4511
4490
|
}
|
|
4512
4491
|
const analysis = analyzeRecursiveHostTree(
|
|
4513
4492
|
row,
|
|
@@ -4516,7 +4495,7 @@ function analyzeCompilerOwnedKeyedRowHostBlocks(shape, container, statesByValue,
|
|
|
4516
4495
|
listNames,
|
|
4517
4496
|
parent,
|
|
4518
4497
|
allocateId,
|
|
4519
|
-
|
|
4498
|
+
rowEvents.attributes
|
|
4520
4499
|
);
|
|
4521
4500
|
if (analysis.reason || analysis.plans.length === 0) {
|
|
4522
4501
|
return void 0;
|
|
@@ -4526,7 +4505,8 @@ function analyzeCompilerOwnedKeyedRowHostBlocks(shape, container, statesByValue,
|
|
|
4526
4505
|
bindings: analysis.bindings,
|
|
4527
4506
|
descriptorBlocks: analysis.blocks,
|
|
4528
4507
|
nestedPlans: analysis.plans,
|
|
4529
|
-
events
|
|
4508
|
+
events: rowEvents.events,
|
|
4509
|
+
eventElements: rowEvents.elements
|
|
4530
4510
|
};
|
|
4531
4511
|
}
|
|
4532
4512
|
function analyzeHostConditionalContainer(container, statesByValue, safeGlobals, listNames, parent, allocateId) {
|
|
@@ -4728,7 +4708,8 @@ function analyzeMixedRangesContainer(container, statesByValue, safeGlobals, list
|
|
|
4728
4708
|
safeGlobals,
|
|
4729
4709
|
listNames,
|
|
4730
4710
|
parent,
|
|
4731
|
-
allocateId
|
|
4711
|
+
allocateId,
|
|
4712
|
+
delegatedEvents
|
|
4732
4713
|
) : {
|
|
4733
4714
|
bindings: [],
|
|
4734
4715
|
plans: [],
|
|
@@ -4740,7 +4721,8 @@ function analyzeMixedRangesContainer(container, statesByValue, safeGlobals, list
|
|
|
4740
4721
|
safeGlobals,
|
|
4741
4722
|
listNames,
|
|
4742
4723
|
parent,
|
|
4743
|
-
allocateId
|
|
4724
|
+
allocateId,
|
|
4725
|
+
delegatedEvents
|
|
4744
4726
|
) : {
|
|
4745
4727
|
bindings: [],
|
|
4746
4728
|
plans: [],
|
|
@@ -4851,7 +4833,7 @@ function keyedListBoundary(blockRuntime, plan, source) {
|
|
|
4851
4833
|
true
|
|
4852
4834
|
);
|
|
4853
4835
|
}
|
|
4854
|
-
function hostElementDescriptor(element, descriptorBlocks = /* @__PURE__ */ new Map()) {
|
|
4836
|
+
function hostElementDescriptor(element, descriptorBlocks = /* @__PURE__ */ new Map(), eventElements) {
|
|
4855
4837
|
const tag = element.openingElement.name;
|
|
4856
4838
|
const attributes = [];
|
|
4857
4839
|
const styles = [];
|
|
@@ -4907,13 +4889,15 @@ function hostElementDescriptor(element, descriptorBlocks = /* @__PURE__ */ new M
|
|
|
4907
4889
|
children.push(keyedRangeDescriptorChildren(keyedRange, descriptorBlocks));
|
|
4908
4890
|
}
|
|
4909
4891
|
} else {
|
|
4910
|
-
children.push(hostElementDescriptor(child, descriptorBlocks));
|
|
4892
|
+
children.push(hostElementDescriptor(child, descriptorBlocks, eventElements));
|
|
4911
4893
|
}
|
|
4912
4894
|
} else if (types.isJSXExpressionContainer(child) && !types.isJSXEmptyExpression(child.expression)) {
|
|
4913
4895
|
const conditionalRange = conditionalBySource.get(child.expression);
|
|
4914
4896
|
const keyedRange = keyedBySource.get(child.expression);
|
|
4915
4897
|
if (conditionalRange) {
|
|
4916
|
-
children.push(
|
|
4898
|
+
children.push(
|
|
4899
|
+
conditionalRangeDescriptorChild(conditionalRange, descriptorBlocks, eventElements)
|
|
4900
|
+
);
|
|
4917
4901
|
} else if (keyedRange) {
|
|
4918
4902
|
if (block?.kind !== "nested-host-keyed-ranges") {
|
|
4919
4903
|
children.push(keyedRangeDescriptorChildren(keyedRange, descriptorBlocks));
|
|
@@ -4930,22 +4914,34 @@ function hostElementDescriptor(element, descriptorBlocks = /* @__PURE__ */ new M
|
|
|
4930
4914
|
types.objectProperty(types.identifier("styles"), types.arrayExpression(styles)),
|
|
4931
4915
|
types.objectProperty(types.identifier("children"), types.arrayExpression(children))
|
|
4932
4916
|
];
|
|
4917
|
+
const events = eventElements?.get(element);
|
|
4918
|
+
if (events) {
|
|
4919
|
+
properties.push(
|
|
4920
|
+
types.objectProperty(
|
|
4921
|
+
types.identifier("events"),
|
|
4922
|
+
types.arrayExpression(events.map((id) => types.numericLiteral(id)))
|
|
4923
|
+
)
|
|
4924
|
+
);
|
|
4925
|
+
}
|
|
4933
4926
|
if (block) {
|
|
4934
4927
|
properties.push(
|
|
4935
|
-
types.objectProperty(
|
|
4928
|
+
types.objectProperty(
|
|
4929
|
+
types.identifier("block"),
|
|
4930
|
+
nestedHostBlockObject(block, descriptorBlocks, eventElements)
|
|
4931
|
+
)
|
|
4936
4932
|
);
|
|
4937
4933
|
}
|
|
4938
4934
|
return types.objectExpression(properties);
|
|
4939
4935
|
}
|
|
4940
|
-
function conditionalRangeDescriptorChild(range, descriptorBlocks) {
|
|
4941
|
-
const truthy = range.truthy ? hostElementDescriptor(range.truthy, descriptorBlocks) : types.nullLiteral();
|
|
4936
|
+
function conditionalRangeDescriptorChild(range, descriptorBlocks, eventElements) {
|
|
4937
|
+
const truthy = range.truthy ? hostElementDescriptor(range.truthy, descriptorBlocks, eventElements) : types.nullLiteral();
|
|
4942
4938
|
if (range.logical) {
|
|
4943
4939
|
return types.logicalExpression("&&", cloneExpression(range.test), truthy);
|
|
4944
4940
|
}
|
|
4945
4941
|
return types.conditionalExpression(
|
|
4946
4942
|
cloneExpression(range.test),
|
|
4947
4943
|
truthy,
|
|
4948
|
-
range.falsy ? hostElementDescriptor(range.falsy, descriptorBlocks) : types.nullLiteral()
|
|
4944
|
+
range.falsy ? hostElementDescriptor(range.falsy, descriptorBlocks, eventElements) : types.nullLiteral()
|
|
4949
4945
|
);
|
|
4950
4946
|
}
|
|
4951
4947
|
function keyedRangeDescriptorChildren(range, descriptorBlocks) {
|
|
@@ -5073,14 +5069,14 @@ function uniqueLocalIdentifier(base, nodes) {
|
|
|
5073
5069
|
}
|
|
5074
5070
|
function rewriteKeyedRowEventAttributes(row, events, eventFactory, item, index, extraArguments = []) {
|
|
5075
5071
|
const eventByLocation = new Map(
|
|
5076
|
-
events.map((event) => [`${event.
|
|
5072
|
+
events.map((event) => [`${event.location}:${event.name}`, event])
|
|
5077
5073
|
);
|
|
5078
|
-
|
|
5074
|
+
forEachKeyedRowElement(row, (element, location) => {
|
|
5079
5075
|
for (const attribute of element.openingElement.attributes) {
|
|
5080
5076
|
if (!types.isJSXAttribute(attribute)) continue;
|
|
5081
5077
|
const name = jsxAttributeName(attribute);
|
|
5082
5078
|
if (!name || !/^on[A-Z]/.test(name)) continue;
|
|
5083
|
-
const event = eventByLocation.get(`${
|
|
5079
|
+
const event = eventByLocation.get(`${location}:${name}`);
|
|
5084
5080
|
if (!event) continue;
|
|
5085
5081
|
attribute.value = types.jsxExpressionContainer(
|
|
5086
5082
|
types.callExpression(types.cloneNode(eventFactory), [
|
|
@@ -5091,14 +5087,7 @@ function rewriteKeyedRowEventAttributes(row, events, eventFactory, item, index,
|
|
|
5091
5087
|
])
|
|
5092
5088
|
);
|
|
5093
5089
|
}
|
|
5094
|
-
|
|
5095
|
-
for (const child of element.children) {
|
|
5096
|
-
if (!types.isJSXElement(child)) continue;
|
|
5097
|
-
visit(child, [...path, elementIndex]);
|
|
5098
|
-
elementIndex += 1;
|
|
5099
|
-
}
|
|
5100
|
-
};
|
|
5101
|
-
visit(row, []);
|
|
5090
|
+
});
|
|
5102
5091
|
}
|
|
5103
5092
|
function rewriteKeyedRowConditionalExpressions(row, conditionals, conditionalFactory, item, index, renderParameters) {
|
|
5104
5093
|
const conditionalByLocation = new Map(
|
|
@@ -5176,10 +5165,12 @@ function keyedRowEventObject(event, renderParameters) {
|
|
|
5176
5165
|
const parameters = [types.cloneNode(renderParameters[0], true), index, syntheticEvent];
|
|
5177
5166
|
return types.objectExpression([
|
|
5178
5167
|
types.objectProperty(types.identifier("name"), types.stringLiteral(event.name)),
|
|
5179
|
-
|
|
5180
|
-
types.
|
|
5181
|
-
|
|
5182
|
-
|
|
5168
|
+
...event.path ? [
|
|
5169
|
+
types.objectProperty(
|
|
5170
|
+
types.identifier("path"),
|
|
5171
|
+
types.arrayExpression(event.path.map((part) => types.numericLiteral(part)))
|
|
5172
|
+
)
|
|
5173
|
+
] : [],
|
|
5183
5174
|
types.objectProperty(
|
|
5184
5175
|
types.identifier("invoke"),
|
|
5185
5176
|
types.arrowFunctionExpression(
|
|
@@ -5390,7 +5381,7 @@ function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFi
|
|
|
5390
5381
|
types.jsxExpressionContainer(
|
|
5391
5382
|
types.arrowFunctionExpression(
|
|
5392
5383
|
parameters.map((parameter) => types.cloneNode(parameter, true)),
|
|
5393
|
-
hostElementDescriptor(plan.row, plan.descriptorBlocks)
|
|
5384
|
+
hostElementDescriptor(plan.row, plan.descriptorBlocks, plan.eventElements)
|
|
5394
5385
|
)
|
|
5395
5386
|
)
|
|
5396
5387
|
),
|
|
@@ -5586,11 +5577,11 @@ function keyedRangesBoundary(blockRuntime, plan) {
|
|
|
5586
5577
|
true
|
|
5587
5578
|
);
|
|
5588
5579
|
}
|
|
5589
|
-
function hostConditionalBranchObject(branch, bindings, descriptorBlocks = /* @__PURE__ */ new Map()) {
|
|
5580
|
+
function hostConditionalBranchObject(branch, bindings, descriptorBlocks = /* @__PURE__ */ new Map(), eventElements) {
|
|
5590
5581
|
return types.objectExpression([
|
|
5591
5582
|
types.objectProperty(
|
|
5592
5583
|
types.identifier("create"),
|
|
5593
|
-
types.arrowFunctionExpression([], hostElementDescriptor(branch, descriptorBlocks))
|
|
5584
|
+
types.arrowFunctionExpression([], hostElementDescriptor(branch, descriptorBlocks, eventElements))
|
|
5594
5585
|
),
|
|
5595
5586
|
types.objectProperty(
|
|
5596
5587
|
types.identifier("bindings"),
|
|
@@ -5637,7 +5628,7 @@ function hostConditionalBoundary(blockRuntime, plan) {
|
|
|
5637
5628
|
}
|
|
5638
5629
|
return types.jsxElement(types.jsxOpeningElement(name, attributes, true), null, [], true);
|
|
5639
5630
|
}
|
|
5640
|
-
function conditionalRangeObject(range, descriptorBlocks = /* @__PURE__ */ new Map()) {
|
|
5631
|
+
function conditionalRangeObject(range, descriptorBlocks = /* @__PURE__ */ new Map(), eventElements) {
|
|
5641
5632
|
const properties = [
|
|
5642
5633
|
types.objectProperty(types.identifier("before"), types.numericLiteral(range.before)),
|
|
5643
5634
|
types.objectProperty(
|
|
@@ -5652,7 +5643,12 @@ function conditionalRangeObject(range, descriptorBlocks = /* @__PURE__ */ new Ma
|
|
|
5652
5643
|
properties.push(
|
|
5653
5644
|
types.objectProperty(
|
|
5654
5645
|
types.identifier("truthy"),
|
|
5655
|
-
hostConditionalBranchObject(
|
|
5646
|
+
hostConditionalBranchObject(
|
|
5647
|
+
range.truthy,
|
|
5648
|
+
range.truthyBindings,
|
|
5649
|
+
descriptorBlocks,
|
|
5650
|
+
eventElements
|
|
5651
|
+
)
|
|
5656
5652
|
)
|
|
5657
5653
|
);
|
|
5658
5654
|
}
|
|
@@ -5660,13 +5656,18 @@ function conditionalRangeObject(range, descriptorBlocks = /* @__PURE__ */ new Ma
|
|
|
5660
5656
|
properties.push(
|
|
5661
5657
|
types.objectProperty(
|
|
5662
5658
|
types.identifier("falsy"),
|
|
5663
|
-
hostConditionalBranchObject(
|
|
5659
|
+
hostConditionalBranchObject(
|
|
5660
|
+
range.falsy,
|
|
5661
|
+
range.falsyBindings,
|
|
5662
|
+
descriptorBlocks,
|
|
5663
|
+
eventElements
|
|
5664
|
+
)
|
|
5664
5665
|
)
|
|
5665
5666
|
);
|
|
5666
5667
|
}
|
|
5667
5668
|
return types.objectExpression(properties);
|
|
5668
5669
|
}
|
|
5669
|
-
function nestedHostBlockObject(plan, descriptorBlocks) {
|
|
5670
|
+
function nestedHostBlockObject(plan, descriptorBlocks, eventElements) {
|
|
5670
5671
|
const kind = plan.kind === "nested-host-conditional-ranges" ? "conditional-ranges" : plan.kind === "nested-host-keyed-ranges" ? "keyed-ranges" : "mixed-ranges";
|
|
5671
5672
|
return types.objectExpression([
|
|
5672
5673
|
types.objectProperty(types.identifier("kind"), types.stringLiteral(kind)),
|
|
@@ -5674,7 +5675,9 @@ function nestedHostBlockObject(plan, descriptorBlocks) {
|
|
|
5674
5675
|
types.objectProperty(
|
|
5675
5676
|
types.identifier("ranges"),
|
|
5676
5677
|
types.arrayExpression(
|
|
5677
|
-
plan.kind === "nested-host-conditional-ranges" ? plan.ranges.map(
|
|
5678
|
+
plan.kind === "nested-host-conditional-ranges" ? plan.ranges.map(
|
|
5679
|
+
(range) => conditionalRangeObject(range, descriptorBlocks, eventElements)
|
|
5680
|
+
) : plan.kind === "nested-host-keyed-ranges" ? plan.ranges.map((range) => keyedRangeObject(range, descriptorBlocks)) : plan.ranges.map((range) => mixedRangeObject(range, descriptorBlocks, eventElements))
|
|
5678
5681
|
)
|
|
5679
5682
|
),
|
|
5680
5683
|
types.objectProperty(types.identifier("trailing"), types.numericLiteral(plan.trailing)),
|
|
@@ -5685,8 +5688,8 @@ function nestedHostBlockObject(plan, descriptorBlocks) {
|
|
|
5685
5688
|
...plan.kind === "nested-host-keyed-ranges" ? [types.objectProperty(types.identifier("staticChildrenOnly"), types.booleanLiteral(true))] : []
|
|
5686
5689
|
]);
|
|
5687
5690
|
}
|
|
5688
|
-
function mixedRangeObject(range, descriptorBlocks) {
|
|
5689
|
-
const value = range.rangeKind === "conditional" ? conditionalRangeObject(range, descriptorBlocks) : keyedRangeObject(range, descriptorBlocks);
|
|
5691
|
+
function mixedRangeObject(range, descriptorBlocks, eventElements) {
|
|
5692
|
+
const value = range.rangeKind === "conditional" ? conditionalRangeObject(range, descriptorBlocks, eventElements) : keyedRangeObject(range, descriptorBlocks);
|
|
5690
5693
|
value.properties.unshift(
|
|
5691
5694
|
types.objectProperty(types.identifier("kind"), types.stringLiteral(range.rangeKind))
|
|
5692
5695
|
);
|
|
@@ -6101,6 +6104,7 @@ function analyzeComposableBlocks(root, statesByValue, safeGlobals, listNames, al
|
|
|
6101
6104
|
events: hostBlocks?.events || keyedRows.events,
|
|
6102
6105
|
conditionals: hostBlocks ? [] : keyedRows.conditionals,
|
|
6103
6106
|
descriptorBlocks: hostBlocks?.descriptorBlocks,
|
|
6107
|
+
eventElements: hostBlocks?.eventElements,
|
|
6104
6108
|
syntax: keyedRows.syntax
|
|
6105
6109
|
});
|
|
6106
6110
|
plans.push(...hostBlocks?.nestedPlans || []);
|
|
@@ -6274,6 +6278,53 @@ function analyzeComposableBlocks(root, statesByValue, safeGlobals, listNames, al
|
|
|
6274
6278
|
keyedExpressions
|
|
6275
6279
|
};
|
|
6276
6280
|
}
|
|
6281
|
+
const rootKeyedRowsStart = nextId;
|
|
6282
|
+
const rootKeyedRowsId = nextId++;
|
|
6283
|
+
const rootKeyedRows = analyzeKeyedRowsContainer(root, statesByValue, safeGlobals, listNames);
|
|
6284
|
+
const rootHostBlocks = rootKeyedRows && analyzeCompilerOwnedKeyedRowHostBlocks(
|
|
6285
|
+
rootKeyedRows,
|
|
6286
|
+
root,
|
|
6287
|
+
statesByValue,
|
|
6288
|
+
safeGlobals,
|
|
6289
|
+
listNames,
|
|
6290
|
+
rootKeyedRowsId,
|
|
6291
|
+
() => nextId++,
|
|
6292
|
+
delegateWithoutReact
|
|
6293
|
+
);
|
|
6294
|
+
if (rootKeyedRows && rootHostBlocks) {
|
|
6295
|
+
plans.push({
|
|
6296
|
+
kind: "keyed-rows",
|
|
6297
|
+
id: rootKeyedRowsId,
|
|
6298
|
+
dependencies: rootKeyedRows.dependencies,
|
|
6299
|
+
source: root,
|
|
6300
|
+
collection: rootKeyedRows.collection,
|
|
6301
|
+
collectionDependency: rootKeyedRows.collectionDependency,
|
|
6302
|
+
structureDependencies: rootKeyedRows.structureDependencies,
|
|
6303
|
+
keyCallback: rootKeyedRows.keyCallback,
|
|
6304
|
+
renderCallback: rootKeyedRows.renderCallback,
|
|
6305
|
+
row: rootHostBlocks.row,
|
|
6306
|
+
bindings: rootHostBlocks.bindings,
|
|
6307
|
+
events: rootHostBlocks.events,
|
|
6308
|
+
conditionals: [],
|
|
6309
|
+
descriptorBlocks: rootHostBlocks.descriptorBlocks,
|
|
6310
|
+
eventElements: rootHostBlocks.eventElements,
|
|
6311
|
+
syntax: rootKeyedRows.syntax
|
|
6312
|
+
});
|
|
6313
|
+
plans.push(...rootHostBlocks.nestedPlans);
|
|
6314
|
+
const list = meaningfulJsxChildren(root)[0];
|
|
6315
|
+
if (types.isJSXElement(list)) ownedElements.add(list);
|
|
6316
|
+
else if (types.isJSXExpressionContainer(list) && !types.isJSXEmptyExpression(list.expression)) {
|
|
6317
|
+
keyedExpressions.add(list.expression);
|
|
6318
|
+
}
|
|
6319
|
+
return {
|
|
6320
|
+
plans,
|
|
6321
|
+
componentElements,
|
|
6322
|
+
conditionalExpressions,
|
|
6323
|
+
ownedElements,
|
|
6324
|
+
keyedExpressions
|
|
6325
|
+
};
|
|
6326
|
+
}
|
|
6327
|
+
nextId = rootKeyedRowsStart;
|
|
6277
6328
|
const rootConditionalRangeStart = nextId;
|
|
6278
6329
|
const rootConditionalRangeId = nextId++;
|
|
6279
6330
|
const rootConditionalRanges = analyzeConditionalRangesContainer(
|
|
@@ -6355,6 +6406,17 @@ function lowerComposableBlocks(root, plans, blockRuntime, listNames, keyedMapUpd
|
|
|
6355
6406
|
if (rootPlan?.kind === "conditional-ranges") {
|
|
6356
6407
|
return conditionalRangesBoundary(blockRuntime, rootPlan);
|
|
6357
6408
|
}
|
|
6409
|
+
if (rootPlan?.kind === "keyed-rows") {
|
|
6410
|
+
return keyedRowsBoundary(
|
|
6411
|
+
blockRuntime,
|
|
6412
|
+
rootPlan,
|
|
6413
|
+
keyedMapUpdateHints,
|
|
6414
|
+
keyedArrayFilterHintedStateIndices,
|
|
6415
|
+
keyedArrayPrependHintedStateIndices,
|
|
6416
|
+
keyedArrayPositionHintedStateIndices,
|
|
6417
|
+
keyedArrayReorderHintedStateIndices
|
|
6418
|
+
);
|
|
6419
|
+
}
|
|
6358
6420
|
const visit = (element) => {
|
|
6359
6421
|
element.children = element.children.map((child) => {
|
|
6360
6422
|
if (types.isJSXElement(child)) {
|