@marko/runtime-tags 6.0.100 → 6.0.102

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.
@@ -1,2 +1,3 @@
1
1
  export declare const DEFAULT_RUNTIME_ID = "M";
2
2
  export declare const DEFAULT_RENDER_ID = "_";
3
+ export declare const DYNAMIC_TAG_SCRIPT_REGISTER_ID: string;
package/dist/debug/dom.js CHANGED
@@ -79,6 +79,7 @@ __export(dom_exports, {
79
79
  _on: () => _on,
80
80
  _or: () => _or,
81
81
  _resume: () => _resume,
82
+ _resume_dynamic_tag: () => _resume_dynamic_tag,
82
83
  _return: () => _return,
83
84
  _return_change: () => _return_change,
84
85
  _script: () => _script,
@@ -237,6 +238,11 @@ function normalizeDynamicRenderer(value) {
237
238
  }
238
239
  }
239
240
 
241
+ // src/common/meta.ts
242
+ var DEFAULT_RUNTIME_ID = "M";
243
+ var DEFAULT_RENDER_ID = "_";
244
+ var DYNAMIC_TAG_SCRIPT_REGISTER_ID = true ? "_dynamicTagScript" : "d";
245
+
240
246
  // src/dom/event.ts
241
247
  var defaultDelegator = createDelegator();
242
248
  function _on(element, type, handler) {
@@ -305,10 +311,6 @@ function stripSpacesAndPunctuation(str) {
305
311
  return str.replace(/[^\p{L}\p{N}]/gu, "");
306
312
  }
307
313
 
308
- // src/common/meta.ts
309
- var DEFAULT_RUNTIME_ID = "M";
310
- var DEFAULT_RENDER_ID = "_";
311
-
312
314
  // src/dom/scope.ts
313
315
  var nextScopeId = 1e6;
314
316
  function createScope($global, closestBranch) {
@@ -1925,6 +1927,9 @@ var _dynamic_tag = function dynamicTag(nodeAccessor, getContent, getTagVar, inpu
1925
1927
  true ? `#${normalizedRenderer}/0` : 0,
1926
1928
  (inputIsArgs ? args[0] : args) || {}
1927
1929
  );
1930
+ if (childScope["EventAttributes:" /* EventAttributes */ + (true ? `#${normalizedRenderer}/0` : 0)] || childScope["ControlledHandler:" /* ControlledHandler */ + (true ? `#${normalizedRenderer}/0` : 0)]) {
1931
+ queueEffect(childScope, dynamicTagScript);
1932
+ }
1928
1933
  } else {
1929
1934
  for (const accessor in normalizedRenderer.___localClosures) {
1930
1935
  normalizedRenderer.___localClosures[accessor](
@@ -1950,6 +1955,12 @@ var _dynamic_tag = function dynamicTag(nodeAccessor, getContent, getTagVar, inpu
1950
1955
  }
1951
1956
  };
1952
1957
  };
1958
+ function _resume_dynamic_tag() {
1959
+ _resume(DYNAMIC_TAG_SCRIPT_REGISTER_ID, dynamicTagScript);
1960
+ }
1961
+ function dynamicTagScript(branch) {
1962
+ _attrs_script(branch, true ? `#${branch.___renderer}/0` : 0);
1963
+ }
1953
1964
  function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
1954
1965
  const referenceNode = scope[nodeAccessor];
1955
1966
  const prevBranch = scope["ConditionalScope:" /* ConditionalScope */ + nodeAccessor];
@@ -134,6 +134,11 @@ function normalizeDynamicRenderer(value) {
134
134
  }
135
135
  }
136
136
 
137
+ // src/common/meta.ts
138
+ var DEFAULT_RUNTIME_ID = "M";
139
+ var DEFAULT_RENDER_ID = "_";
140
+ var DYNAMIC_TAG_SCRIPT_REGISTER_ID = true ? "_dynamicTagScript" : "d";
141
+
137
142
  // src/dom/event.ts
138
143
  var defaultDelegator = createDelegator();
139
144
  function _on(element, type, handler) {
@@ -202,10 +207,6 @@ function stripSpacesAndPunctuation(str) {
202
207
  return str.replace(/[^\p{L}\p{N}]/gu, "");
203
208
  }
204
209
 
205
- // src/common/meta.ts
206
- var DEFAULT_RUNTIME_ID = "M";
207
- var DEFAULT_RENDER_ID = "_";
208
-
209
210
  // src/dom/scope.ts
210
211
  var nextScopeId = 1e6;
211
212
  function createScope($global, closestBranch) {
@@ -1822,6 +1823,9 @@ var _dynamic_tag = function dynamicTag(nodeAccessor, getContent, getTagVar, inpu
1822
1823
  true ? `#${normalizedRenderer}/0` : 0,
1823
1824
  (inputIsArgs ? args[0] : args) || {}
1824
1825
  );
1826
+ if (childScope["EventAttributes:" /* EventAttributes */ + (true ? `#${normalizedRenderer}/0` : 0)] || childScope["ControlledHandler:" /* ControlledHandler */ + (true ? `#${normalizedRenderer}/0` : 0)]) {
1827
+ queueEffect(childScope, dynamicTagScript);
1828
+ }
1825
1829
  } else {
1826
1830
  for (const accessor in normalizedRenderer.___localClosures) {
1827
1831
  normalizedRenderer.___localClosures[accessor](
@@ -1847,6 +1851,12 @@ var _dynamic_tag = function dynamicTag(nodeAccessor, getContent, getTagVar, inpu
1847
1851
  }
1848
1852
  };
1849
1853
  };
1854
+ function _resume_dynamic_tag() {
1855
+ _resume(DYNAMIC_TAG_SCRIPT_REGISTER_ID, dynamicTagScript);
1856
+ }
1857
+ function dynamicTagScript(branch) {
1858
+ _attrs_script(branch, true ? `#${branch.___renderer}/0` : 0);
1859
+ }
1850
1860
  function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
1851
1861
  const referenceNode = scope[nodeAccessor];
1852
1862
  const prevBranch = scope["ConditionalScope:" /* ConditionalScope */ + nodeAccessor];
@@ -2393,6 +2403,7 @@ export {
2393
2403
  _on,
2394
2404
  _or,
2395
2405
  _resume,
2406
+ _resume_dynamic_tag,
2396
2407
  _return,
2397
2408
  _return_change,
2398
2409
  _script,
@@ -3003,6 +3003,7 @@ var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
3003
3003
  // src/common/meta.ts
3004
3004
  var DEFAULT_RUNTIME_ID = "M";
3005
3005
  var DEFAULT_RENDER_ID = "_";
3006
+ var DYNAMIC_TAG_SCRIPT_REGISTER_ID = true ? "_dynamicTagScript" : "d";
3006
3007
 
3007
3008
  // src/html/dynamic-tag.ts
3008
3009
  var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
@@ -3073,6 +3074,11 @@ var _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
3073
3074
  `Body content is not supported for the \`<${renderer}>\` tag.`
3074
3075
  );
3075
3076
  }
3077
+ const childScope = getScopeById(branchId);
3078
+ if (childScope && (childScope["EventAttributes:" /* EventAttributes */ + (true ? `#${renderer}/0` : 0)] || childScope["ControlledHandler:" /* ControlledHandler */ + (true ? `#${renderer}/0` : 0)])) {
3079
+ childScope.___renderer = renderer;
3080
+ _script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
3081
+ }
3076
3082
  if (shouldResume) {
3077
3083
  _html(
3078
3084
  state.mark(
@@ -2911,6 +2911,7 @@ var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
2911
2911
  // src/common/meta.ts
2912
2912
  var DEFAULT_RUNTIME_ID = "M";
2913
2913
  var DEFAULT_RENDER_ID = "_";
2914
+ var DYNAMIC_TAG_SCRIPT_REGISTER_ID = true ? "_dynamicTagScript" : "d";
2914
2915
 
2915
2916
  // src/html/dynamic-tag.ts
2916
2917
  var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
@@ -2981,6 +2982,11 @@ var _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2981
2982
  `Body content is not supported for the \`<${renderer}>\` tag.`
2982
2983
  );
2983
2984
  }
2985
+ const childScope = getScopeById(branchId);
2986
+ if (childScope && (childScope["EventAttributes:" /* EventAttributes */ + (true ? `#${renderer}/0` : 0)] || childScope["ControlledHandler:" /* ControlledHandler */ + (true ? `#${renderer}/0` : 0)])) {
2987
+ childScope.___renderer = renderer;
2988
+ _script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
2989
+ }
2984
2990
  if (shouldResume) {
2985
2991
  _html(
2986
2992
  state.mark(
@@ -10,6 +10,7 @@ export declare function renderCatch(scope: Scope, error: unknown): void;
10
10
  export declare function _if(nodeAccessor: Accessor, ...branches: Renderer[]): (scope: Scope, newBranch: number) => void;
11
11
  export declare function patchDynamicTag(fn: <T extends typeof _dynamic_tag>(cond: T) => T): void;
12
12
  export declare let _dynamic_tag: (nodeAccessor: Accessor, getContent?: ((scope: Scope) => Renderer) | 0, getTagVar?: (() => Signal<unknown>) | 0, inputIsArgs?: 1) => Signal<Renderer | string | undefined>;
13
+ export declare function _resume_dynamic_tag(): void;
13
14
  export declare function setConditionalRenderer<T>(scope: Scope, nodeAccessor: Accessor, newRenderer: T, createBranch: ($global: Scope["$global"], renderer: NonNullable<T>, parentScope: Scope, parentNode: ParentNode) => BranchScope): void;
14
15
  export declare function _for_of(nodeAccessor: Accessor, renderer: Renderer): (scope: Scope, value: [all: unknown[], by?: ((item: unknown, index: number) => unknown) | undefined]) => void;
15
16
  export declare function _for_in(nodeAccessor: Accessor, renderer: Renderer): (scope: Scope, value: [obj: {}, by?: ((key: string, v: unknown) => unknown) | undefined]) => void;
package/dist/dom.d.ts CHANGED
@@ -4,7 +4,7 @@ export { forIn, forOf, forTo, forUntil } from "./common/for";
4
4
  export { _call } from "./common/helpers";
5
5
  export { $signal, $signalReset } from "./dom/abort-signal";
6
6
  export { compat } from "./dom/compat";
7
- export { _await, _dynamic_tag, _for_in, _for_of, _for_to, _for_until, _if, _try, } from "./dom/control-flow";
7
+ export { _await, _dynamic_tag, _for_in, _for_of, _for_to, _for_until, _if, _resume_dynamic_tag, _try, } from "./dom/control-flow";
8
8
  export { _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checked_script, _attr_input_checkedValue, _attr_input_checkedValue_script, _attr_input_value, _attr_input_value_script, _attr_select_value, _attr_select_value_script, _attr_textarea_value, _attr_textarea_value_script, } from "./dom/controllable";
9
9
  export { _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _html, _lifecycle, _text, _text_content, } from "./dom/dom";
10
10
  export { _on } from "./dom/event";
package/dist/dom.js CHANGED
@@ -76,6 +76,7 @@ __export(dom_exports, {
76
76
  _on: () => _on,
77
77
  _or: () => _or,
78
78
  _resume: () => _resume,
79
+ _resume_dynamic_tag: () => _resume_dynamic_tag,
79
80
  _return: () => _return,
80
81
  _return_change: () => _return_change,
81
82
  _script: () => _script,
@@ -1238,7 +1239,7 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1238
1239
  childScope,
1239
1240
  0,
1240
1241
  (inputIsArgs ? args[0] : args) || {}
1241
- );
1242
+ ), (childScope["i" /* EventAttributes */ + 0] || childScope["e" /* ControlledHandler */ + 0]) && queueEffect(childScope, dynamicTagScript);
1242
1243
  else {
1243
1244
  for (let accessor in normalizedRenderer.F)
1244
1245
  normalizedRenderer.F[accessor](
@@ -1262,6 +1263,12 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1262
1263
  }
1263
1264
  };
1264
1265
  };
1266
+ function _resume_dynamic_tag() {
1267
+ _resume("d", dynamicTagScript);
1268
+ }
1269
+ function dynamicTagScript(branch) {
1270
+ _attrs_script(branch, 0);
1271
+ }
1265
1272
  function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
1266
1273
  let referenceNode = scope[nodeAccessor], prevBranch = scope["d" /* ConditionalScope */ + nodeAccessor], parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.h || referenceNode).parentNode : referenceNode, newBranch = scope["d" /* ConditionalScope */ + nodeAccessor] = newRenderer && createBranch2(scope.$global, newRenderer, scope, parentNode);
1267
1274
  referenceNode === parentNode ? (prevBranch && (destroyBranch(prevBranch), referenceNode.textContent = ""), newBranch && insertBranchBefore(newBranch, parentNode, null)) : prevBranch ? (newBranch ? insertBranchBefore(newBranch, parentNode, prevBranch.h) : parentNode.insertBefore(referenceNode, prevBranch.h), removeAndDestroyBranch(prevBranch)) : newBranch && (insertBranchBefore(newBranch, parentNode, referenceNode), referenceNode.remove());
package/dist/dom.mjs CHANGED
@@ -1138,7 +1138,7 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1138
1138
  childScope,
1139
1139
  0,
1140
1140
  (inputIsArgs ? args[0] : args) || {}
1141
- );
1141
+ ), (childScope["i" /* EventAttributes */ + 0] || childScope["e" /* ControlledHandler */ + 0]) && queueEffect(childScope, dynamicTagScript);
1142
1142
  else {
1143
1143
  for (let accessor in normalizedRenderer.F)
1144
1144
  normalizedRenderer.F[accessor](
@@ -1162,6 +1162,12 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1162
1162
  }
1163
1163
  };
1164
1164
  };
1165
+ function _resume_dynamic_tag() {
1166
+ _resume("d", dynamicTagScript);
1167
+ }
1168
+ function dynamicTagScript(branch) {
1169
+ _attrs_script(branch, 0);
1170
+ }
1165
1171
  function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
1166
1172
  let referenceNode = scope[nodeAccessor], prevBranch = scope["d" /* ConditionalScope */ + nodeAccessor], parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.h || referenceNode).parentNode : referenceNode, newBranch = scope["d" /* ConditionalScope */ + nodeAccessor] = newRenderer && createBranch2(scope.$global, newRenderer, scope, parentNode);
1167
1173
  referenceNode === parentNode ? (prevBranch && (destroyBranch(prevBranch), referenceNode.textContent = ""), newBranch && insertBranchBefore(newBranch, parentNode, null)) : prevBranch ? (newBranch ? insertBranchBefore(newBranch, parentNode, prevBranch.h) : parentNode.insertBefore(referenceNode, prevBranch.h), removeAndDestroyBranch(prevBranch)) : newBranch && (insertBranchBefore(newBranch, parentNode, referenceNode), referenceNode.remove());
@@ -1523,6 +1529,7 @@ export {
1523
1529
  _on,
1524
1530
  _or,
1525
1531
  _resume,
1532
+ _resume_dynamic_tag,
1526
1533
  _return,
1527
1534
  _return_change,
1528
1535
  _script,
package/dist/html.js CHANGED
@@ -1981,7 +1981,8 @@ var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|p
1981
1981
  }
1982
1982
  _html(`</${renderer}>`);
1983
1983
  }
