marko 6.3.49 → 6.3.51

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.
@@ -995,12 +995,6 @@ function getAccessorProp() {
995
995
  //#endregion
996
996
  //#region src/translator/util/serialize-reasons.ts
997
997
  const sourcesUtil = new Sorted(compareSources);
998
- const scopeExprsBySection = /* @__PURE__ */ new WeakMap();
999
- const propExprsBySection = /* @__PURE__ */ new WeakMap();
1000
- const scopeProvenanceBySection = /* @__PURE__ */ new WeakMap();
1001
- const propProvenanceBySection = /* @__PURE__ */ new WeakMap();
1002
- const serializePropsByBinding = /* @__PURE__ */ new WeakMap();
1003
- const serializePropByModifier = {};
1004
998
  function isSameReason(a, b) {
1005
999
  return a === b || (a && b ? a !== true && b !== true && compareSources(a, b) === 0 : false);
1006
1000
  }
@@ -1034,20 +1028,15 @@ function addSerializeExpr(section, expr, prop, prefix) {
1034
1028
  if (expr === true) {
1035
1029
  if (section.serializeReasons.get(key) !== true) forcePropSerialize(section, key);
1036
1030
  } else {
1037
- let curExpr;
1038
- let curExprs = propExprsBySection.get(section);
1039
- if (curExprs) curExpr = curExprs.get(key);
1040
- else {
1041
- curExprs = /* @__PURE__ */ new Map();
1042
- propExprsBySection.set(section, curExprs);
1043
- }
1031
+ const curExprs = section.propSerializeExprs ??= /* @__PURE__ */ new Map();
1032
+ const curExpr = curExprs.get(key);
1044
1033
  curExprs.set(key, curExpr ? concat(curExpr, expr) : expr);
1045
1034
  }
1046
1035
  } else if (expr === true) {
1047
1036
  if (section.serializeReason !== true) forceSerialize(section);
1048
1037
  } else {
1049
- const curExpr = scopeExprsBySection.get(section);
1050
- scopeExprsBySection.set(section, curExpr ? concat(curExpr, expr) : expr);
1038
+ const curExpr = section.serializeExprs;
1039
+ section.serializeExprs = curExpr ? concat(curExpr, expr) : expr;
1051
1040
  }
1052
1041
  }
