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