marko 6.3.30 → 6.3.32

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 (58) hide show
  1. package/cheatsheet.md +36 -18
  2. package/dist/common/helpers.d.ts +2 -0
  3. package/dist/debug/dom/catch.feat.js +38 -0
  4. package/dist/debug/dom/catch.feat.mjs +37 -0
  5. package/dist/debug/dom/controllable-input.feat.js +7 -0
  6. package/dist/debug/dom/controllable-input.feat.mjs +6 -0
  7. package/dist/debug/dom/controllable-open.feat.js +5 -0
  8. package/dist/debug/dom/controllable-open.feat.mjs +4 -0
  9. package/dist/debug/dom/controllable-select.feat.js +5 -0
  10. package/dist/debug/dom/controllable-select.feat.mjs +4 -0
  11. package/dist/debug/dom/controllable-textarea.feat.js +5 -0
  12. package/dist/debug/dom/controllable-textarea.feat.mjs +4 -0
  13. package/dist/debug/dom/controllable.feat.js +11 -0
  14. package/dist/debug/dom/controllable.feat.mjs +10 -0
  15. package/dist/debug/dom-BJ93mcSe.mjs +2016 -0
  16. package/dist/debug/dom-CiFITSPN.js +2814 -0
  17. package/dist/debug/dom.js +156 -2245
  18. package/dist/debug/dom.mjs +6 -2089
  19. package/dist/dom/catch.feat.d.ts +1 -0
  20. package/dist/dom/catch.feat.js +25 -0
  21. package/dist/dom/catch.feat.mjs +26 -0
  22. package/dist/dom/control-flow.d.ts +3 -3
  23. package/dist/dom/controllable-input.feat.d.ts +1 -0
  24. package/dist/dom/controllable-input.feat.js +3 -0
  25. package/dist/dom/controllable-input.feat.mjs +3 -0
  26. package/dist/dom/controllable-open.feat.d.ts +1 -0
  27. package/dist/dom/controllable-open.feat.js +4 -0
  28. package/dist/dom/controllable-open.feat.mjs +4 -0
  29. package/dist/dom/controllable-select.feat.d.ts +1 -0
  30. package/dist/dom/controllable-select.feat.js +4 -0
  31. package/dist/dom/controllable-select.feat.mjs +4 -0
  32. package/dist/dom/controllable-textarea.feat.d.ts +1 -0
  33. package/dist/dom/controllable-textarea.feat.js +4 -0
  34. package/dist/dom/controllable-textarea.feat.mjs +4 -0
  35. package/dist/dom/controllable.d.ts +3 -8
  36. package/dist/dom/controllable.feat.d.ts +3 -0
  37. package/dist/dom/controllable.feat.js +3 -0
  38. package/dist/dom/controllable.feat.mjs +6 -0
  39. package/dist/dom/queue.d.ts +2 -2
  40. package/dist/dom/resume.d.ts +0 -1
  41. package/dist/dom/walker.d.ts +0 -1
  42. package/dist/dom-CI-06TZb.js +1721 -0
  43. package/dist/dom-Cj4HQ7T_.mjs +1137 -0
  44. package/dist/dom.d.ts +2 -2
  45. package/dist/dom.js +36 -1221
  46. package/dist/dom.mjs +4 -1188
  47. package/dist/translator/index.js +628 -534
  48. package/dist/translator/util/constants/structure-kind.d.ts +7 -0
  49. package/dist/translator/util/get-tag-name.d.ts +2 -1
  50. package/dist/translator/util/import-reference.d.ts +3 -0
  51. package/dist/translator/util/runtime.d.ts +2 -0
  52. package/dist/translator/util/sections.d.ts +28 -1
  53. package/dist/translator/util/{walks.d.ts → structure.d.ts} +20 -9
  54. package/dist/translator/util/writer.d.ts +0 -8
  55. package/dist/translator/visitors/placeholder.d.ts +4 -3
  56. package/dist/translator/visitors/tag/native-tag.d.ts +9 -6
  57. package/dist/translator/visitors/text.d.ts +3 -7
  58. package/package.json +3 -3
@@ -605,6 +605,9 @@ function getTagName(tag) {
605
605
  break;
606
606
  }
607
607
  }
608
+ function getStaticTagName(node) {
609
+ return _marko_compiler.types.isIdentifier(node.name) ? node.name.name : _marko_compiler.types.isStringLiteral(node.name) ? node.name.value : "tag";
610
+ }
608
611
  //#endregion
609
612
  //#region src/translator/util/is-core-tag.ts
610
613
  const { taglibId } = runtime_info_default;
@@ -665,6 +668,12 @@ function isInvokedFunction(expr) {
665
668
  return false;
666
669
  }
667
670
  //#endregion
671
+ //#region src/translator/util/constants/structure-kind.ts
672
+ const Visit = "visit";
673
+ const Child = "child";
674
+ const SectionRef = "sectionRef";
675
+ const ExportRef = "exportRef";
676
+ //#endregion
668
677
  //#region src/translator/util/optional.ts
669
678
  var Sorted = class {
670
679
  compare;
@@ -1318,7 +1327,8 @@ function startSection(path) {
1318
1327
  hasAbortSignal: false,
1319
1328
  abortSignalExprs: 0,
1320
1329
  readsOwner: false,
1321
- isBranch: false
1330
+ isBranch: false,
1331
+ structure: parentSection && !parentSection.structure ? null : []
1322
1332
  };
1323
1333
  sections.push(section);
1324
1334
  }
@@ -2262,6 +2272,17 @@ function callRuntime(name, ...args) {
2262
2272
  if (isOutputDOM() && pureDOMFunctions.has(name)) return _marko_compiler.types.addComment(callExpression, "leading", "@__PURE__");
2263
2273
  return callExpression;
2264
2274
  }
