marko 6.3.31 → 6.3.33

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 (67) hide show
  1. package/cheatsheet.md +39 -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 -2250
  18. package/dist/debug/dom.mjs +6 -2094
  19. package/dist/debug/html.js +35 -7
  20. package/dist/debug/html.mjs +36 -5
  21. package/dist/dom/catch.feat.d.ts +1 -0
  22. package/dist/dom/catch.feat.js +25 -0
  23. package/dist/dom/catch.feat.mjs +26 -0
  24. package/dist/dom/control-flow.d.ts +3 -3
  25. package/dist/dom/controllable-input.feat.d.ts +1 -0
  26. package/dist/dom/controllable-input.feat.js +3 -0
  27. package/dist/dom/controllable-input.feat.mjs +3 -0
  28. package/dist/dom/controllable-open.feat.d.ts +1 -0
  29. package/dist/dom/controllable-open.feat.js +4 -0
  30. package/dist/dom/controllable-open.feat.mjs +4 -0
  31. package/dist/dom/controllable-select.feat.d.ts +1 -0
  32. package/dist/dom/controllable-select.feat.js +4 -0
  33. package/dist/dom/controllable-select.feat.mjs +4 -0
  34. package/dist/dom/controllable-textarea.feat.d.ts +1 -0
  35. package/dist/dom/controllable-textarea.feat.js +4 -0
  36. package/dist/dom/controllable-textarea.feat.mjs +4 -0
  37. package/dist/dom/controllable.d.ts +3 -8
  38. package/dist/dom/controllable.feat.d.ts +3 -0
  39. package/dist/dom/controllable.feat.js +3 -0
  40. package/dist/dom/controllable.feat.mjs +6 -0
  41. package/dist/dom/queue.d.ts +2 -2
  42. package/dist/dom/resume.d.ts +0 -1
  43. package/dist/dom-CI-06TZb.js +1721 -0
  44. package/dist/dom-Cj4HQ7T_.mjs +1137 -0
  45. package/dist/dom.d.ts +2 -2
  46. package/dist/dom.js +36 -1224
  47. package/dist/dom.mjs +4 -1191
  48. package/dist/html/compat.d.ts +3 -1
  49. package/dist/html/writer.d.ts +3 -0
  50. package/dist/html.d.ts +1 -1
  51. package/dist/html.js +31 -11
  52. package/dist/html.mjs +31 -11
  53. package/dist/translator/index.js +680 -583
  54. package/dist/translator/util/branch-tag.d.ts +5 -0
  55. package/dist/translator/util/constants/structure-kind.d.ts +7 -0
  56. package/dist/translator/util/get-tag-name.d.ts +2 -1
  57. package/dist/translator/util/import-reference.d.ts +3 -0
  58. package/dist/translator/util/runtime.d.ts +2 -0
  59. package/dist/translator/util/sections.d.ts +28 -1
  60. package/dist/translator/util/signals.d.ts +1 -3
  61. package/dist/translator/util/{walks.d.ts → structure.d.ts} +20 -9
  62. package/dist/translator/util/writer.d.ts +0 -8
  63. package/dist/translator/visitors/placeholder.d.ts +4 -3
  64. package/dist/translator/visitors/tag/native-tag.d.ts +9 -6
  65. package/dist/translator/visitors/text.d.ts +3 -7
  66. package/index.d.ts +19 -1
  67. package/package.json +4 -4
@@ -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
  }
@@ -1966,6 +1976,14 @@ function _resume_branch(scopeId) {
1966
1976
  const branchId = $chunk.context?.[kBranchId];
1967
1977
  if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { [ClosestBranchId$1]: branchId });
1968
1978
  }
1979
+ function deferBranchStart(chunk) {
1980
+ const beforeBranch = chunk.html;
1981
+ chunk.html = "";
1982
+ return beforeBranch;
1983
+ }
1984
+ function applyBranchStart(chunk, beforeBranch, rendered) {
1985
+ chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
1986
+ }
1969
1987
  let writeScope = (scopeId, partialScope) => {
1970
1988
  const { state } = $chunk.boundary;
1971
1989
  const target = $chunk.serializeState;
@@ -2186,7 +2204,8 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2186
2204
  };
2187
2205
  renderNative();
