marko 6.4.11 → 6.4.12

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 (89) 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-mQ5mPBTF.js → dom-CtXOr4Nm.js} +68 -31
  27. package/dist/debug/{dom-DjUZd-9y.mjs → dom-DaHYZpf2.mjs} +51 -26
  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-B8j2453O.js → dom-BB-Te-3z.js} +125 -130
  63. package/dist/{dom-HEWdZCCb.mjs → dom-BO-0hzLZ.mjs} +13 -18
  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/index.js +297 -285
  78. package/dist/translator/util/assert.d.ts +2 -0
  79. package/dist/translator/util/branch-tag.d.ts +1 -1
  80. package/dist/translator/util/known-tag.d.ts +4 -1
  81. package/dist/translator/util/optional.d.ts +0 -1
  82. package/dist/translator/util/reasons.d.ts +0 -1
  83. package/dist/translator/util/references.d.ts +1 -0
  84. package/dist/translator/util/sections.d.ts +5 -1
  85. package/dist/translator/util/tag-facts.d.ts +2 -0
  86. package/dist/translator/util/translate-attrs.d.ts +1 -4
  87. package/dist/translator/visitors/program/index.d.ts +2 -2
  88. package/index.d.ts +2 -7
  89. package/package.json +4 -4
@@ -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
  }
@@ -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
  }
@@ -7781,6 +7789,7 @@ function insertStaticText(placeholder, value, before) {
7781
7789
  else placeholder.insertAfter(_marko_compiler.types.markoText(value));
7782
7790
  }
7783
7791
  function normalizeTag(tag) {
7792
+ assertNotContentAttrTag(tag);
7784
7793
  const { node } = tag;
7785
7794
  const { name, attributes } = node;
7786
7795
  let invalidNameReg = invalidAttrNameReg;
@@ -8215,6 +8224,7 @@ var define_default = {
8215
8224
  return;
8216
8225
  }
8217
8226
  assertNoTagVarMutation(tag);
8227
+ varBinding.nullable = false;
8218
8228
  const babelBinding = _marko_compiler.types.isIdentifier(tag.node.var) && tag.scope.getBinding(tag.node.var.name);
8219
8229
  if (babelBinding && !babelBinding.referencePaths.length) {
8220
8230
  dropContent(tag.node.body);
@@ -8679,6 +8689,7 @@ var id_default = {
8679
8689
  const binding = trackVarReferences(tag, 4);
8680
8690
  if (binding) {
8681
8691
  assertNoTagVarMutation(tag);
8692
+ binding.nullable = false;
8682
8693
  setDerivedFrom(binding, valueExtra);
8683
8694
  }
8684
8695
  addSetupExpr(ensureSection(tag), valueNode);
@@ -9759,8 +9770,7 @@ var placeholder_default = {
9759
9770
  else {
9760
9771
  const before = extra.textBefore;
9761
9772
  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));
9773
+ 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
9774
  }
9765
9775
  if (contentType !== 4 || !followsStaticText(placeholder)) enterShallow(placeholder);
9766
9776
  }
@@ -9979,6 +9989,7 @@ var dynamic_tag_default = {
9979
9989
  if (tag.node.extra?.tagNameUnresolved) throw tagNotFoundError(tag);
9980
9990
  (0, _marko_compiler_babel_utils.assertAttributesOrArgs)(tag);
9981
9991
  const { node } = tag;
9992
+ if (node.extra.tagNameType === 0) assertNoNativeAttrTags(tag);
9982
9993
  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
9994
  const definedBodySection = node.extra?.defineBodySection;
9984
9995
  if (definedBodySection) {
@@ -10087,7 +10098,7 @@ var dynamic_tag_default = {
10087
10098
  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
10099
  }
10089
10100
  } 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");
10101
+ const { properties, statements } = translateAttrs(tag, void 0, void 0, isClassAPI ? "renderBody" : "content");
10091
10102
  const args = [];
10092
10103
  const contentProp = getTranslatedBodyContentProperty(properties);
10093
10104
  let hasTagArgs = false;
@@ -10385,6 +10396,7 @@ var program_default = {
10385
10396
  },
10386
10397
  exit(program) {
10387
10398
  if (hasAnalyzeErrors()) return;
10399
+ settleContent(program);
10388
10400
  analyzeRecursiveTags();
10389
10401
  const intersectionsBySection = finalizeReferences();
10390
10402
  solveReasons(intersectionsBySection);
@@ -10736,7 +10748,7 @@ var native_tag_default = {
10736
10748
  enter(tag) {
10737
10749
  (0, _marko_compiler_babel_utils.assertNoArgs)(tag);
10738
10750
  (0, _marko_compiler_babel_utils.assertNoParams)(tag);
10739
- (0, _marko_compiler_babel_utils.assertNoAttributeTags)(tag);
10751
+ assertNoNativeAttrTags(tag);
10740
10752
  const { node: node$1 } = tag;
10741
10753
  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
10754
  const tagName = getCanonicalTagName(tag);
@@ -10805,10 +10817,10 @@ var native_tag_default = {
10805
10817
  if (isDynamicAttr(attr.value, delimitedAttrMeta)) {
10806
10818
  hasDynamicAttributes = true;
10807
10819
  addSetupExpr(tagSection, attr.value);
10808
- } else if (attr.name === "content" && tagName !== "meta") addSetupExpr(tagSection, attr.value);
10820
+ } else if (attr.name === "content" && !tagFacts.htmlContentAttr) addSetupExpr(tagSection, attr.value);
10809
10821
  }
10810
10822
  if (spread) spread.push(i);
10811
- else if (attr.name === "content" && tagName !== "meta") content = i;
10823
+ else if (attr.name === "content" && !tagFacts.htmlContentAttr) content = i;
10812
10824
  else if (isEventHandlerAttr) (handlers ||= []).push(i);
10813
10825
  else if (!controllableAttrNames?.includes(attr.name)) (own ||= []).push(i);
10814
10826
  }
@@ -10825,8 +10837,7 @@ var native_tag_default = {
10825
10837
  }, isDefined);
10826
10838
  const contentAttr = attrAt(attributes, indexByName.content);
10827
10839
  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.`);
10840
+ 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
10841
  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
10842
  }
10832
10843
  const valueChangeAttr = tagName === "input" ? attrAt(attributes, indexByName.valueChange) : void 0;
@@ -11591,6 +11602,7 @@ var tag_default = {
11591
11602
  },
11592
11603
  exit(tag) {
11593
11604
  if (tag.node.extra?.[kAnalyzeFailed]) return;
11605
+ settleContent(tag.get("body"));
11594
11606
  try {
11595
11607
  const hook = (0, _marko_compiler_babel_utils.getTagDef)(tag)?.analyzer?.hook;
11596
11608
  if (hook) {