marko 6.3.56 → 6.4.0

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.
Files changed (81) hide show
  1. package/cheatsheet.md +2 -2
  2. package/dist/common/constants/accessor-prefix.d.ts +1 -0
  3. package/dist/common/constants/accessor-prefix.debug.d.ts +1 -0
  4. package/dist/common/constants/accessor-prop.d.ts +3 -0
  5. package/dist/common/constants/accessor-prop.debug.d.ts +3 -0
  6. package/dist/common/types.d.ts +8 -2
  7. package/dist/debug/dom/catch.feat.js +12 -14
  8. package/dist/debug/dom/catch.feat.mjs +12 -14
  9. package/dist/debug/dom/controllable-input.feat.js +1 -1
  10. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  11. package/dist/debug/dom/controllable-open.feat.js +1 -1
  12. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  13. package/dist/debug/dom/controllable-select.feat.js +1 -1
  14. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  15. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  16. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  17. package/dist/debug/dom/controllable.feat.js +1 -1
  18. package/dist/debug/dom/controllable.feat.mjs +1 -1
  19. package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
  20. package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
  21. package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
  22. package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
  23. package/dist/debug/dom/lazy.feat.js +4 -0
  24. package/dist/debug/dom/lazy.feat.mjs +4 -0
  25. package/dist/debug/dom/placeholder.feat.js +1 -1
  26. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  27. package/dist/debug/{dom-DcwejnYg.js → dom-BRO5aArp.js} +232 -178
  28. package/dist/debug/{dom-BeCNT5R5.mjs → dom-Btj2QJhk.mjs} +215 -167
  29. package/dist/debug/dom.js +14 -12
  30. package/dist/debug/dom.mjs +14 -12
  31. package/dist/debug/html.js +603 -517
  32. package/dist/debug/html.mjs +602 -518
  33. package/dist/dom/abort-signal.d.ts +2 -0
  34. package/dist/dom/catch.feat.js +6 -7
  35. package/dist/dom/catch.feat.mjs +5 -7
  36. package/dist/dom/control-flow.d.ts +3 -5
  37. package/dist/dom/controllable-input.feat.js +3 -2
  38. package/dist/dom/controllable-input.feat.mjs +1 -1
  39. package/dist/dom/controllable-open.feat.js +3 -2
  40. package/dist/dom/controllable-open.feat.mjs +1 -1
  41. package/dist/dom/controllable-select.feat.js +3 -2
  42. package/dist/dom/controllable-select.feat.mjs +1 -1
  43. package/dist/dom/controllable-textarea.feat.js +3 -2
  44. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  45. package/dist/dom/controllable.feat.js +3 -2
  46. package/dist/dom/controllable.feat.mjs +1 -1
  47. package/dist/dom/dynamic-tag-script.feat.js +3 -2
  48. package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
  49. package/dist/dom/dynamic-tag-var.feat.js +2 -1
  50. package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
  51. package/dist/dom/lazy.feat.d.ts +1 -0
  52. package/dist/dom/lazy.feat.js +4 -0
  53. package/dist/dom/lazy.feat.mjs +4 -0
  54. package/dist/dom/load.d.ts +3 -3
  55. package/dist/dom/placeholder.feat.js +4 -3
  56. package/dist/dom/placeholder.feat.mjs +1 -1
  57. package/dist/dom/queue.d.ts +2 -4
  58. package/dist/dom/resume.d.ts +1 -1
  59. package/dist/dom/scope.d.ts +0 -1
  60. package/dist/{dom-BwNsIevR.mjs → dom-B-v8Gw6T.mjs} +114 -87
  61. package/dist/{dom-QEF0csuC.js → dom-BSsI9OPC.js} +210 -182
  62. package/dist/dom.js +59 -56
  63. package/dist/dom.mjs +34 -32
  64. package/dist/html/attrs.d.ts +2 -0
  65. package/dist/html/writer.d.ts +5 -11
  66. package/dist/html.d.ts +1 -1
  67. package/dist/html.js +362 -317
  68. package/dist/html.mjs +361 -317
  69. package/dist/translator/index.js +791 -650
  70. package/dist/translator/util/binding-has-prop.d.ts +2 -0
  71. package/dist/translator/util/entry-builder.d.ts +2 -0
  72. package/dist/translator/util/generate-uid.d.ts +5 -0
  73. package/dist/translator/util/references.d.ts +3 -2
  74. package/dist/translator/util/runtime.d.ts +3 -3
  75. package/dist/translator/util/sections.d.ts +8 -2
  76. package/dist/translator/util/serialize-reasons.d.ts +2 -2
  77. package/dist/translator/util/setup-work.d.ts +5 -0
  78. package/dist/translator/util/signals.d.ts +5 -7
  79. package/dist/translator/visitors/tag/native-tag.d.ts +1 -0
  80. package/package.json +3 -3
  81. package/dist/translator/util/setup-statements.d.ts +0 -5
@@ -26,7 +26,7 @@ var __copyProps = (to, from, except, desc) => {
26
26
  }
27
27
  return to;
28
28
  };
29
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
30
30
  value: mod,
31
31
  enumerable: true
32
32
  }) : target, mod));
@@ -128,7 +128,8 @@ var accessor_prefix_debug_exports = /* @__PURE__ */ __exportAll({
128
128
  KeyedScopes: () => KeyedScopes$1,
129
129
  Lifecycle: () => Lifecycle$1,
130
130
  Promise: () => Promise$2,
131
- TagVariableChange: () => TagVariableChange$3
131
+ TagVariableChange: () => TagVariableChange$3,
132
+ TryBranch: () => TryBranch$3
132
133
  });
133
134
  const BranchScopes$3 = "BranchScopes:";
134
135
  const ClosureScopes$1 = "ClosureScopes:";
@@ -145,6 +146,7 @@ const KeyedScopes$1 = "KeyedScopes:";
145
146
  const Lifecycle$1 = "Lifecycle:";
146
147
  const Promise$2 = "Promise:";
147
148
  const TagVariableChange$3 = "TagVariableChange:";
149
+ const TryBranch$3 = "TryBranch:";
148
150
  //#endregion
149
151
  //#region src/common/constants/accessor-prop.debug.ts