2188
2206
  } else {
2189
- if (shouldResume) _html(state.mark("[", ""));
2207
+ const chunk = void 0;
2208
+ const beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0;
2190
2209
  const render = () => {
2191
2210
  if (renderer) try {
2192
2211
  _set_serialize_reason(shouldResume && inputOrArgs !== void 0 ? 1 : 0);
@@ -2201,7 +2220,10 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2201
2220
  };
2202
2221
  result = shouldResume ? withBranchId(branchId, render) : render();
2203
2222
  rendered = _peek_scope_id() !== branchId;
2204
- if (shouldResume) _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
2223
+ if (beforeBranch !== void 0) {
2224
+ applyBranchStart(chunk, beforeBranch, rendered);
2225
+ _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
2226
+ }
2205
2227
  }
2206
2228
  if (rendered) {
2207
2229
  if (shouldResume) writeScope(scopeId, { [ConditionalRenderer$1 + accessor]: renderer?.["id"] || renderer });
@@ -2262,6 +2284,17 @@ function callRuntime(name, ...args) {
2262
2284
  if (isOutputDOM() && pureDOMFunctions.has(name)) return _marko_compiler.types.addComment(callExpression, "leading", "@__PURE__");
2263
2285
  return callExpression;
2264
2286
  }
2287
+ const importedFeatures = /* @__PURE__ */ new WeakMap();
2288
+ function importRuntimeFeature(feature) {
2289
+ if (!isTranslate()) throw new Error(`\`importRuntimeFeature(${JSON.stringify(feature)})\` may only be called during the translate stage.`);
2290
+ const program = (0, _marko_compiler_babel_utils.getProgram)().node;
2291
+ let features = importedFeatures.get(program);
2292
+ if (!features) importedFeatures.set(program, features = /* @__PURE__ */ new Set());
2293
+ if (!features.has(feature)) {
2294
+ features.add(feature);
2295
+ program.body.push(_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(`${getRuntimePath("dom")}/${feature}.feat`)));
2296
+ }
2297
+ }
2265
2298
  function getHTMLRuntime() {
2266
2299
  return {
2267
2300
  _escape,
@@ -2599,137 +2632,10 @@ function createTypeState() {
2599
2632
  };
2600
2633
  }
2601
2634
  //#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
2635
  //#region src/translator/util/writer.ts
2730
2636
  const [getWrites] = createSectionState("writes", () => [""]);
2731
2637
  const [getTrailerWrites] = createSectionState("trailerWrites", () => [""]);
2732
- function writeTo(path, trailer) {
2638
+ function writeTo$1(path, trailer) {
2733
2639
  const section = getSection(path);
2734
2640
  const get = trailer ? getTrailerWrites : getWrites;
2735
2641
  return (strs, ...exprs) => {
@@ -2762,45 +2668,12 @@ function flushInto(path) {
2762
2668
  const expr = consumeHTML(target);
2763
2669
  if (expr) target.node.body.push(expr);
2764
2670
  }
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
2671
  function markNode(path, nodeBinding, reason, deferred) {
2799
2672
  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
2673
  if (isOutputHTML()) {
2801
2674
  if (reason) {
2802
2675
  const section = getSection(path);
2803
- writeTo(path, deferred)`${callRuntime("_el_resume", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeBinding), getSerializeGuard(section, reason, true))}`;
2676
+ writeTo$1(path, deferred)`${callRuntime("_el_resume", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeBinding), getSerializeGuard(section, reason, true))}`;
2804
2677
  }
2805
2678
  }
2806
2679
  }
@@ -3126,9 +2999,7 @@ function getSignal(section, referencedBindings, name) {
3126
2999
  values: [],
3127
3000
  intersection: void 0,
3128
3001
  render: [],
3129
- renderReferencedBindings: void 0,
3130
3002
  effect: [],
3131
- effectReferencedBindings: void 0,
3132
3003
  hasHTMLEffect: false,
3133
3004
  build: void 0,
3134
3005
  export: !!exportName,
@@ -3367,25 +3238,15 @@ function replaceNullishAndEmptyFunctionsWith0(args) {
3367
3238
  args.length = finalLen || 0;
3368
3239
  return args;
3369
3240
  }
3370
- function addStatement(type, targetSection, referencedBindings, statement, usedReferences, isPure) {
3241
+ function addStatement(type, targetSection, referencedBindings, statement, isPure) {
3371
3242
  const signal = getSignal(targetSection, referencedBindings);
3372
3243
  const statements = signal[type] ??= [];
3373
- const add = type === "effect" ? addEffectReferences : addRenderReferences;
3374
3244
  if (Array.isArray(statement)) statements.push(...statement);
3375
3245
  else statements.push(statement);
3376
- if (usedReferences !== false) if (usedReferences) for (const ref of usedReferences) add(signal, ref);
3377
- else add(signal, referencedBindings);
3378
3246
  if (!isPure || type === "effect") signal.hasSideEffect = true;
3379
3247
  }
3380
- function addEffectReferences(signal, referencedBindings) {
3381
- signal.effectReferencedBindings = bindingUtil.union(signal.effectReferencedBindings, referencedBindings);
3382
- }
3383
- function addRenderReferences(signal, referencedBindings) {
3384
- signal.renderReferencedBindings = bindingUtil.union(signal.renderReferencedBindings, referencedBindings);
3385
- }
3386
3248
  function addValue(targetSection, referencedBindings, signal, value) {
3387
3249
  const parentSignal = getSignal(targetSection, referencedBindings);
3388
- addRenderReferences(parentSignal, referencedBindings);
3389
3250
  parentSignal.values.push({
3390
3251
  signal,
3391
3252
  value
@@ -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) {
@@ -4022,6 +4093,22 @@ function templateElement(value, tail) {
4022
4093
  }, tail);
4023
4094
  }
4024
4095
  //#endregion
4096
+ //#region src/translator/util/branch-tag.ts
4097
+ function getBranchSectionAccessor(nodeBinding) {
4098
+ return {
4099
+ binding: nodeBinding,
4100
+ prefix: getAccessorPrefix().BranchScopes
4101
+ };
4102
+ }
4103
+ function initBranchSection(bodySection, upstreamExpression, sectionAccessor) {
4104
+ bodySection.isBranch = true;
4105
+ bodySection.upstreamExpression = upstreamExpression;
4106
+ bodySection.sectionAccessor = sectionAccessor;
4107
+ }
4108
+ function resumeOwnerByMarkerWhenStatic(tagSection, bodySection, nodeBinding, statefulReasonKey) {
4109
+ if (isStateSerializeReason(getSerializeReason(tagSection, statefulReasonKey)) && isStaticSerializeReason(getSerializeReason(bodySection, kBranchSerializeReason)) && isStaticSerializeReason(getSerializeReason(tagSection, nodeBinding))) setSectionOwnerResumedByMarker(bodySection);
4110
+ }
4111
+ //#endregion
4025
4112
  //#region src/translator/util/is-event-or-change-handler.ts
4026
4113
  function isEventOrChangeHandler(prop) {
4027
4114
  return /^on[-A-Z][a-zA-Z0-9_$]|[a-zA-Z_$][a-zA-Z0-9_$]*Change$/.test(prop);
@@ -4109,12 +4196,11 @@ var for_default = {
4109
4196
  onFinalizeReferences(() => detectForSelector(bodySection, keyBinding));
4110
4197
  }
4111
4198
  }
4112
- bodySection.sectionAccessor = {
4113
- binding: nodeBinding,
4114
- prefix: getAccessorPrefix().BranchScopes
4115
- };
4116
- bodySection.upstreamExpression = tagExtra;
4117
- bodySection.isBranch = true;
4199
+ initBranchSection(bodySection, tagExtra, getBranchSectionAccessor(nodeBinding));
4200
+ if (!isAttrTag && !getOnlyChildParentTagName(tag)) {
4201
+ visit(tag, 37);
4202
+ enterShallow(tag);
4203
+ }
4118
4204
  },
4119
4205
  translate: translateByTarget({
4120
4206
  html: {
@@ -4126,10 +4212,6 @@ var for_default = {
4126
4212
  return;
4127
4213
  }
4128
4214
  setSectionParentIsOwner(bodySection, true);
4129
- if (!getOnlyChildParentTagName(tag)) {
4130
- visit(tag, 37);
4131
- enterShallow(tag);
4132
- }
4133
4215
  flushBefore(tag);
4134
4216
  },
4135
4217
  exit(tag) {
@@ -4148,7 +4230,7 @@ var for_default = {
4148
4230
  const singleChild = bodySection.content?.singleChild && bodySection.content.startType !== 4;
4149
4231
  const branchSerializeReason = getSerializeReason(bodySection, kBranchSerializeReason);
4150
4232
  const markerSerializeReason = getSerializeReason(tagSection, nodeBinding);
4151
- if (isStateSerializeReason(getSerializeReason(tagSection, kStatefulReason$2)) && isStaticSerializeReason(branchSerializeReason) && isStaticSerializeReason(markerSerializeReason)) setSectionOwnerResumedByMarker(bodySection);
4233
+ resumeOwnerByMarkerWhenStatic(tagSection, bodySection, nodeBinding, kStatefulReason$2);
4152
4234
  flushInto(tag);
4153
4235
  writeHTMLResumeStatements(tagBody);
4154
4236
  const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
@@ -4181,10 +4263,6 @@ var for_default = {
4181
4263
  return;
4182
4264
  }
4183
4265
  setSectionParentIsOwner(bodySection, true);
4184
- if (!getOnlyChildParentTagName(tag)) {
4185
- visit(tag, 37);
4186
- enterShallow(tag);
4187
- }
4188
4266
  },
4189
4267
  exit(tag) {
4190
4268
  if (tag.node.body.attributeTags) return;
@@ -4602,132 +4680,179 @@ function buildContent(body) {
4602
4680
  const kNativeTagBinding = Symbol("native tag binding");
4603
4681
  const kSkipEndTag = Symbol("skip native tag mark");
4604
4682
  const kTagContentAttr = Symbol("tag could have dynamic content attribute");
4683
+ const kVisitOp = Symbol("native tag structure visit");
4605
4684
  const htmlSelectArgs = /* @__PURE__ */ new WeakMap();
4606
4685
  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;
4686
+ analyze: {
4687
+ enter(tag) {
4688
+ (0, _marko_compiler_babel_utils.assertNoArgs)(tag);
4689
+ (0, _marko_compiler_babel_utils.assertNoParams)(tag);
4690
+ (0, _marko_compiler_babel_utils.assertNoAttributeTags)(tag);
4691
+ const { node } = tag;
4692
+ 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.");
4693
+ const tagName = getCanonicalTagName(tag);
4694
+ switch (tagName) {
4695
+ case "html":
4696
+ case "body":
4697
+ case "head":
4698
+ (0, _marko_compiler_babel_utils.getProgram)().node.extra.page ??= true;
4699
+ break;
4636
4700
  }
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
- });
4701
+ if (tagName === "option") assertOptionInSelectWithValue(tag);
4702
+ const isTextOnly = isTextOnlyNativeTag(tag);
4703
+ const seen = Object.create(null);
4704
+ const { attributes } = tag.node;
4705
+ let injectNonce = isInjectNonceTag(tagName);
4706
+ let hasDynamicAttributes = false;
4707
+ let hasEventHandlers = false;
4708
+ let relatedControllable;
4709
+ let spreadReferenceNodes;
4710
+ let exprExtras;
4711
+ for (let i = attributes.length; i--;) {
4712
+ const attr = attributes[i];
4713
+ if (_marko_compiler.types.isMarkoAttribute(attr) && attr.name === "content" && tag.node.body.body.length) {
4644
4714
  dropNodes(attr.value);
4645
4715
  continue;
4646
4716
  }
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)) {
4717
+ const valueExtra = attr.value.extra ??= {};
4718
+ if (_marko_compiler.types.isMarkoAttribute(attr)) {
4719
+ if (seen[attr.name]) {
4720
+ (0, _marko_compiler_babel_utils.diagnosticWarn)(tag, {
4721
+ label: `The \`${attr.name}\` attribute is set more than once on \`<${tagName}>\`; only the last value is used.`,
4722
+ loc: attr.loc ?? void 0
4723
+ });
4724
+ dropNodes(attr.value);
4725
+ continue;
4726
+ }
4727
+ seen[attr.name] = attr;
4728
+ assertValidNativeAttrName(tag, attr);
4729
+ assertNativeAttrValueType(tag, attr);
4730
+ if (attr.name === "style") warnCamelCaseStyleKeys(tag, attr);
4731
+ if (injectNonce && attr.name === "nonce") injectNonce = false;
4732
+ if (isEventOrChangeHandler(attr.name)) assertNativeHandlerAttr(tag, attr);
4733
+ if (isEventHandler(attr.name)) {
4734
+ valueExtra.isEffect = true;
4735
+ valueExtra.invokeOnly = true;
4736
+ hasEventHandlers = true;
4737
+ } else {
4738
+ assertValidNativeEventHandlerAttr(tag, attr);
4739
+ if (!evaluate(attr.value).confident) hasDynamicAttributes = true;
4740
+ }
4741
+ } else if (_marko_compiler.types.isMarkoSpreadAttribute(attr)) {
4654
4742
  valueExtra.isEffect = true;
4655
- valueExtra.invokeOnly = true;
4656
4743
  hasEventHandlers = true;
4657
- } else {
4658
- assertValidNativeEventHandlerAttr(tag, attr);
4659
- if (!evaluate(attr.value).confident) hasDynamicAttributes = true;
4660
- }
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;
4744
+ hasDynamicAttributes = true;
4697
4745
  }
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);
4746
+ if (spreadReferenceNodes) spreadReferenceNodes.push(attr.value);
4747
+ else if (_marko_compiler.types.isMarkoSpreadAttribute(attr)) {
4748
+ spreadReferenceNodes = [attr.value];
4749
+ relatedControllable = getRelatedControllable(tagName, seen);
4750
+ } else exprExtras = push(exprExtras, valueExtra);
4751
+ }
4752
+ assertExclusiveAttrs(seen, (msg) => {
4753
+ throw tag.get("name").buildCodeFrameError(msg);
4754
+ });
4755
+ if (seen.content) {
4756
+ const tagDef = (0, _marko_compiler_babel_utils.getTagDef)(tag);
4757
+ 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.`);
4758
+ 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.`);
4759
+ }
4760
+ let textPlaceholders;
4761
+ if (isTextOnly) {
4762
+ for (const child of tag.node.body.body) if (_marko_compiler.types.isMarkoPlaceholder(child)) (textPlaceholders ||= []).push(child.value);
4763
+ else if (!_marko_compiler.types.isMarkoText(child)) throw tag.hub.buildError(child, `Only text is allowed inside a \`<${tagName}>\`.`);
4764
+ }
4765
+ relatedControllable ||= getRelatedControllable(tagName, seen);
4766
+ if (relatedControllable && relatedControllable.attrs[1]) hasEventHandlers = true;
4767
+ if (node.var || hasDynamicAttributes || hasEventHandlers || textPlaceholders || injectNonce || isDynamicControllable(relatedControllable)) {
4768
+ const tagExtra = node.extra ??= {};
4769
+ const tagSection = getOrCreateSection(tag);
4770
+ const nodeBinding = tagExtra[kNativeTagBinding] = createBinding("#" + tagName.toLowerCase(), 0, tagSection, void 0, void 0, void 0, void 0, !!node.var);
4771
+ if (hasEventHandlers) (0, _marko_compiler_babel_utils.getProgram)().node.extra.isInteractive = true;
4772
+ if (spreadReferenceNodes) {
4773
+ const isMergedSpread = !!relatedControllable;
4774
+ if (relatedControllable && !relatedControllable.attrs.every(Boolean)) {
4775
+ for (const attr of relatedControllable.attrs) if (attr) spreadReferenceNodes.push(attr.value);
4776
+ relatedControllable = void 0;
4777
+ }
4778
+ const spreadExtra = mergeReferences(tagSection, tag.node, spreadReferenceNodes);
4779
+ spreadExtra.nativeTagSpread = true;
4780
+ spreadExtra.invokeOnly = true;
4781
+ if (isMergedSpread) spreadExtra.nativeTagSpreadMerged = true;
4782
+ let carveProperties = getSpreadControllableValueProps(tagName);
4783
+ if (!tag.node.body.body.length && !isTextOnly && !(0, _marko_compiler_babel_utils.getTagDef)(tag)?.parseOptions?.openTagOnly && !seen.content) if (carveProperties) carveProperties.push("content");
4784
+ else carveProperties = ["content"];
4785
+ for (const node of spreadReferenceNodes) {
4786
+ const spreadBinding = node.extra?.spreadFrom;
4787
+ if (spreadBinding) {
4788
+ spreadBinding.noSerialize = true;
4789
+ if (carveProperties) {
4790
+ for (const property of carveProperties) if (!includes(spreadBinding.noSerializeProperties, property)) spreadBinding.noSerializeProperties = push(spreadBinding.noSerializeProperties, property);
4791
+ }
4711
4792
  }
4712
4793
  }
4713
4794
  }
4795
+ if (relatedControllable) mergeReferences(tagSection, relatedControllable.attrs.find(Boolean).value, relatedControllable.attrs.map((it) => it?.value));
4796
+ if (textPlaceholders) {
4797
+ exprExtras = push(exprExtras, textPlaceholders.length === 1 ? textPlaceholders[0].extra ??= {} : mergeReferences(tagSection, textPlaceholders[0], textPlaceholders.slice(1)));
4798
+ addSetupExpr(tagSection, textPlaceholders[0]);
4799
+ }
4800
+ if (injectNonce) addSetupStatement(tagSection);
4801
+ if (relatedControllable?.attrs[1]) addSetupStatement(tagSection);
4802
+ for (const name in seen) {
4803
+ const attr = seen[name];
4804
+ if (isEventHandler(name) || name === "content" || !evaluate(attr.value).confident) addSetupExpr(tagSection, attr.value);
4805
+ }
4806
+ addSerializeExpr(tagSection, !!(node.var || hasEventHandlers), nodeBinding);
4807
+ trackDomVarReferences(tag, nodeBinding);
4808
+ addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
4714
4809
  }
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]);
4810
+ const write = writeTo(tag);
4811
+ (node.extra ??= {})[kVisitOp] = visit(tag, 32, false);
4812
+ write`<${tagName}`;
4813
+ for (const attr of getUsedAttrs(tagName, tag.node, true).staticAttrs) {
4814
+ const { name, value } = attr;
4815
+ const { confident, computed } = value.extra || {};
4816
+ switch (name) {
4817
+ case "class":
4818
+ case "style": {
4819
+ const helper = `_attr_${name}`;
4820
+ if (confident) write`${getHTMLRuntime()[helper](computed)}`;
4821
+ else {
4822
+ const meta = {
4823
+ staticItems: void 0,
4824
+ dynamicItems: void 0,
4825
+ dynamicValues: void 0
4826
+ };
4827
+ trackDelimitedAttrValue(value, meta);
4828
+ if (!meta.dynamicItems && meta.staticItems) write`${getHTMLRuntime()[helper](meta.staticItems)}`;
4829
+ }
4830
+ break;
4831
+ }
4832
+ default:
4833
+ if (confident) write`${getHTMLRuntime()._attr(name, computed)}`;
4834
+ break;
4835
+ }
4719
4836
  }
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);
4837
+ write`>`;
4838
+ enter(tag);
4839
+ },
4840
+ exit(tag) {
4841
+ const tagName = getCanonicalTagName(tag);
4842
+ const tagExtra = tag.node.extra;
4843
+ const visitOp = tagExtra[kVisitOp];
4844
+ if (visitOp) visitOp.claimed = !!tagExtra[kNativeTagBinding];
4845
+ if (!(0, _marko_compiler_babel_utils.getTagDef)(tag)?.parseOptions?.openTagOnly) {
4846
+ const write = writeTo(tag);
4847
+ if (tagName !== "textarea" && isTextOnlyNativeTag(tag)) {
4848
+ const textLiteral = bodyToRawTextLiteral(tag.node.body);
4849
+ if (_marko_compiler.types.isStringLiteral(textLiteral)) write`${textLiteral.value}`;
4850
+ }
4851
+ write`</${tagName}>`;
4725
4852
  }
4726
- addSerializeExpr(tagSection, !!(node.var || hasEventHandlers), nodeBinding);
4727
- trackDomVarReferences(tag, nodeBinding);
4728
- addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
4853
+ exit(tag);
4729
4854
  }
4730
- } },
4855
+ },
4731
4856
  translate: translateByTarget({
4732
4857
  html: {
4733
4858
  enter(tag) {
@@ -4735,7 +4860,7 @@ var native_tag_default = {
4735
4860
  const tagExtra = tag.node.extra;
4736
4861
  const nodeBinding = tagExtra[kNativeTagBinding];
4737
4862
  const tagDef = (0, _marko_compiler_babel_utils.getTagDef)(tag);
4738
- const write = writeTo(tag);
4863
+ const write = writeTo$1(tag);
4739
4864
  const tagSection = getSection(tag);
4740
4865
  const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
4741
4866
  const usedAttrs = getUsedAttrs(tagName, tag.node);
@@ -4839,7 +4964,7 @@ var native_tag_default = {
4839
4964
  const tagName = getCanonicalTagName(tag);
4840
4965
  const tagSection = getSection(tag);
4841
4966
  const markerSerializeReason = !tagExtra[kSkipEndTag] && nodeBinding && getSerializeReason(tagSection, nodeBinding);
4842
- const write = writeTo(tag, tagName === "html" || !markerSerializeReason && tagName === "body");
4967
+ const write = writeTo$1(tag, tagName === "html" || !markerSerializeReason && tagName === "body");
4843
4968
  if (tagExtra[kTagContentAttr]) flushBefore(tag);
4844
4969
  if (selectArgs) {
4845
4970
  if (!tagExtra[kSkipEndTag]) write`</${tagName}>`;
@@ -4867,16 +4992,13 @@ var native_tag_default = {
4867
4992
  const tagExtra = tag.node.extra;
4868
4993
  const nodeBinding = tagExtra[kNativeTagBinding];
4869
4994
  const tagDef = (0, _marko_compiler_babel_utils.getTagDef)(tag);
4870
- const write = writeTo(tag);
4871
4995
  const tagSection = getSection(tag);
4872
4996
  const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
4873
- if (nodeBinding) visit(tag, 32);
4874
- write`<${tagName}`;
4875
4997
  const { staticAttrs, staticControllable, staticContentAttr, skipExpression, spreadExpression, injectNonce } = getUsedAttrs(tagName, tag.node);
4876
4998
  const isOpenOnly = !!(tagDef && tagDef.parseOptions?.openTagOnly);
4877
4999
  const isTextOnly = isTextOnlyNativeTag(tag);
4878
5000
  const hasChildren = !!tag.node.body.body.length;
4879
- if (injectNonce) addStatement("render", tagSection, void 0, _marko_compiler.types.expressionStatement(callRuntime("_attr_nonce", scopeIdentifier, getScopeAccessorLiteral(nodeBinding))), void 0, true);
5001
+ if (injectNonce) addStatement("render", tagSection, void 0, _marko_compiler.types.expressionStatement(callRuntime("_attr_nonce", scopeIdentifier, getScopeAccessorLiteral(nodeBinding))), true);
4880
5002
  if (staticControllable) {
4881
5003
  const hasChangeHandler = !!staticControllable.attrs[1];
4882
5004
  const defaultHelper = getDOMControllableDefaultHelper(staticControllable);
@@ -4888,14 +5010,13 @@ var native_tag_default = {
4888
5010
  }
4889
5011
  for (const attr of staticAttrs) {
4890
5012
  const { name, value } = attr;
4891
- const { confident, computed } = value.extra || {};
5013
+ const { confident } = value.extra || {};
4892
5014
  const valueReferences = value.extra?.referencedBindings;
4893
5015
  switch (name) {
4894
5016
  case "class":
4895
5017
  case "style": {
4896
5018
  const helper = `_attr_${name}`;
4897
- if (confident) write`${getHTMLRuntime()[helper](computed)}`;
4898
- else {
5019
+ if (!confident) {
4899
5020
  const nodeExpr = createScopeReadExpression(nodeBinding);
4900
5021
  const meta = {
4901
5022
  staticItems: void 0,
@@ -4905,32 +5026,29 @@ var native_tag_default = {
4905
5026
  let stmt;
4906
5027
  trackDelimitedAttrValue(value, meta);
4907
5028
  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;
5029
+ else if (meta.dynamicValues) {
5030
+ const keys = Object.keys(meta.dynamicValues);
5031
+ if (keys.length === 1) {
5032
+ const [key] = keys;
5033
+ const value = meta.dynamicValues[key];
5034
+ stmt = _marko_compiler.types.expressionStatement(callRuntime(`_attr_${name}_item`, nodeExpr, _marko_compiler.types.stringLiteral(key), value));
5035
+ } else {
5036
+ const props = [];
5037
+ for (const key of keys) {
4914
5038
  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)));
5039
+ props.push(_marko_compiler.types.objectProperty(toPropertyName(key), value));
4923
5040
  }
5041
+ stmt = _marko_compiler.types.expressionStatement(callRuntime(`_attr_${name}_items`, nodeExpr, _marko_compiler.types.objectExpression(props)));
4924
5042
  }
4925
5043
  }
4926
- if (stmt) addStatement("render", tagSection, valueReferences, stmt, void 0, !!meta.dynamicItems);
5044
+ if (stmt) addStatement("render", tagSection, valueReferences, stmt, !!meta.dynamicItems);
4927
5045
  }
4928
5046
  break;
4929
5047
  }
4930
5048
  default:
4931
- if (confident) write`${getHTMLRuntime()._attr(name, computed)}`;
5049
+ if (confident) break;
4932
5050
  else if (isEventHandler(name)) addStatement("effect", tagSection, valueReferences, _marko_compiler.types.expressionStatement(callRuntime("_on", createScopeReadExpression(nodeBinding), _marko_compiler.types.stringLiteral(getEventHandlerName(name)), value)));
4933
- else addStatement("render", tagSection, valueReferences, _marko_compiler.types.expressionStatement(callRuntime("_attr", createScopeReadExpression(nodeBinding), _marko_compiler.types.stringLiteral(name), value)), void 0, true);
5051
+ else addStatement("render", tagSection, valueReferences, _marko_compiler.types.expressionStatement(callRuntime("_attr", createScopeReadExpression(nodeBinding), _marko_compiler.types.stringLiteral(name), value)), true);
4934
5052
  break;
4935
5053
  }
4936
5054
  }
@@ -4941,27 +5059,19 @@ var native_tag_default = {
4941
5059
  const controllable = !staticControllable && controllableClaimFor(staticName);
4942
5060
  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
5061
  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));
4945
- addStatement("effect", tagSection, tagExtra.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_attrs_script", scopeIdentifier, visitAccessor)), false);
5062
+ enableControllable(controllableFeatureFor(staticName));
5063
+ addStatement("effect", tagSection, tagExtra.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_attrs_script", scopeIdentifier, visitAccessor)));
4946
5064
  }
4947
- 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);
5065
+ if (staticContentAttr) addStatement("render", tagSection, staticContentAttr.value.extra?.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_attr_content", scopeIdentifier, visitAccessor, staticContentAttr.value)), true);
4950
5066
  },
4951
5067
  exit(tag) {
4952
5068
  const nodeBinding = tag.node.extra[kNativeTagBinding];
4953
5069
  const openTagOnly = (0, _marko_compiler_babel_utils.getTagDef)(tag)?.parseOptions?.openTagOnly;
4954
5070
  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);
5071
+ if (!openTagOnly) if (tagName !== "textarea" && isTextOnlyNativeTag(tag)) {
5072
+ const textLiteral = bodyToTextLiteral(tag.node.body);
5073
+ if (!_marko_compiler.types.isStringLiteral(textLiteral)) addStatement("render", getSection(tag), textLiteral.extra?.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_text_content", createScopeReadExpression(nodeBinding), textLiteral)), true);
5074
+ } else tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
4965
5075
  tag.remove();
4966
5076
  }
4967
5077
  }
@@ -5049,7 +5159,7 @@ function getInputValueMode(typeAttr) {
5049
5159
  function getDOMControllableDefaultHelper(controllable) {
5050
5160
  return controllable.helper === "_attr_input_value" && controllable.valueMode ? `_attr_input_value_${controllable.valueMode}_default` : `${controllable.helper}_default`;
5051
5161
  }
5052
- function getUsedAttrs(tagName, tag) {
5162
+ function getUsedAttrs(tagName, tag, staticOnly) {
5053
5163
  const seen = Object.create(null);
5054
5164
  const { attributes } = tag;
5055
5165
  const maybeStaticAttrs = /* @__PURE__ */ new Set();
@@ -5092,6 +5202,14 @@ function getUsedAttrs(tagName, tag) {
5092
5202
  for (const attr of staticControllable.attrs) if (attr) maybeStaticAttrs.delete(attr);
5093
5203
  }
5094
5204
  const staticAttrs = [...maybeStaticAttrs].reverse();
5205
+ if (staticOnly) return {
5206
+ injectNonce,
5207
+ staticAttrs,
5208
+ staticContentAttr,
5209
+ staticControllable,
5210
+ spreadExpression,
5211
+ skipExpression
5212
+ };
5095
5213
  if (spreadProps) {
5096
5214
  if (staticControllable) {
5097
5215
  for (const attr of staticControllable.attrs) if (attr) skipProps.add(attr.name);
@@ -5363,28 +5481,20 @@ function controllableClaimFor(tagName) {
5363
5481
  case "dialog": return "_controllable_open";
5364
5482
  }
5365
5483
  }
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) {
5484
+ /** The resume-pass feature for a tag: `_attrs_script` resolves the control
5485
+ * kind at run time, and a run-time tag name can be any of them. */
5486
+ function controllableFeatureFor(tagName) {
5369
5487
  switch (tagName) {
5370
- case "input": return "_enable_controllable_input";
5371
- case "textarea": return "_enable_controllable_textarea";
5372
- case "select": return "_enable_controllable_select";
5488
+ case "input": return "controllable-input";
5489
+ case "textarea": return "controllable-textarea";
5490
+ case "select": return "controllable-select";
5373
5491
  case "details":
5374
- case "dialog": return "_enable_controllable_open";
5375
- case void 0: return "_enable_controllable";
5492
+ case "dialog": return "controllable-open";
5493
+ case void 0: return "controllable";
5376
5494
  }
5377
5495
  }
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)));
5496
+ function enableControllable(feature) {
5497
+ if (feature) importRuntimeFeature(feature);
5388
5498
  }
5389
5499
  //#endregion
5390
5500
  //#region src/translator/util/is-only-child-in-parent.ts
@@ -5426,16 +5536,13 @@ const IfTag = {
5426
5536
  const ifTagSection = getOrCreateSection(ifTag);
5427
5537
  const ifTagExtra = ifTag.node.extra ??= {};
5428
5538
  const mergeReferenceNodes = [];
5429
- const sectionAccessor = {
5430
- binding: getOptimizedOnlyChildNodeBinding(ifTag, ifTagSection, branches.length),
5431
- prefix: getAccessorPrefix().BranchScopes
5432
- };
5539
+ if (!getOnlyChildParentTagName(ifTag, branches.length)) {
5540
+ visit(ifTag, 37);
5541
+ enterShallow(ifTag);
5542
+ }
5543
+ const sectionAccessor = getBranchSectionAccessor(getOptimizedOnlyChildNodeBinding(ifTag, ifTagSection, branches.length));
5433
5544
  for (const [branchTag, branchBodySection] of branches) {
5434
- if (branchBodySection) {
5435
- branchBodySection.isBranch = true;
5436
- branchBodySection.upstreamExpression = ifTagExtra;
5437
- branchBodySection.sectionAccessor = sectionAccessor;
5438
- }
5545
+ if (branchBodySection) initBranchSection(branchBodySection, ifTagExtra, sectionAccessor);
5439
5546
  if (branchTag.node.attributes.length) mergeReferenceNodes.push(branchTag.node.attributes[0].value);
5440
5547
  }
5441
5548
  mergeReferences(ifTagSection, ifTag.node, mergeReferenceNodes);
@@ -5447,10 +5554,6 @@ const IfTag = {
5447
5554
  enter(tag) {
5448
5555
  if (tag.node.body.attributeTags) return;
5449
5556
  const bodySection = getSectionForBody(tag.get("body"));
5450
- if (isRoot(tag) && !getOnlyChildParentTagName(tag)) {
5451
- visit(tag, 37);
5452
- enterShallow(tag);
5453
- }
5454
5557
  flushBefore(tag);
5455
5558
  if (bodySection) setSectionParentIsOwner(bodySection, true);
5456
5559
  },
@@ -5461,7 +5564,7 @@ const IfTag = {
5461
5564
  if (bodySection) {
5462
5565
  const [[ifTag]] = getBranches(tag);
5463
5566
  const ifTagSection = getSection(ifTag);
5464
- if (isStateSerializeReason(getSerializeReason(ifTagSection, kStatefulReason$1)) && isStaticSerializeReason(getSerializeReason(bodySection, kBranchSerializeReason)) && isStaticSerializeReason(getSerializeReason(ifTagSection, getOptimizedOnlyChildNodeBinding(ifTag, ifTagSection)))) setSectionOwnerResumedByMarker(bodySection);
5567
+ resumeOwnerByMarkerWhenStatic(ifTagSection, bodySection, getOptimizedOnlyChildNodeBinding(ifTag, ifTagSection), kStatefulReason$1);
5465
5568
  flushInto(tag);
5466
5569
  writeHTMLResumeStatements(tagBody);
5467
5570
  }
@@ -5515,10 +5618,6 @@ const IfTag = {
5515
5618
  if (tag.node.body.attributeTags) return;
5516
5619
  const bodySection = getSectionForBody(tag.get("body"));
5517
5620
  if (bodySection) setSectionParentIsOwner(bodySection, true);
5518
- if (isRoot(tag) && !getOnlyChildParentTagName(tag)) {
5519
- visit(tag, 37);
5520
- enterShallow(tag);
5521
- }
5522
5621
  },
5523
5622
  exit(tag) {
5524
5623
  if (tag.node.body.attributeTags) return;
@@ -5689,9 +5788,6 @@ function isLastBranch(tag) {
5689
5788
  const branches = getBranches(tag);
5690
5789
  return branches[branches.length - 1][0] === tag;
5691
5790
  }
5692
- function isRoot(tag) {
5693
- return isCoreTagName(tag, "if");
5694
- }
5695
5791
  //#endregion
5696
5792
  //#region src/translator/core/textarea.ts
5697
5793
  function preAnalyze$1(tag) {
@@ -6463,7 +6559,7 @@ function writeParamsToSignals(tag, propTree, importAlias, info) {
6463
6559
  const argExport = propTree.props[i];
6464
6560
  if (argExport) {
6465
6561
  const argExportIdentifier = info.getBindingIdentifier(argExport.binding, `${importAlias}_param_${i}`);
6466
- addStatement("render", info.tagSection, arg.extra?.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(argExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), arg])), void 0, true);
6562
+ addStatement("render", info.tagSection, arg.extra?.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(argExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), arg])), true);
6467
6563
  }
6468
6564
  i++;
6469
6565
  }
@@ -6489,7 +6585,7 @@ function applyAttrObject(tag, propTree, tagInputIdentifier, info) {
6489
6585
  } else attrTagCallsForTag.set(attrTagName, translatedProps = _marko_compiler.types.parenthesizedExpression(callRuntime("attrTag", translatedProps)));
6490
6586
  } else translatedProps = callRuntime("attrTag", translatedProps);
6491
6587
  }
6492
- addStatement("render", info.tagSection, referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(tagInputIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), translatedProps])), void 0, true);
6588
+ addStatement("render", info.tagSection, referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(tagInputIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), translatedProps])), true);
6493
6589
  }