1053
1042
  function addOwnerSerializeReason(from, to, reason) {
@@ -1073,7 +1062,7 @@ function getSerializeReason(section, prop, prefix) {
1073
1062
  else return section.serializeReason;
1074
1063
  }
1075
1064
  function getSerializeSourcesForExpr(expr) {
1076
- if (isReferencedExtra(expr)) return getSerializeSourcesForRef(expr.referencedBindings);
1065
+ return isReferencedExtra(expr) ? getSerializeSourcesForRef(expr.referencedBindings) : void 0;
1077
1066
  }
1078
1067
  function getSerializeSourcesForExprs(exprs) {
1079
1068
  if (exprs) if (exprs === true) return exprs;
@@ -1128,9 +1117,9 @@ function mergeSerializeReasons(a, b) {
1128
1117
  return mergeSources(a, b);
1129
1118
  }
1130
1119
  function applySerializeExprs(section) {
1131
- const propExprs = propExprsBySection.get(section);
1120
+ const propExprs = section.propSerializeExprs;
1132
1121
  if (propExprs) {
1133
- propExprsBySection.delete(section);
1122
+ section.propSerializeExprs = void 0;
1134
1123
  for (const [key, exprs] of propExprs) {
1135
1124
  addProvenance(section, getProvenanceForExprs(exprs), key);
1136
1125
  const exprReason = getSerializeSourcesForExprs(exprs);
@@ -1141,9 +1130,9 @@ function applySerializeExprs(section) {
1141
1130
  }
1142
1131
  }
1143
1132
  }
1144
- const scopeExprs = scopeExprsBySection.get(section);
1133
+ const scopeExprs = section.serializeExprs;
1145
1134
  if (scopeExprs) {
1146
- scopeExprsBySection.delete(section);
1135
+ section.serializeExprs = void 0;
1147
1136
  addProvenance(section, getProvenanceForExprs(scopeExprs));
1148
1137
  const exprReason = getSerializeSourcesForExprs(scopeExprs);
1149
1138
  if (exprReason) {
@@ -1171,16 +1160,15 @@ function finalizeSerializeReason(section) {
1171
1160
  }
1172
1161
  if (newReason && curReason !== newReason) setSerializeReason(section, newReason);
1173
1162
  }
1174
- const propProvenance = propProvenanceBySection.get(section);
1163
+ const propProvenance = section.propSerializeProvenance;
1175
1164
  if (propProvenance) for (const provenance of propProvenance.values()) addProvenance(section, provenance);
1176
1165
  }
1177
1166
  function addProvenance(section, sources, key) {
1178
1167
  if (!sources) return;
1179
1168
  if (key) {
1180
- let provenance = propProvenanceBySection.get(section);
1181
- if (!provenance) propProvenanceBySection.set(section, provenance = /* @__PURE__ */ new Map());
1169
+ const provenance = section.propSerializeProvenance ??= /* @__PURE__ */ new Map();
1182
1170
  provenance.set(key, mergeSources(provenance.get(key), sources));
1183
- } else scopeProvenanceBySection.set(section, mergeSources(scopeProvenanceBySection.get(section), sources));
1171
+ } else section.serializeProvenance = mergeSources(section.serializeProvenance, sources);
1184
1172
  }
1185
1173
  function getProvenanceForExprs(exprs) {
1186
1174
  let sources;
@@ -1194,16 +1182,16 @@ function getProvenanceForExprs(exprs) {
1194
1182
  }
1195
1183
  function getPropKey(section, prop, prefix) {
1196
1184
  if (isStrOrSym(prop)) {
1197
- const keys = serializePropByModifier[prop] ||= /* @__PURE__ */ new WeakMap();
1198
- let key = keys.get(section);
1199
- if (!key) keys.set(section, key = Symbol(typeof prop === "symbol" ? `Symbol(${prop.description})` : prop));
1185
+ const keys = section.serializePropKeys ??= /* @__PURE__ */ new Map();
1186
+ let key = keys.get(prop);
1187
+ if (!key) keys.set(prop, key = Symbol(typeof prop === "symbol" ? `Symbol(${prop.description})` : prop));
1200
1188
  if (prefix) throw new Error("Cannot have a scope property reason with a prefix.");
1201
1189
  return key;
1202
1190
  } else {
1203
- const keys = prefix ? serializePropByModifier[prefix] ||= /* @__PURE__ */ new WeakMap() : serializePropsByBinding;
1204
1191
  const binding = getCanonicalBinding(prop);
1205
- let key = keys.get(binding);
1206
- if (!key) keys.set(binding, key = Symbol((prefix ? typeof prefix === "symbol" ? `Symbol(${prefix.description})` : prefix : "") + binding.name));
1192
+ const keys = binding.serializePropKeys ??= /* @__PURE__ */ new Map();
1193
+ let key = keys.get(prefix);
1194
+ if (!key) keys.set(prefix, key = Symbol((prefix ? typeof prefix === "symbol" ? `Symbol(${prefix.description})` : prefix : "") + binding.name));
1207
1195
  return key;
1208
1196
  }
1209
1197
  }
@@ -1391,12 +1379,17 @@ function startSection(path) {
1391
1379
  serializeReason: void 0,
1392
1380
  serializeReasons: /* @__PURE__ */ new Map(),
1393
1381
  domSerializeReasons: void 0,
1382
+ serializeExprs: void 0,
1383
+ propSerializeExprs: void 0,
1384
+ serializeProvenance: void 0,
1385
+ propSerializeProvenance: void 0,
1386
+ serializePropKeys: void 0,
1394
1387
  paramReasonGroups: void 0,
1395
1388
  returnValueExpr: void 0,
1396
1389
  returnSerializeReason: void 0,
1397
1390
  content: getContentInfo(path),
1398
1391
  upstreamExpression: void 0,
1399
- downstreamBinding: void 0,
1392
+ downstream: void 0,
1400
1393
  hasAbortSignal: false,
1401
1394
  abortSignalExprs: 0,
1402
1395
  readsOwner: false,
@@ -1505,14 +1498,14 @@ function getNodeContentType(path, extraMember, contentInfo) {
1505
1498
  }
1506
1499
  function getSectionRegisterReasons(section) {
1507
1500
  if (section.isBranch) return false;
1508
- const { downstreamBinding } = section;
1509
- if (downstreamBinding) {
1510
- let downstreamReasons = getAllSerializeReasonsForBinding(downstreamBinding.binding, downstreamBinding.properties);
1511
- if (downstreamReasons && downstreamReasons !== true) downstreamReasons = mapCrossProgramReason(section.program, downstreamReasons, downstreamBinding.exprs);
1501
+ const { downstream } = section;
1502
+ if (downstream?.binding) {
1503
+ let downstreamReasons = getAllSerializeReasonsForBinding(downstream.binding, downstream.properties);
1504
+ if (downstreamReasons && downstreamReasons !== true) downstreamReasons = mapCrossProgramReason(section.program, downstreamReasons, downstream.exprs);
1512
1505
  if (!downstreamReasons) return false;
1513
1506
  if (isReasonDynamic(downstreamReasons) && !section.serializeReason && !section.serializeReasons.size && !section.parent?.serializeReason && !section.parent?.serializeReasons.size) return false;
1514
1507
  return downstreamReasons;
1515
- } else if (downstreamBinding === false) return false;
1508
+ } else if (downstream) return false;
1516
1509
  return true;
1517
1510
  }
1518
1511
  function isImmediateOwner(section, binding) {
@@ -1834,8 +1827,8 @@ function hasAnalyzeErrors() {
1834
1827
  }
1835
1828
  //#endregion
1836
1829
  //#region src/translator/util/asset-imports.ts
1837
- function addAssetImport(file, request) {
1838
- (file.metadata.marko.assetImports ??= /* @__PURE__ */ new Set()).add(request);
1830
+ function addAssetImport(request) {
1831
+ ((0, _marko_compiler_babel_utils.getFile)().metadata.marko.assetImports ??= /* @__PURE__ */ new Set()).add(request);
1839
1832
  }
1840
1833
  function isClientAssetImport(file, request) {
1841
1834
  const { hydrateIncludeImports } = file.markoOpts;
@@ -1844,7 +1837,7 @@ function isClientAssetImport(file, request) {
1844
1837
  //#endregion
1845
1838
  //#region src/translator/util/binding-has-prop.ts
1846
1839
  function isSectionRendererElided(section) {
1847
- return !!section.downstreamBinding && !bindingHasProperty(section.downstreamBinding.binding, section.downstreamBinding.properties);
1840
+ return !!section.downstream?.binding && !bindingHasProperty(section.downstream.binding, section.downstream.properties);
1848
1841
  }
1849
1842
  function bindingHasProperty(binding, properties) {
1850
1843
  if (binding.pruned) return false;
@@ -2248,7 +2241,7 @@ function sectionHasSetupStatements(section) {
2248
2241
  * reserved a register id without registering it.
2249
2242
  */
2250
2243
  function writeModuleRegistrations(program) {
2251
- const { file } = program.hub;
2244
+ const file = (0, _marko_compiler_babel_utils.getFile)();
2252
2245
  const statements = [];
2253
2246
  const seen = /* @__PURE__ */ new Set();
2254
2247
  for (const child of program.node.body) {
@@ -3290,11 +3283,14 @@ function writeHTMLResumeStatements(path) {
3290
3283
  }
3291
3284
  const closureIndex = getDynamicClosureIndex(closure, section);
3292
3285
  if (closureIndex) setBindingSerializedValue(section, closure, _marko_compiler.types.numericLiteral(closureIndex), getAccessorPrefix().ClosureSignalIndex);
3286
+ const closureScopesReason = getSerializeReason(closure.section, closure, getAccessorPrefix().ClosureScopes);
3293
3287
  if (underTryPlaceholder(section)) {
3294
3288
  const reason = getSerializeReason(section);
3295
- if (reason) getHTMLSectionStatements(section).push(_marko_compiler.types.expressionStatement(getExprIfSerialized(section, reason, callRuntime("_script", getScopeIdIdentifier(section), _marko_compiler.types.stringLiteral(getResumeRegisterId(section, closure, "pending")), markerSerializeArg))));
3289
+ if (reason) {
3290
+ const script = getExprIfSerialized(section, reason, callRuntime("_script", getScopeIdIdentifier(section), _marko_compiler.types.stringLiteral(getResumeRegisterId(section, closure, "pending")), markerSerializeArg));
3291
+ getHTMLSectionStatements(section).push(_marko_compiler.types.expressionStatement(isReasonDynamic(closureScopesReason) && !isSameReason(closureScopesReason, reason) ? getExprIfSerialized(closure.section, closureScopesReason, script) : script));
3292
+ }
3296
3293
  } else {
3297
- const closureScopesReason = getSerializeReason(closure.section, closure, getAccessorPrefix().ClosureScopes);
3298
3294
  const subscribeArg = isReasonDynamic(closureScopesReason) && !isSameReason(closureScopesReason, sectionSerializeReason) ? getExprIfSerialized(closure.section, closureScopesReason, identifier) : identifier;
3299
3295
  addWriteScopeBuilder(section, (expr) => callRuntime("_subscribe", subscribeArg, expr));
3300
3296
  }
@@ -3998,8 +3994,8 @@ function getRegisteredFnExpression(node) {
3998
3994
  //#endregion
3999
3995
  //#region src/translator/util/body-to-text-literal.ts
4000
3996
  const kRawText = Symbol("raw text placeholder");
4001
- function bodyToTextLiteral(body) {
4002
- return buildTextLiteral(body, toText, true);
3997
+ function bodyToTextLiteral(body, decodeEntities = false) {
3998
+ return buildTextLiteral(body, toText, true, decodeEntities);
4003
3999
  }
4004
4000
  function bodyToRawTextLiteral(body) {
4005
4001
  return buildTextLiteral(body, (value) => value, true);
@@ -4018,13 +4014,13 @@ function injectTextCoercion(expr) {
4018
4014
  function toText(value) {
4019
4015
  return callRuntime("_to_text", value);
4020
4016
  }
4021
- function buildTextLiteral(body, coerce, bareSingle) {
4017
+ function buildTextLiteral(body, coerce, bareSingle, decodeEntities = false) {
4022
4018
  const templateQuasis = [];
4023
4019
  const templateExpressions = [];
4024
4020
  let currentQuasi = "";
4025
4021
  let placeholderExtra;
4026
4022
  let singleValue;
4027
- for (const child of body.body) if (_marko_compiler.types.isMarkoText(child)) currentQuasi += child.value;
4023
+ for (const child of body.body) if (_marko_compiler.types.isMarkoText(child)) currentQuasi += decodeEntities ? (0, _marko_compiler_babel_utils.decodeHTML)(child.value) : child.value;
4028
4024
  else if (_marko_compiler.types.isMarkoPlaceholder(child)) {
4029
4025
  placeholderExtra ||= child.value.extra;
4030
4026
  templateQuasis.push(templateElement(currentQuasi, false));
@@ -4084,6 +4080,7 @@ function isNonHTMLText(placeholder) {
4084
4080
  return false;
4085
4081
  }
4086
4082
  function isTextOnlyNativeTag(tag) {
4083
+ if (analyzeTagNameType(tag) !== 0) return false;
4087
4084
  const def = (0, _marko_compiler_babel_utils.getTagDef)(tag);
4088
4085
  return !!(def && def.html && (def.name === "title" || def.parseOptions?.text));
4089
4086
  }
@@ -5062,7 +5059,7 @@ var native_tag_default = {
5062
5059
  const openTagOnly = (0, _marko_compiler_babel_utils.getTagDef)(tag)?.parseOptions?.openTagOnly;
5063
5060
  const tagName = getCanonicalTagName(tag);
5064
5061
  if (!openTagOnly) if (tagName !== "textarea" && isTextOnlyNativeTag(tag)) {
5065
- const textLiteral = bodyToTextLiteral(tag.node.body);
5062
+ const textLiteral = bodyToTextLiteral(tag.node.body, tagName === "title");
5066
5063
  if (!_marko_compiler.types.isStringLiteral(textLiteral)) addStatement("render", getSection(tag), textLiteral.extra?.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_text_content", createScopeReadExpression(nodeBinding), textLiteral)), true);
5067
5064
  } else tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
5068
5065
  tag.remove();
@@ -5857,6 +5854,10 @@ function normalizeTag(tag) {
5857
5854
  const { node } = tag;
5858
5855
  const { name, attributes } = node;
5859
5856
  let attrNameReg = userAttrNameReg;
5857
+ if (name.type === "StringLiteral") {
5858
+ const tagName = name.value;
5859
+ if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) node.name = withPreviousLocation(_marko_compiler.types.identifier(tagName), name);
5860
+ }
5860
5861
  normalizeBody(tag.get("body").get("body"));
5861
5862
  normalizeBody(tag.get("attributeTags"));
5862
5863
  if (node.var) {
@@ -5868,17 +5869,15 @@ function normalizeTag(tag) {
5868
5869
  for (const param of node.body.params) insertions = getAssignmentInsertions(param, insertions);
5869
5870
  if (insertions) node.body.body = [...insertions, ...node.body.body];
5870
5871
  }
5871
- if (name.type === "StringLiteral") {
5872
- const tagName = name.value;
5873
- if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) node.name = withPreviousLocation(_marko_compiler.types.identifier(tagName), name);
5874
- else if ((0, _marko_compiler_babel_utils.isNativeTag)(tag)) {
5875
- attrNameReg = htmlAttrNameReg;
5876
- switch (tagName) {
5877
- case "textarea":
5878
- preAnalyze$1(tag);
5879
- break;
5880
- }
5872
+ const nativeTagDef = getStaticNativeTagDef(tag);
5873
+ if (nativeTagDef) {
5874
+ if (!_marko_compiler.types.isStringLiteral(node.name)) {
5875
+ node.name = withPreviousLocation(_marko_compiler.types.stringLiteral(nativeTagDef.name), node.name);
5876
+ node.tagDef = nativeTagDef;
5881
5877
  }
5878
+ attrNameReg = htmlAttrNameReg;
5879
+ if (nativeTagDef.parseOptions?.openTagOnly && node.body.body.length) throw tag.hub.buildError(node.body.body[0], `The \`<${nativeTagDef.name}>\` tag cannot have content, so it does not support a body.`);
5880
+ if (nativeTagDef.name === "textarea") preAnalyze$1(tag);
5882
5881
  }
5883
5882
  for (let i = 0; i < attributes.length; i++) {
5884
5883
  const attr = attributes[i];
@@ -5898,6 +5897,14 @@ function normalizeTag(tag) {
5898
5897
  }
5899
5898
  }
5900
5899
  }
5900
+ function getStaticNativeTagDef(tag) {
5901
+ const { name } = tag.node;
5902
+ if (_marko_compiler.types.isStringLiteral(name)) return (0, _marko_compiler_babel_utils.isNativeTag)(tag) ? (0, _marko_compiler_babel_utils.getTagDef)(tag) : void 0;
5903
+ if (_marko_compiler.types.isTemplateLiteral(name) && name.quasis.length === 1) {
5904
+ const tagDef = (0, _marko_compiler_babel_utils.getTagDefForTagName)((0, _marko_compiler_babel_utils.getFile)(), name.quasis[0].value.cooked);
5905
+ if (tagDef?.taglibId === "marko-html" && tagDef.html && !tagDef.template && !tagDef.renderer) return tagDef;
5906
+ }
5907
+ }
5901
5908
  function getChangeHandler(tag, attr) {
5902
5909
  const changeAttrName = attr.name + "Change";
5903
5910
  let modifier;
@@ -6053,7 +6060,7 @@ var program_default = {
6053
6060
  const styleFile = getStyleFile((0, _marko_compiler_babel_utils.getFile)());
6054
6061
  if (styleFile) {
6055
6062
  programExtra.styleFile = styleFile;
6056
- addAssetImport((0, _marko_compiler_babel_utils.getFile)(), styleFile);
6063
+ addAssetImport(styleFile);
6057
6064
  }
6058
6065
  },
6059
6066
  exit(program) {
@@ -6147,9 +6154,9 @@ function setTagDownstream(tag, binding, exprs) {
6147
6154
  });
6148
6155
  }
6149
6156
  function finalizeTagDownstreams(section) {
6150
- for (const [tag, { binding, exprs }] of getTagDownstreams(section)) crawlSectionsAndSetBinding(tag, binding, exprs);
6157
+ for (const [tag, { binding, exprs }] of getTagDownstreams(section)) crawlSectionsAndSetBinding(tag, tag.node.extra, binding, exprs);
6151
6158
  }
6152
- function crawlSectionsAndSetBinding(tag, binding, exprs, properties, skip) {
6159
+ function crawlSectionsAndSetBinding(tag, downstreamTag, binding, exprs, properties, skip) {
6153
6160
  if (!skip) {
6154
6161
  const contentSection = getSectionForBody(tag.get("body"));
6155
6162
  if (contentSection) {
@@ -6157,10 +6164,12 @@ function crawlSectionsAndSetBinding(tag, binding, exprs, properties, skip) {
6157
6164
  forEach(properties, (property) => {
6158
6165
  target = target?.propertyAliases.get(property);
6159
6166
  });
6160
- contentSection.downstreamBinding = target && (target.noSerialize || includes(target.noSerializeProperties, "content")) ? false : {
6161
- binding,
6162
- properties: concat(properties, "content"),
6163
- exprs
6167
+ const serialized = !(target && (target.noSerialize || includes(target.noSerializeProperties, "content")));
6168
+ contentSection.downstream = {
6169
+ tag: downstreamTag,
6170
+ binding: serialized ? binding : void 0,
6171
+ properties: serialized ? concat(properties, "content") : void 0,
6172
+ exprs: serialized ? exprs : void 0
6164
6173
  };
6165
6174
  }
6166
6175
  }
@@ -6169,8 +6178,8 @@ function crawlSectionsAndSetBinding(tag, binding, exprs, properties, skip) {
6169
6178
  const attrTags = getAttrTagPaths(tag);
6170
6179
  for (const child of attrTags) if (child.isMarkoTag()) if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
6171
6180
  const attrTagMeta = attrTagLookup[getTagName(child)];
6172
- crawlSectionsAndSetBinding(child, binding, exprs, concat(properties, attrTagMeta.name));
6173
- } else crawlSectionsAndSetBinding(child, binding, exprs, properties, true);
6181
+ crawlSectionsAndSetBinding(child, downstreamTag, binding, exprs, concat(properties, attrTagMeta.name));
6182
+ } else crawlSectionsAndSetBinding(child, downstreamTag, binding, exprs, properties, true);
6174
6183
  }
6175
6184
  //#endregion
6176
6185
  //#region src/translator/util/translate-var.ts
@@ -6820,6 +6829,7 @@ function createBinding(name, type, refSection, upstreamAlias, property, excludeP
6820
6829
  pruned: void 0,
6821
6830
  exposed: false,
6822
6831
  forcePersist: false,
6832
+ serializePropKeys: void 0,
6823
6833
  reserveSize: 0
6824
6834
  };
6825
6835
  if (property) {
@@ -7267,7 +7277,7 @@ function finalizeReferences() {
7267
7277
  let branchesForced = false;
7268
7278
  let branchesSources;
7269
7279
  while (currentSection !== sourceSection) {
7270
- const upstreamReason = currentSection.downstreamBinding ? getSectionRegisterReasons(currentSection) || void 0 : !currentSection.upstreamExpression || getSerializeSourcesForExpr(currentSection.upstreamExpression);
7280
+ const upstreamReason = currentSection.downstream?.binding ? getSectionRegisterReasons(currentSection) || void 0 : !currentSection.upstreamExpression || getSerializeSourcesForExpr(currentSection.upstreamExpression);
7271
7281
  if (upstreamReason === true) branchesForced = true;
7272
7282
  else if (upstreamReason) branchesSources = mergeSources(branchesSources, upstreamReason);
7273
7283
  currentSection = currentSection.parent;
@@ -8210,7 +8220,8 @@ function createStatementTag(keyword) {
8210
8220
  const keywordReg = new RegExp(`^${keyword}\\s*`);
8211
8221
  return {
8212
8222
  parse(tag) {
8213
- const { node, hub: { file } } = tag;
8223
+ const { node } = tag;
8224
+ const file = (0, _marko_compiler_babel_utils.getFile)();
8214
8225
  const rawValue = node.rawValue;
8215
8226
  const code = rawValue.replace(keywordReg, "");
8216
8227
  const start = node.start + (rawValue.length - code.length);
@@ -9145,16 +9156,16 @@ var style_default = {
9145
9156
  (0, _marko_compiler_babel_utils.assertNoArgs)(tag);
9146
9157
  (0, _marko_compiler_babel_utils.assertNoParams)(tag);
9147
9158
  (0, _marko_compiler_babel_utils.assertNoAttributeTags)(tag);
9148
- const { node, hub: { file } } = tag;
9159
+ const { node } = tag;
9149
9160
  assertNoStyleAttributes(tag);
9150
9161
  const names = collectDynamicStyleNames(tag);
9151
9162
  if (names) {
9152
9163
  checkStyleInterpolations(tag);
9153
9164
  checkDynamicStylePlacement(tag);
9154
9165
  }
9155
- const importPath = getStyleImportPath(file, node, names);
9166
+ const importPath = getStyleImportPath((0, _marko_compiler_babel_utils.getFile)(), node, names);
9156
9167
  (node.extra ??= {}).styleImportPath = importPath;
9157
- if (importPath) addAssetImport(file, importPath);
9168
+ if (importPath) addAssetImport(importPath);
9158
9169
  if (names) {
9159
9170
  analyzeDynamicStyle(tag, names);
9160
9171
  addSetupStatement(getOrCreateSection(tag));
@@ -9192,14 +9203,14 @@ function collectDynamicStyleNames(tag) {
9192
9203
  const program = (0, _marko_compiler_babel_utils.getProgram)().node;
9193
9204
  const index = programDynamicStyleNameCounts.get(program) ?? 0;
9194
9205
  programDynamicStyleNameCounts.set(program, index + 1);
9195
- (names ??= []).push(dynamicStyleName(tag, index));
9206
+ (names ??= []).push(dynamicStyleName(index));
9196
9207
  } else if (!_marko_compiler.types.isMarkoText(child)) throw tag.hub.buildError(child, "The [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) only supports text and `${...}` interpolations. For a native html [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) use the `html-style` core tag instead.");
9197
9208
  return names;
9198
9209
  }
9199
9210
  const styleNameUnsafeReg = /[^a-zA-Z0-9_]/g;
9200
9211
  const encodeStyleNameChar = (c) => "-" + c.charCodeAt(0).toString(36);
9201
- function dynamicStyleName(tag, index) {
9202
- const { file } = tag.hub;
9212
+ function dynamicStyleName(index) {
9213
+ const file = (0, _marko_compiler_babel_utils.getFile)();
9203
9214
  const id = (0, _marko_compiler_babel_utils.getTemplateId)(file.markoOpts, file.opts.filename, index.toString(36));
9204
9215
  return "--" + ((file.markoOpts.runtimeId || "M_") + id).replace(styleNameUnsafeReg, encodeStyleNameChar);
9205
9216
  }
@@ -9254,13 +9265,13 @@ function dynamicStyleValues(node) {
9254
9265
  return values;
9255
9266
  }
9256
9267
  function emitStyleImport(tag) {
9257
- const { node, hub: { file } } = tag;
9268
+ const { node } = tag;
9258
9269
  const importPath = node.extra?.styleImportPath;
9259
9270
  if (!importPath) return;
9260
9271
  if (!node.var) (0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(importPath)));
9261
9272
  else if (_marko_compiler.types.isIdentifier(node.var)) (0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.importDeclaration([_marko_compiler.types.importNamespaceSpecifier(node.var)], _marko_compiler.types.stringLiteral(importPath)));
9262
9273
  else {
9263
- const varDecl = _marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(node.var, (0, _marko_compiler_babel_utils.importStar)(file, importPath, "style"))]);
9274
+ const varDecl = _marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(node.var, (0, _marko_compiler_babel_utils.importStar)((0, _marko_compiler_babel_utils.getFile)(), importPath, "style"))]);
9264
9275
  (0, _marko_compiler_babel_utils.getProgram)().node.body.push(isOutputDOM() ? varDecl : _marko_compiler.types.markoScriptlet([varDecl], true));
9265
9276
  }
9266
9277
  }
@@ -9514,7 +9525,7 @@ var import_declaration_default = {
9514
9525
  const { node } = importDecl;
9515
9526
  const { source } = node;
9516
9527
  const { value } = source;
9517
- if (_marko_compiler.types.isProgram(importDecl.parent) && isClientAssetImport((0, _marko_compiler_babel_utils.getFile)(), value)) addAssetImport((0, _marko_compiler_babel_utils.getFile)(), value);
9528
+ if (_marko_compiler.types.isProgram(importDecl.parent) && isClientAssetImport((0, _marko_compiler_babel_utils.getFile)(), value)) addAssetImport(value);
9518
9529
  const tagImport = (0, _marko_compiler_babel_utils.resolveTagImport)(importDecl, value);
9519
9530
  if (tagImport) {
9520
9531
  (node.extra ??= {}).tagImport = tagImport;
@@ -9533,7 +9544,7 @@ var import_declaration_default = {
9533
9544
  return;
9534
9545
  }
9535
9546
  (node.extra ??= {}).loadImport = loadImport;
9536
- const { file } = importDecl.hub;
9547
+ const file = (0, _marko_compiler_babel_utils.getFile)();
9537
9548
  const loadFile = tagImport && (0, _marko_compiler_babel_utils.loadFileForImport)(file, value);
9538
9549
  if (!loadFile) throw importDecl.buildCodeFrameError("Unable to resolve marko file for load import.");
9539
9550
  (file.path.node.extra.loadImports ??= /* @__PURE__ */ new Set()).add(loadFile.opts.filename);
@@ -9550,8 +9561,7 @@ var import_declaration_default = {
9550
9561
  const { local } = node.specifiers.find(_marko_compiler.types.isImportDefaultSpecifier);
9551
9562
  const binding = importDecl.scope.getBinding(local.name);
9552
9563
  if (isOutputHTML()) {
9553
- const { file } = importDecl.hub;
9554
- const loadFile = (0, _marko_compiler_babel_utils.loadFileForImport)(file, node.source.value);
9564
+ const loadFile = (0, _marko_compiler_babel_utils.loadFileForImport)((0, _marko_compiler_babel_utils.getFile)(), node.source.value);
9555
9565
  const wrappedName = getOrCreateHtmlLoadWrapped(getReadyId(loadFile), _marko_compiler.types.identifier(local.name), loadFile.opts.filename, loadImport.render ? void 0 : loadImport.triggers);
9556
9566
  for (const ref of binding.referencePaths) ref.replaceWith(_marko_compiler.types.identifier(wrappedName));
9557
9567
  node.source.value = tagImport;
@@ -9559,7 +9569,7 @@ var import_declaration_default = {
9559
9569
  return;
9560
9570
  } else if (binding.referencePaths.every((ref) => _marko_compiler.types.isMarkoTag(ref.parent) && ref.parent.extra?.tagNameLoad)) importDecl.remove();
9561
9571
  else {
9562
- const { file } = importDecl.hub;
9572
+ const file = (0, _marko_compiler_babel_utils.getFile)();
9563
9573
  const loadFile = (0, _marko_compiler_babel_utils.loadFileForImport)(file, node.source.value);
9564
9574
  const resolvedPath = (0, _marko_compiler_babel_utils.resolveRelativePath)(file, loadFile.opts.filename);
9565
9575
  importRuntimeFeature("catch");
@@ -9988,7 +9998,7 @@ function translateHTML(tag) {
9988
9998
  }
9989
9999
  function translateDOM(tag) {
9990
10000
  const { node } = tag;
9991
- const { file } = tag.hub;
10001
+ const file = (0, _marko_compiler_babel_utils.getFile)();
9992
10002
  const relativePath = getTagRelativePath(tag);
9993
10003
  const programSection = (0, _marko_compiler_babel_utils.getProgram)().node.extra.section;
9994
10004
  const childFile = (0, _marko_compiler_babel_utils.loadFileForTag)(tag);
@@ -10040,7 +10050,8 @@ function translateDOM(tag) {
10040
10050
  tag.remove();
10041
10051
  }
10042
10052
  function getTagRelativePath(tag) {
10043
- const { node, hub: { file } } = tag;
10053
+ const { node } = tag;
10054
+ const file = (0, _marko_compiler_babel_utils.getFile)();
10044
10055
  let relativePath;
10045
10056
  if (_marko_compiler.types.isStringLiteral(node.name)) {
10046
10057
  const tagDef = (0, _marko_compiler_babel_utils.getTagDef)(tag);
@@ -9,5 +9,5 @@ declare module "@marko/compiler" {
9
9
  assetImports?: Set<string>;
10
10
  }
11
11
  }
12
- export declare function addAssetImport(file: t.BabelFile, request: string): void;
12
+ export declare function addAssetImport(request: string): void;
13
13
  export declare function isClientAssetImport(file: t.BabelFile, request: string): boolean;
@@ -5,6 +5,6 @@ declare module "@marko/compiler/dist/types" {
5
5
  [kRawText]?: true;
6
6
  }
7
7
  }
8
- export declare function bodyToTextLiteral(body: t.MarkoTagBody): t.ArrayExpression | t.ArrowFunctionExpression | t.AssignmentExpression | t.AwaitExpression | t.BigIntLiteral | t.BinaryExpression | t.BindExpression | t.BooleanLiteral | t.CallExpression | t.ClassExpression | t.ConditionalExpression | t.DecimalLiteral | t.DoExpression | t.FunctionExpression | t.Identifier | t.Import | t.ImportExpression | t.JSXElement | t.JSXFragment | t.LogicalExpression | t.MarkoParseError | t.MemberExpression | t.MetaProperty | t.ModuleExpression | t.NewExpression | t.NullLiteral | t.NumericLiteral | t.ObjectExpression | t.OptionalCallExpression | t.OptionalMemberExpression | t.ParenthesizedExpression | t.PipelineBareFunction | t.PipelinePrimaryTopicReference | t.PipelineTopicExpression | t.RecordExpression | t.RegExpLiteral | t.SequenceExpression | t.StringLiteral | t.Super | t.TSAsExpression | t.TSInstantiationExpression | t.TSNonNullExpression | t.TSSatisfiesExpression | t.TSTypeAssertion | t.TaggedTemplateExpression | t.TemplateLiteral | t.ThisExpression | t.TopicReference | t.TupleExpression | t.TypeCastExpression | t.UnaryExpression | t.UpdateExpression | t.YieldExpression;
8
+ export declare function bodyToTextLiteral(body: t.MarkoTagBody, decodeEntities?: boolean): t.ArrayExpression | t.ArrowFunctionExpression | t.AssignmentExpression | t.AwaitExpression | t.BigIntLiteral | t.BinaryExpression | t.BindExpression | t.BooleanLiteral | t.CallExpression | t.ClassExpression | t.ConditionalExpression | t.DecimalLiteral | t.DoExpression | t.FunctionExpression | t.Identifier | t.Import | t.ImportExpression | t.JSXElement | t.JSXFragment | t.LogicalExpression | t.MarkoParseError | t.MemberExpression | t.MetaProperty | t.ModuleExpression | t.NewExpression | t.NullLiteral | t.NumericLiteral | t.ObjectExpression | t.OptionalCallExpression | t.OptionalMemberExpression | t.ParenthesizedExpression | t.PipelineBareFunction | t.PipelinePrimaryTopicReference | t.PipelineTopicExpression | t.RecordExpression | t.RegExpLiteral | t.SequenceExpression | t.StringLiteral | t.Super | t.TSAsExpression | t.TSInstantiationExpression | t.TSNonNullExpression | t.TSSatisfiesExpression | t.TSTypeAssertion | t.TaggedTemplateExpression | t.TemplateLiteral | t.ThisExpression | t.TopicReference | t.TupleExpression | t.TypeCastExpression | t.UnaryExpression | t.UpdateExpression | t.YieldExpression;
9
9
  export declare function bodyToRawTextLiteral(body: t.MarkoTagBody): t.ArrayExpression | t.ArrowFunctionExpression | t.AssignmentExpression | t.AwaitExpression | t.BigIntLiteral | t.BinaryExpression | t.BindExpression | t.BooleanLiteral | t.CallExpression | t.ClassExpression | t.ConditionalExpression | t.DecimalLiteral | t.DoExpression | t.FunctionExpression | t.Identifier | t.Import | t.ImportExpression | t.JSXElement | t.JSXFragment | t.LogicalExpression | t.MarkoParseError | t.MemberExpression | t.MetaProperty | t.ModuleExpression | t.NewExpression | t.NullLiteral | t.NumericLiteral | t.ObjectExpression | t.OptionalCallExpression | t.OptionalMemberExpression | t.ParenthesizedExpression | t.PipelineBareFunction | t.PipelinePrimaryTopicReference | t.PipelineTopicExpression | t.RecordExpression | t.RegExpLiteral | t.SequenceExpression | t.StringLiteral | t.Super | t.TSAsExpression | t.TSInstantiationExpression | t.TSNonNullExpression | t.TSSatisfiesExpression | t.TSTypeAssertion | t.TaggedTemplateExpression | t.TemplateLiteral | t.ThisExpression | t.TopicReference | t.TupleExpression | t.TypeCastExpression | t.UnaryExpression | t.UpdateExpression | t.YieldExpression;
10
10
  export declare function injectTextCoercion(expr: t.Expression): void;
@@ -23,6 +23,7 @@ export declare function toIter<T>(data: Opt<T>): Iterable<T>;
23
23
  export declare function includes<T>(data: Opt<T>, item: T): boolean;
24
24
  export declare function find<T>(data: Opt<T>, cb: (item: T, index: number) => boolean): Opt<T>;
25
25
  export declare function some<T>(data: Opt<T>, cb: (item: T, index: number) => boolean): boolean;
26
+ export declare function every<T>(data: Opt<T>, cb: (item: T, index: number) => boolean): boolean;
26
27
  export declare function toArray<T, R>(data: Opt<T>, cb: (item: T, index: number) => R): R[];
27
28
  export declare function mapToString<T>(data: Opt<T>, sep: string, cb: (item: T, index: number) => string): string;
28
29
  export declare function findSorted<T>(compare: Compare<T>, data: T[], item: T): T | undefined;
@@ -3,7 +3,7 @@ import type { AccessorPrefix } from "../../common/accessor.debug";
3
3
  import * as BindingType from "./constants/binding-type";
4
4
  import { type Many, type Opt, Sorted } from "./optional";
5
5
  import { type Section } from "./sections";
6
- import { type SerializeReason } from "./serialize-reasons";
6
+ import { type SerializeKey, type SerializeReason } from "./serialize-reasons";
7
7
  import { type Signal } from "./signals";
8
8
  export declare const kBranchSerializeReason: unique symbol;
9
9
  export type Aliases = undefined | Binding | {
@@ -48,6 +48,9 @@ export interface Binding {
48
48
  pruned: boolean | undefined;
49
49
  exposed: boolean;
50
50
  forcePersist: boolean;
51
+ /** Binding-side counterpart of `Section.serializePropKeys`, keyed by
52
+ * accessor prefix (`undefined` is the plain binding key). */
53
+ serializePropKeys: Map<AccessorPrefix | symbol | undefined, SerializeKey> | undefined;
51
54
  reserveSize: number;
52
55
  }
53
56
  export interface InputBinding extends Binding {
@@ -4,9 +4,9 @@ import type { WalkCode } from "../../common/types";
4
4
  import * as ContentType from "./constants/content-type";
5
5
  import type * as Step from "./constants/step";
6
6
  import * as StructureKind from "./constants/structure-kind";
7
- import { type Opt, Sorted } from "./optional";
7
+ import { type OneMany, type Opt, Sorted } from "./optional";
8
8
  import { type Binding, type InputBinding, type KnownExprs, type ParamBinding, type ReferencedBindings, type Sources } from "./references";
9
- import { type SerializeReason, type SerializeReasons } from "./serialize-reasons";
9
+ import { type SerializeKey, type SerializeReason, type SerializeReasons } from "./serialize-reasons";
10
10
  export interface ParamSerializeReasonGroup {
11
11
  id: symbol;
12
12
  reason: NonNullable<Sources["param"]>;
@@ -67,16 +67,29 @@ export interface Section {
67
67
  /** Reasons any of the section's dom nodes resumes, as the analyzed reasons
68
68
  * (not merged) so each one's guard stays buildable. */
69
69
  domSerializeReasons: undefined | SerializeReasons;
70
+ /** Pending serialize exprs, resolved into the reasons (and provenance)
71
+ * once references finalize. */
72
+ serializeExprs: Opt<t.NodeExtra>;
73
+ propSerializeExprs: Map<SerializeKey, OneMany<t.NodeExtra>> | undefined;
74
+ /** Whose values feed each serialization decision — survives force-`true`
75
+ * and counts function-body reads; complete after reference finalize. */
76
+ serializeProvenance: Sources | undefined;
77
+ propSerializeProvenance: Map<SerializeKey, Sources> | undefined;
78
+ /** Interned per-prop reason keys for string/symbol props. */
79
+ serializePropKeys: Map<string | symbol, SerializeKey> | undefined;
70
80
  paramReasonGroups: ParamSerializeReasonGroups | undefined;
71
81
  returnValueExpr: t.NodeExtra | undefined;
72
82
  returnSerializeReason: SerializeReason | undefined;
73
83
  isHoistThrough: true | undefined;
74
84
  upstreamExpression: t.NodeExtra | undefined;
75
- downstreamBinding: {
76
- binding: Binding;
85
+ /** The content's rendering tag (its extra), and the child binding the
86
+ * content feeds when the child can serialize it. */
87
+ downstream: {
88
+ tag: t.MarkoTagExtra;
89
+ binding: Binding | undefined;
77
90
  properties: Opt<string>;
78
91
  exprs: KnownExprs | undefined;
79
- } | false | undefined;
92
+ } | undefined;
80
93
  hasAbortSignal: boolean;
81
94
  /** Count of distinct `$signal` expression roots; analyze allocates each
82
95
  * root's `abortId` from this so translates read, never re-derive. */
@@ -108,6 +121,7 @@ export declare const getScopeIdIdentifier: (section: Section) => t.Identifier;
108
121
  export declare const getSectionParentIsOwner: (section: Section) => boolean, setSectionParentIsOwner: (section: Section, value: boolean) => void;
109
122
  export declare const getBranchRendererArgs: (section: Section) => [template?: t.Expression | undefined, walks?: t.Expression | undefined, setup?: t.Expression | undefined, params?: t.Expression | undefined], setBranchRendererArgs: (section: Section, value: [template?: t.Expression | undefined, walks?: t.Expression | undefined, setup?: t.Expression | undefined, params?: t.Expression | undefined]) => void;
110
123
  export declare function forEachSection(fn: (section: Section) => void): void;
124
+ export declare function getChildSections(section: Section): Section[];
111
125
  export declare function forEachSectionReverse(fn: (section: Section) => void): void;
112
126
  export declare function getNodeContentType(path: t.NodePath<t.Statement>, extraMember: "startType" | "endType", contentInfo?: Section["content"]): ContentType.Value | null;
113
127
  export declare function getSectionRegisterReasons(section: Section): false | SerializeReason;
@@ -119,5 +133,6 @@ export declare function getDirectClosures(section: Section): Opt<Binding>;
119
133
  export declare function isSameOrChildSection(section: Section, other: Section): boolean;
120
134
  export declare function getCommonSection(section: Section, other: Section): Section;
121
135
  export declare function finalizeParamSerializeReasonGroups(section: Section): void;
136
+ export declare function ensureReasonGroups(reason: Section["serializeReason"]): void;
122
137
  export declare function getParamReasonGroupIndex(section: Section, reason: ParamSerializeReasonGroup["reason"]): number;
123
- export declare function groupParamsBySection(params: Sources["param"]): Map<Section, import("./optional").OneMany<InputBinding | ParamBinding>>;
138
+ export declare function groupParamsBySection(params: Sources["param"]): Map<Section, OneMany<InputBinding | ParamBinding>>;
@@ -6,6 +6,9 @@ import type { Section } from "./sections";
6
6
  export type SerializeReasons = true | OneMany<Sources>;
7
7
  export declare const sourcesUtil: Sorted<Sources>;
8
8
  export type SerializeReason = true | Sources;
9
+ export type SerializeKey = symbol & {
10
+ __serialize_key__: 1;
11
+ };
9
12
  export declare function isSameReason(a: SerializeReason | undefined, b: SerializeReason | undefined): boolean;
10
13
  export declare function isForceSerialized(section: Section, prop?: Binding | AccessorProp | symbol, prefix?: AccessorPrefix | symbol): boolean;
11
14
  export declare function addSerializeReason(section: Section, reason: undefined | false | SerializeReason, prop?: Binding | AccessorProp | symbol, prefix?: AccessorPrefix | symbol): void;
@@ -1,2 +1,8 @@
1
1
  import { types as t } from "@marko/compiler";
2
+ import { type TagDefinition } from "@marko/compiler/babel-utils";
3
+ declare module "@marko/compiler/dist/types" {
4
+ interface MarkoTag {
5
+ tagDef?: TagDefinition | null;
6
+ }
7
+ }
2
8
  export declare function preAnalyze(program: t.NodePath<t.Program>): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.3.49",
3
+ "version": "6.3.51",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",
@@ -51,14 +51,14 @@
51
51
  }
52
52
  },
53
53
  "dependencies": {
54
- "@marko/compiler": "^5.42.4",
54
+ "@marko/compiler": "^5.42.5",
55
55
  "csstype": "^3.2.3",
56
56
  "fastest-levenshtein": "^1.0.16",
57
57
  "magic-string": "^0.30.21"
58
58
  },
59
59
  "devDependencies": {
60
- "@marko/runtime-tags": "npm:marko@6.3.49",
61
- "marko": "5.39.39"
60
+ "@marko/runtime-tags": "npm:marko@6.3.51",
61
+ "marko": "5.39.40"
62
62
  },
63
63
  "engines": {
64
64
  "node": ">=22"