@marko/runtime-tags 6.0.99 → 6.0.101

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.
@@ -757,6 +757,8 @@ function isMarko(path5) {
757
757
  case "MarkoSpreadAttribute":
758
758
  case "MarkoPlaceholder":
759
759
  case "MarkoScriptlet":
760
+ case "ExportNamedDeclaration":
761
+ case "ExportDefaultDeclaration":
760
762
  return true;
761
763
  default:
762
764
  return false;
@@ -1749,6 +1751,7 @@ function getNodeContentType(path5, extraMember, contentInfo) {
1749
1751
  case "ImportDeclaration":
1750
1752
  case "ExportAllDeclaration":
1751
1753
  case "ExportNamedDeclaration":
1754
+ case "ExportDefaultDeclaration":
1752
1755
  return null;
1753
1756
  case "MarkoTag": {
1754
1757
  const tag = path5;
@@ -1936,7 +1939,7 @@ var function_default = {
1936
1939
  fnExtra.name = node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ? import_compiler8.types.toIdentifier(
1937
1940
  markoRoot.parentPath.has("var") ? markoRoot.parentPath.get("var") : markoRoot.parentPath.get("name")
1938
1941
  ) : markoRoot.node.name : import_compiler8.types.isVariableDeclarator(fn.parent) && import_compiler8.types.isIdentifier(fn.parent.id) ? fn.parent.id.name : import_compiler8.types.isObjectMethod(node) && import_compiler8.types.isIdentifier(node.key) ? node.key.name : "anonymous");
1939
- if (markoRoot.isMarkoScriptlet()) {
1942
+ if (isStaticRoot(markoRoot)) {
1940
1943
  const refs = getStaticDeclRefs(fnExtra, fn);
1941
1944
  if (refs === true) {
1942
1945
  registerFunction(fnExtra, true);
@@ -1968,7 +1971,7 @@ function canIgnoreRegister(markoRoot, exprRoot) {
1968
1971
  return (
1969
1972
  // bail within a placeholder
1970
1973
  markoRoot.isMarkoPlaceholder() || // bail within a server only statement
1971
- markoRoot.isMarkoScriptlet() && markoRoot.node.target === "server" || // bail within the tag name
1974
+ markoRoot.isMarkoScriptlet() && (!markoRoot.node.static || markoRoot.node.target === "server") || // bail within the tag name
1972
1975
  markoRoot.isMarkoTag() && markoRoot.node.name == exprRoot.node || isMarkoAttribute(markoRoot) && (analyzeTagNameType(markoRoot.parentPath) === 0 /* NativeTag */ && // TODO: all native tag functions should avoid registration but right now change handlers require it.
1973
1976
  /^on[A-Z-]/.test(markoRoot.node.name) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))
1974
1977
  );
@@ -1982,11 +1985,12 @@ function getStaticDeclRefs(fnExtra, path5, refs = /* @__PURE__ */ new Set()) {
1982
1985
  const binding = decl.scope.getBinding(name2);
1983
1986
  if (!binding) continue;
1984
1987
  for (const ref of binding.referencePaths) {
1985
- if (isInvokedFunction(ref)) continue;
1988
+ if (isInvokedFunction(ref) || ref.parentPath.type === "Program")
1989
+ continue;
1986
1990
  const exprRoot = getExprRoot(ref);
1987
1991
  const markoRoot = getMarkoRoot(exprRoot);
1988
1992
  if (!markoRoot || canIgnoreRegister(markoRoot, exprRoot)) continue;
1989
- if (markoRoot.isMarkoScriptlet()) {
1993
+ if (isStaticRoot(markoRoot)) {
1990
1994
  if (getStaticDeclRefs(fnExtra, ref, refs) === true) {
1991
1995
  return true;
1992
1996
  }
@@ -2043,6 +2047,17 @@ function registerFunction(fnExtra, reason) {
2043
2047
  function isMarkoAttribute(path5) {
2044
2048
  return path5 ? path5.isMarkoAttribute() : false;
2045
2049
  }
2050
+ function isStaticRoot(path5) {
2051
+ switch (path5.type) {
2052
+ case "MarkoScriptlet":
2053
+ return path5.node.static;
2054
+ case "ExportDefaultDeclaration":
2055
+ case "ExportNamedDeclaration":
2056
+ return true;
2057
+ default:
2058
+ return false;
2059
+ }
2060
+ }
2046
2061
 
2047
2062
  // src/translator/util/for-each-identifier.ts
2048
2063
  function forEachIdentifier(node, cb) {
@@ -8484,6 +8499,8 @@ function resolveBindingSources(binding) {
8484
8499
  binding.sources = aliasRoot2.sources;
8485
8500
  } else if (binding.assignmentSections) {
8486
8501
  binding.sources = createSources(binding, void 0);
8502
+ } else {
8503
+ resolveDerivedSources(binding);
8487
8504
  }
8488
8505
  return;
8489
8506
  }
@@ -9227,7 +9244,7 @@ var const_default = {
9227
9244
  }
9228
9245
  }
9229
9246
  if (!valueExtra.nullable) binding.nullable = false;
9230
- setBindingDownstream(binding, valueExtra);
9247
+ if (!upstreamAlias) setBindingDownstream(binding, valueExtra);
9231
9248
  }
9232
9249
  },
9233
9250
  translate: {
@@ -10830,17 +10847,20 @@ var let_default = {
10830
10847
  }
10831
10848
  const tagSection = getOrCreateSection(tag);
10832
10849
  const binding = trackVarReferences(tag, 1 /* let */);
10833
- mergeReferences(tagSection, tag.node, [
10850
+ const tagExtra = mergeReferences(tagSection, tag.node, [
10834
10851
  valueAttr?.value,
10835
10852
  valueChangeAttr?.value
10836
10853
  ]);
10837
10854
  if (valueChangeAttr) {
10855
+ setBindingDownstream(binding, tagExtra);
10838
10856
  addSerializeReason(
10839
10857
  tagSection,
10840
10858
  true,
10841
10859
  binding,
10842
10860
  getAccessorPrefix().TagVariableChange
10843
10861
  );
10862
+ } else {
10863
+ setBindingDownstream(binding, false);
10844
10864
  }
10845
10865
  },
10846
10866
  translate: {
@@ -1,5 +1,5 @@
1
1
  import type { types as t } from "@marko/compiler";
2
- export type MarkoExprRootPath = t.NodePath<t.MarkoTag | t.MarkoTagBody | t.MarkoAttribute | t.MarkoSpreadAttribute | t.MarkoScriptlet | t.MarkoPlaceholder>;
2
+ export type MarkoExprRootPath = t.NodePath<t.MarkoTag | t.MarkoTagBody | t.MarkoAttribute | t.MarkoSpreadAttribute | t.MarkoScriptlet | t.MarkoPlaceholder | t.ExportNamedDeclaration | t.ExportDefaultDeclaration>;
3
3
  export declare function getMarkoRoot(path: t.NodePath<t.Node>): MarkoExprRootPath | null;
4
4
  export declare function getExprRoot(path: t.NodePath<t.Node>): t.NodePath<t.Node>;
5
5
  export declare function getFnRoot(path: t.NodePath<t.Node>): t.NodePath<t.ArrowFunctionExpression | t.FunctionExpression | t.ObjectMember> | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/runtime-tags",
3
- "version": "6.0.99",
3
+ "version": "6.0.101",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",