marko 6.0.0-next.3.36 → 6.0.0-next.3.38

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.
@@ -628,7 +628,7 @@ function toMemberExpression(object, key, optional) {
628
628
  var pureFunctions = [
629
629
  "conditional",
630
630
  "conditionalClosure",
631
- "conditionalOnlyChild",
631
+ "dynamicTag",
632
632
  "createRenderer",
633
633
  "createRendererWithOwner",
634
634
  "createTemplate",
@@ -1990,6 +1990,10 @@ function setForceResumeScope(section) {
1990
1990
  _setForceResumeScope(section, true);
1991
1991
  }
1992
1992
  var [getSerializedScopeProperties] = createSectionState("serializedScopeProperties", () => /* @__PURE__ */ new Map());
1993
+ var [getHTMLSectionStatements] = createSectionState(
1994
+ "htmlScopeStatements",
1995
+ () => []
1996
+ );
1993
1997
  var unimplementedBuild = () => {
1994
1998
  return import_compiler17.types.stringLiteral("SIGNAL NOT INITIALIZED");
1995
1999
  };
@@ -2680,13 +2684,14 @@ function writeHTMLResumeStatements(path5) {
2680
2684
  )
2681
2685
  );
2682
2686
  }
2683
- if (path5.get("body").length) {
2684
- path5.unshiftContainer(
2685
- "body",
2687
+ const additionalStatements = getHTMLSectionStatements(section);
2688
+ if (path5.get("body").length || additionalStatements.length) {
2689
+ path5.unshiftContainer("body", [
2686
2690
  import_compiler17.types.variableDeclaration("const", [
2687
2691
  import_compiler17.types.variableDeclarator(scopeIdIdentifier, callRuntime("nextScopeId"))
2688
- ])
2689
- );
2692
+ ]),
2693
+ ...additionalStatements
2694
+ ]);
2690
2695
  }
2691
2696
  const returnIdentifier = getSectionReturnValueIdentifier(section);