6494
6590
  function translateAttrTag(tag, attrTagMeta, info, statements) {
6495
6591
  const translatedAttrs = translateAttrs(tag, true, void 0, statements);
@@ -6599,7 +6695,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
6599
6695
  else {
6600
6696
  remaining.delete("content");
6601
6697
  const directContent = !bodySection.params;
6602
- addStatement("render", info.tagSection, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(info.getBindingIdentifier(contentExport.binding, `${importAlias}_content`, directContent), [createScopeReadExpression(info.childScopeBinding, info.tagSection), bodyValue])), void 0, true);
6698
+ addStatement("render", info.tagSection, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(info.getBindingIdentifier(contentExport.binding, `${importAlias}_content`, directContent), [createScopeReadExpression(info.childScopeBinding, info.tagSection), bodyValue])), true);
6603
6699
  }
6604
6700
  }
6605
6701
  }
@@ -6627,13 +6723,13 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
6627
6723
  const childAttrExports = getKnownFromPropTree(propTree, attr.name);
6628
6724
  const attrExportIdentifier = info.getBindingIdentifier(childAttrExports.binding, `${importAlias}_${attr.name}`);
6629
6725
  remaining.delete(attr.name);
6630
- addStatement("render", info.tagSection, attr.value.extra?.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(attrExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), attr.value])), void 0, true);
6726
+ addStatement("render", info.tagSection, attr.value.extra?.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(attrExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), attr.value])), true);
6631
6727
  }