150
152
  var accessor_prop_debug_exports = /* @__PURE__ */ __exportAll({
@@ -166,16 +168,19 @@ var accessor_prop_debug_exports = /* @__PURE__ */ __exportAll({
166
168
  LoopKey: () => LoopKey$1,
167
169
  Owner: () => "_",
168
170
  ParentBranch: () => ParentBranch$1,
171
+ PendingEffectScopes: () => PendingEffectScopes$1,
169
172
  PendingEffects: () => PendingEffects$1,
170
173
  PendingRenders: () => PendingRenders$1,
171
174
  PendingScopes: () => PendingScopes$1,
172
175
  PlaceholderBranch: () => PlaceholderBranch$1,
173
176
  PlaceholderContent: () => PlaceholderContent$1,
174
177
  Renderer: () => Renderer$1,
178
+ ReturnValue: () => ReturnValue$1,
175
179
  StartNode: () => StartNode$1,
176
180
  Subscriptions: () => Subscriptions$1,
177
181
  TagVariable: () => TagVariable$1,
178
- TagVariableChange: () => TagVariableChange$2
182
+ TagVariableChange: () => TagVariableChange$2,
183
+ TryBranch: () => TryBranch$2
179
184
  });
180
185
  const Global$1 = "$global";
181
186
  const AbortControllers$1 = "#AbortControllers";
@@ -194,45 +199,52 @@ const LoopKey$1 = "#LoopKey";
194
199
  const LoopIndex$1 = "#LoopIndex";
195
200
  const ParentBranch$1 = "#ParentBranch";
196
201
  const PendingEffects$1 = "#PendingEffects";
202
+ const PendingEffectScopes$1 = "#PendingEffectScopes";
197
203
  const PendingRenders$1 = "#PendingRenders";
198
204
  const PendingScopes$1 = "#PendingScopes";
199
205
  const PlaceholderBranch$1 = "#PlaceholderBranch";
200
206
  const PlaceholderContent$1 = "#PlaceholderContent";
201
207
  const Renderer$1 = "#Renderer";
208
+ const ReturnValue$1 = "#ReturnValue";
202
209
  const StartNode$1 = "#StartNode";
203
210
  const Subscriptions$1 = "#Subscriptions";
204
211
  const TagVariable$1 = "#TagVariable";
205
212
  const TagVariableChange$2 = "#TagVariableChange";
213
+ const TryBranch$2 = "#TryBranch";
206
214
  //#endregion
207
215
  //#region src/translator/util/traverse.ts
208
216
  const skip = Symbol("skip");
209
217
  function traverseReplace(container, key, enter, state) {
210
218
  const node = container[key];
211
- if (node) if (Array.isArray(node)) for (let i = node.length; i--;) traverseReplace(node, i, enter, state);
212
- else {
213
- const keys = _marko_compiler.types.VISITOR_KEYS[node.type];
214
- for (let i = keys.length; i--;) traverseReplace(node, keys[i], enter, state);
215
- const replacement = enter(node, state);
216
- if (replacement) container[key] = replacement;
219
+ if (node) {
220
+ if (Array.isArray(node)) for (let i = node.length; i--;) traverseReplace(node, i, enter, state);
221
+ else {
222
+ const keys = _marko_compiler.types.VISITOR_KEYS[node.type];
223
+ for (let i = keys.length; i--;) traverseReplace(node, keys[i], enter, state);
224
+ const replacement = enter(node, state);
225
+ if (replacement) container[key] = replacement;
226
+ }
217
227
  }
218
228
  }
219
229
  function traverseContains(node, check) {
220
230
  return !!traverseFind(node, check);
221
231
  }
222
232
  function traverseFind(node, check) {
223
- if (node) if (Array.isArray(node)) for (const item of node) {
224
- const found = traverseFind(item, check);
225
- if (found) return found;
226
- }
227
- else {
228
- switch (check(node)) {
229
- case true: return node;
230
- case skip: return;
231
- }
232
- for (const key of _marko_compiler.types.VISITOR_KEYS[node.type]) {
233
- const found = traverseFind(node[key], check);
233
+ if (node) {
234
+ if (Array.isArray(node)) for (const item of node) {
235
+ const found = traverseFind(item, check);
234
236
  if (found) return found;
235
237
  }
238
+ else {
239
+ switch (check(node)) {
240
+ case true: return node;
241
+ case skip: return;
242
+ }
243
+ for (const key of _marko_compiler.types.VISITOR_KEYS[node.type]) {
244
+ const found = traverseFind(node[key], check);
245
+ if (found) return found;
246
+ }
247
+ }
236
248
  }
237
249
  }
238
250
  function traverseFindAwait(node) {
@@ -401,19 +413,21 @@ const toDelimitedString = function toDelimitedString(val, delimiter, stringify)
401
413
  let str = "";
402
414
  let sep = "";
403
415
  let part;
404
- if (val) if (typeof val !== "object") str += val;
405
- else if (Array.isArray(val)) for (const v of val) {
406
- part = toDelimitedString(v, delimiter, stringify);
407
- if (part) {
408
- str += sep + part;
409
- sep = delimiter;
416
+ if (val) {
417
+ if (typeof val !== "object") str += val;
418
+ else if (Array.isArray(val)) for (const v of val) {
419
+ part = toDelimitedString(v, delimiter, stringify);
420
+ if (part) {
421
+ str += sep + part;
422
+ sep = delimiter;
423
+ }
410
424
  }
411
- }
412
- else for (const name in val) {
413
- part = stringify(name, val[name]);
414
- if (part) {
415
- str += sep + part;
416
- sep = delimiter;
425
+ else for (const name in val) {
426
+ part = stringify(name, val[name]);
427
+ if (part) {
428
+ str += sep + part;
429
+ sep = delimiter;
430
+ }
417
431
  }
418
432
  }
419
433
  return str;
@@ -472,16 +486,8 @@ function generateUid(name = "") {
472
486
  const file = (0, _marko_compiler_babel_utils.getFile)();
473
487
  let counts = countsForFile.get(file);
474
488
  if (!counts) {
475
- const { cache } = file.markoOpts;
476
- const { filename } = file.opts;
477
- const cacheKey = `uid-counts:${filename}`;
478
- counts = cache.get(cacheKey);
479
- if (counts) {
480
- if (isTranslate()) counts = new Map(counts);
481
- } else {
482
- counts = getInitialCounts(file);
483
- if (!isTranslate()) cache.set(cacheKey, counts);
484
- }
489
+ counts = (file.path.node.extra ??= {}).uidCounts ??= getInitialCounts(file);
490
+ if (isTranslate()) counts = new Map(counts);
485
491
  countsForFile.set(file, counts);
486
492
  }
487
493
  name = name.replace(/^[^a-z$_]|[^a-z$_0-9]/gi, "") || "temp";
@@ -498,20 +504,7 @@ const sharedUIDsForFile = /* @__PURE__ */ new WeakMap();
498
504
  function getSharedUid(name, section) {
499
505
  const file = (0, _marko_compiler_babel_utils.getFile)();
500
506
  let sharedUIDs = sharedUIDsForFile.get(file);
501
- if (!sharedUIDs) {
502
- const { cache } = file.markoOpts;
503
- const { filename } = file.opts;
504
- let cacheKey = `uid-shared:${filename}`;
505
- if (section) cacheKey += `:${section.id}`;
506
- sharedUIDs = cache.get(cacheKey);
507
- if (sharedUIDs) {
508
- if (isTranslate()) sharedUIDs = new Map(sharedUIDs);
509
- } else {
510
- sharedUIDs = /* @__PURE__ */ new Map();
511
- if (!isTranslate()) cache.set(cacheKey, sharedUIDs);
512
- }
513
- sharedUIDsForFile.set(file, sharedUIDs);
514
- }
507
+ if (!sharedUIDs) sharedUIDsForFile.set(file, sharedUIDs = /* @__PURE__ */ new Map());
515
508
  const nameKey = section ? `${section.id}:${name}` : name;
516
509
  let uniqueName = sharedUIDs.get(nameKey);
517
510
  if (!uniqueName) {
@@ -562,9 +555,7 @@ function getFnRoot(path) {
562
555
  else switch (curPath.type) {
563
556
  case "OptionalCallExpression":
564
557
  case "CallExpression":
565
- case "NewExpression":
566
- fnPath = void 0;
567
- break;
558
+ case "NewExpression": fnPath = void 0;
568
559
  }
569
560
  const parentPath = curPath.parentPath;
570
561
  if (parentPath) curPath = parentPath;
@@ -626,9 +617,7 @@ function isFunctionOrVariableDeclaration(path) {
626
617
  function getTagName(tag) {
627
618
  switch (tag.node.name.type) {
628
619
  case "StringLiteral": return tag.node.name.value;
629
- case "TemplateLiteral":
630
- if (tag.node.name.quasis.length === 1) return tag.node.name.quasis[0].value.cooked;
631
- break;
620
+ case "TemplateLiteral": if (tag.node.name.quasis.length === 1) return tag.node.name.quasis[0].value.cooked;
632
621
  }
633
622
  }
634
623
  function getStaticTagName(node) {
@@ -643,12 +632,10 @@ function isCoreTag(tag) {
643
632
  const tagDef = (0, _marko_compiler_babel_utils.getTagDef)(tag);
644
633
  if (tagDef) switch (tagDef.taglibId) {
645
634
  case taglibId: return true;
646
- case htmlTaglibId:
647
- switch (tagDef.name) {
648
- case "script":
649
- case "style": return true;
650
- }
651
- break;
635
+ case htmlTaglibId: switch (tagDef.name) {
636
+ case "script":
637
+ case "style": return true;
638
+ }
652
639
  }
653
640
  }
654
641
  return false;
@@ -713,8 +700,10 @@ var Sorted = class {
713
700
  union(a, b) {
714
701
  if (a !== void 0) {
715
702
  if (Array.isArray(a)) {
716
- if (b !== void 0) if (Array.isArray(b)) return unionSortedRepeatable(this.compare, a, b);
717
- else return addSorted(this.compare, a, b);
703
+ if (b !== void 0) {
704
+ if (Array.isArray(b)) return unionSortedRepeatable(this.compare, a, b);
705
+ else return addSorted(this.compare, a, b);
706
+ }
718
707
  return a;
719
708
  }
720
709
  if (b !== void 0) {
@@ -746,11 +735,13 @@ var Sorted = class {
746
735
  }
747
736
  groupBy(data, cb) {
748
737
  const group = /* @__PURE__ */ new Map();
749
- if (data !== void 0) if (Array.isArray(data)) for (const item of data) {
750
- const key = cb(item);
751
- group.set(key, this.union(group.get(key), item));
738
+ if (data !== void 0) {
739
+ if (Array.isArray(data)) for (const item of data) {
740
+ const key = cb(item);
741
+ group.set(key, this.union(group.get(key), item));
742
+ }
743
+ else group.set(cb(data), data);
752
744
  }
753
- else group.set(cb(data), data);
754
745
  return group;
755
746
  }
756
747
  intersects(a, b) {
@@ -808,9 +799,11 @@ function push(data, item) {
808
799
  }
809
800
  function concat(a, b) {
810
801
  if (a !== void 0) {
811
- if (b !== void 0) if (Array.isArray(a)) return a.concat(b);
812
- else if (Array.isArray(b)) return [a, ...b];
813
- else return [a, b];
802
+ if (b !== void 0) {
803
+ if (Array.isArray(a)) return a.concat(b);
804
+ else if (Array.isArray(b)) return [a, ...b];
805
+ else return [a, b];
806
+ }
814
807
  return a;
815
808
  }
816
809
  return b;
@@ -848,10 +841,12 @@ function filter(data, cb) {
848
841
  }
849
842
  }
850
843
  function forEach(data, cb) {
851
- if (data !== void 0) if (Array.isArray(data)) {
852
- let i = 0;
853
- for (const item of data) cb(item, i++);
854
- } else cb(data, 0);
844
+ if (data !== void 0) {
845
+ if (Array.isArray(data)) {
846
+ let i = 0;
847
+ for (const item of data) cb(item, i++);
848
+ } else cb(data, 0);
849
+ }
855
850
  }
856
851
  function fromIter(data) {
857
852
  let one;
@@ -988,8 +983,11 @@ function rest(data) {
988
983
  }
989
984
  //#endregion
990
985
  //#region src/translator/util/binding-has-prop.ts
986
+ function getSectionRendererIdentifier(section) {
987
+ return isSectionRendererElided(section) ? void 0 : _marko_compiler.types.identifier(section.name);
988
+ }
991
989
  function isSectionRendererElided(section) {
992
- return !!section.downstream && !some(section.downstream.binding, (binding) => bindingHasProperty(binding, section.downstream.properties));
990
+ return section.pruned || !!section.downstream && !(section.downstream.tag.tagNameNullable && section.downstream.properties === "content") && !some(section.downstream.binding, (binding) => bindingHasProperty(binding, section.downstream.properties));
993
991
  }
994
992
  function bindingHasProperty(binding, properties) {
995
993
  if (binding.pruned) return false;
@@ -1028,7 +1026,8 @@ var accessor_prefix_exports = /* @__PURE__ */ __exportAll({
1028
1026
  KeyedScopes: () => "O",
1029
1027
  Lifecycle: () => "K",
1030
1028
  Promise: () => "L",
1031
- TagVariableChange: () => "M"
1029
+ TagVariableChange: () => "M",
1030
+ TryBranch: () => "Q"
1032
1031
  });
1033
1032
  //#endregion
1034
1033
  //#region src/common/constants/accessor-prop.ts
@@ -1051,16 +1050,19 @@ var accessor_prop_exports = /* @__PURE__ */ __exportAll({
1051
1050
  LoopKey: () => "M",
1052
1051
  Owner: () => "_",
1053
1052
  ParentBranch: () => "N",
1053
+ PendingEffectScopes: () => "JS",
1054
1054
  PendingEffects: () => "J",
1055
1055
  PendingRenders: () => "W",
1056
1056
  PendingScopes: () => "Y",
1057
1057
  PlaceholderBranch: () => "P",
1058
1058
  PlaceholderContent: () => "Q",
1059
1059
  Renderer: () => "R",
1060
+ ReturnValue: () => "RV",
1060
1061
  StartNode: () => "S",
1061
1062
  Subscriptions: () => "Z",
1062
1063
  TagVariable: () => "T",
1063
- TagVariableChange: () => "U"
1064
+ TagVariableChange: () => "U",
1065
+ TryBranch: () => "PT"
1064
1066
  });
1065
1067
  //#endregion
1066
1068
  //#region src/translator/util/marko-config.ts
@@ -1113,14 +1115,16 @@ function addSerializeReason(section, reason, prop, prefix) {
1113
1115
  }
1114
1116
  }
1115
1117
  function addSerializeExpr(section, expr, prop, prefix) {
1116
- if (expr) if (prop) {
1117
- const key = getPropKey(section, prop, prefix);
1118
- const curExprs = section.propSerializeExprs ??= /* @__PURE__ */ new Map();
1119
- const curExpr = curExprs.get(key);
1120
- curExprs.set(key, curExpr ? concat(curExpr, expr) : expr);
1121
- } else {
1122
- const curExpr = section.serializeExprs;
1123
- section.serializeExprs = curExpr ? concat(curExpr, expr) : expr;
1118
+ if (expr) {
1119
+ if (prop) {
1120
+ const key = getPropKey(section, prop, prefix);
1121
+ const curExprs = section.propSerializeExprs ??= /* @__PURE__ */ new Map();
1122
+ const curExpr = curExprs.get(key);
1123
+ curExprs.set(key, curExpr ? concat(curExpr, expr) : expr);
1124
+ } else {
1125
+ const curExpr = section.serializeExprs;
1126
+ section.serializeExprs = curExpr ? concat(curExpr, expr) : expr;
1127
+ }
1124
1128
  }
1125
1129
  }
1126
1130
  function addOwnerSerializeReason(from, to, reason) {
@@ -1190,11 +1194,6 @@ function mergeSerializeReasons(a, b) {
1190
1194
  function isOwnResumeReason(reason) {
1191
1195
  return !!reason && !!(reason.state || reason.forced);
1192
1196
  }
1193
- function hasOwnResumeReason(section) {
1194
- if (isOwnResumeReason(section.serializeReason)) return true;
1195
- for (const reason of section.serializeReasons.values()) if (isOwnResumeReason(reason)) return true;
1196
- return false;
1197
- }
1198
1197
  function applySerializeExprs(section) {
1199
1198
  const propExprs = section.propSerializeExprs;
1200
1199
  if (propExprs) {
@@ -1263,6 +1262,10 @@ function setPropSerializeReason(section, key, reason) {
1263
1262
  if (!isSameSources(section.serializeReasons.get(key), reason)) reasonsVersion++;
1264
1263
  section.serializeReasons.set(key, reason);
1265
1264
  }
1265
+ function setParamReasonGroups(section, groups) {
1266
+ reasonsVersion++;
1267
+ section.paramReasonGroups = groups;
1268
+ }
1266
1269
  function isSameSources(a, b) {
1267
1270
  return !!a && compareSources(a, b) === 0;
1268
1271
  }
@@ -1328,33 +1331,6 @@ function joinWithAnd(a) {
1328
1331
  }
1329
1332
  }
1330
1333
  //#endregion
1331
- //#region src/html/content.ts
1332
- function _unescaped(val) {
1333
- return val ? val + "" : val === 0 ? "0" : "";
1334
- }
1335
- const unsafeXMLReg = /[<&\r]/g;
1336
- const replaceUnsafeXML = (c) => c === "&" ? "&amp;" : c === "<" ? "&lt;" : "&#13;";
1337
- const escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
1338
- function _escape(val) {
1339
- return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
1340
- }
1341
- const unsafeScriptReg = /<(\/?script|!--)/gi;
1342
- const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C$1") : str;
1343
- function _escape_script(val) {
1344
- return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
1345
- }
1346
- const unsafeStyleReg = /<(\/style)/gi;
1347
- const escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C$1") : str;
1348
- function _escape_style(val) {
1349
- return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
1350
- }
1351
- const unsafeCommentReg = />/g;
1352
- const escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsafeCommentReg, "&gt;") : str;
1353
- function _escape_comment(val) {
1354
- return val ? escapeCommentStr(val + "") : val === 0 ? "0" : "";
1355
- }
1356
- globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask;
1357
- //#endregion
1358
1334
  //#region src/html/attrs.ts
1359
1335
  function _attr_class(value) {
1360
1336
  return stringAttr("class", toDelimitedString(value, " ", stringifyClassObject));
@@ -1394,6 +1370,28 @@ function escapeDoubleQuotedAttrValue(value) {
1394
1370
  function replaceUnsafeDoubleQuoteAttrChar(match) {
1395
1371
  return match === "\"" ? "&#34;" : match === "\r" ? "&#13;" : "&amp;";
1396
1372
  }
1373
+ globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask;
1374
+ //#endregion
1375
+ //#region src/html/content.ts
1376
+ function _unescaped(val) {
1377
+ return val ? val + "" : val === 0 ? "0" : "";
1378
+ }
1379
+ const unsafeXMLReg = /[<&\r]/g;
1380
+ const replaceUnsafeXML = (c) => c === "&" ? "&amp;" : c === "<" ? "&lt;" : "&#13;";
1381
+ const escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
1382
+ function _escape(val) {
1383
+ return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
1384
+ }
1385
+ const unsafeScriptReg = /<(\/?script|!--)/gi;
1386
+ const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C$1") : str;
1387
+ function _escape_script(val) {
1388
+ return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
1389
+ }
1390
+ const unsafeStyleReg = /<(\/style)/gi;
1391
+ const escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C$1") : str;
1392
+ function _escape_style(val) {
1393
+ return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
1394
+ }
1397
1395
  //#endregion
1398
1396
  //#region src/translator/util/to-property-name.ts
1399
1397
  function getMemberExpressionPropString(expr) {
@@ -1494,6 +1492,7 @@ const domRuntimeFeatures = [
1494
1492
  "controllable-textarea",
1495
1493
  "dynamic-tag-script",
1496
1494
  "dynamic-tag-var",
1495
+ "lazy",
1497
1496
  "placeholder"
1498
1497
  ];
1499
1498
  const importedFeatures = /* @__PURE__ */ new WeakMap();
@@ -1504,16 +1503,18 @@ function importRuntimeFeature(feature) {
1504
1503
  if (!features) importedFeatures.set(program.node, features = /* @__PURE__ */ new Set());
1505
1504
  if (!features.has(feature)) {
1506
1505
  features.add(feature);
1507
- const decl = _marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(`${getRuntimePath("dom")}/${feature}.feat`));
1506
+ const decl = getRuntimeFeatureImport(feature);
1508
1507
  const lastImport = program.get("body").findLast((stmt) => stmt.isImportDeclaration());
1509
1508
  if (lastImport) lastImport.insertAfter(decl);
1510
1509
  else program.unshiftContainer("body", decl);
1511
1510
  }
1512
1511
  }
1512
+ function getRuntimeFeatureImport(feature) {
1513
+ return _marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(`${getRuntimePath("dom")}/${feature}.feat`));
1514
+ }
1513
1515
  function getHTMLRuntime() {
1514
1516
  return {
1515
1517
  _escape,
1516
- _escape_comment,
1517
1518
  _unescaped,
1518
1519
  _attr,
1519
1520
  _attr_class,
@@ -1850,7 +1851,6 @@ function startSection(path) {
1850
1851
  referencedHoists: void 0,
1851
1852
  bindings: void 0,
1852
1853
  hoisted: void 0,
1853
- hoistedTo: void 0,
1854
1854
  isHoistThrough: void 0,
1855
1855
  serializeReason: void 0,
1856
1856
  serializeReasons: /* @__PURE__ */ new Map(),
@@ -1865,9 +1865,11 @@ function startSection(path) {
1865
1865
  upstreamExpression: void 0,
1866
1866
  callSections: void 0,
1867
1867
  downstream: void 0,
1868
+ pruned: !!extra.pruned,
1868
1869
  hasAbortSignal: false,
1869
1870
  abortSignalExprs: 0,
1870
1871
  readsOwner: false,
1872
+ hasSetupWork: false,
1871
1873
  isBranch: false,
1872
1874
  structure: parentSection && !parentSection.structure ? null : []
1873
1875
  };
@@ -1886,6 +1888,9 @@ function getOrCreateSection(path) {
1886
1888
  function getSectionForBody(body) {
1887
1889
  return body.node.extra?.section;
1888
1890
  }
1891
+ function removePrunedContent(tag) {
1892
+ if (tag.node.body.extra?.pruned) tag.node.body.body = [];
1893
+ }
1889
1894
  function getSection(path) {
1890
1895
  let section;
1891
1896
  let currentPath = path;
@@ -1978,17 +1983,19 @@ function getNodeContentType(path, extraMember, contentInfo) {
1978
1983
  }
1979
1984
  else if ((0, _marko_compiler_babel_utils.isNativeTag)(tag)) return 3;
1980
1985
  else if ((0, _marko_compiler_babel_utils.isAttributeTag)(tag)) return null;
1981
- else if (_marko_compiler.types.isStringLiteral(tag.node.name)) {
1982
- const tagSection = (0, _marko_compiler_babel_utils.loadFileForTag)(tag)?.ast.program.extra.section;
1983
- if (tagSection) if (tagSection.content) {
1984
- if (contentInfo && !tagSection.content.singleChild) {
1985
- if (extraMember === "endType") {
1986
- contentInfo.startType = tagSection.content.startType;
1987
- contentInfo.singleChild = false;
1986
+ else {
1987
+ const tagSection = tag.node.extra?.defineBodySection || analyzeTagNameType(tag) === 1 && !tag.node.extra.tagNameLoad && (0, _marko_compiler_babel_utils.loadFileForTag)(tag).ast.program.extra.section;
1988
+ if (tagSection) {
1989
+ if (tagSection.content) {
1990
+ if (contentInfo && !tagSection.content.singleChild) {
1991
+ if (extraMember === "endType") {
1992
+ contentInfo.startType = tagSection.content.startType;
1993
+ contentInfo.singleChild = false;
1994
+ }
1988
1995
  }
1989
- }
1990
- return tagSection.content[extraMember];
1991
- } else return null;
1996
+ return tagSection.content[extraMember];
1997
+ } else return null;
1998
+ }
1992
1999
  }
1993
2000
  }
1994
2001
  }
@@ -2066,7 +2073,7 @@ function ensureParamReasonGroup(section, reason) {
2066
2073
  id: Symbol(getDebugNames(reason)),
2067
2074
  reason
2068
2075
  };
2069
- section.paramReasonGroups = paramReasonGroups ? addSorted(compareParamGroups, paramReasonGroups, group) : [group];
2076
+ setParamReasonGroups(section, paramReasonGroups ? addSorted(compareParamGroups, paramReasonGroups, group) : [group]);
2070
2077
  }
2071
2078
  function getParamReasonGroupIndex(section, reason) {
2072
2079
  const index = section.paramReasonGroups && findIndexSorted(compareParamGroups, section.paramReasonGroups, { reason });
@@ -2363,7 +2370,10 @@ const builder = {
2363
2370
  if (state.init || state.load) {
2364
2371
  const isPage = entryFile.path.node.extra.page;
2365
2372
  const initHelper = isPage ? "init" : "initEmbedded";
2366
- if (state.init) body.push(_marko_compiler.types.importDeclaration([_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier(initHelper), _marko_compiler.types.identifier(initHelper))], _marko_compiler.types.stringLiteral(getRuntimePath("dom"))));
2373
+ if (state.init) {
2374
+ body.push(_marko_compiler.types.importDeclaration([_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier(initHelper), _marko_compiler.types.identifier(initHelper))], _marko_compiler.types.stringLiteral(getRuntimePath("dom"))));
2375
+ if (state.lazy) body.push(getRuntimeFeatureImport("lazy"));
2376
+ }
2367
2377
  for (const root of state.roots) body.push(_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(root)));
2368
2378
  if (!state.init) {
2369
2379
  if (exportInit) body.push(_marko_compiler.types.exportDefaultDeclaration(_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement([]))));
@@ -2391,6 +2401,7 @@ const builder = {
2391
2401
  const state = entryFile[kState] ||= {
2392
2402
  init: false,
2393
2403
  load: false,
2404
+ lazy: false,
2394
2405
  bundled: 0,
2395
2406
  roots: [],
2396
2407
  assets: /* @__PURE__ */ new Set(),
@@ -2405,6 +2416,7 @@ const builder = {
2405
2416
  const isRoot = !state.bundled && (init || load || !!programExtra.hasResumes);
2406
2417
  if (init) state.init = true;
2407
2418
  if (load) state.load = true;
2419
+ if (loadImports) state.lazy = true;
2408
2420
  if (isRoot) state.roots.push((0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, file.opts.filename));
2409
2421
  if (assetImports) {
2410
2422
  const assets = isRoot || state.bundled ? state.bundledAssets : state.assets;
@@ -2462,25 +2474,41 @@ function escapeRegExp(str) {
2462
2474
  return str.replace(regexpCharsReg, "\\$&");
2463
2475
  }
2464
2476
  //#endregion
2465
- //#region src/translator/util/setup-statements.ts
2477
+ //#region src/translator/util/setup-work.ts
2466
2478
  /**
2467
- * Tracks during analyze whether translate will add setup-signal statements, so a
2468
- * template can prove its setup export is a noop and parents can skip calling it.
2479
+ * Tracks during analyze whether a section has work keyed by setup, so callers
2480
+ * of a template or `<define>` body can skip calling a noop setup.
2469
2481
  */
2470
- const [getSetupInfo] = createSectionState("setupStatements", () => ({
2482
+ const [getSetupInfo] = createSectionState("setupWork", () => ({
2471
2483
  forced: false,
2472
2484
  exprs: /* @__PURE__ */ new Set()
2473
2485
  }));
2474
- function addSetupStatement(section) {
2486
+ function addSetupWork(section) {
2475
2487
  getSetupInfo(section).forced = true;
2476
2488
  }
2477
2489
  function addSetupExpr(section, node) {
2478
2490
  if (node) getSetupInfo(section).exprs.add(node.extra ??= {});
2479
2491
  else getSetupInfo(section).forced = true;
2480
2492
  }
2481
- function sectionHasSetupStatements(section) {
2493
+ function finalizeSetupWork() {
2494
+ forEachSection((section) => {
2495
+ if (hasOwnSetupWork(section)) section.hasSetupWork = true;
2496
+ });
2497
+ forEachSection((section) => {
2498
+ if (section.hasSetupWork || section.readsOwner) setCallSectionsSetup(section);
2499
+ });
2500
+ }
2501
+ function setCallSectionsSetup(body) {
2502
+ forEach(body.callSections, (callSection) => {
2503
+ if (!callSection.hasSetupWork) {
2504
+ callSection.hasSetupWork = true;
2505
+ setCallSectionsSetup(callSection);
2506
+ }
2507
+ });
2508
+ }
2509
+ function hasOwnSetupWork(section) {
2482
2510
  const info = getSetupInfo(section);
2483
- if (info.forced) return true;
2511
+ if (info.forced || section.referencedClosures) return true;
2484
2512
  for (let extra of info.exprs) {
2485
2513
  while (extra.merged) extra = extra.merged;
2486
2514
  if (!extra.pruned && !extra.referencedBindings) return true;
@@ -2620,22 +2648,24 @@ function normalizeStringExpression(parts, useIife) {
2620
2648
  let curStr = "";
2621
2649
  for (let i = 0; i < parts.length; i++) {
2622
2650
  let content = parts[i];
2623
- if (typeof content === "object") if (_marko_compiler.types.isStringLiteral(content)) content = content.value;
2624
- else if (_marko_compiler.types.isTemplateLiteral(content)) {
2625
- let nextIndex = i + 1;
2626
- const exprLen = content.expressions.length;
2627
- shiftItems(parts, nextIndex, content.quasis.length + exprLen);
2628
- for (let j = 0; j < exprLen; j++) {
2629
- parts[nextIndex++] = content.quasis[j].value.cooked ?? "";
2630
- parts[nextIndex++] = content.expressions[j];
2631
- }
2632
- parts[nextIndex] = content.quasis[exprLen].value.cooked ?? "";
2633
- continue;
2634
- } else {
2635
- exprs.push(content);
2636
- strs.push(curStr);
2637
- curStr = "";
2638
- continue;
2651
+ if (typeof content === "object") {
2652
+ if (_marko_compiler.types.isStringLiteral(content)) content = content.value;
2653
+ else if (_marko_compiler.types.isTemplateLiteral(content)) {
2654
+ let nextIndex = i + 1;
2655
+ const exprLen = content.expressions.length;
2656
+ shiftItems(parts, nextIndex, content.quasis.length + exprLen);
2657
+ for (let j = 0; j < exprLen; j++) {
2658
+ parts[nextIndex++] = content.quasis[j].value.cooked ?? "";
2659
+ parts[nextIndex++] = content.expressions[j];
2660
+ }
2661
+ parts[nextIndex] = content.quasis[exprLen].value.cooked ?? "";
2662
+ continue;
2663
+ } else {
2664
+ exprs.push(content);
2665
+ strs.push(curStr);
2666
+ curStr = "";
2667
+ continue;
2668
+ }
2639
2669
  }
2640
2670
  curStr += content;
2641
2671
  }
@@ -2905,9 +2935,7 @@ function forEachIdentifier(node, cb) {
2905
2935
  if (prop.value.type === "AssignmentPattern") forEachIdentifier(prop.value.left, cb);
2906
2936
  else forEachIdentifier(prop.value, cb);
2907
2937
  break;
2908
- case "RestElement":
2909
- forEachIdentifier(prop.argument, cb);
2910
- break;
2938
+ case "RestElement": forEachIdentifier(prop.argument, cb);
2911
2939
  }
2912
2940
  break;
2913
2941
  case "ArrayPattern":
@@ -2918,14 +2946,10 @@ function forEachIdentifier(node, cb) {
2918
2946
  case "AssignmentPattern":
2919
2947
  forEachIdentifier(el.left, cb);
2920
2948
  break;
2921
- default:
2922
- forEachIdentifier(el, cb);
2923
- break;
2949
+ default: forEachIdentifier(el, cb);
2924
2950
  }
2925
2951
  break;
2926
- case "Identifier":
2927
- cb(node);
2928
- break;
2952
+ case "Identifier": cb(node);
2929
2953
  }
2930
2954
  }
2931
2955
  function forEachIdentifierPath(nodePath, cb) {
@@ -2937,9 +2961,11 @@ function forEachIdentifierPath(nodePath, cb) {
2937
2961
  else forEachIdentifierPath(value, cb);
2938
2962
  } else if (prop.isRestElement()) forEachIdentifierPath(prop.get("argument"), cb);
2939
2963
  } else if (nodePath.isArrayPattern()) {
2940
- for (const el of nodePath.get("elements")) if (el) if (el.isRestElement()) forEachIdentifierPath(el.get("argument"), cb);
2941
- else if (el.isAssignmentPattern()) forEachIdentifierPath(el.get("left"), cb);
2942
- else forEachIdentifierPath(el, cb);
2964
+ for (const el of nodePath.get("elements")) if (el) {
2965
+ if (el.isRestElement()) forEachIdentifierPath(el.get("argument"), cb);
2966
+ else if (el.isAssignmentPattern()) forEachIdentifierPath(el.get("left"), cb);
2967
+ else forEachIdentifierPath(el, cb);
2968
+ }
2943
2969
  }
2944
2970
  }
2945
2971
  //#endregion
@@ -3101,19 +3127,21 @@ function setSectionSerializedValue(section, prop, expression) {
3101
3127
  }
3102
3128
  function setBindingSerializedValue(section, binding, expression, prefix) {
3103
3129
  const reason = getSerializeReason(section, binding, prefix);
3104
- if (reason) if (prefix === void 0) getSerializedAccessors(section).set(getScopeAccessor(binding), {
3105
- expression,
3106
- reason
3107
- });
3108
- else {
3109
- const accessor = getPrefixedScopeAccessor(binding, prefix);
3110
- getSerializedAccessors(section).set(accessor, {
3130
+ if (reason) {
3131
+ if (prefix === void 0) getSerializedAccessors(section).set(getScopeAccessor(binding), {
3111
3132
  expression,
3112
3133
  reason
3113
3134
  });
3114
- if (!isOptimize() && prefix === getAccessorPrefix().TagVariableChange) {
3115
- const { root, access } = getDebugScopeAccess(binding);
3116
- setSectionDebugVar(section, accessor, `${root.name + access}Change`, root.loc);
3135
+ else {
3136
+ const accessor = getPrefixedScopeAccessor(binding, prefix);
3137
+ getSerializedAccessors(section).set(accessor, {
3138
+ expression,
3139
+ reason
3140
+ });
3141
+ if (!isOptimize() && prefix === getAccessorPrefix().TagVariableChange) {
3142
+ const { root, access } = getDebugScopeAccess(binding);
3143
+ setSectionDebugVar(section, accessor, `${root.name + access}Change`, root.loc);
3144
+ }
3117
3145
  }
3118
3146
  }
3119
3147
  }
@@ -3164,7 +3192,6 @@ function getSignal(section, referencedBindings, name) {
3164
3192
  values: [],
3165
3193
  intersection: void 0,
3166
3194
  forwards: void 0,
3167
- prepare: [],
3168
3195
  render: [],
3169
3196
  effect: [],
3170
3197
  hasHTMLEffect: false,
@@ -3197,7 +3224,7 @@ function getSignal(section, referencedBindings, name) {
3197
3224
  const render = getSignalFn(signal);
3198
3225
  const closureSignalBuilder = getClosureSignalBuilder(section);
3199
3226
  if (closureSignalBuilder && !isDynamicClosure(section, closure)) return closureSignalBuilder(closure, render);
3200
- return callRuntime("_closure_get", isOptimize() ? _marko_compiler.types.numericLiteral(getClosureAccessorId(closure)) : getScopeAccessorLiteral(closure, true), render, isImmediateOwner(section, closure) ? void 0 : _marko_compiler.types.arrowFunctionExpression([scopeIdentifier], getScopeExpression(section, closure.section)), isChangeableDynamicClosure(section, closure) ? _marko_compiler.types.stringLiteral(getResumeRegisterId(section, closure, "subscribe")) : void 0);
3227
+ return callRuntime("_closure_get", getClosureAccessorLiteral(closure), render, isImmediateOwner(section, closure) ? void 0 : _marko_compiler.types.arrowFunctionExpression([scopeIdentifier], getScopeExpression(section, closure.section)), isChangeableDynamicClosure(section, closure) ? _marko_compiler.types.stringLiteral(getResumeRegisterId(section, closure, "subscribe")) : void 0);
3201
3228
  };
3202
3229
  }
3203
3230
  return signal;
@@ -3221,7 +3248,7 @@ function initValue(binding, isLet = false) {
3221
3248
  return signal;
3222
3249
  }
3223
3250
  function signalHasStatements(signal) {
3224
- if (signal.extraArgs || signal.forcePersist || signal.prepare.length || signal.render.length || signal.effect.length || signal.hasHTMLEffect || signal.values.length || signal.intersection) return true;
3251
+ if (signal.extraArgs || signal.forcePersist || signal.render.length || signal.effect.length || signal.hasHTMLEffect || signal.values.length || signal.intersection) return true;
3225
3252
  const binding = signal.referencedBindings;
3226
3253
  if (binding) {
3227
3254
  if (!Array.isArray(binding) && (binding.closureSections || binding.type === 0 || binding.section === signal.section && (binding.hoists || binding.aliases.size || hasNonConstantPropertyAlias(binding)))) return true;
@@ -3294,7 +3321,7 @@ function getSignalFn(signal) {
3294
3321
  if (value.signal.inline) continue;
3295
3322
  signal.render.push(_marko_compiler.types.expressionStatement(signalHasStatements(value.signal) ? _marko_compiler.types.callExpression(value.signal.identifier, [
3296
3323
  scopeIdentifier,
3297
- value.value,
3324
+ ...value.value ? [value.value] : [],
3298
3325
  ...getTranslatedExtraArgs(value.signal)
3299
3326
  ]) : withLeadingComment(value.value, getDebugNames(value.signal.referencedBindings))));
3300
3327
  }
@@ -3321,18 +3348,17 @@ function getSignalFn(signal) {
3321
3348
  signal.render.push(_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(effectIdentifier, [scopeIdentifier])));
3322
3349
  }
3323
3350
  if (isValue && getSerializeReason(section, binding)) signal.hasSideEffect = true;
3324
- const render = signal.prepare.length ? signal.prepare.concat(signal.render) : signal.render;
3325
3351
  if (!signal.hasSideEffect) {
3326
- if (isValue && render.length === 1) {
3327
- const first = render[0];
3352
+ if (isValue && signal.render.length === 1) {
3353
+ const first = signal.render[0];
3328
3354
  if (first.type === "ExpressionStatement") {
3329
3355
  const { expression } = first;
3330
3356
  if (expression.type === "CallExpression" && expression.callee.type === "Identifier" && expression.arguments.length === 2 && expression.arguments[0] === scopeIdentifier && isOwnValueRead(expression.arguments[1], binding)) return expression.callee;
3331
3357
  }
3332
3358
  }
3333
- return _marko_compiler.types.arrowFunctionExpression(isValue ? [scopeIdentifier, getSignalValueIdentifier(signal)] : [scopeIdentifier], toFirstExpressionOrBlock(render));
3359
+ return _marko_compiler.types.arrowFunctionExpression(isValue ? [scopeIdentifier, getSignalValueIdentifier(signal)] : [scopeIdentifier], toFirstExpressionOrBlock(signal.render));
3334
3360
  }
3335
- return toScopeFn(render);
3361
+ return toScopeFn(signal.render);
3336
3362
  }
3337
3363
  function toScopeFn(render) {
3338
3364
  if (render.length === 1) {
@@ -3420,17 +3446,20 @@ function addValue(targetSection, referencedBindings, signal, value) {
3420
3446
  signal,
3421
3447
  value
3422
3448
  });
3423
- if (value.extra?.referencedBindingsInFunction) parentSignal.hasSideEffect = true;
3449
+ if ((value?.extra)?.referencedBindingsInFunction) parentSignal.hasSideEffect = true;
3424
3450
  }
3425
3451
  function buildResumeRegisterKey(section, referencedBindings, type) {
3426
3452
  let name = "";
3427
- if (referencedBindings) if (typeof referencedBindings === "string") name += `*${referencedBindings}`;
3428
- else name = reduce(referencedBindings, appendBindingKey, name);
3453
+ if (referencedBindings) {
3454
+ if (typeof referencedBindings === "string") name += `*${referencedBindings}`;
3455
+ else name = reduce(referencedBindings, appendBindingKey, name);
3456
+ }
3429
3457
  return `${section.id}${name}${type ? "/" + type : ""}`;
3430
3458
  }
3431
3459
  function getResumeRegisterId(section, referencedBindings, type) {
3432
3460
  const { markoOpts, opts: { filename } } = (0, _marko_compiler_babel_utils.getFile)();
3433
- return (0, _marko_compiler_babel_utils.getTemplateId)(markoOpts, filename, buildResumeRegisterKey(section, referencedBindings, type));
3461
+ const key = buildResumeRegisterKey(section, referencedBindings, type);
3462
+ return (0, _marko_compiler_babel_utils.getTemplateId)(markoOpts, filename, key);
3434
3463
  }
3435
3464
  function writeSignals(section) {
3436
3465
  const seen = /* @__PURE__ */ new Set();
@@ -3609,7 +3638,7 @@ function writeHTMLResumeStatements(path) {
3609
3638
  if (returnIdentifier !== void 0) body.push(_marko_compiler.types.returnStatement(returnIdentifier));
3610
3639
  }
3611
3640
  function getSetup(section) {
3612
- return section.hoistedTo ? getSignal(section, void 0) : getSignals(section).get(void 0);
3641
+ return getSignals(section).get(void 0);
3613
3642
  }
3614
3643
  function replaceRenderNode(node, signal) {
3615
3644
  return replaceAssignedNode(node) || replaceBindingReadNode$1(node, signal) || replaceRegisteredFunctionNode$1(node);
@@ -3660,52 +3689,50 @@ function replaceAssignedNode(node) {
3660
3689
  }
3661
3690
  break;
3662
3691
  }
3663
- case "AssignmentExpression":
3664
- switch (node.left.type) {
3665
- case "Identifier": {
3666
- const { extra } = node.left;
3667
- if (isAssignedBindingExtra(extra)) {
3668
- const { operator } = node;
3669
- const shortCircuits = operator === "||=" || operator === "&&=" || operator === "??=";
3670
- const readAssigned = () => createScopeReadExpression(extra.assignment, extra.section);
3671
- const builtAssignment = getBuildAssignment(extra)?.(extra.section, operator === "=" || shortCircuits ? node.right : _marko_compiler.types.binaryExpression(operator.slice(0, -1), readAssigned(), node.right));
3672
- if (builtAssignment) return shortCircuits ? _marko_compiler.types.logicalExpression(operator.slice(0, -1), readAssigned(), builtAssignment) : builtAssignment;
3673
- }
3674
- return extra?.assignment && withLeadingComment(node.right, getDebugName(extra.assignment));
3692
+ case "AssignmentExpression": switch (node.left.type) {
3693
+ case "Identifier": {
3694
+ const { extra } = node.left;
3695
+ if (isAssignedBindingExtra(extra)) {
3696
+ const { operator } = node;
3697
+ const shortCircuits = operator === "||=" || operator === "&&=" || operator === "??=";
3698
+ const readAssigned = () => createScopeReadExpression(extra.assignment, extra.section);
3699
+ const builtAssignment = getBuildAssignment(extra)?.(extra.section, operator === "=" || shortCircuits ? node.right : _marko_compiler.types.binaryExpression(operator.slice(0, -1), readAssigned(), node.right));
3700
+ if (builtAssignment) return shortCircuits ? _marko_compiler.types.logicalExpression(operator.slice(0, -1), readAssigned(), builtAssignment) : builtAssignment;
3675
3701
  }
3676
- case "ArrayPattern":
3677
- case "ObjectPattern": {
3678
- let params;
3679
- let assignments;
3680
- forEachIdentifier(node.left, (id) => {
3681
- const { extra } = id;
3682
- if (isAssignedBindingExtra(extra)) {
3683
- const buildAssignment = getBuildAssignment(extra);
3684
- if (buildAssignment) {
3685
- const uid = generateUid(id.name);
3686
- const builtAssignment = buildAssignment(extra.section, _marko_compiler.types.identifier(uid));
3687
- if (builtAssignment) {
3688
- id.name = uid;
3689
- (params ||= []).push(_marko_compiler.types.identifier(uid));
3690
- (assignments ||= []).push(builtAssignment);
3691
- return;
3692
- }
3702
+ return extra?.assignment && withLeadingComment(node.right, getDebugName(extra.assignment));
3703
+ }
3704
+ case "ArrayPattern":
3705
+ case "ObjectPattern": {
3706
+ let params;
3707
+ let assignments;
3708
+ forEachIdentifier(node.left, (id) => {
3709
+ const { extra } = id;
3710
+ if (isAssignedBindingExtra(extra)) {
3711
+ const buildAssignment = getBuildAssignment(extra);
3712
+ if (buildAssignment) {
3713
+ const uid = generateUid(id.name);
3714
+ const builtAssignment = buildAssignment(extra.section, _marko_compiler.types.identifier(uid));
3715
+ if (builtAssignment) {
3716
+ id.name = uid;
3717
+ (params ||= []).push(_marko_compiler.types.identifier(uid));
3718
+ (assignments ||= []).push(builtAssignment);
3719
+ return;
3693
3720
  }
3694
3721
  }
3695
- if (extra?.assignment) (params ||= []).push(_marko_compiler.types.identifier(id.name));
3696
- });
3697
- if (assignments || params) {
3698
- const resultId = generateUid("result");
3699
- return _marko_compiler.types.callExpression(_marko_compiler.types.arrowFunctionExpression([_marko_compiler.types.identifier(resultId), ...params || []], _marko_compiler.types.sequenceExpression([
3700
- _marko_compiler.types.assignmentExpression("=", node.left, _marko_compiler.types.identifier(resultId)),
3701
- ...assignments || [],
3702
- _marko_compiler.types.identifier(resultId)
3703
- ])), [node.right]);
3704
3722
  }
3705
- break;
3723
+ if (extra?.assignment) (params ||= []).push(_marko_compiler.types.identifier(id.name));
3724
+ });
3725
+ if (assignments || params) {
3726
+ const resultId = generateUid("result");
3727
+ return _marko_compiler.types.callExpression(_marko_compiler.types.arrowFunctionExpression([_marko_compiler.types.identifier(resultId), ...params || []], _marko_compiler.types.sequenceExpression([
3728
+ _marko_compiler.types.assignmentExpression("=", node.left, _marko_compiler.types.identifier(resultId)),
3729
+ ...assignments || [],
3730
+ _marko_compiler.types.identifier(resultId)
3731
+ ])), [node.right]);
3706
3732
  }
3733
+ break;
3707
3734
  }
3708
- break;
3735
+ }
3709
3736
  }
3710
3737
  }
3711
3738
  function getChangeHandlerRead(binding, section) {
@@ -3890,9 +3917,11 @@ function resolveStructure(section) {
3890
3917
  break;
3891
3918
  case Child: {
3892
3919
  const content = refContent(op.renderer);
3893
- if (textEdge && content?.startType === 4) separate(resolved);
3894
- textEdge = content?.endType === 4 ? "child" : void 0;
3895
- flushSteps(resolved);
3920
+ if (content) {
3921
+ if (textEdge && content.startType === 4) separate(resolved);
3922
+ textEdge = content.endType === 4 ? "child" : void 0;
3923
+ flushSteps(resolved);
3924
+ }
3896
3925
  const template = op.renderer && resolveRef(op.renderer, "template");
3897
3926
  if (template) resolved.writes.push(template, "");
3898
3927
  resolved.walkComment.push(`<${op.name}${op.hasVar ? "/var" : ""}>`);
@@ -3923,7 +3952,7 @@ function resolveRef(ref, part) {
3923
3952
  return ref.program.section === (0, _marko_compiler_babel_utils.getProgram)().node.extra.section ? _marko_compiler.types.identifier(name) : importOrSelfReferenceName((0, _marko_compiler_babel_utils.getFile)(), ref.path, name, `${ref.hint}_${part}`);
3924
3953
  }
3925
3954
  const [getSectionMeta] = createSectionState("SectionMeta", (section) => {
3926
- if (!section.structure) return {
3955
+ if (!section.structure || section.pruned) return {
3927
3956
  walks: void 0,
3928
3957
  writes: void 0
3929
3958
  };
@@ -4055,50 +4084,53 @@ var dom_default = { translate: {
4055
4084
  const tagParamsIdentifier = tagParamsSignal && signalHasStatements(tagParamsSignal) ? tagParamsSignal.identifier : void 0;
4056
4085
  const { writes } = getSectionMeta(childSection);
4057
4086
  const walks = trimTrailingExits(getSectionMeta(childSection).walks);
4058
- const setup = getSetup(childSection);
4059
4087
  const written = writeSignals(childSection);
4088
+ const setup = getSetup(childSection);
4060
4089
  const setupIdentifier = setup && written.has(setup) ? setup.identifier : void 0;
4061
- if (!isSectionRendererElided(childSection)) if (getSectionParentIsOwner(childSection)) setBranchRendererArgs(childSection, [
4062
- writes,
4063
- walks,
4064
- setupIdentifier,
4065
- tagParamsIdentifier
4066
- ]);
4067
- else {
4068
- const registerReason = getSectionRegisterReasons(childSection);
4069
- const registerId = getResumeRegisterId(childSection, "content");
4070
- const objProps = [];
4071
- forEach(childSection.localClosures, (closure) => {
4072
- const closureSignal = getSignal(childSection, closure);
4073
- const key = toPropertyName(getScopeAccessor(closure, true));
4074
- if (signalHasStatements(closureSignal) || closureSignal.forcePersist) {
4075
- const expr = getSignalFn(closureSignal);
4076
- if (closureSignal.prependStatements) program.node.body.push(...closureSignal.prependStatements);
4077
- if (_marko_compiler.types.isFunction(expr) && _marko_compiler.types.isBlockStatement(expr.body)) objProps.push(_marko_compiler.types.objectMethod("method", key, expr.params, expr.body));
4078
- else objProps.push(_marko_compiler.types.objectProperty(key, expr));
4079
- }
4080
- });
4081
- const registerWrapper = !!(registerReason && objProps.length);
4082
- let renderer = callRuntime("_content", _marko_compiler.types.stringLiteral(registerId), ...replaceNullishAndEmptyFunctionsWith0([
4090
+ if (!isSectionRendererElided(childSection)) {
4091
+ if (getSectionParentIsOwner(childSection)) setBranchRendererArgs(childSection, [
4083
4092
  writes,
4084
4093
  walks,
4085
4094
  setupIdentifier,
4086
- tagParamsIdentifier,
4087
- childSection.hoisted || childSection.isHoistThrough ? getSectionInstancesAccessorLiteral(childSection) : void 0
4088
- ]));
4089
- if (!registerReason || registerWrapper) renderer = _marko_compiler.types.addComment(renderer, "leading", "@__PURE__");
4090
- if (objProps.length) renderer = callRuntime("_content_closures", renderer, _marko_compiler.types.objectExpression(objProps));
4091
- program.node.body.push(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(_marko_compiler.types.identifier(childSection.name), renderer)]));
4092
- if (registerReason && getContentClosures(childSection)) program.node.body.push(_marko_compiler.types.expressionStatement(callRuntime("_content_resume", _marko_compiler.types.identifier(childSection.name), registerWrapper && _marko_compiler.types.numericLiteral(1))));
4093
- else if (registerWrapper) program.node.body.push(_marko_compiler.types.expressionStatement(registerRuntimeValue(registerId, _marko_compiler.types.identifier(childSection.name))));
4095
+ tagParamsIdentifier
4096
+ ]);
4097
+ else {
4098
+ const registerReason = getSectionRegisterReasons(childSection);
4099
+ const registerId = getResumeRegisterId(childSection, "content");
4100
+ const objProps = [];
4101
+ forEach(childSection.localClosures, (closure) => {
4102
+ const closureSignal = getSignal(childSection, closure);
4103
+ const key = toPropertyName(getScopeAccessor(closure, true));
4104
+ if (signalHasStatements(closureSignal) || closureSignal.forcePersist) {
4105
+ const expr = getSignalFn(closureSignal);
4106
+ if (closureSignal.prependStatements) program.node.body.push(...closureSignal.prependStatements);
4107
+ if (_marko_compiler.types.isFunction(expr) && _marko_compiler.types.isBlockStatement(expr.body)) objProps.push(_marko_compiler.types.objectMethod("method", key, expr.params, expr.body));
4108
+ else objProps.push(_marko_compiler.types.objectProperty(key, expr));
4109
+ }
4110
+ });
4111
+ const registerWrapper = !!(registerReason && objProps.length);
4112
+ let renderer = callRuntime("_content", _marko_compiler.types.stringLiteral(registerId), ...replaceNullishAndEmptyFunctionsWith0([
4113
+ writes,
4114
+ walks,
4115
+ setupIdentifier,
4116
+ tagParamsIdentifier,
4117
+ childSection.hoisted || childSection.isHoistThrough ? getSectionInstancesAccessorLiteral(childSection) : void 0
4118
+ ]));
4119
+ if (!registerReason || registerWrapper) renderer = _marko_compiler.types.addComment(renderer, "leading", "@__PURE__");
4120
+ if (objProps.length) renderer = callRuntime("_content_closures", renderer, _marko_compiler.types.objectExpression(objProps));
4121
+ program.node.body.push(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(_marko_compiler.types.identifier(childSection.name), renderer)]));
4122
+ if (registerReason && getContentClosures(childSection)) program.node.body.push(_marko_compiler.types.expressionStatement(callRuntime("_content_resume", _marko_compiler.types.identifier(childSection.name), registerWrapper && _marko_compiler.types.numericLiteral(1))));
4123
+ else if (registerWrapper) program.node.body.push(_marko_compiler.types.expressionStatement(registerRuntimeValue(registerId, _marko_compiler.types.identifier(childSection.name))));
4124
+ }
4094
4125
  }
4095
4126
  }
4096
4127
  });
4097
4128
  const written = writeSignals(section);
4098
4129
  writeRegisteredFns();
4099
4130
  const setup = getSetup(section);
4100
- if (domExports.setupEmpty && setup && written.has(setup)) throw program.buildCodeFrameError("Marko internal error: analysis marked this template's setup export as empty but translation produced statements for it. Please open an issue with a reproduction.");
4101
- if (!setup) program.node.body.unshift(_marko_compiler.types.exportNamedDeclaration(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(setupIdentifier, _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement([])))])));
4131
+ const setupWritten = !!setup && written.has(setup);
4132
+ if (domExports.setupEmpty && setupWritten) throw program.buildCodeFrameError("Marko internal error: analysis marked this template's setup export as empty but translation produced statements for it. Please open an issue with a reproduction.");
4133
+ if (!setupWritten) program.node.body.unshift(_marko_compiler.types.exportNamedDeclaration(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(setupIdentifier, _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement([])))])));
4102
4134
  writeStructureExports(program);
4103
4135
  writeModuleRegistrations(program);
4104
4136
  program.node.body.push(_marko_compiler.types.exportDefaultDeclaration(callRuntime("_template", _marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.getFile)().metadata.marko.id), ...replaceNullishAndEmptyFunctionsWith0([
@@ -4157,8 +4189,10 @@ var html_default = { translate: {
4157
4189
  for (const child of program.get("body")) if (!isStatic(child)) {
4158
4190
  renderContent.push(child.node);
4159
4191
  child.remove();
4160
- } else if (child.isMarkoScriptlet()) if (child.node.target && child.node.target !== "server") child.remove();
4161
- else child.replaceWithMultiple(child.node.body);
4192
+ } else if (child.isMarkoScriptlet()) {
4193
+ if (child.node.target && child.node.target !== "server") child.remove();
4194
+ else child.replaceWithMultiple(child.node.body);
4195
+ }
4162
4196
  writeModuleRegistrations(program);
4163
4197
  const contentId = usedSharedUid("content") && getTemplateContentName();
4164
4198
  const contentFn = _marko_compiler.types.arrowFunctionExpression([_marko_compiler.types.identifier("input")], _marko_compiler.types.blockStatement(renderContent));
@@ -4204,9 +4238,7 @@ function replaceRegisteredFunctionNode(node) {
4204
4238
  case "ArrowFunctionExpression":
4205
4239
  case "FunctionExpression": return getRegisteredFnExpression(node);
4206
4240
  case "BlockStatement":
4207
- case "MarkoScriptlet":
4208
- addRegisteredDeclarations(node.body);
4209
- break;
4241
+ case "MarkoScriptlet": addRegisteredDeclarations(node.body);
4210
4242
  }
4211
4243
  }
4212
4244
  function addRegisteredDeclarations(body) {
@@ -4245,9 +4277,7 @@ function injectTextCoercion(expr) {
4245
4277
  injectTextCoercion(expr.consequent);
4246
4278
  injectTextCoercion(expr.alternate);
4247
4279
  break;
4248
- case "TemplateLiteral":
4249
- expr.expressions = expr.expressions.map((child) => toText(child));
4250
- break;
4280
+ case "TemplateLiteral": expr.expressions = expr.expressions.map((child) => toText(child));
4251
4281
  }
4252
4282
  }
4253
4283
  function toText(value) {
@@ -4315,7 +4345,7 @@ function getOnlyChildParentTagName(tag, branchSize = 1) {
4315
4345
  const extra = tag.node.extra;
4316
4346
  if (extra[kOnlyChildInParent] !== void 0) return extra[kOnlyChildInParent];
4317
4347
  const parentTag = getParentTag(tag);
4318
- return extra[kOnlyChildInParent] = parentTag && analyzeTagNameType(parentTag) === 0 && parentTag.node.name.type === "StringLiteral" && tag.parent.body.filter((node) => node.type !== "MarkoComment").length === branchSize ? parentTag.node.name.value : false;
4348
+ return extra[kOnlyChildInParent] = parentTag && analyzeTagNameType(parentTag) === 0 && parentTag.node.name.type === "StringLiteral" && !isPageElement(parentTag.node.name.value) && tag.parent.body.filter((node) => node.type !== "MarkoComment").length === branchSize ? parentTag.node.name.value : false;
4319
4349
  }
4320
4350
  function getOptimizedOnlyChildNodeBinding(tag, section, branchSize = 1) {
4321
4351
  if (getOnlyChildParentTagName(tag, branchSize)) {
@@ -4664,32 +4694,34 @@ function analyzeAttributeTags(tag) {
4664
4694
  const attrTagNodesByName = {};
4665
4695
  const sampleAttrTagsForControlFlow = /* @__PURE__ */ new Map();
4666
4696
  let chainGroup;
4667
- for (const child of attrTags) if (child.isMarkoTag()) if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
4668
- const name = getTagName(child);
4669
- lookup[name] ||= createAttrTagMeta(name, [name]);
4670
- (attrTagNodesByName[name] ||= []).push(child);
4671
- analyzeAttributeTags(child);
4672
- } else {
4673
- let curGroup = isElseTag(child) ? chainGroup : void 0;
4674
- for (const [name, isRepeated] of crawlAttrTags(child, attrTagNodesByName)) {
4675
- const oldMeta = lookup[name];
4676
- if (oldMeta) {
4677
- if (!curGroup) curGroup = oldMeta.group;
4678
- else if (curGroup !== oldMeta.group) for (const name of oldMeta.group) {
4679
- lookup[name].group = curGroup;
4697
+ for (const child of attrTags) if (child.isMarkoTag()) {
4698
+ if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
4699
+ const name = getTagName(child);
4700
+ lookup[name] ||= createAttrTagMeta(name, [name]);
4701
+ (attrTagNodesByName[name] ||= []).push(child);
4702
+ analyzeAttributeTags(child);
4703
+ } else {
4704
+ let curGroup = isElseTag(child) ? chainGroup : void 0;
4705
+ for (const [name, isRepeated] of crawlAttrTags(child, attrTagNodesByName)) {
4706
+ const oldMeta = lookup[name];
4707
+ if (oldMeta) {
4708
+ if (!curGroup) curGroup = oldMeta.group;
4709
+ else if (curGroup !== oldMeta.group) for (const name of oldMeta.group) {
4710
+ lookup[name].group = curGroup;
4711
+ curGroup.push(name);
4712
+ }
4713
+ }
4714
+ let attrTagMeta = lookup[name];
4715
+ if (!attrTagMeta) {
4716
+ attrTagMeta = lookup[name] = createAttrTagMeta(name, curGroup ||= []);
4680
4717
  curGroup.push(name);
4681
4718
  }
4719
+ attrTagMeta.dynamic = true;
4720
+ if (isRepeated) attrTagMeta.repeated = true;
4721
+ sampleAttrTagsForControlFlow.set(child, name);
4682
4722
  }
4683
- let attrTagMeta = lookup[name];
4684
- if (!attrTagMeta) {
4685
- attrTagMeta = lookup[name] = createAttrTagMeta(name, curGroup ||= []);
4686
- curGroup.push(name);
4687
- }
4688
- attrTagMeta.dynamic = true;
4689
- if (isRepeated) attrTagMeta.repeated = true;
4690
- sampleAttrTagsForControlFlow.set(child, name);
4723
+ chainGroup = curGroup;
4691
4724
  }
4692
- chainGroup = curGroup;
4693
4725
  }
4694
4726
  for (const [controlFlowTag, sampleAttrName] of sampleAttrTagsForControlFlow) (controlFlowTag.node.extra ??= {}).attributeTagGroup = lookup[sampleAttrName].group;
4695
4727
  for (const name in attrTagNodesByName) {
@@ -4711,12 +4743,14 @@ function createAttrTagMeta(name, group) {
4711
4743
  }
4712
4744
  function crawlAttrTags(tag, attrTagNodesByName, attrTagNames = /* @__PURE__ */ new Map(), inLoop = (0, _marko_compiler_babel_utils.isLoopTag)(tag)) {
4713
4745
  const attrTags = getAttrTagPaths(tag);
4714
- for (const child of attrTags) if (child.isMarkoTag()) if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
4715
- const tagName = getTagName(child);
4716
- attrTagNames.set(tagName, inLoop || !!attrTagNames.get(tagName));
4717
- (attrTagNodesByName[tagName] ||= []).push(child);
4718
- analyzeAttributeTags(child);
4719
- } else crawlAttrTags(child, attrTagNodesByName, attrTagNames, inLoop || (0, _marko_compiler_babel_utils.isLoopTag)(child));
4746
+ for (const child of attrTags) if (child.isMarkoTag()) {
4747
+ if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
4748
+ const tagName = getTagName(child);
4749
+ attrTagNames.set(tagName, inLoop || !!attrTagNames.get(tagName));
4750
+ (attrTagNodesByName[tagName] ||= []).push(child);
4751
+ analyzeAttributeTags(child);
4752
+ } else crawlAttrTags(child, attrTagNodesByName, attrTagNames, inLoop || (0, _marko_compiler_babel_utils.isLoopTag)(child));
4753
+ }
4720
4754
  return attrTagNames;
4721
4755
  }
4722
4756
  function hasRepeatedDynamicAttrTags(attrTags) {
@@ -4764,21 +4798,23 @@ function translateAttrs(tag, propTree = true, skip, statements = [], contentKey
4764
4798
  const attrTags = getAttrTagPaths(tag);
4765
4799
  for (let i = 0; i < attrTags.length; i++) {
4766
4800
  const child = attrTags[i];
4767
- if (child.isMarkoTag()) if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
4768
- const attrTagMeta = attrTagLookup[getTagName(child)];
4769
- if (propsUtil.has(skip, attrTagMeta.name)) continue;
4770
- if (attrTagMeta.dynamic) i = addDynamicAttrTagStatements(attrTags, i, attrTagLookup, statements, propTree, contentKey);
4771
- else {
4772
- const translatedAttrTag = translateAttrs(child, getKnownFromPropTree(propTree, attrTagMeta.name), void 0, statements, contentKey);
4773
- const prevProp = attrTagMeta.repeated ? findObjectProperty(attrTagMeta.name, contentProperties) : void 0;
4774
- if (prevProp) prevProp.value = callRuntime("attrTags", prevProp.value, _marko_compiler.types.objectExpression(translatedAttrTag.properties));
4775
- else contentProperties.push(toObjectProperty(attrTagMeta.name, callRuntime("attrTag", _marko_compiler.types.objectExpression(translatedAttrTag.properties))));
4776
- }
4777
- } else i = addDynamicAttrTagStatements(attrTags, i, attrTagLookup, statements, propTree, contentKey);
4801
+ if (child.isMarkoTag()) {
4802
+ if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
4803
+ const attrTagMeta = attrTagLookup[getTagName(child)];
4804
+ if (propsUtil.has(skip, attrTagMeta.name)) continue;
4805
+ if (attrTagMeta.dynamic) i = addDynamicAttrTagStatements(attrTags, i, attrTagLookup, statements, propTree, contentKey);
4806
+ else {
4807
+ const translatedAttrTag = translateAttrs(child, getKnownFromPropTree(propTree, attrTagMeta.name), void 0, statements, contentKey);
4808
+ const prevProp = attrTagMeta.repeated ? findObjectProperty(attrTagMeta.name, contentProperties) : void 0;
4809
+ if (prevProp) prevProp.value = callRuntime("attrTags", prevProp.value, _marko_compiler.types.objectExpression(translatedAttrTag.properties));
4810
+ else contentProperties.push(toObjectProperty(attrTagMeta.name, callRuntime("attrTag", _marko_compiler.types.objectExpression(translatedAttrTag.properties))));
4811
+ }
4812
+ } else i = addDynamicAttrTagStatements(attrTags, i, attrTagLookup, statements, propTree, contentKey);
4813
+ }
4778
4814
  }
4779
4815
  }
4780
4816
  if (!seen.has(contentKey) && getKnownFromPropTree(propTree, contentKey)) {
4781
- const contentExpression = buildContent(tag.get("body"));
4817
+ const contentExpression = buildContent$1(tag.get("body"));
4782
4818
  if (contentExpression) {
4783
4819
  const contentProp = _marko_compiler.types.objectProperty(_marko_compiler.types.identifier(contentKey), contentExpression);
4784
4820
  seen.add(contentKey);
@@ -4808,17 +4844,19 @@ function getTranslatedBodyContentProperty(props) {
4808
4844
  }
4809
4845
  function addDynamicAttrTagStatements(attrTags, index, attrTagLookup, statements, propTree, contentKey = "content") {
4810
4846
  const tag = attrTags[index];
4811
- if (tag.isMarkoTag()) if ((0, _marko_compiler_babel_utils.isAttributeTag)(tag)) {
4812
- const attrTagMeta = attrTagLookup[getTagName(tag)];
4813
- const attrTagExport = getKnownFromPropTree(propTree, attrTagMeta.name);
4814
- if (attrTagExport && attrTagMeta.dynamic) {
4815
- const translatedAttrTag = translateAttrs(tag, attrTagExport, void 0, statements, contentKey);
4816
- if (attrTagMeta.repeated) statements.push(_marko_compiler.types.expressionStatement(_marko_compiler.types.assignmentExpression("=", getAttrTagIdentifier(attrTagMeta), callRuntime("attrTags", getAttrTagIdentifier(attrTagMeta), _marko_compiler.types.objectExpression(translatedAttrTag.properties)))));
4817
- else statements.push(_marko_compiler.types.expressionStatement(_marko_compiler.types.assignmentExpression("=", getAttrTagIdentifier(attrTagMeta), callRuntime("attrTag", _marko_compiler.types.objectExpression(translatedAttrTag.properties)))));
4818
- }
4819
- } else switch (getTagName(tag)) {
4820
- case "if": return translateIfAttrTag(attrTags, index, attrTagLookup, statements, propTree, contentKey);
4821
- case "for": return translateForAttrTag(attrTags, index, attrTagLookup, statements, propTree, contentKey);
4847
+ if (tag.isMarkoTag() && !tag.node.extra.pruned) {
4848
+ if ((0, _marko_compiler_babel_utils.isAttributeTag)(tag)) {
4849
+ const attrTagMeta = attrTagLookup[getTagName(tag)];
4850
+ const attrTagExport = getKnownFromPropTree(propTree, attrTagMeta.name);
4851
+ if (attrTagExport && attrTagMeta.dynamic) {
4852
+ const translatedAttrTag = translateAttrs(tag, attrTagExport, void 0, statements, contentKey);
4853
+ if (attrTagMeta.repeated) statements.push(_marko_compiler.types.expressionStatement(_marko_compiler.types.assignmentExpression("=", getAttrTagIdentifier(attrTagMeta), callRuntime("attrTags", getAttrTagIdentifier(attrTagMeta), _marko_compiler.types.objectExpression(translatedAttrTag.properties)))));
4854
+ else statements.push(_marko_compiler.types.expressionStatement(_marko_compiler.types.assignmentExpression("=", getAttrTagIdentifier(attrTagMeta), callRuntime("attrTag", _marko_compiler.types.objectExpression(translatedAttrTag.properties)))));
4855
+ }
4856
+ } else switch (getTagName(tag)) {
4857
+ case "if": return translateIfAttrTag(attrTags, index, attrTagLookup, statements, propTree, contentKey);
4858
+ case "for": return translateForAttrTag(attrTags, index, attrTagLookup, statements, propTree, contentKey);
4859
+ }
4822
4860
  }
4823
4861
  return index;
4824
4862
  }
@@ -4872,25 +4910,27 @@ function findObjectProperty(name, props) {
4872
4910
  case "StringLiteral":
4873
4911
  if (prop.key.value === name) return prop;
4874
4912
  break;
4875
- case "Identifier":
4876
- if (prop.key.name === name) return prop;
4877
- break;
4913
+ case "Identifier": if (prop.key.name === name) return prop;
4878
4914
  }
4879
4915
  return false;
4880
4916
  }
4881
4917
  function getConditionTestValue({ node: { attributes } }) {
4882
4918
  return attributes.length === 1 ? attributes[0].value : void 0;
4883
4919
  }
4884
- function buildContent(body) {
4920
+ function buildContent$1(body) {
4885
4921
  const bodySection = body.node.extra?.section;
4886
- if (bodySection) if (isOutputHTML()) {
4887
- const serialized = getSectionRegisterReasons(bodySection);
4888
- body.node.body.unshift(getScopeReasonStatement(bodySection));
4889
- return callRuntime(serialized ? "_content_resume" : "_content", _marko_compiler.types.stringLiteral(getResumeRegisterId(bodySection, "content")), _marko_compiler.types.arrowFunctionExpression(body.node.params, _marko_compiler.types.blockStatement(body.node.body)), getScopeIdIdentifier(getSection(getAttributeTagParent(body.parentPath))), serialized && getRegisteredLocals(bodySection));
4890
- } else {
4891
- if (isSectionRendererElided(bodySection)) return;
4892
- const localClosureValues = getLocalClosureValues(bodySection);
4893
- return _marko_compiler.types.callExpression(_marko_compiler.types.identifier(bodySection.name), localClosureValues ? [scopeIdentifier, localClosureValues] : [scopeIdentifier]);
4922
+ if (bodySection) {
4923
+ if (isOutputHTML()) {
4924
+ const serialized = getSectionRegisterReasons(bodySection);
4925
+ body.node.body.unshift(getScopeReasonStatement(bodySection));
4926
+ return callRuntime(serialized ? "_content_resume" : "_content", _marko_compiler.types.stringLiteral(getResumeRegisterId(bodySection, "content")), _marko_compiler.types.arrowFunctionExpression(body.node.params, _marko_compiler.types.blockStatement(body.node.body)), getScopeIdIdentifier(getSection(getAttributeTagParent(body.parentPath))), serialized && getRegisteredLocals(bodySection));
4927
+ } else {
4928
+ const renderer = getSectionRendererIdentifier(bodySection);
4929
+ if (renderer) {
4930
+ const localClosureValues = getLocalClosureValues(bodySection);
4931
+ return _marko_compiler.types.callExpression(renderer, localClosureValues ? [scopeIdentifier, localClosureValues] : [scopeIdentifier]);
4932
+ }
4933
+ }
4894
4934
  }
4895
4935
  }
4896
4936
  function getRegisteredLocals(bodySection) {
@@ -4917,13 +4957,7 @@ var native_tag_default = {
4917
4957
  const { node } = tag;
4918
4958
  if (node.var && !_marko_compiler.types.isIdentifier(node.var)) throw tag.get("var").buildCodeFrameError("Tag variables on [native tags](https://markojs.com/docs/reference/native-tag) cannot be destructured.");
4919
4959
  const tagName = getCanonicalTagName(tag);
4920
- switch (tagName) {
4921
- case "html":
4922
- case "body":
4923
- case "head":
4924
- (0, _marko_compiler_babel_utils.getProgram)().node.extra.page ??= true;
4925
- break;
4926
- }
4960
+ if (isPageElement(tagName)) (0, _marko_compiler_babel_utils.getProgram)().node.extra.page ??= true;
4927
4961
  if (tagName === "option") assertOptionInSelectWithValue(tag);
4928
4962
  const isTextOnly = isTextOnlyNativeTag(tag);
4929
4963
  const seen = Object.create(null);
@@ -5016,8 +5050,8 @@ var native_tag_default = {
5016
5050
  exprExtras = push(exprExtras, textPlaceholders.length === 1 ? textPlaceholders[0].extra ??= {} : mergeReferences(tagSection, textPlaceholders[0], textPlaceholders.slice(1)));
5017
5051
  addSetupExpr(tagSection, textPlaceholders[0]);
5018
5052
  }
5019
- if (injectNonce) addSetupStatement(tagSection);
5020
- if (relatedControllable?.attrs[1]) addSetupStatement(tagSection);
5053
+ if (injectNonce) addSetupWork(tagSection);
5054
+ if (relatedControllable?.attrs[1]) addSetupWork(tagSection);
5021
5055
  for (const name in seen) {
5022
5056
  const attr = seen[name];
5023
5057
  if (isEventHandler(name) || name === "content" || !evaluate(attr.value).confident) addSetupExpr(tagSection, attr.value);
@@ -5048,9 +5082,7 @@ var native_tag_default = {
5048
5082
  }
5049
5083
  break;
5050
5084
  }
5051
- default:
5052
- if (confident) write`${getHTMLRuntime()._attr(name, computed)}`;
5053
- break;
5085
+ default: if (confident) write`${getHTMLRuntime()._attr(name, computed)}`;
5054
5086
  }
5055
5087
  }
5056
5088
  write`>`;
@@ -5111,34 +5143,28 @@ var native_tag_default = {
5111
5143
  if (tagName === "html" && getMarkoOpts().linkAssets && !tag.node.body.body.some((child) => child.type === "MarkoTag" && child.name.type === "StringLiteral" && child.name.value === "head")) writeAtStartOfBody = callRuntime("_flush_head");
5112
5144
  if (tagName === "select") {
5113
5145
  if (staticControllable) htmlSelectArgs.set(tag.node, {
5114
- value: staticControllable.attrs[0]?.value || buildUndefined$1(),
5115
- valueChange: staticControllable.attrs[1]?.value || buildUndefined$1()
5146
+ helper: "_attr_select_value",
5147
+ args: [staticControllable.attrs[0]?.value || buildUndefined$1(), staticControllable.attrs[1]?.value || buildUndefined$1()]
5116
5148
  });
5117
5149
  else if (spreadExpression) {
5118
5150
  const spreadIdentifier = generateUidIdentifier("select_input");
5119
5151
  tag.insertBefore(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(spreadIdentifier, spreadExpression)]));
5120
5152
  htmlSelectArgs.set(tag.node, {
5121
- value: _marko_compiler.types.memberExpression(spreadIdentifier, _marko_compiler.types.identifier("value")),
5122
- valueChange: _marko_compiler.types.memberExpression(spreadIdentifier, _marko_compiler.types.identifier("valueChange")),
5123
- serializeType: _marko_compiler.types.numericLiteral(1)
5153
+ helper: "_attrs_select_value",
5154
+ args: [spreadIdentifier]
5124
5155
  });
5125
5156
  spreadExpression = spreadIdentifier;
5126
5157
  }
5127
5158
  } else if (tagName === "textarea") {
5128
- let value;
5129
- let valueChange;
5130
5159
  if (staticControllable) {
5131
- value = staticControllable.attrs[0]?.value;
5132
- valueChange = staticControllable.attrs[1]?.value;
5160
+ const [value, valueChange] = staticControllable.attrs;
5161
+ writeAtStartOfBody = valueChange ? callRuntime("_attr_textarea_value", getScopeIdIdentifier(tagSection), visitAccessor, value?.value, valueChange.value) : callRuntime("_textarea_value", value.value);
5133
5162
  } else if (spreadExpression) {
5134
5163
  const spreadIdentifier = generateUidIdentifier("textarea_input");
5135
5164
  tag.insertBefore(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(spreadIdentifier, spreadExpression)]));
5136
- value = _marko_compiler.types.memberExpression(spreadIdentifier, _marko_compiler.types.identifier("value"));
5137
- valueChange = _marko_compiler.types.memberExpression(spreadIdentifier, _marko_compiler.types.identifier("valueChange"));
5165
+ writeAtStartOfBody = callRuntime("_attrs_textarea_value", getScopeIdIdentifier(tagSection), visitAccessor, spreadIdentifier);
5138
5166
  spreadExpression = spreadIdentifier;
5139
5167
  }
5140
- if (valueChange) writeAtStartOfBody = callRuntime("_attr_textarea_value", getScopeIdIdentifier(tagSection), visitAccessor, value, valueChange, staticControllable ? void 0 : _marko_compiler.types.numericLiteral(1));
5141
- else if (value) writeAtStartOfBody = callRuntime("_textarea_value", value);
5142
5168
  }
5143
5169
  for (const attr of staticAttrs) {
5144
5170
  const { name, value } = attr;
@@ -5159,14 +5185,12 @@ var native_tag_default = {
5159
5185
  }, (branch) => buildStringAttrAnd(helper, branch) || name === "class" && buildClassAttrExpression(branch) || callRuntime(helper, branch)))}`;
5160
5186
  break;
5161
5187
  }
5162
- default:
5163
- if (confident) write`${getHTMLRuntime()._attr(name, computed)}`;
5164
- else if (isEventHandler(name)) addHTMLEffectCall(tagSection, valueReferences);
5165
- else write`${factorAttrConditional(buildAttrExpression(value, (branch) => {
5166
- const { confident, computed } = evaluate(branch);
5167
- return confident ? getHTMLRuntime()._attr(name, computed) : void 0;
5168
- }, (branch) => buildLogicalAttr(name, branch) || callRuntime("_attr", _marko_compiler.types.stringLiteral(name), branch)))}`;
5169
- break;
5188
+ default: if (confident) write`${getHTMLRuntime()._attr(name, computed)}`;
5189
+ else if (isEventHandler(name)) addHTMLEffectCall(tagSection, valueReferences);
5190
+ else write`${factorAttrConditional(buildAttrExpression(value, (branch) => {
5191
+ const { confident, computed } = evaluate(branch);
5192
+ return confident ? getHTMLRuntime()._attr(name, computed) : void 0;
5193
+ }, (branch) => buildLogicalAttr(name, branch) || callRuntime("_attr", _marko_compiler.types.stringLiteral(name), branch)))}`;
5170
5194
  }
5171
5195
  }
5172
5196
  const isOpenOnly = !!(tagDef && tagDef.parseOptions?.openTagOnly);
@@ -5174,8 +5198,10 @@ var native_tag_default = {
5174
5198
  const spreadContent = !!spreadExpression && spreadRendersContent(tag, staticContentAttr);
5175
5199
  if (spreadExpression) {
5176
5200
  addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
5177
- if (!spreadContent) if (skipExpression) write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), _marko_compiler.types.stringLiteral(tagName))}`;
5178
- else write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), _marko_compiler.types.stringLiteral(tagName))}`;
5201
+ if (!spreadContent) {
5202
+ if (skipExpression) write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), _marko_compiler.types.stringLiteral(tagName))}`;
5203
+ else write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), _marko_compiler.types.stringLiteral(tagName))}`;
5204
+ }
5179
5205
  }
5180
5206
  if (isOpenOnly || isTextOnly) write`>`;
5181
5207
  else if (staticContentAttr) {
@@ -5203,7 +5229,7 @@ var native_tag_default = {
5203
5229
  if (selectArgs) {
5204
5230
  if (!tagExtra[kSkipEndTag]) write`</${tagName}>`;
5205
5231
  flushInto(tag);
5206
- tag.insertBefore(_marko_compiler.types.expressionStatement(callRuntime("_attr_select_value", getScopeIdIdentifier(tagSection), nodeBinding && getScopeAccessorLiteral(nodeBinding), selectArgs.value, selectArgs.valueChange, _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement(tag.node.body.body)), selectArgs.serializeType)));
5232
+ tag.insertBefore(_marko_compiler.types.expressionStatement(callRuntime(selectArgs.helper, getScopeIdIdentifier(tagSection), nodeBinding && getScopeAccessorLiteral(nodeBinding), ...selectArgs.args, _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement(tag.node.body.body)))));
5207
5233
  } else if (isTextOnly) {
5208
5234
  const rawTextHelper = getRawTextEscapeHelper(tagName);
5209
5235
  if (rawTextHelper) {
@@ -5275,11 +5301,9 @@ var native_tag_default = {
5275
5301
  }
5276
5302
  break;
5277
5303
  }
5278
- default:
5279
- if (confident) break;
5280
- else if (isEventHandler(name)) addStatement("effect", tagSection, valueReferences, _marko_compiler.types.expressionStatement(callRuntime("_on", createScopeReadExpression(nodeBinding), _marko_compiler.types.stringLiteral(getEventHandlerName(name)), value)));
5281
- else addStatement("render", tagSection, valueReferences, _marko_compiler.types.expressionStatement(callRuntime("_attr", createScopeReadExpression(nodeBinding), _marko_compiler.types.stringLiteral(name), value)), true);
5282
- break;
5304
+ default: if (confident) break;
5305
+ else if (isEventHandler(name)) addStatement("effect", tagSection, valueReferences, _marko_compiler.types.expressionStatement(callRuntime("_on", createScopeReadExpression(nodeBinding), _marko_compiler.types.stringLiteral(getEventHandlerName(name)), value)));
5306
+ else addStatement("render", tagSection, valueReferences, _marko_compiler.types.expressionStatement(callRuntime("_attr", createScopeReadExpression(nodeBinding), _marko_compiler.types.stringLiteral(name), value)), true);
5283
5307
  }
5284
5308
  }
5285
5309
  if (spreadExpression) {
@@ -5298,10 +5322,12 @@ var native_tag_default = {
5298
5322
  const nodeBinding = tag.node.extra[kNativeTagBinding];
5299
5323
  const openTagOnly = (0, _marko_compiler_babel_utils.getTagDef)(tag)?.parseOptions?.openTagOnly;
5300
5324
  const tagName = getCanonicalTagName(tag);
5301
- if (!openTagOnly) if (tagName !== "textarea" && isTextOnlyNativeTag(tag)) {
5302
- const textLiteral = bodyToTextLiteral(tag.node.body, tagName === "title");
5303
- if (!_marko_compiler.types.isStringLiteral(textLiteral)) addStatement("render", getSection(tag), textLiteral.extra?.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_text_content", createScopeReadExpression(nodeBinding), textLiteral)), true);
5304
- } else tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
5325
+ if (!openTagOnly) {
5326
+ if (tagName !== "textarea" && isTextOnlyNativeTag(tag)) {
5327
+ const textLiteral = bodyToTextLiteral(tag.node.body, tagName === "title");
5328
+ if (!_marko_compiler.types.isStringLiteral(textLiteral)) addStatement("render", getSection(tag), textLiteral.extra?.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_text_content", createScopeReadExpression(nodeBinding), textLiteral)), true);
5329
+ } else tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
5330
+ }
5305
5331
  tag.remove();
5306
5332
  }
5307
5333
  }
@@ -5363,13 +5389,11 @@ function getRelatedControllable(tagName, attrs) {
5363
5389
  };
5364
5390
  break;
5365
5391
  case "details":
5366
- case "dialog":
5367
- if (attrs.open || attrs.openChange) return {
5368
- special: false,
5369
- helper: `_attr_${tagName}_open`,
5370
- attrs: [attrs.open, attrs.openChange]
5371
- };
5372
- break;
5392
+ case "dialog": if (attrs.open || attrs.openChange) return {
5393
+ special: false,
5394
+ helper: `_attr_${tagName}_open`,
5395
+ attrs: [attrs.open, attrs.openChange]
5396
+ };
5373
5397
  }
5374
5398
  }
5375
5399
  function getInputValueMode(typeAttr) {
@@ -5495,10 +5519,13 @@ function warnCamelCaseStyleKeys(tag, attr) {
5495
5519
  if (prop.type !== "ObjectProperty" || prop.computed) continue;
5496
5520
  const { key } = prop;
5497
5521
  const name = key.type === "Identifier" ? key.name : key.type === "StringLiteral" ? key.value : void 0;
5498
- if (name && !name.startsWith("--") && !name.includes("-") && /[A-Z]/.test(name)) (0, _marko_compiler_babel_utils.diagnosticWarn)(tag, {
5499
- label: `\`${name}\` is not a CSS property name; the [\`style=\` object](https://markojs.com/docs/reference/native-tag#style) writes keys out verbatim (unlike the camelCased DOM style API), so this renders as invalid CSS the browser ignores. Use the kebab-case name \`${name.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()).replace(/^ms-/, "-ms-")}\`.`,
5500
- loc: key.loc ?? void 0
5501
- });
5522
+ if (name && !name.startsWith("--") && !name.includes("-") && /[A-Z]/.test(name)) {
5523
+ const kebab = name.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()).replace(/^ms-/, "-ms-");
5524
+ (0, _marko_compiler_babel_utils.diagnosticWarn)(tag, {
5525
+ label: `\`${name}\` is not a CSS property name; the [\`style=\` object](https://markojs.com/docs/reference/native-tag#style) writes keys out verbatim (unlike the camelCased DOM style API), so this renders as invalid CSS the browser ignores. Use the kebab-case name \`${kebab}\`.`,
5526
+ loc: key.loc ?? void 0
5527
+ });
5528
+ }
5502
5529
  }
5503
5530
  }
5504
5531
  function assertNativeHandlerAttr(tag, attr) {
@@ -5644,9 +5671,7 @@ function trackDelimitedAttrValue(expr, meta) {
5644
5671
  case "ArrayExpression":
5645
5672
  trackDelimitedAttrArrayItems(expr, meta);
5646
5673
  break;
5647
- default:
5648
- (meta.dynamicItems ||= []).push(expr);
5649
- break;
5674
+ default: (meta.dynamicItems ||= []).push(expr);
5650
5675
  }
5651
5676
  }
5652
5677
  function trackDelimitedAttrArrayItems(arr, meta) {
@@ -5729,6 +5754,14 @@ function controllableFeatureFor(tagName) {
5729
5754
  function enableControllable(feature) {
5730
5755
  if (feature) importRuntimeFeature(feature);
5731
5756
  }
5757
+ const pageElements = /* @__PURE__ */ new Set([
5758
+ "html",
5759
+ "head",
5760
+ "body"
5761
+ ]);
5762
+ function isPageElement(tagName) {
5763
+ return pageElements.has(tagName);
5764
+ }
5732
5765
  //#endregion
5733
5766
  //#region src/translator/util/branch-tag.ts
5734
5767
  function getBranchSectionAccessor(nodeBinding) {
@@ -5763,7 +5796,7 @@ function getBranchEndArgs(tag, tagSection, nodeBinding, statefulReason, onlyChil
5763
5796
  ];
5764
5797
  }
5765
5798
  function isSingleNodeBranch(bodySection) {
5766
- return !!(bodySection?.content?.singleChild && bodySection.content.startType !== 4);
5799
+ return !!(bodySection?.content?.singleChild && bodySection.content.startType === 3);
5767
5800
  }
5768
5801
  //#endregion
5769
5802
  //#region src/translator/util/to-first-statement-or-block.ts
@@ -5972,7 +6005,6 @@ function assertValidCondition(tag) {
5972
6005
  case "else":
5973
6006
  assertOptionalIfAttribute(tag);
5974
6007
  assertHasPrecedingCondition(tag);
5975
- break;
5976
6008
  }
5977
6009
  }
5978
6010
  function assertHasPrecedingCondition(tag) {
@@ -6081,10 +6113,12 @@ function crawlSectionsAndSetBinding(tag, downstreamTag, binding, exprs, properti
6081
6113
  const attrTagLookup = analyzeAttributeTags(tag);
6082
6114
  if (!attrTagLookup) return;
6083
6115
  const attrTags = getAttrTagPaths(tag);
6084
- for (const child of attrTags) if (child.isMarkoTag()) if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
6085
- const attrTagMeta = attrTagLookup[getTagName(child)];
6086
- crawlSectionsAndSetBinding(child, downstreamTag, binding, exprs, concat(properties, attrTagMeta.name));
6087
- } else crawlSectionsAndSetBinding(child, downstreamTag, binding, exprs, properties, true);
6116
+ for (const child of attrTags) if (child.isMarkoTag()) {
6117
+ if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
6118
+ const attrTagMeta = attrTagLookup[getTagName(child)];
6119
+ crawlSectionsAndSetBinding(child, downstreamTag, binding, exprs, concat(properties, attrTagMeta.name));
6120
+ } else crawlSectionsAndSetBinding(child, downstreamTag, binding, exprs, properties, true);
6121
+ }
6088
6122
  }
6089
6123
  //#endregion
6090
6124
  //#region src/translator/util/translate-var.ts
@@ -6154,14 +6188,14 @@ function knownTagAnalyze(tag, contentSection, propTree) {
6154
6188
  trackParamsReferences(tagBody, 3);
6155
6189
  getKnownTags(section).push(tagExtra);
6156
6190
  tagExtra[kContentSection] = contentSection;
6157
- if (tagExtra.defineBodySection) contentSection.callSections = sectionUtil.add(contentSection.callSections, section);
6191
+ if (contentSection.program === section.program) contentSection.callSections = sectionUtil.add(contentSection.callSections, section);
6158
6192
  const varBinding = trackVarReferences(tag, 5);
6159
6193
  const exprs = tagExtra[kKnownExprs] = analyzeParams(tagExtra, section, tag, propTree, attrExprs);
6160
6194
  setTagDownstream(tag, propTree?.props?.[0]?.binding, exprs);
6161
6195
  if (varBinding) {
6162
- addSetupStatement(section);
6196
+ addSetupWork(section);
6163
6197
  const mutatesTagVar = !!(tag.node.var.type === "Identifier" && tag.scope.getBinding(tag.node.var.name)?.constantViolations.length);
6164
- const varExpr = tagExtra.defineBodySection ? contentSection.returnValueExpr : mapParamReasonToExpr(exprs, contentSection.returnSerializeReason && (contentSection.returnSerializeReason.forced || !!contentSection.returnSerializeReason.state || contentSection.returnSerializeReason.param));
6198
+ const varExpr = isSameOrChildSection(contentSection, section) || (tagExtra.defineBodySection ? contentSection.returnValueExpr : mapParamReasonToExpr(exprs, contentSection.returnSerializeReason && (contentSection.returnSerializeReason.forced || !!contentSection.returnSerializeReason.state || contentSection.returnSerializeReason.param)));
6165
6199
  varBinding.scopeOffset = tagExtra[kChildOffsetScopeBinding$1] = createBinding("#scopeOffset", 0, section);
6166
6200
  setBindingDownstream(varBinding, varExpr);
6167
6201
  if (mutatesTagVar || varExpr === true) addSerializeReason(section, FORCED, childScopeBinding);
@@ -6231,7 +6265,7 @@ function knownTagTranslateDOM(tag, propTree, getBindingIdentifier, callSetup) {
6231
6265
  if (!isOptimize()) changeArgs.push(_marko_compiler.types.stringLiteral(varBinding.name));
6232
6266
  return _marko_compiler.types.callExpression(importRuntime("_var_change"), changeArgs);
6233
6267
  };
6234
- addStatement("prepare", tagSection, void 0, _marko_compiler.types.expressionStatement(callRuntime("_var", scopeIdentifier, getScopeAccessorLiteral(childScopeBinding, true), source.identifier)));
6268
+ addStatement("render", tagSection, void 0, _marko_compiler.types.expressionStatement(callRuntime("_var", scopeIdentifier, getScopeAccessorLiteral(childScopeBinding, true), source.identifier)));
6235
6269
  }
6236
6270
  callSetup?.(tagSection, childScopeBinding);
6237
6271
  if (propTree) writeParamsToSignals(tag, propTree, getTagName(tag) || "tag", {
@@ -6262,7 +6296,7 @@ function buildChildSerializeReason(section, childScopeBinding, reasonGroups) {
6262
6296
  function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
6263
6297
  const inputExpr = {};
6264
6298
  if (!propTree) {
6265
- dropNodes(getAllTagReferenceNodes(tag.node));
6299
+ dropAllTagNodes(tag.node);
6266
6300
  return inputExpr;
6267
6301
  }
6268
6302
  if (!propTree.props || propTree.rest || tag.node.arguments?.some((node) => _marko_compiler.types.isSpreadElement(node))) {
@@ -6286,7 +6320,7 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
6286
6320
  else {
6287
6321
  const args = tag.node.arguments;
6288
6322
  tag.node.arguments = null;
6289
- dropNodes(getAllTagReferenceNodes(tag.node));
6323
+ dropAllTagNodes(tag.node);
6290
6324
  tag.node.arguments = args;
6291
6325
  }
6292
6326
  return inputExpr;
@@ -6308,7 +6342,9 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs, rootE
6308
6342
  const nodeReferencesByGroup = /* @__PURE__ */ new Map();
6309
6343
  const analyzeDynamicAttrTagChildGroup = (group, child) => {
6310
6344
  const referenceNodes = [];
6311
- getAllTagReferenceNodes(child.node, referenceNodes, (0, _marko_compiler_babel_utils.isAttributeTag)(child) ? void 0 : (attrTag) => getKnownFromPropTree(propTree, attrTagLookup[attrTag.name.value].name) ? referenceNodes : dropReferenceNodes);
6345
+ const collectAttrTag = (attrTag) => collectAttrTagReferenceNodes(attrTag, attrTagLookup, propTree, referenceNodes, dropReferenceNodes);
6346
+ if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) collectAttrTag(child.node);
6347
+ else getAllTagReferenceNodes(child.node, referenceNodes, collectAttrTag);
6312
6348
  const groupReferences = nodeReferencesByGroup.get(group);
6313
6349
  if (groupReferences) groupReferences.referenceNodes = groupReferences.referenceNodes.concat(referenceNodes);
6314
6350
  else nodeReferencesByGroup.set(group, {
@@ -6318,22 +6354,24 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs, rootE
6318
6354
  };
6319
6355
  for (const attrTagName in attrTagLookup) seen.add(attrTagLookup[attrTagName].name);
6320
6356
  const attrTags = getAttrTagPaths(tag);
6321
- for (const child of attrTags) if (child.isMarkoTag()) if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
6322
- const attrTagMeta = attrTagLookup[getTagName(child)];
6323
- const childAttrExport = getKnownFromPropTree(propTree, attrTagMeta.name);
6324
- if (!childAttrExport) getAllTagReferenceNodes(child.node, dropReferenceNodes);
6325
- else if (attrTagMeta.dynamic) analyzeDynamicAttrTagChildGroup(attrTagMeta.group, child);
6326
- else if (childAttrExport === true) {
6327
- getAllTagReferenceNodes(child.node, restReferenceNodes ||= []);
6328
- known[attrTagMeta.name] = { value: rootTagExtra };
6329
- } else if (childAttrExport.props) {
6330
- remaining.delete(attrTagMeta.name);
6331
- known[attrTagMeta.name] = analyzeAttrs(rootTagExtra, section, child, childAttrExport, rootAttrExprs, rootExprs);
6332
- } else analyzeDynamicAttrTagChildGroup(attrTagMeta.group, child);
6333
- } else {
6334
- const group = child.node.extra.attributeTagGroup;
6335
- if (hasGroupReads(group, attrTagLookup, propTree)) analyzeDynamicAttrTagChildGroup(group, child);
6336
- else getAllTagReferenceNodes(child.node, dropReferenceNodes);
6357
+ for (const child of attrTags) if (child.isMarkoTag()) {
6358
+ if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
6359
+ const attrTagMeta = attrTagLookup[getTagName(child)];
6360
+ const childAttrExport = getKnownFromPropTree(propTree, attrTagMeta.name);
6361
+ if (!childAttrExport) getAllAttrTagNodes(child.node, dropReferenceNodes);
6362
+ else if (attrTagMeta.dynamic) analyzeDynamicAttrTagChildGroup(attrTagMeta.group, child);
6363
+ else if (childAttrExport === true) {
6364
+ getAllTagReferenceNodes(child.node, restReferenceNodes ||= []);
6365
+ known[attrTagMeta.name] = { value: rootTagExtra };
6366
+ } else if (childAttrExport.props && !(attrTagMeta.repeated && childAttrExport.rest)) {
6367
+ if (remaining.delete(attrTagMeta.name)) known[attrTagMeta.name] = analyzeAttrs(rootTagExtra, section, child, childAttrExport, rootAttrExprs, rootExprs);
6368
+ else getAllAttrTagNodes(child.node, dropReferenceNodes);
6369
+ } else analyzeDynamicAttrTagChildGroup(attrTagMeta.group, child);
6370
+ } else {
6371
+ const group = child.node.extra.attributeTagGroup;
6372
+ if (hasGroupReads(group, attrTagLookup, propTree)) analyzeDynamicAttrTagChildGroup(group, child);
6373
+ else getAllAttrTagNodes(child.node, dropReferenceNodes);
6374
+ }
6337
6375
  }
6338
6376
  for (const [group, { firstTag: { node }, referenceNodes }] of nodeReferencesByGroup) {
6339
6377
  let bindings;
@@ -6369,14 +6407,15 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs, rootE
6369
6407
  }
6370
6408
  }
6371
6409
  const contentExport = getKnownFromPropTree(propTree, "content");
6372
- if (contentExport && !seen.has("content")) {
6410
+ if (!contentExport) dropContent(tag.node.body);
6411
+ else if (!seen.has("content")) {
6373
6412
  if (getSectionForBody(tag.get("body"))) {
6374
6413
  seen.add("content");
6375
6414
  if (contentExport === true) known.content = { value: rootTagExtra };
6376
6415
  else {
6377
6416
  remaining.delete("content");
6378
6417
  known.content = { value: void 0 };
6379
- addSetupStatement(section);
6418
+ addSetupWork(section);
6380
6419
  }
6381
6420
  }
6382
6421
  }
@@ -6422,16 +6461,17 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs, rootE
6422
6461
  addRead(propExtra, propExtra, propBinding, section, void 0);
6423
6462
  setBindingDownstream(templateExportAttr === true ? propTree.rest.binding : templateExportAttr.binding, propExtra, rootExprs);
6424
6463
  }
6425
- else if (spreadReferenceNodes) if (remaining.size || propTree.rest && !propTree.rest.props) {
6426
- inputExpr.value = mergeReferences(section, tag.node, spreadReferenceNodes);
6427
- setBindingDownstream(propTree.rest?.binding || propTree.binding, inputExpr.value, rootExprs);
6428
- } else dropNodes(spreadReferenceNodes);
6429
- else {
6464
+ else if (spreadReferenceNodes) {
6465
+ if (remaining.size || propTree.rest && !propTree.rest.props) {
6466
+ inputExpr.value = mergeReferences(section, tag.node, spreadReferenceNodes);
6467
+ setBindingDownstream(propTree.rest?.binding || propTree.binding, inputExpr.value, rootExprs);
6468
+ } else dropNodes(spreadReferenceNodes);
6469
+ } else {
6430
6470
  if (restReferenceNodes) {
6431
6471
  inputExpr.value = mergeReferences(section, tag.node, restReferenceNodes);
6432
6472
  setBindingDownstream(propTree.rest.binding, inputExpr.value, rootExprs);
6433
6473
  }
6434
- if (remaining.size) addSetupStatement(section);
6474
+ if (remaining.size) addSetupWork(section);
6435
6475
  if (propTree.rest && !propTree.rest.props) addSetupExpr(section, tag.node);
6436
6476
  }
6437
6477
  dropNodes(dropReferenceNodes);
@@ -6453,6 +6493,23 @@ function getSingleKnownSpread(attributes) {
6453
6493
  binding
6454
6494
  };
6455
6495
  }
6496
+ function dropAllTagNodes(tag) {
6497
+ const nodes = [];
6498
+ dropContent(tag.body);
6499
+ dropNodes(getAllTagReferenceNodes(tag, nodes, (attrTag) => getAllAttrTagNodes(attrTag, nodes)));
6500
+ }
6501
+ function collectAttrTagReferenceNodes(attrTag, attrTagLookup, propTree, referenceNodes, dropReferenceNodes) {
6502
+ const attrTagExport = getKnownFromPropTree(propTree, attrTagLookup[attrTag.name.value].name);
6503
+ if (attrTagExport) {
6504
+ if (!getKnownFromPropTree(attrTagExport, "content")) dropContent(attrTag.body);
6505
+ getAllTagReferenceNodes(attrTag, referenceNodes, (nestedAttrTag) => collectAttrTagReferenceNodes(nestedAttrTag, attrTag.extra.attributeTags, attrTagExport, referenceNodes, dropReferenceNodes));
6506
+ } else getAllAttrTagNodes(attrTag, dropReferenceNodes);
6507
+ }
6508
+ function getAllAttrTagNodes(tag, nodes) {
6509
+ nodes.push(tag);
6510
+ if (!tag.body.attributeTags) dropContent(tag.body);
6511
+ return getAllTagReferenceNodes(tag, nodes, (attrTag) => getAllAttrTagNodes(attrTag, nodes));
6512
+ }
6456
6513
  function writeParamsToSignals(tag, propTree, importAlias, info) {
6457
6514
  if (!propTree.props || propTree.rest || tag.node.arguments?.some((node) => _marko_compiler.types.isSpreadElement(node))) {
6458
6515
  const referencedBindings = tag.node.extra?.referencedBindings;
@@ -6479,15 +6536,16 @@ function writeParamsToSignals(tag, propTree, importAlias, info) {
6479
6536
  }
6480
6537
  function applyAttrObject(tag, propTree, tagInputIdentifier, info) {
6481
6538
  const referencedBindings = tag.node.extra?.referencedBindings;
6482
- const translatedAttrs = translateAttrs(tag, true, propTree.rest?.binding.excludeProperties);
6483
- let translatedProps = propsToExpression(translatedAttrs.properties);
6484
- if (translatedAttrs.statements.length) addStatement("render", info.tagSection, referencedBindings, translatedAttrs.statements);
6539
+ const statements = [];
6540
+ let translatedProps;
6485
6541
  if ((0, _marko_compiler_babel_utils.isAttributeTag)(tag)) {
6486
- const repeated = analyzeAttributeTags(tag.parentPath)?.[getTagName(tag)]?.repeated;
6487
- const mergedProps = getAttrTagProps(tag, repeated, _marko_compiler.types.objectExpression(translatedAttrs.properties), info);
6488
- if (!mergedProps) return;
6489
- translatedProps = mergedProps;
6490
- }
6542
+ const attrTagName = getTagName(tag);
6543
+ for (const attrTag of tag.parentPath.get("attributeTags")) if (attrTag.isMarkoTag() && getTagName(attrTag) === attrTagName) {
6544
+ const props = _marko_compiler.types.objectExpression(translateAttrs(attrTag, propTree, void 0, statements).properties);
6545
+ translatedProps = translatedProps ? callRuntime("attrTags", translatedProps, props) : callRuntime("attrTag", props);
6546
+ }
6547
+ } else translatedProps = propsToExpression(translateAttrs(tag, propTree, void 0, statements).properties);
6548
+ if (statements.length) addStatement("render", info.tagSection, referencedBindings, statements);
6491
6549
  addStatement("render", info.tagSection, referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(tagInputIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), translatedProps])), true);
6492
6550
  }
6493
6551
  function translateAttrTag(tag, attrTagMeta, info, statements) {
@@ -6518,7 +6576,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
6518
6576
  const seen = /* @__PURE__ */ new Set();
6519
6577
  const tagReferencedBindings = tag.node.extra?.referencedBindings;
6520
6578
  const remaining = new Set(getAllKnownPropNames(propTree));
6521
- let restProps;
6579
+ const contentProps = [];
6522
6580
  if (attrTagLookup) {
6523
6581
  const attrTags = tag.get("attributeTags");
6524
6582
  const statementsByGroup = /* @__PURE__ */ new Map();
@@ -6534,33 +6592,41 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
6534
6592
  }
6535
6593
  return addDynamicAttrTagStatements(attrTags, index, attrTagLookup, statements, propTree);
6536
6594
  };
6537
- for (const attrTagName in attrTagLookup) seen.add(attrTagLookup[attrTagName].name);
6595
+ for (const attrTagName in attrTagLookup) {
6596
+ const attrTagMeta = attrTagLookup[attrTagName];
6597
+ seen.add(attrTagMeta.name);
6598
+ if (attrTagMeta.dynamic && getKnownFromPropTree(propTree, attrTagMeta.name) === true) contentProps.push(toObjectProperty(attrTagMeta.name, getAttrTagIdentifier(attrTagMeta)));
6599
+ }
6538
6600
  for (let i = 0; i < attrTags.length; i++) {
6539
6601
  const child = attrTags[i];
6540
- if (child.isMarkoTag()) if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
6541
- const attrTagMeta = attrTagLookup[getTagName(child)];
6542
- const childAttrExport = getKnownFromPropTree(propTree, attrTagMeta.name);
6543
- if (!childAttrExport) {} else if (attrTagMeta.dynamic) i = translateDynamicAttrTagChildInGroup(attrTagMeta.group, i);
6544
- else if (childAttrExport === true) {
6545
- const statements = [];
6546
- const translatedAttrs = translateAttrTag(child, attrTagMeta, info, statements);
6547
- addStatement("render", info.tagSection, tagReferencedBindings, statements);
6548
- if (translatedAttrs) (restProps ||= []).push(toObjectProperty(attrTagMeta.name, translatedAttrs));
6602
+ if (child.isMarkoTag()) {
6603
+ if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
6604
+ const attrTagMeta = attrTagLookup[getTagName(child)];
6605
+ const childAttrExport = getKnownFromPropTree(propTree, attrTagMeta.name);
6606
+ if (!childAttrExport) {} else if (attrTagMeta.dynamic) i = translateDynamicAttrTagChildInGroup(attrTagMeta.group, i);
6607
+ else if (childAttrExport === true) {
6608
+ const statements = [];
6609
+ const translatedAttrs = translateAttrTag(child, attrTagMeta, info, statements);
6610
+ addStatement("render", info.tagSection, tagReferencedBindings, statements);
6611
+ if (translatedAttrs) contentProps.push(toObjectProperty(attrTagMeta.name, translatedAttrs));
6612
+ } else if (attrTagMeta.repeated && (!childAttrExport.props || childAttrExport.rest)) {
6613
+ if (remaining.delete(attrTagMeta.name)) applyAttrObject(child, childAttrExport, info.getBindingIdentifier(childAttrExport.binding, `${importAlias}_${attrTagMeta.name}`), info);
6614
+ } else {
6615
+ remaining.delete(attrTagMeta.name);
6616
+ writeAttrsToSignals(child, childAttrExport, `${importAlias}_${attrTagMeta.name}`, info);
6617
+ }
6549
6618
  } else {
6550
- remaining.delete(attrTagMeta.name);
6551
- writeAttrsToSignals(child, childAttrExport, `${importAlias}_${attrTagMeta.name}`, info);
6552
- }
6553
- } else {
6554
- const group = child.node.extra.attributeTagGroup;
6555
- if (hasGroupReads(group, attrTagLookup, propTree)) i = translateDynamicAttrTagChildInGroup(group, i);
6556
- else if (getTagName(child) === "if") while (++i < attrTags.length) {
6557
- const nextTag = attrTags[i];
6558
- switch (nextTag.isMarkoTag() && getTagName(nextTag)) {
6559
- case "else":
6560
- case "else-if": continue;
6619
+ const group = child.node.extra.attributeTagGroup;
6620
+ if (hasGroupReads(group, attrTagLookup, propTree)) i = translateDynamicAttrTagChildInGroup(group, i);
6621
+ else if (getTagName(child) === "if") while (++i < attrTags.length) {
6622
+ const nextTag = attrTags[i];
6623
+ switch (nextTag.isMarkoTag() && getTagName(nextTag)) {
6624
+ case "else":
6625
+ case "else-if": continue;
6626
+ }
6627
+ i--;
6628
+ break;
6561
6629
  }
6562
- i--;
6563
- break;
6564
6630
  }
6565
6631
  }
6566
6632
  }
@@ -6568,8 +6634,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
6568
6634
  const reads = getGroupReads(group, attrTagLookup, propTree);
6569
6635
  const hasRest = reads.some(([, read]) => read === true);
6570
6636
  addStatement("render", info.tagSection, hasRest ? tagReferencedBindings : referencedBindings, [_marko_compiler.types.variableDeclaration("let", reads.map(([attrTagMeta]) => _marko_compiler.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)))), ...statements]);
6571
- for (const [attrTagMeta, read] of reads) if (read === true) (restProps ||= []).push(toObjectProperty(attrTagMeta.name, getAttrTagIdentifier(attrTagMeta)));
6572
- else {
6637
+ for (const [attrTagMeta, read] of reads) if (read !== true) {
6573
6638
  remaining.delete(attrTagMeta.name);
6574
6639
  addStatement("render", info.tagSection, hasRest ? tagReferencedBindings : referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(info.getBindingIdentifier(read.binding, `${importAlias}_${attrTagMeta.name}`), [createScopeReadExpression(info.childScopeBinding, info.tagSection), getAttrTagIdentifier(attrTagMeta)])));
6575
6640
  }
@@ -6580,8 +6645,8 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
6580
6645
  const bodySection = getSectionForBody(tag.get("body"));
6581
6646
  if (bodySection) {
6582
6647
  seen.add("content");
6583
- const bodyValue = _marko_compiler.types.callExpression(_marko_compiler.types.identifier(bodySection.name), [scopeIdentifier]);
6584
- if (contentExport === true) (restProps ||= []).push(toObjectProperty("content", bodyValue));
6648
+ const bodyValue = _marko_compiler.types.callExpression(getSectionRendererIdentifier(bodySection), [scopeIdentifier]);
6649
+ if (contentExport === true) contentProps.push(toObjectProperty("content", bodyValue));
6585
6650
  else {
6586
6651
  remaining.delete("content");
6587
6652
  const directContent = !bodySection.params;
@@ -6590,7 +6655,8 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
6590
6655
  }
6591
6656
  }
6592
6657
  let knownSpread;
6593
- let spreadProps;
6658
+ let hasSpread = false;
6659
+ const attrProps = [];
6594
6660
  const staticAttrs = [];
6595
6661
  const { attributes } = tag.node;
6596
6662
  for (let i = attributes.length; i--;) {
@@ -6599,15 +6665,18 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
6599
6665
  const templateExportAttr = getKnownFromPropTree(propTree, attr.name);
6600
6666
  if (!templateExportAttr || seen.has(attr.name)) continue;
6601
6667
  seen.add(attr.name);
6602
- if (spreadProps) spreadProps.push(toObjectProperty(attr.name, attr.value));
6603
- else if (templateExportAttr === true) (restProps ||= []).push(toObjectProperty(attr.name, attr.value));
6668
+ if (hasSpread || templateExportAttr === true) attrProps.push(toObjectProperty(attr.name, attr.value));
6604
6669
  else staticAttrs.push(attr);
6605
- } else if (spreadProps) spreadProps.push(_marko_compiler.types.spreadElement(attr.value));
6670
+ } else if (hasSpread) attrProps.push(_marko_compiler.types.spreadElement(attr.value));
6606
6671
  else {
6607
6672
  knownSpread = hasAllKnownProps(propTree) ? getSingleKnownSpread(attributes) : void 0;
6608
- if (!knownSpread) (spreadProps = restProps || []).push(_marko_compiler.types.spreadElement(attr.value));
6673
+ if (!knownSpread) {
6674
+ hasSpread = true;
6675
+ attrProps.push(_marko_compiler.types.spreadElement(attr.value));
6676
+ }
6609
6677
  }
6610
6678
  }
6679
+ const inputProps = attrProps.reverse().concat(contentProps);
6611
6680
  for (let i = staticAttrs.length; i--;) {
6612
6681
  const attr = staticAttrs[i];
6613
6682
  const childAttrExports = getKnownFromPropTree(propTree, attr.name);
@@ -6621,8 +6690,8 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
6621
6690
  const propBinding = knownSpread.binding.propertyAliases.get(prop);
6622
6691
  addStatement("render", info.tagSection, propBinding, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(attrExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), createScopeReadExpression(propBinding, info.tagSection)])), true);
6623
6692
  }
6624
- else if (spreadProps && (remaining.size || propTree.rest && !propTree.rest.props)) {
6625
- const spreadExpr = propsToExpression(spreadProps.reverse());
6693
+ else if (hasSpread && (remaining.size || propTree.rest && !propTree.rest.props)) {
6694
+ const spreadExpr = propsToExpression(inputProps);
6626
6695
  let spreadId = spreadExpr;
6627
6696
  if (!isSimpleReference(spreadExpr)) {
6628
6697
  spreadId = generateUidIdentifier(`${importAlias}_spread`);
@@ -6650,7 +6719,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
6650
6719
  const attrExportIdentifier = info.getBindingIdentifier(childAttrExports.binding, `${importAlias}_${name}`);
6651
6720
  addStatement("render", info.tagSection, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(attrExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection)])));
6652
6721
  }
6653
- if (propTree.rest && !propTree.rest.props) addStatement("render", info.tagSection, tagReferencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(info.getBindingIdentifier(propTree.rest.binding, importAlias + "_$rest"), [createScopeReadExpression(info.childScopeBinding, info.tagSection), _marko_compiler.types.objectExpression(restProps || [])])), true);
6722
+ if (propTree.rest && !propTree.rest.props) addStatement("render", info.tagSection, tagReferencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(info.getBindingIdentifier(propTree.rest.binding, importAlias + "_$rest"), [createScopeReadExpression(info.childScopeBinding, info.tagSection), _marko_compiler.types.objectExpression(inputProps)])), true);
6654
6723
  }
6655
6724
  }
6656
6725
  function callStatement(id, ...args) {
@@ -6700,7 +6769,7 @@ var custom_tag_default = {
6700
6769
  if (childSection === programSection && getOrCreateSection(tag) === programSection) throw tag.get("name").buildCodeFrameError(`A template that renders itself outside a branch never terminates. Render \`<${getStaticTagName(tag.node)}>\` inside a branch that eventually stops, such as \`<if>\`.`);
6701
6770
  if (childExtra.page) programExtra.page ??= true;
6702
6771
  if (tagExtra.tagNameLoad) tagExtra[kLoadTagBinding] = createBinding("#text", 0, getOrCreateSection(tag));
6703
- if (tagExtra.tagNameLoad || !childExtra.domExports?.setupEmpty) addSetupStatement(getOrCreateSection(tag));
6772
+ if (tagExtra.tagNameLoad || childSection !== programSection && !childExtra.domExports?.setupEmpty) addSetupWork(getOrCreateSection(tag));
6704
6773
  knownTagAnalyze(tag, childSection, programSection === childSection ? programSection.params && getBindingPropTree(programSection.params) : childExtra.domExports?.params);
6705
6774
  const tagName = getStaticTagName(tag.node);
6706
6775
  if (tagExtra.tagNameLoad) {
@@ -6716,6 +6785,7 @@ var custom_tag_default = {
6716
6785
  } },
6717
6786
  translate: {
6718
6787
  enter(tag) {
6788
+ removePrunedContent(tag);
6719
6789
  if (isOutputHTML()) flushBefore(tag);
6720
6790
  },
6721
6791
  exit(tag) {
@@ -7104,31 +7174,33 @@ function getLiteralName(node) {
7104
7174
  function getAssignmentInsertions(node, insertions) {
7105
7175
  switch (node.type) {
7106
7176
  case "ObjectPattern":
7107
- for (const prop of node.properties) if (prop.type === "ObjectProperty") if (prop.value.type === "AssignmentPattern") {
7108
- const { left, right } = prop.value;
7109
- const sourceName = generateUid(getLiteralName(left) || getLiteralName(prop.key) || "pattern");
7110
- prop.shorthand = false;
7111
- prop.value = _marko_compiler.types.identifier(sourceName);
7112
- (insertions ||= []).push(toConstTag(left, toFallbackExpr(sourceName, right)));
7113
- getAssignmentInsertions(left, insertions);
7114
- } else insertions = getAssignmentInsertions(prop.value, insertions);
7115
- break;
7116
- case "ArrayPattern":
7117
- insertions = getElementInsertions(node.elements, insertions);
7177
+ for (const prop of node.properties) if (prop.type === "ObjectProperty") {
7178
+ if (prop.value.type === "AssignmentPattern") {
7179
+ const { left, right } = prop.value;
7180
+ const sourceName = generateUid(getLiteralName(left) || getLiteralName(prop.key) || "pattern");
7181
+ prop.shorthand = false;
7182
+ prop.value = _marko_compiler.types.identifier(sourceName);
7183
+ (insertions ||= []).push(toConstTag(left, toFallbackExpr(sourceName, right)));
7184
+ getAssignmentInsertions(left, insertions);
7185
+ } else insertions = getAssignmentInsertions(prop.value, insertions);
7186
+ }
7118
7187
  break;
7188
+ case "ArrayPattern": insertions = getElementInsertions(node.elements, insertions);
7119
7189
  }
7120
7190
  return insertions;
7121
7191
  }
7122
7192
  function getElementInsertions(elements, insertions) {
7123
7193
  for (let i = 0, len = elements.length; i < len; i++) {
7124
7194
  const el = elements[i];
7125
- if (el != null) if (el.type === "AssignmentPattern") {
7126
- const { left, right } = el;
7127
- const sourceName = generateUid(getLiteralName(left) || "pattern");
7128
- elements[i] = withPreviousLocation(_marko_compiler.types.identifier(sourceName), el);
7129
- (insertions ||= []).push(toConstTag(left, toFallbackExpr(sourceName, right)));
7130
- getAssignmentInsertions(left, insertions);
7131
- } else insertions = getAssignmentInsertions(el, insertions);
7195
+ if (el != null) {
7196
+ if (el.type === "AssignmentPattern") {
7197
+ const { left, right } = el;
7198
+ const sourceName = generateUid(getLiteralName(left) || "pattern");
7199
+ elements[i] = withPreviousLocation(_marko_compiler.types.identifier(sourceName), el);
7200
+ (insertions ||= []).push(toConstTag(left, toFallbackExpr(sourceName, right)));
7201
+ getAssignmentInsertions(left, insertions);
7202
+ } else insertions = getAssignmentInsertions(el, insertions);
7203
+ }
7132
7204
  }
7133
7205
  return insertions;
7134
7206
  }
@@ -7182,9 +7254,10 @@ var program_default = {
7182
7254
  if (paramsBinding && !paramsBinding.pruned) programExtra.domExports.params = getBindingPropTree(paramsBinding);
7183
7255
  const section = programExtra.section;
7184
7256
  forEachSection((childSection) => {
7185
- programExtra.hasResumes ||= !!(hasOwnResumeReason(childSection) || childSection !== section && !isSectionRendererElided(childSection) && getSectionRegisterReasons(childSection));
7257
+ programExtra.hasResumes ||= !!(isOwnResumeReason(childSection.serializeReason) || childSection !== section && !isSectionRendererElided(childSection) && getSectionRegisterReasons(childSection));
7186
7258
  });
7187
- if (!section.hoistedTo && !sectionHasSetupStatements(section)) programExtra.domExports.setupEmpty = true;
7259
+ finalizeSetupWork();
7260
+ if (!section.hasSetupWork) programExtra.domExports.setupEmpty = true;
7188
7261
  }
7189
7262
  },
7190
7263
  translate: {
@@ -7666,8 +7739,10 @@ function mergeReferences(section, target, nodes) {
7666
7739
  reads = concat(reads, additionalReads);
7667
7740
  readsByExpression.delete(extra);
7668
7741
  }
7669
- if (additionalExprFnReads) if (exprFnReads) for (const [key, value] of additionalExprFnReads) exprFnReads.set(key, value);
7670
- else fnReadsByExpression.set(targetExtra, exprFnReads = new Map(additionalExprFnReads));
7742
+ if (additionalExprFnReads) {
7743
+ if (exprFnReads) for (const [key, value] of additionalExprFnReads) exprFnReads.set(key, value);
7744
+ else fnReadsByExpression.set(targetExtra, exprFnReads = new Map(additionalExprFnReads));
7745
+ }
7671
7746
  } else if (extra?.pruned)
7672
7747
  /* v8 ignore next -- a dropped reference is never merged into another */
7673
7748
  throw new Error("Cannot merged a dropped reference.");
@@ -7736,7 +7811,7 @@ function finalizeReferences() {
7736
7811
  expr.referencedBindings = exprBindings.referencedBindings;
7737
7812
  expr.lazyBindings = exprBindings.lazyBindings;
7738
7813
  expr.globalBindings = exprBindings.globalBindings;
7739
- if (!exprBindings.referencedBindings) addSetupStatement(expr.section);
7814
+ if (!exprBindings.referencedBindings) addSetupWork(expr.section);
7740
7815
  forEach(exprBindings.lazyBindings, (binding) => {
7741
7816
  binding.forcePersist = true;
7742
7817
  });
@@ -7785,7 +7860,6 @@ function finalizeReferences() {
7785
7860
  let highestHoistSection;
7786
7861
  forEach(binding.hoists, (hoistSection) => {
7787
7862
  if (!highestHoistSection || hoistSection.depth < highestHoistSection.depth) highestHoistSection = hoistSection;
7788
- hoistSection.hoistedTo = bindingUtil.add(hoistSection.hoistedTo, binding);
7789
7863
  forceSerialize(binding);
7790
7864
  });
7791
7865
  binding.section.hoisted = bindingUtil.add(binding.section.hoisted, binding);
@@ -7827,6 +7901,7 @@ function finalizeReferences() {
7827
7901
  addSerializeExpr(section.parent, section.upstreamExpression, section.sectionAccessor.binding);
7828
7902
  }
7829
7903
  });
7904
+ for (const finalize of getReferenceFinalizers()) finalize();
7830
7905
  forEachSection(applySerializeExprs);
7831
7906
  let reasonsVersion;
7832
7907
  do {
@@ -7842,6 +7917,7 @@ function finalizeReferences() {
7842
7917
  });
7843
7918
  } while (reasonsVersion !== getSerializeReasonsVersion());
7844
7919
  finalizeFunctionRegistry();
7920
+ const closureIdEnds = /* @__PURE__ */ new Map();
7845
7921
  forEachSection((section) => {
7846
7922
  const { id, bindings } = section;
7847
7923
  const isOwnedBinding = ({ section }) => section.id === id;
@@ -7892,13 +7968,17 @@ function finalizeReferences() {
7892
7968
  intersectionIndex++;
7893
7969
  assignIntersectionId(intersection);
7894
7970
  }
7971
+ let closureId = section.parent ? closureIdEnds.get(section.parent) : 0;
7895
7972
  forEach(ownedBindings, (binding) => {
7896
- if (binding.closureSections) closureAccessorIds.set(binding, nextId++);
7973
+ if (binding.closureSections) {
7974
+ closureId = Math.max(closureId, nextId);
7975
+ closureAccessorIds.set(binding, closureId++);
7976
+ }
7897
7977
  });
7978
+ closureIdEnds.set(section, closureId);
7898
7979
  });
7899
7980
  const programSection = (0, _marko_compiler_babel_utils.getProgram)().node.extra.section;
7900
7981
  if (programSection.returnValueExpr) programSection.returnSerializeReason = getSerializeSourcesForExpr(programSection.returnValueExpr);
7901
- for (const finalize of getReferenceFinalizers()) finalize();
7902
7982
  readsByExpression.clear();
7903
7983
  fnReadsByExpression.clear();
7904
7984
  }
@@ -8161,6 +8241,7 @@ function addRead(exprExtra, extra, binding, section, getter) {
8161
8241
  comparedTo: void 0,
8162
8242
  deferred: false
8163
8243
  };
8244
+ if (section.pruned) return read;
8164
8245
  binding.reads.add(exprExtra);
8165
8246
  exprExtra.section = section;
8166
8247
  readsByExpression.set(exprExtra, push(readsByExpression.get(exprExtra), read));
@@ -8169,8 +8250,8 @@ function addRead(exprExtra, extra, binding, section, getter) {
8169
8250
  function isEmitted(exprExtra) {
8170
8251
  return !getCanonicalExtra(exprExtra).pruned;
8171
8252
  }
8172
- function inEmittedExpr({ exprRoot }) {
8173
- return isEmitted(exprRoot);
8253
+ function inEmittedExpr({ exprRoot, section }) {
8254
+ return !section.pruned && isEmitted(exprRoot);
8174
8255
  }
8175
8256
  function isDroppableValue(expr) {
8176
8257
  return !!expr.pure && !expr.merged && !expr.pruned;
@@ -8202,10 +8283,33 @@ function untrackExtra(exprExtra) {
8202
8283
  getFunctionReadsByExpression().delete(exprExtra);
8203
8284
  forEach(reads, (read) => {
8204
8285
  read.binding.reads.delete(exprExtra);
8205
- if (!exprExtra.pruned) read.binding.untracked = true;
8286
+ if (!exprExtra.pruned && !exprExtra.section.pruned) read.binding.untracked = true;
8206
8287
  });
8207
8288
  }
8208
8289
  }
8290
+ function dropContent(body) {
8291
+ const bodyExtra = body.extra ??= {};
8292
+ bodyExtra.pruned = true;
8293
+ if (bodyExtra.section) bodyExtra.section.pruned = true;
8294
+ for (const param of body.params) untrackNode(param);
8295
+ dropChildren(body.body);
8296
+ }
8297
+ function dropChildren(children) {
8298
+ for (const child of children) switch (child.type) {
8299
+ case "MarkoTag":
8300
+ untrackNode(child.name);
8301
+ if (child.arguments) for (const arg of child.arguments) untrackNode(arg);
8302
+ if (child.var) untrackNode(child.var);
8303
+ for (const attr of child.attributes) untrackNode(attr.value);
8304
+ dropChildren(child.attributeTags);
8305
+ dropContent(child.body);
8306
+ break;
8307
+ case "MarkoPlaceholder":
8308
+ untrackNode(child.value);
8309
+ break;
8310
+ case "MarkoScriptlet": for (const statement of child.body) untrackNode(statement);
8311
+ }
8312
+ }
8209
8313
  function isSerializedChangeHandlerRead(exprRoot) {
8210
8314
  const markoRoot = getMarkoRoot(exprRoot);
8211
8315
  if (!markoRoot?.isMarkoAttribute()) return false;
@@ -8261,17 +8365,15 @@ function someUpstream(binding, test, arg) {
8261
8365
  function isDirectAlias(binding) {
8262
8366
  return binding.upstreamAlias !== void 0 && binding.property === void 0 && binding.excludeProperties === void 0;
8263
8367
  }
8264
- function getAllTagReferenceNodes(tag, referenceNodes = [], getAttrTagNodes) {
8368
+ function getAllTagReferenceNodes(tag, referenceNodes = [], collectAttrTag) {
8265
8369
  if (tag.arguments) for (const arg of tag.arguments) referenceNodes.push(arg);
8266
8370
  for (const attr of tag.attributes) referenceNodes.push(attr.value);
8267
8371
  for (const child of tag.body.attributeTags ? tag.body.body : tag.attributeTags) switch (child.type) {
8268
8372
  case "MarkoTag":
8269
- if (getAttrTagNodes && _marko_compiler.types.isStringLiteral(child.name) && child.name.value[0] === "@") getAllTagReferenceNodes(child, getAttrTagNodes(child));
8270
- else getAllTagReferenceNodes(child, referenceNodes, getAttrTagNodes);
8271
- break;
8272
- case "MarkoScriptlet":
8273
- for (const statement of child.body) referenceNodes.push(statement);
8373
+ if (collectAttrTag && _marko_compiler.types.isStringLiteral(child.name) && child.name.value[0] === "@") collectAttrTag(child);
8374
+ else getAllTagReferenceNodes(child, referenceNodes, collectAttrTag);
8274
8375
  break;
8376
+ case "MarkoScriptlet": for (const statement of child.body) referenceNodes.push(statement);
8275
8377
  }
8276
8378
  return referenceNodes;
8277
8379
  }
@@ -8298,8 +8400,15 @@ function getPrefixedScopeAccessor(binding, prefix) {
8298
8400
  case getAccessorPrefix().ClosureScopes: return decodeAccessor(getClosureAccessorId(canonicalBinding));
8299
8401
  case getAccessorPrefix().ClosureSignalIndex: return prefix + decodeAccessor(getClosureAccessorId(canonicalBinding));
8300
8402
  }
8403
+ else if (prefix === getAccessorPrefix().ClosureScopes || prefix === getAccessorPrefix().ClosureSignalIndex) return prefix + getDebugClosureAccessor(binding);
8301
8404
  return prefix + getScopeAccessor(binding);
8302
8405
  }
8406
+ function getClosureAccessorLiteral(binding) {
8407
+ return isOptimize() ? _marko_compiler.types.numericLiteral(getClosureAccessorId(binding)) : _marko_compiler.types.stringLiteral(getDebugClosureAccessor(binding));
8408
+ }
8409
+ function getDebugClosureAccessor(binding) {
8410
+ return `${getScopeAccessor(binding)}/${getClosureAccessorId(binding)}`;
8411
+ }
8303
8412
  function getClosureAccessorId(binding) {
8304
8413
  const id = closureAccessorIds.get(getCanonicalBinding(binding));
8305
8414
  /* v8 ignore next 5 -- analyze reserves an id for every closure binding */
@@ -8390,9 +8499,10 @@ function getReadReplacement(node, signal) {
8390
8499
  let curNode = node;
8391
8500
  let curBinding = readBinding;
8392
8501
  let replaceMember;
8393
- if (isOutputDOM()) if (signal?.referencedBindings === readBinding && !signal.hasSideEffect) replacement = getSignalValueIdentifier(signal);
8394
- else replacement = createScopeReadExpression(readBinding, extra.section);
8395
- else replacement = _marko_compiler.types.identifier(readBinding.name);
8502
+ if (isOutputDOM()) {
8503
+ if (signal?.referencedBindings === readBinding && !signal.hasSideEffect) replacement = getSignalValueIdentifier(signal);
8504
+ else replacement = createScopeReadExpression(readBinding, extra.section);
8505
+ } else replacement = _marko_compiler.types.identifier(readBinding.name);
8396
8506
  while (remaining && (curNode.type === "MemberExpression" || curNode.type === "OptionalMemberExpression")) {
8397
8507
  const prop = at(props, --remaining);
8398
8508
  if (getMemberExpressionPropString(curNode) !== prop) break;
@@ -8868,7 +8978,7 @@ var await_default = {
8868
8978
  setBindingDownstream(paramsBinding, valueExtra);
8869
8979
  }
8870
8980
  bodySection.upstreamExpression = valueAttr.value.extra;
8871
- addSetupStatement(section);
8981
+ addSetupWork(section);
8872
8982
  visit(tag, 37);
8873
8983
  enterShallow(tag);
8874
8984
  },
@@ -9123,7 +9233,9 @@ var define_default = {
9123
9233
  if (bodySection && hasDirectReferences) {
9124
9234
  const signal = getSignal(bodySection, void 0);
9125
9235
  signal.build = () => {
9126
- if (signalHasStatements(signal)) return callRuntime("_child_setup", getSignalFn(signal));
9236
+ const hasStatements = signalHasStatements(signal);
9237
+ if (hasStatements && !bodySection.hasSetupWork) throw new Error("Marko internal error: analysis marked a `<define>` body's setup as empty but translation produced statements for it. Please open an issue with a reproduction.");
9238
+ if (bodySection.hasSetupWork) return callRuntime("_child_setup", hasStatements ? getSignalFn(signal) : _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.numericLiteral(0)));
9127
9239
  };
9128
9240
  }
9129
9241
  if (bodySection && allDirectReferences) {
@@ -9239,9 +9351,10 @@ var html_comment_default = {
9239
9351
  if (isOutputHTML()) {
9240
9352
  const { body } = tag.node.body;
9241
9353
  write`<!--`;
9242
- if (nodeBinding && isEmptiableCommentBody(body)) if (body.length) write`${_marko_compiler.types.logicalExpression("||", buildCommentValue(body), _marko_compiler.types.stringLiteral(" "))}`;
9243
- else write` `;
9244
- else for (const child of body) if (_marko_compiler.types.isMarkoText(child)) write`${escapeCommentText(child.value)}`;
9354
+ if (nodeBinding && isEmptiableCommentBody(body)) {
9355
+ if (body.length) write`${_marko_compiler.types.logicalExpression("||", buildCommentValue(body), _marko_compiler.types.stringLiteral(" "))}`;
9356
+ else write` `;
9357
+ } else for (const child of body) if (_marko_compiler.types.isMarkoText(child)) write`${escapeCommentText(child.value)}`;
9245
9358
  else if (_marko_compiler.types.isMarkoPlaceholder(child)) write`${callRuntime(child.escape ? "_escape_comment" : "_unescaped", child.value)}`;
9246
9359
  write`-->`;
9247
9360
  } else {
@@ -9378,22 +9491,24 @@ var let_default = {
9378
9491
  const tagVar = node.var;
9379
9492
  let valueAttr;
9380
9493
  let valueChangeAttr;
9381
- for (const attr of node.attributes) if (_marko_compiler.types.isMarkoAttribute(attr)) if (attr.name === "value") {
9382
- if (valueAttr) throw tag.hub.buildError(attr, "Invalid duplicate value attribute.");
9383
- valueAttr = attr;
9384
- } else if (attr.name === "valueChange") {
9385
- if (valueChangeAttr) throw tag.hub.buildError(attr, "Invalid duplicate valueChange attribute.");
9386
- valueChangeAttr = attr;
9387
- } else {
9388
- const start = attr.loc?.start;
9389
- const end = attr.loc?.end;
9390
- let msg = "The [`<let>` tag](https://markojs.com/docs/reference/core-tag#let) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value) and its change handler.";
9391
- if (!tagVar && /^[A-Za-z_$][\w$]*$/.test(attr.name)) msg += ` To declare reactive state, the variable goes after a slash: \`<let/${attr.name}=...>\`. For a one time module level value, prefix a plain JavaScript statement with \`static\`.`;
9392
- if (start == null || end == null) throw tag.get("name").buildCodeFrameError(msg);
9393
- else throw tag.hub.buildError({ loc: {
9394
- start,
9395
- end
9396
- } }, msg, Error);
9494
+ for (const attr of node.attributes) if (_marko_compiler.types.isMarkoAttribute(attr)) {
9495
+ if (attr.name === "value") {
9496
+ if (valueAttr) throw tag.hub.buildError(attr, "Invalid duplicate value attribute.");
9497
+ valueAttr = attr;
9498
+ } else if (attr.name === "valueChange") {
9499
+ if (valueChangeAttr) throw tag.hub.buildError(attr, "Invalid duplicate valueChange attribute.");
9500
+ valueChangeAttr = attr;
9501
+ } else {
9502
+ const start = attr.loc?.start;
9503
+ const end = attr.loc?.end;
9504
+ let msg = "The [`<let>` tag](https://markojs.com/docs/reference/core-tag#let) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value) and its change handler.";
9505
+ if (!tagVar && /^[A-Za-z_$][\w$]*$/.test(attr.name)) msg += ` To declare reactive state, the variable goes after a slash: \`<let/${attr.name}=...>\`. For a one time module level value, prefix a plain JavaScript statement with \`static\`.`;
9506
+ if (start == null || end == null) throw tag.get("name").buildCodeFrameError(msg);
9507
+ else throw tag.hub.buildError({ loc: {
9508
+ start,
9509
+ end
9510
+ } }, msg, Error);
9511
+ }
9397
9512
  }
9398
9513
  (0, _marko_compiler_babel_utils.assertNoArgs)(tag);
9399
9514
  (0, _marko_compiler_babel_utils.assertNoParams)(tag);
@@ -9522,6 +9637,7 @@ var log_default = {
9522
9637
  };
9523
9638
  //#endregion
9524
9639
  //#region src/translator/core/script.ts
9640
+ const htmlScriptTagAlternateMsg = " For a native html [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) use the `html-script` core tag instead.";
9525
9641
  var script_default = {
9526
9642
  parse(tag) {
9527
9643
  const { node } = tag;
@@ -9529,7 +9645,7 @@ var script_default = {
9529
9645
  if (body.length) {
9530
9646
  let code = "";
9531
9647
  for (const child of body) {
9532
- if (child.type !== "MarkoText") throw (0, _marko_compiler_babel_utils.getFile)().hub.buildError(child, "Unexpected content in [`<script>` tag](https://markojs.com/docs/reference/core-tag#script). Only javascript and typescript is supported. For a native html [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) use the `html-script` core tag instead.", SyntaxError);
9648
+ if (child.type !== "MarkoText") throw (0, _marko_compiler_babel_utils.getFile)().hub.buildError(child, "Unexpected content in [`<script>` tag](https://markojs.com/docs/reference/core-tag#script). Only javascript and typescript is supported." + htmlScriptTagAlternateMsg, SyntaxError);
9533
9649
  code += child.value;
9534
9650
  }
9535
9651
  const start = body[0]?.start;
@@ -9548,7 +9664,7 @@ var script_default = {
9548
9664
  (0, _marko_compiler_babel_utils.assertNoParams)(tag);
9549
9665
  assertNoBodyContent(tag);
9550
9666
  (0, _marko_compiler_babel_utils.assertNoAttributeTags)(tag);
9551
- if (node.var) throw tag.hub.buildError(node.var, "The [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) does not support a tag variable reference. For a native html [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) use the `html-script` core tag instead.");
9667
+ if (node.var) throw tag.hub.buildError(node.var, "The [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) does not support a tag variable reference." + htmlScriptTagAlternateMsg);
9552
9668
  let seenValueAttr = false;
9553
9669
  for (const attr of node.attributes) if (attr.type === "MarkoAttribute" && attr.name === "value") {
9554
9670
  if (seenValueAttr) throw tag.hub.buildError(attr, "Invalid duplicate value attribute.");
@@ -9558,7 +9674,7 @@ var script_default = {
9558
9674
  addSetupExpr(getOrCreateSection(tag), attr.value);
9559
9675
  (0, _marko_compiler_babel_utils.getProgram)().node.extra.isInteractive = true;
9560
9676
  }
9561
- } else throw tag.hub.buildError(attr, "The [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) does not support html attributes. For a native html [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) use the `html-script` core tag instead.");
9677
+ } else throw tag.hub.buildError(attr, "The [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) does not support html attributes." + htmlScriptTagAlternateMsg);
9562
9678
  if (!seenValueAttr) dropNodes(getAllTagReferenceNodes(node));
9563
9679
  },
9564
9680
  translate: { exit(tag) {
@@ -9575,16 +9691,18 @@ var script_default = {
9575
9691
  if (isOutputDOM()) {
9576
9692
  const isFunction = _marko_compiler.types.isFunctionExpression(value) || _marko_compiler.types.isArrowFunctionExpression(value);
9577
9693
  let inlineBody = null;
9578
- if (isFunction) if (value.async || value.generator) {} else if (_marko_compiler.types.isBlockStatement(value.body)) {
9579
- if (!traverseContains(value.body, isReturnStatement)) {
9580
- let hasDeclaration = false;
9581
- for (const child of value.body.body) if (_marko_compiler.types.isDeclaration(child)) {
9582
- hasDeclaration = true;
9583
- break;
9694
+ if (isFunction) {
9695
+ if (value.async || value.generator) {} else if (_marko_compiler.types.isBlockStatement(value.body)) {
9696
+ if (!traverseContains(value.body, isReturnStatement)) {
9697
+ let hasDeclaration = false;
9698
+ for (const child of value.body.body) if (_marko_compiler.types.isDeclaration(child)) {
9699
+ hasDeclaration = true;
9700
+ break;
9701
+ }
9702
+ inlineBody = hasDeclaration ? value.body : value.body.body;
9584
9703
  }
9585
- inlineBody = hasDeclaration ? value.body : value.body.body;
9586
- }
9587
- } else inlineBody = _marko_compiler.types.expressionStatement(value.body);
9704
+ } else inlineBody = _marko_compiler.types.expressionStatement(value.body);
9705
+ }
9588
9706
  addStatement("effect", section, referencedBindings, inlineBody || _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(value, [])));
9589
9707
  } else addHTMLEffectCall(section, referencedBindings);
9590
9708
  tag.remove();
@@ -9673,7 +9791,7 @@ var show_default = {
9673
9791
  if (tagExtra[kStaticDisplay] === void 0) {
9674
9792
  mergeReferences(tagSection, tag.node, [display]);
9675
9793
  addSerializeExpr(tagSection, tagExtra, kStatefulReason);
9676
- } else addSetupStatement(tagSection);
9794
+ } else addSetupWork(tagSection);
9677
9795
  },
9678
9796
  exit(tag) {
9679
9797
  const tagExtra = tag.node.extra;
@@ -9804,6 +9922,9 @@ function assertHasValueAttribute(tag) {
9804
9922
  //#endregion
9805
9923
  //#region src/translator/core/static.ts
9806
9924
  var static_default = createStatementTag("static");
9925
+ //#endregion
9926
+ //#region src/translator/util/style-interpolation.ts
9927
+ const htmlStyleTagAlternateMsg = " For a native html [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) use the `html-style` core tag instead.";
9807
9928
  function checkStyleInterpolations(tag) {
9808
9929
  const { body } = tag.node.body;
9809
9930
  let stringQuote = "";
@@ -9874,7 +9995,6 @@ function checkStyleInterpolations(tag) {
9874
9995
  case "}":
9875
9996
  endRun(false);
9876
9997
  if (blockDepth) blockDepth--;
9877
- break;
9878
9998
  }
9879
9999
  }
9880
10000
  }
@@ -9913,7 +10033,7 @@ var style_default = {
9913
10033
  if (importPath) addAssetImport(importPath);
9914
10034
  if (names) {
9915
10035
  analyzeDynamicStyle(tag, names);
9916
- addSetupStatement(getOrCreateSection(tag));
10036
+ addSetupWork(getOrCreateSection(tag));
9917
10037
  visit(tag, 32);
9918
10038
  enterShallow(tag);
9919
10039
  writeTo(tag)`<style></style>`;
@@ -9950,7 +10070,7 @@ function collectDynamicStyleNames(tag) {
9950
10070
  const index = programDynamicStyleNameCounts.get(program) ?? 0;
9951
10071
  programDynamicStyleNameCounts.set(program, index + 1);
9952
10072
  (names ??= []).push(dynamicStyleName(index));
9953
- } else if (!_marko_compiler.types.isMarkoText(child)) throw tag.hub.buildError(child, "The [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) only supports text and `${...}` interpolations. For a native html [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) use the `html-style` core tag instead.");
10073
+ } else if (!_marko_compiler.types.isMarkoText(child)) throw tag.hub.buildError(child, "The [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) only supports text and `${...}` interpolations." + htmlStyleTagAlternateMsg);
9954
10074
  return names;
9955
10075
  }
9956
10076
  const styleNameUnsafeReg = /[^a-zA-Z0-9_]/g;
@@ -9974,7 +10094,7 @@ function assertNoStyleAttributes(tag) {
9974
10094
  const extClass = (STYLE_EXT_REG.exec(node.rawValue || "")?.[1]?.slice(1))?.replace(/\./g, " ");
9975
10095
  for (const attr of node.attributes) {
9976
10096
  if (attr.start == null && attr.type === "MarkoAttribute" && attr.name === "class" && attr.value.type === "StringLiteral" && attr.value.value === extClass) continue;
9977
- throw tag.hub.buildError(attr.value, "The `style` does not support html attributes. For a native html [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) use the `html-style` core tag instead.");
10097
+ throw tag.hub.buildError(attr.value, "The `style` does not support html attributes." + htmlStyleTagAlternateMsg);
9978
10098
  }
9979
10099
  }
9980
10100
  function translateHTML(tag) {
@@ -10093,15 +10213,21 @@ var try_default = {
10093
10213
  (0, _marko_compiler_babel_utils.assertNoAttributes)(tag);
10094
10214
  const attrTags = analyzeAttributeTags(tag);
10095
10215
  if (attrTags) {
10096
- for (const name in attrTags) if (name !== "@placeholder" && name !== "@catch") {
10097
- const suggestion = name[1] === "p" ? "`<@placeholder>`" : "`<@catch>`";
10098
- throw tag.buildCodeFrameError(`The [\`<try>\` tag](https://markojs.com/docs/reference/core-tag#try) only supports the \`<@placeholder>\` and \`<@catch>\` attribute tags, but received \`<${name}>\`. Did you mean ${suggestion}?`);
10216
+ for (const name in attrTags) {
10217
+ if (name !== "@placeholder" && name !== "@catch") {
10218
+ const suggestion = name[1] === "p" ? "`<@placeholder>`" : "`<@catch>`";
10219
+ throw tag.buildCodeFrameError(`The [\`<try>\` tag](https://markojs.com/docs/reference/core-tag#try) only supports the \`<@placeholder>\` and \`<@catch>\` attribute tags, but received \`<${name}>\`. Did you mean ${suggestion}?`);
10220
+ }
10221
+ const { dynamic, repeated } = attrTags[name];
10222
+ if (dynamic || repeated) throw tag.get("name").buildCodeFrameError(dynamic ? `The [\`<try>\` tag](https://markojs.com/docs/reference/core-tag#try) needs its \`<${name}>\` written directly inside it, not within control flow such as \`<if>\` or \`<for>\`.` : `The [\`<try>\` tag](https://markojs.com/docs/reference/core-tag#try) takes a single \`<${name}>\`.`);
10099
10223
  }
10224
+ for (const child of tag.get("attributeTags")) if (child.isMarkoTag() && (child.node.attributes.length || child.node.arguments)) throw child.get("name").buildCodeFrameError(`The [\`<try>\` tag](https://markojs.com/docs/reference/core-tag#try)'s \`<${getTagName(child)}>\` takes no attributes, only content.`);
10100
10225
  }
10101
10226
  const section = getOrCreateSection(tag);
10102
10227
  const tagExtra = mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
10103
10228
  tagExtra.nodeBinding = createBinding("#text", 0, section);
10104
10229
  if (!tag.node.body.body.length) throw tag.get("name").buildCodeFrameError("The [`<try>` tag](https://markojs.com/docs/reference/core-tag#try) requires [body content](https://markojs.com/docs/reference/language#tag-content).");
10230
+ if (!attrTags) throw tag.get("name").buildCodeFrameError("The [`<try>` tag](https://markojs.com/docs/reference/core-tag#try) needs a `<@catch>` to handle errors or a `<@placeholder>` to show while its content is pending. Without either it has no effect, so render its content directly.");
10105
10231
  const bodySection = startSection(tag.get("body"));
10106
10232
  if (bodySection) {
10107
10233
  bodySection.upstreamExpression = tagExtra;
@@ -10121,18 +10247,16 @@ var try_default = {
10121
10247
  flushBefore(tag);
10122
10248
  },
10123
10249
  exit(tag) {
10124
- const { node } = tag;
10125
10250
  const section = getSection(tag);
10126
- const tagExtra = node.extra;
10127
10251
  const tagBody = tag.get("body");
10128
- const translatedAttrs = translateAttrs(tag);
10129
- const nodeRef = tagExtra.nodeBinding;
10130
- const contentProp = getTranslatedBodyContentProperty(translatedAttrs.properties);
10131
- if (contentProp) translatedAttrs.properties.splice(translatedAttrs.properties.indexOf(contentProp), 1);
10252
+ const nodeRef = tag.node.extra.nodeBinding;
10253
+ const catchTag = getAttrTag(tag, "@catch");
10254
+ const placeholderTag = getAttrTag(tag, "@placeholder");
10255
+ const catchSection = catchTag && getSectionForBody(catchTag.get("body"));
10256
+ const placeholderSection = placeholderTag && getSectionForBody(placeholderTag.get("body"));
10132
10257
  flushInto(tag);
10133
10258
  writeHTMLResumeStatements(tagBody);
10134
- tag.insertBefore(translatedAttrs.statements);
10135
- tag.replaceWith(_marko_compiler.types.expressionStatement(callRuntime("_try", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeRef), contentProp?.value, propsToExpression(translatedAttrs.properties))))[0].skip();
10259
+ tag.replaceWith(_marko_compiler.types.expressionStatement(callRuntime("_try", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeRef), buildContent(tagBody), placeholderSection && buildContent(placeholderTag.get("body")), catchTag && (catchSection ? buildContent(catchTag.get("body")) : _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement([]))), placeholderSection && _marko_compiler.types.stringLiteral(getResumeRegisterId(placeholderSection, "content")), catchTag && _marko_compiler.types.stringLiteral(catchSection ? getResumeRegisterId(catchSection, "content") : getEmptyCatchId(section, nodeRef)))))[0].skip();
10136
10260
  }
10137
10261
  },
10138
10262
  dom: {
@@ -10140,24 +10264,33 @@ var try_default = {
10140
10264
  setSectionParentIsOwner(getSectionForBody(tag.get("body")), true);
10141
10265
  },
10142
10266
  exit(tag) {
10143
- const { node } = tag;
10144
- const tagExtra = node.extra;
10145
- const nodeRef = tagExtra.nodeBinding;
10146
- const referencedBindings = tagExtra.referencedBindings;
10147
- const translatedAttrs = translateAttrs(tag);
10148
- const contentProp = getTranslatedBodyContentProperty(translatedAttrs.properties);
10149
- if (contentProp) translatedAttrs.properties.splice(translatedAttrs.properties.indexOf(contentProp), 1);
10267
+ const nodeRef = tag.node.extra.nodeBinding;
10150
10268
  const section = getSection(tag);
10151
10269
  const bodySection = getSectionForBody(tag.get("body"));
10270
+ const catchTag = getAttrTag(tag, "@catch");
10271
+ const catchSection = catchTag && getSectionForBody(catchTag.get("body"));
10272
+ const placeholderTag = getAttrTag(tag, "@placeholder");
10273
+ const placeholderSection = placeholderTag && getSectionForBody(placeholderTag.get("body"));
10274
+ const emptyCatchId = catchTag && !catchSection && getEmptyCatchId(section, nodeRef);
10152
10275
  const signal = getSignal(section, nodeRef, "try");
10153
- const hasPlaceholder = !!tag.node.extra?.attributeTags?.["@placeholder"];
10154
10276
  signal.build = () => {
10155
10277
  importRuntimeFeature("catch");
10156
- if (hasPlaceholder) importRuntimeFeature("placeholder");
10157
- return callRuntime("_try", getScopeAccessorLiteral(nodeRef, true), ...replaceNullishAndEmptyFunctionsWith0(getBranchRendererArgs(bodySection)));
10278
+ if (placeholderSection) importRuntimeFeature("placeholder");
10279
+ let catchContent = catchSection && _marko_compiler.types.identifier(catchSection.name);
10280
+ if (emptyCatchId) {
10281
+ catchContent = _marko_compiler.types.identifier(`${signal.identifier.name}__catch`);
10282
+ (signal.prependStatements ||= []).push(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(catchContent, callRuntime("_content", _marko_compiler.types.stringLiteral(emptyCatchId)))]));
10283
+ }
10284
+ const [template, walks, setup] = getBranchRendererArgs(bodySection);
10285
+ return callRuntime("_try", getScopeAccessorLiteral(nodeRef, true), ...replaceNullishAndEmptyFunctionsWith0([
10286
+ template,
10287
+ walks,
10288
+ setup,
10289
+ placeholderSection && _marko_compiler.types.identifier(placeholderSection.name),
10290
+ catchContent
10291
+ ]));
10158
10292
  };
10159
- if (translatedAttrs.statements.length) addStatement("render", section, referencedBindings, translatedAttrs.statements);
10160
- addValue(section, referencedBindings, signal, propsToExpression(translatedAttrs.properties));
10293
+ addValue(section, void 0, signal);
10161
10294
  tag.remove();
10162
10295
  }
10163
10296
  }
@@ -10169,6 +10302,15 @@ var try_default = {
10169
10302
  }],
10170
10303
  types: runtime_info_default.name + "/tags/try.d.marko"
10171
10304
  };
10305
+ function getAttrTag(tag, name) {
10306
+ for (const child of tag.get("attributeTags")) if (child.isMarkoTag() && getTagName(child) === name) return name === "@catch" || getSectionForBody(child.get("body")) ? child : void 0;
10307
+ }
10308
+ function buildContent(body) {
10309
+ return _marko_compiler.types.arrowFunctionExpression(body.node.params, _marko_compiler.types.blockStatement([getScopeReasonStatement(getSectionForBody(body)), ...body.node.body]));
10310
+ }
10311
+ function getEmptyCatchId(section, nodeRef) {
10312
+ return getResumeRegisterId(section, nodeRef, "catch");
10313
+ }
10172
10314
  //#endregion
10173
10315
  //#region src/translator/core/index.ts
10174
10316
  var core_default = {
@@ -10346,11 +10488,12 @@ function translateExit(placeholder) {
10346
10488
  const section = getSection(placeholder);
10347
10489
  const siblingText = extra[kSiblingText];
10348
10490
  const markerSerializeReason = nodeBinding && getSerializeReason(section, nodeBinding);
10349
- if (isHTML) if (markerSerializeReason) {
10350
- const guard = getSerializeGuard(section, markerSerializeReason, true);
10351
- write`${callRuntime(node.escape ? "_text_resume" : "_html_resume", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeBinding), value, siblingText === 1 ? guard ? _marko_compiler.types.binaryExpression("*", guard, _marko_compiler.types.numericLiteral(2)) : _marko_compiler.types.numericLiteral(2) : guard)}`;
10352
- } else write`${method === "_escape" ? buildEscapedTextExpression(value) : callRuntime(method, value)}`;
10353
- else addStatement("render", section, valueExtra.referencedBindings, _marko_compiler.types.expressionStatement(method === "_text" ? callRuntime("_text", createScopeReadExpression(nodeBinding), value) : callRuntime("_html", scopeIdentifier, value, getScopeAccessorLiteral(nodeBinding))), true);
10491
+ if (isHTML) {
10492
+ if (markerSerializeReason) {
10493
+ const guard = getSerializeGuard(section, markerSerializeReason, true);
10494
+ write`${callRuntime(node.escape ? "_text_resume" : "_html_resume", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeBinding), value, siblingText === 1 ? guard ? _marko_compiler.types.binaryExpression("*", guard, _marko_compiler.types.numericLiteral(2)) : _marko_compiler.types.numericLiteral(2) : guard)}`;
10495
+ } else write`${method === "_escape" ? buildEscapedTextExpression(value) : callRuntime(method, value)}`;
10496
+ } else addStatement("render", section, valueExtra.referencedBindings, _marko_compiler.types.expressionStatement(method === "_text" ? callRuntime("_text", createScopeReadExpression(nodeBinding), value) : callRuntime("_html", scopeIdentifier, value, getScopeAccessorLiteral(nodeBinding))), true);
10354
10497
  }
10355
10498
  placeholder.remove();
10356
10499
  }
@@ -10428,10 +10571,8 @@ var referenced_identifier_default = {
10428
10571
  const { name } = identifier.node;
10429
10572
  if (identifier.scope.hasBinding(name)) return;
10430
10573
  switch (name) {
10431
- case "out":
10432
- if (_marko_compiler.types.isMemberExpression(identifier.parent) && _marko_compiler.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") identifier.parentPath.replaceWith(_marko_compiler.types.identifier("$global"));
10433
- else throw identifier.buildCodeFrameError("Only `out.global` is supported for compatibility.");
10434
- break;
10574
+ case "out": if (_marko_compiler.types.isMemberExpression(identifier.parent) && _marko_compiler.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") identifier.parentPath.replaceWith(_marko_compiler.types.identifier("$global"));
10575
+ else throw identifier.buildCodeFrameError("Only `out.global` is supported for compatibility.");
10435
10576
  }
10436
10577
  },
10437
10578
  analyze(identifier) {
@@ -10464,13 +10605,14 @@ var referenced_identifier_default = {
10464
10605
  case "$signal": if (isOutputHTML()) replaceWithExtra(identifier, _marko_compiler.types.callExpression(_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement([_marko_compiler.types.throwStatement(_marko_compiler.types.newExpression(_marko_compiler.types.identifier("Error"), [_marko_compiler.types.stringLiteral("Cannot use $signal in a server render.")]))])), []));
10465
10606
  else {
10466
10607
  const exprRoot = identifier.node.extra.exprRoot;
10467
- if (getCanonicalExtra(exprRoot).pruned) break;
10608
+ const canonicalExtra = getCanonicalExtra(exprRoot);
10609
+ if (canonicalExtra.pruned) break;
10468
10610
  const section = getSection(identifier);
10469
10611
  const exprId = exprRoot.abortId;
10470
10612
  const resetEmitted = getAbortResetEmitted(section);
10471
10613
  if (!resetEmitted.has(exprRoot)) {
10472
10614
  resetEmitted.add(exprRoot);
10473
- addStatement("render", section, exprRoot.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(importRuntime("$signalReset"), [scopeIdentifier, _marko_compiler.types.numericLiteral(exprId)])));
10615
+ addStatement("render", section, canonicalExtra.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(importRuntime("$signalReset"), [scopeIdentifier, _marko_compiler.types.numericLiteral(exprId)])));
10474
10616
  }
10475
10617
  identifier.replaceWith(_marko_compiler.types.callExpression(importRuntime("$signal"), [scopeIdentifier, _marko_compiler.types.numericLiteral(exprId)]));
10476
10618
  }
@@ -10486,7 +10628,7 @@ function getSignalGlobalKey(identifier) {
10486
10628
  if (!_marko_compiler.types.isMemberExpression(parent) || parent.computed || !_marko_compiler.types.isIdentifier(parent.property) || parent.object !== identifier.node) return;
10487
10629
  const { name } = parent.property;
10488
10630
  if (name === "runtimeId" || name === "renderId") return;
10489
- return getExprRoot(identifier).node.extra?.referencedBindings ? name : void 0;
10631
+ return getCanonicalExtra(getExprRoot(identifier).node.extra).referencedBindings ? name : void 0;
10490
10632
  }
10491
10633
  //#endregion
10492
10634
  //#region src/translator/visitors/scriptlet.ts
@@ -10506,11 +10648,12 @@ var scriptlet_default = {
10506
10648
  if (node.target && node.target !== (isHTML ? "server" : "client")) {
10507
10649
  const ids = Object.keys(scriptlet.getOuterBindingIdentifiers());
10508
10650
  const decl = ids.length && _marko_compiler.types.variableDeclaration("var", ids.map((key) => _marko_compiler.types.variableDeclarator(_marko_compiler.types.identifier(key))));
10509
- if (decl) if (isHTML) {
10510
- scriptlet.node.target = null;
10511
- scriptlet.node.body = [decl];
10512
- } else scriptlet.replaceWith(decl);
10513
- else scriptlet.remove();
10651
+ if (decl) {
10652
+ if (isHTML) {
10653
+ scriptlet.node.target = null;
10654
+ scriptlet.node.body = [decl];
10655
+ } else scriptlet.replaceWith(decl);
10656
+ } else scriptlet.remove();
10514
10657
  return;
10515
10658
  }
10516
10659
  if (isHTML) {} else {
@@ -10534,6 +10677,11 @@ var attribute_tag_default = {
10534
10677
  } },
10535
10678
  translate: {
10536
10679
  enter(tag) {
10680
+ if (tag.node.extra.pruned) {
10681
+ tag.remove();
10682
+ return;
10683
+ }
10684
+ removePrunedContent(tag);
10537
10685
  if (isOutputHTML()) flushBefore(tag);
10538
10686
  },
10539
10687
  exit(tag) {
@@ -10564,7 +10712,6 @@ var dynamic_tag_default = {
10564
10712
  const { node } = tag;
10565
10713
  const definedBodySection = node.extra?.defineBodySection;
10566
10714
  if (definedBodySection) {
10567
- addSetupStatement(getOrCreateSection(tag));
10568
10715
  knownTagAnalyze(tag, definedBodySection, definedBodySection.params && getBindingPropTree(definedBodySection.params));
10569
10716
  child(tag, getStaticTagName(tag.node), {
10570
10717
  kind: SectionRef,
@@ -10606,6 +10753,7 @@ var dynamic_tag_default = {
10606
10753
  tag.remove();
10607
10754
  return;
10608
10755
  }
10756
+ removePrunedContent(tag);
10609
10757
  if (isOutputHTML()) flushBefore(tag);
10610
10758
  },
10611
10759
  exit(tag) {
@@ -10618,8 +10766,7 @@ var dynamic_tag_default = {
10618
10766
  if (isOutputHTML()) knownTagTranslateHTML(tag, _marko_compiler.types.memberExpression(tag.node.name, _marko_compiler.types.identifier("content")), definedBodySection, propTree);
10619
10767
  else {
10620
10768
  knownTagTranslateDOM(tag, propTree, (binding, preferredName, directContent) => directContent && binding.directContentExport ? _marko_compiler.types.identifier(binding.directContentExport) : getSignal(definedBodySection, binding, preferredName).identifier, (section, childBinding) => {
10621
- const signal = getSignal(definedBodySection, void 0);
10622
- if (signalHasStatements(signal)) addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.memberExpression(signal.identifier, _marko_compiler.types.identifier("_")), [createScopeReadExpression(childBinding, section), getScopeExpression(section, definedBodySection.parent)])));
10769
+ if (definedBodySection.hasSetupWork) addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.memberExpression(getSignal(definedBodySection, void 0).identifier, _marko_compiler.types.identifier("_")), [createScopeReadExpression(childBinding, section), getScopeExpression(section, definedBodySection.parent)])));
10623
10770
  else if (definedBodySection.readsOwner) addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.assignmentExpression("=", toMemberExpression(createScopeReadExpression(childBinding, section), getAccessorProp().Owner), getScopeExpression(section, definedBodySection.parent))));
10624
10771
  });
10625
10772
  tag.remove();
@@ -10705,7 +10852,7 @@ var dynamic_tag_default = {
10705
10852
  };
10706
10853
  }
10707
10854
  signal.build = () => {
10708
- return callRuntime("_dynamic_tag", getScopeAccessorLiteral(nodeBinding, true), bodySection && _marko_compiler.types.identifier(bodySection.name), tagVarSignal ? _marko_compiler.types.arrowFunctionExpression([], tagVarSignal.identifier) : void 0, hasTagArgs && _marko_compiler.types.numericLiteral(1));
10855
+ return callRuntime("_dynamic_tag", getScopeAccessorLiteral(nodeBinding, true), bodySection && getSectionRendererIdentifier(bodySection), tagVarSignal ? _marko_compiler.types.arrowFunctionExpression([], tagVarSignal.identifier) : void 0, hasTagArgs && _marko_compiler.types.numericLiteral(1));
10709
10856
  };
10710
10857
  const directBinding = tagExtra.referencedBindings;
10711
10858
  if (directBinding && !Array.isArray(directBinding) && directBinding.directContentExport) (0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.exportNamedDeclaration(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(_marko_compiler.types.identifier(directBinding.directContentExport), callRuntime("_dynamic_tag_content", getScopeAccessorLiteral(nodeBinding, true)))])));
@@ -10757,7 +10904,7 @@ function getDynamicTagInputBindings(tagExtra) {
10757
10904
  for (const childExtra of tagExtra.tagNameTemplates || []) {
10758
10905
  if (childExtra.featureType === "class") return;
10759
10906
  const inputBinding = childExtra.domExports?.params?.props?.[0]?.binding;
10760
- if (inputBinding) inputBindings = bindingUtil.add(inputBindings, inputBinding);
10907
+ if (inputBinding) inputBindings = concat(inputBindings, inputBinding);
10761
10908
  }
10762
10909
  return inputBindings;
10763
10910
  }
@@ -10798,9 +10945,7 @@ var tag_default = {
10798
10945
  case 3:
10799
10946
  attribute_tag_default.analyze.enter(tag);
10800
10947
  break;
10801
- case 2:
10802
- dynamic_tag_default.analyze.enter(tag);
10803
- break;
10948
+ case 2: dynamic_tag_default.analyze.enter(tag);
10804
10949
  }
10805
10950
  } catch (err) {
10806
10951
  (tag.node.extra ??= {}).analyzeFailed = true;
@@ -10845,9 +10990,7 @@ var tag_default = {
10845
10990
  case 2:
10846
10991
  dynamic_tag_default.translate.enter(tag);
10847
10992
  break;
10848
- case 3:
10849
- attribute_tag_default.translate.enter(tag);
10850
- break;
10993
+ case 3: attribute_tag_default.translate.enter(tag);
10851
10994
  }
10852
10995
  },
10853
10996
  exit(tag) {
@@ -10866,9 +11009,7 @@ var tag_default = {
10866
11009
  case 2:
10867
11010
  dynamic_tag_default.translate.exit(tag);
10868
11011
  break;
10869
- case 3:
10870
- attribute_tag_default.translate.exit(tag);
10871
- break;
11012
+ case 3: attribute_tag_default.translate.exit(tag);
10872
11013
  }
10873
11014
  }
10874
11015
  }
@@ -10955,9 +11096,7 @@ function scanBody(state, body) {
10955
11096
  case "MarkoScriptlet":
10956
11097
  if (!child.node.static) addFeature(state, Class, "Scriptlet", child);
10957
11098
  break;
10958
- case "MarkoClass":
10959
- addFeature(state, Class, "Class block", child.get("body"));
10960
- break;
11099
+ case "MarkoClass": addFeature(state, Class, "Class block", child.get("body"));
10961
11100
  }
10962
11101
  }
10963
11102
  function scanTag(state, tag) {
@@ -11041,30 +11180,31 @@ function createInteropTranslator(translate5) {
11041
11180
  build(entryFile) {
11042
11181
  const state = entryFile[kState];
11043
11182
  if (!state) throw entryFile.path.buildCodeFrameError("Unable to build hydrate code, no files were visited before finalizing the build");
11044
- if (state.has5) if (state.has6) {
11045
- const filename = entryFile.opts.filename;
11046
- const baseName = `./${path.default.basename(filename)}`;
11047
- const generatorOpts = {
11048
- ...entryFile.opts.generatorOpts,
11049
- sourceMaps: false
11050
- };
11051
- const { resolveVirtualDependency } = entryFile.markoOpts;
11052
- const importHydrateProgram = (name, statements) => {
11053
- return _marko_compiler.types.importDeclaration([_marko_compiler.types.importDefaultSpecifier(_marko_compiler.types.identifier(`init${name}`))], _marko_compiler.types.stringLiteral(resolveVirtualDependency(filename, {
11054
- code: (0, _marko_compiler_internal_babel.generator)(_marko_compiler.types.program(statements), generatorOpts).code,
11055
- virtualPath: `${baseName}.hydrate-${name}.js`
11056
- })));
11057
- };
11058
- return [
11059
- ...state.needsCompat ? [_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(getCompatRuntimeFile()))] : [],
11060
- ...Array.from(state.compatFiles, (compatFile) => _marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(compatFile))),
11061
- importHydrateProgram("6", builder.build(entryFile, true)),
11062
- importHydrateProgram("5", translate5.internalEntryBuilder.build(entryFile, true)),
11063
- _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier("init6"), [])),
11064
- _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier("init5"), []))
11065
- ];
11066
- } else return translate5.internalEntryBuilder.build(entryFile);
11067
- else return builder.build(entryFile);
11183
+ if (state.has5) {
11184
+ if (state.has6) {
11185
+ const filename = entryFile.opts.filename;
11186
+ const baseName = `./${path.default.basename(filename)}`;
11187
+ const generatorOpts = {
11188
+ ...entryFile.opts.generatorOpts,
11189
+ sourceMaps: false
11190
+ };
11191
+ const { resolveVirtualDependency } = entryFile.markoOpts;
11192
+ const importHydrateProgram = (name, statements) => {
11193
+ return _marko_compiler.types.importDeclaration([_marko_compiler.types.importDefaultSpecifier(_marko_compiler.types.identifier(`init${name}`))], _marko_compiler.types.stringLiteral(resolveVirtualDependency(filename, {
11194
+ code: (0, _marko_compiler_internal_babel.generator)(_marko_compiler.types.program(statements), generatorOpts).code,
11195
+ virtualPath: `${baseName}.hydrate-${name}.js`
11196
+ })));
11197
+ };
11198
+ return [
11199
+ ...state.needsCompat ? [_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(getCompatRuntimeFile()))] : [],
11200
+ ...Array.from(state.compatFiles, (compatFile) => _marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(compatFile))),
11201
+ importHydrateProgram("6", builder.build(entryFile, true)),
11202
+ importHydrateProgram("5", translate5.internalEntryBuilder.build(entryFile, true)),
11203
+ _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier("init6"), [])),
11204
+ _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier("init5"), []))
11205
+ ];
11206
+ } else return translate5.internalEntryBuilder.build(entryFile);
11207
+ } else return builder.build(entryFile);
11068
11208
  },
11069
11209
  visit(file, entryFile, visitChild) {
11070
11210
  const state = entryFile[kState] ||= {
@@ -11162,11 +11302,12 @@ function mergeObjects(a, b, cb) {
11162
11302
  const value = cb(key, aValue, bValue);
11163
11303
  if (value !== void 0) merged[key] = value;
11164
11304
  };
11165
- if (a) if (b) {
11166
- for (const key in a) assign(key, a[key], b[key]);
11167
- for (const key in b) if (!(key in a)) assign(key, void 0, b[key]);
11168
- } else for (const key in a) assign(key, a[key], void 0);
11169
- else if (b) for (const key in b) assign(key, void 0, b[key]);
11305
+ if (a) {
11306
+ if (b) {
11307
+ for (const key in a) assign(key, a[key], b[key]);
11308
+ for (const key in b) if (!(key in a)) assign(key, void 0, b[key]);
11309
+ } else for (const key in a) assign(key, a[key], void 0);
11310
+ } else if (b) for (const key in b) assign(key, void 0, b[key]);
11170
11311
  return merged;
11171
11312
  }
11172
11313
  function normalizeTagDef(tagDef) {