2692
2697
  if (returnIdentifier !== void 0) {
@@ -2895,7 +2900,7 @@ var dom_default = {
2895
2900
  import_compiler18.types.variableDeclaration("const", [
2896
2901
  import_compiler18.types.variableDeclarator(
2897
2902
  identifier,
2898
- isStatefulSection(childSection) ? callRuntime(
2903
+ !childSection.isBranch && isStatefulSection(childSection) ? callRuntime(
2899
2904
  "register",
2900
2905
  import_compiler18.types.stringLiteral(
2901
2906
  getResumeRegisterId(childSection, "renderer")
@@ -4218,8 +4223,8 @@ var debug_default = {
4218
4223
  };
4219
4224
 
4220
4225
  // src/translator/core/define.ts
4221
- var import_compiler31 = require("@marko/compiler");
4222
- var import_babel_utils20 = require("@marko/compiler/babel-utils");
4226
+ var import_compiler32 = require("@marko/compiler");
4227
+ var import_babel_utils21 = require("@marko/compiler/babel-utils");
4223
4228
 
4224
4229
  // src/translator/util/nested-attribute-tags.ts
4225
4230
  var import_compiler27 = require("@marko/compiler");
@@ -4344,10 +4349,14 @@ function getConditionRoot(tag) {
4344
4349
  }
4345
4350
 
4346
4351
  // src/translator/util/translate-attrs.ts
4352
+ var import_compiler31 = require("@marko/compiler");
4353
+ var import_babel_utils20 = require("@marko/compiler/babel-utils");
4354
+
4355
+ // src/translator/core/for.ts
4347
4356
  var import_compiler30 = require("@marko/compiler");
4348
4357
  var import_babel_utils19 = require("@marko/compiler/babel-utils");
4349
4358
 
4350
- // src/translator/core/for.ts
4359
+ // src/translator/util/is-only-child-in-parent.ts
4351
4360
  var import_compiler29 = require("@marko/compiler");
4352
4361
  var import_babel_utils18 = require("@marko/compiler/babel-utils");
4353
4362
 
@@ -4524,7 +4533,9 @@ var native_tag_default = {
4524
4533
  const tagName2 = node.name.type === "StringLiteral" ? node.name.value : import_compiler28.types.toIdentifier(tag.get("name"));
4525
4534
  const tagExtra = node.extra ??= {};
4526
4535
  const bindingName = "#" + tagName2;
4527
- tagExtra[kSerializeMarker] = hasEventHandlers || !!node.var;
4536
+ if (hasEventHandlers || node.var) {
4537
+ tagExtra[kSerializeMarker] = true;
4538
+ }
4528
4539
  tagExtra[kNativeTagBinding] = createBinding(
4529
4540
  bindingName,
4530
4541
  0 /* dom */,
@@ -4905,9 +4916,9 @@ var native_tag_default = {
4905
4916
  import_compiler28.types.ifStatement(tag.node.name, consumeHTML(tag))
4906
4917
  )[0].skip();
4907
4918
  }
4908
- if (nodeRef2 && (extra[kSerializeMarker] || isStatefulReferences(extra.referencedBindings) || tag.node.attributes.some(
4919
+ if (nodeRef2 && (extra[kSerializeMarker] || extra[kSerializeMarker] === void 0 && (isStatefulReferences(extra.referencedBindings) || tag.node.attributes.some(
4909
4920
  (attr2) => isStatefulReferences(attr2.value.extra?.referencedBindings)
4910
- ))) {
4921
+ )))) {
4911
4922
  markNode(tag, nodeRef2);
4912
4923
  }
4913
4924
  exit2(tag);
@@ -5002,16 +5013,46 @@ function isInvokedFunction(expr) {
5002
5013
  return parent.type === "CallExpression" && parent.callee === node;
5003
5014
  }
5004
5015
 
5005
- // src/translator/core/for.ts
5006
- var kForMarkerBinding = Symbol("for marker binding");
5016
+ // src/translator/util/is-only-child-in-parent.ts
5007
5017
  var kOnlyChildInParent = Symbol("only child in parent");
5018
+ var kNodeRef = Symbol("potential only child node ref");
5019
+ function isOnlyChildInParent(tag, branchSize = 1) {
5020
+ const extra = tag.node.extra;
5021
+ if (extra[kOnlyChildInParent] !== void 0) {
5022
+ return extra[kOnlyChildInParent];
5023
+ }
5024
+ const parentTag = getParentTag(tag);
5025
+ if (parentTag && (0, import_babel_utils18.getTagDef)(parentTag)?.html) {
5026
+ return extra[kOnlyChildInParent] = tag.parent.body.length === branchSize;
5027
+ }
5028
+ return extra[kOnlyChildInParent] = false;
5029
+ }
5030
+ function getOptimizedOnlyChildNodeRef(tag, section, branchSize = 1) {
5031
+ if (isOnlyChildInParent(tag, branchSize)) {
5032
+ const parentTag = getParentTag(tag).node;
5033
+ const parentTagName = parentTag.name?.value;
5034
+ return (parentTag.extra ??= {})[kNativeTagBinding] ??= createBinding(
5035
+ "#" + parentTagName,
5036
+ 0 /* dom */,
5037
+ section
5038
+ );
5039
+ } else {
5040
+ return (tag.node.extra ??= {})[kNodeRef] ??= createBinding(
5041
+ "#text",
5042
+ 0 /* dom */,
5043
+ section
5044
+ );
5045
+ }
5046
+ }
5047
+
5048
+ // src/translator/core/for.ts
5008
5049
  var for_default = {
5009
5050
  analyze(tag) {
5010
5051
  const tagExtra = tag.node.extra ??= {};
5011
5052
  const isAttrTag = tag.node.body.attributeTags;
5012
5053
  let allowAttrs;
5013
- (0, import_babel_utils18.assertNoVar)(tag);
5014
- (0, import_babel_utils18.assertNoArgs)(tag);
5054
+ (0, import_babel_utils19.assertNoVar)(tag);
5055
+ (0, import_babel_utils19.assertNoArgs)(tag);
5015
5056
  assertNoSpreadAttrs(tag);
5016
5057
  switch (getForType(tag.node)) {
5017
5058
  case "of":
@@ -5031,7 +5072,7 @@ var for_default = {
5031
5072
  if (!isAttrTag) {
5032
5073
  allowAttrs.push("by");
5033
5074
  }
5034
- (0, import_babel_utils18.assertAllowedAttributes)(tag, allowAttrs);
5075
+ (0, import_babel_utils19.assertAllowedAttributes)(tag, allowAttrs);
5035
5076
  if (isAttrTag) return;
5036
5077
  const tagBody = tag.get("body");
5037
5078
  const bodySection = startSection(tagBody);
@@ -5039,26 +5080,12 @@ var for_default = {
5039
5080
  dropReferences(getAllTagReferenceNodes(tag.node));
5040
5081
  return;
5041
5082
  }
5042
- bodySection.isBranch = true;
5043
5083
  const section = getOrCreateSection(tag);
5044
- if (isOnlyChildInParent(tag)) {
5045
- const parentTag = getParentTag(tag).node;
5046
- const parentTagName = parentTag.name?.value;
5047
- (parentTag.extra ??= {})[kNativeTagBinding] ??= createBinding(
5048
- "#" + parentTagName,
5049
- 0 /* dom */,
5050
- section
5051
- );
5052
- } else {
5053
- tagExtra[kForMarkerBinding] = createBinding(
5054
- "#text",
5055
- 0 /* dom */,
5056
- section
5057
- );
5058
- }
5059
5084
  trackParamsReferences(tagBody, 3 /* param */, void 0, tagExtra);
5060
5085
  mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
5086
+ getOptimizedOnlyChildNodeRef(tag, section);
5061
5087
  bodySection.upstreamExpression = tagExtra;
5088
+ bodySection.isBranch = true;
5062
5089
  },
5063
5090
  translate: translateByTarget({
5064
5091
  html: {
@@ -5085,18 +5112,18 @@ var for_default = {
5085
5112
  const { node } = tag;
5086
5113
  const tagExtra = node.extra;
5087
5114
  const isStateful = isStatefulReferences(tagExtra.referencedBindings);
5088
- const parentTag = getParentTag(tag);
5089
- const nodeRef2 = isOnlyChildInParent(tag) ? parentTag.node.extra[kNativeTagBinding] : tag.node.extra[kForMarkerBinding];
5115
+ const onlyChildInParentOptimization = isOnlyChildInParent(tag);
5116
+ const nodeRef2 = getOptimizedOnlyChildNodeRef(tag, tagSection);
5090
5117
  const forAttrs = getKnownAttrValues(node);
5091
5118
  const forType = getForType(node);
5092
5119
  const params = node.body.params;
5093
5120
  const statements = [];
5094
5121
  const bodyStatements = node.body.body;
5095
5122
  const hasStatefulClosures = checkStatefulClosures(bodySection, true);
5096
- const singleNodeOptimization = bodySection.content === null || bodySection.content.singleChild;
5123
+ const singleNodeOptimization = bodySection.content === null || bodySection.content.singleChild && bodySection.content.startType !== 4 /* Text */;
5097
5124
  let keyExpression;
5098
- if (isStateful && isOnlyChildInParent(tag)) {
5099
- parentTag.node.extra[kSerializeMarker] = true;
5125
+ if (onlyChildInParentOptimization) {
5126
+ getParentTag(tag).node.extra[kSerializeMarker] = false;
5100
5127
  }
5101
5128
  if (isStateful || hasStatefulClosures) {
5102
5129
  const defaultParamNames = {
@@ -5109,33 +5136,33 @@ var for_default = {
5109
5136
  setForceResumeScope(bodySection);
5110
5137
  for (let i = 0; i <= requiredParamsIndex; i++) {
5111
5138
  const existingParam = params[i];
5112
- if (!existingParam || !import_compiler29.types.isIdentifier(existingParam)) {
5139
+ if (!existingParam || !import_compiler30.types.isIdentifier(existingParam)) {
5113
5140
  const id = params[i] = currentProgramPath.scope.generateUidIdentifier(
5114
5141
  defaultParamNames[i]
5115
5142
  );
5116
5143
  if (existingParam) {
5117
5144
  bodyStatements.unshift(
5118
- import_compiler29.types.variableDeclaration("let", [
5119
- import_compiler29.types.variableDeclarator(existingParam, id)
5145
+ import_compiler30.types.variableDeclaration("let", [
5146
+ import_compiler30.types.variableDeclarator(existingParam, id)
5120
5147
  ])
5121
5148
  );
5122
5149
  }
5123
5150
  }
5124
5151
  }
5125
5152
  if (forAttrs.by) {
5126
- if (import_compiler29.types.isStringLiteral(forAttrs.by)) {
5153
+ if (import_compiler30.types.isStringLiteral(forAttrs.by)) {
5127
5154
  keyExpression = toMemberExpression(
5128
5155
  params[0],
5129
5156
  forAttrs.by.value
5130
5157
  );
5131
- } else if (import_compiler29.types.isFunction(forAttrs.by)) {
5158
+ } else if (import_compiler30.types.isFunction(forAttrs.by)) {
5132
5159
  const byIdentifier = currentProgramPath.scope.generateUidIdentifier("by");
5133
5160
  statements.push(
5134
- import_compiler29.types.variableDeclaration("const", [
5135
- import_compiler29.types.variableDeclarator(byIdentifier, forAttrs.by)
5161
+ import_compiler30.types.variableDeclaration("const", [
5162
+ import_compiler30.types.variableDeclarator(byIdentifier, forAttrs.by)
5136
5163
  ])
5137
5164
  );
5138
- keyExpression = import_compiler29.types.callExpression(
5165
+ keyExpression = import_compiler30.types.callExpression(
5139
5166
  byIdentifier,
5140
5167
  params
5141
5168
  );
@@ -5150,21 +5177,21 @@ var for_default = {
5150
5177
  keyExpression = params[defaultByParamIndex];
5151
5178
  }
5152
5179
  const forScopesIdentifier = getScopeIdentifier(bodySection);
5153
- statements.push(
5154
- import_compiler29.types.variableDeclaration("const", [
5155
- import_compiler29.types.variableDeclarator(
5180
+ getHTMLSectionStatements(tagSection).push(
5181
+ import_compiler30.types.variableDeclaration("const", [
5182
+ import_compiler30.types.variableDeclarator(
5156
5183
  forScopesIdentifier,
5157
- import_compiler29.types.newExpression(import_compiler29.types.identifier("Map"), [])
5184
+ import_compiler30.types.newExpression(import_compiler30.types.identifier("Map"), [])
5158
5185
  )
5159
5186
  ])
5160
5187
  );
5161
5188
  if (keyExpression && (isStateful || hasStatefulClosures)) {
5162
5189
  bodyStatements.push(
5163
- import_compiler29.types.expressionStatement(
5164
- import_compiler29.types.callExpression(
5165
- import_compiler29.types.memberExpression(
5190
+ import_compiler30.types.expressionStatement(
5191
+ import_compiler30.types.callExpression(
5192
+ import_compiler30.types.memberExpression(
5166
5193
  getScopeIdentifier(bodySection),
5167
- import_compiler29.types.identifier("set")
5194
+ import_compiler30.types.identifier("set")
5168
5195
  ),
5169
5196
  [
5170
5197
  keyExpression,
@@ -5178,13 +5205,13 @@ var for_default = {
5178
5205
  );
5179
5206
  }
5180
5207
  getSerializedScopeProperties(tagSection).set(
5181
- import_compiler29.types.stringLiteral(
5208
+ import_compiler30.types.stringLiteral(
5182
5209
  getScopeAccessorLiteral(nodeRef2).value + "(" /* LoopScopeMap */
5183
5210
  ),
5184
- import_compiler29.types.conditionalExpression(
5185
- import_compiler29.types.memberExpression(forScopesIdentifier, import_compiler29.types.identifier("size")),
5211
+ import_compiler30.types.conditionalExpression(
5212
+ import_compiler30.types.memberExpression(forScopesIdentifier, import_compiler30.types.identifier("size")),
5186
5213
  forScopesIdentifier,
5187
- import_compiler29.types.identifier("undefined")
5214
+ import_compiler30.types.identifier("undefined")
5188
5215
  )
5189
5216
  );
5190
5217
  }
@@ -5195,7 +5222,7 @@ var for_default = {
5195
5222
  const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
5196
5223
  const forTagHTMLRuntime = isStateful ? forTypeToHTMLResumeRuntime(forType, singleNodeOptimization) : forTypeToRuntime(forType);
5197
5224
  forTagArgs.push(
5198
- import_compiler29.types.arrowFunctionExpression(params, import_compiler29.types.blockStatement(bodyStatements))
5225
+ import_compiler30.types.arrowFunctionExpression(params, import_compiler30.types.blockStatement(bodyStatements))
5199
5226
  );
5200
5227
  if (isStateful) {
5201
5228
  forTagArgs.push(
@@ -5203,8 +5230,11 @@ var for_default = {
5203
5230
  getScopeAccessorLiteral(nodeRef2)
5204
5231
  );
5205
5232
  }
5233
+ if (onlyChildInParentOptimization) {
5234
+ forTagArgs.push(import_compiler30.types.numericLiteral(1));
5235
+ }
5206
5236
  statements.push(
5207
- import_compiler29.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
5237
+ import_compiler30.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
5208
5238
  );
5209
5239
  for (const replacement of tag.replaceWithMultiple(statements)) {
5210
5240
  replacement.skip();
@@ -5234,7 +5264,7 @@ var for_default = {
5234
5264
  const { node } = tag;
5235
5265
  const tagExtra = node.extra;
5236
5266
  const { referencedBindings } = tagExtra;
5237
- const nodeRef2 = isOnlyChildInParent(tag) ? getParentTag(tag).node.extra[kNativeTagBinding] : tag.node.extra[kForMarkerBinding];
5267
+ const nodeRef2 = getOptimizedOnlyChildNodeRef(tag, tagSection);
5238
5268
  setClosureSignalBuilder(tag, (_closureSignal, render, intersection) => {
5239
5269
  return callRuntime(
5240
5270
  "loopClosure",
@@ -5249,7 +5279,7 @@ var for_default = {
5249
5279
  return callRuntime(
5250
5280
  forTypeToDOMRuntime(forType),
5251
5281
  getScopeAccessorLiteral(nodeRef2),
5252
- import_compiler29.types.identifier(bodySection.name)
5282
+ import_compiler30.types.identifier(bodySection.name)
5253
5283
  );
5254
5284
  };
5255
5285
  const params = node.body.params;
@@ -5283,7 +5313,7 @@ var for_default = {
5283
5313
  tagSection,
5284
5314
  referencedBindings,
5285
5315
  signal,
5286
- import_compiler29.types.arrayExpression(loopArgs)
5316
+ import_compiler30.types.arrayExpression(loopArgs)
5287
5317
  );
5288
5318
  tag.remove();
5289
5319
  }
@@ -5349,11 +5379,11 @@ var for_default = {
5349
5379
  ]
5350
5380
  };
5351
5381
  function buildForRuntimeCall(type, attrs2, params, statements) {
5352
- return import_compiler29.types.expressionStatement(
5382
+ return import_compiler30.types.expressionStatement(
5353
5383
  callRuntime(
5354
5384
  forTypeToRuntime(type),
5355
5385
  ...getBaseArgsInForTag(type, attrs2),
5356
- import_compiler29.types.arrowFunctionExpression(params, import_compiler29.types.blockStatement(statements))
5386
+ import_compiler30.types.arrowFunctionExpression(params, import_compiler30.types.blockStatement(statements))
5357
5387
  )
5358
5388
  );
5359
5389
  }
@@ -5429,22 +5459,11 @@ function getBaseArgsInForTag(type, attrs2) {
5429
5459
  case "to":
5430
5460
  return [
5431
5461
  attrs2.to,
5432
- attrs2.from || import_compiler29.types.numericLiteral(0),
5433
- attrs2.step || import_compiler29.types.numericLiteral(1)
5462
+ attrs2.from || import_compiler30.types.numericLiteral(0),
5463
+ attrs2.step || import_compiler30.types.numericLiteral(1)
5434
5464
  ];
5435
5465
  }
5436
5466
  }
5437
- function isOnlyChildInParent(tag) {
5438
- const extra = tag.node.extra;
5439
- if (extra[kOnlyChildInParent] !== void 0) {
5440
- return extra[kOnlyChildInParent];
5441
- }
5442
- const parentTag = getParentTag(tag);
5443
- if (parentTag && (0, import_babel_utils18.getTagDef)(parentTag)?.html) {
5444
- return extra[kOnlyChildInParent] = tag.parent.body.length === 1;
5445
- }
5446
- return extra[kOnlyChildInParent] = false;
5447
- }
5448
5467
 
5449
5468
  // src/translator/util/translate-attrs.ts
5450
5469
  var contentProps = /* @__PURE__ */ new WeakSet();
@@ -5459,8 +5478,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
5459
5478
  seen.add(attrTagMeta.name);
5460
5479
  if (attrTagMeta.dynamic) {
5461
5480
  statements.push(
5462
- import_compiler30.types.variableDeclaration("let", [
5463
- import_compiler30.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta))
5481
+ import_compiler31.types.variableDeclaration("let", [
5482
+ import_compiler31.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta))
5464
5483
  ])
5465
5484
  );
5466
5485
  properties.push(
@@ -5476,7 +5495,7 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
5476
5495
  for (let i = 0; i < attrTags2.length; i++) {
5477
5496
  const child = attrTags2[i];
5478
5497
  if (child.isMarkoTag()) {
5479
- if ((0, import_babel_utils19.isAttributeTag)(child)) {
5498
+ if ((0, import_babel_utils20.isAttributeTag)(child)) {
5480
5499
  const attrTagMeta = attrTagLookup[getTagName(child)];
5481
5500
  if (attrTagMeta.dynamic) {
5482
5501
  i = addDynamicAttrTagStatements(
@@ -5542,8 +5561,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
5542
5561
  seen.add(contentKey);
5543
5562
  const contentExpression = buildContent(tag.get("body"));
5544
5563
  if (contentExpression) {
5545
- const contentProp = import_compiler30.types.objectProperty(
5546
- import_compiler30.types.identifier(contentKey),
5564
+ const contentProp = import_compiler31.types.objectProperty(
5565
+ import_compiler31.types.identifier(contentKey),
5547
5566
  contentExpression
5548
5567
  );
5549
5568
  contentProps.add(contentProp);
@@ -5554,8 +5573,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
5554
5573
  for (let i = attributes.length; i--; ) {
5555
5574
  const attr2 = attributes[i];
5556
5575
  const { value } = attr2;
5557
- if (import_compiler30.types.isMarkoSpreadAttribute(attr2)) {
5558
- properties.push(import_compiler30.types.spreadElement(value));
5576
+ if (import_compiler31.types.isMarkoSpreadAttribute(attr2)) {
5577
+ properties.push(import_compiler31.types.spreadElement(value));
5559
5578
  } else if (!seen.has(attr2.name) && usesExport(templateExports, attr2.name)) {
5560
5579
  seen.add(attr2.name);
5561
5580
  properties.push(toObjectProperty(attr2.name, value));
@@ -5574,7 +5593,7 @@ function getTranslatedBodyContentProperty(props) {
5574
5593
  function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements, templateExports, contentKey = "content") {
5575
5594
  const tag = attrTags2[index];
5576
5595
  if (tag.isMarkoTag()) {
5577
- if ((0, import_babel_utils19.isAttributeTag)(tag)) {
5596
+ if ((0, import_babel_utils20.isAttributeTag)(tag)) {
5578
5597
  const attrTagMeta = attrTagLookup[getTagName(tag)];
5579
5598
  if (usesExport(templateExports, attrTagMeta.name) && attrTagMeta.dynamic) {
5580
5599
  const translatedAttrTag = translateAttrs(
@@ -5585,8 +5604,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
5585
5604
  );
5586
5605
  if (attrTagMeta.repeated) {
5587
5606
  statements.push(
5588
- import_compiler30.types.expressionStatement(
5589
- import_compiler30.types.assignmentExpression(
5607
+ import_compiler31.types.expressionStatement(
5608
+ import_compiler31.types.assignmentExpression(
5590
5609
  "=",
5591
5610
  getAttrTagIdentifier(attrTagMeta),
5592
5611
  callRuntime(
@@ -5599,8 +5618,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
5599
5618
  );
5600
5619
  } else {
5601
5620
  statements.push(
5602
- import_compiler30.types.expressionStatement(
5603
- import_compiler30.types.assignmentExpression(
5621
+ import_compiler31.types.expressionStatement(
5622
+ import_compiler31.types.assignmentExpression(
5604
5623
  "=",
5605
5624
  getAttrTagIdentifier(attrTagMeta),
5606
5625
  callRuntime(
@@ -5639,7 +5658,7 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
5639
5658
  return index;
5640
5659
  }
5641
5660
  function propsToExpression(props) {
5642
- return props.length === 1 && import_compiler30.types.isSpreadElement(props[0]) ? props[0].argument : import_compiler30.types.objectExpression(props);
5661
+ return props.length === 1 && import_compiler31.types.isSpreadElement(props[0]) ? props[0].argument : import_compiler31.types.objectExpression(props);
5643
5662
  }
5644
5663
  function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
5645
5664
  const forTag = attrTags2[index];
@@ -5664,9 +5683,9 @@ function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templa
5664
5683
  function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
5665
5684
  const ifTag = attrTags2[index];
5666
5685
  const consequentStatements = [];
5667
- let ifStatement = import_compiler30.types.ifStatement(
5686
+ let ifStatement = import_compiler31.types.ifStatement(
5668
5687
  getConditionTestValue(ifTag),
5669
- import_compiler30.types.blockStatement(consequentStatements)
5688
+ import_compiler31.types.blockStatement(consequentStatements)
5670
5689
  );
5671
5690
  statements.push(ifStatement);
5672
5691
  addAllAttrTagsAsDynamic(
@@ -5693,14 +5712,14 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
5693
5712
  contentKey
5694
5713
  );
5695
5714
  if (testValue) {
5696
- ifStatement.alternate = ifStatement = import_compiler30.types.ifStatement(
5715
+ ifStatement.alternate = ifStatement = import_compiler31.types.ifStatement(
5697
5716
  testValue,
5698
- import_compiler30.types.blockStatement(alternateStatements)
5717
+ import_compiler31.types.blockStatement(alternateStatements)
5699
5718
  );
5700
5719
  nextIndex++;
5701
5720
  continue;
5702
5721
  } else {
5703
- ifStatement.alternate = import_compiler30.types.blockStatement(alternateStatements);
5722
+ ifStatement.alternate = import_compiler31.types.blockStatement(alternateStatements);
5704
5723
  break;
5705
5724
  }
5706
5725
  }
@@ -5758,12 +5777,12 @@ function buildContent(body) {
5758
5777
  "register",
5759
5778
  callRuntime(
5760
5779
  "createRenderer",
5761
- import_compiler30.types.arrowFunctionExpression(
5780
+ import_compiler31.types.arrowFunctionExpression(
5762
5781
  body.node.params,
5763
- import_compiler30.types.blockStatement(body.node.body)
5782
+ import_compiler31.types.blockStatement(body.node.body)
5764
5783
  )
5765
5784
  ),
5766
- import_compiler30.types.stringLiteral(getResumeRegisterId(bodySection, "renderer")),
5785
+ import_compiler31.types.stringLiteral(getResumeRegisterId(bodySection, "renderer")),
5767
5786
  getScopeIdIdentifier(
5768
5787
  getSection(
5769
5788
  getNonAttributeTagParent(body.parentPath)
@@ -5771,7 +5790,7 @@ function buildContent(body) {
5771
5790
  )
5772
5791
  );
5773
5792
  } else {
5774
- return import_compiler30.types.callExpression(import_compiler30.types.identifier(bodySection.name), [
5793
+ return import_compiler31.types.callExpression(import_compiler31.types.identifier(bodySection.name), [
5775
5794
  scopeIdentifier
5776
5795
  ]);
5777
5796
  }
@@ -5779,7 +5798,7 @@ function buildContent(body) {
5779
5798
  }
5780
5799
  function getNonAttributeTagParent(tag) {
5781
5800
  let cur = tag;
5782
- while ((0, import_babel_utils19.isAttributeTag)(cur) || (0, import_babel_utils19.isTransparentTag)(cur)) {
5801
+ while ((0, import_babel_utils20.isAttributeTag)(cur) || (0, import_babel_utils20.isTransparentTag)(cur)) {
5783
5802
  cur = getParentTag(cur);
5784
5803
  }
5785
5804
  return cur;
@@ -5788,7 +5807,7 @@ function getNonAttributeTagParent(tag) {
5788
5807
  // src/translator/core/define.ts
5789
5808
  var define_default = {
5790
5809
  analyze(tag) {
5791
- (0, import_babel_utils20.assertNoArgs)(tag);
5810
+ (0, import_babel_utils21.assertNoArgs)(tag);
5792
5811
  if (!tag.node.var) {
5793
5812
  throw tag.get("name").buildCodeFrameError("The `define` tag requires a tag variable.");
5794
5813
  }
@@ -5850,24 +5869,24 @@ var define_default = {
5850
5869
  };
5851
5870
 
5852
5871
  // src/translator/core/effect.ts
5853
- var import_compiler32 = require("@marko/compiler");
5854
- var import_babel_utils21 = require("@marko/compiler/babel-utils");
5872
+ var import_compiler33 = require("@marko/compiler");
5873
+ var import_babel_utils22 = require("@marko/compiler/babel-utils");
5855
5874
  var effect_default = {
5856
5875
  migrate: [
5857
5876
  (tag) => {
5858
- (0, import_babel_utils21.assertNoArgs)(tag);
5859
- (0, import_babel_utils21.assertNoParams)(tag);
5877
+ (0, import_babel_utils22.assertNoArgs)(tag);
5878
+ (0, import_babel_utils22.assertNoParams)(tag);
5860
5879
  assertNoBodyContent(tag);
5861
- (0, import_babel_utils21.assertNoAttributeTags)(tag);
5880
+ (0, import_babel_utils22.assertNoAttributeTags)(tag);
5862
5881
  assertNoSpreadAttrs(tag);
5863
- (0, import_babel_utils21.assertAllowedAttributes)(tag, ["value"]);
5864
- (0, import_babel_utils21.diagnosticDeprecate)(tag, {
5882
+ (0, import_babel_utils22.assertAllowedAttributes)(tag, ["value"]);
5883
+ (0, import_babel_utils22.diagnosticDeprecate)(tag, {
5865
5884
  label: "The 'effect' tag has been replaced by the 'script' tag.",
5866
5885
  fix() {
5867
5886
  const { node } = tag;
5868
5887
  tag.replaceWith(
5869
- import_compiler32.types.markoTag(
5870
- withPreviousLocation(import_compiler32.types.stringLiteral("script"), node.name),
5888
+ import_compiler33.types.markoTag(
5889
+ withPreviousLocation(import_compiler33.types.stringLiteral("script"), node.name),
5871
5890
  node.attributes,
5872
5891
  node.body,
5873
5892
  node.arguments,
@@ -5884,12 +5903,12 @@ var effect_default = {
5884
5903
  };
5885
5904
 
5886
5905
  // src/translator/core/export.ts
5887
- var import_babel_utils22 = require("@marko/compiler/babel-utils");
5906
+ var import_babel_utils23 = require("@marko/compiler/babel-utils");
5888
5907
  var export_default = {
5889
5908
  parse(tag) {
5890
5909
  const { node } = tag;
5891
5910
  tag.replaceWith(
5892
- (0, import_babel_utils22.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
5911
+ (0, import_babel_utils23.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
5893
5912
  );
5894
5913
  },
5895
5914
  parseOptions: {
@@ -5904,20 +5923,20 @@ var export_default = {
5904
5923
  };
5905
5924
 
5906
5925
  // src/translator/core/html-comment.ts
5907
- var import_compiler33 = require("@marko/compiler");
5908
- var import_babel_utils23 = require("@marko/compiler/babel-utils");
5926
+ var import_compiler34 = require("@marko/compiler");
5927
+ var import_babel_utils24 = require("@marko/compiler/babel-utils");
5909
5928
  var kCommentTagBinding = Symbol("comment tag binding");
5910
5929
  var kGetterId2 = Symbol("node getter id");
5911
5930
  var html_comment_default = {
5912
5931
  analyze(tag) {
5913
- (0, import_babel_utils23.assertNoArgs)(tag);
5914
- (0, import_babel_utils23.assertNoParams)(tag);
5915
- (0, import_babel_utils23.assertNoAttributes)(tag);
5932
+ (0, import_babel_utils24.assertNoArgs)(tag);
5933
+ (0, import_babel_utils24.assertNoParams)(tag);
5934
+ (0, import_babel_utils24.assertNoAttributes)(tag);
5916
5935
  const tagVar = tag.node.var;
5917
5936
  let needsBinding = false;
5918
5937
  let needsGetter = false;
5919
5938
  if (tagVar) {
5920
- if (!import_compiler33.types.isIdentifier(tagVar)) {
5939
+ if (!import_compiler34.types.isIdentifier(tagVar)) {
5921
5940
  throw tag.get("var").buildCodeFrameError(
5922
5941
  "The `html-comment` tag variable cannot be destructured."
5923
5942
  );
@@ -5968,7 +5987,7 @@ var html_comment_default = {
5968
5987
  callRuntime(
5969
5988
  "nodeRef",
5970
5989
  getterId && getScopeIdIdentifier(getSection(tag)),
5971
- getterId && import_compiler33.types.stringLiteral(getterId)
5990
+ getterId && import_compiler34.types.stringLiteral(getterId)
5972
5991
  )
5973
5992
  );
5974
5993
  } else {
@@ -5981,12 +6000,12 @@ var html_comment_default = {
5981
6000
  );
5982
6001
  currentProgramPath.pushContainer(
5983
6002
  "body",
5984
- import_compiler33.types.variableDeclaration("const", [
5985
- import_compiler33.types.variableDeclarator(
6003
+ import_compiler34.types.variableDeclaration("const", [
6004
+ import_compiler34.types.variableDeclarator(
5986
6005
  getterFnIdentifier,
5987
6006
  callRuntime(
5988
6007
  "nodeRef",
5989
- import_compiler33.types.stringLiteral(getterId),
6008
+ import_compiler34.types.stringLiteral(getterId),
5990
6009
  getScopeAccessorLiteral(commentBinding)
5991
6010
  )
5992
6011
  )
@@ -5997,13 +6016,13 @@ var html_comment_default = {
5997
6016
  const referenceSection = getSection(reference);
5998
6017
  if (reference.parentPath?.isCallExpression()) {
5999
6018
  reference.parentPath.replaceWith(
6000
- import_compiler33.types.expressionStatement(
6019
+ import_compiler34.types.expressionStatement(
6001
6020
  createScopeReadExpression(referenceSection, commentBinding)
6002
6021
  )
6003
6022
  );
6004
6023
  } else if (getterFnIdentifier) {
6005
6024
  reference.replaceWith(
6006
- import_compiler33.types.callExpression(getterFnIdentifier, [
6025
+ import_compiler34.types.callExpression(getterFnIdentifier, [
6007
6026
  getScopeExpression(referenceSection, getSection(tag))
6008
6027
  ])
6009
6028
  );
@@ -6019,9 +6038,9 @@ var html_comment_default = {
6019
6038
  write2`<!--`;
6020
6039
  if (isOutputHTML()) {
6021
6040
  for (const child of tag.node.body.body) {
6022
- if (import_compiler33.types.isMarkoText(child)) {
6041
+ if (import_compiler34.types.isMarkoText(child)) {
6023
6042
  write2`${child.value}`;
6024
- } else if (import_compiler33.types.isMarkoPlaceholder(child)) {
6043
+ } else if (import_compiler34.types.isMarkoPlaceholder(child)) {
6025
6044
  write2`${callRuntime("escapeXML", child.value)}`;
6026
6045
  }
6027
6046
  }
@@ -6030,10 +6049,10 @@ var html_comment_default = {
6030
6049
  const templateExpressions = [];
6031
6050
  let currentQuasi = "";
6032
6051
  for (const child of tag.node.body.body) {
6033
- if (import_compiler33.types.isMarkoText(child)) {
6052
+ if (import_compiler34.types.isMarkoText(child)) {
6034
6053
  currentQuasi += child.value;
6035
- } else if (import_compiler33.types.isMarkoPlaceholder(child)) {
6036
- templateQuasis.push(import_compiler33.types.templateElement({ raw: currentQuasi }));
6054
+ } else if (import_compiler34.types.isMarkoPlaceholder(child)) {
6055
+ templateQuasis.push(import_compiler34.types.templateElement({ raw: currentQuasi }));
6037
6056
  templateExpressions.push(child.value);
6038
6057
  currentQuasi = "";
6039
6058
  }
@@ -6041,20 +6060,20 @@ var html_comment_default = {
6041
6060
  if (templateExpressions.length === 0) {
6042
6061
  write2`${currentQuasi}`;
6043
6062
  } else {
6044
- templateQuasis.push(import_compiler33.types.templateElement({ raw: currentQuasi }));
6063
+ templateQuasis.push(import_compiler34.types.templateElement({ raw: currentQuasi }));
6045
6064
  addStatement(
6046
6065
  "render",
6047
6066
  getSection(tag),
6048
6067
  tagExtra.referencedBindings,
6049
- import_compiler33.types.expressionStatement(
6068
+ import_compiler34.types.expressionStatement(
6050
6069
  callRuntime(
6051
6070
  "data",
6052
- import_compiler33.types.memberExpression(
6071
+ import_compiler34.types.memberExpression(
6053
6072
  scopeIdentifier,
6054
6073
  getScopeAccessorLiteral(commentBinding),
6055
6074
  true
6056
6075
  ),
6057
- import_compiler33.types.templateLiteral(templateQuasis, templateExpressions)
6076
+ import_compiler34.types.templateLiteral(templateQuasis, templateExpressions)
6058
6077
  )
6059
6078
  )
6060
6079
  );
@@ -6080,15 +6099,15 @@ var html_comment_default = {
6080
6099
  };
6081
6100
 
6082
6101
  // src/translator/core/html-script.ts
6083
- var import_compiler34 = require("@marko/compiler");
6084
- var import_babel_utils24 = require("@marko/compiler/babel-utils");
6102
+ var import_compiler35 = require("@marko/compiler");
6103
+ var import_babel_utils25 = require("@marko/compiler/babel-utils");
6085
6104
  var kGetterId3 = Symbol("node getter id");
6086
6105
  var html_script_default = {
6087
6106
  analyze(tag) {
6088
- (0, import_babel_utils24.assertNoArgs)(tag);
6089
- (0, import_babel_utils24.assertNoParams)(tag);
6107
+ (0, import_babel_utils25.assertNoArgs)(tag);
6108
+ (0, import_babel_utils25.assertNoParams)(tag);
6090
6109
  const { node } = tag;
6091
- if (node.var && !import_compiler34.types.isIdentifier(node.var)) {
6110
+ if (node.var && !import_compiler35.types.isIdentifier(node.var)) {
6092
6111
  throw tag.get("var").buildCodeFrameError(
6093
6112
  "Tag variables on native elements cannot be destructured."
6094
6113
  );
@@ -6101,7 +6120,7 @@ var html_script_default = {
6101
6120
  let spreadReferenceNodes;
6102
6121
  for (let i = attributes.length; i--; ) {
6103
6122
  const attr2 = attributes[i];
6104
- if (import_compiler34.types.isMarkoAttribute(attr2)) {
6123
+ if (import_compiler35.types.isMarkoAttribute(attr2)) {
6105
6124
  if (seen[attr2.name]) {
6106
6125
  dropReferences(attr2.value);
6107
6126
  continue;
@@ -6113,14 +6132,14 @@ var html_script_default = {
6113
6132
  } else if (!evaluate(attr2.value).confident) {
6114
6133
  hasDynamicAttributes = true;
6115
6134
  }
6116
- } else if (import_compiler34.types.isMarkoSpreadAttribute(attr2)) {
6135
+ } else if (import_compiler35.types.isMarkoSpreadAttribute(attr2)) {
6117
6136
  hasEventHandlers = true;
6118
6137
  hasDynamicAttributes = true;
6119
6138
  (attr2.value.extra ??= {}).isEffect = true;
6120
6139
  }
6121
6140
  if (spreadReferenceNodes) {
6122
6141
  spreadReferenceNodes.push(attr2.value);
6123
- } else if (import_compiler34.types.isMarkoSpreadAttribute(attr2)) {
6142
+ } else if (import_compiler35.types.isMarkoSpreadAttribute(attr2)) {
6124
6143
  spreadReferenceNodes = [attr2.value];
6125
6144
  }
6126
6145
  }
@@ -6130,10 +6149,10 @@ var html_script_default = {
6130
6149
  const bodyPlaceholderNodes = [];
6131
6150
  let hasBodyPlaceholders = false;
6132
6151
  for (const child of tag.node.body.body) {
6133
- if (import_compiler34.types.isMarkoPlaceholder(child)) {
6152
+ if (import_compiler35.types.isMarkoPlaceholder(child)) {
6134
6153
  bodyPlaceholderNodes.push(child.value);
6135
6154
  hasBodyPlaceholders = true;
6136
- } else if (!import_compiler34.types.isMarkoText(child)) {
6155
+ } else if (!import_compiler35.types.isMarkoText(child)) {
6137
6156
  throw tag.hub.buildError(
6138
6157
  child,
6139
6158
  "Invalid child. Only text is allowed inside an html-script."
@@ -6183,7 +6202,7 @@ var html_script_default = {
6183
6202
  let currentSection = getSection(reference);
6184
6203
  while (currentSection !== section && currentSection.parent) {
6185
6204
  getSerializedScopeProperties(currentSection).set(
6186
- import_compiler34.types.stringLiteral("_"),
6205
+ import_compiler35.types.stringLiteral("_"),
6187
6206
  callRuntime(
6188
6207
  "ensureScopeWithId",
6189
6208
  getScopeIdIdentifier(currentSection = currentSection.parent)
@@ -6196,7 +6215,7 @@ var html_script_default = {
6196
6215
  callRuntime(
6197
6216
  "nodeRef",
6198
6217
  getterId && getScopeIdIdentifier(section),
6199
- getterId && import_compiler34.types.stringLiteral(getterId)
6218
+ getterId && import_compiler35.types.stringLiteral(getterId)
6200
6219
  )
6201
6220
  );
6202
6221
  } else {
@@ -6209,12 +6228,12 @@ var html_script_default = {
6209
6228
  );
6210
6229
  currentProgramPath.pushContainer(
6211
6230
  "body",
6212
- import_compiler34.types.variableDeclaration("const", [
6213
- import_compiler34.types.variableDeclarator(
6231
+ import_compiler35.types.variableDeclaration("const", [
6232
+ import_compiler35.types.variableDeclarator(
6214
6233
  getterFnIdentifier,
6215
6234
  callRuntime(
6216
6235
  "nodeRef",
6217
- import_compiler34.types.stringLiteral(getterId),
6236
+ import_compiler35.types.stringLiteral(getterId),
6218
6237
  getScopeAccessorLiteral(nodeRef2)
6219
6238
  )
6220
6239
  )
@@ -6225,13 +6244,13 @@ var html_script_default = {
6225
6244
  const referenceSection = getSection(reference);
6226
6245
  if (reference.parentPath?.isCallExpression()) {
6227
6246
  reference.parentPath.replaceWith(
6228
- import_compiler34.types.expressionStatement(
6247
+ import_compiler35.types.expressionStatement(
6229
6248
  createScopeReadExpression(referenceSection, nodeRef2)
6230
6249
  )
6231
6250
  );
6232
6251
  } else if (getterFnIdentifier) {
6233
6252
  reference.replaceWith(
6234
- import_compiler34.types.callExpression(getterFnIdentifier, [
6253
+ import_compiler35.types.callExpression(getterFnIdentifier, [
6235
6254
  getScopeExpression(referenceSection, getSection(tag))
6236
6255
  ])
6237
6256
  );
@@ -6264,10 +6283,10 @@ var html_script_default = {
6264
6283
  "render",
6265
6284
  section,
6266
6285
  valueReferences,
6267
- import_compiler34.types.expressionStatement(
6286
+ import_compiler35.types.expressionStatement(
6268
6287
  callRuntime(
6269
6288
  helper,
6270
- import_compiler34.types.memberExpression(scopeIdentifier, visitAccessor, true),
6289
+ import_compiler35.types.memberExpression(scopeIdentifier, visitAccessor, true),
6271
6290
  value
6272
6291
  )
6273
6292
  )
@@ -6282,18 +6301,18 @@ var html_script_default = {
6282
6301
  if (isEventHandler(name2)) {
6283
6302
  addHTMLEffectCall(section, valueReferences);
6284
6303
  } else {
6285
- write2`${callRuntime("attr", import_compiler34.types.stringLiteral(name2), value)}`;
6304
+ write2`${callRuntime("attr", import_compiler35.types.stringLiteral(name2), value)}`;
6286
6305
  }
6287
6306
  } else if (isEventHandler(name2)) {
6288
6307
  addStatement(
6289
6308
  "effect",
6290
6309
  section,
6291
6310
  valueReferences,
6292
- import_compiler34.types.expressionStatement(
6311
+ import_compiler35.types.expressionStatement(
6293
6312
  callRuntime(
6294
6313
  "on",
6295
- import_compiler34.types.memberExpression(scopeIdentifier, visitAccessor, true),
6296
- import_compiler34.types.stringLiteral(getEventHandlerName(name2)),
6314
+ import_compiler35.types.memberExpression(scopeIdentifier, visitAccessor, true),
6315
+ import_compiler35.types.stringLiteral(getEventHandlerName(name2)),
6297
6316
  value
6298
6317
  )
6299
6318
  )
@@ -6303,11 +6322,11 @@ var html_script_default = {
6303
6322
  "render",
6304
6323
  section,
6305
6324
  valueReferences,
6306
- import_compiler34.types.expressionStatement(
6325
+ import_compiler35.types.expressionStatement(
6307
6326
  callRuntime(
6308
6327
  "attr",
6309
- import_compiler34.types.memberExpression(scopeIdentifier, visitAccessor, true),
6310
- import_compiler34.types.stringLiteral(name2),
6328
+ import_compiler35.types.memberExpression(scopeIdentifier, visitAccessor, true),
6329
+ import_compiler35.types.stringLiteral(name2),
6311
6330
  value
6312
6331
  )
6313
6332
  )
@@ -6320,9 +6339,9 @@ var html_script_default = {
6320
6339
  if (isHTML) {
6321
6340
  addHTMLEffectCall(section, tagExtra.referencedBindings);
6322
6341
  if (skipExpression) {
6323
- write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler34.types.stringLiteral("script"))}`;
6342
+ write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler35.types.stringLiteral("script"))}`;
6324
6343
  } else {
6325
- write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler34.types.stringLiteral("script"))}`;
6344
+ write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler35.types.stringLiteral("script"))}`;
6326
6345
  }
6327
6346
  } else {
6328
6347
  if (skipExpression) {
@@ -6330,7 +6349,7 @@ var html_script_default = {
6330
6349
  "render",
6331
6350
  section,
6332
6351
  tagExtra.referencedBindings,
6333
- import_compiler34.types.expressionStatement(
6352
+ import_compiler35.types.expressionStatement(
6334
6353
  callRuntime(
6335
6354
  "partialAttrs",
6336
6355
  scopeIdentifier,
@@ -6345,7 +6364,7 @@ var html_script_default = {
6345
6364
  "render",
6346
6365
  section,
6347
6366
  tagExtra.referencedBindings,
6348
- import_compiler34.types.expressionStatement(
6367
+ import_compiler35.types.expressionStatement(
6349
6368
  callRuntime(
6350
6369
  "attrs",
6351
6370
  scopeIdentifier,
@@ -6359,7 +6378,7 @@ var html_script_default = {
6359
6378
  "effect",
6360
6379
  section,
6361
6380
  tagExtra.referencedBindings,
6362
- import_compiler34.types.expressionStatement(
6381
+ import_compiler35.types.expressionStatement(
6363
6382
  callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
6364
6383
  ),
6365
6384
  false
@@ -6370,9 +6389,9 @@ var html_script_default = {
6370
6389
  enter2(tag);
6371
6390
  if (isOutputHTML()) {
6372
6391
  for (const child of tag.node.body.body) {
6373
- if (import_compiler34.types.isMarkoText(child)) {
6392
+ if (import_compiler35.types.isMarkoText(child)) {
6374
6393
  write2`${child.value}`;
6375
- } else if (import_compiler34.types.isMarkoPlaceholder(child)) {
6394
+ } else if (import_compiler35.types.isMarkoPlaceholder(child)) {
6376
6395
  write2`${callRuntime("escapeScript", child.value)}`;
6377
6396
  }
6378
6397
  }
@@ -6382,11 +6401,11 @@ var html_script_default = {
6382
6401
  let currentQuasi = "";
6383
6402
  let referencePlaceholder;
6384
6403
  for (const child of tag.node.body.body) {
6385
- if (import_compiler34.types.isMarkoText(child)) {
6404
+ if (import_compiler35.types.isMarkoText(child)) {
6386
6405
  currentQuasi += child.value;
6387
- } else if (import_compiler34.types.isMarkoPlaceholder(child)) {
6406
+ } else if (import_compiler35.types.isMarkoPlaceholder(child)) {
6388
6407
  referencePlaceholder ||= child;
6389
- templateQuasis.push(import_compiler34.types.templateElement({ raw: currentQuasi }));
6408
+ templateQuasis.push(import_compiler35.types.templateElement({ raw: currentQuasi }));
6390
6409
  templateExpressions.push(child.value);
6391
6410
  currentQuasi = "";
6392
6411
  }
@@ -6394,16 +6413,16 @@ var html_script_default = {
6394
6413
  if (!referencePlaceholder) {
6395
6414
  write2`${currentQuasi}`;
6396
6415
  } else {
6397
- templateQuasis.push(import_compiler34.types.templateElement({ raw: currentQuasi }));
6416
+ templateQuasis.push(import_compiler35.types.templateElement({ raw: currentQuasi }));
6398
6417
  addStatement(
6399
6418
  "render",
6400
6419
  getSection(tag),
6401
6420
  referencePlaceholder.value.extra?.referencedBindings,
6402
- import_compiler34.types.expressionStatement(
6421
+ import_compiler35.types.expressionStatement(
6403
6422
  callRuntime(
6404
6423
  "textContent",
6405
- import_compiler34.types.memberExpression(scopeIdentifier, visitAccessor, true),
6406
- import_compiler34.types.templateLiteral(templateQuasis, templateExpressions)
6424
+ import_compiler35.types.memberExpression(scopeIdentifier, visitAccessor, true),
6425
+ import_compiler35.types.templateLiteral(templateQuasis, templateExpressions)
6407
6426
  )
6408
6427
  )
6409
6428
  );
@@ -6442,11 +6461,11 @@ function getUsedAttrs2(tag) {
6442
6461
  for (let i = attributes.length; i--; ) {
6443
6462
  const attr2 = attributes[i];
6444
6463
  const { value } = attr2;
6445
- if (import_compiler34.types.isMarkoSpreadAttribute(attr2)) {
6464
+ if (import_compiler35.types.isMarkoSpreadAttribute(attr2)) {
6446
6465
  if (!spreadProps) {
6447
6466
  spreadProps = [];
6448
6467
  }
6449
- spreadProps.push(import_compiler34.types.spreadElement(value));
6468
+ spreadProps.push(import_compiler35.types.spreadElement(value));
6450
6469
  } else if (!seen[attr2.name]) {
6451
6470
  seen[attr2.name] = attr2;
6452
6471
  if (spreadProps) {
@@ -6460,10 +6479,10 @@ function getUsedAttrs2(tag) {
6460
6479
  if (spreadProps) {
6461
6480
  spreadProps.reverse();
6462
6481
  for (const { name: name2 } of staticAttrs) {
6463
- (skipProps ||= []).push(toObjectProperty(name2, import_compiler34.types.numericLiteral(1)));
6482
+ (skipProps ||= []).push(toObjectProperty(name2, import_compiler35.types.numericLiteral(1)));
6464
6483
  }
6465
6484
  if (skipProps) {
6466
- skipExpression = import_compiler34.types.objectExpression(skipProps);
6485
+ skipExpression = import_compiler35.types.objectExpression(skipProps);
6467
6486
  }
6468
6487
  spreadExpression = propsToExpression(spreadProps);
6469
6488
  }
@@ -6475,15 +6494,15 @@ function getUsedAttrs2(tag) {
6475
6494
  }
6476
6495
 
6477
6496
  // src/translator/core/html-style.ts
6478
- var import_compiler35 = require("@marko/compiler");
6479
- var import_babel_utils25 = require("@marko/compiler/babel-utils");
6497
+ var import_compiler36 = require("@marko/compiler");
6498
+ var import_babel_utils26 = require("@marko/compiler/babel-utils");
6480
6499
  var kGetterId4 = Symbol("node getter id");
6481
6500
  var html_style_default = {
6482
6501
  analyze(tag) {
6483
- (0, import_babel_utils25.assertNoArgs)(tag);
6484
- (0, import_babel_utils25.assertNoParams)(tag);
6502
+ (0, import_babel_utils26.assertNoArgs)(tag);
6503
+ (0, import_babel_utils26.assertNoParams)(tag);
6485
6504
  const { node } = tag;
6486
- if (node.var && !import_compiler35.types.isIdentifier(node.var)) {
6505
+ if (node.var && !import_compiler36.types.isIdentifier(node.var)) {
6487
6506
  throw tag.get("var").buildCodeFrameError(
6488
6507
  "Tag variables on native elements cannot be destructured."
6489
6508
  );
@@ -6496,7 +6515,7 @@ var html_style_default = {
6496
6515
  let spreadReferenceNodes;
6497
6516
  for (let i = attributes.length; i--; ) {
6498
6517
  const attr2 = attributes[i];
6499
- if (import_compiler35.types.isMarkoAttribute(attr2)) {
6518
+ if (import_compiler36.types.isMarkoAttribute(attr2)) {
6500
6519
  if (seen[attr2.name]) {
6501
6520
  dropReferences(attr2.value);
6502
6521
  continue;
@@ -6508,14 +6527,14 @@ var html_style_default = {
6508
6527
  } else if (!evaluate(attr2.value).confident) {
6509
6528
  hasDynamicAttributes = true;
6510
6529
  }
6511
- } else if (import_compiler35.types.isMarkoSpreadAttribute(attr2)) {
6530
+ } else if (import_compiler36.types.isMarkoSpreadAttribute(attr2)) {
6512
6531
  hasEventHandlers = true;
6513
6532
  hasDynamicAttributes = true;
6514
6533
  (attr2.value.extra ??= {}).isEffect = true;
6515
6534
  }
6516
6535
  if (spreadReferenceNodes) {
6517
6536
  spreadReferenceNodes.push(attr2.value);
6518
- } else if (import_compiler35.types.isMarkoSpreadAttribute(attr2)) {
6537
+ } else if (import_compiler36.types.isMarkoSpreadAttribute(attr2)) {
6519
6538
  spreadReferenceNodes = [attr2.value];
6520
6539
  }
6521
6540
  }
@@ -6525,10 +6544,10 @@ var html_style_default = {
6525
6544
  const bodyPlaceholderNodes = [];
6526
6545
  let hasBodyPlaceholders = false;
6527
6546
  for (const child of tag.node.body.body) {
6528
- if (import_compiler35.types.isMarkoPlaceholder(child)) {
6547
+ if (import_compiler36.types.isMarkoPlaceholder(child)) {
6529
6548
  bodyPlaceholderNodes.push(child.value);
6530
6549
  hasBodyPlaceholders = true;
6531
- } else if (!import_compiler35.types.isMarkoText(child)) {
6550
+ } else if (!import_compiler36.types.isMarkoText(child)) {
6532
6551
  throw tag.hub.buildError(
6533
6552
  child,
6534
6553
  "Invalid child. Only text is allowed inside an html-style."
@@ -6578,7 +6597,7 @@ var html_style_default = {
6578
6597
  let currentSection = getSection(reference);
6579
6598
  while (currentSection !== section && currentSection.parent) {
6580
6599
  getSerializedScopeProperties(currentSection).set(
6581
- import_compiler35.types.stringLiteral("_"),
6600
+ import_compiler36.types.stringLiteral("_"),
6582
6601
  callRuntime(
6583
6602
  "ensureScopeWithId",
6584
6603
  getScopeIdIdentifier(currentSection = currentSection.parent)
@@ -6591,7 +6610,7 @@ var html_style_default = {
6591
6610
  callRuntime(
6592
6611
  "nodeRef",
6593
6612
  getterId && getScopeIdIdentifier(section),
6594
- getterId && import_compiler35.types.stringLiteral(getterId)
6613
+ getterId && import_compiler36.types.stringLiteral(getterId)
6595
6614
  )
6596
6615
  );
6597
6616
  } else {
@@ -6604,12 +6623,12 @@ var html_style_default = {
6604
6623
  );
6605
6624
  currentProgramPath.pushContainer(
6606
6625
  "body",
6607
- import_compiler35.types.variableDeclaration("const", [
6608
- import_compiler35.types.variableDeclarator(
6626
+ import_compiler36.types.variableDeclaration("const", [
6627
+ import_compiler36.types.variableDeclarator(
6609
6628
  getterFnIdentifier,
6610
6629
  callRuntime(
6611
6630
  "nodeRef",
6612
- import_compiler35.types.stringLiteral(getterId),
6631
+ import_compiler36.types.stringLiteral(getterId),
6613
6632
  getScopeAccessorLiteral(nodeRef2)
6614
6633
  )
6615
6634
  )
@@ -6620,13 +6639,13 @@ var html_style_default = {
6620
6639
  const referenceSection = getSection(reference);
6621
6640
  if (reference.parentPath?.isCallExpression()) {
6622
6641
  reference.parentPath.replaceWith(
6623
- import_compiler35.types.expressionStatement(
6642
+ import_compiler36.types.expressionStatement(
6624
6643
  createScopeReadExpression(referenceSection, nodeRef2)
6625
6644
  )
6626
6645
  );
6627
6646
  } else if (getterFnIdentifier) {
6628
6647
  reference.replaceWith(
6629
- import_compiler35.types.callExpression(getterFnIdentifier, [
6648
+ import_compiler36.types.callExpression(getterFnIdentifier, [
6630
6649
  getScopeExpression(referenceSection, getSection(tag))
6631
6650
  ])
6632
6651
  );
@@ -6659,10 +6678,10 @@ var html_style_default = {
6659
6678
  "render",
6660
6679
  section,
6661
6680
  valueReferences,
6662
- import_compiler35.types.expressionStatement(
6681
+ import_compiler36.types.expressionStatement(
6663
6682
  callRuntime(
6664
6683
  helper,
6665
- import_compiler35.types.memberExpression(scopeIdentifier, visitAccessor, true),
6684
+ import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
6666
6685
  value
6667
6686
  )
6668
6687
  )
@@ -6677,18 +6696,18 @@ var html_style_default = {
6677
6696
  if (isEventHandler(name2)) {
6678
6697
  addHTMLEffectCall(section, valueReferences);
6679
6698
  } else {
6680
- write2`${callRuntime("attr", import_compiler35.types.stringLiteral(name2), value)}`;
6699
+ write2`${callRuntime("attr", import_compiler36.types.stringLiteral(name2), value)}`;
6681
6700
  }
6682
6701
  } else if (isEventHandler(name2)) {
6683
6702
  addStatement(
6684
6703
  "effect",
6685
6704
  section,
6686
6705
  valueReferences,
6687
- import_compiler35.types.expressionStatement(
6706
+ import_compiler36.types.expressionStatement(
6688
6707
  callRuntime(
6689
6708
  "on",
6690
- import_compiler35.types.memberExpression(scopeIdentifier, visitAccessor, true),
6691
- import_compiler35.types.stringLiteral(getEventHandlerName(name2)),
6709
+ import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
6710
+ import_compiler36.types.stringLiteral(getEventHandlerName(name2)),
6692
6711
  value
6693
6712
  )
6694
6713
  )
@@ -6698,11 +6717,11 @@ var html_style_default = {
6698
6717
  "render",
6699
6718
  section,
6700
6719
  valueReferences,
6701
- import_compiler35.types.expressionStatement(
6720
+ import_compiler36.types.expressionStatement(
6702
6721
  callRuntime(
6703
6722
  "attr",
6704
- import_compiler35.types.memberExpression(scopeIdentifier, visitAccessor, true),
6705
- import_compiler35.types.stringLiteral(name2),
6723
+ import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
6724
+ import_compiler36.types.stringLiteral(name2),
6706
6725
  value
6707
6726
  )
6708
6727
  )
@@ -6715,9 +6734,9 @@ var html_style_default = {
6715
6734
  if (isHTML) {
6716
6735
  addHTMLEffectCall(section, tagExtra.referencedBindings);
6717
6736
  if (skipExpression) {
6718
- write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler35.types.stringLiteral("style"))}`;
6737
+ write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler36.types.stringLiteral("style"))}`;
6719
6738
  } else {
6720
- write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler35.types.stringLiteral("style"))}`;
6739
+ write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler36.types.stringLiteral("style"))}`;
6721
6740
  }
6722
6741
  } else {
6723
6742
  if (skipExpression) {
@@ -6725,7 +6744,7 @@ var html_style_default = {
6725
6744
  "render",
6726
6745
  section,
6727
6746
  tagExtra.referencedBindings,
6728
- import_compiler35.types.expressionStatement(
6747
+ import_compiler36.types.expressionStatement(
6729
6748
  callRuntime(
6730
6749
  "partialAttrs",
6731
6750
  scopeIdentifier,
@@ -6740,7 +6759,7 @@ var html_style_default = {
6740
6759
  "render",
6741
6760
  section,
6742
6761
  tagExtra.referencedBindings,
6743
- import_compiler35.types.expressionStatement(
6762
+ import_compiler36.types.expressionStatement(
6744
6763
  callRuntime(
6745
6764
  "attrs",
6746
6765
  scopeIdentifier,
@@ -6754,7 +6773,7 @@ var html_style_default = {
6754
6773
  "effect",
6755
6774
  section,
6756
6775
  tagExtra.referencedBindings,
6757
- import_compiler35.types.expressionStatement(
6776
+ import_compiler36.types.expressionStatement(
6758
6777
  callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
6759
6778
  ),
6760
6779
  false
@@ -6765,9 +6784,9 @@ var html_style_default = {
6765
6784
  enter2(tag);
6766
6785
  if (isOutputHTML()) {
6767
6786
  for (const child of tag.node.body.body) {
6768
- if (import_compiler35.types.isMarkoText(child)) {
6787
+ if (import_compiler36.types.isMarkoText(child)) {
6769
6788
  write2`${child.value}`;
6770
- } else if (import_compiler35.types.isMarkoPlaceholder(child)) {
6789
+ } else if (import_compiler36.types.isMarkoPlaceholder(child)) {
6771
6790
  write2`${callRuntime("escapeStyle", child.value)}`;
6772
6791
  }
6773
6792
  }
@@ -6777,11 +6796,11 @@ var html_style_default = {
6777
6796
  let currentQuasi = "";
6778
6797
  let referencePlaceholder;
6779
6798
  for (const child of tag.node.body.body) {
6780
- if (import_compiler35.types.isMarkoText(child)) {
6799
+ if (import_compiler36.types.isMarkoText(child)) {
6781
6800
  currentQuasi += child.value;
6782
- } else if (import_compiler35.types.isMarkoPlaceholder(child)) {
6801
+ } else if (import_compiler36.types.isMarkoPlaceholder(child)) {
6783
6802
  referencePlaceholder ||= child;
6784
- templateQuasis.push(import_compiler35.types.templateElement({ raw: currentQuasi }));
6803
+ templateQuasis.push(import_compiler36.types.templateElement({ raw: currentQuasi }));
6785
6804
  templateExpressions.push(child.value);
6786
6805
  currentQuasi = "";
6787
6806
  }
@@ -6789,16 +6808,16 @@ var html_style_default = {
6789
6808
  if (!referencePlaceholder) {
6790
6809
  write2`${currentQuasi}`;
6791
6810
  } else {
6792
- templateQuasis.push(import_compiler35.types.templateElement({ raw: currentQuasi }));
6811
+ templateQuasis.push(import_compiler36.types.templateElement({ raw: currentQuasi }));
6793
6812
  addStatement(
6794
6813
  "render",
6795
6814
  getSection(tag),
6796
6815
  referencePlaceholder.value.extra?.referencedBindings,
6797
- import_compiler35.types.expressionStatement(
6816
+ import_compiler36.types.expressionStatement(
6798
6817
  callRuntime(
6799
6818
  "textContent",
6800
- import_compiler35.types.memberExpression(scopeIdentifier, visitAccessor, true),
6801
- import_compiler35.types.templateLiteral(templateQuasis, templateExpressions)
6819
+ import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
6820
+ import_compiler36.types.templateLiteral(templateQuasis, templateExpressions)
6802
6821
  )
6803
6822
  )
6804
6823
  );
@@ -6832,11 +6851,11 @@ function getUsedAttrs3(tag) {
6832
6851
  for (let i = attributes.length; i--; ) {
6833
6852
  const attr2 = attributes[i];
6834
6853
  const { value } = attr2;
6835
- if (import_compiler35.types.isMarkoSpreadAttribute(attr2)) {
6854
+ if (import_compiler36.types.isMarkoSpreadAttribute(attr2)) {
6836
6855
  if (!spreadProps) {
6837
6856
  spreadProps = [];
6838
6857
  }
6839
- spreadProps.push(import_compiler35.types.spreadElement(value));
6858
+ spreadProps.push(import_compiler36.types.spreadElement(value));
6840
6859
  } else if (!seen[attr2.name]) {
6841
6860
  seen[attr2.name] = attr2;
6842
6861
  if (spreadProps) {
@@ -6850,10 +6869,10 @@ function getUsedAttrs3(tag) {
6850
6869
  if (spreadProps) {
6851
6870
  spreadProps.reverse();
6852
6871
  for (const { name: name2 } of staticAttrs) {
6853
- (skipProps ||= []).push(toObjectProperty(name2, import_compiler35.types.numericLiteral(1)));
6872
+ (skipProps ||= []).push(toObjectProperty(name2, import_compiler36.types.numericLiteral(1)));
6854
6873
  }
6855
6874
  if (skipProps) {
6856
- skipExpression = import_compiler35.types.objectExpression(skipProps);
6875
+ skipExpression = import_compiler36.types.objectExpression(skipProps);
6857
6876
  }
6858
6877
  spreadExpression = propsToExpression(spreadProps);
6859
6878
  }
@@ -6865,20 +6884,20 @@ function getUsedAttrs3(tag) {
6865
6884
  }
6866
6885
 
6867
6886
  // src/translator/core/id.ts
6868
- var import_compiler36 = require("@marko/compiler");
6869
- var import_babel_utils26 = require("@marko/compiler/babel-utils");
6887
+ var import_compiler37 = require("@marko/compiler");
6888
+ var import_babel_utils27 = require("@marko/compiler/babel-utils");
6870
6889
  var id_default = {
6871
6890
  analyze(tag) {
6872
- (0, import_babel_utils26.assertNoArgs)(tag);
6873
- (0, import_babel_utils26.assertNoParams)(tag);
6874
- (0, import_babel_utils26.assertNoAttributes)(tag);
6891
+ (0, import_babel_utils27.assertNoArgs)(tag);
6892
+ (0, import_babel_utils27.assertNoParams)(tag);
6893
+ (0, import_babel_utils27.assertNoAttributes)(tag);
6875
6894
  assertNoBodyContent(tag);
6876
- (0, import_babel_utils26.assertNoAttributeTags)(tag);
6895
+ (0, import_babel_utils27.assertNoAttributeTags)(tag);
6877
6896
  const { node } = tag;
6878
6897
  if (!node.var) {
6879
6898
  throw tag.get("name").buildCodeFrameError("The `id` tag requires a tag variable.");
6880
6899
  }
6881
- if (!import_compiler36.types.isIdentifier(node.var)) {
6900
+ if (!import_compiler37.types.isIdentifier(node.var)) {
6882
6901
  throw tag.get("var").buildCodeFrameError("The `id` tag cannot be destructured");
6883
6902
  }
6884
6903
  trackVarReferences(tag, 4 /* derived */);
@@ -6889,7 +6908,7 @@ var id_default = {
6889
6908
  const id = isOutputHTML() ? callRuntime("nextTagId") : callRuntime("nextTagId", scopeIdentifier);
6890
6909
  if (isOutputHTML()) {
6891
6910
  tag.replaceWith(
6892
- import_compiler36.types.variableDeclaration("const", [import_compiler36.types.variableDeclarator(node.var, id)])
6911
+ import_compiler37.types.variableDeclaration("const", [import_compiler37.types.variableDeclarator(node.var, id)])
6893
6912
  );
6894
6913
  } else {
6895
6914
  const source = initValue(node.var.extra.binding);
@@ -6914,23 +6933,22 @@ var id_default = {
6914
6933
  };
6915
6934
 
6916
6935
  // src/translator/core/if.ts
6917
- var import_compiler38 = require("@marko/compiler");
6918
- var import_babel_utils27 = require("@marko/compiler/babel-utils");
6936
+ var import_compiler39 = require("@marko/compiler");
6937
+ var import_babel_utils28 = require("@marko/compiler/babel-utils");
6919
6938
 
6920
6939
  // src/translator/util/to-first-statement-or-block.ts
6921
- var import_compiler37 = require("@marko/compiler");
6940
+ var import_compiler38 = require("@marko/compiler");
6922
6941
  function toFirstStatementOrBlock(body) {
6923
6942
  if (Array.isArray(body)) {
6924
6943
  if (body.length === 1) {
6925
6944
  return body[0];
6926
6945
  }
6927
- return import_compiler37.types.blockStatement(body);
6946
+ return import_compiler38.types.blockStatement(body);
6928
6947
  }
6929
6948
  return body;
6930
6949
  }
6931
6950
 
6932
6951
  // src/translator/core/if.ts
6933
- var kBinding = Symbol("if node binding");
6934
6952
  var BRANCHES_LOOKUP = /* @__PURE__ */ new WeakMap();
6935
6953
  var IfTag = {
6936
6954
  analyze(tag) {
@@ -6946,7 +6964,7 @@ var IfTag = {
6946
6964
  if (branchBodySection) {
6947
6965
  branchBodySection.isBranch = true;
6948
6966
  branchBodySection.upstreamExpression = rootExtra;
6949
- if (!(branchBodySection.content === null || branchBodySection.content?.singleChild)) {
6967
+ if (!(branchBodySection.content === null || branchBodySection.content?.singleChild && branchBodySection.content.startType !== 4 /* Text */)) {
6950
6968
  singleNodeOptimization = false;
6951
6969
  }
6952
6970
  }
@@ -6955,15 +6973,9 @@ var IfTag = {
6955
6973
  }
6956
6974
  }
6957
6975
  const section = getOrCreateSection(tag);
6958
- rootExtra[kBinding] = createBinding(
6959
- "#text",
6960
- 0 /* dom */,
6961
- section,
6962
- void 0,
6963
- rootExtra
6964
- );
6965
- rootExtra.singleNodeOptimization = singleNodeOptimization;
6966
6976
  mergeReferences(section, rootTag.node, mergeReferenceNodes);
6977
+ getOptimizedOnlyChildNodeRef(rootTag, section, branches.length);
6978
+ rootExtra.singleNodeOptimization = singleNodeOptimization;
6967
6979
  }
6968
6980
  },
6969
6981
  translate: translateByTarget({
@@ -6972,10 +6984,10 @@ var IfTag = {
6972
6984
  if (tag.node.body.attributeTags) return;
6973
6985
  const tagBody = tag.get("body");
6974
6986
  const bodySection = getSectionForBody(tagBody);
6975
- if (isRoot(tag)) {
6987
+ if (isRoot(tag) && !isOnlyChildInParent(tag)) {
6976
6988
  visit(tag, 37 /* Replace */);
6989
+ enterShallow(tag);
6977
6990
  }
6978
- enterShallow(tag);
6979
6991
  flushBefore(tag);
6980
6992
  if (bodySection) {
6981
6993
  setSectionParentIsOwner(bodySection, true);
@@ -6987,8 +6999,8 @@ var IfTag = {
6987
6999
  const section = getSection(tag);
6988
7000
  const bodySection = getSectionForBody(tagBody);
6989
7001
  const [isLast, branches] = getBranches(tag, bodySection);
6990
- const rootExtra = branches[0][0].node.extra;
6991
- const nodeRef2 = rootExtra[kBinding];
7002
+ const [rootTag] = branches[0];
7003
+ const rootExtra = rootTag.node.extra;
6992
7004
  const isStateful = isStatefulReferences(rootExtra.referencedBindings);
6993
7005
  const singleNodeOptimization = rootExtra.singleNodeOptimization;
6994
7006
  const hasStatefulClosures = bodySection && checkStatefulClosures(bodySection, true);
@@ -7002,10 +7014,15 @@ var IfTag = {
7002
7014
  writeHTMLResumeStatements(tagBody);
7003
7015
  }
7004
7016
  if (isLast) {
7017
+ const nodeRef2 = getOptimizedOnlyChildNodeRef(rootTag, section);
7018
+ const onlyChildInParentOptimization = isOnlyChildInParent(rootTag);
7005
7019
  const nextTag = tag.getNextSibling();
7006
- const ifScopeIdIdentifier = tag.scope.generateUidIdentifier("ifScopeId");
7007
- const ifRendererIdentifier = tag.scope.generateUidIdentifier("ifRenderer");
7020
+ const ifScopeIdIdentifier = rootTag.scope.generateUidIdentifier("ifScopeId");
7021
+ const ifBranchIdentifier = rootTag.scope.generateUidIdentifier("ifBranch");
7008
7022
  let statement;
7023
+ if (onlyChildInParentOptimization) {
7024
+ getParentTag(rootTag).node.extra[kSerializeMarker] = false;
7025
+ }
7009
7026
  for (let i = branches.length; i--; ) {
7010
7027
  const [branchTag, branchBodySection] = branches[i];
7011
7028
  const bodyStatements = branchTag.node.body.body;
@@ -7016,28 +7033,19 @@ var IfTag = {
7016
7033
  );
7017
7034
  if (isStateful) {
7018
7035
  bodyStatements.push(
7019
- import_compiler38.types.expressionStatement(
7020
- callRuntime(
7021
- "register",
7022
- import_compiler38.types.assignmentExpression(
7023
- "=",
7024
- ifRendererIdentifier,
7025
- callRuntime(
7026
- "createRenderer",
7027
- import_compiler38.types.arrowFunctionExpression([], import_compiler38.types.blockStatement([]))
7028
- )
7029
- ),
7030
- import_compiler38.types.stringLiteral(
7031
- getResumeRegisterId(branchBodySection, "renderer")
7032
- )
7036
+ import_compiler39.types.expressionStatement(
7037
+ import_compiler39.types.assignmentExpression(
7038
+ "=",
7039
+ ifBranchIdentifier,
7040
+ import_compiler39.types.numericLiteral(i)
7033
7041
  )
7034
7042
  )
7035
7043
  );
7036
7044
  }
7037
7045
  if (isStateful || branchHasStatefulClosures) {
7038
7046
  bodyStatements.push(
7039
- import_compiler38.types.expressionStatement(
7040
- import_compiler38.types.assignmentExpression(
7047
+ import_compiler39.types.expressionStatement(
7048
+ import_compiler39.types.assignmentExpression(
7041
7049
  "=",
7042
7050
  ifScopeIdIdentifier,
7043
7051
  getScopeIdIdentifier(branchBodySection)
@@ -7049,7 +7057,7 @@ var IfTag = {
7049
7057
  const [testAttr] = branchTag.node.attributes;
7050
7058
  const curStatement = toFirstStatementOrBlock(bodyStatements);
7051
7059
  if (testAttr) {
7052
- statement = import_compiler38.types.ifStatement(
7060
+ statement = import_compiler39.types.ifStatement(
7053
7061
  testAttr.value,
7054
7062
  curStatement,
7055
7063
  statement
@@ -7064,21 +7072,22 @@ var IfTag = {
7064
7072
  } else {
7065
7073
  if (isStateful) {
7066
7074
  getSerializedScopeProperties(section).set(
7067
- import_compiler38.types.stringLiteral(
7075
+ import_compiler39.types.stringLiteral(
7068
7076
  getScopeAccessorLiteral(nodeRef2).value + "(" /* ConditionalRenderer */
7069
7077
  ),
7070
- ifRendererIdentifier
7078
+ ifBranchIdentifier
7071
7079
  );
7072
- const cbNode = import_compiler38.types.arrowFunctionExpression(
7080
+ const cbNode = import_compiler39.types.arrowFunctionExpression(
7073
7081
  [],
7074
- import_compiler38.types.blockStatement([statement])
7082
+ import_compiler39.types.blockStatement([statement])
7075
7083
  );
7076
- statement = import_compiler38.types.expressionStatement(
7084
+ statement = import_compiler39.types.expressionStatement(
7077
7085
  singleNodeOptimization ? callRuntime(
7078
7086
  "resumeSingleNodeConditional",
7079
7087
  cbNode,
7080
7088
  getScopeIdIdentifier(section),
7081
- getScopeAccessorLiteral(nodeRef2)
7089
+ getScopeAccessorLiteral(nodeRef2),
7090
+ onlyChildInParentOptimization && import_compiler39.types.numericLiteral(1)
7082
7091
  ) : callRuntime(
7083
7092
  "resumeConditional",
7084
7093
  cbNode,
@@ -7087,18 +7096,18 @@ var IfTag = {
7087
7096
  )
7088
7097
  );
7089
7098
  }
7090
- nextTag.insertBefore([
7091
- import_compiler38.types.variableDeclaration(
7099
+ nextTag.insertBefore(statement);
7100
+ getHTMLSectionStatements(section).push(
7101
+ import_compiler39.types.variableDeclaration(
7092
7102
  "let",
7093
7103
  [
7094
- import_compiler38.types.variableDeclarator(ifScopeIdIdentifier),
7095
- isStateful && import_compiler38.types.variableDeclarator(ifRendererIdentifier)
7104
+ import_compiler39.types.variableDeclarator(ifScopeIdIdentifier),
7105
+ isStateful && import_compiler39.types.variableDeclarator(ifBranchIdentifier)
7096
7106
  ].filter(Boolean)
7097
- ),
7098
- statement
7099
- ]);
7107
+ )
7108
+ );
7100
7109
  getSerializedScopeProperties(section).set(
7101
- import_compiler38.types.stringLiteral(
7110
+ import_compiler39.types.stringLiteral(
7102
7111
  getScopeAccessorLiteral(nodeRef2).value + "!" /* ConditionalScope */
7103
7112
  ),
7104
7113
  callRuntime("getScopeById", ifScopeIdIdentifier)
@@ -7115,10 +7124,10 @@ var IfTag = {
7115
7124
  if (bodySection) {
7116
7125
  setSectionParentIsOwner(bodySection, true);
7117
7126
  }
7118
- if (isRoot(tag)) {
7127
+ if (isRoot(tag) && !isOnlyChildInParent(tag)) {
7119
7128
  visit(tag, 37 /* Replace */);
7129
+ enterShallow(tag);
7120
7130
  }
7121
- enterShallow(tag);
7122
7131
  },
7123
7132
  exit(tag) {
7124
7133
  if (tag.node.body.attributeTags) return;
@@ -7127,38 +7136,40 @@ var IfTag = {
7127
7136
  getSectionForBody(tag.get("body"))
7128
7137
  );
7129
7138
  if (isLast) {
7130
- const section = getSection(tag);
7139
+ const [rootTag] = branches[0];
7140
+ const section = getSection(rootTag);
7131
7141
  const rootExtra = branches[0][0].node.extra;
7132
- const nodeRef2 = rootExtra[kBinding];
7133
- let expr = import_compiler38.types.nullLiteral();
7142
+ const nodeRef2 = getOptimizedOnlyChildNodeRef(rootTag, section);
7143
+ const rendererIdentifiers = [];
7144
+ let expr = import_compiler39.types.numericLiteral(branches.length);
7134
7145
  for (let i = branches.length; i--; ) {
7135
7146
  const [branchTag, branchBodySection] = branches[i];
7136
7147
  const [testAttr] = branchTag.node.attributes;
7137
- const consequent = branchBodySection ? import_compiler38.types.identifier(branchBodySection.name) : import_compiler38.types.numericLiteral(0);
7138
- setClosureSignalBuilder(
7139
- branchTag,
7140
- (_closureSignal, render, intersection) => {
7141
- return callRuntime(
7142
- "conditionalClosure",
7143
- getScopeAccessorLiteral(nodeRef2),
7144
- import_compiler38.types.arrowFunctionExpression(
7145
- [],
7146
- import_compiler38.types.identifier(branchBodySection.name)
7147
- ),
7148
- render,
7149
- intersection
7150
- );
7151
- }
7152
- );
7148
+ const consequent = import_compiler39.types.numericLiteral(branchBodySection ? i : -1);
7149
+ if (branchBodySection) {
7150
+ rendererIdentifiers.push(import_compiler39.types.identifier(branchBodySection.name));
7151
+ setClosureSignalBuilder(
7152
+ branchTag,
7153
+ (_closureSignal, render, intersection) => {
7154
+ return callRuntime(
7155
+ "conditionalClosure",
7156
+ getScopeAccessorLiteral(nodeRef2),
7157
+ import_compiler39.types.numericLiteral(i),
7158
+ render,
7159
+ intersection
7160
+ );
7161
+ }
7162
+ );
7163
+ }
7153
7164
  branchTag.remove();
7154
- expr = testAttr ? import_compiler38.types.conditionalExpression(testAttr.value, consequent, expr) : consequent;
7165
+ expr = testAttr ? import_compiler39.types.conditionalExpression(testAttr.value, consequent, expr) : consequent;
7155
7166
  }
7156
7167
  const signal = getSignal(section, nodeRef2, "if");
7157
7168
  signal.build = () => {
7158
7169
  return callRuntime(
7159
7170
  "conditional",
7160
7171
  getScopeAccessorLiteral(nodeRef2),
7161
- getSignalFn(signal, [scopeIdentifier])
7172
+ ...rendererIdentifiers.reverse()
7162
7173
  );
7163
7174
  };
7164
7175
  signal.hasDownstreamIntersections = () => branches.some(([, bodySection]) => bodySection?.closures);
@@ -7196,9 +7207,9 @@ var ElseTag = {
7196
7207
  ]
7197
7208
  };
7198
7209
  function assertValidCondition(tag) {
7199
- (0, import_babel_utils27.assertNoVar)(tag);
7200
- (0, import_babel_utils27.assertNoArgs)(tag);
7201
- (0, import_babel_utils27.assertNoParams)(tag);
7210
+ (0, import_babel_utils28.assertNoVar)(tag);
7211
+ (0, import_babel_utils28.assertNoArgs)(tag);
7212
+ (0, import_babel_utils28.assertNoParams)(tag);
7202
7213
  assertHasBody(tag);
7203
7214
  assertNoSpreadAttrs(tag);
7204
7215
  switch (getTagName(tag)) {
@@ -7234,7 +7245,7 @@ function assertHasBody(tag) {
7234
7245
  function assertHasValueAttribute(tag) {
7235
7246
  const { node } = tag;
7236
7247
  const [valueAttr] = node.attributes;
7237
- if (!import_compiler38.types.isMarkoAttribute(valueAttr) || !valueAttr.default) {
7248
+ if (!import_compiler39.types.isMarkoAttribute(valueAttr) || !valueAttr.default) {
7238
7249
  throw tag.get("name").buildCodeFrameError(`The \`${getTagName(tag)}\` tag requires a value.`);
7239
7250
  }
7240
7251
  if (node.attributes.length > 1) {
@@ -7286,12 +7297,12 @@ function isRoot(tag) {
7286
7297
  }
7287
7298
 
7288
7299
  // src/translator/core/import.ts
7289
- var import_babel_utils28 = require("@marko/compiler/babel-utils");
7300
+ var import_babel_utils29 = require("@marko/compiler/babel-utils");
7290
7301
  var import_default = {
7291
7302
  parse(tag) {
7292
7303
  const { node } = tag;
7293
7304
  tag.replaceWith(
7294
- (0, import_babel_utils28.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
7305
+ (0, import_babel_utils29.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
7295
7306
  );
7296
7307
  },
7297
7308
  parseOptions: {
@@ -7309,8 +7320,8 @@ var import_default = {
7309
7320
  };
7310
7321
 
7311
7322
  // src/translator/core/let.ts
7312
- var import_compiler39 = require("@marko/compiler");
7313
- var import_babel_utils29 = require("@marko/compiler/babel-utils");
7323
+ var import_compiler40 = require("@marko/compiler");
7324
+ var import_babel_utils30 = require("@marko/compiler/babel-utils");
7314
7325
  var let_default = {
7315
7326
  analyze(tag) {
7316
7327
  const { node } = tag;
@@ -7318,7 +7329,7 @@ var let_default = {
7318
7329
  let valueAttr;
7319
7330
  let valueChangeAttr;
7320
7331
  for (const attr2 of node.attributes) {
7321
- if (import_compiler39.types.isMarkoAttribute(attr2)) {
7332
+ if (import_compiler40.types.isMarkoAttribute(attr2)) {
7322
7333
  if (attr2.name === "value") {
7323
7334
  valueAttr = attr2;
7324
7335
  } else if (attr2.name === "valueChange") {
@@ -7339,17 +7350,17 @@ var let_default = {
7339
7350
  }
7340
7351
  }
7341
7352
  }
7342
- (0, import_babel_utils29.assertNoArgs)(tag);
7343
- (0, import_babel_utils29.assertNoParams)(tag);
7353
+ (0, import_babel_utils30.assertNoArgs)(tag);
7354
+ (0, import_babel_utils30.assertNoParams)(tag);
7344
7355
  assertNoBodyContent(tag);
7345
7356
  assertNoSpreadAttrs(tag);
7346
7357
  if (!tagVar) {
7347
7358
  throw tag.get("name").buildCodeFrameError("The `let` tag requires a tag variable.");
7348
7359
  }
7349
- if (!import_compiler39.types.isIdentifier(tagVar)) {
7360
+ if (!import_compiler40.types.isIdentifier(tagVar)) {
7350
7361
  throw tag.get("var").buildCodeFrameError("The `let` tag variable cannot be destructured.");
7351
7362
  }
7352
- if (valueChangeAttr && (0, import_babel_utils29.computeNode)(valueChangeAttr.value)) {
7363
+ if (valueChangeAttr && (0, import_babel_utils30.computeNode)(valueChangeAttr.value)) {
7353
7364
  throw tag.get("attributes").find((attr2) => attr2.node === valueChangeAttr).get("value").buildCodeFrameError(
7354
7365
  "The `let` tag `valueChange` attribute must be a function."
7355
7366
  );
@@ -7365,10 +7376,10 @@ var let_default = {
7365
7376
  const { node } = tag;
7366
7377
  const tagVar = node.var;
7367
7378
  const valueAttr = node.attributes.find(
7368
- (attr2) => import_compiler39.types.isMarkoAttribute(attr2) && (attr2.default || attr2.name === "value")
7369
- ) ?? import_compiler39.types.markoAttribute("value", import_compiler39.types.identifier("undefined"));
7379
+ (attr2) => import_compiler40.types.isMarkoAttribute(attr2) && (attr2.default || attr2.name === "value")
7380
+ ) ?? import_compiler40.types.markoAttribute("value", import_compiler40.types.identifier("undefined"));
7370
7381
  const valueChangeAttr = node.attributes.find(
7371
- (attr2) => import_compiler39.types.isMarkoAttribute(attr2) && attr2.name === "valueChange"
7382
+ (attr2) => import_compiler40.types.isMarkoAttribute(attr2) && attr2.name === "valueChange"
7372
7383
  );
7373
7384
  const section = getSection(tag);
7374
7385
  const binding = tagVar.extra.binding;
@@ -7381,13 +7392,13 @@ var let_default = {
7381
7392
  }
7382
7393
  signal.buildAssignment = (valueSection, value) => {
7383
7394
  const scope = getScopeExpression(valueSection, signal.section);
7384
- return import_compiler39.types.callExpression(signal.identifier, [scope, value]);
7395
+ return import_compiler40.types.callExpression(signal.identifier, [scope, value]);
7385
7396
  };
7386
7397
  } else {
7387
7398
  translateVar(tag, valueAttr.value);
7388
7399
  if (valueChangeAttr) {
7389
7400
  getSerializedScopeProperties(section).set(
7390
- import_compiler39.types.stringLiteral(
7401
+ import_compiler40.types.stringLiteral(
7391
7402
  getScopeAccessorLiteral(binding).value + "@" /* TagVariableChange */
7392
7403
  ),
7393
7404
  valueChangeAttr.value
@@ -7411,14 +7422,14 @@ var let_default = {
7411
7422
  };
7412
7423
 
7413
7424
  // src/translator/core/lifecycle.ts
7414
- var import_compiler40 = require("@marko/compiler");
7415
- var import_babel_utils30 = require("@marko/compiler/babel-utils");
7425
+ var import_compiler41 = require("@marko/compiler");
7426
+ var import_babel_utils31 = require("@marko/compiler/babel-utils");
7416
7427
  var kRef = Symbol("lifecycle attrs reference");
7417
7428
  var lifecycle_default = {
7418
7429
  analyze(tag) {
7419
- (0, import_babel_utils30.assertNoArgs)(tag);
7420
- (0, import_babel_utils30.assertNoVar)(tag);
7421
- (0, import_babel_utils30.assertNoParams)(tag);
7430
+ (0, import_babel_utils31.assertNoArgs)(tag);
7431
+ (0, import_babel_utils31.assertNoVar)(tag);
7432
+ (0, import_babel_utils31.assertNoParams)(tag);
7422
7433
  assertNoBodyContent(tag);
7423
7434
  const { node } = tag;
7424
7435
  const tagExtra = node.extra ??= {};
@@ -7436,7 +7447,7 @@ var lifecycle_default = {
7436
7447
  );
7437
7448
  }
7438
7449
  for (const attr2 of node.attributes) {
7439
- if (import_compiler40.types.isMarkoSpreadAttribute(attr2)) {
7450
+ if (import_compiler41.types.isMarkoSpreadAttribute(attr2)) {
7440
7451
  throw tag.get("name").buildCodeFrameError(
7441
7452
  "The `lifecycle` tag does not support `...spread` attributes."
7442
7453
  );
@@ -7456,7 +7467,7 @@ var lifecycle_default = {
7456
7467
  if (isOutputDOM()) {
7457
7468
  const translatedAttrs = translateAttrs(tag);
7458
7469
  translatedAttrs.statements.push(
7459
- import_compiler40.types.expressionStatement(
7470
+ import_compiler41.types.expressionStatement(
7460
7471
  callRuntime(
7461
7472
  "lifecycle",
7462
7473
  scopeIdentifier,
@@ -7491,19 +7502,19 @@ var lifecycle_default = {
7491
7502
  };
7492
7503
 
7493
7504
  // src/translator/core/log.ts
7494
- var import_compiler41 = require("@marko/compiler");
7495
- var import_babel_utils31 = require("@marko/compiler/babel-utils");
7505
+ var import_compiler42 = require("@marko/compiler");
7506
+ var import_babel_utils32 = require("@marko/compiler/babel-utils");
7496
7507
  var log_default = {
7497
7508
  analyze(tag) {
7498
7509
  const [valueAttr] = tag.node.attributes;
7499
- (0, import_babel_utils31.assertNoArgs)(tag);
7500
- (0, import_babel_utils31.assertNoVar)(tag);
7501
- (0, import_babel_utils31.assertNoParams)(tag);
7510
+ (0, import_babel_utils32.assertNoArgs)(tag);
7511
+ (0, import_babel_utils32.assertNoVar)(tag);
7512
+ (0, import_babel_utils32.assertNoParams)(tag);
7502
7513
  assertNoBodyContent(tag);
7503
7514
  if (!valueAttr) {
7504
7515
  throw tag.get("name").buildCodeFrameError("The `log` tag requires a value.");
7505
7516
  }
7506
- if (tag.node.attributes.length > 1 || !import_compiler41.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
7517
+ if (tag.node.attributes.length > 1 || !import_compiler42.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
7507
7518
  throw tag.get("name").buildCodeFrameError(
7508
7519
  "The `log` tag only supports the `value` attribute."
7509
7520
  );
@@ -7515,9 +7526,9 @@ var log_default = {
7515
7526
  const [valueAttr] = tag.node.attributes;
7516
7527
  const { value } = valueAttr;
7517
7528
  const referencedBindings = value.extra?.referencedBindings;
7518
- const statement = import_compiler41.types.expressionStatement(
7519
- import_compiler41.types.callExpression(
7520
- import_compiler41.types.memberExpression(import_compiler41.types.identifier("console"), import_compiler41.types.identifier("log")),
7529
+ const statement = import_compiler42.types.expressionStatement(
7530
+ import_compiler42.types.callExpression(
7531
+ import_compiler42.types.memberExpression(import_compiler42.types.identifier("console"), import_compiler42.types.identifier("log")),
7521
7532
  [value]
7522
7533
  )
7523
7534
  );
@@ -7543,8 +7554,8 @@ var log_default = {
7543
7554
  };
7544
7555
 
7545
7556
  // src/translator/core/script.ts
7546
- var import_compiler42 = require("@marko/compiler");
7547
- var import_babel_utils32 = require("@marko/compiler/babel-utils");
7557
+ var import_compiler43 = require("@marko/compiler");
7558
+ var import_babel_utils33 = require("@marko/compiler/babel-utils");
7548
7559
  var htmlScriptTagAlternateMsg = " For a native html `script` tag use the `html-script` core tag instead.";
7549
7560
  var script_default = {
7550
7561
  parse(tag) {
@@ -7564,22 +7575,22 @@ var script_default = {
7564
7575
  }
7565
7576
  const start = body[0]?.start;
7566
7577
  const end = body[body.length - 1]?.end;
7567
- const bodyStatements = (0, import_babel_utils32.parseStatements)(tag.hub.file, code, start, end);
7568
- const valueFn = import_compiler42.types.arrowFunctionExpression(
7578
+ const bodyStatements = (0, import_babel_utils33.parseStatements)(tag.hub.file, code, start, end);
7579
+ const valueFn = import_compiler43.types.arrowFunctionExpression(
7569
7580
  [],
7570
- import_compiler42.types.blockStatement(bodyStatements),
7581
+ import_compiler43.types.blockStatement(bodyStatements),
7571
7582
  traverseContains(bodyStatements, isAwaitExpression)
7572
7583
  );
7573
- node.attributes.push(import_compiler42.types.markoAttribute("value", valueFn));
7584
+ node.attributes.push(import_compiler43.types.markoAttribute("value", valueFn));
7574
7585
  node.body.body = [];
7575
7586
  }
7576
7587
  },
7577
7588
  analyze(tag) {
7578
7589
  const { node } = tag;
7579
- (0, import_babel_utils32.assertNoArgs)(tag);
7580
- (0, import_babel_utils32.assertNoParams)(tag);
7590
+ (0, import_babel_utils33.assertNoArgs)(tag);
7591
+ (0, import_babel_utils33.assertNoParams)(tag);
7581
7592
  assertNoBodyContent(tag);
7582
- (0, import_babel_utils32.assertNoAttributeTags)(tag);
7593
+ (0, import_babel_utils33.assertNoAttributeTags)(tag);
7583
7594
  if (node.var) {
7584
7595
  throw tag.hub.buildError(
7585
7596
  node.var,
@@ -7619,28 +7630,28 @@ var script_default = {
7619
7630
  const referencedBindings = value.extra?.referencedBindings;
7620
7631
  if (isOutputDOM()) {
7621
7632
  const { value: value2 } = valueAttr;
7622
- const isFunction2 = import_compiler42.types.isFunctionExpression(value2) || import_compiler42.types.isArrowFunctionExpression(value2);
7633
+ const isFunction2 = import_compiler43.types.isFunctionExpression(value2) || import_compiler43.types.isArrowFunctionExpression(value2);
7623
7634
  let inlineBody = null;
7624
7635
  if (isFunction2 && !(value2.async || value2.generator)) {
7625
- if (import_compiler42.types.isBlockStatement(value2.body)) {
7636
+ if (import_compiler43.types.isBlockStatement(value2.body)) {
7626
7637
  let hasDeclaration = false;
7627
7638
  for (const child of value2.body.body) {
7628
- if (import_compiler42.types.isDeclaration(child)) {
7639
+ if (import_compiler43.types.isDeclaration(child)) {
7629
7640
  hasDeclaration = true;
7630
7641
  break;
7631
7642
  }
7632
7643
  }
7633
7644
  inlineBody = hasDeclaration ? value2.body : value2.body.body;
7634
7645
  } else {
7635
- inlineBody = import_compiler42.types.expressionStatement(value2.body);
7646
+ inlineBody = import_compiler43.types.expressionStatement(value2.body);
7636
7647
  }
7637
7648
  }
7638
7649
  addStatement(
7639
7650
  "effect",
7640
7651
  section,
7641
7652
  referencedBindings,
7642
- inlineBody || import_compiler42.types.expressionStatement(
7643
- import_compiler42.types.callExpression(value2, isFunction2 ? [] : [scopeIdentifier])
7653
+ inlineBody || import_compiler43.types.expressionStatement(
7654
+ import_compiler43.types.callExpression(value2, isFunction2 ? [] : [scopeIdentifier])
7644
7655
  )
7645
7656
  );
7646
7657
  } else {
@@ -7680,8 +7691,8 @@ function isAwaitExpression(node) {
7680
7691
  }
7681
7692
 
7682
7693
  // src/translator/core/server.ts
7683
- var import_compiler43 = require("@marko/compiler");
7684
- var import_babel_utils33 = require("@marko/compiler/babel-utils");
7694
+ var import_compiler44 = require("@marko/compiler");
7695
+ var import_babel_utils34 = require("@marko/compiler/babel-utils");
7685
7696
  var server_default = {
7686
7697
  parse(tag) {
7687
7698
  const {
@@ -7691,11 +7702,11 @@ var server_default = {
7691
7702
  const rawValue = node.rawValue;
7692
7703
  const code = rawValue.replace(/^server\s*/, "").trim();
7693
7704
  const start = node.name.start + (rawValue.length - code.length);
7694
- let body = (0, import_babel_utils33.parseStatements)(file, code, start, start + code.length);
7695
- if (body.length === 1 && import_compiler43.types.isBlockStatement(body[0])) {
7705
+ let body = (0, import_babel_utils34.parseStatements)(file, code, start, start + code.length);
7706
+ if (body.length === 1 && import_compiler44.types.isBlockStatement(body[0])) {
7696
7707
  body = body[0].body;
7697
7708
  }
7698
- tag.replaceWith(import_compiler43.types.markoScriptlet(body, true, "server"));
7709
+ tag.replaceWith(import_compiler44.types.markoScriptlet(body, true, "server"));
7699
7710
  },
7700
7711
  parseOptions: {
7701
7712
  statement: true,
@@ -7711,8 +7722,8 @@ var server_default = {
7711
7722
  };
7712
7723
 
7713
7724
  // src/translator/core/static.ts
7714
- var import_compiler44 = require("@marko/compiler");
7715
- var import_babel_utils34 = require("@marko/compiler/babel-utils");
7725
+ var import_compiler45 = require("@marko/compiler");
7726
+ var import_babel_utils35 = require("@marko/compiler/babel-utils");
7716
7727
  var static_default = {
7717
7728
  parse(tag) {
7718
7729
  const {
@@ -7722,11 +7733,11 @@ var static_default = {
7722
7733
  const rawValue = node.rawValue;
7723
7734
  const code = rawValue.replace(/^static\s*/, "").trim();
7724
7735
  const start = node.name.start + (rawValue.length - code.length);
7725
- let body = (0, import_babel_utils34.parseStatements)(file, code, start, start + code.length);
7726
- if (body.length === 1 && import_compiler44.types.isBlockStatement(body[0])) {
7736
+ let body = (0, import_babel_utils35.parseStatements)(file, code, start, start + code.length);
7737
+ if (body.length === 1 && import_compiler45.types.isBlockStatement(body[0])) {
7727
7738
  body = body[0].body;
7728
7739
  }
7729
- tag.replaceWith(import_compiler44.types.markoScriptlet(body, true));
7740
+ tag.replaceWith(import_compiler45.types.markoScriptlet(body, true));
7730
7741
  },
7731
7742
  parseOptions: {
7732
7743
  statement: true,
@@ -7742,17 +7753,17 @@ var static_default = {
7742
7753
  };
7743
7754
 
7744
7755
  // src/translator/core/style.ts
7745
- var import_compiler45 = require("@marko/compiler");
7746
- var import_babel_utils35 = require("@marko/compiler/babel-utils");
7756
+ var import_compiler46 = require("@marko/compiler");
7757
+ var import_babel_utils36 = require("@marko/compiler/babel-utils");
7747
7758
  var import_magic_string = __toESM(require("magic-string"));
7748
7759
  var import_path3 = __toESM(require("path"));
7749
7760
  var STYLE_EXT_REG = /^style((?:\.[a-zA-Z0-9$_-]+)+)?/;
7750
7761
  var htmlStyleTagAlternateMsg = " For a native html `style` tag use the `html-style` core tag instead.";
7751
7762
  var style_default = {
7752
7763
  analyze(tag) {
7753
- (0, import_babel_utils35.assertNoArgs)(tag);
7754
- (0, import_babel_utils35.assertNoParams)(tag);
7755
- (0, import_babel_utils35.assertNoAttributeTags)(tag);
7764
+ (0, import_babel_utils36.assertNoArgs)(tag);
7765
+ (0, import_babel_utils36.assertNoParams)(tag);
7766
+ (0, import_babel_utils36.assertNoAttributeTags)(tag);
7756
7767
  const { node } = tag;
7757
7768
  const ext = STYLE_EXT_REG.exec(node.rawValue || "")?.[1]?.slice(1);
7758
7769
  for (const attr2 of node.attributes) {
@@ -7791,8 +7802,8 @@ var style_default = {
7791
7802
  }
7792
7803
  const markoText = node.body.body[0];
7793
7804
  const { resolveVirtualDependency } = getMarkoOpts();
7794
- const start = (0, import_babel_utils35.getStart)(file, markoText);
7795
- const end = (0, import_babel_utils35.getEnd)(file, markoText);
7805
+ const start = (0, import_babel_utils36.getStart)(file, markoText);
7806
+ const end = (0, import_babel_utils36.getEnd)(file, markoText);
7796
7807
  let code = markoText.value;
7797
7808
  let map;
7798
7809
  if (resolveVirtualDependency && sourceMaps && start !== null && end !== null) {
@@ -7820,23 +7831,23 @@ var style_default = {
7820
7831
  if (!node.var) {
7821
7832
  currentProgramPath.pushContainer(
7822
7833
  "body",
7823
- import_compiler45.types.importDeclaration([], import_compiler45.types.stringLiteral(importPath))
7834
+ import_compiler46.types.importDeclaration([], import_compiler46.types.stringLiteral(importPath))
7824
7835
  );
7825
- } else if (import_compiler45.types.isIdentifier(node.var)) {
7836
+ } else if (import_compiler46.types.isIdentifier(node.var)) {
7826
7837
  currentProgramPath.pushContainer(
7827
7838
  "body",
7828
- import_compiler45.types.importDeclaration(
7829
- [import_compiler45.types.importDefaultSpecifier(node.var)],
7830
- import_compiler45.types.stringLiteral(importPath)
7839
+ import_compiler46.types.importDeclaration(
7840
+ [import_compiler46.types.importDefaultSpecifier(node.var)],
7841
+ import_compiler46.types.stringLiteral(importPath)
7831
7842
  )
7832
7843
  );
7833
7844
  } else {
7834
7845
  currentProgramPath.pushContainer(
7835
7846
  "body",
7836
- import_compiler45.types.variableDeclaration("const", [
7837
- import_compiler45.types.variableDeclarator(
7847
+ import_compiler46.types.variableDeclaration("const", [
7848
+ import_compiler46.types.variableDeclarator(
7838
7849
  node.var,
7839
- (0, import_babel_utils35.importDefault)(file, importPath, "style")
7850
+ (0, import_babel_utils36.importDefault)(file, importPath, "style")
7840
7851
  )
7841
7852
  ])
7842
7853
  );
@@ -7854,14 +7865,14 @@ var style_default = {
7854
7865
  };
7855
7866
 
7856
7867
  // src/translator/core/try.ts
7857
- var import_compiler46 = require("@marko/compiler");
7858
- var import_babel_utils36 = require("@marko/compiler/babel-utils");
7868
+ var import_compiler47 = require("@marko/compiler");
7869
+ var import_babel_utils37 = require("@marko/compiler/babel-utils");
7859
7870
  var try_default = {
7860
7871
  analyze(tag) {
7861
- (0, import_babel_utils36.assertNoVar)(tag);
7862
- (0, import_babel_utils36.assertNoArgs)(tag);
7863
- (0, import_babel_utils36.assertNoParams)(tag);
7864
- (0, import_babel_utils36.assertNoAttributes)(tag);
7872
+ (0, import_babel_utils37.assertNoVar)(tag);
7873
+ (0, import_babel_utils37.assertNoArgs)(tag);
7874
+ (0, import_babel_utils37.assertNoParams)(tag);
7875
+ (0, import_babel_utils37.assertNoAttributes)(tag);
7865
7876
  assertNoSpreadAttrs(tag);
7866
7877
  analyzeAttributeTags(tag);
7867
7878
  const { node } = tag;
@@ -7888,7 +7899,7 @@ var try_default = {
7888
7899
  writeHTMLResumeStatements(tagBody);
7889
7900
  tag.insertBefore(translatedAttrs.statements);
7890
7901
  tag.replaceWith(
7891
- import_compiler46.types.expressionStatement(
7902
+ import_compiler47.types.expressionStatement(
7892
7903
  callRuntime(
7893
7904
  "tryContent",
7894
7905
  propsToExpression(translatedAttrs.properties)
@@ -8002,8 +8013,8 @@ var document_type_default = {
8002
8013
  };
8003
8014
 
8004
8015
  // src/translator/visitors/function.ts
8005
- var import_compiler47 = require("@marko/compiler");
8006
- var import_babel_utils37 = require("@marko/compiler/babel-utils");
8016
+ var import_compiler48 = require("@marko/compiler");
8017
+ var import_babel_utils38 = require("@marko/compiler/babel-utils");
8007
8018
  var functionIdsBySection = /* @__PURE__ */ new WeakMap();
8008
8019
  var function_default = {
8009
8020
  analyze(fn) {
@@ -8014,14 +8025,14 @@ var function_default = {
8014
8025
  if (markoRoot && (markoRoot.isMarkoPlaceholder() || markoRoot.isMarkoScriptlet() && markoRoot.node.target === "server")) {
8015
8026
  return;
8016
8027
  }
8017
- if (isMarkoAttribute(markoRoot) && ((0, import_babel_utils37.isNativeTag)(markoRoot.parentPath) && /^on[A-Z-]/.test(markoRoot.node.name) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))) {
8028
+ if (isMarkoAttribute(markoRoot) && ((0, import_babel_utils38.isNativeTag)(markoRoot.parentPath) && /^on[A-Z-]/.test(markoRoot.node.name) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))) {
8018
8029
  return;
8019
8030
  }
8020
8031
  const { node } = fn;
8021
8032
  const extra = node.extra ??= {};
8022
- const name2 = extra.name = fn.node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ? import_compiler47.types.toIdentifier(
8033
+ const name2 = extra.name = fn.node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ? import_compiler48.types.toIdentifier(
8023
8034
  markoRoot.parentPath.has("var") ? markoRoot.parentPath.get("var") : markoRoot.parentPath.get("name")
8024
- ) : markoRoot.node.name : import_compiler47.types.isVariableDeclarator(fn.parent) && import_compiler47.types.isIdentifier(fn.parent.id) ? fn.parent.id.name : import_compiler47.types.isObjectMethod(node) && import_compiler47.types.isIdentifier(node.key) ? node.key.name : "anonymous");
8035
+ ) : markoRoot.node.name : import_compiler48.types.isVariableDeclarator(fn.parent) && import_compiler48.types.isIdentifier(fn.parent.id) ? fn.parent.id.name : import_compiler48.types.isObjectMethod(node) && import_compiler48.types.isIdentifier(node.key) ? node.key.name : "anonymous");
8025
8036
  const {
8026
8037
  markoOpts,
8027
8038
  opts: { filename }
@@ -8037,10 +8048,11 @@ var function_default = {
8037
8048
  if (index === void 0) {
8038
8049
  functionNameCounts.set(name2, 0);
8039
8050
  } else {
8051
+ functionNameCounts.set(name2, index + 1);
8040
8052
  id = `_${index}`;
8041
8053
  }
8042
8054
  extra.section = section;
8043
- extra.registerId = (0, import_babel_utils37.getTemplateId)(
8055
+ extra.registerId = (0, import_babel_utils38.getTemplateId)(
8044
8056
  markoOpts,
8045
8057
  filename,
8046
8058
  `${section.id}/${name2 + id}`
@@ -8052,13 +8064,13 @@ function isMarkoAttribute(path5) {
8052
8064
  }
8053
8065
 
8054
8066
  // src/translator/visitors/import-declaration.ts
8055
- var import_babel_utils38 = require("@marko/compiler/babel-utils");
8067
+ var import_babel_utils39 = require("@marko/compiler/babel-utils");
8056
8068
  var import_declaration_default = {
8057
8069
  analyze(importDecl) {
8058
8070
  const { node } = importDecl;
8059
8071
  const { source } = node;
8060
8072
  const { value } = source;
8061
- const tagImport = (0, import_babel_utils38.resolveTagImport)(importDecl, value);
8073
+ const tagImport = (0, import_babel_utils39.resolveTagImport)(importDecl, value);
8062
8074
  if (tagImport) {
8063
8075
  node.extra ??= {};
8064
8076
  node.extra.tagImport = tagImport;
@@ -8081,15 +8093,15 @@ var import_declaration_default = {
8081
8093
  };
8082
8094
 
8083
8095
  // src/translator/visitors/placeholder.ts
8084
- var import_compiler48 = require("@marko/compiler");
8085
- var kBinding2 = Symbol("placeholder node binding");
8096
+ var import_compiler49 = require("@marko/compiler");
8097
+ var kBinding = Symbol("placeholder node binding");
8086
8098
  var kSiblingText = Symbol("placeholder has sibling text");
8087
8099
  var placeholder_default = {
8088
8100
  analyze(placeholder) {
8089
8101
  const { node } = placeholder;
8090
8102
  const { confident, computed } = evaluate(node.value);
8091
8103
  if (!(confident && (node.escape || isVoid2(computed)))) {
8092
- (node.extra ??= {})[kBinding2] = createBinding(
8104
+ (node.extra ??= {})[kBinding] = createBinding(
8093
8105
  "#text",
8094
8106
  0 /* dom */,
8095
8107
  getOrCreateSection(placeholder),
@@ -8111,7 +8123,7 @@ var placeholder_default = {
8111
8123
  const isHTML = isOutputHTML();
8112
8124
  const write2 = writeTo(placeholder);
8113
8125
  const extra = node.extra || {};
8114
- const nodeBinding = extra[kBinding2];
8126
+ const nodeBinding = extra[kBinding];
8115
8127
  const canWriteHTML = isHTML || confident && node.escape;
8116
8128
  const method = canWriteHTML ? node.escape ? "escapeXML" : "toString" : node.escape ? "data" : "html";
8117
8129
  const isStateful = isStatefulReferences(referencedBindings);
@@ -8140,10 +8152,10 @@ var placeholder_default = {
8140
8152
  "render",
8141
8153
  getSection(placeholder),
8142
8154
  value.extra?.referencedBindings,
8143
- import_compiler48.types.expressionStatement(
8155
+ import_compiler49.types.expressionStatement(
8144
8156
  method === "data" ? callRuntime(
8145
8157
  "data",
8146
- import_compiler48.types.memberExpression(
8158
+ import_compiler49.types.memberExpression(
8147
8159
  scopeIdentifier,
8148
8160
  getScopeAccessorLiteral(nodeBinding),
8149
8161
  true
@@ -8180,7 +8192,7 @@ function analyzeSiblingText(placeholder) {
8180
8192
  break;
8181
8193
  }
8182
8194
  }
8183
- if (!prev.node && import_compiler48.types.isProgram(placeholder.parentPath)) {
8195
+ if (!prev.node && import_compiler49.types.isProgram(placeholder.parentPath)) {
8184
8196
  return placeholderExtra[kSiblingText] = 1 /* Before */;
8185
8197
  }
8186
8198
  let next = placeholder.getNextSibling();
@@ -8197,7 +8209,7 @@ function analyzeSiblingText(placeholder) {
8197
8209
  break;
8198
8210
  }
8199
8211
  }
8200
- if (!next.node && import_compiler48.types.isProgram(placeholder.parentPath)) {
8212
+ if (!next.node && import_compiler49.types.isProgram(placeholder.parentPath)) {
8201
8213
  return placeholderExtra[kSiblingText] = 2 /* After */;
8202
8214
  }
8203
8215
  return placeholderExtra[kSiblingText] = 0 /* None */;
@@ -8207,7 +8219,7 @@ function isVoid2(value) {
8207
8219
  }
8208
8220
 
8209
8221
  // src/translator/visitors/referenced-identifier.ts
8210
- var import_compiler49 = require("@marko/compiler");
8222
+ var import_compiler50 = require("@marko/compiler");
8211
8223
  var abortIdsByExpressionForSection = /* @__PURE__ */ new WeakMap();
8212
8224
  var referenced_identifier_default = {
8213
8225
  migrate(identifier) {
@@ -8215,8 +8227,8 @@ var referenced_identifier_default = {
8215
8227
  if (identifier.scope.hasBinding(name2)) return;
8216
8228
  switch (name2) {
8217
8229
  case "out":
8218
- if (import_compiler49.types.isMemberExpression(identifier.parent) && import_compiler49.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") {
8219
- identifier.parentPath.replaceWith(import_compiler49.types.identifier("$global"));
8230
+ if (import_compiler50.types.isMemberExpression(identifier.parent) && import_compiler50.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") {
8231
+ identifier.parentPath.replaceWith(import_compiler50.types.identifier("$global"));
8220
8232
  } else {
8221
8233
  throw identifier.buildCodeFrameError(
8222
8234
  "Only `out.global` is supported for compatibility."
@@ -8243,24 +8255,24 @@ var referenced_identifier_default = {
8243
8255
  case "$global":
8244
8256
  if (isOutputHTML()) {
8245
8257
  identifier.replaceWith(
8246
- import_compiler49.types.callExpression(importRuntime("$global"), [])
8258
+ import_compiler50.types.callExpression(importRuntime("$global"), [])
8247
8259
  );
8248
8260
  } else {
8249
8261
  identifier.replaceWith(
8250
- import_compiler49.types.memberExpression(scopeIdentifier, import_compiler49.types.identifier("$global"))
8262
+ import_compiler50.types.memberExpression(scopeIdentifier, import_compiler50.types.identifier("$global"))
8251
8263
  );
8252
8264
  }
8253
8265
  break;
8254
8266
  case "$signal":
8255
8267
  if (isOutputHTML()) {
8256
8268
  identifier.replaceWith(
8257
- import_compiler49.types.callExpression(
8258
- import_compiler49.types.arrowFunctionExpression(
8269
+ import_compiler50.types.callExpression(
8270
+ import_compiler50.types.arrowFunctionExpression(
8259
8271
  [],
8260
- import_compiler49.types.blockStatement([
8261
- import_compiler49.types.throwStatement(
8262
- import_compiler49.types.newExpression(import_compiler49.types.identifier("Error"), [
8263
- import_compiler49.types.stringLiteral("Cannot use $signal in a server render.")
8272
+ import_compiler50.types.blockStatement([
8273
+ import_compiler50.types.throwStatement(
8274
+ import_compiler50.types.newExpression(import_compiler50.types.identifier("Error"), [
8275
+ import_compiler50.types.stringLiteral("Cannot use $signal in a server render.")
8264
8276
  ])
8265
8277
  )
8266
8278
  ])
@@ -8286,18 +8298,18 @@ var referenced_identifier_default = {
8286
8298
  "render",
8287
8299
  section,
8288
8300
  exprRoot.node.extra?.referencedBindings,
8289
- import_compiler49.types.expressionStatement(
8290
- import_compiler49.types.callExpression(importRuntime("resetAbortSignal"), [
8301
+ import_compiler50.types.expressionStatement(
8302
+ import_compiler50.types.callExpression(importRuntime("resetAbortSignal"), [
8291
8303
  scopeIdentifier,
8292
- import_compiler49.types.numericLiteral(exprId)
8304
+ import_compiler50.types.numericLiteral(exprId)
8293
8305
  ])
8294
8306
  )
8295
8307
  );
8296
8308
  }
8297
8309
  identifier.replaceWith(
8298
- import_compiler49.types.callExpression(importRuntime("getAbortSignal"), [
8310
+ import_compiler50.types.callExpression(importRuntime("getAbortSignal"), [
8299
8311
  scopeIdentifier,
8300
- import_compiler49.types.numericLiteral(exprId)
8312
+ import_compiler50.types.numericLiteral(exprId)
8301
8313
  ])
8302
8314
  );
8303
8315
  }
@@ -8337,21 +8349,21 @@ var scriptlet_default = {
8337
8349
  };
8338
8350
 
8339
8351
  // src/translator/visitors/tag/index.ts
8340
- var import_compiler53 = require("@marko/compiler");
8341
- var import_babel_utils42 = require("@marko/compiler/babel-utils");
8352
+ var import_compiler54 = require("@marko/compiler");
8353
+ var import_babel_utils43 = require("@marko/compiler/babel-utils");
8342
8354
 
8343
8355
  // src/translator/visitors/tag/attribute-tag.ts
8344
- var import_compiler50 = require("@marko/compiler");
8345
- var import_babel_utils39 = require("@marko/compiler/babel-utils");
8356
+ var import_compiler51 = require("@marko/compiler");
8357
+ var import_babel_utils40 = require("@marko/compiler/babel-utils");
8346
8358
  var attribute_tag_default = {
8347
8359
  analyze: {
8348
8360
  enter(tag) {
8349
- (0, import_babel_utils39.assertNoVar)(tag);
8350
- (0, import_babel_utils39.assertNoArgs)(tag);
8361
+ (0, import_babel_utils40.assertNoVar)(tag);
8362
+ (0, import_babel_utils40.assertNoArgs)(tag);
8351
8363
  const body = tag.get("body");
8352
8364
  startSection(body);
8353
8365
  trackParamsReferences(body, 3 /* param */);
8354
- if (!(0, import_babel_utils39.findParentTag)(tag)) {
8366
+ if (!(0, import_babel_utils40.findParentTag)(tag)) {
8355
8367
  throw tag.get("name").buildCodeFrameError("@tags must be nested within another tag.");
8356
8368
  }
8357
8369
  }
@@ -8372,17 +8384,17 @@ var attribute_tag_default = {
8372
8384
  };
8373
8385
 
8374
8386
  // src/translator/visitors/tag/custom-tag.ts
8375
- var import_compiler51 = require("@marko/compiler");
8376
- var import_babel_utils40 = require("@marko/compiler/babel-utils");
8387
+ var import_compiler52 = require("@marko/compiler");
8388
+ var import_babel_utils41 = require("@marko/compiler/babel-utils");
8377
8389
  var import_path4 = __toESM(require("path"));
8378
8390
  var kChildScopeBinding = Symbol("custom tag child scope");
8379
8391
  var kChildAttrExprs = Symbol("custom tag child attribute expressions");
8380
8392
  var custom_tag_default = {
8381
8393
  analyze: {
8382
8394
  enter(tag) {
8383
- (0, import_babel_utils40.assertAttributesOrSingleArg)(tag);
8395
+ (0, import_babel_utils41.assertAttributesOrSingleArg)(tag);
8384
8396
  analyzeAttributeTags(tag);
8385
- const templateFile = (0, import_babel_utils40.getTagTemplate)(tag);
8397
+ const templateFile = (0, import_babel_utils41.getTagTemplate)(tag);
8386
8398
  if (!templateFile) {
8387
8399
  const tagName = getTagName(tag);
8388
8400
  if (tagName && tag.scope.hasBinding(tagName)) {
@@ -8406,7 +8418,7 @@ var custom_tag_default = {
8406
8418
  tagExtra
8407
8419
  );
8408
8420
  tagExtra[kChildAttrExprs] = /* @__PURE__ */ new Set([tagExtra]);
8409
- const childFile = (0, import_babel_utils40.loadFileForTag)(tag);
8421
+ const childFile = (0, import_babel_utils41.loadFileForTag)(tag);
8410
8422
  if (childFile.opts.filename === tag.hub.file.opts.filename) {
8411
8423
  mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
8412
8424
  } else {
@@ -8443,15 +8455,15 @@ function translateHTML(tag) {
8443
8455
  let tagIdentifier;
8444
8456
  flushInto(tag);
8445
8457
  writeHTMLResumeStatements(tagBody);
8446
- if (import_compiler51.types.isStringLiteral(node.name)) {
8458
+ if (import_compiler52.types.isStringLiteral(node.name)) {
8447
8459
  const relativePath = getTagRelativePath(tag);
8448
- tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? htmlRendererIdentifier : (0, import_babel_utils40.importDefault)(tag.hub.file, relativePath, getTagName(tag));
8460
+ tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? htmlRendererIdentifier : (0, import_babel_utils41.importDefault)(tag.hub.file, relativePath, getTagName(tag));
8449
8461
  } else {
8450
8462
  tagIdentifier = node.name;
8451
8463
  }
8452
8464
  const tagVar = node.var;
8453
8465
  const section = getSection(tag);
8454
- const inputExport = (0, import_babel_utils40.loadFileForTag)(tag)?.ast.program.extra?.domExports?.params?.props?.[0];
8466
+ const inputExport = (0, import_babel_utils41.loadFileForTag)(tag)?.ast.program.extra?.domExports?.params?.props?.[0];
8455
8467
  const { properties, statements } = inputExport ? translateAttrs(tag, inputExport.props) : {
8456
8468
  properties: [],
8457
8469
  statements: []
@@ -8469,8 +8481,8 @@ function translateHTML(tag) {
8469
8481
  childScopeBinding?.name
8470
8482
  );
8471
8483
  tag.insertBefore(
8472
- import_compiler51.types.variableDeclaration("const", [
8473
- import_compiler51.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
8484
+ import_compiler52.types.variableDeclaration("const", [
8485
+ import_compiler52.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
8474
8486
  ])
8475
8487
  );
8476
8488
  getSerializedScopeProperties(section).set(
@@ -8479,12 +8491,12 @@ function translateHTML(tag) {
8479
8491
  );
8480
8492
  if (tagVar) {
8481
8493
  statements.push(
8482
- import_compiler51.types.expressionStatement(
8494
+ import_compiler52.types.expressionStatement(
8483
8495
  callRuntime(
8484
8496
  "setTagVar",
8485
8497
  getScopeIdIdentifier(section),
8486
8498
  peekScopeId,
8487
- import_compiler51.types.stringLiteral(
8499
+ import_compiler52.types.stringLiteral(
8488
8500
  getResumeRegisterId(
8489
8501
  section,
8490
8502
  node.var.extra?.binding,
@@ -8504,8 +8516,8 @@ function translateHTML(tag) {
8504
8516
  const contentExpression = contentProp.value;
8505
8517
  contentProp.value = contentId = tag.scope.generateUidIdentifier("content");
8506
8518
  const [contentPath] = tag.insertBefore(
8507
- import_compiler51.types.variableDeclaration("const", [
8508
- import_compiler51.types.variableDeclarator(
8519
+ import_compiler52.types.variableDeclaration("const", [
8520
+ import_compiler52.types.variableDeclarator(
8509
8521
  contentId,
8510
8522
  // TODO: only register if needed (child template analysis)
8511
8523
  contentExpression
@@ -8519,13 +8531,13 @@ function translateHTML(tag) {
8519
8531
  propsToExpression(properties)
8520
8532
  );
8521
8533
  if (tagVar) {
8522
- translateVar(tag, import_compiler51.types.unaryExpression("void", import_compiler51.types.numericLiteral(0)), "let");
8523
- renderTagExpr = import_compiler51.types.assignmentExpression("=", tagVar, renderTagExpr);
8534
+ translateVar(tag, import_compiler52.types.unaryExpression("void", import_compiler52.types.numericLiteral(0)), "let");
8535
+ renderTagExpr = import_compiler52.types.assignmentExpression("=", tagVar, renderTagExpr);
8524
8536
  }
8525
8537
  statements.push(
8526
- import_compiler51.types.ifStatement(
8538
+ import_compiler52.types.ifStatement(
8527
8539
  tagIdentifier,
8528
- import_compiler51.types.expressionStatement(renderTagExpr),
8540
+ import_compiler52.types.expressionStatement(renderTagExpr),
8529
8541
  contentId && callStatement(contentId)
8530
8542
  )
8531
8543
  );
@@ -8551,9 +8563,9 @@ function translateDOM(tag) {
8551
8563
  const childScopeBinding = extra[kChildScopeBinding];
8552
8564
  const write2 = writeTo(tag);
8553
8565
  const { file } = tag.hub;
8554
- const tagName = import_compiler51.types.isIdentifier(node.name) ? node.name.name : import_compiler51.types.isStringLiteral(node.name) ? node.name.value : "tag";
8566
+ const tagName = import_compiler52.types.isIdentifier(node.name) ? node.name.name : import_compiler52.types.isStringLiteral(node.name) ? node.name.value : "tag";
8555
8567
  const relativePath = getTagRelativePath(tag);
8556
- const childFile = (0, import_babel_utils40.loadFileForTag)(tag);
8568
+ const childFile = (0, import_babel_utils41.loadFileForTag)(tag);
8557
8569
  const childExports = childFile.ast.program.extra.domExports;
8558
8570
  const tagIdentifier = importOrSelfReferenceName(
8559
8571
  file,
@@ -8571,10 +8583,10 @@ function translateDOM(tag) {
8571
8583
  attrTagCallsByTag: void 0
8572
8584
  });
8573
8585
  }
8574
- write2`${(0, import_babel_utils40.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
8586
+ write2`${(0, import_babel_utils41.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
8575
8587
  injectWalks(
8576
8588
  tag,
8577
- (0, import_babel_utils40.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`)
8589
+ (0, import_babel_utils41.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`)
8578
8590
  );
8579
8591
  if (node.var) {
8580
8592
  const source = initValue(
@@ -8583,7 +8595,7 @@ function translateDOM(tag) {
8583
8595
  );
8584
8596
  source.register = true;
8585
8597
  source.buildAssignment = (valueSection, value) => {
8586
- return import_compiler51.types.callExpression(importRuntime("tagVarSignalChange"), [
8598
+ return import_compiler52.types.callExpression(importRuntime("tagVarSignalChange"), [
8587
8599
  createScopeReadExpression(valueSection, childScopeBinding),
8588
8600
  value
8589
8601
  ]);
@@ -8592,7 +8604,7 @@ function translateDOM(tag) {
8592
8604
  "render",
8593
8605
  tagSection,
8594
8606
  void 0,
8595
- import_compiler51.types.expressionStatement(
8607
+ import_compiler52.types.expressionStatement(
8596
8608
  callRuntime(
8597
8609
  "setTagVar",
8598
8610
  scopeIdentifier,
@@ -8606,8 +8618,8 @@ function translateDOM(tag) {
8606
8618
  "render",
8607
8619
  tagSection,
8608
8620
  void 0,
8609
- import_compiler51.types.expressionStatement(
8610
- import_compiler51.types.callExpression(tagIdentifier, [
8621
+ import_compiler52.types.expressionStatement(
8622
+ import_compiler52.types.callExpression(tagIdentifier, [
8611
8623
  createScopeReadExpression(tagSection, childScopeBinding)
8612
8624
  ])
8613
8625
  )
@@ -8620,9 +8632,9 @@ function getTagRelativePath(tag) {
8620
8632
  hub: { file }
8621
8633
  } = tag;
8622
8634
  let relativePath;
8623
- if (import_compiler51.types.isStringLiteral(node.name)) {
8624
- const template = (0, import_babel_utils40.getTagTemplate)(tag);
8625
- relativePath = template && (0, import_babel_utils40.resolveRelativePath)(file, template);
8635
+ if (import_compiler52.types.isStringLiteral(node.name)) {
8636
+ const template = (0, import_babel_utils41.getTagTemplate)(tag);
8637
+ relativePath = template && (0, import_babel_utils41.resolveRelativePath)(file, template);
8626
8638
  } else if (node.extra?.tagNameImported) {
8627
8639
  relativePath = node.extra.tagNameImported;
8628
8640
  }
@@ -8668,7 +8680,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
8668
8680
  const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
8669
8681
  for (const child of attrTags2) {
8670
8682
  if (child.isMarkoTag()) {
8671
- if ((0, import_babel_utils40.isAttributeTag)(child)) {
8683
+ if ((0, import_babel_utils41.isAttributeTag)(child)) {
8672
8684
  const attrTagMeta = attrTagLookup[getTagName(child)];
8673
8685
  const childAttrExports = templateExport.props[attrTagMeta.name];
8674
8686
  if (childAttrExports) {
@@ -8709,7 +8721,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
8709
8721
  let spreadReferenceNodes;
8710
8722
  for (let i = attributes.length; i--; ) {
8711
8723
  const attr2 = attributes[i];
8712
- if (import_compiler51.types.isMarkoAttribute(attr2)) {
8724
+ if (import_compiler52.types.isMarkoAttribute(attr2)) {
8713
8725
  if (seen.has(attr2.name) || !templateExport.props[attr2.name]) {
8714
8726
  dropReferences(attr2.value);
8715
8727
  continue;
@@ -8718,7 +8730,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
8718
8730
  }
8719
8731
  if (spreadReferenceNodes) {
8720
8732
  spreadReferenceNodes.push(attr2.value);
8721
- } else if (import_compiler51.types.isMarkoSpreadAttribute(attr2)) {
8733
+ } else if (import_compiler52.types.isMarkoSpreadAttribute(attr2)) {
8722
8734
  spreadReferenceNodes = [attr2.value];
8723
8735
  } else {
8724
8736
  rootTagExtra[kChildAttrExprs].add(attr2.value.extra ??= {});
@@ -8743,12 +8755,12 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
8743
8755
  // but we should probably ensure all other references are dropped in this case before we do that.
8744
8756
  tag.node.extra?.referencedBindings,
8745
8757
  identifierToSignal(tagInputIdentifier),
8746
- import_compiler51.types.isSpreadElement(arg) ? import_compiler51.types.memberExpression(arg.argument, import_compiler51.types.numericLiteral(0), true) : arg,
8758
+ import_compiler52.types.isSpreadElement(arg) ? import_compiler52.types.memberExpression(arg.argument, import_compiler52.types.numericLiteral(0), true) : arg,
8747
8759
  createScopeReadExpression(info.tagSection, info.childScopeBinding),
8748
8760
  callRuntime(
8749
8761
  "inChild",
8750
8762
  getScopeAccessorLiteral(info.childScopeBinding),
8751
- import_compiler51.types.identifier(tagInputIdentifier.name)
8763
+ import_compiler52.types.identifier(tagInputIdentifier.name)
8752
8764
  )
8753
8765
  );
8754
8766
  return;
@@ -8771,7 +8783,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
8771
8783
  );
8772
8784
  }
8773
8785
  let translatedProps = propsToExpression(translatedAttrs.properties);
8774
- if ((0, import_babel_utils40.isAttributeTag)(tag)) {
8786
+ if ((0, import_babel_utils41.isAttributeTag)(tag)) {
8775
8787
  const attrTagName = getTagName(tag);
8776
8788
  const parentTag = tag.parentPath;
8777
8789
  const repeated = analyzeAttributeTags(parentTag)?.[attrTagName]?.repeated;
@@ -8796,7 +8808,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
8796
8808
  } else {
8797
8809
  attrTagCallsForTag.set(
8798
8810
  attrTagName,
8799
- translatedProps = import_compiler51.types.parenthesizedExpression(
8811
+ translatedProps = import_compiler52.types.parenthesizedExpression(
8800
8812
  callRuntime("attrTag", translatedProps)
8801
8813
  )
8802
8814
  );
@@ -8814,7 +8826,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
8814
8826
  callRuntime(
8815
8827
  "inChild",
8816
8828
  getScopeAccessorLiteral(info.childScopeBinding),
8817
- import_compiler51.types.identifier(tagInputIdentifier.name)
8829
+ import_compiler52.types.identifier(tagInputIdentifier.name)
8818
8830
  )
8819
8831
  );
8820
8832
  return;
@@ -8848,7 +8860,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
8848
8860
  for (let i = 0; i < attrTags2.length; i++) {
8849
8861
  const child = attrTags2[i];
8850
8862
  if (child.isMarkoTag()) {
8851
- if ((0, import_babel_utils40.isAttributeTag)(child)) {
8863
+ if ((0, import_babel_utils41.isAttributeTag)(child)) {
8852
8864
  const attrTagMeta = attrTagLookup[getTagName(child)];
8853
8865
  const childAttrExport = templateExport.props[attrTagMeta.name];
8854
8866
  if (childAttrExport) {
@@ -8886,7 +8898,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
8886
8898
  childAttrExports.id,
8887
8899
  `${importAlias}_${attrTagMeta.name}`
8888
8900
  );
8889
- decls.push(import_compiler51.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
8901
+ decls.push(import_compiler52.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
8890
8902
  addValue(
8891
8903
  info.tagSection,
8892
8904
  referencedBindings,
@@ -8896,12 +8908,12 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
8896
8908
  callRuntime(
8897
8909
  "inChild",
8898
8910
  getScopeAccessorLiteral(info.childScopeBinding),
8899
- import_compiler51.types.identifier(attrExportIdentifier.name)
8911
+ import_compiler52.types.identifier(attrExportIdentifier.name)
8900
8912
  )
8901
8913
  );
8902
8914
  }
8903
8915
  addStatement("render", info.tagSection, referencedBindings, [
8904
- import_compiler51.types.variableDeclaration("let", decls),
8916
+ import_compiler52.types.variableDeclaration("let", decls),
8905
8917
  ...statements
8906
8918
  ]);
8907
8919
  }
@@ -8910,7 +8922,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
8910
8922
  if (bodySection && !seen.has("content")) {
8911
8923
  seen.add("content");
8912
8924
  if (templateExport.props.content) {
8913
- const contentExportIdentifier = (0, import_babel_utils40.importNamed)(
8925
+ const contentExportIdentifier = (0, import_babel_utils41.importNamed)(
8914
8926
  tag.hub.file,
8915
8927
  info.relativePath,
8916
8928
  templateExport.props.content.id,
@@ -8921,12 +8933,12 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
8921
8933
  void 0,
8922
8934
  // TODO: pretty sure content needs to have the reference group of it's param defaults.
8923
8935
  identifierToSignal(contentExportIdentifier),
8924
- import_compiler51.types.callExpression(import_compiler51.types.identifier(bodySection.name), [scopeIdentifier]),
8936
+ import_compiler52.types.callExpression(import_compiler52.types.identifier(bodySection.name), [scopeIdentifier]),
8925
8937
  createScopeReadExpression(info.tagSection, info.childScopeBinding),
8926
8938
  callRuntime(
8927
8939
  "inChild",
8928
8940
  getScopeAccessorLiteral(info.childScopeBinding),
8929
- import_compiler51.types.identifier(contentExportIdentifier.name)
8941
+ import_compiler52.types.identifier(contentExportIdentifier.name)
8930
8942
  )
8931
8943
  );
8932
8944
  }
@@ -8936,7 +8948,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
8936
8948
  let spreadProps;
8937
8949
  for (let i = attributes.length; i--; ) {
8938
8950
  const attr2 = attributes[i];
8939
- if (import_compiler51.types.isMarkoAttribute(attr2)) {
8951
+ if (import_compiler52.types.isMarkoAttribute(attr2)) {
8940
8952
  const childAttrExports = templateExport.props[attr2.name];
8941
8953
  if (!childAttrExports || seen.has(attr2.name)) continue;
8942
8954
  seen.add(attr2.name);
@@ -8946,9 +8958,9 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
8946
8958
  }
8947
8959
  staticAttrs.push(attr2);
8948
8960
  } else if (spreadProps) {
8949
- spreadProps.push(import_compiler51.types.spreadElement(attr2.value));
8961
+ spreadProps.push(import_compiler52.types.spreadElement(attr2.value));
8950
8962
  } else {
8951
- spreadProps = [import_compiler51.types.spreadElement(attr2.value)];
8963
+ spreadProps = [import_compiler52.types.spreadElement(attr2.value)];
8952
8964
  }
8953
8965
  }
8954
8966
  for (const attr2 of staticAttrs.reverse()) {
@@ -8968,7 +8980,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
8968
8980
  callRuntime(
8969
8981
  "inChild",
8970
8982
  getScopeAccessorLiteral(info.childScopeBinding),
8971
- import_compiler51.types.identifier(attrExportIdentifier.name)
8983
+ import_compiler52.types.identifier(attrExportIdentifier.name)
8972
8984
  )
8973
8985
  );
8974
8986
  }
@@ -8982,8 +8994,8 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
8982
8994
  spreadProps.reverse();
8983
8995
  getMissingPropValue = (name2) => toMemberExpression(spreadId, name2);
8984
8996
  addStatement("render", info.tagSection, referencedBindings, [
8985
- import_compiler51.types.variableDeclaration("const", [
8986
- import_compiler51.types.variableDeclarator(spreadId, propsToExpression(spreadProps))
8997
+ import_compiler52.types.variableDeclaration("const", [
8998
+ import_compiler52.types.variableDeclarator(spreadId, propsToExpression(spreadProps))
8987
8999
  ])
8988
9000
  ]);
8989
9001
  }
@@ -9004,7 +9016,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9004
9016
  callRuntime(
9005
9017
  "inChild",
9006
9018
  getScopeAccessorLiteral(info.childScopeBinding),
9007
- import_compiler51.types.identifier(attrExportIdentifier.name)
9019
+ import_compiler52.types.identifier(attrExportIdentifier.name)
9008
9020
  )
9009
9021
  );
9010
9022
  }
@@ -9012,19 +9024,19 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9012
9024
  }
9013
9025
  function importOrSelfReferenceName(file, request, name2, nameHint) {
9014
9026
  if (isCircularRequest(file, request)) {
9015
- return import_compiler51.types.identifier(name2);
9027
+ return import_compiler52.types.identifier(name2);
9016
9028
  }
9017
- return (0, import_babel_utils40.importNamed)(file, request, name2, nameHint);
9029
+ return (0, import_babel_utils41.importNamed)(file, request, name2, nameHint);
9018
9030
  }
9019
9031
  function isCircularRequest(file, request) {
9020
9032
  const { filename } = file.opts;
9021
9033
  return request === filename || request[0] === "." && import_path4.default.resolve(filename, "..", request) === filename;
9022
9034
  }
9023
9035
  function callStatement(id, ...args) {
9024
- return import_compiler51.types.expressionStatement(callExpression(id, ...args));
9036
+ return import_compiler52.types.expressionStatement(callExpression(id, ...args));
9025
9037
  }
9026
9038
  function callExpression(id, ...args) {
9027
- return import_compiler51.types.callExpression(id, args.filter(Boolean));
9039
+ return import_compiler52.types.callExpression(id, args.filter(Boolean));
9028
9040
  }
9029
9041
  function identifierToSignal(identifier) {
9030
9042
  return {
@@ -9033,20 +9045,20 @@ function identifierToSignal(identifier) {
9033
9045
  };
9034
9046
  }
9035
9047
  function buildUndefined2() {
9036
- return import_compiler51.types.unaryExpression("void", import_compiler51.types.numericLiteral(0));
9048
+ return import_compiler52.types.unaryExpression("void", import_compiler52.types.numericLiteral(0));
9037
9049
  }
9038
9050
  function always() {
9039
9051
  return true;
9040
9052
  }
9041
9053
 
9042
9054
  // src/translator/visitors/tag/dynamic-tag.ts
9043
- var import_compiler52 = require("@marko/compiler");
9044
- var import_babel_utils41 = require("@marko/compiler/babel-utils");
9055
+ var import_compiler53 = require("@marko/compiler");
9056
+ var import_babel_utils42 = require("@marko/compiler/babel-utils");
9045
9057
  var kDOMBinding = Symbol("dynamic tag dom binding");
9046
9058
  var dynamic_tag_default = {
9047
9059
  analyze: {
9048
9060
  enter(tag) {
9049
- (0, import_babel_utils41.assertAttributesOrArgs)(tag);
9061
+ (0, import_babel_utils42.assertAttributesOrArgs)(tag);
9050
9062
  analyzeAttributeTags(tag);
9051
9063
  const section = getOrCreateSection(tag);
9052
9064
  const tagExtra = tag.node.extra ??= {};
@@ -9080,8 +9092,8 @@ var dynamic_tag_default = {
9080
9092
  const section = getSection(tag);
9081
9093
  const isClassAPI = extra.featureType === "class";
9082
9094
  let tagExpression = node.name;
9083
- if (import_compiler52.types.isStringLiteral(tagExpression)) {
9084
- tagExpression = (0, import_babel_utils41.importDefault)(
9095
+ if (import_compiler53.types.isStringLiteral(tagExpression)) {
9096
+ tagExpression = (0, import_babel_utils42.importDefault)(
9085
9097
  tag.hub.file,
9086
9098
  getTagRelativePath(tag),
9087
9099
  tagExpression.value
@@ -9091,12 +9103,12 @@ var dynamic_tag_default = {
9091
9103
  if (isOutputHTML()) {
9092
9104
  currentProgramPath.pushContainer(
9093
9105
  "body",
9094
- import_compiler52.types.expressionStatement(
9095
- import_compiler52.types.callExpression(
9096
- (0, import_babel_utils41.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
9106
+ import_compiler53.types.expressionStatement(
9107
+ import_compiler53.types.callExpression(
9108
+ (0, import_babel_utils42.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
9097
9109
  [
9098
- import_compiler52.types.identifier(tagExpression.name),
9099
- import_compiler52.types.stringLiteral((0, import_babel_utils41.loadFileForTag)(tag).metadata.marko.id)
9110
+ import_compiler53.types.identifier(tagExpression.name),
9111
+ import_compiler53.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id)
9100
9112
  ]
9101
9113
  )
9102
9114
  )
@@ -9104,11 +9116,11 @@ var dynamic_tag_default = {
9104
9116
  } else {
9105
9117
  currentProgramPath.pushContainer(
9106
9118
  "body",
9107
- import_compiler52.types.expressionStatement(
9119
+ import_compiler53.types.expressionStatement(
9108
9120
  callRuntime(
9109
9121
  "register",
9110
- import_compiler52.types.stringLiteral((0, import_babel_utils41.loadFileForTag)(tag).metadata.marko.id),
9111
- import_compiler52.types.identifier(tagExpression.name)
9122
+ import_compiler53.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id),
9123
+ import_compiler53.types.identifier(tagExpression.name)
9112
9124
  )
9113
9125
  )
9114
9126
  );
@@ -9128,7 +9140,7 @@ var dynamic_tag_default = {
9128
9140
  hasMultipleArgs = true;
9129
9141
  args.push(propsToExpression(properties));
9130
9142
  } else {
9131
- hasMultipleArgs = node.arguments.length > 1 || import_compiler52.types.isSpreadElement(node.arguments[0]);
9143
+ hasMultipleArgs = node.arguments.length > 1 || import_compiler53.types.isSpreadElement(node.arguments[0]);
9132
9144
  }
9133
9145
  } else {
9134
9146
  const contentProp = getTranslatedBodyContentProperty(properties);
@@ -9144,7 +9156,7 @@ var dynamic_tag_default = {
9144
9156
  writeHTMLResumeStatements(tag.get("body"));
9145
9157
  if (node.var) {
9146
9158
  if (!hasMultipleArgs && args.length === 1) {
9147
- args.push(import_compiler52.types.unaryExpression("void", import_compiler52.types.numericLiteral(0)));
9159
+ args.push(import_compiler53.types.unaryExpression("void", import_compiler53.types.numericLiteral(0)));
9148
9160
  }
9149
9161
  }
9150
9162
  const dynamicScopeIdentifier = currentProgramPath.scope.generateUidIdentifier("dynamicScope");
@@ -9153,7 +9165,7 @@ var dynamic_tag_default = {
9153
9165
  getScopeIdIdentifier(section),
9154
9166
  getScopeAccessorLiteral(nodeRef2),
9155
9167
  tagExpression,
9156
- import_compiler52.types.arrayExpression(args)
9168
+ import_compiler53.types.arrayExpression(args)
9157
9169
  ) : callRuntime(
9158
9170
  "dynamicTagInput",
9159
9171
  getScopeIdIdentifier(section),
@@ -9162,8 +9174,8 @@ var dynamic_tag_default = {
9162
9174
  ...args
9163
9175
  );
9164
9176
  statements.push(
9165
- import_compiler52.types.variableDeclaration("const", [
9166
- import_compiler52.types.variableDeclarator(
9177
+ import_compiler53.types.variableDeclaration("const", [
9178
+ import_compiler53.types.variableDeclarator(
9167
9179
  dynamicScopeIdentifier,
9168
9180
  callRuntime("peekNextScope")
9169
9181
  )
@@ -9171,12 +9183,12 @@ var dynamic_tag_default = {
9171
9183
  );
9172
9184
  if (node.var) {
9173
9185
  statements.push(
9174
- import_compiler52.types.expressionStatement(
9186
+ import_compiler53.types.expressionStatement(
9175
9187
  callRuntime(
9176
9188
  "setTagVar",
9177
9189
  getScopeIdIdentifier(section),
9178
9190
  dynamicScopeIdentifier,
9179
- import_compiler52.types.stringLiteral(
9191
+ import_compiler53.types.stringLiteral(
9180
9192
  getResumeRegisterId(
9181
9193
  section,
9182
9194
  node.var.extra?.binding,
@@ -9186,26 +9198,26 @@ var dynamic_tag_default = {
9186
9198
  )
9187
9199
  )
9188
9200
  ),
9189
- import_compiler52.types.variableDeclaration("const", [
9190
- import_compiler52.types.variableDeclarator(node.var, dynamicTagExpr)
9201
+ import_compiler53.types.variableDeclaration("const", [
9202
+ import_compiler53.types.variableDeclarator(node.var, dynamicTagExpr)
9191
9203
  ])
9192
9204
  );
9193
9205
  } else {
9194
- statements.push(import_compiler52.types.expressionStatement(dynamicTagExpr));
9206
+ statements.push(import_compiler53.types.expressionStatement(dynamicTagExpr));
9195
9207
  }
9196
9208
  getSerializedScopeProperties(section).set(
9197
- import_compiler52.types.stringLiteral(
9209
+ import_compiler53.types.stringLiteral(
9198
9210
  getScopeAccessorLiteral(nodeRef2).value + "!" /* ConditionalScope */
9199
9211
  ),
9200
9212
  callRuntime("writeExistingScope", dynamicScopeIdentifier)
9201
9213
  );
9202
9214
  getSerializedScopeProperties(section).set(
9203
- import_compiler52.types.stringLiteral(
9215
+ import_compiler53.types.stringLiteral(
9204
9216
  getScopeAccessorLiteral(nodeRef2).value + "(" /* ConditionalRenderer */
9205
9217
  ),
9206
9218
  callRuntime(
9207
9219
  "normalizeDynamicRenderer",
9208
- import_compiler52.types.isIdentifier(tagExpression) ? import_compiler52.types.identifier(tagExpression.name) : tagExpression
9220
+ import_compiler53.types.isIdentifier(tagExpression) ? import_compiler53.types.identifier(tagExpression.name) : tagExpression
9209
9221
  )
9210
9222
  );
9211
9223
  for (const replacement of tag.replaceWithMultiple(statements)) {
@@ -9214,10 +9226,10 @@ var dynamic_tag_default = {
9214
9226
  } else {
9215
9227
  const section2 = getSection(tag);
9216
9228
  const bodySection = getSectionForBody(tag.get("body"));
9217
- const signal = getSignal(section2, nodeRef2, "dynamicTagName");
9229
+ const signal = getSignal(section2, nodeRef2, "dynamicTag");
9218
9230
  signal.build = () => {
9219
9231
  return callRuntime(
9220
- "conditional",
9232
+ "dynamicTag",
9221
9233
  getScopeAccessorLiteral(nodeRef2),
9222
9234
  getSignalFn(signal, [scopeIdentifier]),
9223
9235
  buildSignalIntersections(signal)
@@ -9228,16 +9240,16 @@ var dynamic_tag_default = {
9228
9240
  section2,
9229
9241
  node.name.extra?.referencedBindings,
9230
9242
  signal,
9231
- bodySection ? import_compiler52.types.logicalExpression(
9243
+ bodySection ? import_compiler53.types.logicalExpression(
9232
9244
  "||",
9233
9245
  tagExpression,
9234
- import_compiler52.types.callExpression(import_compiler52.types.identifier(bodySection.name), [
9246
+ import_compiler53.types.callExpression(import_compiler53.types.identifier(bodySection.name), [
9235
9247
  scopeIdentifier
9236
9248
  ])
9237
9249
  ) : tagExpression
9238
9250
  );
9239
9251
  if (tag.node.var) {
9240
- const childScopeLiteral = import_compiler52.types.stringLiteral(
9252
+ const childScopeLiteral = import_compiler53.types.stringLiteral(
9241
9253
  getScopeAccessorLiteral(extra[kDOMBinding]).value + "!" /* ConditionalScope */
9242
9254
  );
9243
9255
  const source = initValue(
@@ -9246,8 +9258,8 @@ var dynamic_tag_default = {
9246
9258
  );
9247
9259
  source.register = true;
9248
9260
  source.buildAssignment = (valueSection, value) => {
9249
- return import_compiler52.types.callExpression(importRuntime("tagVarSignalChange"), [
9250
- import_compiler52.types.memberExpression(
9261
+ return import_compiler53.types.callExpression(importRuntime("tagVarSignalChange"), [
9262
+ import_compiler53.types.memberExpression(
9251
9263
  getScopeExpression(source.section, valueSection),
9252
9264
  childScopeLiteral,
9253
9265
  true
@@ -9259,7 +9271,7 @@ var dynamic_tag_default = {
9259
9271
  "render",
9260
9272
  section2,
9261
9273
  nodeRef2,
9262
- import_compiler52.types.expressionStatement(
9274
+ import_compiler53.types.expressionStatement(
9263
9275
  callRuntime(
9264
9276
  "setTagVar",
9265
9277
  scopeIdentifier,
@@ -9270,11 +9282,11 @@ var dynamic_tag_default = {
9270
9282
  );
9271
9283
  }
9272
9284
  if (args.length) {
9273
- const argsOrInput = hasMultipleArgs ? import_compiler52.types.arrayExpression(args) : args[0];
9274
- const attrsGetter = import_compiler52.types.arrowFunctionExpression(
9285
+ const argsOrInput = hasMultipleArgs ? import_compiler53.types.arrayExpression(args) : args[0];
9286
+ const attrsGetter = import_compiler53.types.arrowFunctionExpression(
9275
9287
  [],
9276
- statements.length ? import_compiler52.types.blockStatement(
9277
- statements.concat(import_compiler52.types.returnStatement(argsOrInput))
9288
+ statements.length ? import_compiler53.types.blockStatement(
9289
+ statements.concat(import_compiler53.types.returnStatement(argsOrInput))
9278
9290
  ) : argsOrInput
9279
9291
  );
9280
9292
  const id = currentProgramPath.scope.generateUidIdentifier(
@@ -9289,14 +9301,14 @@ var dynamic_tag_default = {
9289
9301
  if (!added) {
9290
9302
  currentProgramPath.pushContainer(
9291
9303
  "body",
9292
- import_compiler52.types.variableDeclaration("const", [
9293
- import_compiler52.types.variableDeclarator(
9304
+ import_compiler53.types.variableDeclaration("const", [
9305
+ import_compiler53.types.variableDeclarator(
9294
9306
  id,
9295
9307
  callRuntime(
9296
9308
  "dynamicTagAttrs",
9297
9309
  getScopeAccessorLiteral(nodeRef2),
9298
- bodySection && import_compiler52.types.identifier(bodySection.name),
9299
- hasMultipleArgs && import_compiler52.types.numericLiteral(1)
9310
+ bodySection && import_compiler53.types.identifier(bodySection.name),
9311
+ hasMultipleArgs && import_compiler53.types.numericLiteral(1)
9300
9312
  )
9301
9313
  )
9302
9314
  ])
@@ -9318,35 +9330,25 @@ var dynamic_tag_default = {
9318
9330
 
9319
9331
  // src/translator/visitors/tag/index.ts
9320
9332
  var TAG_NAME_IDENTIFIER_REG = /^[A-Z][a-zA-Z0-9_$]*$/;
9333
+ var BINDING_CHANGE_HANDLER = /* @__PURE__ */ new WeakMap();
9321
9334
  var tag_default = {
9322
9335
  transform: {
9323
9336
  enter(tag) {
9324
9337
  const { node } = tag;
9325
9338
  const { name: name2, attributes } = tag.node;
9326
9339
  let crawl = false;
9327
- if (import_compiler53.types.isStringLiteral(name2)) {
9340
+ if (import_compiler54.types.isStringLiteral(name2)) {
9328
9341
  const tagName = name2.value;
9329
9342
  if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
9330
- node.name = withPreviousLocation(import_compiler53.types.identifier(tagName), name2);
9343
+ node.name = withPreviousLocation(import_compiler54.types.identifier(tagName), name2);
9331
9344
  crawl = true;
9332
9345
  }
9333
9346
  }
9334
9347
  for (let i = 0; i < attributes.length; i++) {
9335
9348
  const attr2 = attributes[i];
9336
- if (import_compiler53.types.isMarkoAttribute(attr2) && attr2.bound) {
9349
+ if (import_compiler54.types.isMarkoAttribute(attr2) && attr2.bound) {
9337
9350
  attr2.bound = false;
9338
- const changeValue = getChangeHandler(tag, attr2);
9339
- if (changeValue === null) {
9340
- throw tag.hub.buildError(
9341
- attr2,
9342
- "Attributes may only be bound to identifiers or member expressions"
9343
- );
9344
- }
9345
- attributes.splice(
9346
- ++i,
9347
- 0,
9348
- import_compiler53.types.markoAttribute(attr2.name + "Change", changeValue)
9349
- );
9351
+ attributes.splice(++i, 0, getChangeHandler(tag, attr2));
9350
9352
  crawl = true;
9351
9353
  }
9352
9354
  }
@@ -9357,7 +9359,7 @@ var tag_default = {
9357
9359
  },
9358
9360
  analyze: {
9359
9361
  enter(tag) {
9360
- const tagDef = (0, import_babel_utils42.getTagDef)(tag);
9362
+ const tagDef = (0, import_babel_utils43.getTagDef)(tag);
9361
9363
  const type = analyzeTagNameType(tag);
9362
9364
  const hook = tagDef?.analyzer?.hook;
9363
9365
  if (hook) {
@@ -9381,7 +9383,7 @@ var tag_default = {
9381
9383
  }
9382
9384
  },
9383
9385
  exit(tag) {
9384
- const hook = (0, import_babel_utils42.getTagDef)(tag)?.analyzer?.hook;
9386
+ const hook = (0, import_babel_utils43.getTagDef)(tag)?.analyzer?.hook;
9385
9387
  if (hook) {
9386
9388
  exit(hook, tag);
9387
9389
  return;
@@ -9390,7 +9392,7 @@ var tag_default = {
9390
9392
  },
9391
9393
  translate: {
9392
9394
  enter(tag) {
9393
- const tagDef = (0, import_babel_utils42.getTagDef)(tag);
9395
+ const tagDef = (0, import_babel_utils43.getTagDef)(tag);
9394
9396
  const extra = tag.node.extra;
9395
9397
  if (tagDef?.translator) {
9396
9398
  if (tagDef.translator.path) {
@@ -9407,7 +9409,7 @@ var tag_default = {
9407
9409
  );
9408
9410
  }
9409
9411
  if (attr2.node.modifier) {
9410
- if ((0, import_babel_utils42.isNativeTag)(attr2.parentPath)) {
9412
+ if ((0, import_babel_utils43.isNativeTag)(attr2.parentPath)) {
9411
9413
  attr2.node.name += `:${attr2.node.modifier}`;
9412
9414
  } else {
9413
9415
  throw attr2.buildCodeFrameError(
@@ -9420,8 +9422,8 @@ var tag_default = {
9420
9422
  if (extra.tagNameDynamic && extra.tagNameNullable && !tag.get("name").isIdentifier() && isOutputHTML()) {
9421
9423
  const tagNameId = tag.scope.generateUidIdentifier("tagName");
9422
9424
  const [tagNameVarPath] = tag.insertBefore(
9423
- import_compiler53.types.variableDeclaration("const", [
9424
- import_compiler53.types.variableDeclarator(tagNameId, tag.node.name)
9425
+ import_compiler54.types.variableDeclaration("const", [
9426
+ import_compiler54.types.variableDeclarator(tagNameId, tag.node.name)
9425
9427
  ])
9426
9428
  );
9427
9429
  tagNameVarPath.skip();
@@ -9443,7 +9445,7 @@ var tag_default = {
9443
9445
  }
9444
9446
  },
9445
9447
  exit(tag) {
9446
- const translator = (0, import_babel_utils42.getTagDef)(tag)?.translator;
9448
+ const translator = (0, import_babel_utils43.getTagDef)(tag)?.translator;
9447
9449
  if (translator) {
9448
9450
  exit(translator.hook, tag);
9449
9451
  return;
@@ -9466,37 +9468,98 @@ var tag_default = {
9466
9468
  }
9467
9469
  };
9468
9470
  function getChangeHandler(tag, attr2) {
9469
- if (import_compiler53.types.isIdentifier(attr2.value)) {
9470
- const valueId = tag.scope.generateUidIdentifier("new_" + attr2.value.name);
9471
- return import_compiler53.types.arrowFunctionExpression(
9472
- [valueId],
9473
- import_compiler53.types.blockStatement([
9474
- import_compiler53.types.expressionStatement(
9475
- import_compiler53.types.assignmentExpression("=", import_compiler53.types.cloneNode(attr2.value), valueId)
9471
+ const attrName = attr2.name;
9472
+ const changeAttrName = attrName + "Change";
9473
+ if (import_compiler54.types.isIdentifier(attr2.value)) {
9474
+ const binding = tag.scope.getBinding(attr2.value.name);
9475
+ if (!binding)
9476
+ return import_compiler54.types.markoAttribute(
9477
+ changeAttrName,
9478
+ buildChangeHandlerFunction(attr2.value)
9479
+ );
9480
+ const existingChangedAttr = BINDING_CHANGE_HANDLER.get(binding.identifier);
9481
+ if (!existingChangedAttr) {
9482
+ const changeHandlerAttr = import_compiler54.types.markoAttribute(
9483
+ changeAttrName,
9484
+ buildChangeHandlerFunction(attr2.value)
9485
+ );
9486
+ BINDING_CHANGE_HANDLER.set(binding.identifier, changeHandlerAttr);
9487
+ return changeHandlerAttr;
9488
+ }
9489
+ if (existingChangedAttr.type === "Identifier") {
9490
+ return import_compiler54.types.markoAttribute(
9491
+ changeAttrName,
9492
+ withPreviousLocation(
9493
+ import_compiler54.types.identifier(existingChangedAttr.name),
9494
+ attr2.value
9476
9495
  )
9477
- ])
9478
- );
9479
- } else if (import_compiler53.types.isMemberExpression(attr2.value)) {
9480
- const prop = attr2.value.property;
9481
- if (import_compiler53.types.isPrivateName(prop)) return null;
9482
- if (import_compiler53.types.isIdentifier(prop)) {
9483
- return import_compiler53.types.memberExpression(
9484
- import_compiler53.types.cloneNode(attr2.value.object),
9485
- import_compiler53.types.identifier(prop.name + "Change")
9486
9496
  );
9497
+ }
9498
+ const markoRoot = isMarko(binding.path) ? binding.path : getMarkoRoot(binding.path);
9499
+ if (!(markoRoot?.isMarkoTag() || markoRoot?.isMarkoTagBody())) {
9500
+ throw tag.hub.buildError(attr2.value, "Unable to bind to value.");
9501
+ }
9502
+ const changeHandlerId = markoRoot.scope.generateUid(changeAttrName);
9503
+ const changeHandlerConst = import_compiler54.types.markoTag(
9504
+ import_compiler54.types.stringLiteral("const"),
9505
+ [import_compiler54.types.markoAttribute("value", existingChangedAttr.value, null, null, true)],
9506
+ import_compiler54.types.markoTagBody([]),
9507
+ null,
9508
+ import_compiler54.types.identifier(changeHandlerId)
9509
+ );
9510
+ BINDING_CHANGE_HANDLER.set(
9511
+ binding.identifier,
9512
+ existingChangedAttr.value = import_compiler54.types.identifier(changeHandlerId)
9513
+ );
9514
+ if (markoRoot.isMarkoTag()) {
9515
+ markoRoot.insertAfter(changeHandlerConst);
9487
9516
  } else {
9488
- return import_compiler53.types.memberExpression(
9489
- import_compiler53.types.cloneNode(attr2.value.object),
9490
- import_compiler53.types.binaryExpression("+", import_compiler53.types.cloneNode(prop), import_compiler53.types.stringLiteral("Change")),
9491
- true
9517
+ markoRoot.unshiftContainer("body", changeHandlerConst);
9518
+ }
9519
+ return import_compiler54.types.markoAttribute(
9520
+ changeAttrName,
9521
+ withPreviousLocation(import_compiler54.types.identifier(changeHandlerId), attr2.value)
9522
+ );
9523
+ } else if (import_compiler54.types.isMemberExpression(attr2.value)) {
9524
+ const prop = attr2.value.property;
9525
+ if (!import_compiler54.types.isPrivateName(attr2.value.property)) {
9526
+ return import_compiler54.types.markoAttribute(
9527
+ changeAttrName,
9528
+ import_compiler54.types.memberExpression(
9529
+ import_compiler54.types.cloneNode(attr2.value.object),
9530
+ prop.type === "Identifier" ? withPreviousLocation(import_compiler54.types.identifier(prop.name + "Change"), prop) : import_compiler54.types.binaryExpression(
9531
+ "+",
9532
+ import_compiler54.types.cloneNode(prop),
9533
+ import_compiler54.types.stringLiteral("Change")
9534
+ ),
9535
+ prop.type !== "Identifier"
9536
+ )
9492
9537
  );
9493
9538
  }
9494
9539
  }
9495
- return null;
9540
+ throw tag.hub.buildError(
9541
+ attr2.value,
9542
+ "Attributes may only be bound to identifiers or member expressions"
9543
+ );
9544
+ }
9545
+ function buildChangeHandlerFunction(id) {
9546
+ const newId = "_new_" + id.name;
9547
+ return import_compiler54.types.arrowFunctionExpression(
9548
+ [withPreviousLocation(import_compiler54.types.identifier(newId), id)],
9549
+ import_compiler54.types.blockStatement([
9550
+ import_compiler54.types.expressionStatement(
9551
+ import_compiler54.types.assignmentExpression(
9552
+ "=",
9553
+ withPreviousLocation(import_compiler54.types.identifier(id.name), id),
9554
+ withPreviousLocation(import_compiler54.types.identifier(newId), id)
9555
+ )
9556
+ )
9557
+ ])
9558
+ );
9496
9559
  }
9497
9560
 
9498
9561
  // src/translator/visitors/text.ts
9499
- var import_compiler54 = require("@marko/compiler");
9562
+ var import_compiler55 = require("@marko/compiler");
9500
9563
  var text_default = {
9501
9564
  translate: {
9502
9565
  exit(text) {