marko 6.1.17 → 6.1.18

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.
package/dist/debug/dom.js CHANGED
@@ -1900,6 +1900,9 @@ const compat = {
1900
1900
  getStartNode(branch) {
1901
1901
  return branch["#StartNode"];
1902
1902
  },
1903
+ getEndNode(branch) {
1904
+ return branch["#EndNode"];
1905
+ },
1903
1906
  setScopeNodes(branch, startNode, endNode) {
1904
1907
  branch["#StartNode"] = startNode;
1905
1908
  branch["#EndNode"] = endNode;
@@ -1898,6 +1898,9 @@ const compat = {
1898
1898
  getStartNode(branch) {
1899
1899
  return branch["#StartNode"];
1900
1900
  },
1901
+ getEndNode(branch) {
1902
+ return branch["#EndNode"];
1903
+ },
1901
1904
  setScopeNodes(branch, startNode, endNode) {
1902
1905
  branch["#StartNode"] = startNode;
1903
1906
  branch["#EndNode"] = endNode;
@@ -10,6 +10,7 @@ export declare const compat: {
10
10
  setRendererId(renderer: any, id: unknown): void;
11
11
  isRenderer(renderer: any): any;
12
12
  getStartNode(branch: any): any;
13
+ getEndNode(branch: any): any;
13
14
  setScopeNodes(branch: any, startNode: Node, endNode: Node): void;
14
15
  runComponentEffects(this: any): void;
15
16
  runComponentDestroy(this: any): void;
package/dist/dom.js CHANGED
@@ -74,6 +74,9 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
74
74
  getStartNode(branch) {
75
75
  return branch.S;
76
76
  },
77
+ getEndNode(branch) {
78
+ return branch.K;
79
+ },
77
80
  setScopeNodes(branch, startNode, endNode) {
78
81
  branch.S = startNode, branch.K = endNode;
79
82
  },
package/dist/dom.mjs CHANGED
@@ -74,6 +74,9 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
74
74
  getStartNode(branch) {
75
75
  return branch.S;
76
76
  },
77
+ getEndNode(branch) {
78
+ return branch.K;
79
+ },
77
80
  setScopeNodes(branch, startNode, endNode) {
78
81
  branch.S = startNode, branch.K = endNode;
79
82
  },
@@ -1348,7 +1348,6 @@ function analyzeTagNameType(tag, allowDynamic) {
1348
1348
  extra.tagNameType = 2;
1349
1349
  extra.tagNameDynamic = true;
1350
1350
  extra.featureType = "class";
1351
- ((0, _marko_compiler_babel_utils.getProgram)().node.extra ??= {}).needsCompat = true;
1352
1351
  } else if (!childFile) {
1353
1352
  extra.tagNameType = 2;
1354
1353
  extra.tagNameDynamic = true;
@@ -8770,12 +8769,27 @@ var dynamic_tag_default = {
8770
8769
  const tagExtra = node.extra;
8771
8770
  const nodeBinding = tagExtra[kDOMBinding];
8772
8771
  const isClassAPI = tagExtra.featureType === "class";
8772
+ const tagsSerializeReason = getSerializeReason(tagSection, nodeBinding);
8773
+ const serializeReason = tagsSerializeReason;
8773
8774
  let tagExpression = node.name;
8774
- if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)(tag.hub.file, getTagRelativePath(tag), tagExpression.value);
8775
- if (isClassAPI) if ((0, _marko_compiler_babel_utils.getTagTemplate)(tag)) {
8776
- if (getSerializeReason(tagSection, nodeBinding)) if (isOutputHTML()) (0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression((0, _marko_compiler_babel_utils.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"), [_marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.loadFileForTag)(tag).metadata.marko.id), _marko_compiler.types.identifier(tagExpression.name)]))], true));
8777
- else (0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.expressionStatement(callRuntime("_resume", _marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.loadFileForTag)(tag).metadata.marko.id), _marko_compiler.types.identifier(tagExpression.name))));
8778
- } else (0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.assignmentExpression("??=", _marko_compiler.types.memberExpression(_marko_compiler.types.identifier(tagExpression.name), _marko_compiler.types.identifier("_")), _marko_compiler.types.identifier(tagExpression.name)))], true));
8775
+ if (isClassAPI) {
8776
+ 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;
8778
+ if (!isOutputHTML() && isOptimize() && classTagTemplate && !tagsSerializeReason && !classHydration) {
8779
+ tag.remove();
8780
+ return;
8781
+ }
8782
+ ((0, _marko_compiler_babel_utils.getProgram)().node.extra ??= {}).needsCompat = true;
8783
+ if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)(tag.hub.file, getTagRelativePath(tag), tagExpression.value);
8784
+ 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"), [
8787
+ _marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.loadFileForTag)(tag).metadata.marko.id),
8788
+ _marko_compiler.types.identifier(tagExpression.name),
8789
+ ...preserveBoundary ? [_marko_compiler.types.stringLiteral("preserve")] : []
8790
+ ]))], true) : _marko_compiler.types.expressionStatement(callRuntime("_resume", _marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.loadFileForTag)(tag).metadata.marko.id), _marko_compiler.types.identifier(tagExpression.name))));
8791
+ } else (0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.assignmentExpression("??=", _marko_compiler.types.memberExpression(_marko_compiler.types.identifier(tagExpression.name), _marko_compiler.types.identifier("_")), _marko_compiler.types.identifier(tagExpression.name)))], true));
8792
+ } else if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)(tag.hub.file, getTagRelativePath(tag), tagExpression.value);
8779
8793
  const { properties, statements } = translateAttrs(tag, void 0, void 0, void 0, isClassAPI ? "renderBody" : "content");