2275
+ const importedFeatures = /* @__PURE__ */ new WeakMap();
2276
+ function importRuntimeFeature(feature) {
2277
+ if (!isTranslate()) throw new Error(`\`importRuntimeFeature(${JSON.stringify(feature)})\` may only be called during the translate stage.`);
2278
+ const program = (0, _marko_compiler_babel_utils.getProgram)().node;
2279
+ let features = importedFeatures.get(program);
2280
+ if (!features) importedFeatures.set(program, features = /* @__PURE__ */ new Set());
2281
+ if (!features.has(feature)) {
2282
+ features.add(feature);
2283
+ program.body.push(_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(`${getRuntimePath("dom")}/${feature}.feat`)));
2284
+ }
2285
+ }
2265
2286
  function getHTMLRuntime() {
2266
2287
  return {
2267
2288
  _escape,
@@ -2599,137 +2620,10 @@ function createTypeState() {
2599
2620
  };
2600
2621
  }
2601
2622
  //#endregion
2602
- //#region src/translator/util/walks.ts
2603
- const [getWalks] = createSectionState("walks", () => [""]);
2604
- const [getWalkComment] = createSectionState("walkComment", () => []);
2605
- const [getSteps] = createSectionState("steps", (section) => {
2606
- if (section.content?.startType === 1) return [0, 1];
2607
- return [];
2608
- });
2609
- const walkCodeToName = {
2610
- [32]: "get",
2611
- [37]: "replace",
2612
- [38]: "endChild",
2613
- [47]: "beginChild",
2614
- [48]: "beginChildWithVar",
2615
- [49]: "dynamicTagWithVar",
2616
- [67]: "next",
2617
- [97]: "over",
2618
- [107]: "out",
2619
- [117]: "multiplier",
2620
- [91]: "nextEnd",
2621
- [106]: "overEnd",
2622
- [116]: "outEnd",
2623
- [126]: "multiplierEnd"
2624
- };
2625
- function enter(path) {
2626
- getSteps(getSection(path)).push(0);
2627
- }
2628
- function exit(path) {
2629
- getSteps(getSection(path)).push(1);
2630
- }
2631
- function enterShallow(path) {
2632
- const section = getSection(path);
2633
- getSteps(section).push(0, 1);
2634
- }
2635
- function injectWalks(tag, name, expr) {
2636
- const section = getSection(tag);
2637
- const walks = getWalks(section);
2638
- const walkComment = getWalkComment(section);
2639
- visitInternal(section);
2640
- walkComment.push(`<${name}${tag.node.var ? "/var" : ""}>`);
2641
- appendLiteral(walks, String.fromCharCode(tag.node.var ? 48 : 47));
2642
- if (expr) walks.push(expr);
2643
- walks.push(String.fromCharCode(38));
2644
- }
2645
- function visit(path, code) {
2646
- if (isOutputHTML()) return;
2647
- const section = getSection(path);
2648
- const walks = getWalks(section);
2649
- const walkComment = getWalkComment(section);
2650
- visitInternal(section);
2651
- if (code !== 32) writeTo(path)`<!>`;
2652
- walkComment.push(`${walkCodeToName[code]}`);
2653
- appendLiteral(walks, String.fromCharCode(code));
2654
- }
2655
- function visitInternal(section) {
2656
- const steps = getSteps(section);
2657
- if (!steps.length) return;
2658
- const walks = getWalks(section);
2659
- const walkComment = getWalkComment(section);
2660
- const walkCodes = [];
2661
- let walkString = "";
2662
- let depth = 0;
2663
- for (const step of steps) if (step === 0) {
2664
- depth++;
2665
- walkCodes.push(67);
2666
- } else {
2667
- depth--;
2668
- if (depth >= 0) {
2669
- walkCodes.length = walkCodes.lastIndexOf(67);
2670
- walkCodes.push(97);
2671
- } else {
2672
- walkCodes.length = walkCodes.lastIndexOf(107) + 1;
2673
- walkCodes.push(107);
2674
- depth = 0;
2675
- }
2676
- }
2677
- let current = walkCodes[0];
2678
- let count = 0;
2679
- for (const walk of walkCodes) if (walk !== current) {
2680
- walkComment.push(`${walkCodeToName[current]}(${count})`);
2681
- walkString += nCodeString(current, count);
2682
- current = walk;
2683
- count = 1;
2684
- } else count++;
2685
- walkComment.push(`${walkCodeToName[current]}(${count})`);
2686
- walkString += nCodeString(current, count);
2687
- steps.length = 0;
2688
- appendLiteral(walks, walkString);
2689
- }
2690
- function nCodeString(code, number) {
2691
- switch (code) {
2692
- case 67: return toCharString(number, code, 25);
2693
- case 97: return toCharString(number, code, 10);
2694
- case 107: return toCharString(number, code, 10);
2695
- default: throw new Error(`Unexpected walk code: ${code}`);
2696
- }
2697
- }
2698
- function toCharString(number, startCode, rangeSize) {
2699
- let result = "";
2700
- if (number >= rangeSize) {
2701
- const multiplier = Math.floor(number / rangeSize);
2702
- result += toCharString(multiplier, 117, 10);
2703
- number -= multiplier * rangeSize;
2704
- }
2705
- result += String.fromCharCode(startCode + number);
2706
- return result;
2707
- }
2708
- /** `_content` strips trailing exit codes before it walks, so a renderer that
2709
- * reaches the runtime through it never needs them on the wire. */
2710
- function trimTrailingExits(walks) {
2711
- if (!_marko_compiler.types.isStringLiteral(walks)) return walks;
2712
- const value = walks.value.replace(/[^\0-1]+$/, "");
2713
- return value === walks.value ? walks : value ? withLeadingComment(_marko_compiler.types.stringLiteral(value), getComment(walks)) : void 0;
2714
- }
2715
- function getComment(node) {
2716
- return node.leadingComments?.[0]?.value.trim() || "";
2717
- }
2718
- function getWalkString(section) {
2719
- if (section.content?.endType === 1) getSteps(section).push(0, 1);
2720
- visitInternal(section);
2721
- const walkLiteral = normalizeStringExpression(getWalks(section).map(unwrapWalk), true);
2722
- if (walkLiteral && walkLiteral.value !== "") withLeadingComment(walkLiteral, getWalkComment(section).join(", "));
2723
- return walkLiteral;
2724
- }
2725
- function unwrapWalk(walk) {
2726
- return typeof walk === "function" ? walk() || "" : walk;
2727
- }
2728
- //#endregion
2729
2623
  //#region src/translator/util/writer.ts
2730
2624
  const [getWrites] = createSectionState("writes", () => [""]);
2731
2625
  const [getTrailerWrites] = createSectionState("trailerWrites", () => [""]);
2732
- function writeTo(path, trailer) {
2626
+ function writeTo$1(path, trailer) {
2733
2627
  const section = getSection(path);
2734
2628
  const get = trailer ? getTrailerWrites : getWrites;
2735
2629
  return (strs, ...exprs) => {
@@ -2762,45 +2656,12 @@ function flushInto(path) {
2762
2656
  const expr = consumeHTML(target);
2763
2657
  if (expr) target.node.body.push(expr);
2764
2658
  }
2765
- const [getSectionMeta] = createSectionState("SectionMeta", (section) => {
2766
- const writePrefix = section.content?.startType === 1 ? "<!>" : "";
2767
- const writePostfix = section.content?.endType === 1 ? "<!>" : "";
2768
- const writes = getWrites(section);
2769
- return {
2770
- walks: getWalkString(section),
2771
- writes: normalizeStringExpression([
2772
- writePrefix,
2773
- ...writes.map(unwrapWrite),
2774
- writePostfix
2775
- ], true),
2776
- decls: void 0
2777
- };
2778
- });
2779
- const sectionMetaIsIds = /* @__PURE__ */ new WeakSet();
2780
- function getSectionMetaIdentifiers(section) {
2781
- const meta = getSectionMeta(section);
2782
- if (!sectionMetaIsIds.has(meta)) {
2783
- sectionMetaIsIds.add(meta);
2784
- const { walks, writes } = meta;
2785
- const decls = [];
2786
- if (walks) {
2787
- meta.walks = generateUidIdentifier(`${section.name}__walks`);
2788
- decls.push(_marko_compiler.types.variableDeclarator(meta.walks, walks));
2789
- }
2790
- if (writes) {
2791
- meta.writes = generateUidIdentifier(`${section.name}__template`);
2792
- decls.push(_marko_compiler.types.variableDeclarator(meta.writes, writes));
2793
- }
2794
- if (decls.length) meta.decls = decls;
2795
- }
2796
- return meta;
2797
- }
2798
2659
  function markNode(path, nodeBinding, reason, deferred) {
2799
2660
  if (nodeBinding.type !== 0) throw path.buildCodeFrameError("POTENTIAL MARKO BUG: Tried to mark a node that was not determined to need a mark during analyze.");
2800
2661
  if (isOutputHTML()) {
2801
2662
  if (reason) {
2802
2663
  const section = getSection(path);
2803
- writeTo(path, deferred)`${callRuntime("_el_resume", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeBinding), getSerializeGuard(section, reason, true))}`;
2664
+ writeTo$1(path, deferred)`${callRuntime("_el_resume", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeBinding), getSerializeGuard(section, reason, true))}`;
2804
2665
  }
2805
2666
  }
2806
2667
  }
@@ -3764,6 +3625,216 @@ function getRegisteredFnExpression$1(node) {
3764
3625
  }
3765
3626
  }
3766
3627
  //#endregion
3628
+ //#region src/translator/util/import-reference.ts
3629
+ function importOrSelfReferenceName(file, request, name, nameHint) {
3630
+ if (isCircularRequest(file, request)) return _marko_compiler.types.identifier(name);
3631
+ return (0, _marko_compiler_babel_utils.importNamed)(file, request, name, nameHint);
3632
+ }
3633
+ function isCircularRequest(file, request) {
3634
+ const { filename } = file.opts;
3635
+ return request === filename || request[0] === "." && path.default.resolve(filename, "..", request) === filename;
3636
+ }
3637
+ //#endregion
3638
+ //#region src/translator/util/structure.ts
3639
+ const walkCodeToName = {
3640
+ [32]: "get",
3641
+ [37]: "replace",
3642
+ [38]: "endChild",
3643
+ [47]: "beginChild",
3644
+ [48]: "beginChildWithVar",
3645
+ [49]: "dynamicTagWithVar",
3646
+ [67]: "next",
3647
+ [97]: "over",
3648
+ [107]: "out",
3649
+ [117]: "multiplier",
3650
+ [91]: "nextEnd",
3651
+ [106]: "overEnd",
3652
+ [116]: "outEnd",
3653
+ [126]: "multiplierEnd"
3654
+ };
3655
+ function enter(path) {
3656
+ getSection(path).structure?.push(0);
3657
+ }
3658
+ function exit(path) {
3659
+ getSection(path).structure?.push(1);
3660
+ }
3661
+ function enterShallow(path) {
3662
+ getSection(path).structure?.push(0, 1);
3663
+ }
3664
+ function child(tag, name, renderer) {
3665
+ getSection(tag).structure?.push({
3666
+ kind: Child,
3667
+ name,
3668
+ hasVar: !!tag.node.var,
3669
+ renderer
3670
+ });
3671
+ }
3672
+ function writeTo(path) {
3673
+ const { structure } = getSection(path);
3674
+ return (strs, ...exprs) => {
3675
+ if (!structure) return;
3676
+ const exprsLen = exprs.length;
3677
+ pushMarkup(structure, strs[0]);
3678
+ for (let i = 0; i < exprsLen; i++) {
3679
+ pushMarkup(structure, exprs[i]);
3680
+ pushMarkup(structure, strs[i + 1]);
3681
+ }
3682
+ };
3683
+ }
3684
+ function pushMarkup(structure, str) {
3685
+ if (!str) return;
3686
+ const last = structure.length - 1;
3687
+ if (typeof structure[last] === "string") structure[last] += str;
3688
+ else structure.push(str);
3689
+ }
3690
+ function visit(path, code, claimed = true) {
3691
+ const { structure } = getSection(path);
3692
+ if (!structure) return;
3693
+ const op = {
3694
+ kind: Visit,
3695
+ code,
3696
+ claimed
3697
+ };
3698
+ structure.push(op);
3699
+ return op;
3700
+ }
3701
+ function resolveStructure(section) {
3702
+ const startDynamic = section.content?.startType === 1;
3703
+ const resolved = {
3704
+ writes: [startDynamic ? "<!>" : ""],
3705
+ walks: [""],
3706
+ walkComment: [],
3707
+ steps: startDynamic ? [0, 1] : []
3708
+ };
3709
+ for (const op of section.structure) if (typeof op === "string") appendLiteral(resolved.writes, op);
3710
+ else if (typeof op === "number") resolved.steps.push(op);
3711
+ else switch (op.kind) {
3712
+ case Visit:
3713
+ if (!op.claimed) continue;
3714
+ flushSteps(resolved);
3715
+ resolved.walkComment.push(walkCodeToName[op.code]);
3716
+ appendLiteral(resolved.walks, String.fromCharCode(op.code));
3717
+ if (op.code !== 32) appendLiteral(resolved.writes, "<!>");
3718
+ break;
3719
+ case Child: {
3720
+ flushSteps(resolved);
3721
+ const template = op.renderer && resolveRef(op.renderer, "template");
3722
+ if (template) resolved.writes.push(template, "");
3723
+ resolved.walkComment.push(`<${op.name}${op.hasVar ? "/var" : ""}>`);
3724
+ appendLiteral(resolved.walks, String.fromCharCode(op.hasVar ? 48 : 47));
3725
+ const walks = op.renderer && resolveRef(op.renderer, "walks");
3726
+ if (walks) resolved.walks.push(walks, "");
3727
+ appendLiteral(resolved.walks, String.fromCharCode(38));
3728
+ break;
3729
+ }
3730
+ }
3731
+ if (section.content?.endType === 1) {
3732
+ appendLiteral(resolved.writes, "<!>");
3733
+ resolved.steps.push(0, 1);
3734
+ }
3735
+ flushSteps(resolved);
3736
+ return resolved;
3737
+ }
3738
+ function resolveRef(ref, part) {
3739
+ if (ref.kind === "sectionRef") return getSectionMetaIdentifiers(ref.section)[part === "template" ? "writes" : "walks"];
3740
+ const name = ref.program.domExports[part];
3741
+ return ref.program.section === (0, _marko_compiler_babel_utils.getProgram)().node.extra.section ? _marko_compiler.types.identifier(name) : importOrSelfReferenceName((0, _marko_compiler_babel_utils.getProgram)().hub.file, ref.path, name, `${ref.hint}_${part}`);
3742
+ }
3743
+ const [getSectionMeta] = createSectionState("SectionMeta", (section) => {
3744
+ if (!section.structure) return {
3745
+ walks: void 0,
3746
+ writes: void 0,
3747
+ decls: void 0
3748
+ };
3749
+ const { writes, walks, walkComment } = resolveStructure(section);
3750
+ const walkLiteral = normalizeStringExpression(walks, true);
3751
+ if (walkLiteral && walkLiteral.value !== "") withLeadingComment(walkLiteral, walkComment.join(", "));
3752
+ return {
3753
+ walks: walkLiteral,
3754
+ writes: normalizeStringExpression(writes, true),
3755
+ decls: void 0
3756
+ };
3757
+ });
3758
+ const sectionMetaIsIds = /* @__PURE__ */ new WeakSet();
3759
+ function getSectionMetaIdentifiers(section) {
3760
+ const meta = getSectionMeta(section);
3761
+ if (!sectionMetaIsIds.has(meta)) {
3762
+ sectionMetaIsIds.add(meta);
3763
+ const { walks, writes } = meta;
3764
+ const decls = [];
3765
+ if (walks) {
3766
+ meta.walks = generateUidIdentifier(`${section.name}__walks`);
3767
+ decls.push(_marko_compiler.types.variableDeclarator(meta.walks, walks));
3768
+ }
3769
+ if (writes) {
3770
+ meta.writes = generateUidIdentifier(`${section.name}__template`);
3771
+ decls.push(_marko_compiler.types.variableDeclarator(meta.writes, writes));
3772
+ }
3773
+ if (decls.length) meta.decls = decls;
3774
+ }
3775
+ return meta;
3776
+ }
3777
+ function flushSteps({ walks, walkComment, steps }) {
3778
+ if (!steps.length) return;
3779
+ const walkCodes = [];
3780
+ let walkString = "";
3781
+ let depth = 0;
3782
+ for (const step of steps) if (step === 0) {
3783
+ depth++;
3784
+ walkCodes.push(67);
3785
+ } else {
3786
+ depth--;
3787
+ if (depth >= 0) {
3788
+ walkCodes.length = walkCodes.lastIndexOf(67);
3789
+ walkCodes.push(97);
3790
+ } else {
3791
+ walkCodes.length = walkCodes.lastIndexOf(107) + 1;
3792
+ walkCodes.push(107);
3793
+ depth = 0;
3794
+ }
3795
+ }
3796
+ let current = walkCodes[0];
3797
+ let count = 0;
3798
+ for (const walk of walkCodes) if (walk !== current) {
3799
+ walkComment.push(`${walkCodeToName[current]}(${count})`);
3800
+ walkString += nCodeString(current, count);
3801
+ current = walk;
3802
+ count = 1;
3803
+ } else count++;
3804
+ walkComment.push(`${walkCodeToName[current]}(${count})`);
3805
+ walkString += nCodeString(current, count);
3806
+ steps.length = 0;
3807
+ appendLiteral(walks, walkString);
3808
+ }
3809
+ function nCodeString(code, number) {
3810
+ switch (code) {
3811
+ case 67: return toCharString(number, code, 25);
3812
+ case 97: return toCharString(number, code, 10);
3813
+ case 107: return toCharString(number, code, 10);
3814
+ default: throw new Error(`Unexpected walk code: ${code}`);
3815
+ }
3816
+ }
3817
+ function toCharString(number, startCode, rangeSize) {
3818
+ let result = "";
3819
+ if (number >= rangeSize) {
3820
+ const multiplier = Math.floor(number / rangeSize);
3821
+ result += toCharString(multiplier, 117, 10);
3822
+ number -= multiplier * rangeSize;
3823
+ }
3824
+ result += String.fromCharCode(startCode + number);
3825
+ return result;
3826
+ }
3827
+ /** `_content` strips trailing exit codes before it walks, so a renderer that
3828
+ * reaches the runtime through it never needs them on the wire. */
3829
+ function trimTrailingExits(walks) {
3830
+ if (!_marko_compiler.types.isStringLiteral(walks)) return walks;
3831
+ const value = walks.value.replace(/[^\0-1]+$/, "");
3832
+ return value === walks.value ? walks : value ? withLeadingComment(_marko_compiler.types.stringLiteral(value), getComment(walks)) : void 0;
3833
+ }
3834
+ function getComment(node) {
3835
+ return node.leadingComments?.[0]?.value.trim() || "";
3836
+ }
3837
+ //#endregion
3767
3838
  //#region src/translator/visitors/program/dom.ts
3768
3839
  var dom_default = { translate: {
3769
3840
  enter(program) {
@@ -4115,6 +4186,10 @@ var for_default = {
4115
4186
  };
4116
4187
  bodySection.upstreamExpression = tagExtra;
4117
4188
  bodySection.isBranch = true;
4189
+ if (!isAttrTag && !getOnlyChildParentTagName(tag)) {
4190
+ visit(tag, 37);
4191
+ enterShallow(tag);
4192
+ }
4118
4193
  },
4119
4194
  translate: translateByTarget({
4120
4195
  html: {
@@ -4126,10 +4201,6 @@ var for_default = {
4126
4201
  return;
4127
4202
  }
4128
4203
  setSectionParentIsOwner(bodySection, true);
4129
- if (!getOnlyChildParentTagName(tag)) {
4130
- visit(tag, 37);
4131
- enterShallow(tag);
4132
- }
4133
4204
  flushBefore(tag);
4134
4205
  },
4135
4206
  exit(tag) {
@@ -4181,10 +4252,6 @@ var for_default = {
4181
4252
  return;
4182
4253
  }
4183
4254
  setSectionParentIsOwner(bodySection, true);
4184
- if (!getOnlyChildParentTagName(tag)) {
4185
- visit(tag, 37);
4186
- enterShallow(tag);
4187
- }
4188
4255
  },
4189
4256
  exit(tag) {
4190
4257
  if (tag.node.body.attributeTags) return;
@@ -4602,132 +4669,179 @@ function buildContent(body) {
4602
4669
  const kNativeTagBinding = Symbol("native tag binding");
4603
4670
  const kSkipEndTag = Symbol("skip native tag mark");
4604
4671
  const kTagContentAttr = Symbol("tag could have dynamic content attribute");
4672
+ const kVisitOp = Symbol("native tag structure visit");
4605
4673
  const htmlSelectArgs = /* @__PURE__ */ new WeakMap();
4606
4674
  var native_tag_default = {
4607
- analyze: { enter(tag) {
4608
- (0, _marko_compiler_babel_utils.assertNoArgs)(tag);
4609
- (0, _marko_compiler_babel_utils.assertNoParams)(tag);
4610
- (0, _marko_compiler_babel_utils.assertNoAttributeTags)(tag);
4611
- const { node } = tag;
4612
- 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.");
4613
- const tagName = getCanonicalTagName(tag);
4614
- switch (tagName) {
4615
- case "html":
4616
- case "body":
4617
- case "head":
4618
- (0, _marko_compiler_babel_utils.getProgram)().node.extra.page ??= true;
4619
- break;
4620
- }
4621
- if (tagName === "option") assertOptionInSelectWithValue(tag);
4622
- const isTextOnly = isTextOnlyNativeTag(tag);
4623
- const seen = Object.create(null);
4624
- const { attributes } = tag.node;
4625
- let injectNonce = isInjectNonceTag(tagName);
4626
- let hasDynamicAttributes = false;
4627
- let hasEventHandlers = false;
4628
- let relatedControllable;
4629
- let spreadReferenceNodes;
4630
- let exprExtras;
4631
- for (let i = attributes.length; i--;) {
4632
- const attr = attributes[i];
4633
- if (_marko_compiler.types.isMarkoAttribute(attr) && attr.name === "content" && tag.node.body.body.length) {
4634
- dropNodes(attr.value);
4635
- continue;
4675
+ analyze: {
4676
+ enter(tag) {
4677
+ (0, _marko_compiler_babel_utils.assertNoArgs)(tag);
4678
+ (0, _marko_compiler_babel_utils.assertNoParams)(tag);
4679
+ (0, _marko_compiler_babel_utils.assertNoAttributeTags)(tag);
4680
+ const { node } = tag;
4681
+ 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.");
4682
+ const tagName = getCanonicalTagName(tag);
4683
+ switch (tagName) {
4684
+ case "html":
4685
+ case "body":
4686
+ case "head":
4687
+ (0, _marko_compiler_babel_utils.getProgram)().node.extra.page ??= true;
4688
+ break;
4636
4689
  }
4637
- const valueExtra = attr.value.extra ??= {};
4638
- if (_marko_compiler.types.isMarkoAttribute(attr)) {
4639
- if (seen[attr.name]) {
4640
- (0, _marko_compiler_babel_utils.diagnosticWarn)(tag, {
4641
- label: `The \`${attr.name}\` attribute is set more than once on \`<${tagName}>\`; only the last value is used.`,
4642
- loc: attr.loc ?? void 0
4643
- });
4690
+ if (tagName === "option") assertOptionInSelectWithValue(tag);
4691
+ const isTextOnly = isTextOnlyNativeTag(tag);
4692
+ const seen = Object.create(null);
4693
+ const { attributes } = tag.node;
4694
+ let injectNonce = isInjectNonceTag(tagName);
4695
+ let hasDynamicAttributes = false;
4696
+ let hasEventHandlers = false;
4697
+ let relatedControllable;
4698
+ let spreadReferenceNodes;
4699
+ let exprExtras;
4700
+ for (let i = attributes.length; i--;) {
4701
+ const attr = attributes[i];
4702
+ if (_marko_compiler.types.isMarkoAttribute(attr) && attr.name === "content" && tag.node.body.body.length) {
4644
4703
  dropNodes(attr.value);
4645
4704
  continue;
4646
4705
  }
4647
- seen[attr.name] = attr;
4648
- assertValidNativeAttrName(tag, attr);
4649
- assertNativeAttrValueType(tag, attr);
4650
- if (attr.name === "style") warnCamelCaseStyleKeys(tag, attr);
4651
- if (injectNonce && attr.name === "nonce") injectNonce = false;
4652
- if (isEventOrChangeHandler(attr.name)) assertNativeHandlerAttr(tag, attr);
4653
- if (isEventHandler(attr.name)) {
4706
+ const valueExtra = attr.value.extra ??= {};
4707
+ if (_marko_compiler.types.isMarkoAttribute(attr)) {
4708
+ if (seen[attr.name]) {
4709
+ (0, _marko_compiler_babel_utils.diagnosticWarn)(tag, {
4710
+ label: `The \`${attr.name}\` attribute is set more than once on \`<${tagName}>\`; only the last value is used.`,
4711
+ loc: attr.loc ?? void 0
4712
+ });
4713
+ dropNodes(attr.value);
4714
+ continue;
4715
+ }
4716
+ seen[attr.name] = attr;
4717
+ assertValidNativeAttrName(tag, attr);
4718
+ assertNativeAttrValueType(tag, attr);
4719
+ if (attr.name === "style") warnCamelCaseStyleKeys(tag, attr);
4720
+ if (injectNonce && attr.name === "nonce") injectNonce = false;
4721
+ if (isEventOrChangeHandler(attr.name)) assertNativeHandlerAttr(tag, attr);
4722
+ if (isEventHandler(attr.name)) {
4723
+ valueExtra.isEffect = true;
4724
+ valueExtra.invokeOnly = true;
4725
+ hasEventHandlers = true;
4726
+ } else {
4727
+ assertValidNativeEventHandlerAttr(tag, attr);
4728
+ if (!evaluate(attr.value).confident) hasDynamicAttributes = true;
4729
+ }
4730
+ } else if (_marko_compiler.types.isMarkoSpreadAttribute(attr)) {
4654
4731
  valueExtra.isEffect = true;
4655
- valueExtra.invokeOnly = true;
4656
4732
  hasEventHandlers = true;
4657
- } else {
4658
- assertValidNativeEventHandlerAttr(tag, attr);
4659
- if (!evaluate(attr.value).confident) hasDynamicAttributes = true;
4733
+ hasDynamicAttributes = true;
4660
4734
  }
4661
- } else if (_marko_compiler.types.isMarkoSpreadAttribute(attr)) {
4662
- valueExtra.isEffect = true;
4663
- hasEventHandlers = true;
4664
- hasDynamicAttributes = true;
4665
- }
4666
- if (spreadReferenceNodes) spreadReferenceNodes.push(attr.value);
4667
- else if (_marko_compiler.types.isMarkoSpreadAttribute(attr)) {
4668
- spreadReferenceNodes = [attr.value];
4669
- relatedControllable = getRelatedControllable(tagName, seen);
4670
- } else exprExtras = push(exprExtras, valueExtra);
4671
- }
4672
- assertExclusiveAttrs(seen, (msg) => {
4673
- throw tag.get("name").buildCodeFrameError(msg);
4674
- });
4675
- if (seen.content) {
4676
- const tagDef = (0, _marko_compiler_babel_utils.getTagDef)(tag);
4677
- if (tagDef?.parseOptions?.openTagOnly && !tagDef.attributes?.content) throw tag.hub.buildError(seen.content, `The \`<${tagName}>\` tag cannot have content, so it does not support the \`content\` attribute.`);
4678
- if (isTextOnly) throw tag.hub.buildError(seen.content, `The \`<${tagName}>\` tag takes its content from its body as text, so it does not support the \`content\` attribute.`);
4679
- }
4680
- let textPlaceholders;
4681
- if (isTextOnly) {
4682
- for (const child of tag.node.body.body) if (_marko_compiler.types.isMarkoPlaceholder(child)) (textPlaceholders ||= []).push(child.value);
4683
- else if (!_marko_compiler.types.isMarkoText(child)) throw tag.hub.buildError(child, `Only text is allowed inside a \`<${tagName}>\`.`);
4684
- }
4685
- relatedControllable ||= getRelatedControllable(tagName, seen);
4686
- if (relatedControllable && relatedControllable.attrs[1]) hasEventHandlers = true;
4687
- if (node.var || hasDynamicAttributes || hasEventHandlers || textPlaceholders || injectNonce || isDynamicControllable(relatedControllable)) {
4688
- const tagExtra = node.extra ??= {};
4689
- const tagSection = getOrCreateSection(tag);
4690
- const nodeBinding = tagExtra[kNativeTagBinding] = createBinding("#" + tagName.toLowerCase(), 0, tagSection, void 0, void 0, void 0, void 0, !!node.var);
4691
- if (hasEventHandlers) (0, _marko_compiler_babel_utils.getProgram)().node.extra.isInteractive = true;
4692
- if (spreadReferenceNodes) {
4693
- const isMergedSpread = !!relatedControllable;
4694
- if (relatedControllable && !relatedControllable.attrs.every(Boolean)) {
4695
- for (const attr of relatedControllable.attrs) if (attr) spreadReferenceNodes.push(attr.value);
4696
- relatedControllable = void 0;
4697
- }
4698
- const spreadExtra = mergeReferences(tagSection, tag.node, spreadReferenceNodes);
4699
- spreadExtra.nativeTagSpread = true;
4700
- spreadExtra.invokeOnly = true;
4701
- if (isMergedSpread) spreadExtra.nativeTagSpreadMerged = true;
4702
- let carveProperties = getSpreadControllableValueProps(tagName);
4703
- if (!tag.node.body.body.length && !isTextOnly && !(0, _marko_compiler_babel_utils.getTagDef)(tag)?.parseOptions?.openTagOnly && !seen.content) if (carveProperties) carveProperties.push("content");
4704
- else carveProperties = ["content"];
4705
- for (const node of spreadReferenceNodes) {
4706
- const spreadBinding = node.extra?.spreadFrom;
4707
- if (spreadBinding) {
4708
- spreadBinding.noSerialize = true;
4709
- if (carveProperties) {
4710
- for (const property of carveProperties) if (!includes(spreadBinding.noSerializeProperties, property)) spreadBinding.noSerializeProperties = push(spreadBinding.noSerializeProperties, property);
4735
+ if (spreadReferenceNodes) spreadReferenceNodes.push(attr.value);
4736
+ else if (_marko_compiler.types.isMarkoSpreadAttribute(attr)) {
4737
+ spreadReferenceNodes = [attr.value];
4738
+ relatedControllable = getRelatedControllable(tagName, seen);
4739
+ } else exprExtras = push(exprExtras, valueExtra);
4740
+ }
4741
+ assertExclusiveAttrs(seen, (msg) => {
4742
+ throw tag.get("name").buildCodeFrameError(msg);
4743
+ });
4744
+ if (seen.content) {
4745
+ const tagDef = (0, _marko_compiler_babel_utils.getTagDef)(tag);
4746
+ if (tagDef?.parseOptions?.openTagOnly && !tagDef.attributes?.content) throw tag.hub.buildError(seen.content, `The \`<${tagName}>\` tag cannot have content, so it does not support the \`content\` attribute.`);
4747
+ if (isTextOnly) throw tag.hub.buildError(seen.content, `The \`<${tagName}>\` tag takes its content from its body as text, so it does not support the \`content\` attribute.`);
4748
+ }
4749
+ let textPlaceholders;
4750
+ if (isTextOnly) {
4751
+ for (const child of tag.node.body.body) if (_marko_compiler.types.isMarkoPlaceholder(child)) (textPlaceholders ||= []).push(child.value);
4752
+ else if (!_marko_compiler.types.isMarkoText(child)) throw tag.hub.buildError(child, `Only text is allowed inside a \`<${tagName}>\`.`);
4753
+ }
4754
+ relatedControllable ||= getRelatedControllable(tagName, seen);
4755
+ if (relatedControllable && relatedControllable.attrs[1]) hasEventHandlers = true;
4756
+ if (node.var || hasDynamicAttributes || hasEventHandlers || textPlaceholders || injectNonce || isDynamicControllable(relatedControllable)) {
4757
+ const tagExtra = node.extra ??= {};
4758
+ const tagSection = getOrCreateSection(tag);
4759
+ const nodeBinding = tagExtra[kNativeTagBinding] = createBinding("#" + tagName.toLowerCase(), 0, tagSection, void 0, void 0, void 0, void 0, !!node.var);
4760
+ if (hasEventHandlers) (0, _marko_compiler_babel_utils.getProgram)().node.extra.isInteractive = true;
4761
+ if (spreadReferenceNodes) {
4762
+ const isMergedSpread = !!relatedControllable;
4763
+ if (relatedControllable && !relatedControllable.attrs.every(Boolean)) {
4764
+ for (const attr of relatedControllable.attrs) if (attr) spreadReferenceNodes.push(attr.value);
4765
+ relatedControllable = void 0;
4766
+ }
4767
+ const spreadExtra = mergeReferences(tagSection, tag.node, spreadReferenceNodes);
4768
+ spreadExtra.nativeTagSpread = true;
4769
+ spreadExtra.invokeOnly = true;
4770
+ if (isMergedSpread) spreadExtra.nativeTagSpreadMerged = true;
4771
+ let carveProperties = getSpreadControllableValueProps(tagName);
4772
+ if (!tag.node.body.body.length && !isTextOnly && !(0, _marko_compiler_babel_utils.getTagDef)(tag)?.parseOptions?.openTagOnly && !seen.content) if (carveProperties) carveProperties.push("content");
4773
+ else carveProperties = ["content"];
4774
+ for (const node of spreadReferenceNodes) {
4775
+ const spreadBinding = node.extra?.spreadFrom;
4776
+ if (spreadBinding) {
4777
+ spreadBinding.noSerialize = true;
4778
+ if (carveProperties) {
4779
+ for (const property of carveProperties) if (!includes(spreadBinding.noSerializeProperties, property)) spreadBinding.noSerializeProperties = push(spreadBinding.noSerializeProperties, property);
4780
+ }
4711
4781
  }
4712
4782
  }
4713
4783
  }
4784
+ if (relatedControllable) mergeReferences(tagSection, relatedControllable.attrs.find(Boolean).value, relatedControllable.attrs.map((it) => it?.value));
4785
+ if (textPlaceholders) {
4786
+ exprExtras = push(exprExtras, textPlaceholders.length === 1 ? textPlaceholders[0].extra ??= {} : mergeReferences(tagSection, textPlaceholders[0], textPlaceholders.slice(1)));
4787
+ addSetupExpr(tagSection, textPlaceholders[0]);
4788
+ }
4789
+ if (injectNonce) addSetupStatement(tagSection);
4790
+ if (relatedControllable?.attrs[1]) addSetupStatement(tagSection);
4791
+ for (const name in seen) {
4792
+ const attr = seen[name];
4793
+ if (isEventHandler(name) || name === "content" || !evaluate(attr.value).confident) addSetupExpr(tagSection, attr.value);
4794
+ }
4795
+ addSerializeExpr(tagSection, !!(node.var || hasEventHandlers), nodeBinding);
4796
+ trackDomVarReferences(tag, nodeBinding);
4797
+ addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
4714
4798
  }
4715
- if (relatedControllable) mergeReferences(tagSection, relatedControllable.attrs.find(Boolean).value, relatedControllable.attrs.map((it) => it?.value));
4716
- if (textPlaceholders) {
4717
- exprExtras = push(exprExtras, textPlaceholders.length === 1 ? textPlaceholders[0].extra ??= {} : mergeReferences(tagSection, textPlaceholders[0], textPlaceholders.slice(1)));
4718
- addSetupExpr(tagSection, textPlaceholders[0]);
4799
+ const write = writeTo(tag);
4800
+ (node.extra ??= {})[kVisitOp] = visit(tag, 32, false);
4801
+ write`<${tagName}`;
4802
+ for (const attr of getUsedAttrs(tagName, tag.node, true).staticAttrs) {
4803
+ const { name, value } = attr;
4804
+ const { confident, computed } = value.extra || {};
4805
+ switch (name) {
4806
+ case "class":
4807
+ case "style": {
4808
+ const helper = `_attr_${name}`;
4809
+ if (confident) write`${getHTMLRuntime()[helper](computed)}`;
4810
+ else {
4811
+ const meta = {
4812
+ staticItems: void 0,
4813
+ dynamicItems: void 0,
4814
+ dynamicValues: void 0
4815
+ };
4816
+ trackDelimitedAttrValue(value, meta);
4817
+ if (!meta.dynamicItems && meta.staticItems) write`${getHTMLRuntime()[helper](meta.staticItems)}`;
4818
+ }
4819
+ break;
4820
+ }
4821
+ default:
4822
+ if (confident) write`${getHTMLRuntime()._attr(name, computed)}`;
4823
+ break;
4824
+ }
4719
4825
  }
4720
- if (injectNonce) addSetupStatement(tagSection);
4721
- if (relatedControllable?.attrs[1]) addSetupStatement(tagSection);
4722
- for (const name in seen) {
4723
- const attr = seen[name];
4724
- if (isEventHandler(name) || name === "content" || !evaluate(attr.value).confident) addSetupExpr(tagSection, attr.value);
4826
+ write`>`;
4827
+ enter(tag);
4828
+ },
4829
+ exit(tag) {
4830
+ const tagName = getCanonicalTagName(tag);
4831
+ const tagExtra = tag.node.extra;
4832
+ const visitOp = tagExtra[kVisitOp];
4833
+ if (visitOp) visitOp.claimed = !!tagExtra[kNativeTagBinding];
4834
+ if (!(0, _marko_compiler_babel_utils.getTagDef)(tag)?.parseOptions?.openTagOnly) {
4835
+ const write = writeTo(tag);
4836
+ if (tagName !== "textarea" && isTextOnlyNativeTag(tag)) {
4837
+ const textLiteral = bodyToRawTextLiteral(tag.node.body);
4838
+ if (_marko_compiler.types.isStringLiteral(textLiteral)) write`${textLiteral.value}`;
4839
+ }
4840
+ write`</${tagName}>`;
4725
4841
  }
4726
- addSerializeExpr(tagSection, !!(node.var || hasEventHandlers), nodeBinding);
4727
- trackDomVarReferences(tag, nodeBinding);
4728
- addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
4842
+ exit(tag);
4729
4843
  }
4730
- } },
4844
+ },
4731
4845
  translate: translateByTarget({
4732
4846
  html: {
4733
4847
  enter(tag) {
@@ -4735,7 +4849,7 @@ var native_tag_default = {
4735
4849
  const tagExtra = tag.node.extra;
4736
4850
  const nodeBinding = tagExtra[kNativeTagBinding];
4737
4851
  const tagDef = (0, _marko_compiler_babel_utils.getTagDef)(tag);
4738
- const write = writeTo(tag);
4852
+ const write = writeTo$1(tag);
4739
4853
  const tagSection = getSection(tag);
4740
4854
  const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
4741
4855
  const usedAttrs = getUsedAttrs(tagName, tag.node);
@@ -4839,7 +4953,7 @@ var native_tag_default = {
4839
4953
  const tagName = getCanonicalTagName(tag);
4840
4954
  const tagSection = getSection(tag);
4841
4955
  const markerSerializeReason = !tagExtra[kSkipEndTag] && nodeBinding && getSerializeReason(tagSection, nodeBinding);
4842
- const write = writeTo(tag, tagName === "html" || !markerSerializeReason && tagName === "body");
4956
+ const write = writeTo$1(tag, tagName === "html" || !markerSerializeReason && tagName === "body");
4843
4957
  if (tagExtra[kTagContentAttr]) flushBefore(tag);
4844
4958
  if (selectArgs) {
4845
4959
  if (!tagExtra[kSkipEndTag]) write`</${tagName}>`;
@@ -4867,11 +4981,8 @@ var native_tag_default = {
4867
4981
  const tagExtra = tag.node.extra;
4868
4982
  const nodeBinding = tagExtra[kNativeTagBinding];
4869
4983
  const tagDef = (0, _marko_compiler_babel_utils.getTagDef)(tag);
4870
- const write = writeTo(tag);
4871
4984
  const tagSection = getSection(tag);
4872
4985
  const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
4873
- if (nodeBinding) visit(tag, 32);
4874
- write`<${tagName}`;
4875
4986
  const { staticAttrs, staticControllable, staticContentAttr, skipExpression, spreadExpression, injectNonce } = getUsedAttrs(tagName, tag.node);
4876
4987
  const isOpenOnly = !!(tagDef && tagDef.parseOptions?.openTagOnly);
4877
4988
  const isTextOnly = isTextOnlyNativeTag(tag);
@@ -4888,14 +4999,13 @@ var native_tag_default = {
4888
4999
  }
4889
5000
  for (const attr of staticAttrs) {
4890
5001
  const { name, value } = attr;
4891
- const { confident, computed } = value.extra || {};
5002
+ const { confident } = value.extra || {};
4892
5003
  const valueReferences = value.extra?.referencedBindings;
4893
5004
  switch (name) {
4894
5005
  case "class":
4895
5006
  case "style": {
4896
5007
  const helper = `_attr_${name}`;
4897
- if (confident) write`${getHTMLRuntime()[helper](computed)}`;
4898
- else {
5008
+ if (!confident) {
4899
5009
  const nodeExpr = createScopeReadExpression(nodeBinding);
4900
5010
  const meta = {
4901
5011
  staticItems: void 0,
@@ -4905,22 +5015,19 @@ var native_tag_default = {
4905
5015
  let stmt;
4906
5016
  trackDelimitedAttrValue(value, meta);
4907
5017
  if (meta.dynamicItems) stmt = _marko_compiler.types.expressionStatement(callRuntime(helper, nodeExpr, value));
4908
- else {
4909
- if (meta.staticItems) write`${getHTMLRuntime()[helper](meta.staticItems)}`;
4910
- if (meta.dynamicValues) {
4911
- const keys = Object.keys(meta.dynamicValues);
4912
- if (keys.length === 1) {
4913
- const [key] = keys;
5018
+ else if (meta.dynamicValues) {
5019
+ const keys = Object.keys(meta.dynamicValues);
5020
+ if (keys.length === 1) {
5021
+ const [key] = keys;
5022
+ const value = meta.dynamicValues[key];
5023
+ stmt = _marko_compiler.types.expressionStatement(callRuntime(`_attr_${name}_item`, nodeExpr, _marko_compiler.types.stringLiteral(key), value));
5024
+ } else {
5025
+ const props = [];
5026
+ for (const key of keys) {
4914
5027
  const value = meta.dynamicValues[key];
4915
- stmt = _marko_compiler.types.expressionStatement(callRuntime(`_attr_${name}_item`, nodeExpr, _marko_compiler.types.stringLiteral(key), value));
4916
- } else {
4917
- const props = [];
4918
- for (const key of keys) {
4919
- const value = meta.dynamicValues[key];
4920
- props.push(_marko_compiler.types.objectProperty(toPropertyName(key), value));
4921
- }
4922
- stmt = _marko_compiler.types.expressionStatement(callRuntime(`_attr_${name}_items`, nodeExpr, _marko_compiler.types.objectExpression(props)));
5028
+ props.push(_marko_compiler.types.objectProperty(toPropertyName(key), value));
4923
5029
  }
5030
+ stmt = _marko_compiler.types.expressionStatement(callRuntime(`_attr_${name}_items`, nodeExpr, _marko_compiler.types.objectExpression(props)));
4924
5031
  }
4925
5032
  }
4926
5033
  if (stmt) addStatement("render", tagSection, valueReferences, stmt, void 0, !!meta.dynamicItems);
@@ -4928,7 +5035,7 @@ var native_tag_default = {
4928
5035
  break;
4929
5036
  }
4930
5037
  default:
4931
- if (confident) write`${getHTMLRuntime()._attr(name, computed)}`;
5038
+ if (confident) break;
4932
5039
  else if (isEventHandler(name)) addStatement("effect", tagSection, valueReferences, _marko_compiler.types.expressionStatement(callRuntime("_on", createScopeReadExpression(nodeBinding), _marko_compiler.types.stringLiteral(getEventHandlerName(name)), value)));
4933
5040
  else addStatement("render", tagSection, valueReferences, _marko_compiler.types.expressionStatement(callRuntime("_attr", createScopeReadExpression(nodeBinding), _marko_compiler.types.stringLiteral(name), value)), void 0, true);
4934
5041
  break;
@@ -4941,27 +5048,19 @@ var native_tag_default = {
4941
5048
  const controllable = !staticControllable && controllableClaimFor(staticName);
4942
5049
  if (skipExpression) addStatement("render", tagSection, tagExtra.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime(canHaveAttrContent ? "_attrs_partial_content" : "_attrs_partial", scopeIdentifier, visitAccessor, spreadExpression, skipExpression, controllable && importRuntime(controllable))));
4943
5050
  else addStatement("render", tagSection, tagExtra.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime(canHaveAttrContent ? "_attrs_content" : "_attrs", scopeIdentifier, visitAccessor, spreadExpression, controllable && importRuntime(controllable))));
4944
- enableControllable(controllableScriptLatchFor(staticName));
5051
+ enableControllable(controllableFeatureFor(staticName));
4945
5052
  addStatement("effect", tagSection, tagExtra.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_attrs_script", scopeIdentifier, visitAccessor)), false);
4946
5053
  }
4947
5054
  if (staticContentAttr) addStatement("render", tagSection, staticContentAttr.value.extra?.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_attr_content", scopeIdentifier, visitAccessor, staticContentAttr.value)), void 0, true);
4948
- write`>`;
4949
- enter(tag);
4950
5055
  },
4951
5056
  exit(tag) {
4952
5057
  const nodeBinding = tag.node.extra[kNativeTagBinding];
4953
5058
  const openTagOnly = (0, _marko_compiler_babel_utils.getTagDef)(tag)?.parseOptions?.openTagOnly;
4954
5059
  const tagName = getCanonicalTagName(tag);
4955
- if (!openTagOnly) {
4956
- const write = writeTo(tag);
4957
- if (tagName !== "textarea" && isTextOnlyNativeTag(tag)) {
4958
- const textLiteral = bodyToTextLiteral(tag.node.body);
4959
- if (_marko_compiler.types.isStringLiteral(textLiteral)) write`${textLiteral}`;
4960
- else addStatement("render", getSection(tag), textLiteral.extra?.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_text_content", createScopeReadExpression(nodeBinding), textLiteral)), void 0, true);
4961
- } else tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
4962
- write`</${tagName}>`;
4963
- }
4964
- exit(tag);
5060
+ if (!openTagOnly) if (tagName !== "textarea" && isTextOnlyNativeTag(tag)) {
5061
+ const textLiteral = bodyToTextLiteral(tag.node.body);
5062
+ if (!_marko_compiler.types.isStringLiteral(textLiteral)) addStatement("render", getSection(tag), textLiteral.extra?.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_text_content", createScopeReadExpression(nodeBinding), textLiteral)), void 0, true);
5063
+ } else tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
4965
5064
  tag.remove();
4966
5065
  }
4967
5066
  }
@@ -5049,7 +5148,7 @@ function getInputValueMode(typeAttr) {
5049
5148
  function getDOMControllableDefaultHelper(controllable) {
5050
5149
  return controllable.helper === "_attr_input_value" && controllable.valueMode ? `_attr_input_value_${controllable.valueMode}_default` : `${controllable.helper}_default`;
5051
5150
  }
5052
- function getUsedAttrs(tagName, tag) {
5151
+ function getUsedAttrs(tagName, tag, staticOnly) {
5053
5152
  const seen = Object.create(null);
5054
5153
  const { attributes } = tag;
5055
5154
  const maybeStaticAttrs = /* @__PURE__ */ new Set();
@@ -5092,6 +5191,14 @@ function getUsedAttrs(tagName, tag) {
5092
5191
  for (const attr of staticControllable.attrs) if (attr) maybeStaticAttrs.delete(attr);
5093
5192
  }
5094
5193
  const staticAttrs = [...maybeStaticAttrs].reverse();
5194
+ if (staticOnly) return {
5195
+ injectNonce,
5196
+ staticAttrs,
5197
+ staticContentAttr,
5198
+ staticControllable,
5199
+ spreadExpression,
5200
+ skipExpression
5201
+ };
5095
5202
  if (spreadProps) {
5096
5203
  if (staticControllable) {
5097
5204
  for (const attr of staticControllable.attrs) if (attr) skipProps.add(attr.name);
@@ -5363,28 +5470,20 @@ function controllableClaimFor(tagName) {
5363
5470
  case "dialog": return "_controllable_open";
5364
5471
  }
5365
5472
  }
5366
- /** The resume-pass latch for a tag: `_attrs_script` resolves the control kind
5367
- * at run time, and a run-time tag name can be any of them. */
5368
- function controllableScriptLatchFor(tagName) {
5473
+ /** The resume-pass feature for a tag: `_attrs_script` resolves the control
5474
+ * kind at run time, and a run-time tag name can be any of them. */
5475
+ function controllableFeatureFor(tagName) {
5369
5476
  switch (tagName) {
5370
- case "input": return "_enable_controllable_input";
5371
- case "textarea": return "_enable_controllable_textarea";
5372
- case "select": return "_enable_controllable_select";
5477
+ case "input": return "controllable-input";
5478
+ case "textarea": return "controllable-textarea";
5479
+ case "select": return "controllable-select";
5373
5480
  case "details":
5374
- case "dialog": return "_enable_controllable_open";
5375
- case void 0: return "_enable_controllable";
5481
+ case "dialog": return "controllable-open";
5482
+ case void 0: return "controllable";
5376
5483
  }
5377
5484
  }
5378
- const enabledControllables = /* @__PURE__ */ new WeakMap();
5379
- /** Emits the latch once per program, like `_enable_catch`. */
5380
- function enableControllable(helper) {
5381
- if (!helper) return;
5382
- const program = (0, _marko_compiler_babel_utils.getProgram)().node;
5383
- let enabled = enabledControllables.get(program);
5384
- if (!enabled) enabledControllables.set(program, enabled = /* @__PURE__ */ new Set());
5385
- if (enabled.has(helper)) return;
5386
- enabled.add(helper);
5387
- program.body.push(_marko_compiler.types.expressionStatement(callRuntime(helper)));
5485
+ function enableControllable(feature) {
5486
+ if (feature) importRuntimeFeature(feature);
5388
5487
  }
5389
5488
  //#endregion
5390
5489
  //#region src/translator/util/is-only-child-in-parent.ts
@@ -5426,6 +5525,10 @@ const IfTag = {
5426
5525
  const ifTagSection = getOrCreateSection(ifTag);
5427
5526
  const ifTagExtra = ifTag.node.extra ??= {};
5428
5527
  const mergeReferenceNodes = [];
5528
+ if (!getOnlyChildParentTagName(ifTag, branches.length)) {
5529
+ visit(ifTag, 37);
5530
+ enterShallow(ifTag);
5531
+ }
5429
5532
  const sectionAccessor = {
5430
5533
  binding: getOptimizedOnlyChildNodeBinding(ifTag, ifTagSection, branches.length),
5431
5534
  prefix: getAccessorPrefix().BranchScopes
@@ -5447,10 +5550,6 @@ const IfTag = {
5447
5550
  enter(tag) {
5448
5551
  if (tag.node.body.attributeTags) return;
5449
5552
  const bodySection = getSectionForBody(tag.get("body"));
5450
- if (isRoot(tag) && !getOnlyChildParentTagName(tag)) {
5451
- visit(tag, 37);
5452
- enterShallow(tag);
5453
- }
5454
5553
  flushBefore(tag);
5455
5554
  if (bodySection) setSectionParentIsOwner(bodySection, true);
5456
5555
  },
@@ -5515,10 +5614,6 @@ const IfTag = {
5515
5614
  if (tag.node.body.attributeTags) return;
5516
5615
  const bodySection = getSectionForBody(tag.get("body"));
5517
5616
  if (bodySection) setSectionParentIsOwner(bodySection, true);
5518
- if (isRoot(tag) && !getOnlyChildParentTagName(tag)) {
5519
- visit(tag, 37);
5520
- enterShallow(tag);
5521
- }
5522
5617
  },
5523
5618
  exit(tag) {
5524
5619
  if (tag.node.body.attributeTags) return;
@@ -5689,9 +5784,6 @@ function isLastBranch(tag) {
5689
5784
  const branches = getBranches(tag);
5690
5785
  return branches[branches.length - 1][0] === tag;
5691
5786
  }
5692
- function isRoot(tag) {
5693
- return isCoreTagName(tag, "if");
5694
- }
5695
5787
  //#endregion
5696
5788
  //#region src/translator/core/textarea.ts
5697
5789
  function preAnalyze$1(tag) {
@@ -7963,6 +8055,8 @@ var await_default = {
7963
8055
  if (paramsBinding) setBindingDownstream(paramsBinding, valueExtra);
7964
8056
  bodySection.upstreamExpression = valueAttr.value.extra;
7965
8057
  addSetupStatement(section);
8058
+ visit(tag, 37);
8059
+ enterShallow(tag);
7966
8060
  },
7967
8061
  translate: translateByTarget({
7968
8062
  html: {
@@ -7995,8 +8089,6 @@ var await_default = {
7995
8089
  return;
7996
8090
  }
7997
8091
  setSectionParentIsOwner(bodySection, true);
7998
- visit(tag, 37);
7999
- enterShallow(tag);
8000
8092
  },
8001
8093
  exit(tag) {
8002
8094
  const { node } = tag;
@@ -8009,6 +8101,7 @@ var await_default = {
8009
8101
  const branchRenderArgs = getBranchRendererArgs(bodySection);
8010
8102
  const branchParams = branchRenderArgs.pop();
8011
8103
  (signal.prependStatements ||= []).push(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(_marko_compiler.types.identifier(bodySection.name), callRuntime("_await_content", getScopeAccessorLiteral(nodeRef, true), ...replaceNullishAndEmptyFunctionsWith0(branchRenderArgs)))]));
8104
+ importRuntimeFeature("catch");
8012
8105
  return callRuntime("_await_promise", getScopeAccessorLiteral(nodeRef, true), branchParams);
8013
8106
  };
8014
8107
  addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier(bodySection.name), [scopeIdentifier])));
@@ -8292,6 +8385,7 @@ var html_comment_default = {
8292
8385
  if (!_marko_compiler.types.isIdentifier(tagVar)) throw tag.get("var").buildCodeFrameError("The [`<html-comment>` tag](https://markojs.com/docs/reference/core-tag#html-comment) tag variable cannot be destructured.");
8293
8386
  needsBinding = true;
8294
8387
  }
8388
+ let nodeBinding;
8295
8389
  const referenceNodes = [];
8296
8390
  for (const child of tag.get("body").get("body")) if (child.isMarkoPlaceholder()) {
8297
8391
  referenceNodes.push(child.node.value);
@@ -8300,40 +8394,40 @@ var html_comment_default = {
8300
8394
  if (needsBinding) {
8301
8395
  const tagSection = getOrCreateSection(tag);
8302
8396
  const tagExtra = mergeReferences(tagSection, tag.node, referenceNodes);
8303
- const nodeBinding = tagExtra[kNodeBinding$1] = createBinding("#comment", 0, tagSection, void 0, void 0, void 0, void 0, !!tagVar);
8397
+ nodeBinding = tagExtra[kNodeBinding$1] = createBinding("#comment", 0, tagSection, void 0, void 0, void 0, void 0, !!tagVar);
8304
8398
  trackDomVarReferences(tag, nodeBinding);
8305
8399
  addSerializeExpr(tagSection, !!tagVar || tagExtra, nodeBinding);
8306
8400
  }
8401
+ const write = writeTo(tag);
8402
+ if (nodeBinding) visit(tag, 32);
8403
+ enter(tag);
8404
+ write`<!--`;
8405
+ const textLiteral = bodyToRawTextLiteral(tag.node.body);
8406
+ if (_marko_compiler.types.isStringLiteral(textLiteral)) write`${escapeCommentText(textLiteral.value)}`;
8407
+ exit(tag);
8408
+ write`-->`;
8307
8409
  tag.skip();
8308
8410
  },
8309
- translate: {
8310
- enter(tag) {
8311
- if (tag.node.extra[kNodeBinding$1]) visit(tag, 32);
8312
- enter(tag);
8313
- writeTo(tag)`<!--`;
8314
- },
8315
- exit(tag) {
8316
- const tagSection = getSection(tag);
8317
- const tagExtra = tag.node.extra;
8318
- const nodeBinding = tagExtra[kNodeBinding$1];
8319
- const write = writeTo(tag);
8320
- if (isOutputHTML()) {
8321
- const { body } = tag.node.body;
8322
- if (nodeBinding && isEmptiableCommentBody(body)) if (body.length) write`${_marko_compiler.types.logicalExpression("||", buildCommentValue(body), _marko_compiler.types.stringLiteral(" "))}`;
8323
- else write` `;
8324
- else for (const child of body) if (_marko_compiler.types.isMarkoText(child)) write`${escapeCommentText(child.value)}`;
8325
- else if (_marko_compiler.types.isMarkoPlaceholder(child)) write`${callRuntime(child.escape ? "_escape_comment" : "_unescaped", child.value)}`;
8326
- } else {
8327
- const textLiteral = bodyToTextLiteral(tag.node.body);
8328
- if (_marko_compiler.types.isStringLiteral(textLiteral)) write`${escapeCommentText(textLiteral.value)}`;
8329
- else addStatement("render", tagSection, tagExtra.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_text", createScopeReadExpression(nodeBinding), textLiteral)));
8330
- }
8331
- exit(tag);
8411
+ translate: { exit(tag) {
8412
+ const tagSection = getSection(tag);
8413
+ const tagExtra = tag.node.extra;
8414
+ const nodeBinding = tagExtra[kNodeBinding$1];
8415
+ const write = writeTo$1(tag);
8416
+ if (isOutputHTML()) {
8417
+ const { body } = tag.node.body;
8418
+ write`<!--`;
8419
+ if (nodeBinding && isEmptiableCommentBody(body)) if (body.length) write`${_marko_compiler.types.logicalExpression("||", buildCommentValue(body), _marko_compiler.types.stringLiteral(" "))}`;
8420
+ else write` `;
8421
+ else for (const child of body) if (_marko_compiler.types.isMarkoText(child)) write`${escapeCommentText(child.value)}`;
8422
+ else if (_marko_compiler.types.isMarkoPlaceholder(child)) write`${callRuntime(child.escape ? "_escape_comment" : "_unescaped", child.value)}`;
8332
8423
  write`-->`;
8333
- if (nodeBinding) markNode(tag, nodeBinding, getSerializeReason(tagSection, nodeBinding));
8334
- tag.remove();
8424
+ } else {
8425
+ const textLiteral = bodyToTextLiteral(tag.node.body);
8426
+ if (!_marko_compiler.types.isStringLiteral(textLiteral)) addStatement("render", tagSection, tagExtra.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_text", createScopeReadExpression(nodeBinding), textLiteral)));
8335
8427
  }
8336
- },
8428
+ if (nodeBinding) markNode(tag, nodeBinding, getSerializeReason(tagSection, nodeBinding));
8429
+ tag.remove();
8430
+ } },
8337
8431
  parseOptions: { text: true },
8338
8432
  types: runtime_info_default.name + "/tags/html-comment.d.marko",
8339
8433
  autocomplete: [{
@@ -8748,7 +8842,11 @@ var show_default = {
8748
8842
  assertLegalHiddenContext(tag);
8749
8843
  const tagSection = getOrCreateSection(tag);
8750
8844
  if (getOnlyChildParentTagName(tag)) getOptimizedOnlyChildNodeBinding(tag, tagSection);
8751
- else tagExtra[kStartBinding] = createBinding("#text", 0, tagSection);
8845
+ else {
8846
+ tagExtra[kStartBinding] = createBinding("#text", 0, tagSection);
8847
+ visit(tag, 37);
8848
+ enterShallow(tag);
8849
+ }
8752
8850
  if (tagExtra[kStaticDisplay] === void 0) {
8753
8851
  mergeReferences(tagSection, tag.node, [display]);
8754
8852
  addSerializeExpr(tagSection, tagExtra, kStatefulReason);
@@ -8758,7 +8856,15 @@ var show_default = {
8758
8856
  const tagExtra = tag.node.extra;
8759
8857
  if (tagExtra[kStaticDisplay] === true) return;
8760
8858
  const tagSection = getSection(tag);
8761
- if (tagExtra[kStartBinding] && !tagExtra[kSingleNodeBody]) tagExtra[kEndBinding] = createBinding("#text", 0, tagSection);
8859
+ if (tagExtra[kStartBinding]) {
8860
+ if (!tagExtra[kSingleNodeBody]) {
8861
+ tagExtra[kEndBinding] = createBinding("#text", 0, tagSection);
8862
+ visit(tag, 37);
8863
+ enterShallow(tag);
8864
+ }
8865
+ visit(tag, 37);
8866
+ enterShallow(tag);
8867
+ }
8762
8868
  const nodeBinding = getOptimizedOnlyChildNodeBinding(tag, tagSection);
8763
8869
  if (tagExtra[kStaticDisplay] === void 0) addSerializeExpr(tagSection, tagExtra, nodeBinding);
8764
8870
  }
@@ -8771,7 +8877,7 @@ var show_default = {
8771
8877
  const staticDisplay = tagExtra[kStaticDisplay];
8772
8878
  if (staticDisplay === true) return;
8773
8879
  if (staticDisplay === false) {
8774
- writeTo(tag)`<t hidden>`;
8880
+ writeTo$1(tag)`<t hidden>`;
8775
8881
  return;
8776
8882
  }
8777
8883
  const display = tag.node.attributes[0].value;
@@ -8784,7 +8890,7 @@ var show_default = {
8784
8890
  exit(tag) {
8785
8891
  const tagExtra = tag.node.extra;
8786
8892
  const staticDisplay = tagExtra[kStaticDisplay];
8787
- if (staticDisplay === false) writeTo(tag)`</t>`;
8893
+ if (staticDisplay === false) writeTo$1(tag)`</t>`;
8788
8894
  flushInto(tag);
8789
8895
  const bodyStatements = tag.node.body.body;
8790
8896
  if (staticDisplay !== void 0) {
@@ -8814,40 +8920,24 @@ var show_default = {
8814
8920
  ])) replacement.skip();
8815
8921
  }
8816
8922
  },
8817
- dom: {
8818
- enter(tag) {
8819
- if (tag.node.extra[kStartBinding]) {
8820
- visit(tag, 37);
8821
- enterShallow(tag);
8822
- }
8823
- },
8824
- exit(tag) {
8825
- const tagExtra = tag.node.extra;
8826
- if (tagExtra[kStaticDisplay] === true) {
8827
- tag.remove();
8828
- return;
8829
- }
8830
- const tagSection = getSection(tag);
8831
- const endBinding = tagExtra[kEndBinding];
8832
- const nodeBinding = getOptimizedOnlyChildNodeBinding(tag, tagSection);
8833
- const startBinding = tagExtra[kStartBinding];
8834
- const display = tagExtra[kStaticDisplay] === false ? _marko_compiler.types.booleanLiteral(false) : tag.node.attributes[0].value;
8835
- if (endBinding) {
8836
- visit(tag, 37);
8837
- enterShallow(tag);
8838
- }
8839
- if (startBinding) {
8840
- visit(tag, 37);
8841
- enterShallow(tag);
8842
- }
8843
- const signal = getSignal(tagSection, nodeBinding, "show");
8844
- signal.build = () => {
8845
- return callRuntime("_show", getScopeAccessorLiteral(nodeBinding, true), startBinding ? getScopeAccessorLiteral(startBinding, true) : void 0, endBinding ? getScopeAccessorLiteral(endBinding, true) : void 0);
8846
- };
8847
- addValue(tagSection, tagExtra.referencedBindings, signal, display);
8923
+ dom: { exit(tag) {
8924
+ const tagExtra = tag.node.extra;
8925
+ if (tagExtra[kStaticDisplay] === true) {
8848
8926
  tag.remove();
8927
+ return;
8849
8928
  }
8850
- }
8929
+ const tagSection = getSection(tag);
8930
+ const endBinding = tagExtra[kEndBinding];
8931
+ const nodeBinding = getOptimizedOnlyChildNodeBinding(tag, tagSection);
8932
+ const startBinding = tagExtra[kStartBinding];
8933
+ const display = tagExtra[kStaticDisplay] === false ? _marko_compiler.types.booleanLiteral(false) : tag.node.attributes[0].value;
8934
+ const signal = getSignal(tagSection, nodeBinding, "show");
8935
+ signal.build = () => {
8936
+ return callRuntime("_show", getScopeAccessorLiteral(nodeBinding, true), startBinding ? getScopeAccessorLiteral(startBinding, true) : void 0, endBinding ? getScopeAccessorLiteral(endBinding, true) : void 0);
8937
+ };
8938
+ addValue(tagSection, tagExtra.referencedBindings, signal, display);
8939
+ tag.remove();
8940
+ } }
8851
8941
  }),
8852
8942
  parseOptions: { controlFlow: true },
8853
8943
  autocomplete: [{
@@ -9009,6 +9099,8 @@ var style_default = {
9009
9099
  if (names) {
9010
9100
  analyzeDynamicStyle(tag, names);
9011
9101
  addSetupStatement(getOrCreateSection(tag));
9102
+ visit(tag, 32);
9103
+ writeTo(tag)`<style></style>`;
9012
9104
  }
9013
9105
  },
9014
9106
  translate: translateByTarget({
@@ -9075,7 +9167,7 @@ function translateHTML$1(tag) {
9075
9167
  if (dynamic) {
9076
9168
  const { binding } = dynamic;
9077
9169
  const section = getSection(tag);
9078
- writeTo(tag)`${callRuntime("_style_html", buildStyleDecls(node))}`;
9170
+ writeTo$1(tag)`${callRuntime("_style_html", buildStyleDecls(node))}`;
9079
9171
  markNode(tag, binding, getSerializeReason(section, binding));
9080
9172
  }
9081
9173
  emitStyleImport(tag);
@@ -9087,16 +9179,12 @@ function translateDOM$1(tag) {
9087
9179
  if (dynamic) {
9088
9180
  const { names, binding } = dynamic;
9089
9181
  const section = getSection(tag);
9090
- const write = writeTo(tag);
9091
9182
  const readEl = () => createScopeReadExpression(binding);
9092
- visit(tag, 32);
9093
- write`<style>`;
9094
9183
  addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(callRuntime("_style_shell", scopeIdentifier, getScopeAccessorLiteral(binding))), void 0, true);
9095
9184
  dynamicStyleValues(node).forEach((value, i) => {
9096
9185
  const valueRef = value.extra?.referencedBindings;
9097
9186
  addStatement("render", section, valueRef, _marko_compiler.types.expressionStatement(callRuntime("_style_rule_item", readEl(), _marko_compiler.types.stringLiteral(names[i]), value)), void 0, !valueRef);
9098
9187
  });
9099
- write`</style>`;
9100
9188
  }
9101
9189
  emitStyleImport(tag);
9102
9190
  tag.remove();
@@ -9181,7 +9269,6 @@ function getStyleImportPath(file, node, names) {
9181
9269
  }
9182
9270
  //#endregion
9183
9271
  //#region src/translator/core/try.ts
9184
- const hasEnabledCatch = /* @__PURE__ */ new WeakSet();
9185
9272
  const kDOMBinding$1 = Symbol("try tag dom binding");
9186
9273
  var try_default = {
9187
9274
  analyze(tag) {
@@ -9195,7 +9282,11 @@ var try_default = {
9195
9282
  tagExtra[kDOMBinding$1] = createBinding("#text", 0, section);
9196
9283
  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).");
9197
9284
  const bodySection = startSection(tag.get("body"));
9198
- if (bodySection) bodySection.upstreamExpression = tagExtra;
9285
+ if (bodySection) {
9286
+ bodySection.upstreamExpression = tagExtra;
9287
+ visit(tag, 37);
9288
+ enterShallow(tag);
9289
+ }
9199
9290
  },
9200
9291
  translate: translateByTarget({
9201
9292
  html: {
@@ -9229,8 +9320,6 @@ var try_default = {
9229
9320
  const bodySection = getSectionForBody(tag.get("body"));
9230
9321
  if (tag.node.extra?.attributeTags?.["@placeholder"]) setTryHasPlaceholder(bodySection, true);
9231
9322
  setSectionParentIsOwner(bodySection, true);
9232
- visit(tag, 37);
9233
- enterShallow(tag);
9234
9323
  },
9235
9324
  exit(tag) {
9236
9325
  const { node } = tag;
@@ -9244,14 +9333,10 @@ var try_default = {
9244
9333
  const bodySection = getSectionForBody(tag.get("body"));
9245
9334
  const signal = getSignal(section, nodeRef, "try");
9246
9335
  signal.build = () => {
9336
+ importRuntimeFeature("catch");
9247
9337
  return callRuntime("_try", getScopeAccessorLiteral(nodeRef, true), ...replaceNullishAndEmptyFunctionsWith0(getBranchRendererArgs(bodySection)));
9248
9338
  };
9249
9339
  if (translatedAttrs.statements.length) addStatement("render", section, referencedBindings, translatedAttrs.statements);
9250
- const program = (0, _marko_compiler_babel_utils.getProgram)().node;
9251
- if (!hasEnabledCatch.has(program)) {
9252
- hasEnabledCatch.add(program);
9253
- program.body.push(_marko_compiler.types.expressionStatement(callRuntime("_enable_catch")));
9254
- }
9255
9340
  addValue(section, referencedBindings, signal, propsToExpression(translatedAttrs.properties));
9256
9341
  tag.remove();
9257
9342
  }
@@ -9315,7 +9400,7 @@ var declaration_default = { translate: { enter(decl) {
9315
9400
  //#endregion
9316
9401
  //#region src/translator/visitors/document-type.ts
9317
9402
  var document_type_default = { translate: { exit(documentType) {
9318
- if (isOutputHTML()) writeTo(documentType)`<!${documentType.node.value}>`;
9403
+ if (isOutputHTML()) writeTo$1(documentType)`<!${documentType.node.value}>`;
9319
9404
  documentType.remove();
9320
9405
  } } };
9321
9406
  //#endregion
@@ -9370,6 +9455,7 @@ var import_declaration_default = {
9370
9455
  const { file } = importDecl.hub;
9371
9456
  const loadFile = (0, _marko_compiler_babel_utils.loadFileForImport)(file, node.source.value);
9372
9457
  const resolvedPath = (0, _marko_compiler_babel_utils.resolveRelativePath)(file, loadFile.opts.filename);
9458
+ importRuntimeFeature("catch");
9373
9459
  importDecl.replaceWith(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(local, callRuntime("_load_template", _marko_compiler.types.stringLiteral(loadFile.metadata.marko.id), _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.callExpression(_marko_compiler.types.memberExpression(_marko_compiler.types.callExpression(_marko_compiler.types.import(), [_marko_compiler.types.stringLiteral(resolvedPath)]), _marko_compiler.types.identifier("then")), [_marko_compiler.types.arrowFunctionExpression([_marko_compiler.types.identifier("mod")], toMemberExpression(_marko_compiler.types.identifier("mod"), "default"))]))))]));
9374
9460
  }
9375
9461
  return;
@@ -9486,65 +9572,78 @@ function isEmptyPlaceholder(placeholder) {
9486
9572
  //#region src/translator/visitors/placeholder.ts
9487
9573
  const kNodeBinding = Symbol("placeholder node binding");
9488
9574
  const kSiblingText = Symbol("placeholder has sibling text");
9489
- const kSharedText$1 = Symbol("placeholder will merge its visitor with a another node");
9490
9575
  var placeholder_default = {
9491
- analyze(placeholder) {
9492
- if (isNonHTMLText(placeholder)) return;
9493
- const { node } = placeholder;
9494
- const valueExtra = evaluate(node.value);
9495
- const { confident, computed } = valueExtra;
9496
- if (confident && isVoid(computed)) return;
9497
- if (isStaticText(node)) {
9498
- if (isStaticText(getPrevStaticSibling(placeholder))) (node.extra ??= {})[kSharedText$1] = true;
9499
- } else {
9500
- const section = getOrCreateSection(placeholder);
9501
- const nodeBinding = (node.extra ??= {})[kNodeBinding] = createBinding("#text", 0, section);
9502
- analyzeSiblingText(placeholder);
9503
- addSetupExpr(section, node.value);
9504
- addSerializeExpr(section, valueExtra, nodeBinding);
9505
- }
9506
- },
9507
- translate: { exit(placeholder) {
9508
- if (isNonHTMLText(placeholder)) return;
9509
- const { node } = placeholder;
9510
- const { value } = node;
9511
- if (node.extra?.[kRawText]) injectTextCoercion(value);
9512
- const valueExtra = evaluate(value);
9513
- const { confident, computed } = valueExtra;
9514
- if (confident && isVoid(computed)) {
9515
- placeholder.remove();
9516
- return;
9517
- }
9518
- const isHTML = isOutputHTML();
9519
- const write = writeTo(placeholder);
9520
- const extra = node.extra || {};
9521
- const nodeBinding = extra[kNodeBinding];
9522
- const canWriteHTML = isHTML || confident && node.escape;
9523
- const method = canWriteHTML ? node.escape ? "_escape" : "_unescaped" : node.escape ? "_text" : "_html";
9524
- if (confident && canWriteHTML) write`${getHTMLRuntime()[method](computed)}`;
9525
- else {
9526
- const section = getSection(placeholder);
9527
- const siblingText = extra[kSiblingText];
9528
- const markerSerializeReason = nodeBinding && getSerializeReason(section, nodeBinding);
9529
- if (siblingText === 1) {
9530
- if (isHTML && markerSerializeReason) writeSeparator(write, section, markerSerializeReason);
9531
- visit(placeholder, 37);
9532
- } else if (siblingText === 2) visit(placeholder, 37);
9576
+ analyze: {
9577
+ enter(placeholder) {
9578
+ if (isNonHTMLText(placeholder)) return;
9579
+ const { node } = placeholder;
9580
+ const valueExtra = evaluate(node.value);
9581
+ const { confident, computed } = valueExtra;
9582
+ if (confident && isVoid(computed)) return;
9583
+ if (!isStaticText(node)) {
9584
+ const section = getOrCreateSection(placeholder);
9585
+ const nodeBinding = (node.extra ??= {})[kNodeBinding] = createBinding("#text", 0, section);
9586
+ analyzeSiblingText(placeholder);
9587
+ addSetupExpr(section, node.value);
9588
+ addSerializeExpr(section, valueExtra, nodeBinding);
9589
+ }
9590
+ },
9591
+ exit(placeholder) {
9592
+ if (isNonHTMLText(placeholder)) return;
9593
+ const { node } = placeholder;
9594
+ const { confident, computed } = evaluate(node.value);
9595
+ if (confident && isVoid(computed)) return;
9596
+ const extra = node.extra || {};
9597
+ if (confident && node.escape) writeTo(placeholder)`${getHTMLRuntime()._escape(computed)}`;
9533
9598
  else {
9534
- if (isHTML) {
9535
- if (siblingText === 3 && markerSerializeReason) writeSeparator(write, section, markerSerializeReason);
9536
- } else write` `;
9537
- visit(placeholder, 32);
9599
+ const siblingText = extra[kSiblingText];
9600
+ if (siblingText === 1 || siblingText === 2) visit(placeholder, 37);
9601
+ else {
9602
+ writeTo(placeholder)` `;
9603
+ visit(placeholder, 32);
9604
+ }
9538
9605
  }
9539
- if (isHTML) {
9540
- write`${method === "_escape" ? buildEscapedTextExpression(value) : callRuntime(method, value)}`;
9541
- if (nodeBinding) markNode(placeholder, nodeBinding, markerSerializeReason);
9542
- } else addStatement("render", section, valueExtra.referencedBindings, _marko_compiler.types.expressionStatement(method === "_text" ? callRuntime("_text", createScopeReadExpression(nodeBinding), value) : callRuntime("_html", scopeIdentifier, value, getScopeAccessorLiteral(nodeBinding))), void 0, true);
9606
+ if (!isStaticText(node) || !isStaticText(getPrevStaticSibling(placeholder))) enterShallow(placeholder);
9543
9607
  }
9544
- if (!extra[kSharedText$1]) enterShallow(placeholder);
9545
- placeholder.remove();
9608
+ },
9609
+ translate: { exit(placeholder) {
9610
+ translateExit(placeholder);
9546
9611
  } }
9547
9612
  };
9613
+ function translateExit(placeholder) {
9614
+ if (isNonHTMLText(placeholder)) return;
9615
+ const { node } = placeholder;
9616
+ const { value } = node;
9617
+ if (node.extra?.[kRawText]) injectTextCoercion(value);
9618
+ const valueExtra = evaluate(value);
9619
+ const { confident, computed } = valueExtra;
9620
+ if (confident && isVoid(computed)) {
9621
+ placeholder.remove();
9622
+ return;
9623
+ }
9624
+ const isHTML = isOutputHTML();
9625
+ const write = writeTo$1(placeholder);
9626
+ const extra = node.extra || {};
9627
+ const nodeBinding = extra[kNodeBinding];
9628
+ const canWriteHTML = isHTML || confident && node.escape;
9629
+ const method = canWriteHTML ? node.escape ? "_escape" : "_unescaped" : node.escape ? "_text" : "_html";
9630
+ if (confident && canWriteHTML) {
9631
+ if (isHTML) write`${getHTMLRuntime()[method](computed)}`;
9632
+ } else {
9633
+ const section = getSection(placeholder);
9634
+ const siblingText = extra[kSiblingText];
9635
+ const markerSerializeReason = nodeBinding && getSerializeReason(section, nodeBinding);
9636
+ if (isHTML && markerSerializeReason) {
9637
+ if (siblingText === 1) writeSeparator(write, section, markerSerializeReason);
9638
+ else if (siblingText === 3) writeSeparator(write, section, markerSerializeReason);
9639
+ }
9640
+ if (isHTML) {
9641
+ write`${method === "_escape" ? buildEscapedTextExpression(value) : callRuntime(method, value)}`;
9642
+ if (nodeBinding) markNode(placeholder, nodeBinding, markerSerializeReason);
9643
+ } else addStatement("render", section, valueExtra.referencedBindings, _marko_compiler.types.expressionStatement(method === "_text" ? callRuntime("_text", createScopeReadExpression(nodeBinding), value) : callRuntime("_html", scopeIdentifier, value, getScopeAccessorLiteral(nodeBinding))), void 0, true);
9644
+ }
9645
+ placeholder.remove();
9646
+ }
9548
9647
  function buildEscapedTextExpression(value) {
9549
9648
  const { _escape } = getHTMLRuntime();
9550
9649
  switch (value.type) {
@@ -9745,6 +9844,17 @@ var custom_tag_default = {
9745
9844
  if (tagExtra.tagNameLoad) tagExtra[kLoadTagBinding] = createBinding("#text", 0, getOrCreateSection(tag));
9746
9845
  if (tagExtra.tagNameLoad || !childExtra.domExports?.setupEmpty) addSetupStatement(getOrCreateSection(tag));
9747
9846
  knownTagAnalyze(tag, childSection, programSection === childSection ? programSection.params && getBindingPropTree(programSection.params) : childExtra.domExports?.params);
9847
+ const tagName = getStaticTagName(tag.node);
9848
+ if (tagExtra.tagNameLoad) {
9849
+ visit(tag, 37);
9850
+ child(tag, tagName);
9851
+ enterShallow(tag);
9852
+ } else child(tag, tagName, {
9853
+ kind: ExportRef,
9854
+ program: childExtra,
9855
+ path: getTagRelativePath(tag),
9856
+ hint: tagName
9857
+ });
9748
9858
  } },
9749
9859
  translate: {
9750
9860
  enter(tag) {
@@ -9769,7 +9879,6 @@ function translateHTML(tag) {
9769
9879
  function translateDOM(tag) {
9770
9880
  const { node } = tag;
9771
9881
  const { file } = tag.hub;
9772
- const write = writeTo(tag);
9773
9882
  const relativePath = getTagRelativePath(tag);
9774
9883
  const programSection = (0, _marko_compiler_babel_utils.getProgram)().node.extra.section;
9775
9884
  const childFile = (0, _marko_compiler_babel_utils.loadFileForTag)(tag);
@@ -9778,7 +9887,7 @@ function translateDOM(tag) {
9778
9887
  const childSection = childExtra.section;
9779
9888
  const loadConfig = node.extra?.tagNameLoad;
9780
9889
  const isLoad = !!loadConfig;
9781
- const tagName = _marko_compiler.types.isIdentifier(node.name) ? node.name.name : _marko_compiler.types.isStringLiteral(node.name) ? node.name.value : "tag";
9890
+ const tagName = getStaticTagName(node);
9782
9891
  if (isLoad) {
9783
9892
  const childFileName = childFile.opts.filename;
9784
9893
  const { triggers, signals } = getLoadIdentifiers();
@@ -9804,24 +9913,19 @@ function translateDOM(tag) {
9804
9913
  }, (section, childBinding) => {
9805
9914
  const setupIdent = generateUidIdentifier(`load_${tagName}_setup`);
9806
9915
  const setupLoadExpr = _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.callExpression(_marko_compiler.types.import(), [_marko_compiler.types.stringLiteral(buildLoadSetupVirtualModule(file, childFileName, childExports))]));
9916
+ importRuntimeFeature("catch");
9807
9917
  (0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.variableDeclaration("let", [_marko_compiler.types.variableDeclarator(setupIdent, callRuntime("_load_setup", getScopeAccessorLiteral(node.extra[kLoadTagBinding], true), getScopeAccessorLiteral(childBinding, true), triggerIdent ? _marko_compiler.types.addComment(_marko_compiler.types.callExpression(triggerIdent, [setupLoadExpr]), "leading", "@__PURE__") : setupLoadExpr))]));
9808
9918
  addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(setupIdent, [scopeIdentifier])));
9809
9919
  });
9810
- visit(tag, 37);
9811
- injectWalks(tag, tagName);
9812
- enterShallow(tag);
9813
- } else if (programSection === childSection) {
9814
- knownTagTranslateDOM(tag, childExports.params, (binding, preferredName) => getSignal(programSection, binding, preferredName).identifier, childExports.setupEmpty ? void 0 : (section, childBinding) => {
9815
- addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier(childExports.setup), [createScopeReadExpression(childBinding, section)])));
9816
- });
9817
- write`${_marko_compiler.types.identifier(childExports.template)}`;
9818
- injectWalks(tag, tagName, _marko_compiler.types.identifier(childExports.walks));
9819
- } else {
9920
+ } else if (programSection === childSection) knownTagTranslateDOM(tag, childExports.params, (binding, preferredName) => getSignal(programSection, binding, preferredName).identifier, childExports.setupEmpty ? void 0 : (section, childBinding) => {
9921
+ addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier(childExports.setup), [createScopeReadExpression(childBinding, section)])));
9922
+ });
9923
+ else {
9820
9924
  knownTagTranslateDOM(tag, childExports.params, (binding, preferredName, directContent) => importOrSelfReferenceName(tag.hub.file, relativePath, directContent && binding.directContentExport || binding.export, preferredName), childExports.setupEmpty ? void 0 : (section, childBinding) => {
9821
9925
  addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(importOrSelfReferenceName(file, relativePath, childExports.setup, tagName), [createScopeReadExpression(childBinding, section)])));
9822
9926
  });
9823
- write`${(0, _marko_compiler_babel_utils.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
9824
- injectWalks(tag, tagName, (0, _marko_compiler_babel_utils.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`));
9927
+ (0, _marko_compiler_babel_utils.importNamed)(file, relativePath, childExports.template, `${tagName}_template`);
9928
+ (0, _marko_compiler_babel_utils.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`);
9825
9929
  }
9826
9930
  tag.remove();
9827
9931
  }
@@ -9876,14 +9980,6 @@ function collectProseWords(node, tagName) {
9876
9980
  }
9877
9981
  return text;
9878
9982
  }
9879
- function importOrSelfReferenceName(file, request, name, nameHint) {
9880
- if (isCircularRequest(file, request)) return _marko_compiler.types.identifier(name);
9881
- return (0, _marko_compiler_babel_utils.importNamed)(file, request, name, nameHint);
9882
- }
9883
- function isCircularRequest(file, request) {
9884
- const { filename } = file.opts;
9885
- return request === filename || request[0] === "." && path.default.resolve(filename, "..", request) === filename;
9886
- }
9887
9983
  function buildLoadSetupVirtualModule(file, childFileName, childExports) {
9888
9984
  const parts = `${childExports.template}, ${childExports.walks}, ${childExports.setup}`;
9889
9985
  return getMarkoOpts().resolveVirtualDependency(file.opts.filename, {
@@ -9935,6 +10031,10 @@ var dynamic_tag_default = {
9935
10031
  const definedBodySection = node.extra?.defineBodySection;
9936
10032
  if (definedBodySection) {
9937
10033
  knownTagAnalyze(tag, definedBodySection, definedBodySection.params && getBindingPropTree(definedBodySection.params));
10034
+ child(tag, getStaticTagName(tag.node), {
10035
+ kind: SectionRef,
10036
+ section: definedBodySection
10037
+ });
9938
10038
  return;
9939
10039
  }
9940
10040
  analyzeAttributeTags(tag);
@@ -9948,24 +10048,21 @@ var dynamic_tag_default = {
9948
10048
  trackVarReferences(tag, 5);
9949
10049
  tag.node.var.extra.binding.scopeOffset = tagExtra[kChildOffsetScopeBinding] = createBinding("#scopeOffset", 0, tagSection);
9950
10050
  }
9951
- startSection(tagBody);
10051
+ const bodySection = startSection(tagBody);
9952
10052
  trackParamsReferences(tagBody, 3);
9953
10053
  addSerializeExpr(tagSection, hasVar || tagExtra, nodeBinding);
9954
10054
  if (!hasVar && !node.arguments && !node.attributes.length && !node.body.body.length) tagExtra[kDirectContent] = true;
10055
+ if (tagExtra.featureType !== "class" || (0, _marko_compiler_babel_utils.getTagTemplate)(tag)) {
10056
+ visit(tag, hasVar ? 49 : 37);
10057
+ enterShallow(tag);
10058
+ } else if (bodySection) bodySection.structure = null;
9955
10059
  } },
9956
10060
  translate: {
9957
10061
  enter(tag) {
9958
- const tagExtra = tag.node.extra;
9959
- if (tagExtra?.featureType === "class" && !isOutputHTML() && !(0, _marko_compiler_babel_utils.getTagTemplate)(tag)) {
10062
+ if (tag.node.extra?.featureType === "class" && !isOutputHTML() && !(0, _marko_compiler_babel_utils.getTagTemplate)(tag)) {
9960
10063
  tag.remove();
9961
10064
  return;
9962
10065
  }
9963
- if (tagExtra?.defineBodySection) {
9964
- if (isOutputHTML()) flushBefore(tag);
9965
- return;
9966
- }
9967
- visit(tag, tag.node.var ? 49 : 37);
9968
- enterShallow(tag);
9969
10066
  if (isOutputHTML()) flushBefore(tag);
9970
10067
  },
9971
10068
  exit(tag) {
@@ -9977,14 +10074,11 @@ var dynamic_tag_default = {
9977
10074
  const propTree = paramsBinding && getBindingPropTree(paramsBinding);
9978
10075
  if (isOutputHTML()) knownTagTranslateHTML(tag, _marko_compiler.types.memberExpression(tag.node.name, _marko_compiler.types.identifier("content")), definedBodySection, propTree);
9979
10076
  else {
9980
- const write = writeTo(tag);
9981
10077
  knownTagTranslateDOM(tag, propTree, (binding, preferredName, directContent) => directContent && binding.directContentExport ? _marko_compiler.types.identifier(binding.directContentExport) : getSignal(definedBodySection, binding, preferredName).identifier, (section, childBinding) => {
9982
10078
  const signal = getSignal(definedBodySection, void 0);
9983
10079
  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)])));
9984
10080
  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))));
9985
10081
  });
9986
- write`${() => getSectionMetaIdentifiers(definedBodySection).writes || ""}`;
9987
- injectWalks(tag, tag.get("name").toString(), () => getSectionMetaIdentifiers(definedBodySection).walks);
9988
10082
  tag.remove();
9989
10083
  }
9990
10084
  return;
@@ -10088,7 +10182,7 @@ const controlledAttrs = /^(?:value|checked(?:Value)?|open)(?:Change)?$/;
10088
10182
  function enableDynamicTagControllables(tag) {
10089
10183
  if (analyzeTagNameType(tag, true) === 1) return;
10090
10184
  for (const attr of tag.node.attributes) if (attr.type === "MarkoSpreadAttribute" || attr.type === "MarkoAttribute" && controlledAttrs.test(attr.name)) {
10091
- enableControllable(controllableScriptLatchFor(void 0));
10185
+ enableControllable(controllableFeatureFor(void 0));
10092
10186
  return;
10093
10187
  }
10094
10188
  }
@@ -10144,6 +10238,7 @@ var tag_default = {
10144
10238
  exit$1(hook, tag);
10145
10239
  return;
10146
10240
  }
10241
+ if (analyzeTagNameType(tag) === 0) native_tag_default.analyze.exit(tag);
10147
10242
  } catch (err) {
10148
10243
  (tag.node.extra ??= {}).analyzeFailed = true;
10149
10244
  reportAnalyzeError(tag, err);
@@ -10202,16 +10297,15 @@ var tag_default = {
10202
10297
  };
10203
10298
  //#endregion
10204
10299
  //#region src/translator/visitors/text.ts
10205
- const kSharedText = Symbol("text merges its walk step with a sibling node");
10206
10300
  var text_default = {
10207
- analyze(text) {
10301
+ analyze: { exit(text) {
10208
10302
  if (isNonHTMLText(text)) return;
10209
- if (isStaticText(getPrevStaticSibling(text))) (text.node.extra ??= {})[kSharedText] = true;
10210
- },
10303
+ writeTo(text)`${text.node.value}`;
10304
+ if (!isStaticText(getPrevStaticSibling(text))) enterShallow(text);
10305
+ } },
10211
10306
  translate: { exit(text) {
10212
10307
  if (isNonHTMLText(text)) return;
10213
- writeTo(text)`${text.node.value}`;
10214
- if (!text.node.extra?.[kSharedText]) enterShallow(text);
10308
+ if (isOutputHTML()) writeTo$1(text)`${text.node.value}`;
10215
10309
  text.remove();
10216
10310
  } }
10217
10311
  };
@@ -10220,7 +10314,7 @@ var text_default = {
10220
10314
  function buildAggregateError(file, rootMsg, ...paths) {
10221
10315
  const err = /* @__PURE__ */ new SyntaxError();
10222
10316
  const fileName = path.default.relative(_marko_compiler_modules.cwd, file.opts.filename);
10223
- const finalMsg = `${rootMsg}:\n\n${paths.map(([msg, path$13]) => `\x1b[90m${msg} at ${getFileNameWithLoc(fileName, path$13)}:\x1b[0m\n${getFrame(file, path$13)}`).join("\n\n")}`;
10317
+ const finalMsg = `${rootMsg}:\n\n${paths.map(([msg, path$14]) => `\x1b[90m${msg} at ${getFileNameWithLoc(fileName, path$14)}:\x1b[0m\n${getFrame(file, path$14)}`).join("\n\n")}`;
10224
10318
  if (!("MARKO_DEBUG" in process.env)) err.stack = finalMsg;
10225
10319
  Object.defineProperty(err, "message", {
10226
10320
  get() {
@@ -10450,13 +10544,13 @@ function mergeVisitors(visitor5, visitor6) {
10450
10544
  function mergeVisit(visit5, visit6) {
10451
10545
  const enter5 = getVisitorEnter(visit5);
10452
10546
  const enter6 = getVisitorEnter(visit6);
10453
- const enter = (enter5 || enter6) && function enter(path$9, state) {
10454
- return (isTagsAPI() ? enter6 : enter5)?.call(this, path$9, state);
10547
+ const enter = (enter5 || enter6) && function enter(path$10, state) {
10548
+ return (isTagsAPI() ? enter6 : enter5)?.call(this, path$10, state);
10455
10549
  };
10456
10550
  const exit5 = getVisitorExit(visit5);
10457
10551
  const exit6 = getVisitorExit(visit6);
10458
- const exit = (exit5 || exit6) && function exit(path$10, state) {
10459
- return (isTagsAPI() ? exit6 : exit5)?.call(this, path$10, state);
10552
+ const exit = (exit5 || exit6) && function exit(path$11, state) {
10553
+ return (isTagsAPI() ? exit6 : exit5)?.call(this, path$11, state);
10460
10554
  };
10461
10555
  return exit ? enter ? {
10462
10556
  enter,
@@ -10539,17 +10633,17 @@ function sequenceVisit(first, second) {
10539
10633
  if (!first || !second) return first || second;
10540
10634
  const enterFirst = getVisitorEnter(first);
10541
10635
  const enterSecond = getVisitorEnter(second);
10542
- const enter = (enterFirst || enterSecond) && function enter(path$11, state) {
10543
- const { node } = path$11;
10544
- enterFirst?.call(this, path$11, state);
10545
- if (path$11.node === node) enterSecond?.call(this, path$11, state);
10636
+ const enter = (enterFirst || enterSecond) && function enter(path$12, state) {
10637
+ const { node } = path$12;
10638
+ enterFirst?.call(this, path$12, state);
10639
+ if (path$12.node === node) enterSecond?.call(this, path$12, state);
10546
10640
  };
10547
10641
  const exitFirst = getVisitorExit(first);
10548
10642
  const exitSecond = getVisitorExit(second);
10549
- const exit = (exitFirst || exitSecond) && function exit(path$12, state) {
10550
- const { node } = path$12;
10551
- exitFirst?.call(this, path$12, state);
10552
- if (path$12.node === node) exitSecond?.call(this, path$12, state);
10643
+ const exit = (exitFirst || exitSecond) && function exit(path$13, state) {
10644
+ const { node } = path$13;
10645
+ exitFirst?.call(this, path$13, state);
10646
+ if (path$13.node === node) exitSecond?.call(this, path$13, state);
10553
10647
  };
10554
10648
  return exit ? enter ? {
10555
10649
  enter,