6632
6728
  if (knownSpread) for (const prop of remaining) {
6633
6729
  const childAttrExports = getKnownFromPropTree(propTree, prop);
6634
6730
  const attrExportIdentifier = info.getBindingIdentifier(childAttrExports.binding, `${importAlias}_${prop}`);
6635
6731
  const propBinding = knownSpread.binding.propertyAliases.get(prop);
6636
- addStatement("render", info.tagSection, propBinding, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(attrExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), createScopeReadExpression(propBinding, info.tagSection)])), void 0, true);
6732
+ addStatement("render", info.tagSection, propBinding, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(attrExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), createScopeReadExpression(propBinding, info.tagSection)])), true);
6637
6733
  }
6638
6734
  else if (spreadProps && (remaining.size || propTree.rest && !propTree.rest.props)) {
6639
6735
  const spreadExpr = propsToExpression(spreadProps.reverse());
@@ -6656,7 +6752,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
6656
6752
  props.push(_marko_compiler.types.objectProperty(propId, shorthand ? propId : generateUidIdentifier(name), false, shorthand));
6657
6753
  });
6658
6754
  props.push(_marko_compiler.types.restElement(restId));
6659
- 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.callExpression(_marko_compiler.types.arrowFunctionExpression([_marko_compiler.types.objectPattern(props)], restId), [spreadId])])), void 0, true);
6755
+ 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.callExpression(_marko_compiler.types.arrowFunctionExpression([_marko_compiler.types.objectPattern(props)], restId), [spreadId])])), true);
6660
6756
  }