8780
8794
  const args = [];
8781
8795
  let hasTagArgs = false;
@@ -8793,7 +8807,7 @@ var dynamic_tag_default = {
8793
8807
  if (isOutputHTML()) {
8794
8808
  flushInto(tag);
8795
8809
  writeHTMLResumeStatements(tag.get("body"));
8796
- const serializeArg = getSerializeGuard(tagSection, getSerializeReason(tagSection, nodeBinding), true);
8810
+ const serializeArg = getSerializeGuard(tagSection, serializeReason, true);
8797
8811
  const dynamicTagExpr = hasTagArgs ? callRuntime("_dynamic_tag", getScopeIdIdentifier(tagSection), getScopeAccessorLiteral(nodeBinding), tagExpression, _marko_compiler.types.arrayExpression(args), _marko_compiler.types.numericLiteral(0), _marko_compiler.types.numericLiteral(1), serializeArg) : callRuntime("_dynamic_tag", getScopeIdIdentifier(tagSection), getScopeAccessorLiteral(nodeBinding), tagExpression, args[0], args[1] || (serializeArg ? _marko_compiler.types.numericLiteral(0) : void 0), serializeArg ? _marko_compiler.types.numericLiteral(0) : void 0, serializeArg);
8798
8812
  if (node.var) {
8799
8813
  const dynamicScopeIdentifier = generateUidIdentifier(tag.get("name").toString() + "_scope");
@@ -8826,7 +8840,7 @@ var dynamic_tag_default = {
8826
8840
  const argsOrInput = hasTagArgs ? _marko_compiler.types.arrayExpression(args) : args[0];
8827
8841
  if (!_marko_compiler.types.isObjectExpression(argsOrInput) || argsOrInput.properties.length) signal.extraArgs = [_marko_compiler.types.arrowFunctionExpression([], statements.length ? _marko_compiler.types.blockStatement(statements.concat(_marko_compiler.types.returnStatement(argsOrInput))) : argsOrInput)];
8828
8842
  }
8829
- enableDynamicTagResume(tag);
8843
+ if (!isClassAPI) enableDynamicTagResume(tag);
8830
8844
  addValue(section, tagExtra.referencedBindings, signal, tagExpression);
8831
8845
  tag.remove();
8832
8846
  }
@@ -3,6 +3,15 @@ import { type Binding } from "../../util/references";
3
3
  import { type Section } from "../../util/sections";
4
4
  declare const kDOMBinding: unique symbol;
5
5
  declare const kChildOffsetScopeBinding: unique symbol;
6
+ declare enum ClassHydration {
7
+ Self = "self",
8
+ Descendant = "descendant"
9
+ }
10
+ declare module "@marko/compiler" {
11
+ interface MarkoMeta {
12
+ classHydration?: ClassHydration;
13
+ }
14
+ }
6
15
  declare module "@marko/compiler/dist/types" {
7
16
  interface MarkoTagExtra {
8
17
  [kDOMBinding]?: Binding;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.1.17",
3
+ "version": "6.1.18",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",