marko 6.1.18 → 6.1.20

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.
@@ -25,7 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  let package_json = require("../../package.json");
26
26
  let _marko_compiler = require("@marko/compiler");
27
27
  let _marko_compiler_babel_utils = require("@marko/compiler/babel-utils");
28
- let _marko_compiler_config = require("@marko/compiler/config");
29
28
  let node_path = require("node:path");
30
29
  node_path = __toESM(node_path);
31
30
  let path = require("path");
@@ -1765,13 +1764,13 @@ function getBindingPropTree(binding) {
1765
1764
  };
1766
1765
  if (!binding.reads.size) {
1767
1766
  if (!binding.aliases.size) {
1768
- props.props = {};
1767
+ props.props = Object.create(null);
1769
1768
  for (const [property, alias] of binding.propertyAliases) props.props[property] = getBindingPropTree(alias);
1770
1769
  } else if (binding.aliases.size === 1) {
1771
1770
  const [restAlias] = binding.aliases;
1772
1771
  if (hasSupersetExcludeProperties(binding, restAlias.excludeProperties)) {
1773
1772
  props.rest = getBindingPropTree(restAlias);
1774
- props.props = {};
1773
+ props.props = Object.create(null);
1775
1774
  if (restAlias.type === 2) restAlias.export ??= generateUid(restAlias.name);
1776
1775
  forEach(restAlias.excludeProperties, (property) => {
1777
1776
  const propAlias = binding.propertyAliases.get(property);
@@ -2013,29 +2012,30 @@ function _attr_style(value) {
2013
2012
  }
2014
2013
  function _attr_option_value(value) {
2015
2014
  const valueAttr = _attr("value", value);
2016
- if (normalizedValueMatches(getContext(kSelectedValue), value)) return valueAttr + " selected";
2015
+ const selectedValue = getContext(kSelectedValue);
2016
+ if (selectedValue !== void 0 && normalizedValueMatches(selectedValue, value)) return valueAttr + " selected";
2017
2017
  return valueAttr;
2018
2018
  }
2019
2019
  const kSelectedValue = Symbol("selectedValue");
2020
- function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content) {
2021
- if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange);
2020
+ function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content, serializeType) {
2021
+ if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange, serializeType);
2022
2022
  if (content) withContext(kSelectedValue, value, content);
2023
2023
  }
2024
- function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange) {
2025
- if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange);
2024
+ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
2025
+ if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
2026
2026
  return _escape(value);
2027
2027
  }
2028
- function _attr_input_value(scopeId, nodeAccessor, value, valueChange) {
2029
- if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange);
2028
+ function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
2029
+ if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
2030
2030
  return _attr("value", value);
2031
2031
  }
2032
- function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange) {
2033
- if (checkedChange) writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange);
2032
+ function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange, serializeType) {
2033
+ if (checkedChange) writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType);
2034
2034
  return isNotVoid(checked) ? " checked" : "";
2035
2035
  }
2036
- function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value) {
2036
+ function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value, serializeType) {
2037
2037
  const valueAttr = _attr("value", value);
2038
- if (checkedValueChange) writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange);
2038
+ if (checkedValueChange) writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange, serializeType);
2039
2039
  return normalizedValueMatches(checkedValue, value) ? valueAttr + " checked" : valueAttr;
2040
2040
  }
2041
2041
  const checkedValuesRefs = /* @__PURE__ */ new WeakMap();
@@ -2049,9 +2049,9 @@ function getCheckedValueRef(checkedValue) {
2049
2049
  return ref;
2050
2050
  }
2051
2051
  }
2052
- function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange) {
2052
+ function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, serializeType) {
2053
2053
  const normalizedOpen = isNotVoid(open);
2054
- if (openChange) writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange);
2054
+ if (openChange) writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange, serializeType);
2055
2055
  return normalizedOpen ? " open" : "";
2056
2056
  }
