marko 6.0.0-next.3.34 → 6.0.0-next.3.35

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.
@@ -3114,7 +3114,9 @@ var program_default = {
3114
3114
  currentProgramPath = program;
3115
3115
  startSection(program);
3116
3116
  trackParamsReferences(program, 2 /* input */);
3117
- program.node.params[0].extra.binding.nullable = false;
3117
+ if (program.node.params[0]?.extra?.binding) {
3118
+ program.node.params[0].extra.binding.nullable = false;
3119
+ }
3118
3120
  const { scope } = program;
3119
3121
  (program.node.extra ??= {}).domExports = {
3120
3122
  template: scope.generateUid("template_"),
@@ -4569,6 +4571,7 @@ var native_tag_default = {
4569
4571
  );
4570
4572
  }
4571
4573
  }
4574
+ setForceResumeScope(section);
4572
4575
  translateVar(
4573
4576
  tag,
4574
4577
  callRuntime(
@@ -8008,14 +8011,14 @@ var function_default = {
8008
8011
  if (markoRoot && (markoRoot.isMarkoPlaceholder() || markoRoot.isMarkoScriptlet() && markoRoot.node.target === "server")) {
8009
8012
  return;
8010
8013
  }
8014
+ if (isMarkoAttribute(markoRoot) && ((0, import_babel_utils37.isNativeTag)(markoRoot.parentPath) && /^on[A-Z-]/.test(markoRoot.node.name) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))) {
8015
+ return;
8016
+ }
8011
8017
  const { node } = fn;
8012
8018
  const extra = node.extra ??= {};
8013
8019
  const name2 = extra.name = fn.node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ? import_compiler47.types.toIdentifier(
8014
8020
  markoRoot.parentPath.has("var") ? markoRoot.parentPath.get("var") : markoRoot.parentPath.get("name")
8015
8021
  ) : markoRoot.node.name : import_compiler47.types.isVariableDeclarator(fn.parent) && import_compiler47.types.isIdentifier(fn.parent.id) ? fn.parent.id.name : import_compiler47.types.isObjectMethod(node) && import_compiler47.types.isIdentifier(node.key) ? node.key.name : "anonymous");
8016
- if (isMarkoAttribute(markoRoot) && ((0, import_babel_utils37.isNativeTag)(markoRoot.parentPath) && /^on[A-Z-]/.test(markoRoot.node.name) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))) {
8017
- return;
8018
- }
8019
8022
  const {
8020
8023
  markoOpts,
8021
8024
  opts: { filename }
@@ -8370,6 +8373,7 @@ var import_compiler51 = require("@marko/compiler");
8370
8373
  var import_babel_utils40 = require("@marko/compiler/babel-utils");
8371
8374
  var import_path4 = __toESM(require("path"));
8372
8375
  var kChildScopeBinding = Symbol("custom tag child scope");
8376
+ var kChildAttrExprs = Symbol("custom tag child attribute expressions");
8373
8377
  var custom_tag_default = {
8374
8378
  analyze: {
8375
8379
  enter(tag) {
@@ -8398,12 +8402,14 @@ var custom_tag_default = {
8398
8402
  void 0,
8399
8403
  tagExtra
8400
8404
  );
8405
+ tagExtra[kChildAttrExprs] = /* @__PURE__ */ new Set([tagExtra]);
8401
8406
  const childFile = (0, import_babel_utils40.loadFileForTag)(tag);
8402
8407
  if (childFile.opts.filename === tag.hub.file.opts.filename) {
8403
8408
  mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
8404
8409
  } else {
8405
8410
  const childProgramExtra = childFile.ast.program.extra;
8406
8411
  analyzeAttrs(
8412
+ tagExtra,
8407
8413
  section,
8408
8414
  tag,
8409
8415
  childProgramExtra?.domExports.params?.props?.[0]
@@ -8442,40 +8448,51 @@ function translateHTML(tag) {
8442
8448
  }
8443
8449
  const tagVar = node.var;
8444
8450
  const section = getSection(tag);
8445
- const childScopeBinding = node.extra[kChildScopeBinding];
8446
- const peekScopeId = tag.scope.generateUidIdentifier(childScopeBinding?.name);
8447
- tag.insertBefore(
8448
- import_compiler51.types.variableDeclaration("const", [
8449
- import_compiler51.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
8450
- ])
8451
- );
8452
- getSerializedScopeProperties(section).set(
8453
- getScopeAccessorLiteral(childScopeBinding),
8454
- callRuntime("writeExistingScope", peekScopeId)
8455
- );
8456
8451
  const inputExport = (0, import_babel_utils40.loadFileForTag)(tag)?.ast.program.extra?.domExports?.params?.props?.[0];
8457
8452
  const { properties, statements } = inputExport ? translateAttrs(tag, inputExport.props) : {
8458
8453
  properties: [],
8459
8454
  statements: []
8460
8455
  };
8461
- if (tagVar) {
8462
- statements.push(
8463
- import_compiler51.types.expressionStatement(
8464
- callRuntime(
8465
- "setTagVar",
8466
- getScopeIdIdentifier(section),
8467
- peekScopeId,
8468
- import_compiler51.types.stringLiteral(
8469
- getResumeRegisterId(
8470
- section,
8471
- node.var.extra?.binding,
8472
- // TODO: node.var is not always an identifier.
8473
- "var"
8456
+ let providesStatefulAttrs = false;
8457
+ for (const expr of tag.node.extra[kChildAttrExprs]) {
8458
+ if (isReferencedExtra(expr) && isStatefulReferences(expr.referencedBindings)) {
8459
+ providesStatefulAttrs = true;
8460
+ break;
8461
+ }
8462
+ }
8463
+ if (providesStatefulAttrs || tagVar) {
8464
+ const childScopeBinding = node.extra[kChildScopeBinding];
8465
+ const peekScopeId = tag.scope.generateUidIdentifier(
8466
+ childScopeBinding?.name
8467
+ );
8468
+ tag.insertBefore(
8469
+ import_compiler51.types.variableDeclaration("const", [
8470
+ import_compiler51.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
8471
+ ])
8472
+ );
8473
+ getSerializedScopeProperties(section).set(
8474
+ getScopeAccessorLiteral(childScopeBinding),
8475
+ callRuntime("writeExistingScope", peekScopeId)
8476
+ );
8477
+ if (tagVar) {
8478
+ statements.push(
8479
+ import_compiler51.types.expressionStatement(
8480
+ callRuntime(
8481
+ "setTagVar",
8482
+ getScopeIdIdentifier(section),
8483
+ peekScopeId,
8484
+ import_compiler51.types.stringLiteral(
8485
+ getResumeRegisterId(
8486
+ section,
8487
+ node.var.extra?.binding,
8488
+ // TODO: node.var is not always an identifier.
8489
+ "var"
8490
+ )
8474
8491
  )
8475
8492
  )
8476
8493
  )
8477
- )
8478
- );
8494
+ );
8495
+ }
8479
8496
  }
8480
8497
  if (node.extra.tagNameNullable) {
8481
8498
  const contentProp = getTranslatedBodyContentProperty(properties);
@@ -8617,7 +8634,7 @@ function getTagRelativePath(tag) {
8617
8634
  }
8618
8635
  return relativePath;
8619
8636
  }
8620
- function analyzeAttrs(section, tag, templateExport) {
8637
+ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
8621
8638
  if (!templateExport) {
8622
8639
  dropReferences(getAllTagReferenceNodes(tag.node));
8623
8640
  return;
@@ -8653,7 +8670,7 @@ function analyzeAttrs(section, tag, templateExport) {
8653
8670
  const childAttrExports = templateExport.props[attrTagMeta.name];
8654
8671
  if (childAttrExports) {
8655
8672
  if (childAttrExports.props && !attrTagMeta.dynamic) {
8656
- analyzeAttrs(section, child, childAttrExports);
8673
+ analyzeAttrs(rootTagExtra, section, child, childAttrExports);
8657
8674
  } else {
8658
8675
  analyzeDynamicChildGroup(attrTagMeta.group, child);
8659
8676
  }
@@ -8677,8 +8694,12 @@ function analyzeAttrs(section, tag, templateExport) {
8677
8694
  }
8678
8695
  }
8679
8696
  }
8680
- for (const { firstTag, referenceNodes } of nodeReferencesByGroup.values()) {
8681
- mergeReferences(section, firstTag.node, referenceNodes);
8697
+ for (const {
8698
+ firstTag: { node },
8699
+ referenceNodes
8700
+ } of nodeReferencesByGroup.values()) {
8701
+ mergeReferences(section, node, referenceNodes);
8702
+ rootTagExtra[kChildAttrExprs].add(node.extra);
8682
8703
  }
8683
8704
  }
8684
8705
  const { attributes } = tag.node;
@@ -8696,6 +8717,8 @@ function analyzeAttrs(section, tag, templateExport) {
8696
8717
  spreadReferenceNodes.push(attr2.value);
8697
8718
  } else if (import_compiler51.types.isMarkoSpreadAttribute(attr2)) {
8698
8719
  spreadReferenceNodes = [attr2.value];
8720
+ } else {
8721
+ rootTagExtra[kChildAttrExprs].add(attr2.value.extra ??= {});
8699
8722
  }
8700
8723
  }
8701
8724
  if (spreadReferenceNodes) {
@@ -1,9 +1,11 @@
1
1
  import { types as t } from "@marko/compiler";
2
2
  import { type Binding } from "../../util/references";
3
3
  declare const kChildScopeBinding: unique symbol;
4
+ declare const kChildAttrExprs: unique symbol;
4
5
  declare module "@marko/compiler/dist/types" {
5
6
  interface MarkoTagExtra {
6
7
  [kChildScopeBinding]?: Binding;
8
+ [kChildAttrExprs]?: Set<t.NodeExtra>;
7
9
  }
8
10
  }
9
11
  declare const _default: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.0-next.3.34",
3
+ "version": "6.0.0-next.3.35",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",