6661
6757
  } else {
6662
6758
  for (const name of remaining) {
@@ -6664,7 +6760,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
6664
6760
  const attrExportIdentifier = info.getBindingIdentifier(childAttrExports.binding, `${importAlias}_${name}`);
6665
6761
  addStatement("render", info.tagSection, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(attrExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection)])));
6666
6762
  }
6667
- 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 || [])])), void 0, true);
6763
+ 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);
6668
6764
  }
6669
6765
  }
6670
6766
  function mapParamReasonToExpr(exprs, reason) {
@@ -6780,7 +6876,6 @@ function getOrCreatePropertyAlias(binding, property) {
6780
6876
  function trackDomVarReferences(tag, binding) {
6781
6877
  const tagVar = tag.node.var;
6782
6878
  if (!tagVar) return;
6783
- if (!_marko_compiler.types.isIdentifier(tagVar)) throw tag.get("var").buildCodeFrameError("Tag variables on native elements cannot be destructured.");
6784
6879
  const babelBinding = tag.scope.getBinding(tagVar.name);
6785
6880
  const section = getOrCreateSection(tag);
6786
6881
  binding.originalName = tagVar.name;
@@ -7963,6 +8058,8 @@ var await_default = {
7963
8058
  if (paramsBinding) setBindingDownstream(paramsBinding, valueExtra);
7964
8059
  bodySection.upstreamExpression = valueAttr.value.extra;
7965
8060
  addSetupStatement(section);
8061
+ visit(tag, 37);
8062
+ enterShallow(tag);
7966
8063
  },
7967
8064
  translate: translateByTarget({
7968
8065
  html: {
@@ -7995,8 +8092,6 @@ var await_default = {
7995
8092
  return;
7996
8093
  }
7997
8094
  setSectionParentIsOwner(bodySection, true);
7998
- visit(tag, 37);
7999
- enterShallow(tag);
8000
8095
  },
8001
8096
  exit(tag) {
8002
8097
  const { node } = tag;
@@ -8009,6 +8104,7 @@ var await_default = {
8009
8104
  const branchRenderArgs = getBranchRendererArgs(bodySection);
8010
8105
  const branchParams = branchRenderArgs.pop();
8011
8106
  (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)))]));
8107
+ importRuntimeFeature("catch");
8012
8108
  return callRuntime("_await_promise", getScopeAccessorLiteral(nodeRef, true), branchParams);
8013
8109
  };
8014
8110
  addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier(bodySection.name), [scopeIdentifier])));
@@ -8292,6 +8388,7 @@ var html_comment_default = {
8292
8388
  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
8389
  needsBinding = true;
8294
8390
  }
8391
+ let nodeBinding;
8295
8392
  const referenceNodes = [];
8296
8393
  for (const child of tag.get("body").get("body")) if (child.isMarkoPlaceholder()) {
8297
8394
  referenceNodes.push(child.node.value);
@@ -8300,40 +8397,40 @@ var html_comment_default = {
8300
8397
  if (needsBinding) {
8301
8398
  const tagSection = getOrCreateSection(tag);
8302
8399
  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);
8400
+ nodeBinding = tagExtra[kNodeBinding$1] = createBinding("#comment", 0, tagSection, void 0, void 0, void 0, void 0, !!tagVar);
8304
8401
  trackDomVarReferences(tag, nodeBinding);
8305
8402
  addSerializeExpr(tagSection, !!tagVar || tagExtra, nodeBinding);
8306
8403
  }
8404
+ const write = writeTo(tag);
8405
+ if (nodeBinding) visit(tag, 32);
8406
+ enter(tag);
8407
+ write`<!--`;
8408
+ const textLiteral = bodyToRawTextLiteral(tag.node.body);
8409
+ if (_marko_compiler.types.isStringLiteral(textLiteral)) write`${escapeCommentText(textLiteral.value)}`;
8410
+ exit(tag);
8411
+ write`-->`;
8307
8412
  tag.skip();
8308
8413
  },
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);
8414
+ translate: { exit(tag) {
8415
+ const tagSection = getSection(tag);
8416
+ const tagExtra = tag.node.extra;
8417
+ const nodeBinding = tagExtra[kNodeBinding$1];
8418
+ const write = writeTo$1(tag);
8419
+ if (isOutputHTML()) {
8420
+ const { body } = tag.node.body;
8421
+ write`<!--`;
8422
+ if (nodeBinding && isEmptiableCommentBody(body)) if (body.length) write`${_marko_compiler.types.logicalExpression("||", buildCommentValue(body), _marko_compiler.types.stringLiteral(" "))}`;
8423
+ else write` `;
8424
+ else for (const child of body) if (_marko_compiler.types.isMarkoText(child)) write`${escapeCommentText(child.value)}`;
8425
+ else if (_marko_compiler.types.isMarkoPlaceholder(child)) write`${callRuntime(child.escape ? "_escape_comment" : "_unescaped", child.value)}`;
8332
8426
  write`-->`;
8333
- if (nodeBinding) markNode(tag, nodeBinding, getSerializeReason(tagSection, nodeBinding));
8334
- tag.remove();
8427
+ } else {
8428
+ const textLiteral = bodyToTextLiteral(tag.node.body);
8429
+ if (!_marko_compiler.types.isStringLiteral(textLiteral)) addStatement("render", tagSection, tagExtra.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_text", createScopeReadExpression(nodeBinding), textLiteral)));
8335
8430
  }
8336
- },
8431
+ if (nodeBinding) markNode(tag, nodeBinding, getSerializeReason(tagSection, nodeBinding));
8432
+ tag.remove();
8433
+ } },
8337
8434
  parseOptions: { text: true },