2057
2057
  function _attr(name, value) {
@@ -2063,11 +2063,16 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
2063
2063
  let events;
2064
2064
  switch (tagName) {
2065
2065
  case "input":
2066
- if (data.checkedChange) result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange);
2067
- else if ("checkedValue" in data || data.checkedValueChange) result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value);
2068
- else if (data.valueChange) result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange);
2069
- else break;
2070
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
2066
+ if (data.checkedChange) {
2067
+ result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1);
2068
+ skip = /^checked(?:Value)?(?:Change)?$|[\s/>"'=]/;
2069
+ } else if ("checkedValue" in data || data.checkedValueChange) {
2070
+ result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
2071
+ skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
2072
+ } else if (data.valueChange) {
2073
+ result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
2074
+ skip = /^value(?:Change)?$|[\s/>"'=]/;
2075
+ } else break;
2071
2076
  break;
2072
2077
  case "select":
2073
2078
  case "textarea":
@@ -2082,7 +2087,7 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
2082
2087
  case "details":
2083
2088
  case "dialog":
2084
2089
  if (data.openChange) {
2085
- result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange);
2090
+ result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange, 1);
2086
2091
  skip = /^open(?:Change)?$|[\s/>"'=]/;
2087
2092
  }
2088
2093
  break;
@@ -2109,11 +2114,14 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
2109
2114
  }
2110
2115
  return result;
2111
2116
  }
2112
- function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange) {
2113
- writeScope(scopeId, {
2117
+ function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
2118
+ writeScope(scopeId, serializeType ? {
2114
2119
  ["ControlledType:" + nodeAccessor]: type,
2115
2120
  ["ControlledValue:" + nodeAccessor]: value,
2116
2121
  ["ControlledHandler:" + nodeAccessor]: valueChange
2122
+ } : {
2123
+ ["ControlledValue:" + nodeAccessor]: value,
2124
+ ["ControlledHandler:" + nodeAccessor]: valueChange
2117
2125
  });
2118
2126
  }
2119
2127
  function stringAttr(name, value) {
@@ -2175,10 +2183,10 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2175
2183
  _html(`<${renderer}${_attrs(input, "a", branchId, renderer)}>`);
2176
2184
  if (!voidElementsReg.test(renderer)) {
2177
2185
  const renderContent = content || normalizeDynamicRenderer(input.content);
2178
- if (renderer === "textarea") _html(_attr_textarea_value(branchId, "a", input.value, input.valueChange));
2186
+ if (renderer === "textarea") _html(_attr_textarea_value(branchId, "a", input.value, input.valueChange, 1));
2179
2187
  else if (renderContent) {
2180
2188
  if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2181
- if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent);
2189
+ if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent, 1);
2182
2190
  else _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason);
2183
2191
  }
2184
2192
  _html(`</${renderer}>`);
@@ -4070,8 +4078,7 @@ function analyzeAttributeTags(tag) {
4070
4078
  }
4071
4079
  let attrTagMeta = lookup[name];
4072
4080
  if (!attrTagMeta) {
4073
- attrTagMeta = lookup[name] = createAttrTagMeta(name, []);
4074
- curGroup = attrTagMeta.group;
4081
+ attrTagMeta = lookup[name] = createAttrTagMeta(name, curGroup ||= []);
4075
4082
  curGroup.push(name);
4076
4083
  }
4077
4084
  attrTagMeta.dynamic = true;
@@ -4418,7 +4425,8 @@ var native_tag_default = {
4418
4425
  tag.insertBefore(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(spreadIdentifier, spreadExpression)]));
4419
4426
  htmlSelectArgs.set(tag.node, {
4420
4427
  value: _marko_compiler.types.memberExpression(spreadIdentifier, _marko_compiler.types.identifier("value")),
4421
- valueChange: _marko_compiler.types.memberExpression(spreadIdentifier, _marko_compiler.types.identifier("valueChange"))
4428
+ valueChange: _marko_compiler.types.memberExpression(spreadIdentifier, _marko_compiler.types.identifier("valueChange")),
4429
+ serializeType: _marko_compiler.types.numericLiteral(1)
4422
4430
  });
4423
4431
  spreadExpression = spreadIdentifier;
4424
4432
  }
