marko 6.4.11 → 6.4.13

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 (108) hide show
  1. package/dist/common/attr-tag.d.ts +1 -0
  2. package/dist/common/errors.d.ts +2 -0
  3. package/dist/common/helpers.d.ts +2 -0
  4. package/dist/debug/dom/catch.feat.js +1 -1
  5. package/dist/debug/dom/catch.feat.mjs +1 -1
  6. package/dist/debug/dom/compat.feat.js +143 -0
  7. package/dist/debug/dom/compat.feat.mjs +141 -0
  8. package/dist/debug/dom/controllable-input.feat.js +1 -1
  9. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  10. package/dist/debug/dom/controllable-open.feat.js +1 -1
  11. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  12. package/dist/debug/dom/controllable-select.feat.js +1 -1
  13. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  14. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  15. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  16. package/dist/debug/dom/controllable.feat.js +1 -1
  17. package/dist/debug/dom/controllable.feat.mjs +1 -1
  18. package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
  19. package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
  20. package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
  21. package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
  22. package/dist/debug/dom/lazy.feat.js +1 -1
  23. package/dist/debug/dom/lazy.feat.mjs +1 -1
  24. package/dist/debug/dom/placeholder.feat.js +1 -1
  25. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  26. package/dist/debug/{dom-DjUZd-9y.mjs → dom-BORByF2b.mjs} +54 -27
  27. package/dist/debug/{dom-mQ5mPBTF.js → dom-sfzdCRAg.js} +71 -38
  28. package/dist/debug/dom.js +4 -127
  29. package/dist/debug/dom.mjs +2 -119
  30. package/dist/debug/html/compat.feat.js +222 -0
  31. package/dist/debug/html/compat.feat.mjs +220 -0
  32. package/dist/debug/html-DMo6pc_h.mjs +3931 -0
  33. package/dist/debug/html-DfZjMkhx.js +4513 -0
  34. package/dist/debug/html.js +83 -4220
  35. package/dist/debug/html.mjs +1 -4133
  36. package/dist/dom/catch.feat.js +4 -4
  37. package/dist/dom/catch.feat.mjs +1 -1
  38. package/dist/dom/{compat.d.ts → compat.feat.d.ts} +18 -9
  39. package/dist/dom/compat.feat.js +101 -0
  40. package/dist/dom/compat.feat.mjs +100 -0
  41. package/dist/dom/control-flow.d.ts +0 -1
  42. package/dist/dom/controllable-input.feat.js +2 -2
  43. package/dist/dom/controllable-input.feat.mjs +1 -1
  44. package/dist/dom/controllable-open.feat.js +2 -2
  45. package/dist/dom/controllable-open.feat.mjs +1 -1
  46. package/dist/dom/controllable-select.feat.js +2 -2
  47. package/dist/dom/controllable-select.feat.mjs +1 -1
  48. package/dist/dom/controllable-textarea.feat.js +2 -2
  49. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  50. package/dist/dom/controllable.feat.js +2 -2
  51. package/dist/dom/controllable.feat.mjs +1 -1
  52. package/dist/dom/dom.d.ts +2 -1
  53. package/dist/dom/dynamic-tag-script.feat.js +2 -2
  54. package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
  55. package/dist/dom/dynamic-tag-var.feat.js +3 -3
  56. package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
  57. package/dist/dom/lazy.feat.js +1 -1
  58. package/dist/dom/lazy.feat.mjs +1 -1
  59. package/dist/dom/placeholder.feat.js +3 -3
  60. package/dist/dom/placeholder.feat.mjs +1 -1
  61. package/dist/dom/resume.d.ts +3 -1
  62. package/dist/{dom-HEWdZCCb.mjs → dom-DKn1bCPC.mjs} +15 -19
  63. package/dist/{dom-B8j2453O.js → dom-DRiewpRL.js} +127 -136
  64. package/dist/dom.d.ts +0 -1
  65. package/dist/dom.js +21 -95
  66. package/dist/dom.mjs +3 -72
  67. package/dist/html/{compat.d.ts → compat.feat.d.ts} +5 -4
  68. package/dist/html/compat.feat.js +165 -0
  69. package/dist/html/compat.feat.mjs +164 -0
  70. package/dist/html/dynamic-tag.d.ts +1 -2
  71. package/dist/html/writer.d.ts +2 -1
  72. package/dist/html-DMDc0zKs.mjs +2404 -0
  73. package/dist/html-DrHsybFm.js +2880 -0
  74. package/dist/html.d.ts +0 -1
  75. package/dist/html.js +2 -2566
  76. package/dist/html.mjs +3 -2561
  77. package/dist/translator/core/if.d.ts +0 -85
  78. package/dist/translator/core/index.d.ts +2 -85
  79. package/dist/translator/index.d.ts +2 -85
  80. package/dist/translator/index.js +332 -476
  81. package/dist/translator/interop/index.d.ts +2 -0
  82. package/dist/translator/util/assert.d.ts +2 -0
  83. package/dist/translator/util/branch-tag.d.ts +1 -1
  84. package/dist/translator/util/known-tag.d.ts +4 -1
  85. package/dist/translator/util/optional.d.ts +0 -1
  86. package/dist/translator/util/reasons.d.ts +0 -1
  87. package/dist/translator/util/references.d.ts +1 -0
  88. package/dist/translator/util/sections.d.ts +5 -1
  89. package/dist/translator/util/tag-facts.d.ts +2 -0
  90. package/dist/translator/util/translate-attrs.d.ts +1 -4
  91. package/dist/translator/visitors/program/index.d.ts +2 -2
  92. package/index.d.ts +2 -7
  93. package/package.json +4 -4
  94. package/tags/await.d.marko +9 -1
  95. package/tags/const.d.marko +7 -1
  96. package/tags/debug.d.marko +7 -1
  97. package/tags/define.d.marko +7 -1
  98. package/tags/effect.d.marko +6 -1
  99. package/tags/html-comment.d.marko +6 -0
  100. package/tags/html-script.d.marko +5 -0
  101. package/tags/html-style.d.marko +5 -0
  102. package/tags/id.d.marko +11 -1
  103. package/tags/let.d.marko +8 -1
  104. package/tags/lifecycle.d.marko +11 -1
  105. package/tags/log.d.marko +7 -1
  106. package/tags/script.d.marko +9 -1
  107. package/tags/show.d.marko +7 -1
  108. package/tags/try.d.marko +9 -1