8338
8435
  types: runtime_info_default.name + "/tags/html-comment.d.marko",
8339
8436
  autocomplete: [{
@@ -8748,7 +8845,11 @@ var show_default = {
8748
8845
  assertLegalHiddenContext(tag);
8749
8846
  const tagSection = getOrCreateSection(tag);
8750
8847
  if (getOnlyChildParentTagName(tag)) getOptimizedOnlyChildNodeBinding(tag, tagSection);
8751
- else tagExtra[kStartBinding] = createBinding("#text", 0, tagSection);
8848
+ else {
8849
+ tagExtra[kStartBinding] = createBinding("#text", 0, tagSection);
8850
+ visit(tag, 37);
8851
+ enterShallow(tag);
8852
+ }
8752
8853
  if (tagExtra[kStaticDisplay] === void 0) {
8753
8854
  mergeReferences(tagSection, tag.node, [display]);
8754
8855
  addSerializeExpr(tagSection, tagExtra, kStatefulReason);
@@ -8758,7 +8859,15 @@ var show_default = {
8758
8859
  const tagExtra = tag.node.extra;
8759
8860
  if (tagExtra[kStaticDisplay] === true) return;
8760
8861
  const tagSection = getSection(tag);
8761
- if (tagExtra[kStartBinding] && !tagExtra[kSingleNodeBody]) tagExtra[kEndBinding] = createBinding("#text", 0, tagSection);
8862
+ if (tagExtra[kStartBinding]) {
8863
+ if (!tagExtra[kSingleNodeBody]) {
8864
+ tagExtra[kEndBinding] = createBinding("#text", 0, tagSection);
8865
+ visit(tag, 37);
8866
+ enterShallow(tag);
8867
+ }
8868
+ visit(tag, 37);
8869
+ enterShallow(tag);
8870
+ }
8762
8871
  const nodeBinding = getOptimizedOnlyChildNodeBinding(tag, tagSection);
8763
8872
  if (tagExtra[kStaticDisplay] === void 0) addSerializeExpr(tagSection, tagExtra, nodeBinding);
8764
8873
  }
@@ -8771,7 +8880,7 @@ var show_default = {
8771
8880
  const staticDisplay = tagExtra[kStaticDisplay];
8772
8881
  if (staticDisplay === true) return;
8773
8882
  if (staticDisplay === false) {
8774
- writeTo(tag)`<t hidden>`;
8883
+ writeTo$1(tag)`<t hidden>`;
8775
8884
  return;
8776
8885
  }
8777
8886
  const display = tag.node.attributes[0].value;
@@ -8784,7 +8893,7 @@ var show_default = {
8784
8893
  exit(tag) {
8785
8894
  const tagExtra = tag.node.extra;
8786
8895
  const staticDisplay = tagExtra[kStaticDisplay];
8787
- if (staticDisplay === false) writeTo(tag)`</t>`;
8896
+ if (staticDisplay === false) writeTo$1(tag)`</t>`;
8788
8897
  flushInto(tag);
8789
8898
  const bodyStatements = tag.node.body.body;
8790
8899
  if (staticDisplay !== void 0) {
@@ -8814,40 +8923,24 @@ var show_default = {
8814
8923
  ])) replacement.skip();
8815
8924
  }
8816
8925
  },
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);
8926
+ dom: { exit(tag) {
8927
+ const tagExtra = tag.node.extra;
8928
+ if (tagExtra[kStaticDisplay] === true) {
8848
8929
  tag.remove();
8930
+ return;
8849
8931
  }
8850
- }
8932
+ const tagSection = getSection(tag);
8933
+ const endBinding = tagExtra[kEndBinding];
8934
+ const nodeBinding = getOptimizedOnlyChildNodeBinding(tag, tagSection);
8935
+ const startBinding = tagExtra[kStartBinding];
8936
+ const display = tagExtra[kStaticDisplay] === false ? _marko_compiler.types.booleanLiteral(false) : tag.node.attributes[0].value;
8937
+ const signal = getSignal(tagSection, nodeBinding, "show");
8938
+ signal.build = () => {
8939
+ return callRuntime("_show", getScopeAccessorLiteral(nodeBinding, true), startBinding ? getScopeAccessorLiteral(startBinding, true) : void 0, endBinding ? getScopeAccessorLiteral(endBinding, true) : void 0);
8940
+ };
8941
+ addValue(tagSection, tagExtra.referencedBindings, signal, display);
8942
+ tag.remove();
8943
+ } }
8851
8944
  }),
8852
8945
  parseOptions: { controlFlow: true },