@@ -4435,7 +4443,7 @@ var native_tag_default = {
4435
4443
  valueChange = _marko_compiler.types.memberExpression(spreadIdentifier, _marko_compiler.types.identifier("valueChange"));
4436
4444
  spreadExpression = spreadIdentifier;
4437
4445
  }
4438
- if (valueChange) writeAtStartOfBody = callRuntime("_attr_textarea_value", getScopeIdIdentifier(tagSection), visitAccessor, value, valueChange);
4446
+ if (valueChange) writeAtStartOfBody = callRuntime("_attr_textarea_value", getScopeIdIdentifier(tagSection), visitAccessor, value, valueChange, staticControllable ? void 0 : _marko_compiler.types.numericLiteral(1));
4439
4447
  else if (value) writeAtStartOfBody = callRuntime("_escape", value);
4440
4448
  }
4441
4449
  for (const attr of staticAttrs) {
@@ -4495,7 +4503,7 @@ var native_tag_default = {
4495
4503
  if (selectArgs) {
4496
4504
  if (!tagExtra[kSkipEndTag]) write`</${tagName}>`;
4497
4505
  flushInto(tag);
4498
- tag.insertBefore(_marko_compiler.types.expressionStatement(callRuntime("_attr_select_value", getScopeIdIdentifier(tagSection), nodeBinding && getScopeAccessorLiteral(nodeBinding), selectArgs.value, selectArgs.valueChange, _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement(tag.node.body.body)))));
4506
+ tag.insertBefore(_marko_compiler.types.expressionStatement(callRuntime("_attr_select_value", getScopeIdIdentifier(tagSection), nodeBinding && getScopeAccessorLiteral(nodeBinding), selectArgs.value, selectArgs.valueChange, _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement(tag.node.body.body)), selectArgs.serializeType)));
4499
4507
  } else if (isTextOnly) {
4500
4508
  for (const child of tag.node.body.body) if (_marko_compiler.types.isMarkoText(child)) write`${child.value}`;
4501
4509
  else if (_marko_compiler.types.isMarkoPlaceholder(child)) write`${callRuntime(getTextOnlyEscapeHelper(tagName), child.value)}`;
@@ -6919,7 +6927,7 @@ function getReadReplacement(node, signal) {
6919
6927
  else if (read.getter?.hoisted) replacement = _marko_compiler.types.callExpression(getBindingGetterIdentifier(readBinding, read.getter.hoisted), [getScopeExpression(extra.section, read.getter.hoisted)]);
6920
6928
  else if (readBinding.type === 0) {
6921
6929
  if (read.getter) replacement = _marko_compiler.types.callExpression(getBindingGetterIdentifier(readBinding, readBinding.section), [getScopeExpression(extra.section, readBinding.section)]);
6922
- } else if (!_marko_compiler_config.optimize && read.ownVar) replacement = callRuntime("_assert_init", extra.section ? getScopeExpression(extra.section, readBinding.section) : scopeIdentifier, getScopeAccessorLiteral(readBinding));
6930
+ } else if (!isOptimize() && read.ownVar) replacement = callRuntime("_assert_init", extra.section ? getScopeExpression(extra.section, readBinding.section) : scopeIdentifier, getScopeAccessorLiteral(readBinding));
6923
6931
  else replacement = createScopeReadExpression(readBinding, extra.section);
6924
6932
  else if (node.type !== "Identifier") replacement = _marko_compiler.types.identifier(readBinding.name);
6925
6933
  else if (read.getter?.hoisted) replacement = getBindingGetterIdentifier(readBinding, read.getter.hoisted);
@@ -7982,9 +7990,9 @@ var style_default = {
7982
7990
  (0, _marko_compiler_babel_utils.assertNoParams)(tag);
7983
7991
  (0, _marko_compiler_babel_utils.assertNoAttributeTags)(tag);
7984
7992
  const { node, hub: { file } } = tag;
7985
- const ext = STYLE_EXT_REG.exec(node.rawValue || "")?.[1]?.slice(1);
7993
+ const extClass = (STYLE_EXT_REG.exec(node.rawValue || "")?.[1]?.slice(1))?.replace(/\./g, " ");
7986
7994
  for (const attr of node.attributes) {
7987
- if (attr.start == null && attr.type === "MarkoAttribute" && attr.name === "class" && attr.value.type === "StringLiteral" && attr.value.value === ext) continue;
7995
+ if (attr.start == null && attr.type === "MarkoAttribute" && attr.name === "class" && attr.value.type === "StringLiteral" && attr.value.value === extClass) continue;
7988
7996
  throw tag.hub.buildError(attr.value, "The `style` does not support html attributes." + htmlStyleTagAlternateMsg);
7989
7997
  }
7990
7998
  for (const child of node.body.body) if (child.type !== "MarkoText") throw tag.hub.buildError(child, "The [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) currently only supports static content." + htmlStyleTagAlternateMsg);
@@ -8481,7 +8489,7 @@ var referenced_identifier_default = {
8481
8489
  abortIdsByExpression = /* @__PURE__ */ new Map();
8482
8490
  abortIdsByExpressionForSection.set(section, abortIdsByExpression);
8483
8491
  }
8484
- if (!exprId) {
8492
+ if (exprId === void 0) {
8485
8493
  exprId = abortIdsByExpression.size;
8486
8494
  abortIdsByExpression.set(exprRoot, exprId);
8487
8495
  addStatement("render", section, exprRoot.node.extra?.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(importRuntime("$signalReset"), [scopeIdentifier, _marko_compiler.types.numericLiteral(exprId)])), false);
@@ -8774,7 +8782,8 @@ var dynamic_tag_default = {
8774
8782
  let tagExpression = node.name;
8775
8783
  if (isClassAPI) {
8776
8784
  const classTagTemplate = (0, _marko_compiler_babel_utils.getTagTemplate)(tag);
8777
- const classHydration = (classTagTemplate ? (0, _marko_compiler_babel_utils.loadFileForTag)(tag) : void 0)?.metadata.marko.classHydration;
8785
+ const classFile = classTagTemplate ? (0, _marko_compiler_babel_utils.loadFileForTag)(tag) : void 0;
8786
+ const classHydration = classFile?.metadata.marko.classHydration;
8778
8787
  if (!isOutputHTML() && isOptimize() && classTagTemplate && !tagsSerializeReason && !classHydration) {
8779
8788
  tag.remove();
8780
8789
  return;
@@ -8782,8 +8791,8 @@ var dynamic_tag_default = {
8782
8791
  ((0, _marko_compiler_babel_utils.getProgram)().node.extra ??= {}).needsCompat = true;
8783
8792
  if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)(tag.hub.file, getTagRelativePath(tag), tagExpression.value);
8784
8793
  if (classTagTemplate) {
8785
- const preserveBoundary = classHydration === "descendant" && !tagsSerializeReason;
8786
- if (isOutputHTML() ? serializeReason || preserveBoundary : serializeReason) (0, _marko_compiler_babel_utils.getProgram)().node.body.push(isOutputHTML() ? _marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression((0, _marko_compiler_babel_utils.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"), [
8794
+ const preserveBoundary = !tagsSerializeReason && (classHydration === "descendant" || classHydration === "self" && !!classFile?.metadata.marko.hasComponentBrowser);
8795
+ if (isOutputHTML() ? serializeReason || classHydration : serializeReason) (0, _marko_compiler_babel_utils.getProgram)().node.body.push(isOutputHTML() ? _marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression((0, _marko_compiler_babel_utils.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"), [
8787
8796
  _marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.loadFileForTag)(tag).metadata.marko.id),
8788
8797
  _marko_compiler.types.identifier(tagExpression.name),
8789
8798
  ...preserveBoundary ? [_marko_compiler.types.stringLiteral("preserve")] : []
@@ -10,6 +10,7 @@ declare enum ClassHydration {
10
10
  declare module "@marko/compiler" {
11
11
  interface MarkoMeta {
12
12
  classHydration?: ClassHydration;
13
+ hasComponentBrowser?: boolean;
13
14
  }
14
15
  }
15
16
  declare module "@marko/compiler/dist/types" {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.1.18",
3
+ "version": "6.1.20",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",