1984
- shouldResume && _html(
1984
+ let childScope = getScopeById(branchId);
1985
+ childScope && (childScope["i" /* EventAttributes */ + 0] || childScope["e" /* ControlledHandler */ + 0]) && (childScope.i = renderer, _script(branchId, "d")), shouldResume && _html(
1985
1986
  state.mark(
1986
1987
  "'" /* BranchEndNativeTag */,
1987
1988
  scopeId + " " + accessor + " " + branchId
package/dist/html.mjs CHANGED
@@ -1892,7 +1892,8 @@ var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|p
1892
1892
  }
1893
1893
  _html(`</${renderer}>`);
1894
1894
  }
1895
- shouldResume && _html(
1895
+ let childScope = getScopeById(branchId);
1896
+ childScope && (childScope["i" /* EventAttributes */ + 0] || childScope["e" /* ControlledHandler */ + 0]) && (childScope.i = renderer, _script(branchId, "d")), shouldResume && _html(
1896
1897
  state.mark(
1897
1898
  "'" /* BranchEndNativeTag */,
1898
1899
  scopeId + " " + accessor + " " + branchId
@@ -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;
@@ -1512,38 +1514,37 @@ function createSectionState(key, init) {
1512
1514
  var import_compiler6 = require("@marko/compiler");
1513
1515
  var import_babel_utils9 = require("@marko/compiler/babel-utils");
1514
1516
  var MARKO_FILE_REG = /^<.*>$|\.marko$/;
1515
- function analyzeTagNameType(tag) {
1517
+ function analyzeTagNameType(tag, allowDynamic) {
1516
1518
  const extra = tag.node.extra ??= {};
1517
1519
  if (extra.tagNameType === void 0) {
1518
1520
  const name2 = tag.get("name");
1519
1521
  if (name2.isStringLiteral()) {
1520
1522
  extra.tagNameType = name2.node.value[0] === "@" ? 3 /* AttributeTag */ : (0, import_babel_utils9.isNativeTag)(tag) ? 0 /* NativeTag */ : 1 /* CustomTag */;
1521
- extra.tagNameNullable = extra.tagNameNullable = false;
1522
- } else if (name2.isIdentifier()) {
1523
- analyzeExpressionTagName(name2, extra);
1524
- if (extra.tagNameType === 0 /* NativeTag */) {
1525
- extra.tagNameType = 2 /* DynamicTag */;
1526
- }
1523
+ extra.tagNameNullable = extra.tagNameDynamic = false;
1527
1524
  } else if (name2.isTemplateLiteral() && !name2.node.expressions.length) {
1528
1525
  extra.tagNameType = 0 /* NativeTag */;
1526
+ extra.tagNameNullable = extra.tagNameDynamic = false;
1527
+ } else if (name2.isIdentifier()) {
1528
+ analyzeExpressionTagName(name2, extra);
1529
+ extra.tagNameDynamic = !extra.tagNameImported;
1529
1530
  } else {
1530
- extra.tagNameType = 2 /* DynamicTag */;
1531
- }
1532
- if (extra.tagNameType === void 0) {
1533
- extra.tagNameType = 2 /* DynamicTag */;
1531
+ analyzeExpressionTagName(name2, extra);
1532
+ extra.tagNameDynamic = true;
1534
1533
  }
1535
- if (extra.tagNameType === 1 /* CustomTag */ && !isCoreTag(tag)) {
1534
+ if (!extra.tagNameDynamic && extra.tagNameType === 1 /* CustomTag */ && !isCoreTag(tag)) {
1536
1535
  const childFile = (0, import_babel_utils9.loadFileForTag)(tag);
1537
1536
  if (!childFile) {
1538
1537
  extra.tagNameType = 2 /* DynamicTag */;
1538
+ extra.tagNameDynamic = true;
1539
1539
  } else if (childFile.ast.program.extra.featureType === "class") {
1540
1540
  extra.tagNameType = 2 /* DynamicTag */;
1541
+ extra.tagNameDynamic = true;
1541
1542
  extra.featureType = "class";
1542
1543
  ((0, import_babel_utils9.getProgram)().node.extra ??= {}).needsCompat = true;
1543
1544
  }
1544
1545
  }
1545
1546
  }
1546
- return extra.tagNameType;
1547
+ return !allowDynamic && extra.tagNameDynamic ? 2 /* DynamicTag */ : extra.tagNameType;
1547
1548
  }
1548
1549
  function analyzeExpressionTagName(name2, extra) {
1549
1550
  const pending = [name2];
@@ -1567,9 +1568,9 @@ function analyzeExpressionTagName(name2, extra) {
1567
1568
  } else if (path5.isAssignmentExpression()) {
1568
1569
  pending.push(path5.get("right"));
1569
1570
  } else if (path5.isBinaryExpression()) {
1570
- type = path5.node.operator !== "+" || type !== void 0 ? 2 /* DynamicTag */ : 0 /* NativeTag */;
1571
+ type = path5.node.operator !== "+" || type === void 0 || type === 0 /* NativeTag */ ? 0 /* NativeTag */ : 2 /* DynamicTag */;
1571
1572
  } else if (path5.isStringLiteral() || path5.isTemplateLiteral()) {
1572
- type = type !== void 0 ? 2 /* DynamicTag */ : 0 /* NativeTag */;
1573
+ type = type === void 0 || type === 0 /* NativeTag */ ? 0 /* NativeTag */ : 2 /* DynamicTag */;
1573
1574
  } else if (path5.isNullLiteral()) {
1574
1575
  nullable = true;
1575
1576
  } else if (path5.isIdentifier()) {
@@ -1586,12 +1587,14 @@ function analyzeExpressionTagName(name2, extra) {
1586
1587
  const decl = binding.path.parent;
1587
1588
  if (MARKO_FILE_REG.test(decl.source.value) && decl.specifiers.some((it) => import_compiler6.types.isImportDefaultSpecifier(it))) {
1588
1589
  const resolvedImport = (0, import_babel_utils9.resolveTagImport)(name2, decl.source.value) || decl.source.value;
1589
- if (type === 0 /* NativeTag */ || tagNameImported && tagNameImported !== resolvedImport) {
1590
- type = 2 /* DynamicTag */;
1591
- tagNameImported = void 0;
1592
- } else {
1590
+ if (type === void 0) {
1593
1591
  type = 1 /* CustomTag */;
1594
1592
  tagNameImported = resolvedImport;
1593
+ } else if (type === 0 /* NativeTag */) {
1594
+ type = 2 /* DynamicTag */;
1595
+ tagNameImported = void 0;
1596
+ } else if (tagNameImported !== resolvedImport) {
1597
+ tagNameImported = void 0;
1595
1598
  }
1596
1599
  } else {
1597
1600
  type = 2 /* DynamicTag */;
@@ -1618,9 +1621,8 @@ function analyzeExpressionTagName(name2, extra) {
1618
1621
  type = 2 /* DynamicTag */;
1619
1622
  }
1620
1623
  }
1621
- extra.tagNameType = type;
1624
+ extra.tagNameType = type ?? 2 /* DynamicTag */;
1622
1625
  extra.tagNameNullable = nullable;
1623
- extra.tagNameDynamic = true;
1624
1626
  if (type === 1 /* CustomTag */ && tagNameImported) {
1625
1627
  extra.tagNameImported = tagNameImported;
1626
1628
  }
@@ -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) {
@@ -5252,10 +5267,10 @@ function translateVar(tag, initialValue, kind = "const") {
5252
5267
  }
5253
5268
  forEachIdentifierPath(tag.get("var"), (id) => {
5254
5269
  const binding = id.node.extra?.binding;
5255
- if (!binding || !binding.upstreamAlias || !binding.assignmentSections || id.node === tagVar) {
5270
+ if (!binding || !binding.upstreamAlias || !binding.assignmentSections || binding.property === void 0 || id.node === tagVar) {
5256
5271
  return;
5257
5272
  }
5258
- const changeName = binding.name + "Change";
5273
+ const changeName = binding.property + "Change";
5259
5274
  const changeBinding = binding.upstreamAlias.propertyAliases.get(changeName);
5260
5275
  if (changeBinding && changeName !== changeBinding.name) {
5261
5276
  getDestructurePattern(id)?.pushContainer(
@@ -10679,7 +10694,7 @@ function assertValidCondition(tag) {
10679
10694
  function assertHasPrecedingCondition(tag) {
10680
10695
  let prev = tag.getPrevSibling();
10681
10696
  while (prev.node && prev.isMarkoComment()) prev = prev.getPrevSibling();
10682
- if (!isConditionTag(prev) || getTagName(prev) !== "else" && !prev.node.attributes.length) {
10697
+ if (!isConditionTag(prev) || getTagName(prev) === "else" && !prev.node.attributes.length) {
10683
10698
  throw tag.buildCodeFrameError(
10684
10699
  `The [\`<${getTagName(tag)}>\` tag](https://markojs.com/docs/reference/core-tag#if--else) must have a preceding \`<if=cond>\` or \`<else if=cond>\`.`
10685
10700
  );
@@ -10719,7 +10734,7 @@ function assertOptionalIfAttribute(tag) {
10719
10734
  const { node } = tag;
10720
10735
  const [ifAttr] = node.attributes;
10721
10736
  if (node.attributes.length > 1 || ifAttr && ifAttr.name !== "if") {
10722
- const start = node.attributes[1].loc?.start;
10737
+ const start = node.attributes[0].loc?.start;
10723
10738
  const end = node.attributes[node.attributes.length - 1].loc?.end;
10724
10739
  const msg = `The [\`${getTagName(tag)}\` tag](https://markojs.com/docs/reference/core-tag#if--else) only supports an \`if=\` attribute.`;
10725
10740
  if (start == null || end == null) {
@@ -12173,6 +12188,7 @@ var import_compiler63 = require("@marko/compiler");
12173
12188
  var import_babel_utils51 = require("@marko/compiler/babel-utils");
12174
12189
  var kDOMBinding3 = Symbol("dynamic tag dom binding");
12175
12190
  var kChildOffsetScopeBinding2 = Symbol("custom tag scope offset");
12191
+ var importedDynamicTagResume = /* @__PURE__ */ new WeakSet();
12176
12192
  var dynamic_tag_default = {
12177
12193
  analyze: {
12178
12194
  enter(tag) {
@@ -12463,12 +12479,27 @@ var dynamic_tag_default = {
12463
12479
  ];
12464
12480
  }
12465
12481
  }
12482
+ enableDynamicTagResume(tag);
12466
12483
  addValue(section, tagExtra.referencedBindings, signal, tagExpression);
12467
12484
  tag.remove();
12468
12485
  }
12469
12486
  }
12470
12487
  }
12471
12488
  };
12489
+ function enableDynamicTagResume(tag) {
12490
+ const program = (0, import_babel_utils51.getProgram)().node;
12491
+ if (!importedDynamicTagResume.has(program) && analyzeTagNameType(tag, true) !== 1 /* CustomTag */) {
12492
+ for (const attr of tag.node.attributes) {
12493
+ if (attr.type === "MarkoSpreadAttribute" || attr.type === "MarkoAttribute" && isEventOrChangeHandler(attr.name)) {
12494
+ importedDynamicTagResume.add(program);
12495
+ program.body.push(
12496
+ import_compiler63.types.expressionStatement(callRuntime("_resume_dynamic_tag"))
12497
+ );
12498
+ return;
12499
+ }
12500
+ }
12501
+ }
12502
+ }
12472
12503
 
12473
12504
  // src/translator/visitors/tag/index.ts
12474
12505
  var tag_default = {
@@ -12534,7 +12565,8 @@ var tag_default = {
12534
12565
  }
12535
12566
  }
12536
12567
  }
12537
- if (extra.tagNameDynamic && extra.tagNameNullable && !tag.get("name").isIdentifier() && isOutputHTML()) {
12568
+ const type = analyzeTagNameType(tag);
12569
+ if (extra.tagNameDynamic && extra.tagNameNullable && type === 0 /* NativeTag */ && !tag.get("name").isIdentifier() && isOutputHTML()) {
12538
12570
  const tagNameId = generateUidIdentifier("tagName");
12539
12571
  const [tagNameVarPath] = tag.insertBefore(
12540
12572
  import_compiler64.types.variableDeclaration("const", [
@@ -12544,7 +12576,7 @@ var tag_default = {
12544
12576
  tagNameVarPath.skip();
12545
12577
  tag.set("name", tagNameId);
12546
12578
  }
12547
- switch (extra.tagNameType) {
12579
+ switch (type) {
12548
12580
  case 0 /* NativeTag */:
12549
12581
  native_tag_default.translate.enter(tag);
12550
12582
  break;
@@ -12565,7 +12597,7 @@ var tag_default = {
12565
12597
  exit(translator.hook, tag);
12566
12598
  return;
12567
12599
  }
12568
- switch (tag.node.extra.tagNameType) {
12600
+ switch (analyzeTagNameType(tag)) {
12569
12601
  case 0 /* NativeTag */:
12570
12602
  native_tag_default.translate.exit(tag);
12571
12603
  break;
@@ -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;
@@ -13,4 +13,4 @@ export declare enum TagNameType {
13
13
  DynamicTag = 2,
14
14
  AttributeTag = 3
15
15
  }
16
- export default function analyzeTagNameType(tag: t.NodePath<t.MarkoTag>): TagNameType;
16
+ export default function analyzeTagNameType(tag: t.NodePath<t.MarkoTag>, allowDynamic?: boolean): TagNameType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/runtime-tags",
3
- "version": "6.0.100",
3
+ "version": "6.0.102",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",