8853
8946
  autocomplete: [{
@@ -9009,6 +9102,8 @@ var style_default = {
9009
9102
  if (names) {
9010
9103
  analyzeDynamicStyle(tag, names);
9011
9104
  addSetupStatement(getOrCreateSection(tag));
9105
+ visit(tag, 32);
9106
+ writeTo(tag)`<style></style>`;
9012
9107
  }
9013
9108
  },
9014
9109
  translate: translateByTarget({
@@ -9056,7 +9151,7 @@ function checkDynamicStylePlacement(tag) {
9056
9151
  for (const sibling of tag.getAllPrevSiblings()) {
9057
9152
  if (isCoreTagName(sibling, "style")) continue;
9058
9153
  if (sibling.isMarkoText() ? /\S/.test(sibling.node.value) : getNodeContentType(sibling, "startType") !== null) {
9059
- (0, _marko_compiler_babel_utils.diagnosticWarn)(tag, { label: "The `${...}` values of a [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) only apply to elements rendered after it, so the content before this tag will not receive them. Move the `<style>` tag above the content it styles." });
9154
+ (0, _marko_compiler_babel_utils.diagnosticWarn)(tag, { label: "The `${...}` values of a [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) only apply to the subsequent siblings of the `<style>` tag and their descendants, so the content before this tag will not receive them. Move the `<style>` tag above the content it styles." });
9060
9155
  return;
9061
9156
  }
9062
9157
  }
@@ -9075,7 +9170,7 @@ function translateHTML$1(tag) {
9075
9170
  if (dynamic) {
9076
9171
  const { binding } = dynamic;
9077
9172
  const section = getSection(tag);
9078
- writeTo(tag)`${callRuntime("_style_html", buildStyleDecls(node))}`;
9173
+ writeTo$1(tag)`${callRuntime("_style_html", buildStyleDecls(node))}`;
9079
9174
  markNode(tag, binding, getSerializeReason(section, binding));
9080
9175
  }
9081
9176
  emitStyleImport(tag);
@@ -9087,16 +9182,12 @@ function translateDOM$1(tag) {
9087
9182
  if (dynamic) {
9088
9183
  const { names, binding } = dynamic;
9089
9184
  const section = getSection(tag);
9090
- const write = writeTo(tag);
9091
9185
  const readEl = () => createScopeReadExpression(binding);
9092
- visit(tag, 32);
9093
- write`<style>`;
9094
- addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(callRuntime("_style_shell", scopeIdentifier, getScopeAccessorLiteral(binding))), void 0, true);
9186
+ addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(callRuntime("_style_shell", scopeIdentifier, getScopeAccessorLiteral(binding))), true);
9095
9187
  dynamicStyleValues(node).forEach((value, i) => {
9096
9188
  const valueRef = value.extra?.referencedBindings;
9097
- addStatement("render", section, valueRef, _marko_compiler.types.expressionStatement(callRuntime("_style_rule_item", readEl(), _marko_compiler.types.stringLiteral(names[i]), value)), void 0, !valueRef);
9189
+ addStatement("render", section, valueRef, _marko_compiler.types.expressionStatement(callRuntime("_style_rule_item", readEl(), _marko_compiler.types.stringLiteral(names[i]), value)), !valueRef);
9098
9190
  });
9099
- write`</style>`;
9100
9191
  }
9101
9192
  emitStyleImport(tag);
9102
9193
  tag.remove();
@@ -9181,7 +9272,6 @@ function getStyleImportPath(file, node, names) {
9181
9272
  }
9182
9273
  //#endregion
9183
9274
  //#region src/translator/core/try.ts
9184
- const hasEnabledCatch = /* @__PURE__ */ new WeakSet();
9185
9275
  const kDOMBinding$1 = Symbol("try tag dom binding");
9186
9276
  var try_default = {
9187
9277
  analyze(tag) {
@@ -9195,7 +9285,11 @@ var try_default = {
9195
9285
  tagExtra[kDOMBinding$1] = createBinding("#text", 0, section);
9196
9286
  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
9287
  const bodySection = startSection(tag.get("body"));
9198
- if (bodySection) bodySection.upstreamExpression = tagExtra;
9288
+ if (bodySection) {
9289
+ bodySection.upstreamExpression = tagExtra;
9290
+ visit(tag, 37);
9291
+ enterShallow(tag);
9292
+ }
9199
9293
  },
9200
9294
  translate: translateByTarget({
9201
9295
  html: {
@@ -9229,8 +9323,6 @@ var try_default = {
9229
9323
  const bodySection = getSectionForBody(tag.get("body"));
9230
9324
  if (tag.node.extra?.attributeTags?.["@placeholder"]) setTryHasPlaceholder(bodySection, true);
9231
9325
  setSectionParentIsOwner(bodySection, true);
9232
- visit(tag, 37);
9233
- enterShallow(tag);
9234
9326
  },
9235
9327
  exit(tag) {
9236
9328
  const { node } = tag;
@@ -9244,14 +9336,10 @@ var try_default = {
9244
9336
  const bodySection = getSectionForBody(tag.get("body"));
9245
9337
  const signal = getSignal(section, nodeRef, "try");
9246
9338
  signal.build = () => {
9339
+ importRuntimeFeature("catch");
9247
9340
  return callRuntime("_try", getScopeAccessorLiteral(nodeRef, true), ...replaceNullishAndEmptyFunctionsWith0(getBranchRendererArgs(bodySection)));
9248
9341
  };
9249
9342
  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
9343
  addValue(section, referencedBindings, signal, propsToExpression(translatedAttrs.properties));
9256
9344
  tag.remove();
9257
9345
  }
@@ -9315,7 +9403,7 @@ var declaration_default = { translate: { enter(decl) {
9315
9403
  //#endregion
9316
9404
  //#region src/translator/visitors/document-type.ts
9317
9405
  var document_type_default = { translate: { exit(documentType) {
9318
- if (isOutputHTML()) writeTo(documentType)`<!${documentType.node.value}>`;
9406
+ if (isOutputHTML()) writeTo$1(documentType)`<!${documentType.node.value}>`;
9319
9407
  documentType.remove();
9320
9408
  } } };
9321
9409
  //#endregion
@@ -9370,6 +9458,7 @@ var import_declaration_default = {
9370
9458
  const { file } = importDecl.hub;
9371
9459
  const loadFile = (0, _marko_compiler_babel_utils.loadFileForImport)(file, node.source.value);
9372
9460
  const resolvedPath = (0, _marko_compiler_babel_utils.resolveRelativePath)(file, loadFile.opts.filename);
9461
+ importRuntimeFeature("catch");
9373
9462
  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
9463
  }
9375
9464
  return;
@@ -9486,65 +9575,78 @@ function isEmptyPlaceholder(placeholder) {
9486
9575
  //#region src/translator/visitors/placeholder.ts
9487
9576
  const kNodeBinding = Symbol("placeholder node binding");
9488
9577
  const kSiblingText = Symbol("placeholder has sibling text");
9489
- const kSharedText$1 = Symbol("placeholder will merge its visitor with a another node");
9490
9578
  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);
9579
+ analyze: {
9580
+ enter(placeholder) {
9581
+ if (isNonHTMLText(placeholder)) return;
9582
+ const { node } = placeholder;
9583
+ const valueExtra = evaluate(node.value);
9584
+ const { confident, computed } = valueExtra;
9585
+ if (confident && isVoid(computed)) return;
9586
+ if (!isStaticText(node)) {
9587
+ const section = getOrCreateSection(placeholder);
9588
+ const nodeBinding = (node.extra ??= {})[kNodeBinding] = createBinding("#text", 0, section);
9589
+ analyzeSiblingText(placeholder);
9590
+ addSetupExpr(section, node.value);
9591
+ addSerializeExpr(section, valueExtra, nodeBinding);
9592
+ }
9593
+ },
9594
+ exit(placeholder) {
9595
+ if (isNonHTMLText(placeholder)) return;
9596
+ const { node } = placeholder;
9597
+ const { confident, computed } = evaluate(node.value);
9598
+ if (confident && isVoid(computed)) return;
9599
+ const extra = node.extra || {};
9600
+ if (confident && node.escape) writeTo(placeholder)`${getHTMLRuntime()._escape(computed)}`;
9533
9601
  else {
9534
- if (isHTML) {
9535
- if (siblingText === 3 && markerSerializeReason) writeSeparator(write, section, markerSerializeReason);
9536
- } else write` `;
9537
- visit(placeholder, 32);
9602
+ const siblingText = extra[kSiblingText];
9603
+ if (siblingText === 1 || siblingText === 2) visit(placeholder, 37);
9604
+ else {
9605
+ writeTo(placeholder)` `;
9606
+ visit(placeholder, 32);
9607
+ }
9538
9608
  }
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);
9609
+ if (!isStaticText(node) || !isStaticText(getPrevStaticSibling(placeholder))) enterShallow(placeholder);
9543
9610
  }
9544
- if (!extra[kSharedText$1]) enterShallow(placeholder);
9545
- placeholder.remove();
9611
+ },
9612
+ translate: { exit(placeholder) {
9613
+ translateExit(placeholder);
9546
9614
  } }
9547
9615
  };
9616
+ function translateExit(placeholder) {
9617
+ if (isNonHTMLText(placeholder)) return;
9618
+ const { node } = placeholder;
9619
+ const { value } = node;
9620
+ if (node.extra?.[kRawText]) injectTextCoercion(value);
9621
+ const valueExtra = evaluate(value);
9622
+ const { confident, computed } = valueExtra;
9623
+ if (confident && isVoid(computed)) {
9624
+ placeholder.remove();
9625
+ return;
9626
+ }
9627
+ const isHTML = isOutputHTML();
9628
+ const write = writeTo$1(placeholder);
9629
+ const extra = node.extra || {};
9630
+ const nodeBinding = extra[kNodeBinding];
9631
+ const canWriteHTML = isHTML || confident && node.escape;
9632
+ const method = canWriteHTML ? node.escape ? "_escape" : "_unescaped" : node.escape ? "_text" : "_html";
9633
+ if (confident && canWriteHTML) {
9634
+ if (isHTML) write`${getHTMLRuntime()[method](computed)}`;
9635
+ } else {
9636
+ const section = getSection(placeholder);
9637
+ const siblingText = extra[kSiblingText];
9638
+ const markerSerializeReason = nodeBinding && getSerializeReason(section, nodeBinding);
9639
+ if (isHTML && markerSerializeReason) {
9640
+ if (siblingText === 1) writeSeparator(write, section, markerSerializeReason);
9641
+ else if (siblingText === 3) writeSeparator(write, section, markerSerializeReason);
9642
+ }
9643
+ if (isHTML) {
9644
+ write`${method === "_escape" ? buildEscapedTextExpression(value) : callRuntime(method, value)}`;
9645
+ if (nodeBinding) markNode(placeholder, nodeBinding, markerSerializeReason);
9646
+ } else addStatement("render", section, valueExtra.referencedBindings, _marko_compiler.types.expressionStatement(method === "_text" ? callRuntime("_text", createScopeReadExpression(nodeBinding), value) : callRuntime("_html", scopeIdentifier, value, getScopeAccessorLiteral(nodeBinding))), true);
9647
+ }
9648
+ placeholder.remove();
9649
+ }
9548
9650
  function buildEscapedTextExpression(value) {
9549
9651
  const { _escape } = getHTMLRuntime();
9550
9652
  switch (value.type) {
@@ -9662,7 +9764,7 @@ var referenced_identifier_default = {
9662
9764
  const resetEmitted = getAbortResetEmitted(section);
9663
9765
  if (!resetEmitted.has(exprRoot)) {
9664
9766
  resetEmitted.add(exprRoot);
9665
- addStatement("render", section, exprRoot.node.extra?.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(importRuntime("$signalReset"), [scopeIdentifier, _marko_compiler.types.numericLiteral(exprId)])), false);
9767
+ addStatement("render", section, exprRoot.node.extra?.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(importRuntime("$signalReset"), [scopeIdentifier, _marko_compiler.types.numericLiteral(exprId)])));
9666
9768
  }
9667
9769
  identifier.replaceWith(_marko_compiler.types.callExpression(importRuntime("$signal"), [scopeIdentifier, _marko_compiler.types.numericLiteral(exprId)]));
9668
9770
  }
@@ -9745,6 +9847,17 @@ var custom_tag_default = {
9745
9847
  if (tagExtra.tagNameLoad) tagExtra[kLoadTagBinding] = createBinding("#text", 0, getOrCreateSection(tag));
9746
9848
  if (tagExtra.tagNameLoad || !childExtra.domExports?.setupEmpty) addSetupStatement(getOrCreateSection(tag));
9747
9849
  knownTagAnalyze(tag, childSection, programSection === childSection ? programSection.params && getBindingPropTree(programSection.params) : childExtra.domExports?.params);
9850
+ const tagName = getStaticTagName(tag.node);
9851
+ if (tagExtra.tagNameLoad) {
9852
+ visit(tag, 37);
9853
+ child(tag, tagName);
9854
+ enterShallow(tag);
9855
+ } else child(tag, tagName, {
9856
+ kind: ExportRef,
9857
+ program: childExtra,
9858
+ path: getTagRelativePath(tag),
9859
+ hint: tagName
9860
+ });
9748
9861
  } },
9749
9862
  translate: {
9750
9863
  enter(tag) {
@@ -9769,7 +9882,6 @@ function translateHTML(tag) {
9769
9882
  function translateDOM(tag) {
9770
9883
  const { node } = tag;
9771
9884
  const { file } = tag.hub;
9772
- const write = writeTo(tag);
9773
9885
  const relativePath = getTagRelativePath(tag);
9774
9886
  const programSection = (0, _marko_compiler_babel_utils.getProgram)().node.extra.section;
9775
9887
  const childFile = (0, _marko_compiler_babel_utils.loadFileForTag)(tag);
@@ -9778,7 +9890,7 @@ function translateDOM(tag) {
9778
9890
  const childSection = childExtra.section;
9779
9891
  const loadConfig = node.extra?.tagNameLoad;
9780
9892
  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";
9893
+ const tagName = getStaticTagName(node);
9782
9894
  if (isLoad) {
9783
9895
  const childFileName = childFile.opts.filename;
9784
9896
  const { triggers, signals } = getLoadIdentifiers();
@@ -9804,24 +9916,19 @@ function translateDOM(tag) {
9804
9916
  }, (section, childBinding) => {
9805
9917
  const setupIdent = generateUidIdentifier(`load_${tagName}_setup`);
9806
9918
  const setupLoadExpr = _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.callExpression(_marko_compiler.types.import(), [_marko_compiler.types.stringLiteral(buildLoadSetupVirtualModule(file, childFileName, childExports))]));
9919
+ importRuntimeFeature("catch");
9807
9920
  (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
9921
  addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(setupIdent, [scopeIdentifier])));
9809
9922
  });
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 {
9923
+ } else if (programSection === childSection) knownTagTranslateDOM(tag, childExports.params, (binding, preferredName) => getSignal(programSection, binding, preferredName).identifier, childExports.setupEmpty ? void 0 : (section, childBinding) => {
9924
+ addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier(childExports.setup), [createScopeReadExpression(childBinding, section)])));
9925
+ });
9926
+ else {
9820
9927
  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
9928
  addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(importOrSelfReferenceName(file, relativePath, childExports.setup, tagName), [createScopeReadExpression(childBinding, section)])));
9822
9929
  });
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`));
9930
+ (0, _marko_compiler_babel_utils.importNamed)(file, relativePath, childExports.template, `${tagName}_template`);
9931
+ (0, _marko_compiler_babel_utils.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`);
9825
9932
  }
9826
9933
  tag.remove();
9827
9934
  }
@@ -9876,14 +9983,6 @@ function collectProseWords(node, tagName) {
9876
9983
  }
9877
9984
  return text;
9878
9985
  }
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
9986
  function buildLoadSetupVirtualModule(file, childFileName, childExports) {
9888
9987
  const parts = `${childExports.template}, ${childExports.walks}, ${childExports.setup}`;
9889
9988
  return getMarkoOpts().resolveVirtualDependency(file.opts.filename, {
@@ -9935,6 +10034,10 @@ var dynamic_tag_default = {
9935
10034
  const definedBodySection = node.extra?.defineBodySection;
9936
10035
  if (definedBodySection) {
9937
10036
  knownTagAnalyze(tag, definedBodySection, definedBodySection.params && getBindingPropTree(definedBodySection.params));
10037
+ child(tag, getStaticTagName(tag.node), {
10038
+ kind: SectionRef,
10039
+ section: definedBodySection
10040
+ });
9938
10041
  return;
9939
10042
  }
9940
10043
  analyzeAttributeTags(tag);
@@ -9948,24 +10051,21 @@ var dynamic_tag_default = {
9948
10051
  trackVarReferences(tag, 5);
9949
10052
  tag.node.var.extra.binding.scopeOffset = tagExtra[kChildOffsetScopeBinding] = createBinding("#scopeOffset", 0, tagSection);
9950
10053
  }
9951
- startSection(tagBody);
10054
+ const bodySection = startSection(tagBody);
9952
10055
  trackParamsReferences(tagBody, 3);
9953
10056
  addSerializeExpr(tagSection, hasVar || tagExtra, nodeBinding);
9954
10057
  if (!hasVar && !node.arguments && !node.attributes.length && !node.body.body.length) tagExtra[kDirectContent] = true;
10058
+ if (tagExtra.featureType !== "class" || (0, _marko_compiler_babel_utils.getTagTemplate)(tag)) {
10059
+ visit(tag, hasVar ? 49 : 37);
10060
+ enterShallow(tag);
10061
+ } else if (bodySection) bodySection.structure = null;
9955
10062
  } },
9956
10063
  translate: {
9957
10064
  enter(tag) {
9958
- const tagExtra = tag.node.extra;
9959
- if (tagExtra?.featureType === "class" && !isOutputHTML() && !(0, _marko_compiler_babel_utils.getTagTemplate)(tag)) {
10065
+ if (tag.node.extra?.featureType === "class" && !isOutputHTML() && !(0, _marko_compiler_babel_utils.getTagTemplate)(tag)) {
9960
10066
  tag.remove();
9961
10067
  return;
9962
10068
  }
9963
- if (tagExtra?.defineBodySection) {
9964
- if (isOutputHTML()) flushBefore(tag);
9965
- return;
9966
- }
9967
- visit(tag, tag.node.var ? 49 : 37);
9968
- enterShallow(tag);
9969
10069
  if (isOutputHTML()) flushBefore(tag);
9970
10070
  },
9971
10071
  exit(tag) {
@@ -9977,14 +10077,11 @@ var dynamic_tag_default = {
9977
10077
  const propTree = paramsBinding && getBindingPropTree(paramsBinding);
9978
10078
  if (isOutputHTML()) knownTagTranslateHTML(tag, _marko_compiler.types.memberExpression(tag.node.name, _marko_compiler.types.identifier("content")), definedBodySection, propTree);
9979
10079
  else {
9980
- const write = writeTo(tag);
9981
10080
  knownTagTranslateDOM(tag, propTree, (binding, preferredName, directContent) => directContent && binding.directContentExport ? _marko_compiler.types.identifier(binding.directContentExport) : getSignal(definedBodySection, binding, preferredName).identifier, (section, childBinding) => {
9982
10081
  const signal = getSignal(definedBodySection, void 0);
9983
10082
  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
10083
  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
10084
  });
9986
- write`${() => getSectionMetaIdentifiers(definedBodySection).writes || ""}`;
9987
- injectWalks(tag, tag.get("name").toString(), () => getSectionMetaIdentifiers(definedBodySection).walks);
9988
10085
  tag.remove();
9989
10086
  }
9990
10087
  return;
@@ -10088,7 +10185,7 @@ const controlledAttrs = /^(?:value|checked(?:Value)?|open)(?:Change)?$/;
10088
10185
  function enableDynamicTagControllables(tag) {
10089
10186
  if (analyzeTagNameType(tag, true) === 1) return;
10090
10187
  for (const attr of tag.node.attributes) if (attr.type === "MarkoSpreadAttribute" || attr.type === "MarkoAttribute" && controlledAttrs.test(attr.name)) {
10091
- enableControllable(controllableScriptLatchFor(void 0));
10188
+ enableControllable(controllableFeatureFor(void 0));
10092
10189
  return;
10093
10190
  }
10094
10191
  }
@@ -10144,6 +10241,7 @@ var tag_default = {
10144
10241
  exit$1(hook, tag);
10145
10242
  return;
10146
10243
  }
10244
+ if (analyzeTagNameType(tag) === 0) native_tag_default.analyze.exit(tag);
10147
10245
  } catch (err) {
10148
10246
  (tag.node.extra ??= {}).analyzeFailed = true;
10149
10247
  reportAnalyzeError(tag, err);
@@ -10202,16 +10300,15 @@ var tag_default = {
10202
10300
  };
10203
10301
  //#endregion
10204
10302
  //#region src/translator/visitors/text.ts
10205
- const kSharedText = Symbol("text merges its walk step with a sibling node");
10206
10303
  var text_default = {
10207
- analyze(text) {
10304
+ analyze: { exit(text) {
10208
10305
  if (isNonHTMLText(text)) return;
10209
- if (isStaticText(getPrevStaticSibling(text))) (text.node.extra ??= {})[kSharedText] = true;
10210
- },
10306
+ writeTo(text)`${text.node.value}`;
10307
+ if (!isStaticText(getPrevStaticSibling(text))) enterShallow(text);
10308
+ } },
10211
10309
  translate: { exit(text) {
10212
10310
  if (isNonHTMLText(text)) return;
10213
- writeTo(text)`${text.node.value}`;
10214
- if (!text.node.extra?.[kSharedText]) enterShallow(text);
10311
+ if (isOutputHTML()) writeTo$1(text)`${text.node.value}`;
10215
10312
  text.remove();
10216
10313
  } }
10217
10314
  };
@@ -10220,7 +10317,7 @@ var text_default = {
10220
10317
  function buildAggregateError(file, rootMsg, ...paths) {
10221
10318
  const err = /* @__PURE__ */ new SyntaxError();
10222
10319
  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")}`;
10320
+ 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
10321
  if (!("MARKO_DEBUG" in process.env)) err.stack = finalMsg;
10225
10322
  Object.defineProperty(err, "message", {
10226
10323
  get() {
@@ -10450,13 +10547,13 @@ function mergeVisitors(visitor5, visitor6) {
10450
10547
  function mergeVisit(visit5, visit6) {
10451
10548
  const enter5 = getVisitorEnter(visit5);
10452
10549
  const enter6 = getVisitorEnter(visit6);
10453
- const enter = (enter5 || enter6) && function enter(path$9, state) {
10454
- return (isTagsAPI() ? enter6 : enter5)?.call(this, path$9, state);
10550
+ const enter = (enter5 || enter6) && function enter(path$10, state) {
10551
+ return (isTagsAPI() ? enter6 : enter5)?.call(this, path$10, state);
10455
10552
  };
10456
10553
  const exit5 = getVisitorExit(visit5);
10457
10554
  const exit6 = getVisitorExit(visit6);
10458
- const exit = (exit5 || exit6) && function exit(path$10, state) {
10459
- return (isTagsAPI() ? exit6 : exit5)?.call(this, path$10, state);
10555
+ const exit = (exit5 || exit6) && function exit(path$11, state) {
10556
+ return (isTagsAPI() ? exit6 : exit5)?.call(this, path$11, state);
10460
10557
  };
10461
10558
  return exit ? enter ? {
10462
10559
  enter,
@@ -10539,17 +10636,17 @@ function sequenceVisit(first, second) {
10539
10636
  if (!first || !second) return first || second;
10540
10637
  const enterFirst = getVisitorEnter(first);
10541
10638
  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);
10639
+ const enter = (enterFirst || enterSecond) && function enter(path$12, state) {
10640
+ const { node } = path$12;
10641
+ enterFirst?.call(this, path$12, state);
10642
+ if (path$12.node === node) enterSecond?.call(this, path$12, state);
10546
10643
  };
10547
10644
  const exitFirst = getVisitorExit(first);
10548
10645
  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);
10646
+ const exit = (exitFirst || exitSecond) && function exit(path$13, state) {
10647
+ const { node } = path$13;
10648
+ exitFirst?.call(this, path$13, state);
10649
+ if (path$13.node === node) exitSecond?.call(this, path$13, state);
10553
10650
  };
10554
10651
  return exit ? enter ? {
10555
10652
  enter,