@@ -404,9 +404,6 @@ function reduceWhile(data, cb, initial) {
404
404
  function toArray(data, cb) {
405
405
  return data !== void 0 ? Array.isArray(data) ? data.map(cb) : [cb(data, 0)] : [];
406
406
  }
407
- function toSet(data) {
408
- return data !== void 0 ? Array.isArray(data) ? new Set(data) : (/* @__PURE__ */ new Set()).add(data) : /* @__PURE__ */ new Set();
409
- }
410
407
  function mapToString(data, sep, cb) {
411
408
  if (data !== void 0) {
412
409
  if (Array.isArray(data)) {
@@ -1761,6 +1758,9 @@ function createResolvedGetterRead(binding, properties, getter) {
1761
1758
  function isReferencedExtra(extra) {
1762
1759
  return !!(extra && !extra.dropped && extra.section);
1763
1760
  }
1761
+ function hasResumableWriter(source) {
1762
+ return !!source.returnedBy || hasResumableAssignment(source);
1763
+ }
1764
1764
  function hasResumableAssignment(binding) {
1765
1765
  return some(binding.assignments, isResumableAssignment);
1766
1766
  }
@@ -2058,6 +2058,195 @@ function getCompatRuntimeFile() {
2058
2058
  const markoOpts = getMarkoOpts();
2059
2059
  return `marko/${markoOpts.optimize ? "dist" : "src"}/runtime/helpers/tags-compat/${isOutputHTML() ? "html" : "dom"}${markoOpts.optimize ? "" : "-debug"}.${markoOpts.modules === "esm" ? "mjs" : "js"}`;
2060
2060
  }
2061
+ // src/translator/util/with-comment.ts
2062
+ function withLeadingComment(node, value) {
2063
+ if (value) {
2064
+ const comment = {
2065
+ type: "CommentBlock",
2066
+ value: ` ${value} `
2067
+ };
2068
+ node.leadingComments = node.leadingComments ? [...node.leadingComments, comment] : [comment];
2069
+ }
2070
+ return node;
2071
+ }
2072
+ // src/translator/util/write-guard.ts
2073
+ function isSameReason(a, b) {
2074
+ return a === b || (a && b ? a.always && b.always || compareSources(a, b) === 0 : false);
2075
+ }
2076
+ const groupCheckPrefixes = {
2077
+ _write_guard: "wg",
2078
+ _write_if: "wi"
2079
+ };
2080
+ const [getSectionGuards] = createOutputSectionState((section) => ({
2081
+ shares: /* @__PURE__ */ new Map(),
2082
+ declarators: [_marko_compiler.types.variableDeclarator(scopeReasonIdentifier(section), callRuntime("_scope_reason"))]
2083
+ }));
2084
+ function buildGroupMask(groups) {
2085
+ let mask = 0;
2086
+ let maskNames = "";
2087
+ let dynamic;
2088
+ const props = [];
2089
+ let needsObject = false;
2090
+ let any = false;
2091
+ for (let i = 0; i < groups.length; i++) {
2092
+ const { value, names } = groups[i];
2093
+ if (value === void 0) continue;
2094
+ any = true;
2095
+ if (value === 0) continue;
2096
+ if (i >= 15) needsObject = true;
2097
+ else if (typeof value === "number") {
2098
+ mask |= value << 1 + 2 * i;
2099
+ if (names) maskNames += maskNames ? ` | ${names}` : names;
2100
+ } else {
2101
+ const shifted = _marko_compiler.types.binaryExpression("<<", value, withLeadingComment(_marko_compiler.types.numericLiteral(1 + 2 * i), names));
2102
+ dynamic = dynamic ? _marko_compiler.types.binaryExpression("|", dynamic, shifted) : shifted;
2103
+ }
2104
+ props.push(_marko_compiler.types.objectProperty(withLeadingComment(_marko_compiler.types.numericLiteral(i), names), typeof value === "number" ? _marko_compiler.types.numericLiteral(value) : value));
2105
+ }
2106
+ if (needsObject) return _marko_compiler.types.objectExpression(props);
2107
+ if (!any) return;
2108
+ const literal = mask ? withLeadingComment(_marko_compiler.types.numericLiteral(mask), maskNames) : void 0;
2109
+ return literal && dynamic ? _marko_compiler.types.binaryExpression("|", literal, dynamic) : literal || dynamic || _marko_compiler.types.numericLiteral(0);
2110
+ }
2111
+ function getScopeReasonStatement(section) {
2112
+ return hasGuardedReason(section) ? _marko_compiler.types.variableDeclaration("const", getSectionGuards(section).declarators) : _marko_compiler.types.expressionStatement(callRuntime("_scope_reason"));
2113
+ }
2114
+ function getWriteReason(binding) {
2115
+ return findSlot(binding)?.reason;
2116
+ }
2117
+ function getBranchWriteReason(section) {
2118
+ return findSectionSlot(section, 9)?.reason;
2119
+ }
2120
+ function isBranchAlwaysMarked(section) {
2121
+ return isOptionalBranch(section) && getWriteBit(section.parent, getWriteReason(section.branch.tag.nodeBinding)) === 1;
2122
+ }
2123
+ function getWriteGuard(section, reason, omitUnconditional) {
2124
+ if (!isDynamicWriteGuard(section, reason)) {
2125
+ if (!reason) return _marko_compiler.types.numericLiteral(0);
2126
+ return omitUnconditional ? void 0 : withLeadingComment(_marko_compiler.types.numericLiteral(1), getDebugNames(reason.always ? void 0 : reason.state));
2127
+ }
2128
+ const bit = getGroupsBit(reason.param);
2129
+ if (bit !== void 0) return bit && omitUnconditional ? void 0 : _marko_compiler.types.numericLiteral(bit);
2130
+ return orEachParamGroup(reason.param, "_write_guard");
2131
+ }
2132
+ function getWriteGuardForAny(section, reasons, omitUnconditional) {
2133
+ if (!Array.isArray(reasons)) return getWriteGuard(section, reasons, omitUnconditional);
2134
+ for (const reason of reasons) if (getWriteBit(section, reason) === 1) return omitUnconditional ? void 0 : withLeadingComment(_marko_compiler.types.numericLiteral(1), getDebugNames(reason.state));
2135
+ let expr;
2136
+ for (const reason of reasons) if (getWriteBit(section, reason) !== 0) expr = orGuard(expr, getWriteGuard(section, reason, false));
2137
+ return expr || _marko_compiler.types.numericLiteral(0);
2138
+ }
2139
+ function getExprIfWritten(section, reason, expr) {
2140
+ const ownReason = mapBodyParams(section, reason);
2141
+ if (!isGuardedReason(ownReason)) return ownReason && expr;
2142
+ const bit = getGroupsBit(ownReason.param);
2143
+ if (bit !== void 0) return bit ? expr : void 0;
2144
+ return andGuard(orEachParamGroup(ownReason.param, "_write_if"), expr);
2145
+ }
2146
+ function isEverWritten(section, reason) {
2147
+ const ownReason = mapBodyParams(section, reason);
2148
+ return isGuardedReason(ownReason) ? getGroupsBit(ownReason.param) !== 0 : !!ownReason;
2149
+ }
2150
+ function isWrittenForCall(section, reason, call, callSection) {
2151
+ if (getWriteBit(section, reason) === 1) return true;
2152
+ const { childScopeBinding, childSection } = call;
2153
+ return !!childScopeBinding && isDynamicWriteGuard(section, reason) && reduceParamGroups(reason.param, (written, groupSection, group) => written || groupSection === childSection && getWriteBit(callSection, findSlot(childScopeBinding, 5, callSection, childSection.paramReasonGroups[getParamReasonGroupIndex(childSection, group)])?.reason) === 1, false);
2154
+ }
2155
+ function getWriteBit(section, reason) {
2156
+ return isDynamicWriteGuard(section, reason) ? getGroupsBit(reason.param) : reason ? 1 : 0;
2157
+ }
2158
+ function getGroupsBit(params) {
2159
+ return reduceParamGroups(params, addGroupBit, 0);
2160
+ }
2161
+ function addGroupBit(bit, section, group) {
2162
+ const groupBit = getStaticGroupBit(section, group);
2163
+ return bit === 1 || groupBit === 1 ? 1 : bit === 0 && groupBit === 0 ? 0 : void 0;
2164
+ }
2165
+ function orEachParamGroup(params, check) {
2166
+ return reduceParamGroups(params, orGroupChecks[check], void 0);
2167
+ }
2168
+ const orGroupChecks = {
2169
+ _write_guard: orGroupCheck("_write_guard"),
2170
+ _write_if: orGroupCheck("_write_if")
2171
+ };
2172
+ function orGroupCheck(check) {
2173
+ return (expr, section, group) => getStaticGroupBit(section, group) === 0 ? expr : orGuard(expr, getOrShareSectionGuard(section, group, check));
2174
+ }
2175
+ function orGuard(guard, other) {
2176
+ return guard ? _marko_compiler.types.logicalExpression("||", guard, other) : other;
2177
+ }
2178
+ function andGuard(guard, expr) {
2179
+ return guard ? _marko_compiler.types.logicalExpression("&&", guard, expr) : expr;
2180
+ }
2181
+ function getOrShareSectionGuard(section, params, check) {
2182
+ if (!section.paramReasonGroups) return scopeReasonIdentifier(section);
2183
+ const state = getSectionGuards(section);
2184
+ let tracking = state.shares.get(check);
2185
+ if (!tracking) state.shares.set(check, tracking = createGuardShares());
2186
+ const index = getParamReasonGroupIndex(section, params);
2187
+ const name = tracking.names.get(index);
2188
+ if (name) return _marko_compiler.types.identifier(name);
2189
+ const guard = callRuntime(check, scopeReasonIdentifier(section), withLeadingComment(_marko_compiler.types.numericLiteral(index), getDebugNames(params)));
2190
+ const pending = tracking.pending.get(index);
2191
+ if (!pending) {
2192
+ const expr = _marko_compiler.types.parenthesizedExpression(guard);
2193
+ tracking.pending.set(index, expr);
2194
+ return expr;
2195
+ }
2196
+ const shared = generateUid(`${groupCheckPrefixes[check]}__${getDebugNamesAsIdentifier(params)}`);
2197
+ tracking.names.set(index, shared);
2198
+ tracking.pending.delete(index);
2199
+ state.declarators.push(_marko_compiler.types.variableDeclarator(_marko_compiler.types.identifier(shared), guard));
2200
+ pending.expression = _marko_compiler.types.identifier(shared);
2201
+ return _marko_compiler.types.parenthesizedExpression(_marko_compiler.types.identifier(shared));
2202
+ }
2203
+ function isDynamicWriteGuard(section, reason) {
2204
+ return isGuardedReason(reason) && !isCrossSection(section, reason);
2205
+ }
2206
+ function isCrossSection(section, reason) {
2207
+ return some(reason.param, (param) => !isSameOrAncestorSection(param.section, section));
2208
+ }
2209
+ function getStaticGroupBit(body, group) {
2210
+ const index = findParamReasonGroupIndex(body, group);
2211
+ return index === -1 ? void 0 : getBodyGroupBit(body.paramReasonGroups[index]);
2212
+ }
2213
+ const [getBodyGroupBit] = createAnalysisMemo((group) => {
2214
+ const body = first(group).section;
2215
+ return isOnlyCalled(body) ? getCallsBit(body, group) : void 0;
2216
+ }, void 0);
2217
+ function getCallsBit(body, group) {
2218
+ const renderedBy = body.renderedBy;
2219
+ let bit;
2220
+ for (const call of Array.isArray(renderedBy) ? renderedBy : [renderedBy]) {
2221
+ const callSection = call.childScopeBinding.section;
2222
+ const callBit = getWriteBit(callSection, findSlot(call.childScopeBinding, 5, callSection, group)?.reason);
2223
+ if (callBit === void 0 || bit !== void 0 && bit !== callBit) return;
2224
+ bit = callBit;
2225
+ }
2226
+ return bit;
2227
+ }
2228
+ function isOnlyCalled(body) {
2229
+ return !!body.renderedBy && !!body.derives && !some(body.derives.binding, isUsed);
2230
+ }
2231
+ function isUsed(binding) {
2232
+ return !!binding.reads.size || !!binding.aliases.size || !!binding.propertyAliases.size;
2233
+ }
2234
+ function createGuardShares() {
2235
+ return {
2236
+ names: /* @__PURE__ */ new Map(),
2237
+ pending: /* @__PURE__ */ new Map()
2238
+ };
2239
+ }
2240
+ function hasGuardedReason(section) {
2241
+ if (section.paramReasonGroups || isGuardedReason(mapBodyParams(section, section.reason))) return true;
2242
+ return section.slots.some(isConditionalSlot);
2243
+ }
2244
+ function isConditionalSlot(slot) {
2245
+ return isGuardedReason(mapBodyParams(slot.section, slot.reason));
2246
+ }
2247
+ function scopeReasonIdentifier(section) {
2248
+ return _marko_compiler.types.identifier(ensureSharedUid(`scope${section.id}_reason`, section));
2249
+ }
2061
2250
  // src/translator/util/module-registrations.ts
2062
2251
  const kRegisteredExports = Symbol("registered exports");
2063
2252
  const [getReferencesByFn] = createAnalysisState(() => /* @__PURE__ */ new Map());
@@ -2080,7 +2269,7 @@ function addFunctionReasons() {
2080
2269
  }
2081
2270
  function finalizeRegistrations() {
2082
2271
  const programExtra = (0, _marko_compiler_babel_utils.getProgram)().node.extra;
2083
- for (const fnExtra of getReferencesByFn().keys()) if (fnExtra.reason) {
2272
+ for (const fnExtra of getReferencesByFn().keys()) if (isEverWritten(fnExtra.section, fnExtra.reason)) {
2084
2273
  registerFunction(fnExtra);
2085
2274
  programExtra.isInteractive ||= !isGuardedReason(fnExtra.reason);
2086
2275
  }
@@ -3154,7 +3343,7 @@ function getSimilarTagHint(tagName) {
3154
3343
  const lowerTagName = tagName.toLowerCase();
3155
3344
  let closestTag;
3156
3345
  let closestDistance = 4;
3157
- for (const name in lookup.merged.tags) {
3346
+ for (const { name } of lookup.getTagsSorted()) {
3158
3347
  const lengthDelta = Math.abs(name.length - tagName.length);
3159
3348
  if (lengthDelta < closestDistance) {
3160
3349
  if (!lengthDelta && name.toLowerCase() === lowerTagName) return ` Tag names are case-sensitive: did you mean \`<${name}>\`?`;
@@ -3268,7 +3457,12 @@ const nativeElementFacts = /* @__PURE__ */ new Map([
3268
3457
  ["tr", discardsWrapperChildrenFacts],
3269
3458
  ["colgroup", discardsWrapperChildrenFacts],
3270
3459
  ["select", discardsWrapperChildrenFacts],
3271
- ["optgroup", discardsWrapperChildrenFacts]
3460
+ ["optgroup", discardsWrapperChildrenFacts],
3461
+ ["meta", {
3462
+ content: 3,
3463
+ inlineBody: true,
3464
+ htmlContentAttr: true
3465
+ }]
3272
3466
  ]);
3273
3467
  const controllableElements = /* @__PURE__ */ new Map([
3274
3468
  ["input", {
@@ -3334,194 +3528,6 @@ function getStyleContentType(tag) {
3334
3528
  function isMarkoPlaceholder(node) {
3335
3529
  return _marko_compiler.types.isMarkoPlaceholder(node);
3336
3530
  }
3337
- // src/translator/util/with-comment.ts
3338
- function withLeadingComment(node, value) {
3339
- if (value) {
3340
- const comment = {
3341
- type: "CommentBlock",
3342
- value: ` ${value} `
3343
- };
3344
- node.leadingComments = node.leadingComments ? [...node.leadingComments, comment] : [comment];
3345
- }
3346
- return node;
3347
- }
3348
- // src/translator/util/write-guard.ts
3349
- function isSameReason(a, b) {
3350
- return a === b || (a && b ? a.always && b.always || compareSources(a, b) === 0 : false);
3351
- }
3352
- const groupCheckPrefixes = {
3353
- _write_guard: "wg",
3354
- _write_if: "wi"
3355
- };
3356
- const [getSectionGuards] = createOutputSectionState((section) => ({
3357
- shares: /* @__PURE__ */ new Map(),
3358
- declarators: [_marko_compiler.types.variableDeclarator(scopeReasonIdentifier(section), callRuntime("_scope_reason"))]
3359
- }));
3360
- function buildGroupMask(groups) {
3361
- let mask = 0;
3362
- let maskNames = "";
3363
- let dynamic;
3364
- const props = [];
3365
- let needsObject = false;
3366
- let any = false;
3367
- for (let i = 0; i < groups.length; i++) {
3368
- const { value, names } = groups[i];
3369
- if (value === void 0) continue;
3370
- any = true;
3371
- if (value === 0) continue;
3372
- if (i >= 15) needsObject = true;
3373
- else if (typeof value === "number") {
3374
- mask |= value << 1 + 2 * i;
3375
- if (names) maskNames += maskNames ? ` | ${names}` : names;
3376
- } else {
3377
- const shifted = _marko_compiler.types.binaryExpression("<<", value, withLeadingComment(_marko_compiler.types.numericLiteral(1 + 2 * i), names));
3378
- dynamic = dynamic ? _marko_compiler.types.binaryExpression("|", dynamic, shifted) : shifted;
3379
- }
3380
- props.push(_marko_compiler.types.objectProperty(withLeadingComment(_marko_compiler.types.numericLiteral(i), names), typeof value === "number" ? _marko_compiler.types.numericLiteral(value) : value));
3381
- }
3382
- if (needsObject) return _marko_compiler.types.objectExpression(props);
3383
- if (!any) return;
3384
- const literal = mask ? withLeadingComment(_marko_compiler.types.numericLiteral(mask), maskNames) : void 0;
3385
- return literal && dynamic ? _marko_compiler.types.binaryExpression("|", literal, dynamic) : literal || dynamic || _marko_compiler.types.numericLiteral(0);
3386
- }
3387
- function getScopeReasonStatement(section) {
3388
- return hasGuardedReason(section) ? _marko_compiler.types.variableDeclaration("const", getSectionGuards(section).declarators) : _marko_compiler.types.expressionStatement(callRuntime("_scope_reason"));
3389
- }
3390
- function getWriteReason(binding) {
3391
- return findSlot(binding)?.reason;
3392
- }
3393
- function getBranchWriteReason(section) {
3394
- return findSectionSlot(section, 9)?.reason;
3395
- }
3396
- function isBranchAlwaysMarked(section) {
3397
- return isOptionalBranch(section) && getWriteBit(section.parent, getWriteReason(section.branch.tag.nodeBinding)) === 1;
3398
- }
3399
- function getWriteGuard(section, reason, omitUnconditional) {
3400
- if (!isDynamicWriteGuard(section, reason)) {
3401
- if (!reason) return _marko_compiler.types.numericLiteral(0);
3402
- return omitUnconditional ? void 0 : withLeadingComment(_marko_compiler.types.numericLiteral(1), getDebugNames(reason.always ? void 0 : reason.state));
3403
- }
3404
- const bit = getGroupsBit(reason.param);
3405
- if (bit !== void 0) return bit && omitUnconditional ? void 0 : _marko_compiler.types.numericLiteral(bit);
3406
- return orEachParamGroup(reason.param, "_write_guard");
3407
- }
3408
- function getWriteGuardForAny(section, reasons, omitUnconditional) {
3409
- if (!Array.isArray(reasons)) return getWriteGuard(section, reasons, omitUnconditional);
3410
- for (const reason of reasons) if (getWriteBit(section, reason) === 1) return omitUnconditional ? void 0 : withLeadingComment(_marko_compiler.types.numericLiteral(1), getDebugNames(reason.state));
3411
- let expr;
3412
- for (const reason of reasons) if (getWriteBit(section, reason) !== 0) expr = orGuard(expr, getWriteGuard(section, reason, false));
3413
- return expr || _marko_compiler.types.numericLiteral(0);
3414
- }
3415
- function getExprIfWritten(section, reason, expr) {
3416
- const ownReason = mapBodyParams(section, reason);
3417
- if (!isGuardedReason(ownReason)) return ownReason && expr;
3418
- const bit = getGroupsBit(ownReason.param);
3419
- if (bit !== void 0) return bit ? expr : void 0;
3420
- return andGuard(orEachParamGroup(ownReason.param, "_write_if"), expr);
3421
- }
3422
- function isEverWritten(section, reason) {
3423
- const ownReason = mapBodyParams(section, reason);
3424
- return isGuardedReason(ownReason) ? getGroupsBit(ownReason.param) !== 0 : !!ownReason;
3425
- }
3426
- function isWrittenForCall(section, reason, call, callSection) {
3427
- if (getWriteBit(section, reason) === 1) return true;
3428
- const { childScopeBinding, childSection } = call;
3429
- return !!childScopeBinding && isDynamicWriteGuard(section, reason) && reduceParamGroups(reason.param, (written, groupSection, group) => written || groupSection === childSection && getWriteBit(callSection, findSlot(childScopeBinding, 5, callSection, childSection.paramReasonGroups[getParamReasonGroupIndex(childSection, group)])?.reason) === 1, false);
3430
- }
3431
- function getWriteBit(section, reason) {
3432
- return isDynamicWriteGuard(section, reason) ? getGroupsBit(reason.param) : reason ? 1 : 0;
3433
- }
3434
- function getGroupsBit(params) {
3435
- return reduceParamGroups(params, addGroupBit, 0);
3436
- }
3437
- function addGroupBit(bit, section, group) {
3438
- const groupBit = getStaticGroupBit(section, group);
3439
- return bit === 1 || groupBit === 1 ? 1 : bit === 0 && groupBit === 0 ? 0 : void 0;
3440
- }
3441
- function orEachParamGroup(params, check) {
3442
- return reduceParamGroups(params, orGroupChecks[check], void 0);
3443
- }
3444
- const orGroupChecks = {
3445
- _write_guard: orGroupCheck("_write_guard"),
3446
- _write_if: orGroupCheck("_write_if")
3447
- };
3448
- function orGroupCheck(check) {
3449
- return (expr, section, group) => getStaticGroupBit(section, group) === 0 ? expr : orGuard(expr, getOrShareSectionGuard(section, group, check));
3450
- }
3451
- function orGuard(guard, other) {
3452
- return guard ? _marko_compiler.types.logicalExpression("||", guard, other) : other;
3453
- }
3454
- function andGuard(guard, expr) {
3455
- return guard ? _marko_compiler.types.logicalExpression("&&", guard, expr) : expr;
3456
- }
3457
- function getOrShareSectionGuard(section, params, check) {
3458
- if (!section.paramReasonGroups) return scopeReasonIdentifier(section);
3459
- const state = getSectionGuards(section);
3460
- let tracking = state.shares.get(check);
3461
- if (!tracking) state.shares.set(check, tracking = createGuardShares());
3462
- const index = getParamReasonGroupIndex(section, params);
3463
- const name = tracking.names.get(index);
3464
- if (name) return _marko_compiler.types.identifier(name);
3465
- const guard = callRuntime(check, scopeReasonIdentifier(section), withLeadingComment(_marko_compiler.types.numericLiteral(index), getDebugNames(params)));
3466
- const pending = tracking.pending.get(index);
3467
- if (!pending) {
3468
- const expr = _marko_compiler.types.parenthesizedExpression(guard);
3469
- tracking.pending.set(index, expr);
3470
- return expr;
3471
- }
3472
- const shared = generateUid(`${groupCheckPrefixes[check]}__${getDebugNamesAsIdentifier(params)}`);
3473
- tracking.names.set(index, shared);
3474
- tracking.pending.delete(index);
3475
- state.declarators.push(_marko_compiler.types.variableDeclarator(_marko_compiler.types.identifier(shared), guard));
3476
- pending.expression = _marko_compiler.types.identifier(shared);
3477
- return _marko_compiler.types.parenthesizedExpression(_marko_compiler.types.identifier(shared));
3478
- }
3479
- function isDynamicWriteGuard(section, reason) {
3480
- return isGuardedReason(reason) && !isCrossSection(section, reason);
3481
- }
3482
- function isCrossSection(section, reason) {
3483
- return some(reason.param, (param) => !isSameOrAncestorSection(param.section, section));
3484
- }
3485
- function getStaticGroupBit(body, group) {
3486
- return getBodyGroupBit(body.paramReasonGroups[getParamReasonGroupIndex(body, group)]);
3487
- }
3488
- const [getBodyGroupBit] = createAnalysisMemo((group) => {
3489
- const body = first(group).section;
3490
- return isOnlyCalled(body) ? getCallsBit(body, group) : void 0;
3491
- }, void 0);
3492
- function getCallsBit(body, group) {
3493
- const renderedBy = body.renderedBy;
3494
- let bit;
3495
- for (const call of Array.isArray(renderedBy) ? renderedBy : [renderedBy]) {
3496
- const callSection = call.childScopeBinding.section;
3497
- const callBit = getWriteBit(callSection, findSlot(call.childScopeBinding, 5, callSection, group)?.reason);
3498
- if (callBit === void 0 || bit !== void 0 && bit !== callBit) return;
3499
- bit = callBit;
3500
- }
3501
- return bit;
3502
- }
3503
- function isOnlyCalled(body) {
3504
- return !!body.renderedBy && !!body.derives && !some(body.derives.binding, isUsed);
3505
- }
3506
- function isUsed(binding) {
3507
- return !!binding.reads.size || !!binding.aliases.size || !!binding.propertyAliases.size;
3508
- }
3509
- function createGuardShares() {
3510
- return {
3511
- names: /* @__PURE__ */ new Map(),
3512
- pending: /* @__PURE__ */ new Map()
3513
- };
3514
- }
3515
- function hasGuardedReason(section) {
3516
- if (section.paramReasonGroups || isGuardedReason(mapBodyParams(section, section.reason))) return true;
3517
- return section.slots.some(isConditionalSlot);
3518
- }
3519
- function isConditionalSlot(slot) {
3520
- return isGuardedReason(mapBodyParams(slot.section, slot.reason));
3521
- }
3522
- function scopeReasonIdentifier(section) {
3523
- return _marko_compiler.types.identifier(ensureSharedUid(`scope${section.id}_reason`, section));
3524
- }
3525
3531
  // src/translator/util/sections.ts
3526
3532
  const sectionUtil = new Sorted(function compareSections(a, b) {
3527
3533
  return a.id - b.id;
@@ -3556,7 +3562,7 @@ function ensureBodySection(path) {
3556
3562
  reason: void 0,
3557
3563
  paramReasonGroups: void 0,
3558
3564
  returnValueExpr: void 0,
3559
- content: getContentInfo(path),
3565
+ content: void 0,
3560
3566
  branchExpr: void 0,
3561
3567
  renderedBy: void 0,
3562
3568
  knownTags: void 0,
@@ -3629,6 +3635,10 @@ function forEachSectionReverse(fn) {
3629
3635
  const { sections } = (0, _marko_compiler_babel_utils.getProgram)().node.extra;
3630
3636
  for (let i = sections.length; i--;) fn(sections[i]);
3631
3637
  }
3638
+ function settleContent(body) {
3639
+ const section = getSectionForBody(body);
3640
+ if (section) section.content = getContentInfo(body);
3641
+ }
3632
3642
  function getContentInfo(path) {
3633
3643
  const body = path.get("body");
3634
3644
  for (let endIndex = body.length; endIndex--;) {
@@ -3643,8 +3653,7 @@ function getContentInfo(path) {
3643
3653
  singleChild: false
3644
3654
  };
3645
3655
  }
3646
- const knownChild = end.type === "MarkoTag" && getKnownChildSection(end);
3647
- return knownChild ? knownChild.content : {
3656
+ return end.type === "MarkoTag" && getKnownChildContent(end) || {
3648
3657
  startType: endType,
3649
3658
  endType,
3650
3659
  singleChild: endType !== 1
@@ -3665,9 +3674,8 @@ function getNodeContentType(path, edge) {
3665
3674
  case "ExportDefaultDeclaration": return null;
3666
3675
  case "MarkoTag": {
3667
3676
  const tag = path;
3668
- const tagSection = getKnownChildSection(tag);
3669
- if (!tagSection) return getTagContentType(tag);
3670
- return tagSection.content ? tagSection.content[edge] : null;
3677
+ const content = getKnownChildContent(tag);
3678
+ return content === void 0 ? getTagContentType(tag) : content && content[edge];
3671
3679
  }
3672
3680
  }
3673
3681
  return 1;
@@ -3736,8 +3744,15 @@ function getInlinedBodyTag(parent) {
3736
3744
  function mayRenderText(contentType) {
3737
3745
  return contentType === 4 || contentType === 1 || contentType === 2;
3738
3746
  }
3739
- function getKnownChildSection(tag) {
3740
- return tag.node.extra?.defineBodySection || !isCoreTag(tag) && analyzeTagNameType(tag) === 1 && !tag.node.extra.tagNameLoad && (0, _marko_compiler_babel_utils.loadFileForTag)(tag).ast.program.extra.section;
3747
+ function getKnownChildContent(tag) {
3748
+ const section = tag.node.extra?.defineBodySection || !isCoreTag(tag) && analyzeTagNameType(tag) === 1 && !tag.node.extra.tagNameLoad && (0, _marko_compiler_babel_utils.loadFileForTag)(tag).ast.program.extra.section;
3749
+ if (!section) return;
3750
+ if (section.content !== void 0) return section.content;
3751
+ let body = tag.parentPath;
3752
+ while (body.type === "MarkoTagBody") {
3753
+ body = body.parentPath.parentPath;
3754
+ if (body.node.extra?.section === section) return getContentInfo(body);
3755
+ }
3741
3756
  }
3742
3757
  function getRendererReason(section) {
3743
3758
  if (isOptionalBranch(section)) return false;
@@ -3810,10 +3825,13 @@ function ensureParamReasonGroup(section, group) {
3810
3825
  if (groups !== paramReasonGroups) setParamReasonGroups(section, groups);
3811
3826
  }
3812
3827
  function getParamReasonGroupIndex(section, group) {
3813
- const index = section.paramReasonGroups && findIndexSorted(compareReferences, section.paramReasonGroups, group);
3814
- if (index === void 0 || index === -1) throw new Error("Invalid compiler state, cannot ask for a param reason group that was not analyzed.");
3828
+ const index = findParamReasonGroupIndex(section, group);
3829
+ if (index === -1) throw new Error("Invalid compiler state, cannot ask for a param reason group that was not analyzed.");
3815
3830
  return index;
3816
3831
  }
3832
+ function findParamReasonGroupIndex(section, group) {
3833
+ return section.paramReasonGroups ? findIndexSorted(compareReferences, section.paramReasonGroups, group) : -1;
3834
+ }
3817
3835
  function forEachParamGroup(params, fn) {
3818
3836
  bindingUtil.forEachRun(params, bindingToSection, sectionUtil.compare, fn);
3819
3837
  }
@@ -3896,8 +3914,8 @@ function exposeParamsTree(binding, bodyAnalyzed) {
3896
3914
  }
3897
3915
  function isDirectContentBinding(binding) {
3898
3916
  if (binding.reads.size !== 1) return false;
3899
- const [read] = binding.reads.keys();
3900
- return read.nameOnly && read.section === binding.section;
3917
+ const [[expr, read]] = binding.reads;
3918
+ return expr.nameOnly && expr.section === binding.section && !Array.isArray(read) && !!read.extra.tagName;
3901
3919
  }
3902
3920
  function isPossiblyRead(alias) {
3903
3921
  if (alias.reads.size) return true;
@@ -4466,7 +4484,7 @@ function pruneBinding(binding) {
4466
4484
  forEach(binding.assignments, pruneAssignmentDerived);
4467
4485
  const assignedObject = getAssignedObject(binding);
4468
4486
  for (const [expr, reads] of binding.reads) {
4469
- const ancestor = assignedObject ? getNearestReadBy(assignedObject, expr) || assignedObject : getNearestReadBy(binding.aliasOf, expr);
4487
+ const ancestor = assignedObject ? getNearestReadBy(assignedObject, expr) || assignedObject : binding.aliasOf && !isRest(binding) && getNearestReadBy(binding.aliasOf, expr);
4470
4488
  if (ancestor) {
4471
4489
  ancestor.reads.set(expr, concat(ancestor.reads.get(expr), reads));
4472
4490
  binding.reads.delete(expr);
@@ -4509,7 +4527,12 @@ function resolveReferencedBindingsInFunction(expr, refs, reads) {
4509
4527
  };
4510
4528
  }
4511
4529
  function getNearestReadBy(binding, expr) {
4512
- for (let cur = binding; cur; cur = cur.aliasOf) if (cur.reads.has(expr)) return cur;
4530
+ let cur = binding;
4531
+ while (!cur.reads.has(expr)) {
4532
+ if (!cur.aliasOf || isRest(cur)) return;
4533
+ cur = cur.aliasOf;
4534
+ }
4535
+ return cur;
4513
4536
  }
4514
4537
  function markLazyRead(binding) {
4515
4538
  getCanonicalBinding(binding).hasLazyReads = true;
@@ -4546,10 +4569,8 @@ function resolveReferencedBindings(expr, reads, intersectionsBySection) {
4546
4569
  }
4547
4570
  } else {
4548
4571
  const isChangeHandlerRead = extra.assignmentTo === binding;
4549
- if (isChangeHandlerRead) {
4550
- const ancestor = getNearestReadBy(binding.aliasOf, expr);
4551
- if (ancestor) binding = ancestor;
4552
- } else if (binding.type !== 6) {
4572
+ if (isChangeHandlerRead) binding = getNearestReadBy(binding, expr);
4573
+ else if (binding.type !== 6) {
4553
4574
  extra.section = expr.section;
4554
4575
  ({binding} = extra.read = resolveConstantReference(binding) ?? resolveExpressionReference(expr, read));
4555
4576
  }
@@ -4607,8 +4628,8 @@ function getConstantRoot(binding) {
4607
4628
  return root;
4608
4629
  }
4609
4630
  function resolveExpressionReference(expr, { binding, inOwnBody }) {
4610
- const ancestor = getNearestReadBy(binding.aliasOf, expr);
4611
- return ancestor ? createResolvedRead(ancestor, getPropertyPath(binding, ancestor)) : createResolvedRead(binding, void 0, inOwnBody);
4631
+ const holder = getNearestReadBy(binding, expr);
4632
+ return holder === binding ? createResolvedRead(binding, void 0, inOwnBody) : createResolvedRead(holder, getPropertyPath(binding, holder));
4612
4633
  }
4613
4634
  // src/translator/util/get-declared-binding-expression.ts
4614
4635
  function getDeclaredBindingExpression(binding, inPlace = false) {
@@ -4811,7 +4832,7 @@ function translateRest(tag, id, rest, kind) {
4811
4832
  const from = getDeclaredAlias(source) || source;
4812
4833
  let target = tag;
4813
4834
  let inPlace = true;
4814
- if (rest.section !== getSection(tag) && getWriteReason(rest)) {
4835
+ if (rest.section !== getSection(tag) && isEverWritten(rest.section, getWriteReason(rest))) {
4815
4836
  target = getSectionTarget(tag, rest.section);
4816
4837
  inPlace = false;
4817
4838
  }
@@ -5083,7 +5104,7 @@ function getSignal(section, referencedBindings, name) {
5083
5104
  }
5084
5105
  function isChangeableDynamicClosure(section, closure) {
5085
5106
  const { sources } = closure;
5086
- return !!sources && isDynamicClosure(section, closure) && (!sources.state || some(sources.state, hasResumableAssignment));
5107
+ return !!sources && isDynamicClosure(section, closure) && (!sources.state || some(sources.state, hasResumableWriter));
5087
5108
  }
5088
5109
  function initValue(binding, isLet = false) {
5089
5110
  const section = binding.section;
@@ -5690,10 +5711,10 @@ function getKnownAttrValues(tag) {
5690
5711
  }
5691
5712
  // src/translator/util/translate-attrs.ts
5692
5713
  const contentProps = /* @__PURE__ */ new WeakSet();
5693
- function translateAttrs(tag, paramsTree = true, skip, statements = [], contentKey = "content") {
5714
+ function translateAttrs(tag, paramsTree = true, statements = [], contentKey = "content") {
5694
5715
  const contentProperties = [];
5695
5716
  const attrTagLookup = tag.node.extra?.attrTagLookup;
5696
- const seen = toSet(skip);
5717
+ const seen = /* @__PURE__ */ new Set();
5697
5718
  if (attrTagLookup) {
5698
5719
  for (const name in attrTagLookup) {
5699
5720
  const attrTagMeta = attrTagLookup[name];
@@ -5711,10 +5732,9 @@ function translateAttrs(tag, paramsTree = true, skip, statements = [], contentKe
5711
5732
  if (child.isMarkoTag()) {
5712
5733
  if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
5713
5734
  const attrTagMeta = attrTagLookup[getTagName(child)];
5714
- if (propertiesUtil.has(skip, attrTagMeta.name)) continue;
5715
5735
  if (attrTagMeta.dynamic) i = addDynamicAttrTagStatements(attrTags, i, attrTagLookup, statements, paramsTree, contentKey);
5716
5736
  else {
5717
- const translatedAttrTag = translateAttrs(child, getParamsTreeAt(paramsTree, attrTagMeta.name), void 0, statements, contentKey);
5737
+ const translatedAttrTag = translateAttrs(child, getParamsTreeAt(paramsTree, attrTagMeta.name), statements, contentKey);
5718
5738
  addAttrTag(contentProperties, attrTagMeta, _marko_compiler.types.objectExpression(translatedAttrTag.properties));
5719
5739
  }
5720
5740
  } else i = addDynamicAttrTagStatements(attrTags, i, attrTagLookup, statements, paramsTree, contentKey);
@@ -5732,11 +5752,11 @@ function translateAttrs(tag, paramsTree = true, skip, statements = [], contentKe
5732
5752
  }
5733
5753
  const { attributes } = tag.node;
5734
5754
  const attrProperties = [];
5735
- const knownSpread = getSingleKnownSpread(paramsTree, attributes);
5736
5755
  for (let i = attributes.length; i--;) {
5737
5756
  const attr = attributes[i];
5738
5757
  const { value } = attr;
5739
- if (_marko_compiler.types.isMarkoSpreadAttribute(attr) && knownSpread) {
5758
+ if (_marko_compiler.types.isMarkoSpreadAttribute(attr) && attr.extra?.knownSpread) {
5759
+ const { knownSpread } = attr.extra;
5740
5760
  if (!getCanonicalBinding(knownSpread).pruned) attrProperties.push(_marko_compiler.types.spreadElement(getDeclaredBindingExpression(knownSpread, true)));
5741
5761
  } else if (!value.extra?.dropped) {
5742
5762
  if (_marko_compiler.types.isMarkoSpreadAttribute(attr)) attrProperties.push(_marko_compiler.types.spreadElement(value));
@@ -5761,7 +5781,7 @@ function addDynamicAttrTagStatements(attrTags, index, attrTagLookup, statements,
5761
5781
  const attrTagMeta = attrTagLookup[getTagName(tag)];
5762
5782
  const attrTagTree = getParamsTreeAt(paramsTree, attrTagMeta.name);
5763
5783
  if (attrTagTree && attrTagMeta.dynamic) {
5764
- const translatedAttrTag = translateAttrs(tag, attrTagTree, void 0, statements, contentKey);
5784
+ const translatedAttrTag = translateAttrs(tag, attrTagTree, statements, contentKey);
5765
5785
  statements.push(_marko_compiler.types.expressionStatement(_marko_compiler.types.assignmentExpression("=", getAttrTagIdentifier(attrTagMeta), appendAttrTag(attrTagMeta.repeated && getAttrTagIdentifier(attrTagMeta), _marko_compiler.types.objectExpression(translatedAttrTag.properties)))));
5766
5786
  }
5767
5787
  } else switch (getTagName(tag)) {
@@ -5863,19 +5883,6 @@ function getLocalClosureValues(bodySection) {
5863
5883
  function toLocalClosureProperty(closure) {
5864
5884
  return toObjectProperty(getScopeAccessor(closure, true), getDeclaredBindingExpression(closure));
5865
5885
  }
5866
- function getSingleKnownSpread(paramsTree, attributes) {
5867
- if (paramsTree === true || !hasAllKnownProperties(paramsTree)) return;
5868
- let binding;
5869
- for (let i = attributes.length; i--;) {
5870
- const attr = attributes[i];
5871
- if (attr.type === "MarkoSpreadAttribute") {
5872
- const spreadFrom = attr.value.extra?.spreadFrom;
5873
- if (binding || !spreadFrom || Array.isArray(spreadFrom)) return;
5874
- binding = spreadFrom;
5875
- } else if (binding && !propertiesUtil.has(binding.excludeProperties, attr.name)) return;
5876
- }
5877
- return binding;
5878
- }
5879
5886
  // src/translator/util/known-tag.ts
5880
5887
  const [getTagVarBindings] = createOutputSectionState(() => []);
5881
5888
  const [getCallSiteSourcesByParam] = createAnalysisState(() => /* @__PURE__ */ new Map());
@@ -6028,7 +6035,6 @@ function knownTagTranslateDOM(tag, getBindingIdentifier, callSetup) {
6028
6035
  callSetup?.(tagSection, childScopeBinding);
6029
6036
  if (paramsTree) writeParamsToSignals(tag, paramsTree, getTagName(tag) || "tag", {
6030
6037
  tagSection,
6031
- knownExprs: extra[kKnownExprs],
6032
6038
  getBindingIdentifier,
6033
6039
  childScopeBinding
6034
6040
  });
@@ -6236,9 +6242,11 @@ function analyzeAttrs(rootTagExtra, section, tag, paramsTree, rootAttrExprs, roo
6236
6242
  }
6237
6243
  } else if (spreadReferenceNodes) spreadReferenceNodes.push(attr.value);
6238
6244
  else {
6239
- knownSpread = getSingleKnownSpread(paramsTree, attributes);
6240
- if (knownSpread) dropNodes(attr.value);
6241
- else (spreadReferenceNodes = restReferenceNodes || []).push(attr.value);
6245
+ knownSpread = getKnownSpread(paramsTree, attributes, i);
6246
+ if (knownSpread) {
6247
+ (attr.extra ??= {}).knownSpread = knownSpread;
6248
+ dropNodes(attr.value);
6249
+ } else (spreadReferenceNodes = restReferenceNodes || []).push(attr.value);
6242
6250
  }
6243
6251
  }
6244
6252
  if (knownSpread) for (const prop of remaining) {
@@ -6253,11 +6261,13 @@ function analyzeAttrs(rootTagExtra, section, tag, paramsTree, rootAttrExprs, roo
6253
6261
  else if (spreadReferenceNodes) {
6254
6262
  if (remaining.size || paramsTree.rest && !paramsTree.rest.properties) {
6255
6263
  inputExpr.value = mergeReferences(section, tag.node, spreadReferenceNodes);
6264
+ rootAttrExprs.add(inputExpr.value);
6256
6265
  setDerivedFrom(paramsTree.rest?.binding || paramsTree.binding, inputExpr.value, rootExprs);
6257
6266
  } else dropNodes(spreadReferenceNodes);
6258
6267
  } else {
6259
6268
  if (restReferenceNodes) {
6260
6269
  inputExpr.value = mergeReferences(section, tag.node, restReferenceNodes);
6270
+ rootAttrExprs.add(inputExpr.value);
6261
6271
  setDerivedFrom(paramsTree.rest.binding, inputExpr.value, rootExprs);
6262
6272
  }
6263
6273
  if (remaining.size) addSetupWork(section);
@@ -6266,6 +6276,15 @@ function analyzeAttrs(rootTagExtra, section, tag, paramsTree, rootAttrExprs, roo
6266
6276
  dropNodes(dropReferenceNodes);
6267
6277
  return inputExpr;
6268
6278
  }
6279
+ function getKnownSpread(paramsTree, attributes, index) {
6280
+ const binding = attributes[index].value.extra?.spreadFrom;
6281
+ if (!binding || Array.isArray(binding) || !hasAllKnownProperties(paramsTree)) return;
6282
+ for (let i = index; i--;) {
6283
+ const attr = attributes[i];
6284
+ if (attr.type === "MarkoSpreadAttribute" || !propertiesUtil.has(binding.excludeProperties, attr.name)) return;
6285
+ }
6286
+ return binding;
6287
+ }
6269
6288
  function readsParamsByName(tag, paramsTree) {
6270
6289
  return !!paramsTree.properties && !paramsTree.rest && !tag.node.arguments?.some(isSpreadArgument);
6271
6290
  }
@@ -6322,8 +6341,8 @@ function writeParamsToSignals(tag, paramsTree, hint, info) {
6322
6341
  i++;
6323
6342
  }
6324
6343
  const attrsTree = paramsTree.properties[i];
6325
- if (attrsTree && tag.node.extra[kPassesInput]) writeAttrsToSignals(tag, attrsTree, `${hint}_input`, info);
6326
6344
  const { known } = tag.node.extra[kKnownExprs];
6345
+ if (attrsTree && tag.node.extra[kPassesInput]) writeAttrsToSignals(tag, attrsTree, known[i], `${hint}_input`, info);
6327
6346
  for (const key in paramsTree.properties) if (!known[key]) writeToSignal(info, info.getBindingIdentifier(paramsTree.properties[key].binding, `${hint}_param_${key}`), void 0, void 0, true);
6328
6347
  }
6329
6348
  function applyAttrObject(tag, paramsTree, tagInputIdentifier, info) {
@@ -6332,12 +6351,12 @@ function applyAttrObject(tag, paramsTree, tagInputIdentifier, info) {
6332
6351
  let translatedProps;
6333
6352
  if ((0, _marko_compiler_babel_utils.isAttributeTag)(tag)) {
6334
6353
  const attrTagName = getTagName(tag);
6335
- for (const attrTag of tag.parentPath.get("attributeTags")) if (attrTag.isMarkoTag() && getTagName(attrTag) === attrTagName) translatedProps = appendAttrTag(translatedProps, _marko_compiler.types.objectExpression(translateAttrs(attrTag, paramsTree, void 0, statements).properties));
6336
- } else translatedProps = propsToExpression(translateAttrs(tag, paramsTree, void 0, statements).properties);
6354
+ for (const attrTag of tag.parentPath.get("attributeTags")) if (attrTag.isMarkoTag() && getTagName(attrTag) === attrTagName) translatedProps = appendAttrTag(translatedProps, _marko_compiler.types.objectExpression(translateAttrs(attrTag, paramsTree, statements).properties));
6355
+ } else translatedProps = propsToExpression(translateAttrs(tag, paramsTree, statements).properties);
6337
6356
  if (statements.length) addStatement("render", info.tagSection, tagExtra, statements);
6338
6357
  writeToSignal(info, tagInputIdentifier, tagExtra, translatedProps, true);
6339
6358
  }
6340
- function writeAttrsToSignals(tag, paramsTree, hint, info) {
6359
+ function writeAttrsToSignals(tag, paramsTree, exprs, hint, info) {
6341
6360
  if (!paramsTree.properties) {
6342
6361
  applyAttrObject(tag, paramsTree, info.getBindingIdentifier(paramsTree.binding, hint), info);
6343
6362
  return;
@@ -6376,27 +6395,16 @@ function writeAttrsToSignals(tag, paramsTree, hint, info) {
6376
6395
  if (!childAttrTree) {} else if (attrTagMeta.dynamic) i = translateDynamicAttrTagChildInGroup(attrTagMeta.group, i);
6377
6396
  else if (childAttrTree === true) {
6378
6397
  const statements = [];
6379
- const translatedAttrs = translateAttrs(child, true, void 0, statements);
6398
+ const translatedAttrs = translateAttrs(child, true, statements);
6380
6399
  addStatement("render", info.tagSection, tagExtra, statements);
6381
6400
  addAttrTag(contentProps, attrTagMeta, _marko_compiler.types.objectExpression(translatedAttrs.properties));
6382
- } else if (attrTagMeta.repeated && (!childAttrTree.properties || childAttrTree.rest)) {
6383
- if (remaining.delete(attrTagMeta.name)) applyAttrObject(child, childAttrTree, info.getBindingIdentifier(childAttrTree.binding, `${hint}_${attrTagMeta.name}`), info);
6384
- } else {
6401
+ } else if (exprs.known[attrTagMeta.name].known) {
6385
6402
  remaining.delete(attrTagMeta.name);
6386
- writeAttrsToSignals(child, childAttrTree, `${hint}_${attrTagMeta.name}`, info);
6387
- }
6403
+ writeAttrsToSignals(child, childAttrTree, exprs.known[attrTagMeta.name], `${hint}_${attrTagMeta.name}`, info);
6404
+ } else if (remaining.delete(attrTagMeta.name)) applyAttrObject(child, childAttrTree, info.getBindingIdentifier(childAttrTree.binding, `${hint}_${attrTagMeta.name}`), info);
6388
6405
  } else {
6389
6406
  const group = child.node.extra.attributeTagGroup;
6390
6407
  if (hasGroupReads(group, attrTagLookup, paramsTree)) i = translateDynamicAttrTagChildInGroup(group, i);
6391
- else if (getTagName(child) === "if") while (++i < attrTags.length) {
6392
- const nextTag = attrTags[i];
6393
- switch (nextTag.isMarkoTag() && getTagName(nextTag)) {
6394
- case "else":
6395
- case "else-if": continue;
6396
- }
6397
- i--;
6398
- break;
6399
- }
6400
6408
  }
6401
6409
  }
6402
6410
  }
@@ -6437,13 +6445,10 @@ function writeAttrsToSignals(tag, paramsTree, hint, info) {
6437
6445
  seen.add(attr.name);
6438
6446
  if (hasSpread || attrTree === true) attrProps.push(toObjectProperty(attr.name, attr.value));
6439
6447
  else staticAttrs.push(attr);
6440
- } else if (hasSpread) attrProps.push(_marko_compiler.types.spreadElement(attr.value));
6448
+ } else if (attr.extra?.knownSpread) knownSpread = attr.extra.knownSpread;
6441
6449
  else {
6442
- knownSpread = getSingleKnownSpread(paramsTree, attributes);
6443
- if (!knownSpread) {
6444
- hasSpread = true;
6445
- attrProps.push(_marko_compiler.types.spreadElement(attr.value));
6446
- }
6450
+ hasSpread = true;
6451
+ attrProps.push(_marko_compiler.types.spreadElement(attr.value));
6447
6452
  }
6448
6453
  }
6449
6454
  const inputProps = attrProps.reverse().concat(contentProps);
@@ -6456,7 +6461,7 @@ function writeAttrsToSignals(tag, paramsTree, hint, info) {
6456
6461
  if (knownSpread) for (const prop of remaining) {
6457
6462
  const propSignal = getSignalIdentifier(info, paramsTree, hint, prop);
6458
6463
  const propBinding = getPropertyAlias(knownSpread, prop);
6459
- writeToSignal(info, propSignal, getKnownExprsAt(info.knownExprs, getParamsTreeAt(paramsTree, prop).binding).value, createScopeReadExpression(propBinding, info.tagSection), true);
6464
+ writeToSignal(info, propSignal, exprs.known[prop].value, createScopeReadExpression(propBinding, info.tagSection), true);
6460
6465
  }
6461
6466
  else if (hasSpread && (remaining.size || paramsTree.rest && !paramsTree.rest.properties)) {
6462
6467
  const spreadExpr = propsToExpression(inputProps);
@@ -6467,15 +6472,9 @@ function writeAttrsToSignals(tag, paramsTree, hint, info) {
6467
6472
  }
6468
6473
  for (const name of remaining) writeToSignal(info, getSignalIdentifier(info, paramsTree, hint, name), tagExtra, toMemberExpression(_marko_compiler.types.cloneNode(spreadId, true), name));
6469
6474
  if (paramsTree.rest && !paramsTree.rest.properties) {
6470
- const props = [];
6471
- const restId = _marko_compiler.types.identifier(paramsTree.rest.binding.name);
6472
- forEach(paramsTree.rest.binding.excludeProperties, (name) => {
6473
- const propId = toPropertyName(name);
6474
- const shorthand = propId.type === "Identifier" && _marko_compiler.types.isValidIdentifier(name);
6475
- props.push(_marko_compiler.types.objectProperty(propId, shorthand ? propId : generateUidIdentifier(name), false, shorthand));
6476
- });
6477
- props.push(_marko_compiler.types.restElement(restId));
6478
- writeToSignal(info, info.getBindingIdentifier(paramsTree.rest.binding, hint + "_$rest"), tagExtra, _marko_compiler.types.callExpression(_marko_compiler.types.arrowFunctionExpression([_marko_compiler.types.objectPattern(props)], restId), [spreadId]), true);
6475
+ const rest = paramsTree.rest.binding;
6476
+ const restId = _marko_compiler.types.identifier(rest.name);
6477
+ writeToSignal(info, info.getBindingIdentifier(rest, hint + "_$rest"), tagExtra, _marko_compiler.types.callExpression(_marko_compiler.types.arrowFunctionExpression([getRestPattern(rest, restId, paramsTree.binding, true)], restId), [spreadId]), true);
6479
6478
  }
6480
6479
  } else {
6481
6480
  for (const name of remaining) writeToSignal(info, getSignalIdentifier(info, paramsTree, hint, name), void 0);
@@ -6541,14 +6540,15 @@ function mapBodyParams(section, reason, seen) {
6541
6540
  let mapped;
6542
6541
  const params = bindingUtil.filter(reason.param, (param) => {
6543
6542
  if (isSameOrAncestorSection(param.section, section)) return true;
6544
- if (!(seen ||= /* @__PURE__ */ new Set()).has(param)) {
6543
+ seen ??= /* @__PURE__ */ new Set();
6544
+ if (!seen.has(param)) {
6545
6545
  seen.add(param);
6546
6546
  mapped = mergeSources(mapped, getCallSiteSources(param));
6547
6547
  }
6548
6548
  return false;
6549
6549
  });
6550
6550
  if (params === reason.param) return reason;
6551
- return mergeSources(mapBodyParams(section, mapped, seen), withSources(reason, reason.state, params)) || ALWAYS;
6551
+ return mergeSources(mapBodyParams(section, mapped, seen), withSources(reason, reason.state, params));
6552
6552
  }
6553
6553
  function isGuardedReason(reason) {
6554
6554
  return !!reason && !reason.always && !reason.state;
@@ -6875,7 +6875,7 @@ function resumeOwnerByMarkerWhenUnconditional(bodySection, nodeBinding) {
6875
6875
  if (!isStateReason(branchExprReason)) return;
6876
6876
  const branchReason = getBranchWriteReason(bodySection);
6877
6877
  const nodeReason = getWriteReason(nodeBinding);
6878
- if (branchReason && !isGuardedReason(branchReason) && nodeReason && !isGuardedReason(nodeReason) && some(branchExprReason.state, hasResumableAssignment)) setSectionOwnerResumedByMarker(bodySection);
6878
+ if (branchReason && !isGuardedReason(branchReason) && nodeReason && !isGuardedReason(nodeReason) && some(branchExprReason.state, hasResumableWriter)) setSectionOwnerResumedByMarker(bodySection);
6879
6879
  }
6880
6880
  function getBranchResumeArgs(tag, branchReasons, singleNode) {
6881
6881
  const tagSection = getSection(tag);
@@ -6969,6 +6969,7 @@ const docsAnchors = {
6969
6969
  attrs: ""
6970
6970
  };
6971
6971
  const languageDocsURL = "https://markojs.com/docs/reference/language";
6972
+ const nativeTagDocsURL = "https://markojs.com/docs/reference/native-tag";
6972
6973
  const valueAttrLink = `[\`value=\` attribute](${languageDocsURL}#shorthand-value)`;
6973
6974
  function assertNoSpreadAttrs(tag) {
6974
6975
  const { attributes } = tag.node;
@@ -7012,6 +7013,13 @@ function assertHasBody(tag) {
7012
7013
  function assertNoBodyContent(tag) {
7013
7014
  if (tag.node.body.body.length) throw tag.get("name").buildCodeFrameError(`The ${coreTagLink(tag)} does not support body content.`);
7014
7015
  }
7016
+ function assertNoNativeAttrTags(tag) {
7017
+ const takesContent = `take their content from their body or the [\`content=\` attribute](${nativeTagDocsURL}#content)`;
7018
+ (0, _marko_compiler_babel_utils.assertNoAttributeTags)(tag, isStaticNativeTag(tag) ? `[Native tags](${nativeTagDocsURL}) ${takesContent}.` : `This dynamic tag only renders [native tags](${nativeTagDocsURL}), which ${takesContent}.`);
7019
+ }
7020
+ function assertNotContentAttrTag(tag) {
7021
+ if (getTagName(tag) === "@content") throw tag.get("name").buildCodeFrameError(`The \`<@content>\` [attribute tag](${languageDocsURL}#attribute-tags) is not supported, since a tag's \`content\` is its [body content](${languageDocsURL}#tag-content). Write it as the tag's body, or pass it with a \`content=\` attribute.`);
7022
+ }
7015
7023
  function buildAttrsError(tag, attrs, msg) {
7016
7024
  return buildRangeError(tag, attrs[0].loc?.start, attrs[attrs.length - 1].loc?.end, msg);
7017
7025
  }
@@ -7607,27 +7615,7 @@ const IfTag = {
7607
7615
  }
7608
7616
  } }
7609
7617
  }),
7610
- parseOptions: { controlFlow: true },
7611
- autocomplete: [{
7612
- snippet: "if=${1:condition}",
7613
- description: "Use to display content only if the condition is met.",
7614
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#if--else"
7615
- }]
7616
- };
7617
- const ElseIfTag = {
7618
- ...IfTag,
7619
- autocomplete: [{
7620
- snippet: "else-if=${1:condition}",
7621
- description: "Use after an <if> or <else-if> tag to display content if those conditions do not match and this one does.",
7622
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#if--else"
7623
- }]
7624
- };
7625
- const ElseTag = {
7626
- ...IfTag,
7627
- autocomplete: [{
7628
- description: "Use after an <if> or <else-if> tag to display content if those conditions do not match.",
7629
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#if--else"
7630
- }]
7618
+ parseOptions: { controlFlow: true }
7631
7619
  };
7632
7620
  function flattenTextOnlyConditional(rootTag) {
7633
7621
  if (!isCoreTagName(rootTag, "if")) return;
@@ -7781,6 +7769,7 @@ function insertStaticText(placeholder, value, before) {
7781
7769
  else placeholder.insertAfter(_marko_compiler.types.markoText(value));
7782
7770
  }
7783
7771
  function normalizeTag(tag) {
7772
+ assertNotContentAttrTag(tag);
7784
7773
  const { node } = tag;
7785
7774
  const { name, attributes } = node;
7786
7775
  let invalidNameReg = invalidAttrNameReg;
@@ -7984,29 +7973,21 @@ function toConstTag(id, expr) {
7984
7973
  return _marko_compiler.types.markoTag(_marko_compiler.types.stringLiteral("const"), [_marko_compiler.types.markoAttribute("value", expr, null, null, true)], _marko_compiler.types.markoTagBody(), null, id);
7985
7974
  }
7986
7975
  // src/translator/core/attrs.ts
7987
- var attrs_default = {
7988
- migrate: (tag) => {
7989
- (0, _marko_compiler_babel_utils.assertNoArgs)(tag);
7990
- (0, _marko_compiler_babel_utils.assertNoParams)(tag);
7991
- (0, _marko_compiler_babel_utils.assertNoAttributes)(tag);
7992
- assertNoBodyContent(tag);
7993
- (0, _marko_compiler_babel_utils.assertNoAttributeTags)(tag);
7994
- (0, _marko_compiler_babel_utils.diagnosticDeprecate)(tag, {
7995
- label: "The `attrs` tag is deprecated, prefer destructuring `input` via the `const` tag.",
7996
- fix() {
7997
- const tagVar = tag.node.var;
7998
- if (tagVar && !(tagVar.type === "Identifier" && tagVar.name === "input")) tag.replaceWith(toConstTag(tagVar, _marko_compiler.types.identifier("input")));
7999
- else tag.remove();
8000
- }
8001
- });
8002
- },
8003
- attributes: {},
8004
- autocomplete: [{
8005
- displayText: "attrs/{ ... }",
8006
- description: "Use to receive the attributes passed into this template.",
8007
- snippet: "attrs/{ $1 }$2"
8008
- }]
8009
- };
7976
+ var attrs_default = { migrate: (tag) => {
7977
+ (0, _marko_compiler_babel_utils.assertNoArgs)(tag);
7978
+ (0, _marko_compiler_babel_utils.assertNoParams)(tag);
7979
+ (0, _marko_compiler_babel_utils.assertNoAttributes)(tag);
7980
+ assertNoBodyContent(tag);
7981
+ (0, _marko_compiler_babel_utils.assertNoAttributeTags)(tag);
7982
+ (0, _marko_compiler_babel_utils.diagnosticDeprecate)(tag, {
7983
+ label: "The `attrs` tag is deprecated, prefer destructuring `input` via the `const` tag.",
7984
+ fix() {
7985
+ const tagVar = tag.node.var;
7986
+ if (tagVar && !(tagVar.type === "Identifier" && tagVar.name === "input")) tag.replaceWith(toConstTag(tagVar, _marko_compiler.types.identifier("input")));
7987
+ else tag.remove();
7988
+ }
7989
+ });
7990
+ } };
8010
7991
  // src/translator/core/await.ts
8011
7992
  var await_default = {
8012
7993
  analyze(tag) {
@@ -8074,11 +8055,6 @@ var await_default = {
8074
8055
  replaceWithStatements(tag);
8075
8056
  } }
8076
8057
  }),
8077
- attributes: {},
8078
- autocomplete: [{
8079
- description: "Use to consume asynchronous data.",
8080
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#await"
8081
- }],
8082
8058
  types: runtime_info_default.name + "/tags/await.d.marko"
8083
8059
  };
8084
8060
  // src/translator/core/class.ts
@@ -8117,12 +8093,7 @@ function createStatementTag(keyword) {
8117
8093
  parseOptions: {
8118
8094
  statement: true,
8119
8095
  rawOpenTag: true
8120
- },
8121
- autocomplete: [{
8122
- displayText: `${keyword} <statement>`,
8123
- description: `A JavaScript statement which is only evaluated once your template is loaded${target ? ` on the ${target}` : ""}.`,
8124
- descriptionMoreURL: `https://markojs.com/docs/reference/language#${keyword === "static" ? "static" : "server-and-client"}`
8125
- }]
8096
+ }
8126
8097
  };
8127
8098
  }
8128
8099
  // src/translator/core/client.ts
@@ -8167,11 +8138,6 @@ var const_default = {
8167
8138
  replaceWithStatements(tag);
8168
8139
  } },
8169
8140
  parseOptions: { openTagOnly: true },
8170
- attributes: {},
8171
- autocomplete: [{
8172
- description: "Use to create a constant binding.",
8173
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#const"
8174
- }],
8175
8141
  types: runtime_info_default.name + "/tags/const.d.marko"
8176
8142
  };
8177
8143
  function getVarHint(tag) {
@@ -8195,11 +8161,6 @@ var debug_default = {
8195
8161
  addTagStatement(tag, withPreviousLocation(_marko_compiler.types.debuggerStatement(), tag.node));
8196
8162
  } },
8197
8163
  parseOptions: { openTagOnly: true },
8198
- attributes: {},
8199
- autocomplete: [{
8200
- description: "Debug on value change.",
8201
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#debug"
8202
- }],
8203
8164
  types: runtime_info_default.name + "/tags/debug.d.marko"
8204
8165
  };
8205
8166
  // src/translator/core/define.ts
@@ -8215,6 +8176,7 @@ var define_default = {
8215
8176
  return;
8216
8177
  }
8217
8178
  assertNoTagVarMutation(tag);
8179
+ varBinding.nullable = false;
8218
8180
  const babelBinding = _marko_compiler.types.isIdentifier(tag.node.var) && tag.scope.getBinding(tag.node.var.name);
8219
8181
  if (babelBinding && !babelBinding.referencePaths.length) {
8220
8182
  dropContent(tag.node.body);
@@ -8292,11 +8254,6 @@ var define_default = {
8292
8254
  }
8293
8255
  }
8294
8256
  },
8295
- attributes: {},
8296
- autocomplete: [{
8297
- description: "Use to create a constant object binding that can be rendered.",
8298
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#define"
8299
- }],
8300
8257
  types: runtime_info_default.name + "/tags/define.d.marko"
8301
8258
  };
8302
8259
  // src/translator/core/effect.ts
@@ -8316,7 +8273,6 @@ var effect_default = {
8316
8273
  }
8317
8274
  });
8318
8275
  },
8319
- attributes: {},
8320
8276
  types: runtime_info_default.name + "/tags/effect.d.marko"
8321
8277
  };
8322
8278
  // src/translator/core/export.ts
@@ -8330,8 +8286,7 @@ var export_default = {
8330
8286
  parseOptions: {
8331
8287
  statement: true,
8332
8288
  rawOpenTag: true
8333
- },
8334
- autocomplete: [{ displayText: "export <value>" }]
8289
+ }
8335
8290
  };
8336
8291
  function getDefaultExport(statement) {
8337
8292
  if (statement.type === "ExportDefaultDeclaration") return statement;
@@ -8450,52 +8405,7 @@ var for_default = {
8450
8405
  }
8451
8406
  }
8452
8407
  }),
8453
- parseOptions: { controlFlow: true },
8454
- attributes: {
8455
- of: {
8456
- type: "expression",
8457
- autocomplete: [{ description: "Iterates over a list of items." }]
8458
- },
8459
- in: {
8460
- type: "expression",
8461
- autocomplete: [{ description: "Iterates over the keys and values of an object." }]
8462
- },
8463
- to: {
8464
- type: "number",
8465
- autocomplete: [{ description: "Iterates up to the provided number (inclusive)" }]
8466
- },
8467
- until: {
8468
- type: "number",
8469
- autocomplete: [{ description: "Iterates up to the provided number (exclusive)" }]
8470
- },
8471
- from: {
8472
- type: "number",
8473
- autocomplete: [{ description: "Iterates starting from the provided number (inclusive)" }]
8474
- },
8475
- step: {
8476
- type: "number",
8477
- autocomplete: [{ description: "The amount to increment during each iteration (with from/to/until)" }]
8478
- }
8479
- },
8480
- autocomplete: [
8481
- {
8482
- snippet: "for|${1:value, index}| of=${3:array}",
8483
- description: "Use to iterate over lists, object properties, or between ranges.",
8484
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#for"
8485
- },
8486
- {
8487
- snippet: "for|${1:name, value}| in=${3:object}",
8488
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#for"
8489
- },
8490
- {
8491
- snippet: "for|${1:index}| to=${2:number}",
8492
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#for"
8493
- },
8494
- {
8495
- snippet: "for|${1:index}| until=${2:number}",
8496
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#for"
8497
- }
8498
- ]
8408
+ parseOptions: { controlFlow: true }
8499
8409
  };
8500
8410
  function getLoopKeyBinding(byAttr, paramsBinding, forType) {
8501
8411
  if (byAttr) {
@@ -8616,11 +8526,7 @@ var html_comment_default = {
8616
8526
  replaceWithStatements(tag);
8617
8527
  } },
8618
8528
  parseOptions: { text: true },
8619
- types: runtime_info_default.name + "/tags/html-comment.d.marko",
8620
- autocomplete: [{
8621
- description: "Use to create an html comment that is not stripped from the output.",
8622
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#html-comment"
8623
- }]
8529
+ types: runtime_info_default.name + "/tags/html-comment.d.marko"
8624
8530
  };
8625
8531
  function isEmptiableCommentBody(body) {
8626
8532
  for (const child of body) if (!_marko_compiler.types.isMarkoPlaceholder(child) || isNonEmptyLiteral(child.value)) return false;
@@ -8644,11 +8550,7 @@ var html_script_default = {
8644
8550
  parseOptions: {
8645
8551
  text: true,
8646
8552
  preserveWhitespace: true
8647
- },
8648
- autocomplete: [{
8649
- description: "Use instead of `<script>` to render a native tag directly, without processing by Marko.",
8650
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#html-script--html-style"
8651
- }]
8553
+ }
8652
8554
  };
8653
8555
  // src/translator/core/html-style.ts
8654
8556
  var html_style_default = {
@@ -8657,11 +8559,7 @@ var html_style_default = {
8657
8559
  parseOptions: {
8658
8560
  text: true,
8659
8561
  preserveWhitespace: true
8660
- },
8661
- autocomplete: [{
8662
- description: "Use instead of `<style>` to render a native tag directly, without processing by Marko.",
8663
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#html-script--html-style"
8664
- }]
8562
+ }
8665
8563
  };
8666
8564
  // src/translator/core/id.ts
8667
8565
  var id_default = {
@@ -8679,6 +8577,7 @@ var id_default = {
8679
8577
  const binding = trackVarReferences(tag, 4);
8680
8578
  if (binding) {
8681
8579
  assertNoTagVarMutation(tag);
8580
+ binding.nullable = false;
8682
8581
  setDerivedFrom(binding, valueExtra);
8683
8582
  }
8684
8583
  addSetupExpr(ensureSection(tag), valueNode);
@@ -8703,13 +8602,6 @@ var id_default = {
8703
8602
  }
8704
8603
  } },
8705
8604
  parseOptions: { openTagOnly: true },
8706
- attributes: {},
8707
- autocomplete: [{
8708
- displayText: "id/<name>",
8709
- description: "Use to create a unique identifier.",
8710
- snippet: "id/${1:name}",
8711
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#id"
8712
- }],
8713
8605
  types: runtime_info_default.name + "/tags/id.d.marko"
8714
8606
  };
8715
8607
  // src/translator/core/import.ts
@@ -8720,13 +8612,7 @@ var import_default = {
8720
8612
  parseOptions: {
8721
8613
  statement: true,
8722
8614
  rawOpenTag: true
8723
- },
8724
- autocomplete: [{
8725
- displayText: "import <scope> from \"<path>\"",
8726
- description: "Use to import external modules, follows the same syntax as JavaScript imports.",
8727
- snippet: "import ${2} from \"${1:path}\"",
8728
- descriptionMoreURL: "https://markojs.com/docs/reference/language#import"
8729
- }]
8615
+ }
8730
8616
  };
8731
8617
  // src/translator/core/let.ts
8732
8618
  var let_default = {
@@ -8797,11 +8683,6 @@ var let_default = {
8797
8683
  replaceWithStatements(tag);
8798
8684
  } },
8799
8685
  parseOptions: { openTagOnly: true },
8800
- attributes: {},
8801
- autocomplete: [{
8802
- description: "Use to create a mutable binding.",
8803
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#let"
8804
- }],
8805
8686
  types: runtime_info_default.name + "/tags/let.d.marko"
8806
8687
  };
8807
8688
  function getDeclarationHint(attr) {
@@ -8839,11 +8720,6 @@ var lifecycle_default = {
8839
8720
  replaceWithStatements(tag);
8840
8721
  } },
8841
8722
  parseOptions: { openTagOnly: true },
8842
- attributes: {},
8843
- autocomplete: [{
8844
- description: "Use to create side effects.",
8845
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#lifecycle"
8846
- }],
8847
8723
  types: runtime_info_default.name + "/tags/lifecycle.d.marko"
8848
8724
  };
8849
8725
  // src/translator/core/log.ts
@@ -8860,11 +8736,6 @@ var log_default = {
8860
8736
  addTagStatement(tag, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.memberExpression(_marko_compiler.types.identifier("console"), _marko_compiler.types.identifier("log")), [tag.node.attributes[0].value])));
8861
8737
  } },
8862
8738
  parseOptions: { openTagOnly: true },
8863
- attributes: {},
8864
- autocomplete: [{
8865
- description: "Use to log a value to the console.",
8866
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#log"
8867
- }],
8868
8739
  types: runtime_info_default.name + "/tags/log.d.marko"
8869
8740
  };
8870
8741
  // src/translator/core/return.ts
@@ -8909,13 +8780,7 @@ var return_default = {
8909
8780
  replaceWithStatements(tag);
8910
8781
  } }
8911
8782
  }),
8912
- parseOptions: { openTagOnly: true },
8913
- autocomplete: [{
8914
- displayText: "return=<value>",
8915
- description: "Provides a value for use in a parent template.",
8916
- snippet: "return=${1:value}",
8917
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#return"
8918
- }]
8783
+ parseOptions: { openTagOnly: true }
8919
8784
  };
8920
8785
  // src/translator/core/script.ts
8921
8786
  const htmlScriptTagAlternateMsg = " For a native html `<script>` tag use the [`html-script` core tag](https://markojs.com/docs/reference/core-tag#html-script--html-style) instead.";
@@ -8995,10 +8860,6 @@ var script_default = {
8995
8860
  text: true,
8996
8861
  preserveWhitespace: true
8997
8862
  },
8998
- autocomplete: [{
8999
- description: "Use to create side effects. For a native `<script>` element, use `<html-script>`.",
9000
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#script"
9001
- }],
9002
8863
  types: runtime_info_default.name + "/tags/script.d.marko"
9003
8864
  };
9004
8865
  function isEmptyFunction(node) {
@@ -9125,11 +8986,6 @@ var show_default = {
9125
8986
  } }
9126
8987
  }),
9127
8988
  parseOptions: { controlFlow: true },
9128
- autocomplete: [{
9129
- snippet: "show=${1:condition}",
9130
- description: "Use to render content that is always mounted but only displayed when the condition is met.",
9131
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#show"
9132
- }],
9133
8989
  types: runtime_info_default.name + "/tags/show.d.marko"
9134
8990
  };
9135
8991
  function assertValidShow(tag) {
@@ -9285,8 +9141,7 @@ var style_default = {
9285
9141
  text: true,
9286
9142
  rawOpenTag: true,
9287
9143
  preserveWhitespace: true
9288
- },
9289
- attributes: {}
9144
+ }
9290
9145
  };
9291
9146
  function analyzeDynamicStyle(tag, names) {
9292
9147
  const { node } = tag;
@@ -9448,7 +9303,10 @@ var try_default = {
9448
9303
  const { dynamic, repeated } = attrTags[name];
9449
9304
  if (dynamic || repeated) throw tag.get("name").buildCodeFrameError(dynamic ? `The ${coreTagLink(tag)} needs its \`<${name}>\` written directly inside it, not within control flow such as \`<if>\` or \`<for>\`.` : `The ${coreTagLink(tag)} takes a single \`<${name}>\`.`);
9450
9305
  }
9451
- for (const child of tag.get("attributeTags")) if (child.isMarkoTag() && (child.node.attributes.length || child.node.arguments)) throw child.get("name").buildCodeFrameError(`The ${coreTagLink(tag)}'s \`<${getTagName(child)}>\` takes no attributes, only content.`);
9306
+ for (const child of tag.get("attributeTags")) {
9307
+ if (child.isMarkoTag() && (child.node.attributes.length || child.node.arguments)) throw child.get("name").buildCodeFrameError(`The ${coreTagLink(tag)}'s \`<${getTagName(child)}>\` takes no attributes, only content.`);
9308
+ if (child.isMarkoTag() && child.node.body.params.length && getTagName(child) === "@placeholder") throw child.get("name").buildCodeFrameError(`The ${coreTagLink(tag)}'s \`<@placeholder>\` takes no parameters: nothing passes it arguments.`);
9309
+ }
9452
9310
  }
9453
9311
  assertHasBody(tag);
9454
9312
  if (!attrTags) throw tag.get("name").buildCodeFrameError(`The ${coreTagLink(tag)} needs a \`<@catch>\` to handle errors or a \`<@placeholder>\` to show while its content is pending. Without either it has no effect, so render its content directly.`);
@@ -9514,11 +9372,6 @@ var try_default = {
9514
9372
  replaceWithStatements(tag);
9515
9373
  } }
9516
9374
  }),
9517
- attributes: {},
9518
- autocomplete: [{
9519
- description: "Used to capture errors and display placeholders for nested content.",
9520
- descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#try"
9521
- }],
9522
9375
  types: runtime_info_default.name + "/tags/try.d.marko"
9523
9376
  };
9524
9377
  function getTryParts(tag) {
@@ -9548,8 +9401,8 @@ var core_default = {
9548
9401
  "<debug>": debug_default,
9549
9402
  "<define>": define_default,
9550
9403
  "<effect>": effect_default,
9551
- "<else-if>": ElseIfTag,
9552
- "<else>": ElseTag,
9404
+ "<else-if>": IfTag,
9405
+ "<else>": IfTag,
9553
9406
  "<export>": export_default,
9554
9407
  "<for>": for_default,
9555
9408
  "<html-comment>": html_comment_default,
@@ -9759,8 +9612,7 @@ var placeholder_default = {
9759
9612
  else {
9760
9613
  const before = extra.textBefore;
9761
9614
  const after = extra[kTextAfter];
9762
- const { content } = getSection(placeholder);
9763
- text(placeholder, extra.nodeBinding, before || after || !node.escape && content.singleChild && content.startType === 2 || (before === false && after === false ? false : void 0));
9615
+ text(placeholder, extra.nodeBinding, before || after || !node.escape && before === void 0 && after === void 0 && !!getSectionForBody(placeholder.parentPath) || (before === false && after === false ? false : void 0));
9764
9616
  }
9765
9617
  if (contentType !== 4 || !followsStaticText(placeholder)) enterShallow(placeholder);
9766
9618
  }
@@ -9979,6 +9831,7 @@ var dynamic_tag_default = {
9979
9831
  if (tag.node.extra?.tagNameUnresolved) throw tagNotFoundError(tag);
9980
9832
  (0, _marko_compiler_babel_utils.assertAttributesOrArgs)(tag);
9981
9833
  const { node } = tag;
9834
+ if (node.extra.tagNameType === 0) assertNoNativeAttrTags(tag);
9982
9835
  if (node.var && node.extra.featureType === "class") throw tag.get("var").buildCodeFrameError(`The Marko 5 (class API) tag \`${getTagNameHint(node)}\` cannot [\`<return>\`](https://markojs.com/docs/reference/core-tag#return) a value, so it does not support a [tag variable](https://markojs.com/docs/reference/language#tag-variables). Remove the variable, or migrate the tag to the tags API.`);
9983
9836
  const definedBodySection = node.extra?.defineBodySection;
9984
9837
  if (definedBodySection) {
@@ -10087,7 +9940,7 @@ var dynamic_tag_default = {
10087
9940
  pushStatementOnce(rendererName, _marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.assignmentExpression("??=", _marko_compiler.types.memberExpression(_marko_compiler.types.identifier(rendererName), _marko_compiler.types.identifier("_")), _marko_compiler.types.identifier(rendererName)))], true));
10088
9941
  }
10089
9942
  } else if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)((0, _marko_compiler_babel_utils.getFile)(), getTagRelativePath(tag), tagExpression.value);
10090
- const { properties, statements } = translateAttrs(tag, void 0, void 0, void 0, isClassAPI ? "renderBody" : "content");
9943
+ const { properties, statements } = translateAttrs(tag, void 0, void 0, isClassAPI ? "renderBody" : "content");
10091
9944
  const args = [];
10092
9945
  const contentProp = getTranslatedBodyContentProperty(properties);
10093
9946
  let hasTagArgs = false;
@@ -10385,6 +10238,7 @@ var program_default = {
10385
10238
  },
10386
10239
  exit(program) {
10387
10240
  if (hasAnalyzeErrors()) return;
10241
+ settleContent(program);
10388
10242
  analyzeRecursiveTags();
10389
10243
  const intersectionsBySection = finalizeReferences();
10390
10244
  solveReasons(intersectionsBySection);
@@ -10736,7 +10590,7 @@ var native_tag_default = {
10736
10590
  enter(tag) {
10737
10591
  (0, _marko_compiler_babel_utils.assertNoArgs)(tag);
10738
10592
  (0, _marko_compiler_babel_utils.assertNoParams)(tag);
10739
- (0, _marko_compiler_babel_utils.assertNoAttributeTags)(tag);
10593
+ assertNoNativeAttrTags(tag);
10740
10594
  const { node: node$1 } = tag;
10741
10595
  if (node$1.var && !_marko_compiler.types.isIdentifier(node$1.var)) throw tag.get("var").buildCodeFrameError("Tag variables on [native tags](https://markojs.com/docs/reference/native-tag) cannot be destructured.");
10742
10596
  const tagName = getCanonicalTagName(tag);
@@ -10805,10 +10659,10 @@ var native_tag_default = {
10805
10659
  if (isDynamicAttr(attr.value, delimitedAttrMeta)) {
10806
10660
  hasDynamicAttributes = true;
10807
10661
  addSetupExpr(tagSection, attr.value);
10808
- } else if (attr.name === "content" && tagName !== "meta") addSetupExpr(tagSection, attr.value);
10662
+ } else if (attr.name === "content" && !tagFacts.htmlContentAttr) addSetupExpr(tagSection, attr.value);
10809
10663
  }
10810
10664
  if (spread) spread.push(i);
10811
- else if (attr.name === "content" && tagName !== "meta") content = i;
10665
+ else if (attr.name === "content" && !tagFacts.htmlContentAttr) content = i;
10812
10666
  else if (isEventHandlerAttr) (handlers ||= []).push(i);
10813
10667
  else if (!controllableAttrNames?.includes(attr.name)) (own ||= []).push(i);
10814
10668
  }
@@ -10825,8 +10679,7 @@ var native_tag_default = {
10825
10679
  }, isDefined);
10826
10680
  const contentAttr = attrAt(attributes, indexByName.content);
10827
10681
  if (contentAttr) {
10828
- const tagDef = (0, _marko_compiler_babel_utils.getTagDef)(tag);
10829
- if (tagDef?.parseOptions?.openTagOnly && !tagDef.attributes?.content) throw tag.hub.buildError(contentAttr, `The \`<${tagName}>\` tag cannot have content, so it does not support the \`content\` attribute.`);
10682
+ if ((0, _marko_compiler_babel_utils.getTagDef)(tag)?.parseOptions?.openTagOnly && !tagFacts.htmlContentAttr) throw tag.hub.buildError(contentAttr, `The \`<${tagName}>\` tag cannot have content, so it does not support the \`content\` attribute.`);
10830
10683
  if (isTextOnly) throw tag.hub.buildError(contentAttr, `The \`<${tagName}>\` tag takes its content from its body as text, so it does not support the \`content\` attribute.`);
10831
10684
  }
10832
10685
  const valueChangeAttr = tagName === "input" ? attrAt(attributes, indexByName.valueChange) : void 0;
@@ -11591,6 +11444,7 @@ var tag_default = {
11591
11444
  },
11592
11445
  exit(tag) {
11593
11446
  if (tag.node.extra?.[kAnalyzeFailed]) return;
11447
+ settleContent(tag.get("body"));
11594
11448
  try {
11595
11449
  const hook = (0, _marko_compiler_babel_utils.getTagDef)(tag)?.analyzer?.hook;
11596
11450
  if (hook) {
@@ -11807,7 +11661,9 @@ function createInteropTranslator(translate5) {
11807
11661
  analyze: mergeVisitors(translate5.analyze, analyze),
11808
11662
  translate: withInteropEntryBuilder(mergeVisitors(translate5.translate, translate)),
11809
11663
  tagDiscoveryDirs: [...tagDiscoveryDirs, ...translate5.tagDiscoveryDirs],
11810
- taglibs: mergeTaglibs(_marko_compiler.taglib.resolveOptionalTaglibs(translate5.optionalTaglibs).concat(translate5.taglibs), taglibs.concat([["marko-interop", { migrate: out_global_default }]])),
11664
+ classTaglibs: translate5.classTaglibs,
11665
+ optionalTaglibs: translate5.optionalTaglibs,
11666
+ taglibs: mergeTaglibs(translate5.taglibs, taglibs.concat([["marko-interop", { migrate: out_global_default }]])),
11811
11667
  getRuntimeEntryFiles(output, optimize) {
11812
11668
  return [...translate5.getRuntimeEntryFiles(output, optimize), ...getRuntimeEntryFiles(output, optimize)];
11813
11669
  }