@geajs/vite-plugin 1.0.27 → 1.1.0

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.
Files changed (2) hide show
  1. package/dist/index.js +995 -412
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import babelGenerator2 from "@babel/generator";
2
+ import babelGenerator3 from "@babel/generator";
3
3
  import babelTraverse2 from "@babel/traverse";
4
4
 
5
5
  // src/parse.ts
@@ -180,8 +180,8 @@ function collectStateReferences(ast, storeImports = /* @__PURE__ */ new Map()) {
180
180
  VariableDeclarator(path) {
181
181
  if (!path.node.init || !t.isIdentifier(path.node.id)) return;
182
182
  if (stateRefs.has(path.node.id.name)) return;
183
- const classMethod9 = path.findParent((p) => t.isClassMethod(p.node));
184
- if (!classMethod9) return;
183
+ const classMethod10 = path.findParent((p) => t.isClassMethod(p.node));
184
+ if (!classMethod10) return;
185
185
  candidates.set(path.node.id.name, t.cloneNode(path.node.init, true));
186
186
  }
187
187
  });
@@ -591,14 +591,14 @@ function replaceThisPropsRootWithValueParam(expr, propName) {
591
591
  visit(e.object),
592
592
  e.property,
593
593
  e.computed,
594
- e.optional
594
+ e.optional ?? true
595
595
  );
596
596
  }
597
597
  if (t2.isOptionalCallExpression(e)) {
598
598
  return t2.optionalCallExpression(
599
599
  visit(e.callee),
600
600
  e.arguments.map((a) => t2.isExpression(a) ? visit(a) : a),
601
- e.optional
601
+ e.optional ?? true
602
602
  );
603
603
  }
604
604
  if (t2.isCallExpression(e)) {
@@ -728,14 +728,14 @@ function optionalizeMemberChainsFromBindingRoot(expr, rootName) {
728
728
  visit(e.object),
729
729
  e.property,
730
730
  e.computed,
731
- e.optional
731
+ e.optional ?? true
732
732
  );
733
733
  }
734
734
  if (t2.isOptionalCallExpression(e)) {
735
735
  return t2.optionalCallExpression(
736
736
  visit(e.callee),
737
737
  e.arguments.map((a) => t2.isExpression(a) ? visit(a) : a),
738
- e.optional
738
+ e.optional ?? true
739
739
  );
740
740
  }
741
741
  if (t2.isCallExpression(e)) {
@@ -861,14 +861,14 @@ function optionalizeMemberChainsAfterComputedItemKey(expr, itemKeyName) {
861
861
  visit(e.object),
862
862
  e.property,
863
863
  e.computed,
864
- e.optional
864
+ e.optional ?? true
865
865
  );
866
866
  }
867
867
  if (t2.isOptionalCallExpression(e)) {
868
868
  return t2.optionalCallExpression(
869
869
  visit(e.callee),
870
870
  e.arguments.map((a) => t2.isExpression(a) ? visit(a) : a),
871
- e.optional
871
+ e.optional ?? true
872
872
  );
873
873
  }
874
874
  if (t2.isCallExpression(e)) {
@@ -1033,14 +1033,14 @@ function replacePropRefsInNode(node, propNames, wholeParamName, propDefaults) {
1033
1033
  r(node.object),
1034
1034
  node.property,
1035
1035
  node.computed,
1036
- node.optional
1036
+ node.optional ?? true
1037
1037
  );
1038
1038
  }
1039
1039
  if (t2.isOptionalCallExpression(node)) {
1040
1040
  return t2.optionalCallExpression(
1041
1041
  r(node.callee),
1042
1042
  node.arguments.map((a) => t2.isExpression(a) ? r(a) : a),
1043
- node.optional
1043
+ node.optional ?? true
1044
1044
  );
1045
1045
  }
1046
1046
  if (t2.isConditionalExpression(node)) {
@@ -1177,8 +1177,8 @@ function wrapEventsGetterWithCache(getter) {
1177
1177
  const returnStmt = body.find((s) => t2.isReturnStatement(s) && s.argument !== null);
1178
1178
  if (!returnStmt?.argument) return;
1179
1179
  const cachedProp = t2.memberExpression(t2.thisExpression(), t2.identifier("__evts"));
1180
- const elementProp = t2.memberExpression(t2.thisExpression(), t2.identifier("element_"));
1181
- const tmpId = t2.identifier("__geaEvtsResult");
1180
+ const elementProp = t2.memberExpression(t2.thisExpression(), t2.identifier("GEA_ELEMENT"), true);
1181
+ const tmpId = t2.identifier("geaEvtsResult");
1182
1182
  const objectExpr = returnStmt.argument;
1183
1183
  const returnIndex = body.indexOf(returnStmt);
1184
1184
  body.splice(
@@ -1559,9 +1559,7 @@ function replaceIdentifierWithClonedExpr(node, name, expr) {
1559
1559
  }
1560
1560
  function optimizeBoundValueAliasesInSequence(stmts) {
1561
1561
  const out = [...stmts];
1562
- let changed = true;
1563
- while (changed) {
1564
- changed = false;
1562
+ while (true) {
1565
1563
  const idx = out.findIndex(
1566
1564
  (s) => t2.isVariableDeclaration(s) && s.declarations.length === 1 && t2.isIdentifier(s.declarations[0].id, { name: "__boundValue" })
1567
1565
  );
@@ -1576,7 +1574,6 @@ function optimizeBoundValueAliasesInSequence(stmts) {
1576
1574
  renameIdentifier(blk2, "__boundValue", aliasedName);
1577
1575
  out.length = 0;
1578
1576
  out.push(...blk2.body);
1579
- changed = true;
1580
1577
  continue;
1581
1578
  }
1582
1579
  if (!t2.isExpression(init) || !isPureExpression(init)) break;
@@ -1587,7 +1584,6 @@ function optimizeBoundValueAliasesInSequence(stmts) {
1587
1584
  replaceIdentifierWithClonedExpr(blk, "__boundValue", init);
1588
1585
  out.length = 0;
1589
1586
  out.push(...blk.body);
1590
- changed = true;
1591
1587
  }
1592
1588
  return out;
1593
1589
  }
@@ -1646,7 +1642,7 @@ function stmtUsesPropRefreshCall(stmt) {
1646
1642
  }
1647
1643
  function containsPropRefreshCall(node) {
1648
1644
  if (t2.isMemberExpression(node) && t2.isIdentifier(node.property)) {
1649
- if (node.property.name === "__geaUpdateProps" || node.property.name.startsWith("__refresh")) return true;
1645
+ if (node.property.name === "GEA_UPDATE_PROPS" || node.property.name.startsWith("__refresh")) return true;
1650
1646
  }
1651
1647
  const keys = t2.VISITOR_KEYS[node.type];
1652
1648
  if (!keys) return false;
@@ -1713,6 +1709,70 @@ function loggingCatchClause(extra = []) {
1713
1709
  ])
1714
1710
  );
1715
1711
  }
1712
+ function buildThisGeaMember(symExportName) {
1713
+ return t2.memberExpression(t2.thisExpression(), t2.identifier(symExportName), true);
1714
+ }
1715
+ function buildThisGeaCall(symExportName, args = []) {
1716
+ return t2.callExpression(buildThisGeaMember(symExportName), args);
1717
+ }
1718
+ function buildExprGeaMember(expr, symExportName) {
1719
+ return t2.memberExpression(expr, t2.identifier(symExportName), true);
1720
+ }
1721
+ var GEA_COMPILER_SYMBOL_IMPORTS = [
1722
+ "GEA_RENDERED",
1723
+ "GEA_PARENT_COMPONENT",
1724
+ "GEA_ELEMENT",
1725
+ "GEA_MAPS",
1726
+ "GEA_CONDS",
1727
+ "GEA_RESET_ELS",
1728
+ "GEA_OBSERVE",
1729
+ "GEA_OBSERVE_LIST",
1730
+ "GEA_EL",
1731
+ "GEA_UPDATE_TEXT",
1732
+ "GEA_REQUEST_RENDER",
1733
+ "GEA_UPDATE_PROPS",
1734
+ "GEA_SYNC_MAP",
1735
+ "GEA_REGISTER_MAP",
1736
+ "GEA_PATCH_COND",
1737
+ "GEA_PATCH_NODE",
1738
+ "GEA_REGISTER_COND",
1739
+ "GEA_REFRESH_LIST",
1740
+ "GEA_RECONCILE_LIST",
1741
+ "GEA_ENSURE_ARRAY_CONFIGS",
1742
+ "GEA_APPLY_LIST_CHANGES",
1743
+ "GEA_INSTANTIATE_CHILD_COMPONENTS",
1744
+ "GEA_MOUNT_COMPILED_CHILD_COMPONENTS",
1745
+ "GEA_SWAP_CHILD",
1746
+ "GEA_SWAP_STATE_CHILDREN",
1747
+ "GEA_CHILD",
1748
+ "GEA_LIST_CONFIG_REFRESHING",
1749
+ "GEA_DOM_KEY",
1750
+ "GEA_DOM_ITEM",
1751
+ "GEA_DOM_PROPS",
1752
+ "GEA_HANDLE_ITEM_HANDLER",
1753
+ "GEA_MAP_CONFIG_TPL",
1754
+ "GEA_MAP_CONFIG_PREV",
1755
+ "GEA_MAP_CONFIG_COUNT",
1756
+ "geaCondPatchedSymbol",
1757
+ "geaCondValueSymbol",
1758
+ "geaObservePrevSymbol",
1759
+ "geaPrevGuardSymbol",
1760
+ "GEA_SETUP_LOCAL_STATE_OBSERVERS",
1761
+ "GEA_CLONE_TEMPLATE",
1762
+ "GEA_SETUP_REFS",
1763
+ "GEA_ON_PROP_CHANGE",
1764
+ "GEA_SELF_PROXY",
1765
+ "GEA_STORE_ROOT",
1766
+ "GEA_PROXY_RAW",
1767
+ "GEA_PROXY_GET_TARGET",
1768
+ "geaSanitizeAttr",
1769
+ "geaEscapeHtml"
1770
+ ];
1771
+ function ensureGeaCompilerSymbolImports(ast) {
1772
+ for (const name of GEA_COMPILER_SYMBOL_IMPORTS) {
1773
+ ensureImport(ast, "@geajs/core", name);
1774
+ }
1775
+ }
1716
1776
 
1717
1777
  // src/hmr.ts
1718
1778
  import { createRequire as createRequire2 } from "module";
@@ -1755,9 +1815,9 @@ function injectHMR(ast, componentClassName, componentImports, componentImportsUs
1755
1815
  hmrStmts.push(...createAccepts(componentImports, proxyDep));
1756
1816
  hmrStmts.push(js`const __origCreated = ${id2(componentClassName)}.prototype.created;`);
1757
1817
  hmrStmts.push(
1758
- js`${id2(componentClassName)}.prototype.created = function(__geaProps) {
1818
+ js`${id2(componentClassName)}.prototype.created = function(geaProps) {
1759
1819
  registerComponentInstance(this.constructor.name, this);
1760
- return __origCreated.call(this, __geaProps);
1820
+ return __origCreated.call(this, geaProps);
1761
1821
  };`
1762
1822
  );
1763
1823
  hmrStmts.push(js`const __origDispose = ${id2(componentClassName)}.prototype.dispose;`);
@@ -1847,39 +1907,54 @@ import { dirname, resolve } from "path";
1847
1907
  var EVENT_NAMES = /* @__PURE__ */ new Set([
1848
1908
  "click",
1849
1909
  "dblclick",
1910
+ "change",
1911
+ "input",
1912
+ "submit",
1913
+ "reset",
1914
+ "focus",
1915
+ "blur",
1916
+ "keydown",
1917
+ "keyup",
1918
+ "keypress",
1850
1919
  "mousedown",
1851
1920
  "mouseup",
1852
1921
  "mouseover",
1853
1922
  "mouseout",
1923
+ "mouseenter",
1924
+ "mouseleave",
1854
1925
  "mousemove",
1855
- "keydown",
1856
- "keyup",
1857
- "keypress",
1858
- "focus",
1859
- "blur",
1860
- "input",
1861
- "change",
1862
- "submit",
1863
- "scroll",
1926
+ "contextmenu",
1864
1927
  "touchstart",
1865
- "touchmove",
1866
1928
  "touchend",
1929
+ "touchmove",
1930
+ "pointerdown",
1931
+ "pointerup",
1932
+ "pointermove",
1933
+ "scroll",
1934
+ "resize",
1935
+ "drag",
1936
+ "dragstart",
1937
+ "dragend",
1938
+ "dragover",
1939
+ "dragleave",
1940
+ "drop",
1941
+ "animationstart",
1942
+ "animationend",
1943
+ "animationiteration",
1944
+ "transitionstart",
1945
+ "transitionend",
1946
+ "transitionrun",
1947
+ "transitioncancel",
1867
1948
  "tap",
1868
1949
  "longTap",
1869
1950
  "swipeRight",
1870
1951
  "swipeUp",
1871
1952
  "swipeLeft",
1872
- "swipeDown",
1873
- "dragstart",
1874
- "dragend",
1875
- "dragover",
1876
- "dragleave",
1877
- "drop"
1953
+ "swipeDown"
1878
1954
  ]);
1879
1955
  function toGeaEventType(attrName) {
1880
1956
  if (attrName.startsWith("on") && attrName.length > 2) {
1881
- const rest = attrName.slice(2);
1882
- return rest.charAt(0).toLowerCase() + rest.slice(1);
1957
+ return attrName.slice(2).toLowerCase();
1883
1958
  }
1884
1959
  return attrName;
1885
1960
  }
@@ -2751,7 +2826,7 @@ function buildComponentPropsExpression(jsxElement, imports, componentInstances,
2751
2826
  else if (t8.isJSXExpressionContainer(attr.value) && !t8.isJSXEmptyExpression(attr.value.expression)) {
2752
2827
  const expr = attr.value.expression;
2753
2828
  propValue = transformExpression(expr);
2754
- if (propValue && (/^on[A-Z]/.test(propName) || /^(click|input|change|submit|focus|blur|keydown|keyup|keypress|mousedown|mouseup|mouseover|mouseout|mouseenter|mouseleave|touchstart|touchend|touchmove|pointerdown|pointerup|pointermove|scroll|resize|drag|dragstart|dragend|dragover|drop|reset)$/.test(
2829
+ if (propValue && (/^on[A-Z]/.test(propName) || /^(click|dblclick|input|change|submit|reset|focus|blur|keydown|keyup|keypress|mousedown|mouseup|mouseover|mouseout|mouseenter|mouseleave|mousemove|contextmenu|touchstart|touchend|touchmove|pointerdown|pointerup|pointermove|scroll|resize|drag|dragstart|dragend|dragover|dragleave|drop|tap|longTap|swipeRight|swipeUp|swipeLeft|swipeDown)$/.test(
2755
2830
  propName
2756
2831
  )) && t8.isMemberExpression(propValue)) {
2757
2832
  const argsId = t8.identifier("args");
@@ -3663,7 +3738,8 @@ function analyzeChildren(node, tagName, elementPath, bindings, propBindings, arr
3663
3738
  stateRefs,
3664
3739
  onUnresolvedMap,
3665
3740
  classBody2,
3666
- templateSetupContext
3741
+ templateSetupContext,
3742
+ conditionalSlots?.length
3667
3743
  );
3668
3744
  } else {
3669
3745
  const nestedMapCalls = collectNestedMapCalls(expr);
@@ -3803,7 +3879,7 @@ function collectImportedStoreGetterDependencies(expr, setupStatements, stateRefs
3803
3879
  }
3804
3880
  return Array.from(deps.values());
3805
3881
  }
3806
- function handleArrayMap(expr, tagName, node, elementPath, index, arrayMaps, stateProps, stateRefs, onUnresolvedMap, classBody2, templateSetupContext) {
3882
+ function handleArrayMap(expr, tagName, node, elementPath, index, arrayMaps, stateProps, stateRefs, onUnresolvedMap, classBody2, templateSetupContext, afterCondSlotIndex) {
3807
3883
  const arrayExpr = expr.callee.object;
3808
3884
  const normalizedArrayExpr = resolveHelperCallExpression(arrayExpr, classBody2) || arrayExpr;
3809
3885
  if (t9.isArrowFunctionExpression(expr.arguments?.[0])) {
@@ -3861,7 +3937,8 @@ function handleArrayMap(expr, tagName, node, elementPath, index, arrayMaps, stat
3861
3937
  dependencies,
3862
3938
  containerElementPath: [...elementPath],
3863
3939
  ...cbBodyStmts2.length > 0 ? { callbackBodyStatements: cbBodyStmts2 } : {},
3864
- ...relationalClassBindings.length > 0 ? { relationalClassBindings } : {}
3940
+ ...relationalClassBindings.length > 0 ? { relationalClassBindings } : {},
3941
+ ...afterCondSlotIndex != null ? { afterCondSlotIndex } : {}
3865
3942
  });
3866
3943
  }
3867
3944
  return;
@@ -3971,9 +4048,41 @@ function handleArrayMap(expr, tagName, node, elementPath, index, arrayMaps, stat
3971
4048
  ...!itemIdProperty && isKeyed ? { keyExpression: t9.cloneNode(extractKeyExpression(itemTemplate), true) } : {},
3972
4049
  classToggleName,
3973
4050
  conditionalBindings,
3974
- ...cbBodyStmts.length > 0 ? { callbackBodyStatements: cbBodyStmts } : {}
4051
+ ...cbBodyStmts.length > 0 ? { callbackBodyStatements: cbBodyStmts } : {},
4052
+ ...afterCondSlotIndex != null ? { afterCondSlotIndex } : {}
3975
4053
  });
3976
4054
  }
4055
+ function expressionContainsComponentJSX(node) {
4056
+ if (t9.isJSXElement(node)) {
4057
+ const name = node.openingElement.name;
4058
+ if (t9.isJSXIdentifier(name) && /^[A-Z]/.test(name.name)) return true;
4059
+ if (t9.isJSXMemberExpression(name)) {
4060
+ let cur = name;
4061
+ while (t9.isJSXMemberExpression(cur)) cur = cur.object;
4062
+ if (t9.isJSXIdentifier(cur) && /^[A-Z]/.test(cur.name)) return true;
4063
+ }
4064
+ for (const c of node.children) {
4065
+ if (expressionContainsComponentJSX(c)) return true;
4066
+ }
4067
+ return false;
4068
+ }
4069
+ if (t9.isJSXExpressionContainer(node) && !t9.isJSXEmptyExpression(node.expression)) {
4070
+ return expressionContainsComponentJSX(node.expression);
4071
+ }
4072
+ if (t9.isLogicalExpression(node)) {
4073
+ return expressionContainsComponentJSX(node.left) || expressionContainsComponentJSX(node.right);
4074
+ }
4075
+ if (t9.isConditionalExpression(node)) {
4076
+ return expressionContainsComponentJSX(node.consequent) || expressionContainsComponentJSX(node.alternate);
4077
+ }
4078
+ if (t9.isParenthesizedExpression(node)) {
4079
+ return expressionContainsComponentJSX(node.expression);
4080
+ }
4081
+ if (t9.isJSXFragment(node)) {
4082
+ return node.children.some((c) => expressionContainsComponentJSX(c));
4083
+ }
4084
+ return false;
4085
+ }
3977
4086
  function handleTextBinding(expr, node, tagName, elementPath, bindings, propBindings, stateProps, stateRefs, textTemplate, textExpressions, shouldBuildTextTemplate, propsParamName, destructuredPropNames, templateSetupContext, rerenderPropNames, rerenderConditions, conditionalSlots, _hasNestedMapCall = false, classBody2, conditionalSlotNodeMap, textNodeIndex, jsxInTextSiblingGroup = false) {
3978
4087
  const propName = resolvePropRef(expr, propsParamName, destructuredPropNames);
3979
4088
  if (propName) {
@@ -4094,6 +4203,7 @@ function handleTextBinding(expr, node, tagName, elementPath, bindings, propBindi
4094
4203
  conditionExpr: t9.cloneNode(conditionExpr, true),
4095
4204
  setupStatements: condSetupStatements.map((s) => t9.cloneNode(s, true)),
4096
4205
  htmlSetupStatements: fullSetupStatements.map((s) => t9.cloneNode(s, true)),
4206
+ ...expressionContainsComponentJSX(expr) ? { hasCompiledChildren: true } : {},
4097
4207
  dependentPropNames: [...dependentProps],
4098
4208
  dependencies: dependencies.map((dep) => ({
4099
4209
  observeKey: dep.observeKey,
@@ -4104,6 +4214,7 @@ function handleTextBinding(expr, node, tagName, elementPath, bindings, propBindi
4104
4214
  });
4105
4215
  conditionalSlotNodeMap?.set(expr, slotId);
4106
4216
  }
4217
+ return;
4107
4218
  }
4108
4219
  }
4109
4220
  }
@@ -4656,6 +4767,35 @@ function toHtmlAttrName(attrName, isComponent) {
4656
4767
  if (attrName === "className") return "class";
4657
4768
  return attrName;
4658
4769
  }
4770
+ function unwrapExpression(expr) {
4771
+ let e = expr;
4772
+ while (t10.isParenthesizedExpression(e)) {
4773
+ e = e.expression;
4774
+ }
4775
+ return e;
4776
+ }
4777
+ function extractHtmlTemplatesFromRawConditional(rawExpr, ctx, slotId) {
4778
+ const childCtx = { ...ctx, elementPathPrefix: "__cs_" + slotId };
4779
+ const top = unwrapExpression(rawExpr);
4780
+ if (t10.isLogicalExpression(top) && top.operator === "&&") {
4781
+ return extractHtmlTemplatesFromRawConditional(top.right, ctx, slotId);
4782
+ }
4783
+ if (t10.isConditionalExpression(top)) {
4784
+ const truthyHtmlExpr = transformJSXExpression(top.consequent, childCtx);
4785
+ const alt = unwrapExpression(top.alternate);
4786
+ if (t10.isConditionalExpression(alt)) {
4787
+ return {
4788
+ truthyHtmlExpr,
4789
+ falsyHtmlExpr: transformJSXExpression(top.alternate, childCtx)
4790
+ };
4791
+ }
4792
+ return {
4793
+ truthyHtmlExpr,
4794
+ falsyHtmlExpr: transformJSXExpression(top.alternate, childCtx)
4795
+ };
4796
+ }
4797
+ return null;
4798
+ }
4659
4799
  function extractHtmlTemplatesFromConditional(expr) {
4660
4800
  const normalizeHtmlExpression = (value) => {
4661
4801
  if (t10.isCallExpression(value) && t10.isMemberExpression(value.callee) && t10.isIdentifier(value.callee.property) && value.callee.property.name === "map") {
@@ -4671,7 +4811,11 @@ function extractHtmlTemplatesFromConditional(expr) {
4671
4811
  }
4672
4812
  if (t10.isConditionalExpression(expr)) {
4673
4813
  const truthy = extractHtmlTemplatesFromConditional(expr.consequent).truthyHtmlExpr;
4674
- const falsy = extractHtmlTemplatesFromConditional(expr.alternate).truthyHtmlExpr;
4814
+ const alt = unwrapExpression(expr.alternate);
4815
+ if (t10.isConditionalExpression(alt)) {
4816
+ return { truthyHtmlExpr: truthy, falsyHtmlExpr: normalizeHtmlExpression(alt) };
4817
+ }
4818
+ const falsy = extractHtmlTemplatesFromConditional(alt).truthyHtmlExpr;
4675
4819
  return { truthyHtmlExpr: truthy, falsyHtmlExpr: falsy };
4676
4820
  }
4677
4821
  if (t10.isParenthesizedExpression(expr)) {
@@ -4796,7 +4940,7 @@ function escapeHtml(str) {
4796
4940
  var URL_ATTRS = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "cite", "poster", "background"]);
4797
4941
  function wrapWithSanitizeAttr(attrName, expr) {
4798
4942
  if (!URL_ATTRS.has(attrName)) return expr;
4799
- return t10.callExpression(t10.identifier("__sanitizeAttr"), [
4943
+ return t10.callExpression(t10.identifier("geaSanitizeAttr"), [
4800
4944
  t10.stringLiteral(attrName),
4801
4945
  t10.callExpression(t10.identifier("String"), [expr])
4802
4946
  ]);
@@ -4850,24 +4994,48 @@ var EVENT_TYPES = /* @__PURE__ */ new Set([
4850
4994
  "dblclick",
4851
4995
  "change",
4852
4996
  "input",
4997
+ "submit",
4998
+ "reset",
4999
+ "focus",
5000
+ "blur",
4853
5001
  "keydown",
4854
5002
  "keyup",
4855
- "blur",
4856
- "focus",
5003
+ "keypress",
4857
5004
  "mousedown",
4858
5005
  "mouseup",
4859
- "submit",
5006
+ "mouseover",
5007
+ "mouseout",
5008
+ "mouseenter",
5009
+ "mouseleave",
5010
+ "mousemove",
5011
+ "contextmenu",
5012
+ "touchstart",
5013
+ "touchend",
5014
+ "touchmove",
5015
+ "pointerdown",
5016
+ "pointerup",
5017
+ "pointermove",
5018
+ "scroll",
5019
+ "resize",
5020
+ "drag",
5021
+ "dragstart",
5022
+ "dragend",
5023
+ "dragover",
5024
+ "dragleave",
5025
+ "drop",
5026
+ "animationstart",
5027
+ "animationend",
5028
+ "animationiteration",
5029
+ "transitionstart",
5030
+ "transitionend",
5031
+ "transitionrun",
5032
+ "transitioncancel",
4860
5033
  "tap",
4861
5034
  "longTap",
4862
5035
  "swipeRight",
4863
5036
  "swipeUp",
4864
5037
  "swipeLeft",
4865
- "swipeDown",
4866
- "dragstart",
4867
- "dragend",
4868
- "dragover",
4869
- "dragleave",
4870
- "drop"
5038
+ "swipeDown"
4871
5039
  ]);
4872
5040
  function transformJSXToTemplate(el, ctx, elementPath = []) {
4873
5041
  const parts = jsxToTemplateParts(el, ctx, elementPath);
@@ -5555,8 +5723,9 @@ function processChildren(children, parts, ctx, elementPath, dcCursor, directChil
5555
5723
  });
5556
5724
  appendString(parts, `-->`);
5557
5725
  pushString(parts, "");
5558
- let condExpr = transformJSXExpression(rawExpr, { ...ctx, elementPathPrefix: "__cs_" + slot.slotId });
5559
- const extracted = extractHtmlTemplatesFromConditional(condExpr);
5726
+ const slotCtx = { ...ctx, elementPathPrefix: "__cs_" + slot.slotId };
5727
+ let condExpr = transformJSXExpression(rawExpr, slotCtx);
5728
+ const extracted = extractHtmlTemplatesFromRawConditional(rawExpr, ctx, slot.slotId) ?? extractHtmlTemplatesFromConditional(condExpr);
5560
5729
  slot.truthyHtmlExpr = extracted.truthyHtmlExpr;
5561
5730
  slot.falsyHtmlExpr = extracted.falsyHtmlExpr;
5562
5731
  if (expressionMayBeFalsy(rawExpr)) {
@@ -5612,9 +5781,7 @@ function processChildren(children, parts, ctx, elementPath, dcCursor, directChil
5612
5781
  expr = t10.logicalExpression("||", expr, t10.stringLiteral(""));
5613
5782
  }
5614
5783
  const skipEscape = childCallInfo || isChildrenPropAccess(rawExpr) || expressionContainsJSX(rawExpr) || ctx.inMapCallback || callsJSXReturningProperty(rawExpr, ctx.classBody);
5615
- const safeExpr = skipEscape ? expr : t10.callExpression(t10.identifier("__escapeHtml"), [
5616
- t10.callExpression(t10.identifier("String"), [expr])
5617
- ]);
5784
+ const safeExpr = skipEscape ? expr : t10.callExpression(t10.identifier("geaEscapeHtml"), [t10.callExpression(t10.identifier("String"), [expr])]);
5618
5785
  parts.push({ type: "expression", value: safeExpr });
5619
5786
  }
5620
5787
  }
@@ -5768,20 +5935,62 @@ function collectItemTemplatePropTree(template, itemVar) {
5768
5935
  });
5769
5936
  return tree;
5770
5937
  }
5771
- function buildDummyFromTree(tree, keyPathParts) {
5938
+ function getCalleeMemberChainFromItem(callee, itemVar) {
5939
+ const chain = [];
5940
+ let node = callee;
5941
+ while (t11.isMemberExpression(node) && !node.computed && t11.isIdentifier(node.property)) {
5942
+ chain.unshift(node.property.name);
5943
+ node = node.object;
5944
+ }
5945
+ if (!t11.isIdentifier(node, { name: itemVar }) || chain.length === 0) return null;
5946
+ return chain;
5947
+ }
5948
+ function collectItemCalleePropertyPaths(template, itemVar) {
5949
+ const paths = /* @__PURE__ */ new Set();
5950
+ const program12 = t11.program([t11.expressionStatement(t11.cloneNode(template, true))]);
5951
+ traverse6(program12, {
5952
+ noScope: true,
5953
+ CallExpression(path) {
5954
+ const chain = getCalleeMemberChainFromItem(path.node.callee, itemVar);
5955
+ if (chain) paths.add(chain.join("."));
5956
+ }
5957
+ });
5958
+ return paths;
5959
+ }
5960
+ function buildDummyFromTree(tree, keyPathParts, calleePaths, pathPrefix = []) {
5772
5961
  const props = [];
5773
5962
  for (const [key, value] of Object.entries(tree)) {
5963
+ const pathHere = [...pathPrefix, key];
5964
+ const pathStr = pathHere.join(".");
5774
5965
  const matchesKeyPath = keyPathParts && keyPathParts.length > 0 && keyPathParts[0] === key;
5775
5966
  if (matchesKeyPath && keyPathParts.length === 1) {
5776
5967
  props.push(t11.objectProperty(t11.identifier(key), t11.numericLiteral(0)));
5777
5968
  } else if (matchesKeyPath) {
5778
5969
  props.push(
5779
- t11.objectProperty(t11.identifier(key), buildDummyFromTree(value === true ? {} : value, keyPathParts.slice(1)))
5970
+ t11.objectProperty(
5971
+ t11.identifier(key),
5972
+ buildDummyFromTree(
5973
+ value === true ? {} : value,
5974
+ keyPathParts.slice(1),
5975
+ calleePaths,
5976
+ pathHere
5977
+ )
5978
+ )
5780
5979
  );
5781
5980
  } else if (value === true) {
5782
- props.push(t11.objectProperty(t11.identifier(key), t11.stringLiteral(" ")));
5981
+ props.push(
5982
+ t11.objectProperty(
5983
+ t11.identifier(key),
5984
+ calleePaths.has(pathStr) ? (
5985
+ // Return empty string so `${item.content()}` in template init does not inject "null" / escaped markup.
5986
+ t11.arrowFunctionExpression([], t11.stringLiteral(""), true)
5987
+ ) : t11.stringLiteral(" ")
5988
+ )
5989
+ );
5783
5990
  } else {
5784
- props.push(t11.objectProperty(t11.identifier(key), buildDummyFromTree(value, null)));
5991
+ props.push(
5992
+ t11.objectProperty(t11.identifier(key), buildDummyFromTree(value, null, calleePaths, pathHere))
5993
+ );
5785
5994
  }
5786
5995
  }
5787
5996
  return t11.objectExpression(props);
@@ -5792,7 +6001,6 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
5792
6001
  const arrayName = arrayPath.replace(/\./g, "");
5793
6002
  const capName = arrayName.charAt(0).toUpperCase() + arrayName.slice(1);
5794
6003
  const methodName = `patch${capName}Item`;
5795
- const containerProp = `__${arrayPath.replace(/\./g, "_")}_container`;
5796
6004
  const itemIdProperty = arrayMap.itemIdProperty;
5797
6005
  const itemTemplateRootIsComponent = t11.isJSXElement(arrayMap.itemTemplate) && isComponentTag(getJSXTagName(arrayMap.itemTemplate.openingElement.name));
5798
6006
  if (itemTemplateRootIsComponent) return { method: null, privateFields: [] };
@@ -6004,9 +6212,7 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
6004
6212
  const keyRenames = arrayMap.indexVariable ? /* @__PURE__ */ new Map([[arrayMap.indexVariable, "__idx"]]) : void 0;
6005
6213
  const rawItemIdExpr = arrayMap.keyExpression ? t11.cloneNode(rewriteItemVarInExpression(arrayMap.keyExpression, arrayMap.itemVariable, "item", keyRenames), true) : itemIdProperty && itemIdProperty !== ITEM_IS_KEY ? t11.logicalExpression("??", buildOptionalMemberChain(t11.identifier("item"), itemIdProperty), t11.identifier("item")) : t11.identifier("item");
6006
6214
  const itemIdExpr = t11.callExpression(t11.identifier("String"), [rawItemIdExpr]);
6007
- body.push(
6008
- t11.expressionStatement(t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaKey")), itemIdExpr))
6009
- );
6215
+ body.push(t11.expressionStatement(t11.assignmentExpression("=", buildExprGeaMember(elVar, "GEA_DOM_KEY"), itemIdExpr)));
6010
6216
  const rowElsProp = `__rowEls_${arrayMap.containerBindingId ?? "list"}`;
6011
6217
  const privateElsRef = t11.memberExpression(t11.thisExpression(), t11.privateName(t11.identifier(rowElsProp)));
6012
6218
  body.push(
@@ -6028,9 +6234,7 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
6028
6234
  );
6029
6235
  const patchPrivateFields = [rowElsProp];
6030
6236
  body.push(
6031
- t11.expressionStatement(
6032
- t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaItem")), t11.identifier("item"))
6033
- )
6237
+ t11.expressionStatement(t11.assignmentExpression("=", buildExprGeaMember(elVar, "GEA_DOM_ITEM"), t11.identifier("item")))
6034
6238
  );
6035
6239
  const params = [t11.identifier("row"), t11.identifier("item"), t11.identifier("__prevItem")];
6036
6240
  if (arrayMap.indexVariable) params.push(t11.identifier("__idx"));
@@ -6039,6 +6243,26 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
6039
6243
  privateFields: patchPrivateFields
6040
6244
  };
6041
6245
  }
6246
+ function textPatchHasItemMethodCall(expr, itemVar) {
6247
+ const calleeIsItemMethod = (callee) => t11.isMemberExpression(callee) && !callee.computed && t11.isIdentifier(callee.object, { name: itemVar });
6248
+ const visit = (e) => {
6249
+ let found = false;
6250
+ traverse6(t11.program([t11.expressionStatement(t11.cloneNode(e, true))]), {
6251
+ noScope: true,
6252
+ CallExpression(p) {
6253
+ if (calleeIsItemMethod(p.node.callee)) {
6254
+ found = true;
6255
+ p.stop();
6256
+ }
6257
+ }
6258
+ });
6259
+ return found;
6260
+ };
6261
+ if (t11.isTemplateLiteral(expr)) {
6262
+ return expr.expressions.some((ex) => visit(ex));
6263
+ }
6264
+ return visit(expr);
6265
+ }
6042
6266
  function collectPatchEntries(arrayMap) {
6043
6267
  const cloned = t11.cloneNode(arrayMap.itemTemplate, true);
6044
6268
  const tempFile = t11.file(t11.program([t11.expressionStatement(cloned)]));
@@ -6050,15 +6274,26 @@ function collectPatchEntries(arrayMap) {
6050
6274
  });
6051
6275
  const modified = tempFile.program.body[0].expression;
6052
6276
  const entries = [];
6053
- const requiresRerender = templateRequiresRerender(tempFile);
6277
+ let requiresRerender = templateRequiresRerender(tempFile);
6054
6278
  if (t11.isJSXElement(modified)) {
6055
6279
  const rootTagName = getJSXTagName(modified.openingElement.name);
6056
6280
  const rootIsComponent = isComponentTag(rootTagName);
6281
+ if (!rootIsComponent && !requiresRerender) {
6282
+ requiresRerender = templateHasChildComponent(modified);
6283
+ }
6057
6284
  walkJSXForPatch(modified, [], entries, rootIsComponent);
6058
6285
  }
6059
6286
  for (const ent of entries) {
6060
6287
  ent.expression = optionalizeMemberChainsAfterComputedItemKey(ent.expression, "item");
6061
6288
  }
6289
+ if (!requiresRerender) {
6290
+ for (const ent of entries) {
6291
+ if (ent.type === "text" && textPatchHasItemMethodCall(ent.expression, "item")) {
6292
+ requiresRerender = true;
6293
+ break;
6294
+ }
6295
+ }
6296
+ }
6062
6297
  return { entries, requiresRerender };
6063
6298
  }
6064
6299
  function walkJSXForPatch(node, path, entries, rootIsComponent = false) {
@@ -6130,7 +6365,9 @@ function walkJSXForPatch(node, path, entries, rootIsComponent = false) {
6130
6365
  let elementIndex = 0;
6131
6366
  for (const child of node.children) {
6132
6367
  if (t11.isJSXElement(child)) {
6133
- walkJSXForPatch(child, [...path, elementIndex], entries);
6368
+ if (!isComponentTag(getJSXTagName(child.openingElement.name))) {
6369
+ walkJSXForPatch(child, [...path, elementIndex], entries);
6370
+ }
6134
6371
  elementIndex++;
6135
6372
  }
6136
6373
  }
@@ -6325,7 +6562,7 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
6325
6562
  t11.expressionStatement(
6326
6563
  t11.assignmentExpression(
6327
6564
  "=",
6328
- t11.memberExpression(t11.identifier("el"), t11.identifier("__geaProps")),
6565
+ buildExprGeaMember(t11.identifier("el"), "GEA_DOM_PROPS"),
6329
6566
  t11.objectExpression(propsProperties)
6330
6567
  )
6331
6568
  )
@@ -6347,10 +6584,12 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
6347
6584
  }
6348
6585
  const propTree = collectItemTemplatePropTree(arrayMap.itemTemplate, arrayMap.itemVariable);
6349
6586
  const containerRef = t11.memberExpression(t11.thisExpression(), t11.identifier(containerProp));
6350
- const privateDcField = t11.memberExpression(t11.thisExpression(), t11.privateName(t11.identifier("__dc")));
6587
+ const dcFieldSuffix = arrayMap.containerBindingId ?? arrayPath.replace(/\./g, "_");
6588
+ const dcPrivateName = `__dc_${dcFieldSuffix}`;
6589
+ const privateDcField = t11.memberExpression(t11.thisExpression(), t11.privateName(t11.identifier(dcPrivateName)));
6351
6590
  const cVar = t11.identifier("__c");
6352
6591
  const elVar = t11.identifier("el");
6353
- const privateFields = ["__dc"];
6592
+ const privateFields = [dcPrivateName];
6354
6593
  const body = [];
6355
6594
  if (useRawStoreCache) {
6356
6595
  const privateRsField = t11.memberExpression(t11.thisExpression(), t11.privateName(t11.identifier("__rs")));
@@ -6364,7 +6603,7 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
6364
6603
  t11.assignmentExpression(
6365
6604
  "=",
6366
6605
  t11.cloneNode(privateRsField),
6367
- t11.memberExpression(t11.identifier(arrayMap.storeVar), t11.identifier("__raw"))
6606
+ buildExprGeaMember(t11.identifier(arrayMap.storeVar), "GEA_PROXY_RAW")
6368
6607
  )
6369
6608
  )
6370
6609
  )
@@ -6383,10 +6622,11 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
6383
6622
  )
6384
6623
  ])
6385
6624
  );
6386
- const isPrimitiveKey = !itemIdProperty || itemIdProperty === ITEM_IS_KEY;
6625
+ const isPrimitiveKey = (itemIdProperty === ITEM_IS_KEY || !itemIdProperty) && !arrayMap.keyExpression && Object.keys(propTree).length === 0;
6626
+ const calleePaths = collectItemCalleePropertyPaths(arrayMap.itemTemplate, arrayMap.itemVariable);
6387
6627
  const dummyItem = isPrimitiveKey ? t11.stringLiteral("__dummy__") : (() => {
6388
6628
  if (itemIdProperty) ensureDummyTreePath(propTree, itemIdProperty);
6389
- return buildDummyFromTree(propTree, itemIdProperty ? normalizePathParts(itemIdProperty) : null);
6629
+ return buildDummyFromTree(propTree, itemIdProperty ? normalizePathParts(itemIdProperty) : null, calleePaths);
6390
6630
  })();
6391
6631
  const hasRootClassNamePatch = patchedEntries.some((e) => e.type === "className" && e.childPath.length === 0);
6392
6632
  const tplInit = [
@@ -6411,7 +6651,7 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
6411
6651
  t11.expressionStatement(
6412
6652
  t11.assignmentExpression(
6413
6653
  "=",
6414
- t11.memberExpression(cVar, t11.identifier("__geaTpl")),
6654
+ buildExprGeaMember(cVar, "GEA_MAP_CONFIG_TPL"),
6415
6655
  t11.memberExpression(
6416
6656
  t11.memberExpression(t11.identifier("__tw"), t11.identifier("content")),
6417
6657
  t11.identifier("firstElementChild")
@@ -6421,7 +6661,7 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
6421
6661
  t11.expressionStatement(
6422
6662
  t11.optionalCallExpression(
6423
6663
  t11.optionalMemberExpression(
6424
- t11.memberExpression(cVar, t11.identifier("__geaTpl")),
6664
+ buildExprGeaMember(cVar, "GEA_MAP_CONFIG_TPL"),
6425
6665
  t11.identifier("removeAttribute"),
6426
6666
  false,
6427
6667
  true
@@ -6436,13 +6676,13 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
6436
6676
  t11.ifStatement(
6437
6677
  t11.logicalExpression(
6438
6678
  "&&",
6439
- t11.memberExpression(cVar, t11.identifier("__geaTpl")),
6440
- t11.memberExpression(t11.memberExpression(cVar, t11.identifier("__geaTpl")), t11.identifier("className"))
6679
+ buildExprGeaMember(cVar, "GEA_MAP_CONFIG_TPL"),
6680
+ t11.memberExpression(buildExprGeaMember(cVar, "GEA_MAP_CONFIG_TPL"), t11.identifier("className"))
6441
6681
  ),
6442
6682
  t11.expressionStatement(
6443
6683
  t11.assignmentExpression(
6444
6684
  "=",
6445
- t11.memberExpression(t11.memberExpression(cVar, t11.identifier("__geaTpl")), t11.identifier("className")),
6685
+ t11.memberExpression(buildExprGeaMember(cVar, "GEA_MAP_CONFIG_TPL"), t11.identifier("className")),
6446
6686
  t11.stringLiteral("")
6447
6687
  )
6448
6688
  )
@@ -6451,19 +6691,19 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
6451
6691
  }
6452
6692
  body.push(
6453
6693
  t11.ifStatement(
6454
- t11.unaryExpression("!", t11.memberExpression(cVar, t11.identifier("__geaTpl"))),
6694
+ t11.unaryExpression("!", buildExprGeaMember(cVar, "GEA_MAP_CONFIG_TPL")),
6455
6695
  t11.blockStatement([t11.tryStatement(t11.blockStatement(tplInit), loggingCatchClause())])
6456
6696
  )
6457
6697
  );
6458
6698
  body.push(
6459
6699
  t11.ifStatement(
6460
- t11.memberExpression(cVar, t11.identifier("__geaTpl")),
6700
+ buildExprGeaMember(cVar, "GEA_MAP_CONFIG_TPL"),
6461
6701
  t11.blockStatement([
6462
6702
  t11.variableDeclaration("var", [
6463
6703
  t11.variableDeclarator(
6464
6704
  elVar,
6465
6705
  t11.callExpression(
6466
- t11.memberExpression(t11.memberExpression(cVar, t11.identifier("__geaTpl")), t11.identifier("cloneNode")),
6706
+ t11.memberExpression(buildExprGeaMember(cVar, "GEA_MAP_CONFIG_TPL"), t11.identifier("cloneNode")),
6467
6707
  [t11.booleanLiteral(true)]
6468
6708
  )
6469
6709
  )
@@ -6658,17 +6898,16 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
6658
6898
  }
6659
6899
  }
6660
6900
  const createKeyRenames = arrayMap.indexVariable ? /* @__PURE__ */ new Map([[arrayMap.indexVariable, "__idx"]]) : void 0;
6661
- const rawPatchItemIdExpr = arrayMap.keyExpression ? t11.cloneNode(rewriteItemVarInExpression(arrayMap.keyExpression, arrayMap.itemVariable, "item", createKeyRenames), true) : itemIdProperty && itemIdProperty !== ITEM_IS_KEY ? t11.logicalExpression("??", buildOptionalMemberChain(t11.identifier("item"), itemIdProperty), t11.identifier("item")) : t11.identifier("item");
6901
+ const rawPatchItemIdExpr = arrayMap.keyExpression ? t11.cloneNode(
6902
+ rewriteItemVarInExpression(arrayMap.keyExpression, arrayMap.itemVariable, "item", createKeyRenames),
6903
+ true
6904
+ ) : itemIdProperty && itemIdProperty !== ITEM_IS_KEY ? t11.logicalExpression("??", buildOptionalMemberChain(t11.identifier("item"), itemIdProperty), t11.identifier("item")) : t11.identifier("item");
6662
6905
  const patchItemIdExpr = t11.callExpression(t11.identifier("String"), [rawPatchItemIdExpr]);
6663
6906
  body.push(
6664
- t11.expressionStatement(
6665
- t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaKey")), patchItemIdExpr)
6666
- )
6907
+ t11.expressionStatement(t11.assignmentExpression("=", buildExprGeaMember(elVar, "GEA_DOM_KEY"), patchItemIdExpr))
6667
6908
  );
6668
6909
  body.push(
6669
- t11.expressionStatement(
6670
- t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaItem")), t11.identifier("item"))
6671
- )
6910
+ t11.expressionStatement(t11.assignmentExpression("=", buildExprGeaMember(elVar, "GEA_DOM_ITEM"), t11.identifier("item")))
6672
6911
  );
6673
6912
  if (itemTemplateRootIsComponent && t11.isJSXElement(arrayMap.itemTemplate)) {
6674
6913
  const propsProperties = [];
@@ -6699,11 +6938,7 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
6699
6938
  if (propsProperties.length > 0) {
6700
6939
  body.push(
6701
6940
  t11.expressionStatement(
6702
- t11.assignmentExpression(
6703
- "=",
6704
- t11.memberExpression(elVar, t11.identifier("__geaProps")),
6705
- t11.objectExpression(propsProperties)
6706
- )
6941
+ t11.assignmentExpression("=", buildExprGeaMember(elVar, "GEA_DOM_PROPS"), t11.objectExpression(propsProperties))
6707
6942
  )
6708
6943
  );
6709
6944
  }
@@ -6752,6 +6987,14 @@ function branchContainsJSX(expr) {
6752
6987
  });
6753
6988
  return containsJSX;
6754
6989
  }
6990
+ function templateHasChildComponent(root) {
6991
+ for (const child of root.children) {
6992
+ if (!t11.isJSXElement(child)) continue;
6993
+ if (isComponentTag(getJSXTagName(child.openingElement.name))) return true;
6994
+ if (templateHasChildComponent(child)) return true;
6995
+ }
6996
+ return false;
6997
+ }
6755
6998
 
6756
6999
  // src/generate-clone.ts
6757
7000
  var EVENT_TYPES2 = /* @__PURE__ */ new Set([
@@ -6759,24 +7002,48 @@ var EVENT_TYPES2 = /* @__PURE__ */ new Set([
6759
7002
  "dblclick",
6760
7003
  "change",
6761
7004
  "input",
7005
+ "submit",
7006
+ "reset",
7007
+ "focus",
7008
+ "blur",
6762
7009
  "keydown",
6763
7010
  "keyup",
6764
- "blur",
6765
- "focus",
7011
+ "keypress",
6766
7012
  "mousedown",
6767
7013
  "mouseup",
6768
- "submit",
7014
+ "mouseover",
7015
+ "mouseout",
7016
+ "mouseenter",
7017
+ "mouseleave",
7018
+ "mousemove",
7019
+ "contextmenu",
7020
+ "touchstart",
7021
+ "touchend",
7022
+ "touchmove",
7023
+ "pointerdown",
7024
+ "pointerup",
7025
+ "pointermove",
7026
+ "scroll",
7027
+ "resize",
7028
+ "drag",
7029
+ "dragstart",
7030
+ "dragend",
7031
+ "dragover",
7032
+ "dragleave",
7033
+ "drop",
7034
+ "animationstart",
7035
+ "animationend",
7036
+ "animationiteration",
7037
+ "transitionstart",
7038
+ "transitionend",
7039
+ "transitionrun",
7040
+ "transitioncancel",
6769
7041
  "tap",
6770
7042
  "longTap",
6771
7043
  "swipeRight",
6772
7044
  "swipeUp",
6773
7045
  "swipeLeft",
6774
- "swipeDown",
6775
- "dragstart",
6776
- "dragend",
6777
- "dragover",
6778
- "dragleave",
6779
- "drop"
7046
+ "swipeDown"
6780
7047
  ]);
6781
7048
  var VOID_ELEMENTS2 = /* @__PURE__ */ new Set([
6782
7049
  "area",
@@ -6831,7 +7098,7 @@ function buildEventIdExpr(suffix) {
6831
7098
  t12.stringLiteral("-" + suffix)
6832
7099
  );
6833
7100
  }
6834
- function jsxToStaticHtml(node, refCounter, elementPath = [], isRoot = true) {
7101
+ function jsxToStaticHtml(node, refCounter, elementPath = [], _isRoot = true) {
6835
7102
  const tagName = getJSXTagName(node.openingElement.name);
6836
7103
  const isComp = Boolean(tagName && isComponentTag(tagName));
6837
7104
  if (isComp) return null;
@@ -7272,7 +7539,13 @@ function generateCloneMembers(root, analysis, templateParams, sourceFile, import
7272
7539
  true
7273
7540
  );
7274
7541
  const cloneMethodBody = buildCloneTemplateBody(identityPatches, contentPatches, cloneCtx);
7275
- const cloneMethod = t12.classMethod("method", t12.identifier("__cloneTemplate"), [], t12.blockStatement(cloneMethodBody));
7542
+ const cloneMethod = t12.classMethod(
7543
+ "method",
7544
+ t12.identifier("GEA_CLONE_TEMPLATE"),
7545
+ [],
7546
+ t12.blockStatement(cloneMethodBody),
7547
+ true
7548
+ );
7276
7549
  return [staticField, cloneMethod];
7277
7550
  }
7278
7551
  function buildCloneTemplateBody(identityPatches, contentPatches, cloneCtx) {
@@ -7471,7 +7744,9 @@ function buildCloneTemplateBody(identityPatches, contentPatches, cloneCtx) {
7471
7744
 
7472
7745
  // src/generate-events.ts
7473
7746
  import * as t13 from "@babel/types";
7747
+ import babelGenerator from "@babel/generator";
7474
7748
  import { id as id4, jsBlockBody, jsMethod as jsMethod2 } from "eszter";
7749
+ var generate2 = typeof babelGenerator.default === "function" ? babelGenerator.default : babelGenerator;
7475
7750
  function getTemplateParamContext(classBody2) {
7476
7751
  const templateMethod = classBody2.body.find(
7477
7752
  (m) => t13.isClassMethod(m) && t13.isIdentifier(m.key) && m.key.name === "template"
@@ -7495,12 +7770,26 @@ function getTemplateParamContext(classBody2) {
7495
7770
  function getMapContextKey(ctx) {
7496
7771
  const store = ctx.storeVar || "store";
7497
7772
  const path = ctx.arrayPathParts.join("_");
7498
- return `${store}_${path}_${ctx.itemIdProperty}`;
7773
+ const keyPart = ctx.keyExpression ? `expr:${generate2(ctx.keyExpression).code}` : ctx.itemIdProperty;
7774
+ return `${store}_${path}_${keyPart}`;
7499
7775
  }
7500
7776
  function ensureMapItemHelper(classBody2, ctx, helperName) {
7501
7777
  if (classBody2.body.some((m) => t13.isClassMethod(m) && t13.isIdentifier(m.key) && m.key.name === helperName)) return;
7502
7778
  const itemsExpr = buildArrayItemsExpr(ctx);
7503
- const findPredicate = ctx.itemIdProperty && ctx.itemIdProperty !== ITEM_IS_KEY ? t13.arrowFunctionExpression(
7779
+ const findPredicate = ctx.keyExpression ? t13.arrowFunctionExpression(
7780
+ [t13.identifier("__candidate")],
7781
+ t13.binaryExpression(
7782
+ "===",
7783
+ t13.callExpression(t13.identifier("String"), [
7784
+ rewriteItemVarInExpression(
7785
+ t13.cloneNode(ctx.keyExpression, true),
7786
+ ctx.itemVariable,
7787
+ "__candidate"
7788
+ )
7789
+ ]),
7790
+ t13.identifier("__itemId")
7791
+ )
7792
+ ) : ctx.itemIdProperty && ctx.itemIdProperty !== ITEM_IS_KEY ? t13.arrowFunctionExpression(
7504
7793
  [t13.identifier("__candidate")],
7505
7794
  t13.binaryExpression(
7506
7795
  "===",
@@ -7529,18 +7818,34 @@ function ensureMapItemHelper(classBody2, ctx, helperName) {
7529
7818
  )
7530
7819
  );
7531
7820
  const method = jsMethod2`${id4(helperName)}(e) {}`;
7532
- method.body.body.push(
7533
- ...buildGeaItemDomWalk(),
7534
- ...jsBlockBody`
7535
- if (!__el) return null;
7536
- if (__el.__geaItem) return __el.__geaItem;
7537
- const __itemId = __el.__geaKey ?? (__el.getAttribute && __el.getAttribute('data-gea-item-id'));
7538
- if (__itemId == null) return null;
7539
- const __items = ${itemsExpr};
7540
- const __arr = Array.isArray(__items) ? __items : Array.isArray(__items?.__getTarget) ? __items.__getTarget : [];
7541
- return __arr.find(${findPredicate}) || __itemId;
7542
- `
7543
- );
7821
+ if (!ctx.keyExpression && ctx.itemIdProperty && ctx.itemIdProperty !== ITEM_IS_KEY) {
7822
+ method.body.body.push(
7823
+ ...buildGeaItemDomWalk(),
7824
+ ...jsBlockBody`
7825
+ if (!__el) return null;
7826
+ if (__el[GEA_DOM_ITEM]) return __el[GEA_DOM_ITEM];
7827
+ const __itemId = __el[GEA_DOM_KEY] ?? (__el.getAttribute && __el.getAttribute('data-gea-item-id'));
7828
+ if (__itemId == null) return null;
7829
+ const __items = ${itemsExpr};
7830
+ const __arr = Array.isArray(__items) ? __items : Array.isArray(__items?.[GEA_PROXY_GET_TARGET]) ? __items[GEA_PROXY_GET_TARGET] : [];
7831
+ const __found = __arr.find(${findPredicate});
7832
+ return __found != null ? __found : { ${ctx.itemIdProperty}: __itemId };
7833
+ `
7834
+ );
7835
+ } else {
7836
+ method.body.body.push(
7837
+ ...buildGeaItemDomWalk(),
7838
+ ...jsBlockBody`
7839
+ if (!__el) return null;
7840
+ if (__el[GEA_DOM_ITEM]) return __el[GEA_DOM_ITEM];
7841
+ const __itemId = __el[GEA_DOM_KEY] ?? (__el.getAttribute && __el.getAttribute('data-gea-item-id'));
7842
+ if (__itemId == null) return null;
7843
+ const __items = ${itemsExpr};
7844
+ const __arr = Array.isArray(__items) ? __items : Array.isArray(__items?.[GEA_PROXY_GET_TARGET]) ? __items[GEA_PROXY_GET_TARGET] : [];
7845
+ return __arr.find(${findPredicate}) || __itemId;
7846
+ `
7847
+ );
7848
+ }
7544
7849
  classBody2.body.unshift(method);
7545
7850
  }
7546
7851
  function getLocalFunctionInSetup(name, setupStatements) {
@@ -7552,12 +7857,17 @@ function getLocalFunctionInSetup(name, setupStatements) {
7552
7857
  }
7553
7858
  return null;
7554
7859
  }
7555
- function appendCompiledEventMethods(classBody2, handlers, setupStatements = []) {
7860
+ function appendCompiledEventMethods(classBody2, handlers, setupStatements = [], fileAst) {
7556
7861
  if (handlers.length === 0) return false;
7557
7862
  const paramContext = getTemplateParamContext(classBody2);
7558
7863
  const mapHandlers = handlers.filter(
7559
7864
  (h) => Boolean(h.mapContext)
7560
7865
  );
7866
+ if (mapHandlers.length > 0 && fileAst) {
7867
+ ensureImport(fileAst, "@geajs/core", "GEA_MAPS");
7868
+ ensureImport(fileAst, "@geajs/core", "GEA_DOM_KEY");
7869
+ ensureImport(fileAst, "@geajs/core", "GEA_DOM_ITEM");
7870
+ }
7561
7871
  const seenContexts = /* @__PURE__ */ new Set();
7562
7872
  for (const h of mapHandlers) {
7563
7873
  const key = getMapContextKey(h.mapContext);
@@ -7572,6 +7882,13 @@ function appendCompiledEventMethods(classBody2, handlers, setupStatements = [])
7572
7882
  function isDirectThisMethodRef(handler) {
7573
7883
  return !!handler.handlerExpression && t13.isMemberExpression(handler.handlerExpression) && t13.isThisExpression(handler.handlerExpression.object) && t13.isIdentifier(handler.handlerExpression.property) && !handler.delegatedPropName && !handler.mapContext;
7574
7884
  }
7885
+ function wrapEventsGetterHandlerRef(methodProperty) {
7886
+ const callee = t13.memberExpression(t13.thisExpression(), methodProperty);
7887
+ return t13.arrowFunctionExpression(
7888
+ [t13.identifier("e"), t13.identifier("targetComponent")],
7889
+ t13.callExpression(callee, [t13.identifier("e"), t13.identifier("targetComponent")])
7890
+ );
7891
+ }
7575
7892
  function appendEventsGetterHandlers(classBody2, handlers, paramContext, setupStatements) {
7576
7893
  const getter = ensureEventsGetter(classBody2);
7577
7894
  const eventsObject = getEventsObject(getter);
@@ -7580,7 +7897,7 @@ function appendEventsGetterHandlers(classBody2, handlers, paramContext, setupSta
7580
7897
  let handlerRef;
7581
7898
  if (isDirectThisMethodRef(handler)) {
7582
7899
  const prop = handler.handlerExpression.property;
7583
- handlerRef = t13.memberExpression(t13.thisExpression(), t13.cloneNode(prop));
7900
+ handlerRef = wrapEventsGetterHandlerRef(t13.cloneNode(prop));
7584
7901
  } else {
7585
7902
  let methodName = handler.methodName || `__event_${handler.eventType}_${index}`;
7586
7903
  let uniqueIndex = 1;
@@ -7591,7 +7908,7 @@ function appendEventsGetterHandlers(classBody2, handlers, paramContext, setupSta
7591
7908
  if (!findClassMethod(classBody2, methodName)) {
7592
7909
  classBody2.body.push(buildSelectorHandlerMethod(handler, methodName, paramContext, setupStatements));
7593
7910
  }
7594
- handlerRef = t13.memberExpression(t13.thisExpression(), t13.identifier(methodName));
7911
+ handlerRef = wrapEventsGetterHandlerRef(t13.identifier(methodName));
7595
7912
  }
7596
7913
  const selectorExpr = handler.selectorExpression ? replacePropRefsInExpression(
7597
7914
  t13.cloneNode(handler.selectorExpression, true),
@@ -7725,7 +8042,7 @@ function replacePropsObjectRefsInNode(node, propsObjectName) {
7725
8042
  replacePropsObjectRefsInNode(node.object, propsObjectName),
7726
8043
  node.property,
7727
8044
  node.computed,
7728
- node.optional
8045
+ node.optional ?? true
7729
8046
  );
7730
8047
  }
7731
8048
  if (t13.isOptionalCallExpression(node)) {
@@ -7734,7 +8051,7 @@ function replacePropsObjectRefsInNode(node, propsObjectName) {
7734
8051
  node.arguments.map(
7735
8052
  (a) => t13.isExpression(a) ? replacePropsObjectRefsInNode(a, propsObjectName) : a
7736
8053
  ),
7737
- node.optional
8054
+ node.optional ?? true
7738
8055
  );
7739
8056
  }
7740
8057
  if (t13.isConditionalExpression(node)) {
@@ -7831,7 +8148,7 @@ function buildArrayItemsExpr(ctx, opts = {}) {
7831
8148
  return t13.callExpression(
7832
8149
  t13.memberExpression(
7833
8150
  t13.memberExpression(
7834
- t13.memberExpression(t13.thisExpression(), t13.identifier("__geaMaps")),
8151
+ t13.memberExpression(t13.thisExpression(), t13.identifier("GEA_MAPS"), true),
7835
8152
  t13.numericLiteral(mapIdx),
7836
8153
  true
7837
8154
  ),
@@ -7840,7 +8157,7 @@ function buildArrayItemsExpr(ctx, opts = {}) {
7840
8157
  []
7841
8158
  );
7842
8159
  }
7843
- const base = ctx.isImportedState ? opts.raw ? t13.memberExpression(t13.identifier(ctx.storeVar || "store"), t13.identifier("__raw")) : t13.identifier(ctx.storeVar || "store") : t13.thisExpression();
8160
+ const base = ctx.isImportedState ? opts.raw ? buildExprGeaMember(t13.identifier(ctx.storeVar || "store"), "GEA_PROXY_RAW") : t13.identifier(ctx.storeVar || "store") : t13.thisExpression();
7844
8161
  if (ctx.arrayPathParts.length === 0) return base;
7845
8162
  const [, ...rest] = ctx.arrayPathParts;
7846
8163
  const isIndex = /^\d+$/.test(first);
@@ -7850,7 +8167,7 @@ function buildArrayItemsExpr(ctx, opts = {}) {
7850
8167
  function buildGeaItemDomWalk() {
7851
8168
  return jsBlockBody`
7852
8169
  var __el = e.target;
7853
- while (__el && __el.__geaKey == null && (!__el.getAttribute || !__el.getAttribute('data-gea-item-id'))) __el = __el.parentElement;
8170
+ while (__el && __el[GEA_DOM_KEY] == null && (!__el.getAttribute || !__el.getAttribute('data-gea-item-id'))) __el = __el.parentElement;
7854
8171
  `;
7855
8172
  }
7856
8173
  function buildMapEventBody(handler, paramContext) {
@@ -7868,8 +8185,8 @@ function buildMapEventBody(handler, paramContext) {
7868
8185
  const preamble2 = [
7869
8186
  ...buildGeaItemDomWalk(),
7870
8187
  ...jsBlockBody`
7871
- if (!__el || !__el.__geaItem) return;
7872
- const ${id4(ctx.indexVariable)} = ${rawArrayExpr}.indexOf(__el.__geaItem);
8188
+ if (!__el || !__el[GEA_DOM_ITEM]) return;
8189
+ const ${id4(ctx.indexVariable)} = ${rawArrayExpr}.indexOf(__el[GEA_DOM_ITEM]);
7873
8190
  `
7874
8191
  ];
7875
8192
  return [...preamble2, ...handlerBody];
@@ -7883,7 +8200,7 @@ function buildMapEventBody(handler, paramContext) {
7883
8200
  preamble.push(
7884
8201
  ...buildGeaItemDomWalk(),
7885
8202
  ...jsBlockBody`
7886
- const ${id4(ctx.indexVariable)} = __el ? ${rawArrayExpr}.indexOf(__el.__geaItem) : -1;
8203
+ const ${id4(ctx.indexVariable)} = __el ? ${rawArrayExpr}.indexOf(__el[GEA_DOM_ITEM]) : -1;
7887
8204
  `
7888
8205
  );
7889
8206
  }
@@ -8008,10 +8325,7 @@ function injectChildComponents(ast, componentInstances, directForwardingChildren
8008
8325
  t14.assignmentExpression(
8009
8326
  "=",
8010
8327
  t14.memberExpression(t14.thisExpression(), t14.identifier(backingField)),
8011
- t14.callExpression(t14.memberExpression(t14.thisExpression(), t14.identifier("__child")), [
8012
- t14.identifier(child.tagName),
8013
- propsArg
8014
- ])
8328
+ t14.callExpression(buildThisGeaMember("GEA_CHILD"), [t14.identifier(child.tagName), propsArg])
8015
8329
  )
8016
8330
  )
8017
8331
  ),
@@ -8084,10 +8398,7 @@ function buildInstanceStatements(instances, directForwardingChildren) {
8084
8398
  t14.assignmentExpression(
8085
8399
  "=",
8086
8400
  t14.memberExpression(t14.thisExpression(), t14.identifier(child.instanceVar)),
8087
- t14.callExpression(t14.memberExpression(t14.thisExpression(), t14.identifier("__child")), [
8088
- t14.identifier(child.tagName),
8089
- propsArg
8090
- ])
8401
+ t14.callExpression(buildThisGeaMember("GEA_CHILD"), [t14.identifier(child.tagName), propsArg])
8091
8402
  )
8092
8403
  )
8093
8404
  );
@@ -8167,7 +8478,7 @@ function buildPropsBuilderMethod(child) {
8167
8478
  }
8168
8479
 
8169
8480
  // src/apply-reactivity.ts
8170
- import babelGenerator from "@babel/generator";
8481
+ import babelGenerator2 from "@babel/generator";
8171
8482
  import * as t20 from "@babel/types";
8172
8483
  import { appendToBody as appendToBody5, id as id11, js as js6, jsBlockBody as jsBlockBody4, jsExpr as jsExpr4, jsMethod as jsMethod8 } from "eszter";
8173
8484
 
@@ -8225,10 +8536,7 @@ function buildValueExpression(textExpr, stateRefs) {
8225
8536
  return rewriteStateRefs(t15.cloneNode(textExpr.expression, true), stateRefs);
8226
8537
  }
8227
8538
  if (textExpr.isImportedState && textExpr.storeVar) {
8228
- return buildMemberChainFromParts(
8229
- t15.memberExpression(t15.identifier(textExpr.storeVar), t15.identifier("__store")),
8230
- textExpr.pathParts
8231
- );
8539
+ return buildMemberChainFromParts(t15.identifier(textExpr.storeVar), textExpr.pathParts);
8232
8540
  }
8233
8541
  return buildMemberChainFromParts(t15.thisExpression(), textExpr.pathParts);
8234
8542
  }
@@ -8248,19 +8556,15 @@ function rewriteStateRefs(expr, stateRefs) {
8248
8556
  } else if (ref.kind === "local") {
8249
8557
  path.replaceWith(t15.thisExpression());
8250
8558
  } else if ((ref.kind === "imported-destructured" || ref.kind === "store-alias") && ref.storeVar && ref.propName) {
8251
- path.replaceWith(
8252
- t15.memberExpression(
8253
- t15.memberExpression(t15.identifier(ref.storeVar), t15.identifier("__store")),
8254
- t15.identifier(ref.propName)
8255
- )
8256
- );
8559
+ path.replaceWith(t15.memberExpression(t15.identifier(ref.storeVar), t15.identifier(ref.propName)));
8257
8560
  path.skip();
8258
8561
  } else if (ref.kind === "local-destructured" && ref.propName) {
8259
8562
  path.replaceWith(t15.memberExpression(t15.thisExpression(), t15.identifier(ref.propName)));
8260
8563
  path.skip();
8261
- } else {
8262
- path.replaceWith(t15.memberExpression(t15.identifier(path.node.name), t15.identifier("__store")));
8564
+ } else if (ref.kind === "imported") {
8263
8565
  path.skip();
8566
+ } else {
8567
+ throw new Error(`rewriteStateRefs: unhandled state ref kind ${ref.kind}`);
8264
8568
  }
8265
8569
  }
8266
8570
  });
@@ -8304,7 +8608,7 @@ function buildSimpleUpdate(binding, param, stateRefs) {
8304
8608
  }
8305
8609
  if (target === "textContent" && binding.bindingId && binding.bindingId !== "" && !binding.userIdExpr) {
8306
8610
  const suffix = t15.stringLiteral(binding.bindingId);
8307
- return js3`${jsExpr2`this.__updateText(${suffix}, ${valueExpr})`};`;
8611
+ return t15.expressionStatement(t15.callExpression(buildThisGeaMember("GEA_UPDATE_TEXT"), [suffix, valueExpr]));
8308
8612
  }
8309
8613
  return js3`if (${el}) { ${jsExpr2`${el}.${id6(target)}`} = ${valueExpr}; }`;
8310
8614
  }
@@ -8560,7 +8864,7 @@ function buildPropPatcherFunction(binding, propName) {
8560
8864
  t17.variableDeclaration("const", [
8561
8865
  t17.variableDeclarator(
8562
8866
  t17.identifier("__newAttr"),
8563
- URL_ATTRS2.has(attrName) ? t17.callExpression(t17.identifier("__sanitizeAttr"), [
8867
+ URL_ATTRS2.has(attrName) ? t17.callExpression(t17.identifier("geaSanitizeAttr"), [
8564
8868
  t17.stringLiteral(attrName),
8565
8869
  t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
8566
8870
  ]) : t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
@@ -8934,7 +9238,9 @@ function generateEnsureArrayConfigsMethod(arrayMaps) {
8934
9238
  ])
8935
9239
  );
8936
9240
  });
8937
- return appendToBody3(jsMethod5`${id8("__ensureArrayConfigs")}() {}`, ...body);
9241
+ const method = t17.classMethod("method", t17.identifier("GEA_ENSURE_ARRAY_CONFIGS"), [], t17.blockStatement([]), true);
9242
+ method.body.body.push(...body);
9243
+ return method;
8938
9244
  }
8939
9245
  function generateArrayRelationalObserver(path, arrayMap, bindings, methodName) {
8940
9246
  const arrayPath = pathPartsToString(getArrayPathParts(arrayMap));
@@ -9009,12 +9315,12 @@ function generateArrayConditionalPatchObserver(arrayMap, bindings, methodName) {
9009
9315
  const containerName = `__${arrayPath.replace(/\./g, "_")}_container`;
9010
9316
  const containerRef = t17.memberExpression(t17.thisExpression(), t17.identifier(containerName));
9011
9317
  const proxiedArr = arrayMap.isImportedState ? buildMemberChain(
9012
- t17.memberExpression(t17.identifier(arrayMap.storeVar || "store"), t17.identifier("__store")),
9318
+ buildExprGeaMember(t17.identifier(arrayMap.storeVar || "store"), "GEA_STORE_ROOT"),
9013
9319
  arrayPath
9014
9320
  ) : buildMemberChain(t17.thisExpression(), arrayPath);
9015
9321
  const rawArrExpr = t17.logicalExpression(
9016
9322
  "||",
9017
- t17.memberExpression(t17.cloneNode(proxiedArr, true), t17.identifier("__getTarget")),
9323
+ buildExprGeaMember(t17.cloneNode(proxiedArr, true), "GEA_PROXY_GET_TARGET"),
9018
9324
  t17.cloneNode(proxiedArr, true)
9019
9325
  );
9020
9326
  const loopBody = [
@@ -9067,12 +9373,12 @@ function generateArrayConditionalRerenderObserver(arrayMap, methodName) {
9067
9373
  const containerRef = t17.memberExpression(t17.thisExpression(), t17.identifier(containerName));
9068
9374
  const configRef = t17.memberExpression(t17.thisExpression(), t17.identifier(getArrayConfigPropName(arrayMap)));
9069
9375
  const proxiedArr = arrayMap.isImportedState ? buildMemberChain(
9070
- t17.memberExpression(t17.identifier(arrayMap.storeVar || "store"), t17.identifier("__store")),
9376
+ buildExprGeaMember(t17.identifier(arrayMap.storeVar || "store"), "GEA_STORE_ROOT"),
9071
9377
  arrayPath
9072
9378
  ) : buildMemberChain(t17.thisExpression(), arrayPath);
9073
9379
  const rawArrExpr = t17.logicalExpression(
9074
9380
  "||",
9075
- t17.memberExpression(t17.cloneNode(proxiedArr, true), t17.identifier("__getTarget")),
9381
+ buildExprGeaMember(t17.cloneNode(proxiedArr, true), "GEA_PROXY_GET_TARGET"),
9076
9382
  t17.cloneNode(proxiedArr, true)
9077
9383
  );
9078
9384
  return appendToBody3(
@@ -9150,9 +9456,7 @@ function generateArrayConditionalRerenderObserver(arrayMap, methodName) {
9150
9456
  t17.ifStatement(
9151
9457
  t17.unaryExpression("!", t17.identifier("__skipArrayConditionalRerender")),
9152
9458
  t17.blockStatement([
9153
- t17.expressionStatement(
9154
- t17.callExpression(t17.memberExpression(t17.thisExpression(), t17.identifier("__ensureArrayConfigs")), [])
9155
- ),
9459
+ t17.expressionStatement(buildThisGeaCall("GEA_ENSURE_ARRAY_CONFIGS")),
9156
9460
  t17.variableDeclaration("const", [
9157
9461
  t17.variableDeclarator(
9158
9462
  t17.identifier("__arr"),
@@ -9164,7 +9468,7 @@ function generateArrayConditionalRerenderObserver(arrayMap, methodName) {
9164
9468
  )
9165
9469
  ]),
9166
9470
  t17.expressionStatement(
9167
- t17.callExpression(t17.memberExpression(t17.thisExpression(), t17.identifier("__applyListChanges")), [
9471
+ buildThisGeaCall("GEA_APPLY_LIST_CHANGES", [
9168
9472
  containerRef,
9169
9473
  t17.identifier("__arr"),
9170
9474
  t17.nullLiteral(),
@@ -9266,10 +9570,7 @@ function buildElsLookup(elsRef, containerRef, idExpr, rowVar, containerBindingId
9266
9570
  t17.binaryExpression(
9267
9571
  "<",
9268
9572
  t17.identifier("__i"),
9269
- t17.memberExpression(
9270
- t17.memberExpression(ctrLocal, t17.identifier("children")),
9271
- t17.identifier("length")
9272
- )
9573
+ t17.memberExpression(t17.memberExpression(ctrLocal, t17.identifier("children")), t17.identifier("length"))
9273
9574
  ),
9274
9575
  t17.updateExpression("++", t17.identifier("__i")),
9275
9576
  t17.blockStatement([
@@ -9288,16 +9589,12 @@ function buildElsLookup(elsRef, containerRef, idExpr, rowVar, containerBindingId
9288
9589
  "||",
9289
9590
  t17.binaryExpression(
9290
9591
  "==",
9291
- t17.memberExpression(t17.identifier("__ch"), t17.identifier("__geaKey")),
9592
+ buildExprGeaMember(t17.identifier("__ch"), "GEA_DOM_KEY"),
9292
9593
  t17.cloneNode(idExpr, true)
9293
9594
  ),
9294
9595
  t17.logicalExpression(
9295
9596
  "&&",
9296
- t17.binaryExpression(
9297
- "==",
9298
- t17.memberExpression(t17.identifier("__ch"), t17.identifier("__geaKey")),
9299
- t17.nullLiteral()
9300
- ),
9597
+ t17.binaryExpression("==", buildExprGeaMember(t17.identifier("__ch"), "GEA_DOM_KEY"), t17.nullLiteral()),
9301
9598
  t17.binaryExpression(
9302
9599
  "==",
9303
9600
  t17.optionalCallExpression(
@@ -9385,11 +9682,9 @@ function generateArrayHandlers(arrayMap, methodName) {
9385
9682
  t17.returnStatement()
9386
9683
  ])
9387
9684
  ),
9685
+ t17.expressionStatement(buildThisGeaCall("GEA_ENSURE_ARRAY_CONFIGS")),
9388
9686
  t17.expressionStatement(
9389
- t17.callExpression(t17.memberExpression(t17.thisExpression(), t17.identifier("__ensureArrayConfigs")), [])
9390
- ),
9391
- t17.expressionStatement(
9392
- t17.callExpression(t17.memberExpression(t17.thisExpression(), t17.identifier("__applyListChanges")), [
9687
+ buildThisGeaCall("GEA_APPLY_LIST_CHANGES", [
9393
9688
  containerRef,
9394
9689
  t17.identifier(paramName),
9395
9690
  t17.identifier("change"),
@@ -9727,7 +10022,7 @@ function generateRenderItemMethod(arrayMap, imports, eventHandlers, eventIdCount
9727
10022
  t18.assignmentExpression(
9728
10023
  "=",
9729
10024
  t18.cloneNode(privateRsField),
9730
- t18.memberExpression(t18.identifier(arrayMap.storeVar), t18.identifier("__raw"))
10025
+ buildExprGeaMember(t18.identifier(arrayMap.storeVar), "GEA_PROXY_RAW")
9731
10026
  )
9732
10027
  )
9733
10028
  )
@@ -9743,11 +10038,33 @@ function generateRenderItemMethod(arrayMap, imports, eventHandlers, eventIdCount
9743
10038
  returnStmt
9744
10039
  );
9745
10040
  if (handlerPropsInMap.length > 0 && classBody2) {
9746
- const handleItemHandler = jsMethod6`__handleItemHandler(itemId, e) {
9747
- const fn = this.__itemHandlers_?.[itemId];
9748
- if (fn) fn(e);
9749
- }`;
9750
- if (!classBody2.body.some((m) => t18.isClassMethod(m) && t18.isIdentifier(m.key) && m.key.name === "__handleItemHandler")) {
10041
+ const handleItemHandlerBody = t18.blockStatement([
10042
+ t18.variableDeclaration("const", [
10043
+ t18.variableDeclarator(
10044
+ t18.identifier("fn"),
10045
+ t18.optionalMemberExpression(
10046
+ t18.memberExpression(t18.thisExpression(), t18.identifier("__itemHandlers_")),
10047
+ t18.identifier("itemId"),
10048
+ true,
10049
+ true
10050
+ )
10051
+ )
10052
+ ]),
10053
+ t18.ifStatement(
10054
+ t18.identifier("fn"),
10055
+ t18.expressionStatement(t18.callExpression(t18.identifier("fn"), [t18.identifier("e")]))
10056
+ )
10057
+ ]);
10058
+ const handleItemHandler = t18.classMethod(
10059
+ "method",
10060
+ t18.identifier("GEA_HANDLE_ITEM_HANDLER"),
10061
+ [t18.identifier("itemId"), t18.identifier("e")],
10062
+ handleItemHandlerBody,
10063
+ true
10064
+ );
10065
+ if (!classBody2.body.some(
10066
+ (m) => t18.isClassMethod(m) && m.computed === true && t18.isIdentifier(m.key) && m.key.name === "GEA_HANDLE_ITEM_HANDLER"
10067
+ )) {
9751
10068
  classBody2.body.unshift(handleItemHandler);
9752
10069
  }
9753
10070
  }
@@ -9755,6 +10072,7 @@ function generateRenderItemMethod(arrayMap, imports, eventHandlers, eventIdCount
9755
10072
  h.mapContext = {
9756
10073
  arrayPathParts: arrayMap.arrayPathParts || normalizePathParts(arrayMap.arrayPath || ""),
9757
10074
  itemIdProperty: arrayMap.itemIdProperty || "id",
10075
+ ...arrayMap.keyExpression ? { keyExpression: t18.cloneNode(arrayMap.keyExpression, true) } : {},
9758
10076
  itemVariable: arrayMap.itemVariable,
9759
10077
  indexVariable: arrayMap.indexVariable,
9760
10078
  isImportedState: arrayMap.isImportedState || false,
@@ -9785,7 +10103,16 @@ function getArrayCapName2(arrayPropName) {
9785
10103
  return arrayPropName.charAt(0).toUpperCase() + arrayPropName.slice(1);
9786
10104
  }
9787
10105
  function getComponentArrayItemsName(arrayPropName) {
9788
- return `_${arrayPropName}Items`;
10106
+ const safe = arrayPropName.replace(/[^a-zA-Z0-9_$]/g, "_");
10107
+ return `_gea_${safe}_items`;
10108
+ }
10109
+ function buildComponentArrayItemsSymbolDecl(arrayPropName, itemsBinding) {
10110
+ return t19.variableDeclaration("const", [
10111
+ t19.variableDeclarator(
10112
+ t19.identifier(itemsBinding),
10113
+ t19.callExpression(t19.identifier("geaListItemsSymbol"), [t19.stringLiteral(arrayPropName)])
10114
+ )
10115
+ ]);
9789
10116
  }
9790
10117
  function getComponentArrayRefreshMethodName(arrayPropName) {
9791
10118
  return `__refresh${getArrayCapName2(arrayPropName)}Items`;
@@ -9853,6 +10180,7 @@ function generateComponentArrayResult(um, arrayPropName, imports, propNames, _cl
9853
10180
  finalPropsExpr = cloned;
9854
10181
  }
9855
10182
  const itemsName = getComponentArrayItemsName(arrayPropName);
10183
+ const symbolConstDecl = buildComponentArrayItemsSymbolDecl(arrayPropName, itemsName);
9856
10184
  let arrAccessExpr;
9857
10185
  let arrSetupStatements = [];
9858
10186
  if (storeArrayAccess) {
@@ -9895,7 +10223,7 @@ function generateComponentArrayResult(um, arrayPropName, imports, propNames, _cl
9895
10223
  if (!t19.isVariableDeclaration(stmt)) continue;
9896
10224
  for (const decl of stmt.declarations) {
9897
10225
  if (t19.isIdentifier(decl.init) && storeVarNames.has(decl.init.name)) {
9898
- decl.init = t19.memberExpression(t19.identifier(decl.init.name), t19.identifier("__raw"));
10226
+ decl.init = buildExprGeaMember(t19.identifier(decl.init.name), "GEA_PROXY_RAW");
9899
10227
  }
9900
10228
  }
9901
10229
  }
@@ -9909,7 +10237,7 @@ function generateComponentArrayResult(um, arrayPropName, imports, propNames, _cl
9909
10237
  const keyExpr = itemIdProp && itemIdProp !== ITEM_IS_KEY ? t19.callExpression(t19.identifier("String"), [t19.memberExpression(t19.identifier("opt"), t19.identifier(itemIdProp))]) : itemIdProp === ITEM_IS_KEY ? t19.callExpression(t19.identifier("String"), [t19.identifier("opt")]) : t19.binaryExpression("+", t19.stringLiteral("__idx_"), t19.identifier("__k"));
9910
10238
  const mapParams = [t19.identifier("opt")];
9911
10239
  if (indexVar || !itemIdProp) mapParams.push(t19.identifier("__k"));
9912
- const childCall = t19.callExpression(t19.memberExpression(t19.thisExpression(), t19.identifier("__child")), [
10240
+ const childCall = t19.callExpression(buildThisGeaMember("GEA_CHILD"), [
9913
10241
  t19.identifier(comp.componentTag),
9914
10242
  t19.cloneNode(itemPropsCall, true),
9915
10243
  t19.cloneNode(keyExpr, true)
@@ -9919,11 +10247,12 @@ function generateComponentArrayResult(um, arrayPropName, imports, propNames, _cl
9919
10247
  const parenthesized = t19.parenthesizedExpression ? t19.parenthesizedExpression(nullishCoalesce) : nullishCoalesce;
9920
10248
  const mapCallExpr = t19.callExpression(t19.memberExpression(parenthesized, t19.identifier("map")), [mapCallback]);
9921
10249
  const constructorInit = t19.expressionStatement(
9922
- t19.assignmentExpression("=", t19.memberExpression(t19.thisExpression(), t19.identifier(itemsName)), mapCallExpr)
10250
+ t19.assignmentExpression("=", t19.memberExpression(t19.thisExpression(), t19.identifier(itemsName), true), mapCallExpr)
9923
10251
  );
9924
10252
  return {
9925
10253
  itemPropsMethod,
9926
10254
  constructorInit,
10255
+ symbolConstDecl,
9927
10256
  componentTag: comp.componentTag,
9928
10257
  containerBindingId: um.containerBindingId,
9929
10258
  containerUserIdExpr: um.containerUserIdExpr,
@@ -9935,7 +10264,7 @@ function generateComponentArrayResult(um, arrayPropName, imports, propNames, _cl
9935
10264
 
9936
10265
  // src/apply-reactivity.ts
9937
10266
  import { createRequire as createRequire12 } from "module";
9938
- var generate2 = "default" in babelGenerator ? babelGenerator.default : babelGenerator;
10267
+ var generate3 = "default" in babelGenerator2 ? babelGenerator2.default : babelGenerator2;
9939
10268
  var URL_ATTRS3 = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "cite", "poster", "background"]);
9940
10269
  var require13 = createRequire12(import.meta.url);
9941
10270
  var traverse12 = require13("@babel/traverse").default;
@@ -9962,7 +10291,7 @@ function rewriteTemplateBodyForImportedState(_templateMethod, _stateRefs, _store
9962
10291
  function generateCreatedHooks(stores, hasArrayConfigs, observeListConfigs = []) {
9963
10292
  const body = [];
9964
10293
  if (hasArrayConfigs) {
9965
- body.push(js6`this.__ensureArrayConfigs();`);
10294
+ body.push(t20.expressionStatement(buildThisGeaCall("GEA_ENSURE_ARRAY_CONFIGS")));
9966
10295
  }
9967
10296
  const observeListPathKeys = /* @__PURE__ */ new Set();
9968
10297
  for (const config of observeListConfigs) {
@@ -9991,7 +10320,7 @@ function generateCreatedHooks(stores, hasArrayConfigs, observeListConfigs = [])
9991
10320
  if (handlers.length === 1 && !handlers[0].isVia) {
9992
10321
  body.push(
9993
10322
  t20.expressionStatement(
9994
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__observe")), [
10323
+ t20.callExpression(thisGea("GEA_OBSERVE"), [
9995
10324
  storeVarExpr,
9996
10325
  pathArray,
9997
10326
  t20.memberExpression(t20.thisExpression(), t20.identifier(handlers[0].methodName))
@@ -10022,10 +10351,10 @@ function generateCreatedHooks(stores, hasArrayConfigs, observeListConfigs = [])
10022
10351
  ])
10023
10352
  );
10024
10353
  if (h.dynamicKeyExpr) {
10025
- const keyId = t20.identifier(`__geaKey${hi}`);
10026
- const changeId = t20.identifier(`__geaChange${hi}`);
10027
- const partsId = t20.identifier(`__geaParts${hi}`);
10028
- const prevRootId = t20.identifier(`__geaPrevRoot${hi}`);
10354
+ const keyId = t20.identifier(`geaDynKey${hi}`);
10355
+ const changeId = t20.identifier(`geaDynChange${hi}`);
10356
+ const partsId = t20.identifier(`geaDynParts${hi}`);
10357
+ const prevRootId = t20.identifier(`geaDynPrevRoot${hi}`);
10029
10358
  const prefixChecks = h.pathParts.map(
10030
10359
  (part, idx) => t20.binaryExpression(
10031
10360
  "===",
@@ -10103,7 +10432,7 @@ function generateCreatedHooks(stores, hasArrayConfigs, observeListConfigs = [])
10103
10432
  }
10104
10433
  body.push(
10105
10434
  t20.expressionStatement(
10106
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__observe")), [
10435
+ t20.callExpression(thisGea("GEA_OBSERVE"), [
10107
10436
  storeVarExpr,
10108
10437
  pathArray,
10109
10438
  t20.arrowFunctionExpression([vParam, cParam], t20.blockStatement(callStmts))
@@ -10117,17 +10446,15 @@ function generateCreatedHooks(stores, hasArrayConfigs, observeListConfigs = [])
10117
10446
  const itemsName = getComponentArrayItemsName(config.arrayPropName);
10118
10447
  const itemPropsMethodName = `__itemProps_${config.arrayPropName}`;
10119
10448
  const configProps = [
10120
- t20.objectProperty(t20.identifier("items"), t20.memberExpression(t20.thisExpression(), t20.identifier(itemsName))),
10121
- t20.objectProperty(t20.identifier("itemsKey"), t20.stringLiteral(itemsName)),
10449
+ t20.objectProperty(t20.identifier("items"), t20.memberExpression(t20.thisExpression(), t20.identifier(itemsName), true)),
10450
+ t20.objectProperty(t20.identifier("itemsKey"), t20.identifier(itemsName)),
10122
10451
  t20.objectProperty(
10123
10452
  t20.identifier("container"),
10124
10453
  t20.arrowFunctionExpression(
10125
10454
  [],
10126
10455
  config.containerUserIdExpr ? t20.callExpression(t20.memberExpression(t20.identifier("document"), t20.identifier("getElementById")), [
10127
10456
  t20.cloneNode(config.containerUserIdExpr, true)
10128
- ]) : config.containerBindingId ? t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__el")), [
10129
- t20.stringLiteral(config.containerBindingId)
10130
- ]) : jsExpr4`this.$(":scope")`
10457
+ ]) : config.containerBindingId ? t20.callExpression(thisGea("GEA_EL"), [t20.stringLiteral(config.containerBindingId)]) : jsExpr4`this.$(":scope")`
10131
10458
  )
10132
10459
  ),
10133
10460
  t20.objectProperty(t20.identifier("Ctor"), t20.identifier(config.componentTag)),
@@ -10156,6 +10483,11 @@ function generateCreatedHooks(stores, hasArrayConfigs, observeListConfigs = [])
10156
10483
  )
10157
10484
  )
10158
10485
  ];
10486
+ if (config.afterCondSlotIndex != null) {
10487
+ configProps.push(
10488
+ t20.objectProperty(t20.identifier("afterCondSlotIndex"), t20.numericLiteral(config.afterCondSlotIndex))
10489
+ );
10490
+ }
10159
10491
  const samePathHandlers = [];
10160
10492
  const pathKey = JSON.stringify(config.pathParts);
10161
10493
  for (const handler of store.observeHandlers) {
@@ -10181,11 +10513,7 @@ function generateCreatedHooks(stores, hasArrayConfigs, observeListConfigs = [])
10181
10513
  }
10182
10514
  body.push(
10183
10515
  t20.expressionStatement(
10184
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__observeList")), [
10185
- storeVarExpr,
10186
- pathArray,
10187
- t20.objectExpression(configProps)
10188
- ])
10516
+ t20.callExpression(thisGea("GEA_OBSERVE_LIST"), [storeVarExpr, pathArray, t20.objectExpression(configProps)])
10189
10517
  )
10190
10518
  );
10191
10519
  }
@@ -10226,6 +10554,15 @@ function classMethodUsesParam(method, index) {
10226
10554
  function serializeAstNode(node) {
10227
10555
  return node ? JSON.stringify(node) : "";
10228
10556
  }
10557
+ var thisGea = buildThisGeaMember;
10558
+ function insertStmtBeforeClass(classPath, stmt) {
10559
+ const parent = classPath.parentPath;
10560
+ if (parent.isExportDefaultDeclaration()) {
10561
+ parent.insertBefore(stmt);
10562
+ } else {
10563
+ classPath.insertBefore(stmt);
10564
+ }
10565
+ }
10229
10566
  function expressionReferencesIdentifier(expr, name) {
10230
10567
  let found = false;
10231
10568
  const program12 = t20.program([t20.expressionStatement(t20.cloneNode(expr, true))]);
@@ -10241,16 +10578,16 @@ function expressionReferencesIdentifier(expr, name) {
10241
10578
  return found;
10242
10579
  }
10243
10580
  function generateLocalStateObserverSetup(observeHandlers, hasArrayConfigs) {
10244
- const localStore = t20.memberExpression(t20.thisExpression(), t20.identifier("__store"));
10581
+ const localStore = buildThisGeaMember("GEA_STORE_ROOT");
10245
10582
  const body = [];
10246
10583
  if (hasArrayConfigs) {
10247
- body.push(js6`this.__ensureArrayConfigs();`);
10584
+ body.push(t20.expressionStatement(buildThisGeaCall("GEA_ENSURE_ARRAY_CONFIGS")));
10248
10585
  }
10249
10586
  body.push(js6`if (!${localStore}) { return; }`);
10250
10587
  for (const observeHandler of observeHandlers) {
10251
10588
  body.push(
10252
10589
  t20.expressionStatement(
10253
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__observe")), [
10590
+ t20.callExpression(thisGea("GEA_OBSERVE"), [
10254
10591
  t20.thisExpression(),
10255
10592
  t20.arrayExpression(observeHandler.pathParts.map((part) => t20.stringLiteral(part))),
10256
10593
  t20.memberExpression(t20.thisExpression(), t20.identifier(observeHandler.methodName))
@@ -10258,7 +10595,13 @@ function generateLocalStateObserverSetup(observeHandlers, hasArrayConfigs) {
10258
10595
  )
10259
10596
  );
10260
10597
  }
10261
- const method = jsMethod8`${id11("__setupLocalStateObservers")}() {}`;
10598
+ const method = t20.classMethod(
10599
+ "method",
10600
+ t20.identifier("GEA_SETUP_LOCAL_STATE_OBSERVERS"),
10601
+ [],
10602
+ t20.blockStatement([]),
10603
+ true
10604
+ );
10262
10605
  method.body.body.push(...body);
10263
10606
  return method;
10264
10607
  }
@@ -10291,6 +10634,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
10291
10634
  traverse12(ast, {
10292
10635
  ClassDeclaration(classPath) {
10293
10636
  if (!t20.isIdentifier(classPath.node.id) || classPath.node.id.name !== className) return;
10637
+ ensureGeaCompilerSymbolImports(ast);
10294
10638
  let originalClassBody;
10295
10639
  traverse12(originalAST, {
10296
10640
  noScope: true,
@@ -10386,7 +10730,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
10386
10730
  t20.memberExpression(t20.thisExpression(), t20.identifier("id")),
10387
10731
  t20.stringLiteral("-" + pb.bindingId)
10388
10732
  )
10389
- ) : pb.selector === ":scope" ? t20.memberExpression(t20.thisExpression(), t20.identifier("element_")) : t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("$")), [
10733
+ ) : pb.selector === ":scope" ? thisGea("GEA_ELEMENT") : t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("$")), [
10390
10734
  t20.stringLiteral(pb.selector)
10391
10735
  ]);
10392
10736
  const valueExpr = pb.expression && pb.setupStatements ? t20.identifier("__boundValue") : t20.identifier("value");
@@ -10460,31 +10804,163 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
10460
10804
  t20.cloneNode(valueExpr, true)
10461
10805
  )
10462
10806
  );
10463
- const consequent = isHtmlProducing ? t20.blockStatement([
10464
- assignStmt,
10465
- // After replacing innerHTML for children, re-initialize child
10466
- // components that were created from the new HTML string.
10467
- t20.expressionStatement(
10468
- t20.callExpression(
10469
- t20.memberExpression(t20.thisExpression(), t20.identifier("instantiateChildComponents_")),
10470
- []
10471
- )
10472
- ),
10473
- // Reconnect compiled children from the parent component whose
10474
- // DOM elements were replaced by the innerHTML update.
10475
- t20.ifStatement(
10476
- t20.memberExpression(t20.thisExpression(), t20.identifier("parentComponent")),
10807
+ let consequent;
10808
+ if (isHtmlProducing) {
10809
+ const __tpl = t20.identifier("__tpl");
10810
+ const __nc = t20.identifier("__nc");
10811
+ const __oc = t20.identifier("__oc");
10812
+ const __structural = t20.identifier("__structural");
10813
+ const __j = t20.identifier("__j");
10814
+ const setupStmts = [
10815
+ t20.variableDeclaration("var", [
10816
+ t20.variableDeclarator(
10817
+ __tpl,
10818
+ t20.callExpression(t20.memberExpression(t20.identifier("document"), t20.identifier("createElement")), [
10819
+ t20.stringLiteral("template")
10820
+ ])
10821
+ )
10822
+ ]),
10477
10823
  t20.expressionStatement(
10478
- t20.callExpression(
10824
+ t20.assignmentExpression(
10825
+ "=",
10826
+ t20.memberExpression(__tpl, t20.identifier("innerHTML")),
10827
+ t20.cloneNode(valueExpr, true)
10828
+ )
10829
+ ),
10830
+ t20.variableDeclaration("var", [
10831
+ t20.variableDeclarator(
10832
+ __nc,
10479
10833
  t20.memberExpression(
10480
- t20.memberExpression(t20.thisExpression(), t20.identifier("parentComponent")),
10481
- t20.identifier("mountCompiledChildComponents_")
10834
+ t20.memberExpression(__tpl, t20.identifier("content")),
10835
+ t20.identifier("childNodes")
10836
+ )
10837
+ )
10838
+ ]),
10839
+ t20.variableDeclaration("var", [
10840
+ t20.variableDeclarator(__oc, t20.memberExpression(t20.identifier("__el"), t20.identifier("childNodes")))
10841
+ ])
10842
+ ];
10843
+ const structuralDetect = [
10844
+ t20.variableDeclaration("var", [
10845
+ t20.variableDeclarator(
10846
+ __structural,
10847
+ t20.binaryExpression(
10848
+ "!==",
10849
+ t20.memberExpression(__nc, t20.identifier("length")),
10850
+ t20.memberExpression(__oc, t20.identifier("length"))
10851
+ )
10852
+ )
10853
+ ]),
10854
+ t20.ifStatement(
10855
+ t20.unaryExpression("!", __structural),
10856
+ t20.blockStatement([
10857
+ t20.forStatement(
10858
+ t20.variableDeclaration("var", [t20.variableDeclarator(__j, t20.numericLiteral(0))]),
10859
+ t20.binaryExpression("<", __j, t20.memberExpression(__nc, t20.identifier("length"))),
10860
+ t20.updateExpression("++", __j),
10861
+ t20.blockStatement([
10862
+ t20.ifStatement(
10863
+ t20.logicalExpression(
10864
+ "||",
10865
+ t20.binaryExpression(
10866
+ "!==",
10867
+ t20.memberExpression(t20.memberExpression(__oc, __j, true), t20.identifier("nodeType")),
10868
+ t20.memberExpression(t20.memberExpression(__nc, __j, true), t20.identifier("nodeType"))
10869
+ ),
10870
+ t20.logicalExpression(
10871
+ "&&",
10872
+ t20.binaryExpression(
10873
+ "===",
10874
+ t20.memberExpression(t20.memberExpression(__oc, __j, true), t20.identifier("nodeType")),
10875
+ t20.numericLiteral(1)
10876
+ ),
10877
+ t20.binaryExpression(
10878
+ "!==",
10879
+ t20.memberExpression(t20.memberExpression(__oc, __j, true), t20.identifier("tagName")),
10880
+ t20.memberExpression(t20.memberExpression(__nc, __j, true), t20.identifier("tagName"))
10881
+ )
10882
+ )
10883
+ ),
10884
+ t20.blockStatement([
10885
+ t20.expressionStatement(t20.assignmentExpression("=", __structural, t20.booleanLiteral(true))),
10886
+ t20.breakStatement()
10887
+ ])
10888
+ )
10889
+ ])
10890
+ )
10891
+ ])
10892
+ )
10893
+ ];
10894
+ const patchNodeCall = t20.callExpression(
10895
+ t20.memberExpression(
10896
+ t20.memberExpression(t20.thisExpression(), t20.identifier("constructor")),
10897
+ t20.identifier("GEA_PATCH_NODE"),
10898
+ true
10899
+ ),
10900
+ [t20.memberExpression(__oc, __j, true), t20.memberExpression(__nc, __j, true), t20.booleanLiteral(true)]
10901
+ );
10902
+ const patchLoop = t20.forStatement(
10903
+ t20.variableDeclaration("var", [t20.variableDeclarator(__j, t20.numericLiteral(0))]),
10904
+ t20.binaryExpression("<", __j, t20.memberExpression(__nc, t20.identifier("length"))),
10905
+ t20.updateExpression("++", __j),
10906
+ t20.blockStatement([
10907
+ t20.ifStatement(
10908
+ t20.binaryExpression(
10909
+ "===",
10910
+ t20.memberExpression(t20.memberExpression(__oc, __j, true), t20.identifier("nodeType")),
10911
+ t20.numericLiteral(3)
10482
10912
  ),
10483
- []
10913
+ t20.blockStatement([
10914
+ t20.ifStatement(
10915
+ t20.binaryExpression(
10916
+ "!==",
10917
+ t20.memberExpression(t20.memberExpression(__oc, __j, true), t20.identifier("textContent")),
10918
+ t20.memberExpression(t20.memberExpression(__nc, __j, true), t20.identifier("textContent"))
10919
+ ),
10920
+ t20.expressionStatement(
10921
+ t20.assignmentExpression(
10922
+ "=",
10923
+ t20.memberExpression(t20.memberExpression(__oc, __j, true), t20.identifier("textContent")),
10924
+ t20.memberExpression(t20.memberExpression(__nc, __j, true), t20.identifier("textContent"))
10925
+ )
10926
+ )
10927
+ )
10928
+ ]),
10929
+ t20.ifStatement(
10930
+ t20.binaryExpression(
10931
+ "===",
10932
+ t20.memberExpression(t20.memberExpression(__oc, __j, true), t20.identifier("nodeType")),
10933
+ t20.numericLiteral(1)
10934
+ ),
10935
+ t20.expressionStatement(patchNodeCall)
10936
+ )
10937
+ )
10938
+ ])
10939
+ );
10940
+ const fallbackBlock = t20.blockStatement([
10941
+ assignStmt,
10942
+ t20.expressionStatement(t20.callExpression(buildThisGeaMember("GEA_INSTANTIATE_CHILD_COMPONENTS"), [])),
10943
+ t20.ifStatement(
10944
+ buildThisGeaMember("GEA_PARENT_COMPONENT"),
10945
+ t20.expressionStatement(
10946
+ t20.callExpression(
10947
+ buildExprGeaMember(
10948
+ buildThisGeaMember("GEA_PARENT_COMPONENT"),
10949
+ "GEA_MOUNT_COMPILED_CHILD_COMPONENTS"
10950
+ ),
10951
+ []
10952
+ )
10484
10953
  )
10485
10954
  )
10486
- )
10487
- ]) : assignStmt;
10955
+ ]);
10956
+ consequent = t20.blockStatement([
10957
+ ...setupStmts,
10958
+ ...structuralDetect,
10959
+ t20.ifStatement(__structural, fallbackBlock, t20.blockStatement([patchLoop]))
10960
+ ]);
10961
+ } else {
10962
+ consequent = assignStmt;
10963
+ }
10488
10964
  updateStmt = t20.ifStatement(
10489
10965
  t20.binaryExpression(
10490
10966
  "!==",
@@ -10679,7 +11155,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
10679
11155
  t20.binaryExpression("===", valueExpr, t20.nullLiteral()),
10680
11156
  t20.binaryExpression("===", valueExpr, t20.identifier("undefined"))
10681
11157
  );
10682
- const newAttrValueExpr = isBooleanAttr ? t20.stringLiteral("") : URL_ATTRS3.has(attrName) ? t20.callExpression(t20.identifier("__sanitizeAttr"), [
11158
+ const newAttrValueExpr = isBooleanAttr ? t20.stringLiteral("") : URL_ATTRS3.has(attrName) ? t20.callExpression(t20.identifier("geaSanitizeAttr"), [
10683
11159
  t20.stringLiteral(attrName),
10684
11160
  t20.callExpression(t20.identifier("String"), [valueExpr])
10685
11161
  ]) : t20.callExpression(t20.identifier("String"), [valueExpr]);
@@ -10885,8 +11361,35 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
10885
11361
  const parsed = JSON.parse(entry.observeKey);
10886
11362
  const storeVarName = parsed.storeVar || void 0;
10887
11363
  const methodNameStr = getObserveMethodName(propPath, storeVarName);
10888
- const prevProp = `__geaPrev_guard_${methodNameStr}`;
10889
- const rerenderMethod = jsMethod8`${id11(methodNameStr)}(__v, __c) { if (!__v === !this.${id11(prevProp)}) return; this.${id11(prevProp)} = __v; this.__geaRequestRender(); }`;
11364
+ const prevGuardMem = t20.memberExpression(
11365
+ t20.thisExpression(),
11366
+ t20.callExpression(t20.identifier("geaPrevGuardSymbol"), [t20.stringLiteral(methodNameStr)]),
11367
+ true
11368
+ );
11369
+ const rerenderMethod = t20.classMethod(
11370
+ "method",
11371
+ t20.identifier(methodNameStr),
11372
+ [t20.identifier("__v"), t20.identifier("__c")],
11373
+ t20.blockStatement([
11374
+ // Skip only when we've seen a prior value and truthiness is unchanged.
11375
+ // If prev is undefined and __v is false, !__v and !prev are both true — without this
11376
+ // guard the first delivery after mount would skip rerender (auth early-return repro).
11377
+ t20.ifStatement(
11378
+ t20.logicalExpression(
11379
+ "&&",
11380
+ t20.binaryExpression("!==", prevGuardMem, t20.identifier("undefined")),
11381
+ t20.binaryExpression(
11382
+ "===",
11383
+ t20.unaryExpression("!", t20.identifier("__v")),
11384
+ t20.unaryExpression("!", prevGuardMem)
11385
+ )
11386
+ ),
11387
+ t20.returnStatement()
11388
+ ),
11389
+ t20.expressionStatement(t20.assignmentExpression("=", prevGuardMem, t20.identifier("__v"))),
11390
+ t20.expressionStatement(buildThisGeaCall("GEA_REQUEST_RENDER"))
11391
+ ])
11392
+ );
10890
11393
  mergeObserveMethod(entry.observeKey, rerenderMethod);
10891
11394
  if (!stateProps.has(entry.observeKey)) {
10892
11395
  stateProps.set(entry.observeKey, entry.pathParts);
@@ -10951,9 +11454,11 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
10951
11454
  usesTargetComponent: true
10952
11455
  }));
10953
11456
  if (delegatedEvents.length > 0) {
10954
- appendCompiledEventMethods(classPath.node.body, delegatedEvents);
11457
+ appendCompiledEventMethods(classPath.node.body, delegatedEvents, [], ast);
10955
11458
  }
10956
11459
  }
11460
+ ensureImport(ast, "@geajs/core", "geaListItemsSymbol");
11461
+ insertStmtBeforeClass(classPath, arrayResult.symbolConstDecl);
10957
11462
  inlineIntoConstructor(classPath.node.body, [
10958
11463
  ...arrayResult.arrSetupStatements.map((s) => t20.cloneNode(s, true)),
10959
11464
  arrayResult.constructorInit
@@ -10966,7 +11471,8 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
10966
11471
  componentTag: arrayResult.componentTag,
10967
11472
  containerBindingId: arrayResult.containerBindingId,
10968
11473
  containerUserIdExpr: arrayResult.containerUserIdExpr,
10969
- itemIdProperty: arrayResult.itemIdProperty
11474
+ itemIdProperty: arrayResult.itemIdProperty,
11475
+ afterCondSlotIndex: um.afterCondSlotIndex
10970
11476
  });
10971
11477
  } else {
10972
11478
  const computedDeps = (um.dependencies || collectUnresolvedDependencies([um], stateRefs, classPath.node.body)).filter((dep) => dep.storeVar || dep.pathParts[0] !== "props");
@@ -10976,9 +11482,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
10976
11482
  const containerSuffix = arrayResult.containerBindingId;
10977
11483
  const containerExpr = arrayResult.containerUserIdExpr ? t20.callExpression(t20.memberExpression(t20.identifier("document"), t20.identifier("getElementById")), [
10978
11484
  t20.cloneNode(arrayResult.containerUserIdExpr, true)
10979
- ]) : containerSuffix ? t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__el")), [
10980
- t20.stringLiteral(containerSuffix)
10981
- ]) : jsExpr4`this.$(":scope")`;
11485
+ ]) : containerSuffix ? t20.callExpression(thisGea("GEA_EL"), [t20.stringLiteral(containerSuffix)]) : jsExpr4`this.$(":scope")`;
10982
11486
  const itemIdProp = arrayResult.itemIdProperty;
10983
11487
  const keyFn = itemIdProp && itemIdProp !== ITEM_IS_KEY ? t20.arrowFunctionExpression(
10984
11488
  [t20.identifier("opt")],
@@ -11006,8 +11510,8 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11006
11510
  t20.variableDeclaration("const", [
11007
11511
  t20.variableDeclarator(
11008
11512
  t20.identifier("__new"),
11009
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__reconcileList")), [
11010
- t20.memberExpression(t20.thisExpression(), t20.identifier(itemsName)),
11513
+ t20.callExpression(thisGea("GEA_RECONCILE_LIST"), [
11514
+ t20.memberExpression(t20.thisExpression(), t20.identifier(itemsName), true),
11011
11515
  t20.identifier("__arr"),
11012
11516
  t20.cloneNode(containerExpr, true),
11013
11517
  t20.identifier(arrayResult.componentTag),
@@ -11026,7 +11530,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11026
11530
  t20.assignmentExpression(
11027
11531
  "=",
11028
11532
  t20.memberExpression(
11029
- t20.memberExpression(t20.thisExpression(), t20.identifier(itemsName)),
11533
+ t20.memberExpression(t20.thisExpression(), t20.identifier(itemsName), true),
11030
11534
  t20.identifier("length")
11031
11535
  ),
11032
11536
  t20.numericLiteral(0)
@@ -11035,7 +11539,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11035
11539
  t20.expressionStatement(
11036
11540
  t20.callExpression(
11037
11541
  t20.memberExpression(
11038
- t20.memberExpression(t20.thisExpression(), t20.identifier(itemsName)),
11542
+ t20.memberExpression(t20.thisExpression(), t20.identifier(itemsName), true),
11039
11543
  t20.identifier("push")
11040
11544
  ),
11041
11545
  [t20.spreadElement(t20.identifier("__new"))]
@@ -11222,11 +11726,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11222
11726
  t20.identifier(getObserveMethodName(dep.pathParts, dep.storeVar)),
11223
11727
  [t20.identifier("value"), t20.identifier("change")],
11224
11728
  t20.blockStatement([
11225
- t20.expressionStatement(
11226
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__geaSyncMap")), [
11227
- t20.numericLiteral(mapIdx)
11228
- ])
11229
- )
11729
+ t20.expressionStatement(t20.callExpression(thisGea("GEA_SYNC_MAP"), [t20.numericLiteral(mapIdx)]))
11230
11730
  ])
11231
11731
  )
11232
11732
  );
@@ -11285,13 +11785,13 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11285
11785
  );
11286
11786
  if (elRefFieldNames.length > 0) {
11287
11787
  const hasReset = classPath.node.body.body.some(
11288
- (m) => t20.isClassMethod(m) && t20.isIdentifier(m.key) && m.key.name === "__resetEls"
11788
+ (m) => t20.isClassMethod(m) && m.computed === true && t20.isIdentifier(m.key) && m.key.name === "GEA_RESET_ELS"
11289
11789
  );
11290
11790
  if (!hasReset) {
11291
11791
  classPath.node.body.body.push(
11292
11792
  t20.classMethod(
11293
11793
  "method",
11294
- t20.identifier("__resetEls"),
11794
+ t20.identifier("GEA_RESET_ELS"),
11295
11795
  [],
11296
11796
  t20.blockStatement(
11297
11797
  elRefFieldNames.map(
@@ -11303,7 +11803,8 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11303
11803
  )
11304
11804
  )
11305
11805
  )
11306
- )
11806
+ ),
11807
+ true
11307
11808
  )
11308
11809
  );
11309
11810
  applied = true;
@@ -11334,11 +11835,13 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11334
11835
  if (!dep.storeVar) continue;
11335
11836
  addCondSlotIndex(dep.observeKey, slotIndex);
11336
11837
  }
11337
- for (const htmlExpr of [slot.truthyHtmlExpr, slot.falsyHtmlExpr]) {
11338
- if (!htmlExpr) continue;
11339
- const contentDeps = collectExpressionDependencies(htmlExpr, stateRefs, slot.setupStatements);
11340
- for (const dep of contentDeps) {
11341
- addCondSlotIndex(dep.observeKey, slotIndex);
11838
+ if (!slot.hasCompiledChildren) {
11839
+ for (const htmlExpr of [slot.truthyHtmlExpr, slot.falsyHtmlExpr]) {
11840
+ if (!htmlExpr) continue;
11841
+ const contentDeps = collectExpressionDependencies(htmlExpr, stateRefs, slot.setupStatements);
11842
+ for (const dep of contentDeps) {
11843
+ addCondSlotIndex(dep.observeKey, slotIndex);
11844
+ }
11342
11845
  }
11343
11846
  }
11344
11847
  });
@@ -11348,9 +11851,10 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11348
11851
  stateProps.set(observeKey, parts);
11349
11852
  }
11350
11853
  }
11351
- const hasOnPropChange = classPath.node.body.body.some(
11352
- (member) => t20.isClassMethod(member) && t20.isIdentifier(member.key) && member.key.name === "__onPropChange"
11353
- );
11854
+ const hasOnPropChange = classPath.node.body.body.some((member) => {
11855
+ if (!t20.isClassMethod(member) || !t20.isIdentifier(member.key)) return false;
11856
+ return member.computed && member.key.name === "GEA_ON_PROP_CHANGE";
11857
+ });
11354
11858
  const childObserveGroups = /* @__PURE__ */ new Map();
11355
11859
  compiledChildren.forEach((child) => {
11356
11860
  if (childHasNoProps(child)) return;
@@ -11764,9 +12268,9 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11764
12268
  }).map((child) => {
11765
12269
  const updateExpr = t20.expressionStatement(
11766
12270
  t20.callExpression(
11767
- t20.memberExpression(
12271
+ buildExprGeaMember(
11768
12272
  t20.memberExpression(t20.thisExpression(), t20.identifier(child.instanceVar)),
11769
- t20.identifier("__geaUpdateProps")
12273
+ "GEA_UPDATE_PROPS"
11770
12274
  ),
11771
12275
  [
11772
12276
  t20.callExpression(
@@ -11806,7 +12310,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11806
12310
  unresolvedBindings.forEach(({ info, binding }) => {
11807
12311
  const deps = info.dependencies || collectUnresolvedDependencies([info], stateRefs, classPath.node.body);
11808
12312
  const mapIdx = getMapIndex(binding.arrayPathParts);
11809
- const delegateName = `__geaSyncMapDelegate_${mapIdx}`;
12313
+ const delegateName = `geaSyncMapDelegate_${mapIdx}`;
11810
12314
  const hasNonRelationalDeps = deps.some(
11811
12315
  (dep) => !(info.relationalClassBindings || []).find((rb) => rb.observeKey === dep.observeKey)
11812
12316
  );
@@ -11838,11 +12342,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11838
12342
  classPath.node.body.body.push(
11839
12343
  appendToBody5(
11840
12344
  jsMethod8`${id11(delegateName)}() {}`,
11841
- t20.expressionStatement(
11842
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__geaSyncMap")), [
11843
- t20.numericLiteral(mapIdx)
11844
- ])
11845
- )
12345
+ t20.expressionStatement(t20.callExpression(thisGea("GEA_SYNC_MAP"), [t20.numericLiteral(mapIdx)]))
11846
12346
  )
11847
12347
  );
11848
12348
  delegateEmitted = true;
@@ -11854,11 +12354,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11854
12354
  });
11855
12355
  } else {
11856
12356
  const syncBody = t20.blockStatement([
11857
- t20.expressionStatement(
11858
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__geaSyncMap")), [
11859
- t20.numericLiteral(mapIdx)
11860
- ])
11861
- )
12357
+ t20.expressionStatement(t20.callExpression(thisGea("GEA_SYNC_MAP"), [t20.numericLiteral(mapIdx)]))
11862
12358
  ]);
11863
12359
  mergeObserveMethod(
11864
12360
  dep.observeKey,
@@ -11950,9 +12446,11 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11950
12446
  usesTargetComponent: true
11951
12447
  }));
11952
12448
  if (delegatedEvents.length > 0) {
11953
- appendCompiledEventMethods(classPath.node.body, delegatedEvents);
12449
+ appendCompiledEventMethods(classPath.node.body, delegatedEvents, [], ast);
11954
12450
  }
11955
12451
  }
12452
+ ensureImport(ast, "@geajs/core", "geaListItemsSymbol");
12453
+ insertStmtBeforeClass(classPath, arrayResult.symbolConstDecl);
11956
12454
  inlineIntoConstructor(classPath.node.body, [
11957
12455
  ...arrayResult.arrSetupStatements.map((s) => t20.cloneNode(s, true)),
11958
12456
  arrayResult.constructorInit
@@ -11965,7 +12463,8 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11965
12463
  componentTag: arrayResult.componentTag,
11966
12464
  containerBindingId: arrayResult.containerBindingId,
11967
12465
  containerUserIdExpr: arrayResult.containerUserIdExpr,
11968
- itemIdProperty: arrayResult.itemIdProperty
12466
+ itemIdProperty: arrayResult.itemIdProperty,
12467
+ afterCondSlotIndex: arrayMap.afterCondSlotIndex
11969
12468
  });
11970
12469
  }
11971
12470
  componentArrayDisposeTargets.push(getComponentArrayItemsName(arrayPropName));
@@ -11993,14 +12492,12 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
11993
12492
  const depObserveKey = buildObserveKey(depPath, arrayMap.storeVar);
11994
12493
  const depMethodName = getObserveMethodName(depPath, arrayMap.storeVar);
11995
12494
  const refreshStmt = t20.expressionStatement(
11996
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__refreshList")), [
11997
- t20.stringLiteral(pathKey)
11998
- ])
12495
+ t20.callExpression(thisGea("GEA_REFRESH_LIST"), [t20.stringLiteral(pathKey)])
11999
12496
  );
12000
12497
  const existing = addedMethods.get(depObserveKey);
12001
12498
  if (existing && t20.isBlockStatement(existing.body)) {
12002
12499
  const renderedGuardIdx = existing.body.body.findIndex(
12003
- (s) => t20.isIfStatement(s) && t20.isMemberExpression(s.test) && t20.isIdentifier(s.test.property) && s.test.property.name === "rendered_"
12500
+ (s) => t20.isIfStatement(s) && t20.isMemberExpression(s.test) && s.test.computed === true && t20.isIdentifier(s.test.property) && s.test.property.name === "GEA_RENDERED"
12004
12501
  );
12005
12502
  if (renderedGuardIdx >= 0) {
12006
12503
  existing.body.body.splice(renderedGuardIdx, 0, refreshStmt);
@@ -12046,7 +12543,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
12046
12543
  MemberExpression(mePath) {
12047
12544
  const resolved = resolvePath(mePath.node, stateRefs);
12048
12545
  if (!resolved?.parts?.length || !resolved.isImportedState) return;
12049
- if (resolved.parts.some((p) => p === "__raw")) return;
12546
+ if (resolved.parts.some((p) => p === "__raw" || p === "GEA_PROXY_RAW")) return;
12050
12547
  const depKey = buildObserveKey(resolved.parts, resolved.storeVar);
12051
12548
  if (!getterDepKeys.has(depKey) && !externalDeps.has(depKey)) {
12052
12549
  externalDeps.set(depKey, { parts: [...resolved.parts], storeVar: resolved.storeVar });
@@ -12057,11 +12554,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
12057
12554
  const depMethodName = getObserveMethodName(dep.parts, dep.storeVar);
12058
12555
  if (!stateProps.has(depKey)) stateProps.set(depKey, dep.parts);
12059
12556
  const delegateBody = t20.blockStatement([
12060
- t20.expressionStatement(
12061
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__refreshList")), [
12062
- t20.stringLiteral(pathKey)
12063
- ])
12064
- )
12557
+ t20.expressionStatement(t20.callExpression(thisGea("GEA_REFRESH_LIST"), [t20.stringLiteral(pathKey)]))
12065
12558
  ]);
12066
12559
  const delegateMethod = t20.classMethod(
12067
12560
  "method",
@@ -12095,7 +12588,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
12095
12588
  const strippedInTemplate = templateMethod && (analysis.conditionalSlots || []).length > 0 ? stripHtmlArrayMapJoinInTemplateMethod(templateMethod, arrayMap) : false;
12096
12589
  if (strippedInSlots || strippedInTemplate) {
12097
12590
  const currentValueExpr = arrayMap.storeVar ? buildMemberChainFromParts(t20.identifier(arrayMap.storeVar), arrayMap.arrayPathParts) : buildMemberChainFromParts(t20.thisExpression(), arrayMap.arrayPathParts);
12098
- const initialArrayName = `__geaInitial_${arrayHandlerMethodName}`;
12591
+ const initialArrayName = `geaInitial_${arrayHandlerMethodName}`;
12099
12592
  initialHtmlArrayRefreshOnMount.push(
12100
12593
  t20.variableDeclaration("const", [
12101
12594
  t20.variableDeclarator(t20.identifier(initialArrayName), currentValueExpr)
@@ -12203,17 +12696,17 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
12203
12696
  }
12204
12697
  }
12205
12698
  if (renderEventHandlers.length > 0) {
12206
- applied = appendCompiledEventMethods(classPath.node.body, renderEventHandlers) || applied;
12699
+ applied = appendCompiledEventMethods(classPath.node.body, renderEventHandlers, [], ast) || applied;
12207
12700
  }
12208
12701
  if (unresolvedEventHandlers.length > 0) {
12209
- applied = appendCompiledEventMethods(classPath.node.body, unresolvedEventHandlers) || applied;
12702
+ applied = appendCompiledEventMethods(classPath.node.body, unresolvedEventHandlers, [], ast) || applied;
12210
12703
  }
12211
12704
  if (applied) {
12212
12705
  const importedStores = /* @__PURE__ */ new Map();
12213
12706
  const localObserveHandlers = /* @__PURE__ */ new Map();
12214
12707
  const ensureStoreGroup = (storeVar) => {
12215
12708
  if (!importedStores.has(storeVar)) {
12216
- const captureExpression = t20.memberExpression(t20.identifier(storeVar), t20.identifier("__store"));
12709
+ const captureExpression = buildExprGeaMember(t20.identifier(storeVar), "GEA_STORE_ROOT");
12217
12710
  importedStores.set(storeVar, {
12218
12711
  captureExpression,
12219
12712
  observeHandlers: /* @__PURE__ */ new Map()
@@ -12350,6 +12843,31 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
12350
12843
  }
12351
12844
  }
12352
12845
  } else if (parts.length === 1) {
12846
+ const selfKey = buildObserveKey(parts, sv);
12847
+ if (guardStateKeys.has(selfKey) && t20.isBlockStatement(method.body)) {
12848
+ const storePropExpr = t20.memberExpression(t20.identifier(sv), t20.identifier(parts[0]));
12849
+ const observePrevMem = t20.memberExpression(
12850
+ t20.thisExpression(),
12851
+ t20.callExpression(t20.identifier("geaObservePrevSymbol"), [
12852
+ t20.stringLiteral(getObserveMethodName(parts, sv))
12853
+ ]),
12854
+ true
12855
+ );
12856
+ const guardBlock = t20.ifStatement(
12857
+ t20.binaryExpression("==", t20.cloneNode(storePropExpr), t20.nullLiteral()),
12858
+ t20.blockStatement([
12859
+ t20.expressionStatement(t20.assignmentExpression("=", observePrevMem, t20.cloneNode(storePropExpr))),
12860
+ t20.ifStatement(
12861
+ thisGea("GEA_RENDERED"),
12862
+ t20.blockStatement([
12863
+ t20.expressionStatement(t20.callExpression(thisGea("GEA_REQUEST_RENDER"), []))
12864
+ ])
12865
+ ),
12866
+ t20.returnStatement()
12867
+ ])
12868
+ );
12869
+ method.body.body.unshift(guardBlock);
12870
+ }
12353
12871
  const storeRef = stateRefs.get(sv);
12354
12872
  if (storeRef?.getterDeps) {
12355
12873
  for (const [getterName, depPaths] of storeRef.getterDeps) {
@@ -12386,7 +12904,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
12386
12904
  const bodyGroups = /* @__PURE__ */ new Map();
12387
12905
  for (const entry of methodEntries) {
12388
12906
  const { storeVar } = parseObserveKey(entry.observeKey);
12389
- const bodyCode = (storeVar || "") + ":" + generate2(t20.blockStatement(entry.method.body.body)).code;
12907
+ const bodyCode = (storeVar || "") + ":" + generate3(t20.blockStatement(entry.method.body.body)).code;
12390
12908
  if (!bodyGroups.has(bodyCode)) bodyGroups.set(bodyCode, []);
12391
12909
  bodyGroups.get(bodyCode).push(entry);
12392
12910
  }
@@ -12633,7 +13151,7 @@ function generateUnresolvedRelationalObserver(arrayMap, unresolvedMap, relBindin
12633
13151
  )
12634
13152
  ]);
12635
13153
  const commonPreamble = [
12636
- js6`if (!this.rendered_) return;`,
13154
+ t20.ifStatement(t20.unaryExpression("!", thisGea("GEA_RENDERED")), t20.blockStatement([t20.returnStatement()])),
12637
13155
  lazyInit2(containerName, containerLookup),
12638
13156
  ...jsBlockBody4`if (!${containerRef}) return;`,
12639
13157
  ...setupStatements,
@@ -12753,15 +13271,11 @@ function generateMapRegistration(arrayMap, unresolvedMap, templatePropNames, who
12753
13271
  }
12754
13272
  });
12755
13273
  const keyFnParams = idxVar ? [t20.identifier("__k"), t20.identifier("__ki")] : [t20.identifier("__k")];
12756
- registerArgs.push(
12757
- t20.arrowFunctionExpression(keyFnParams, t20.callExpression(t20.identifier("String"), [keyExpr]))
12758
- );
13274
+ registerArgs.push(t20.arrowFunctionExpression(keyFnParams, t20.callExpression(t20.identifier("String"), [keyExpr])));
12759
13275
  } else if (arrayMap.itemIdProperty && arrayMap.itemIdProperty !== ITEM_IS_KEY) {
12760
13276
  registerArgs.push(t20.stringLiteral(arrayMap.itemIdProperty));
12761
13277
  }
12762
- return t20.expressionStatement(
12763
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__geaRegisterMap")), registerArgs)
12764
- );
13278
+ return t20.expressionStatement(t20.callExpression(thisGea("GEA_REGISTER_MAP"), registerArgs));
12765
13279
  }
12766
13280
  function collectFreeIdentifiers(nodes) {
12767
13281
  const names = /* @__PURE__ */ new Set();
@@ -12856,7 +13370,10 @@ function replaceMapWithComponentArrayItems(templateMethod, arrayExpr, itemsName,
12856
13370
  toReplace = path.parentPath.parentPath;
12857
13371
  }
12858
13372
  const replacement = opts?.slotBranch ? t20.stringLiteral("") : t20.callExpression(
12859
- t20.memberExpression(t20.memberExpression(t20.thisExpression(), t20.identifier(itemsName)), t20.identifier("join")),
13373
+ t20.memberExpression(
13374
+ t20.memberExpression(t20.thisExpression(), t20.identifier(itemsName), true),
13375
+ t20.identifier("join")
13376
+ ),
12860
13377
  [t20.stringLiteral("")]
12861
13378
  );
12862
13379
  toReplace.replaceWith(replacement);
@@ -12885,6 +13402,7 @@ function replaceMapWithComponentArrayItemsInConditionalSlots(slots, arrayExpr, i
12885
13402
  }
12886
13403
  }
12887
13404
  }
13405
+ var ctorInlineInsertOffset = /* @__PURE__ */ new WeakMap();
12888
13406
  function inlineIntoConstructor(classBody2, statements) {
12889
13407
  let ctor = classBody2.body.find(
12890
13408
  (member) => t20.isClassMethod(member) && t20.isIdentifier(member.key) && member.key.name === "constructor"
@@ -12896,13 +13414,42 @@ function inlineIntoConstructor(classBody2, statements) {
12896
13414
  ...statements
12897
13415
  );
12898
13416
  classBody2.body.unshift(ctor);
13417
+ ctorInlineInsertOffset.set(ctor, statements.length);
12899
13418
  return;
12900
13419
  }
12901
- ctor.body.body.push(...statements);
13420
+ const body = ctor.body.body;
13421
+ const superIdx = body.findIndex(
13422
+ (stmt) => t20.isExpressionStatement(stmt) && t20.isCallExpression(stmt.expression) && t20.isSuper(stmt.expression.callee)
13423
+ );
13424
+ const base = superIdx >= 0 ? superIdx + 1 : 0;
13425
+ const prev = ctorInlineInsertOffset.get(ctor) ?? 0;
13426
+ const insertAt = base + prev;
13427
+ body.splice(insertAt, 0, ...statements);
13428
+ ctorInlineInsertOffset.set(ctor, prev + statements.length);
12902
13429
  }
12903
13430
  function ensureDisposeCalls(classBody2, targets) {
12904
13431
  const disposeStatements = targets.map(
12905
- (target) => js6`this.${id11(target)}?.forEach?.(item => item?.dispose?.());`
13432
+ (target) => t20.expressionStatement(
13433
+ t20.optionalCallExpression(
13434
+ t20.optionalMemberExpression(
13435
+ t20.memberExpression(t20.thisExpression(), t20.identifier(target), true),
13436
+ t20.identifier("forEach"),
13437
+ false,
13438
+ true
13439
+ ),
13440
+ [
13441
+ t20.arrowFunctionExpression(
13442
+ [t20.identifier("item")],
13443
+ t20.optionalCallExpression(
13444
+ t20.optionalMemberExpression(t20.identifier("item"), t20.identifier("dispose"), false, true),
13445
+ [],
13446
+ true
13447
+ )
13448
+ )
13449
+ ],
13450
+ true
13451
+ )
13452
+ )
12906
13453
  );
12907
13454
  const existingDispose = classBody2.body.find(
12908
13455
  (member) => t20.isClassMethod(member) && t20.isIdentifier(member.key) && member.key.name === "dispose"
@@ -12916,9 +13463,10 @@ function ensureDisposeCalls(classBody2, targets) {
12916
13463
  );
12917
13464
  }
12918
13465
  function ensureOnPropChangeMethod(classBody2, inlinePatchBodies, compiledChildren, arrayRefreshDeps, conditionalSlots = [], unresolvedMapPropRefreshDeps = []) {
12919
- const existing = classBody2.body.find(
12920
- (member) => t20.isClassMethod(member) && t20.isIdentifier(member.key) && member.key.name === "__onPropChange"
12921
- );
13466
+ const existing = classBody2.body.find((member) => {
13467
+ if (!t20.isClassMethod(member) || !t20.isIdentifier(member.key)) return false;
13468
+ return member.computed && member.key.name === "GEA_ON_PROP_CHANGE";
13469
+ });
12922
13470
  if (existing) return;
12923
13471
  const directForwardCalls = [];
12924
13472
  const nonDirectChildren = [];
@@ -12936,9 +13484,9 @@ function ensureOnPropChangeMethod(classBody2, inlinePatchBodies, compiledChildre
12936
13484
  guard,
12937
13485
  t20.expressionStatement(
12938
13486
  t20.callExpression(
12939
- t20.memberExpression(
13487
+ buildExprGeaMember(
12940
13488
  t20.memberExpression(t20.thisExpression(), t20.identifier(child.instanceVar)),
12941
- t20.identifier("__geaUpdateProps")
13489
+ "GEA_UPDATE_PROPS"
12942
13490
  ),
12943
13491
  [t20.objectExpression([t20.objectProperty(t20.identifier("key"), t20.identifier("value"), true)])]
12944
13492
  )
@@ -12952,9 +13500,9 @@ function ensureOnPropChangeMethod(classBody2, inlinePatchBodies, compiledChildre
12952
13500
  t20.binaryExpression("===", t20.identifier("key"), t20.stringLiteral(m.parentPropName)),
12953
13501
  t20.expressionStatement(
12954
13502
  t20.callExpression(
12955
- t20.memberExpression(
13503
+ buildExprGeaMember(
12956
13504
  t20.memberExpression(t20.thisExpression(), t20.identifier(child.instanceVar)),
12957
- t20.identifier("__geaUpdateProps")
13505
+ "GEA_UPDATE_PROPS"
12958
13506
  ),
12959
13507
  [t20.objectExpression([t20.objectProperty(t20.identifier(m.childPropName), t20.identifier("value"))])]
12960
13508
  )
@@ -12986,10 +13534,7 @@ function ensureOnPropChangeMethod(classBody2, inlinePatchBodies, compiledChildre
12986
13534
  const childRefreshCalls = childRefreshEntries.map(({ child, depProps }) => {
12987
13535
  const call = t20.expressionStatement(
12988
13536
  t20.callExpression(
12989
- t20.memberExpression(
12990
- t20.memberExpression(t20.thisExpression(), t20.identifier(child.instanceVar)),
12991
- t20.identifier("__geaUpdateProps")
12992
- ),
13537
+ buildExprGeaMember(t20.memberExpression(t20.thisExpression(), t20.identifier(child.instanceVar)), "GEA_UPDATE_PROPS"),
12993
13538
  [
12994
13539
  t20.callExpression(
12995
13540
  t20.memberExpression(t20.thisExpression(), t20.identifier(`__buildProps_${child.instanceVar.replace(/^_/, "")}`)),
@@ -13024,9 +13569,7 @@ function ensureOnPropChangeMethod(classBody2, inlinePatchBodies, compiledChildre
13024
13569
  if (conditionalSlots.length > 0) {
13025
13570
  for (let i = 0; i < conditionalSlots.length; i++) {
13026
13571
  const slot = conditionalSlots[i];
13027
- const call = t20.expressionStatement(
13028
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__geaPatchCond")), [t20.numericLiteral(i)])
13029
- );
13572
+ const call = t20.expressionStatement(t20.callExpression(thisGea("GEA_PATCH_COND"), [t20.numericLiteral(i)]));
13030
13573
  if (slot.dependentPropNames.length > 0) {
13031
13574
  const guard = slot.dependentPropNames.reduce((acc, prop) => {
13032
13575
  const test = t20.binaryExpression("===", t20.identifier("key"), t20.stringLiteral(prop));
@@ -13045,11 +13588,7 @@ function ensureOnPropChangeMethod(classBody2, inlinePatchBodies, compiledChildre
13045
13588
  )
13046
13589
  );
13047
13590
  const unresolvedMapRefreshCalls = unresolvedMapPropRefreshDeps.map((dep) => {
13048
- const call = t20.expressionStatement(
13049
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__geaSyncMap")), [
13050
- t20.numericLiteral(dep.mapIdx)
13051
- ])
13052
- );
13591
+ const call = t20.expressionStatement(t20.callExpression(thisGea("GEA_SYNC_MAP"), [t20.numericLiteral(dep.mapIdx)]));
13053
13592
  if (dep.propNames.length > 0) {
13054
13593
  const guard = dep.propNames.reduce((acc, prop) => {
13055
13594
  const test = t20.binaryExpression("===", t20.identifier("key"), t20.stringLiteral(prop));
@@ -13068,7 +13607,18 @@ function ensureOnPropChangeMethod(classBody2, inlinePatchBodies, compiledChildre
13068
13607
  ];
13069
13608
  if (allKeyGuarded.length === 0) return;
13070
13609
  const merged = mergeKeyGuards(allKeyGuarded);
13071
- classBody2.body.push(appendToBody5(jsMethod8`${id11("__onPropChange")}(key, value) {}`, ...merged));
13610
+ classBody2.body.push(
13611
+ appendToBody5(
13612
+ t20.classMethod(
13613
+ "method",
13614
+ t20.identifier("GEA_ON_PROP_CHANGE"),
13615
+ [t20.identifier("key"), t20.identifier("value")],
13616
+ t20.blockStatement([]),
13617
+ true
13618
+ ),
13619
+ ...merged
13620
+ )
13621
+ );
13072
13622
  }
13073
13623
  function serializeKeyGuard(test) {
13074
13624
  if (t20.isBinaryExpression(test) && test.operator === "===" && t20.isIdentifier(test.left, { name: "key" }) && t20.isStringLiteral(test.right)) {
@@ -13229,7 +13779,11 @@ function generateConditionalPatchMethods(classBody2, slots, templatePropNames, w
13229
13779
  t20.expressionStatement(
13230
13780
  t20.assignmentExpression(
13231
13781
  "=",
13232
- t20.memberExpression(t20.thisExpression(), t20.identifier(`__geaCond_${i}`)),
13782
+ t20.memberExpression(
13783
+ t20.thisExpression(),
13784
+ t20.callExpression(t20.identifier("geaCondValueSymbol"), [t20.numericLiteral(i)]),
13785
+ true
13786
+ ),
13233
13787
  t20.unaryExpression("!", t20.unaryExpression("!", rewrittenCondExprsSafe[i]))
13234
13788
  )
13235
13789
  )
@@ -13267,7 +13821,7 @@ function generateConditionalPatchMethods(classBody2, slots, templatePropNames, w
13267
13821
  };
13268
13822
  registerCondCalls.push(
13269
13823
  t20.expressionStatement(
13270
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__geaRegisterCond")), [
13824
+ t20.callExpression(thisGea("GEA_REGISTER_COND"), [
13271
13825
  t20.numericLiteral(i),
13272
13826
  t20.stringLiteral(slot.slotId),
13273
13827
  t20.arrowFunctionExpression([], t20.blockStatement(getCondBody)),
@@ -13455,6 +14009,8 @@ function addJoinToUnresolvedMapCalls(templateMethod, _unresolvedMaps) {
13455
14009
  const alreadyHasJoin = path.parentPath?.isMemberExpression() && t20.isIdentifier(path.parentPath.node.property) && path.parentPath.node.property.name === "join" && path.parentPath.parentPath?.isCallExpression();
13456
14010
  if (alreadyHasJoin) {
13457
14011
  const joinCall = path.parentPath.parentPath;
14012
+ const joinArg = joinCall.node.arguments[0];
14013
+ if (t20.isStringLiteral(joinArg) && joinArg.value !== "") return;
13458
14014
  const replacement = t20.binaryExpression("+", t20.cloneNode(joinCall.node, true), t20.stringLiteral("<!---->"));
13459
14015
  joinCall.replaceWith(replacement);
13460
14016
  joinCall.skip();
@@ -13585,76 +14141,85 @@ function replaceMapInConditionalSlots(slots, arrayMap) {
13585
14141
  }
13586
14142
  function generateStoreInlinePatchObserver(pathParts, storeVar, patchStatements) {
13587
14143
  const method = jsMethod8`${id11(getObserveMethodName(pathParts, storeVar))}(value, change) {}`;
13588
- method.body.body.push(
13589
- t20.ifStatement(t20.memberExpression(t20.thisExpression(), t20.identifier("rendered_")), t20.blockStatement(patchStatements))
13590
- );
14144
+ method.body.body.push(t20.ifStatement(thisGea("GEA_RENDERED"), t20.blockStatement(patchStatements)));
13591
14145
  return method;
13592
14146
  }
13593
14147
  function generateRerenderObserver(pathParts, storeVar, truthinessOnly) {
13594
14148
  const method = jsMethod8`${id11(getObserveMethodName(pathParts, storeVar))}(value, change) {}`;
13595
14149
  if (storeVar) {
13596
- const prevProp = `__geaPrev_${getObserveMethodName(pathParts, storeVar)}`;
14150
+ const observePrevMem = t20.memberExpression(
14151
+ t20.thisExpression(),
14152
+ t20.callExpression(t20.identifier("geaObservePrevSymbol"), [
14153
+ t20.stringLiteral(getObserveMethodName(pathParts, storeVar))
14154
+ ]),
14155
+ true
14156
+ );
13597
14157
  if (truthinessOnly) {
13598
14158
  method.body.body.push(
13599
- ...jsBlockBody4`
13600
- if (!value === !this.${id11(prevProp)}) return;
13601
- this.${id11(prevProp)} = value;
13602
- `
14159
+ t20.ifStatement(
14160
+ t20.logicalExpression(
14161
+ "&&",
14162
+ t20.binaryExpression("!==", observePrevMem, t20.identifier("undefined")),
14163
+ t20.binaryExpression(
14164
+ "===",
14165
+ t20.unaryExpression("!", t20.identifier("value")),
14166
+ t20.unaryExpression("!", observePrevMem)
14167
+ )
14168
+ ),
14169
+ t20.returnStatement()
14170
+ ),
14171
+ t20.expressionStatement(t20.assignmentExpression("=", observePrevMem, t20.identifier("value")))
13603
14172
  );
13604
14173
  } else {
13605
14174
  method.body.body.push(
13606
- ...jsBlockBody4`
13607
- if (value === this.${id11(prevProp)}) return;
13608
- this.${id11(prevProp)} = value;
13609
- `
14175
+ t20.ifStatement(t20.binaryExpression("===", t20.identifier("value"), observePrevMem), t20.returnStatement()),
14176
+ t20.expressionStatement(t20.assignmentExpression("=", observePrevMem, t20.identifier("value")))
13610
14177
  );
13611
14178
  }
13612
14179
  }
13613
14180
  method.body.body.push(
13614
14181
  t20.ifStatement(
13615
- t20.memberExpression(t20.thisExpression(), t20.identifier("rendered_")),
13616
- t20.blockStatement([
13617
- t20.expressionStatement(
13618
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__geaRequestRender")), [])
13619
- )
13620
- ])
14182
+ thisGea("GEA_RENDERED"),
14183
+ t20.blockStatement([t20.expressionStatement(t20.callExpression(thisGea("GEA_REQUEST_RENDER"), []))])
13621
14184
  )
13622
14185
  );
13623
14186
  return method;
13624
14187
  }
13625
14188
  function generateConditionalSlotObserveMethod(pathParts, storeVar, slotIndices, emitEarlyReturn = true) {
13626
14189
  const method = jsMethod8`${id11(getObserveMethodName(pathParts, storeVar))}(value, change) {}`;
13627
- const anyPatchedExpr = slotIndices.map((i) => t20.memberExpression(t20.thisExpression(), t20.identifier(`__geaCondPatched_${i}`))).reduce((acc, expr) => t20.logicalExpression("||", acc, expr));
14190
+ const anyPatchedExpr = slotIndices.map(
14191
+ (i) => t20.memberExpression(
14192
+ t20.thisExpression(),
14193
+ t20.callExpression(t20.identifier("geaCondPatchedSymbol"), [t20.numericLiteral(i)]),
14194
+ true
14195
+ )
14196
+ ).reduce((acc, expr) => t20.logicalExpression("||", acc, expr));
13628
14197
  const patchStatements = [];
13629
14198
  if (slotIndices.length === 1) {
13630
14199
  patchStatements.push(t20.ifStatement(anyPatchedExpr, t20.returnStatement()));
13631
14200
  }
13632
14201
  slotIndices.forEach((slotIndex) => {
14202
+ const patchedMem = t20.memberExpression(
14203
+ t20.thisExpression(),
14204
+ t20.callExpression(t20.identifier("geaCondPatchedSymbol"), [t20.numericLiteral(slotIndex)]),
14205
+ true
14206
+ );
13633
14207
  patchStatements.push(
13634
14208
  t20.expressionStatement(
13635
14209
  t20.assignmentExpression(
13636
14210
  "=",
13637
- t20.memberExpression(t20.thisExpression(), t20.identifier(`__geaCondPatched_${slotIndex}`)),
13638
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__geaPatchCond")), [
13639
- t20.numericLiteral(slotIndex)
13640
- ])
14211
+ patchedMem,
14212
+ t20.callExpression(thisGea("GEA_PATCH_COND"), [t20.numericLiteral(slotIndex)])
13641
14213
  )
13642
14214
  )
13643
14215
  );
13644
14216
  patchStatements.push(
13645
14217
  t20.ifStatement(
13646
- t20.memberExpression(t20.thisExpression(), t20.identifier(`__geaCondPatched_${slotIndex}`)),
14218
+ patchedMem,
13647
14219
  t20.blockStatement([
13648
14220
  t20.expressionStatement(
13649
14221
  t20.callExpression(t20.identifier("queueMicrotask"), [
13650
- t20.arrowFunctionExpression(
13651
- [],
13652
- t20.assignmentExpression(
13653
- "=",
13654
- t20.memberExpression(t20.thisExpression(), t20.identifier(`__geaCondPatched_${slotIndex}`)),
13655
- t20.booleanLiteral(false)
13656
- )
13657
- )
14222
+ t20.arrowFunctionExpression([], t20.assignmentExpression("=", patchedMem, t20.booleanLiteral(false)))
13658
14223
  ])
13659
14224
  )
13660
14225
  ])
@@ -13664,28 +14229,22 @@ function generateConditionalSlotObserveMethod(pathParts, storeVar, slotIndices,
13664
14229
  if (emitEarlyReturn) {
13665
14230
  patchStatements.push(t20.ifStatement(anyPatchedExpr, t20.returnStatement()));
13666
14231
  }
13667
- method.body.body.push(
13668
- t20.ifStatement(t20.memberExpression(t20.thisExpression(), t20.identifier("rendered_")), t20.blockStatement(patchStatements))
13669
- );
14232
+ method.body.body.push(t20.ifStatement(thisGea("GEA_RENDERED"), t20.blockStatement(patchStatements)));
13670
14233
  return method;
13671
14234
  }
13672
14235
  function generateStateChildSwapObserver(pathParts, storeVar) {
13673
14236
  const method = jsMethod8`${id11(getObserveMethodName(pathParts, storeVar))}(value, change) {}`;
13674
14237
  method.body.body.push(
13675
14238
  t20.ifStatement(
13676
- t20.memberExpression(t20.thisExpression(), t20.identifier("rendered_")),
13677
- t20.blockStatement([
13678
- t20.expressionStatement(
13679
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__geaSwapStateChildren")), [])
13680
- )
13681
- ])
14239
+ thisGea("GEA_RENDERED"),
14240
+ t20.blockStatement([t20.expressionStatement(t20.callExpression(thisGea("GEA_SWAP_STATE_CHILDREN"), []))])
13682
14241
  )
13683
14242
  );
13684
14243
  return method;
13685
14244
  }
13686
14245
  function generateStateChildSwapMethod(classBody2, stateChildSlots) {
13687
14246
  const existing = classBody2.body.find(
13688
- (member) => t20.isClassMethod(member) && t20.isIdentifier(member.key) && member.key.name === "__geaSwapStateChildren"
14247
+ (member) => t20.isClassMethod(member) && member.computed && t20.isIdentifier(member.key) && member.key.name === "GEA_SWAP_STATE_CHILDREN"
13689
14248
  );
13690
14249
  if (existing) return;
13691
14250
  const templateMethod = classBody2.body.find(
@@ -13708,9 +14267,9 @@ function generateStateChildSwapMethod(classBody2, stateChildSlots) {
13708
14267
  if (!hasBuildProps) return null;
13709
14268
  return t20.expressionStatement(
13710
14269
  t20.callExpression(
13711
- t20.memberExpression(
14270
+ buildExprGeaMember(
13712
14271
  t20.memberExpression(t20.thisExpression(), t20.identifier(slot.childInstanceVar)),
13713
- t20.identifier("__geaUpdateProps")
14272
+ "GEA_UPDATE_PROPS"
13714
14273
  ),
13715
14274
  [t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier(buildPropsName)), [])]
13716
14275
  )
@@ -13719,7 +14278,7 @@ function generateStateChildSwapMethod(classBody2, stateChildSlots) {
13719
14278
  const swapCalls = stateChildSlots.map((slot) => {
13720
14279
  const guardClone = t20.cloneNode(slot.guardExpr, true);
13721
14280
  return t20.expressionStatement(
13722
- t20.callExpression(t20.memberExpression(t20.thisExpression(), t20.identifier("__geaSwapChild")), [
14281
+ t20.callExpression(thisGea("GEA_SWAP_CHILD"), [
13723
14282
  t20.stringLiteral(slot.markerId),
13724
14283
  t20.logicalExpression(
13725
14284
  "&&",
@@ -13732,9 +14291,10 @@ function generateStateChildSwapMethod(classBody2, stateChildSlots) {
13732
14291
  const filteredSetup = pruneUnusedSetupDestructuring(setupStatements, [...propsUpdateCalls, ...swapCalls]);
13733
14292
  const method = t20.classMethod(
13734
14293
  "method",
13735
- t20.identifier("__geaSwapStateChildren"),
14294
+ t20.identifier("GEA_SWAP_STATE_CHILDREN"),
13736
14295
  [],
13737
- t20.blockStatement([...filteredSetup, ...propsUpdateCalls, ...swapCalls])
14296
+ t20.blockStatement([...filteredSetup, ...propsUpdateCalls, ...swapCalls]),
14297
+ true
13738
14298
  );
13739
14299
  classBody2.body.push(method);
13740
14300
  }
@@ -13766,9 +14326,6 @@ function resolveImportPath2(importer, source) {
13766
14326
  }
13767
14327
  var getterDepsCache = /* @__PURE__ */ new Map();
13768
14328
  var storeFieldsCache = /* @__PURE__ */ new Map();
13769
- function isPrivateName(name) {
13770
- return name.charCodeAt(0) === 95 || name.charCodeAt(name.length - 1) === 95;
13771
- }
13772
14329
  function extractGetterStatePaths(method) {
13773
14330
  if (!t21.isBlockStatement(method.body)) return null;
13774
14331
  const paths = /* @__PURE__ */ new Map();
@@ -13781,7 +14338,6 @@ function extractGetterStatePaths(method) {
13781
14338
  return;
13782
14339
  }
13783
14340
  const propName = node.property.name;
13784
- if (isPrivateName(propName)) return;
13785
14341
  if (!paths.has(propName)) {
13786
14342
  paths.set(propName, [propName]);
13787
14343
  }
@@ -13791,7 +14347,6 @@ function extractGetterStatePaths(method) {
13791
14347
  for (const prop of path.node.id.properties) {
13792
14348
  if (!t21.isObjectProperty(prop) || !t21.isIdentifier(prop.key)) continue;
13793
14349
  const propName = prop.key.name;
13794
- if (isPrivateName(propName)) continue;
13795
14350
  if (!paths.has(propName)) {
13796
14351
  paths.set(propName, [propName]);
13797
14352
  }
@@ -14071,7 +14626,7 @@ function transformComponentFile(ast, imports, storeImports, className, sourceFil
14071
14626
  (p) => t22.isClassDeclaration(p.node)
14072
14627
  );
14073
14628
  if (earlyClassPath) {
14074
- transformed = appendCompiledEventMethods(earlyClassPath.node.body, earlyReturnCtx.eventHandlers, []) || transformed;
14629
+ transformed = appendCompiledEventMethods(earlyClassPath.node.body, earlyReturnCtx.eventHandlers, [], ast) || transformed;
14075
14630
  }
14076
14631
  }
14077
14632
  for (const info of conditionalSlotInfos) {
@@ -14102,6 +14657,7 @@ function transformComponentFile(ast, imports, storeImports, className, sourceFil
14102
14657
  cloneCtxForPatches
14103
14658
  );
14104
14659
  if (cloneMembers) {
14660
+ ensureImport(ast, "@geajs/core", "GEA_CLONE_TEMPLATE");
14105
14661
  classPath.node.body.body.push(...cloneMembers);
14106
14662
  transformed = true;
14107
14663
  }
@@ -14110,17 +14666,18 @@ function transformComponentFile(ast, imports, storeImports, className, sourceFil
14110
14666
  const classPath2 = path.findParent((p) => t22.isClassDeclaration(p.node));
14111
14667
  if (classPath2) {
14112
14668
  const setupStatements = returnIndex >= 0 ? body.slice(0, returnIndex) : [];
14113
- transformed = appendCompiledEventMethods(classPath2.node.body, eventHandlers, setupStatements) || transformed;
14669
+ transformed = appendCompiledEventMethods(classPath2.node.body, eventHandlers, setupStatements, ast) || transformed;
14114
14670
  }
14115
14671
  }
14116
14672
  if (refBindings.length > 0) {
14117
14673
  const classPath2 = path.findParent((p) => t22.isClassDeclaration(p.node));
14118
14674
  if (classPath2) {
14675
+ ensureImport(ast, "@geajs/core", "GEA_ELEMENT");
14119
14676
  const refStatements = refBindings.flatMap((ref) => {
14120
14677
  const target = ref.targetExpr;
14121
14678
  const q = t22.callExpression(
14122
14679
  t22.memberExpression(
14123
- t22.memberExpression(t22.thisExpression(), t22.identifier("element_")),
14680
+ t22.memberExpression(t22.thisExpression(), t22.identifier("GEA_ELEMENT"), true),
14124
14681
  t22.identifier("querySelector")
14125
14682
  ),
14126
14683
  [t22.stringLiteral(`[data-gea-ref="${ref.refId}"]`)]
@@ -14130,14 +14687,16 @@ function transformComponentFile(ast, imports, storeImports, className, sourceFil
14130
14687
  t22.expressionStatement(t22.assignmentExpression("=", target, q))
14131
14688
  ];
14132
14689
  });
14133
- const existingSetup = classPath2.node.body.body.find(
14134
- (m) => t22.isClassMethod(m) && t22.isIdentifier(m.key) && m.key.name === "__setupRefs"
14135
- );
14690
+ ensureImport(ast, "@geajs/core", "GEA_SETUP_REFS");
14691
+ const existingSetup = classPath2.node.body.body.find((m) => {
14692
+ if (!t22.isClassMethod(m) || !t22.isIdentifier(m.key)) return false;
14693
+ return m.computed && m.key.name === "GEA_SETUP_REFS";
14694
+ });
14136
14695
  if (existingSetup && t22.isClassMethod(existingSetup)) {
14137
14696
  existingSetup.body.body.push(...refStatements);
14138
14697
  } else {
14139
14698
  classPath2.node.body.body.push(
14140
- t22.classMethod("method", t22.identifier("__setupRefs"), [], t22.blockStatement(refStatements))
14699
+ t22.classMethod("method", t22.identifier("GEA_SETUP_REFS"), [], t22.blockStatement(refStatements), true)
14141
14700
  );
14142
14701
  }
14143
14702
  transformed = true;
@@ -14251,14 +14810,15 @@ function transformComponentFile(ast, imports, storeImports, className, sourceFil
14251
14810
  if (!t22.isClassMethod(member) || member.kind === "constructor") continue;
14252
14811
  const name = t22.isIdentifier(member.key) ? member.key.name : null;
14253
14812
  if (!name) continue;
14254
- const isCompilerGenerated = name === "template" || name === "events" && member.kind === "get" || name.startsWith("__");
14813
+ const isCompilerGenerated = name === "template" || name === "events" && member.kind === "get" || name.startsWith("__") || member.computed && name === "GEA_ON_PROP_CHANGE";
14255
14814
  if (isCompilerGenerated) {
14256
14815
  cacheThisIdInMethod(member);
14257
14816
  }
14258
14817
  if (name === "events" && member.kind === "get") {
14818
+ ensureImport(ast, "@geajs/core", "GEA_ELEMENT");
14259
14819
  wrapEventsGetterWithCache(member);
14260
14820
  }
14261
- if (name === "__onPropChange") {
14821
+ if (member.computed && name === "GEA_ON_PROP_CHANGE") {
14262
14822
  wrapSubpathCacheGuards(member, subpathPcCounter, path.node.body);
14263
14823
  }
14264
14824
  }
@@ -14266,6 +14826,9 @@ function transformComponentFile(ast, imports, storeImports, className, sourceFil
14266
14826
  }
14267
14827
  });
14268
14828
  }
14829
+ if (transformed) {
14830
+ ensureGeaCompilerSymbolImports(ast);
14831
+ }
14269
14832
  return transformed;
14270
14833
  }
14271
14834
  function transformNonComponentJSX(ast, imports) {
@@ -14393,8 +14956,8 @@ function transformRemainingJSX(ast, imports) {
14393
14956
  traverse14(ast, {
14394
14957
  noScope: true,
14395
14958
  JSXElement(path) {
14396
- const classMethod9 = path.findParent((p) => t22.isClassMethod(p.node));
14397
- if (classMethod9 && t22.isClassMethod(classMethod9.node) && t22.isIdentifier(classMethod9.node.key) && classMethod9.node.key.name === "template")
14959
+ const classMethod10 = path.findParent((p) => t22.isClassMethod(p.node));
14960
+ if (classMethod10 && t22.isClassMethod(classMethod10.node) && t22.isIdentifier(classMethod10.node.key) && classMethod10.node.key.name === "template")
14398
14961
  return;
14399
14962
  try {
14400
14963
  path.replaceWith(transformJSXToTemplate(path.node, { imports }));
@@ -14403,8 +14966,8 @@ function transformRemainingJSX(ast, imports) {
14403
14966
  }
14404
14967
  },
14405
14968
  JSXFragment(path) {
14406
- const classMethod9 = path.findParent((p) => t22.isClassMethod(p.node));
14407
- if (classMethod9 && t22.isClassMethod(classMethod9.node) && t22.isIdentifier(classMethod9.node.key) && classMethod9.node.key.name === "template")
14969
+ const classMethod10 = path.findParent((p) => t22.isClassMethod(p.node));
14970
+ if (classMethod10 && t22.isClassMethod(classMethod10.node) && t22.isIdentifier(classMethod10.node.key) && classMethod10.node.key.name === "template")
14408
14971
  return;
14409
14972
  try {
14410
14973
  path.replaceWith(transformJSXFragmentToTemplate(path.node, { imports }));
@@ -14526,7 +15089,7 @@ function resolveDefault(mod) {
14526
15089
  throw new Error("resolveDefault: expected a function or module with default export");
14527
15090
  }
14528
15091
  var traverse16 = resolveDefault(babelTraverse2);
14529
- var generate3 = resolveDefault(babelGenerator2);
15092
+ var generate4 = resolveDefault(babelGenerator3);
14530
15093
  function hasSSREnvironment(ctx) {
14531
15094
  if (!("environment" in ctx)) return false;
14532
15095
  const env = ctx.environment;
@@ -14539,8 +15102,9 @@ var RESOLVED_HMR_RUNTIME_ID = "\0" + HMR_RUNTIME_ID;
14539
15102
  var STORE_REGISTRY_ID = "virtual:gea-store-registry";
14540
15103
  var RESOLVED_STORE_REGISTRY_ID = "\0" + STORE_REGISTRY_ID;
14541
15104
  var RECONCILE_SOURCE = `
15105
+ import { GEA_DOM_ITEM } from '@geajs/core';
14542
15106
  function getKey(el) {
14543
- if (el.__geaItem) return String(el.__geaItem.id);
15107
+ if (el[GEA_DOM_ITEM]) return String(el[GEA_DOM_ITEM].id);
14544
15108
  return el.getAttribute('key');
14545
15109
  }
14546
15110
  export function reconcile(oldC, newC) {
@@ -14678,41 +15242,42 @@ export function unregisterComponentInstance(className, instance) {
14678
15242
  }
14679
15243
 
14680
15244
  function reRenderComponent(instance) {
14681
- if (!instance || !instance.element_) return;
14682
- var parent = instance.element_.parentElement;
15245
+ if (!instance || !instance[GEA_ELEMENT]) return;
15246
+ var parent = instance[GEA_ELEMENT].parentElement;
14683
15247
  if (!parent) return;
14684
- var index = Array.prototype.indexOf.call(parent.children, instance.element_);
15248
+ var index = Array.prototype.indexOf.call(parent.children, instance[GEA_ELEMENT]);
14685
15249
  var props = Object.assign({}, instance.props);
14686
15250
  var __stateSnapshot = {};
14687
15251
  var __ownKeys = Object.getOwnPropertyNames(instance);
14688
15252
  for (var __ki = 0; __ki < __ownKeys.length; __ki++) {
14689
15253
  var __k = __ownKeys[__ki];
14690
- if (__k.charAt(0) === '_' || __k === 'props' || __k === 'element_' || __k === 'rendered_' || __k === 'id') continue;
15254
+ if (__k.charAt(0) === '_' || __k === 'props' || __k === 'id') continue;
14691
15255
  var __desc = Object.getOwnPropertyDescriptor(instance, __k);
14692
15256
  if (__desc && (__desc.get || __desc.set)) continue;
14693
15257
  try { __stateSnapshot[__k] = instance[__k]; } catch(e) {}
14694
15258
  }
14695
- instance.rendered_ = false;
14696
- if (instance.cleanupBindings_) instance.cleanupBindings_();
14697
- if (instance.teardownSelfListeners_) instance.teardownSelfListeners_();
15259
+ instance[GEA_RENDERED] = false;
15260
+ if (typeof instance[GEA_CLEANUP_BINDINGS] === 'function') instance[GEA_CLEANUP_BINDINGS]();
15261
+ if (typeof instance[GEA_TEARDOWN_SELF_LISTENERS] === 'function') instance[GEA_TEARDOWN_SELF_LISTENERS]();
14698
15262
  if (instance.__cleanupCompiledDirectEvents) instance.__cleanupCompiledDirectEvents();
14699
- if (instance.__childComponents && instance.__childComponents.length) {
14700
- instance.__childComponents.forEach(function(child) { if (child && child.dispose) child.dispose(); });
14701
- instance.__childComponents = [];
15263
+ var __cc = instance[GEA_CHILD_COMPONENTS];
15264
+ if (__cc && __cc.length) {
15265
+ __cc.forEach(function(child) { if (child && child.dispose) child.dispose(); });
15266
+ instance[GEA_CHILD_COMPONENTS] = [];
14702
15267
  }
14703
- if (instance.element_ && instance.element_.parentNode) {
14704
- instance.element_.parentNode.removeChild(instance.element_);
15268
+ if (instance[GEA_ELEMENT] && instance[GEA_ELEMENT].parentNode) {
15269
+ instance[GEA_ELEMENT].parentNode.removeChild(instance[GEA_ELEMENT]);
14705
15270
  }
14706
- instance.element_ = null;
15271
+ instance[GEA_ELEMENT] = null;
14707
15272
  instance.props = props;
14708
15273
  var __restoreKeys = Object.getOwnPropertyNames(__stateSnapshot);
14709
15274
  for (var __ri = 0; __ri < __restoreKeys.length; __ri++) {
14710
15275
  try { instance[__restoreKeys[__ri]] = __stateSnapshot[__restoreKeys[__ri]]; } catch(e) {}
14711
15276
  }
14712
- if (!instance.__bindings) instance.__bindings = [];
15277
+ if (!instance[GEA_BINDINGS]) instance[GEA_BINDINGS] = [];
14713
15278
  if (!instance.__bindingRemovers) instance.__bindingRemovers = [];
14714
- if (!instance.__selfListeners) instance.__selfListeners = [];
14715
- if (!instance.__childComponents) instance.__childComponents = [];
15279
+ if (!instance[GEA_SELF_LISTENERS]) instance[GEA_SELF_LISTENERS] = [];
15280
+ if (!instance[GEA_CHILD_COMPONENTS]) instance[GEA_CHILD_COMPONENTS] = [];
14716
15281
  instance.render(parent, index);
14717
15282
  if (typeof instance.createdHooks === 'function') {
14718
15283
  instance.createdHooks(instance.props);
@@ -14762,6 +15327,13 @@ function isComponentImportSource(source) {
14762
15327
  if (source.startsWith("node:")) return false;
14763
15328
  return true;
14764
15329
  }
15330
+ function looksLikeGeaFunctionalComponentSource(source) {
15331
+ if (!source.includes("<") || !source.includes(">")) return false;
15332
+ if (/export\s+default\s+async\s+function\b/.test(source)) return true;
15333
+ if (/export\s+default\s+function\b/.test(source)) return true;
15334
+ if (/export\s+default\s*\([^)]*\)\s*=>\s*/.test(source)) return true;
15335
+ return false;
15336
+ }
14765
15337
  function geaPlugin() {
14766
15338
  const storeModules = /* @__PURE__ */ new Set();
14767
15339
  const componentModules = /* @__PURE__ */ new Set();
@@ -14821,6 +15393,10 @@ function geaPlugin() {
14821
15393
  componentModules.add(filePath);
14822
15394
  return true;
14823
15395
  }
15396
+ if (looksLikeGeaFunctionalComponentSource(source)) {
15397
+ componentModules.add(filePath);
15398
+ return true;
15399
+ }
14824
15400
  return false;
14825
15401
  } catch {
14826
15402
  return false;
@@ -14903,7 +15479,7 @@ ${entries.join(",\n")}
14903
15479
  convertFunctionalToClass(ast, functionalComponentInfo, imports);
14904
15480
  componentClassName = functionalComponentInfo.name;
14905
15481
  componentClassNames = [functionalComponentInfo.name];
14906
- const freshCode = generate3(ast, { retainLines: true }).code;
15482
+ const freshCode = generate4(ast, { retainLines: true }).code;
14907
15483
  const freshParsed = parseSource(freshCode);
14908
15484
  if (freshParsed) {
14909
15485
  ast = freshParsed.ast;
@@ -14990,7 +15566,13 @@ ${entries.join(",\n")}
14990
15566
  noScope: true,
14991
15567
  ClassDeclaration(path) {
14992
15568
  if (!path.node.id || path.node.id.name !== cn) return;
14993
- const prop = t24.classProperty(t24.identifier("__geaTagName"), t24.stringLiteral(kebab));
15569
+ const prop = t24.classProperty(
15570
+ t24.identifier("GEA_CTOR_TAG_NAME"),
15571
+ t24.stringLiteral(kebab),
15572
+ void 0,
15573
+ void 0,
15574
+ true
15575
+ );
14994
15576
  prop.static = true;
14995
15577
  path.node.body.body.unshift(prop);
14996
15578
  path.stop();
@@ -14998,6 +15580,7 @@ ${entries.join(",\n")}
14998
15580
  });
14999
15581
  transformed = true;
15000
15582
  }
15583
+ ensureImport(ast, "@geajs/core", "GEA_CTOR_TAG_NAME");
15001
15584
  } else {
15002
15585
  transformed = transformNonComponentJSX(ast, imports);
15003
15586
  }
@@ -15023,9 +15606,9 @@ ${entries.join(",\n")}
15023
15606
  if (hmrAdded) transformed = true;
15024
15607
  }
15025
15608
  if (!transformed) return null;
15026
- ensureImport(ast, "@geajs/core", "__escapeHtml");
15027
- ensureImport(ast, "@geajs/core", "__sanitizeAttr");
15028
- const output = generate3(ast, { sourceMaps: true, sourceFileName: cleanId }, code);
15609
+ ensureImport(ast, "@geajs/core", "geaEscapeHtml");
15610
+ ensureImport(ast, "@geajs/core", "geaSanitizeAttr");
15611
+ const output = generate4(ast, { sourceMaps: true, sourceFileName: cleanId }, code);
15029
15612
  return { code: output.code, map: output.map };
15030
15613
  } catch (error) {
15031
15614
  if (error?.__geaCompileError) {