@geajs/vite-plugin 1.2.0 → 1.2.1

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.mjs +11 -2
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1126,6 +1126,7 @@ function buildComponentPropsExpression(jsxElement, imports, componentInstances,
1126
1126
  else if (t.isJSXExpressionContainer(attr.value) && !t.isJSXEmptyExpression(attr.value.expression)) {
1127
1127
  const expr = attr.value.expression;
1128
1128
  propValue = transformExpression(expr);
1129
+ if (propValue && t.isTemplateLiteral(propValue) && propValue.quasis.length === 2 && propValue.quasis[0].value.raw === "" && propValue.quasis[1].value.raw === "" && propValue.expressions.length === 1) propValue = propValue.expressions[0];
1129
1130
  if (propValue && (/^on[A-Z]/.test(propName) || DOM_EVENT_RE.test(propName)) && t.isMemberExpression(propValue)) {
1130
1131
  const argsId = t.identifier("args");
1131
1132
  propValue = t.arrowFunctionExpression([t.restElement(argsId)], t.callExpression(t.cloneNode(propValue, true), [t.spreadElement(argsId)]));
@@ -1734,6 +1735,12 @@ function collectComponentTags(node, imports, instanceTags, inMapCallback = false
1734
1735
  if (tag && isComponentTag(tag) && imports.has(tag)) {
1735
1736
  if (!inMapCallback) instanceTags.push(tag);
1736
1737
  }
1738
+ for (const attr of node.openingElement.attributes) {
1739
+ if (!t.isJSXAttribute(attr) || !attr.value || !t.isJSXExpressionContainer(attr.value)) continue;
1740
+ if (t.isJSXEmptyExpression(attr.value.expression)) continue;
1741
+ const attrExpr = attr.value.expression;
1742
+ visitExpr(attrExpr, inMapCallback);
1743
+ }
1737
1744
  node.children.forEach((c) => {
1738
1745
  if (t.isJSXElement(c)) collectComponentTags(c, imports, instanceTags, inMapCallback);
1739
1746
  else if (t.isJSXFragment(c)) collectComponentTags(c, imports, instanceTags, inMapCallback);
@@ -2276,7 +2283,7 @@ function processChildren(children, parts, ctx, elementPath, dcCursor, directChil
2276
2283
  pushString(parts, "");
2277
2284
  }
2278
2285
  if (expressionMayBeFalsy(rawExpr)) expr = t.logicalExpression("||", expr, t.stringLiteral(""));
2279
- const safeExpr = childCallInfo || isChildrenPropAccess(rawExpr) || expressionContainsJSX(rawExpr) || ctx.inMapCallback || callsJSXReturningProperty(rawExpr, ctx.classBody) ? expr : jsExpr`geaEscapeHtml(String(${expr}))`;
2286
+ const safeExpr = childCallInfo || isChildrenPropAccess(rawExpr) || expressionContainsJSX(rawExpr) || ctx.inMapCallback || callsJSXReturningProperty(rawExpr, ctx.classBody) ? expr : jsExpr`geaEscapeHtml(${expr})`;
2280
2287
  parts.push({
2281
2288
  type: "expression",
2282
2289
  value: safeExpr
@@ -9687,7 +9694,9 @@ function transformRemainingJSX(ast, imports) {
9687
9694
  const classMethod = path.findParent((p) => t.isClassMethod(p.node));
9688
9695
  if (classMethod && t.isClassMethod(classMethod.node) && t.isIdentifier(classMethod.node.key) && classMethod.node.key.name === "template") return;
9689
9696
  try {
9690
- path.replaceWith(transformJSXToTemplate(path.node, { imports }));
9697
+ let result = transformJSXToTemplate(path.node, { imports });
9698
+ if (t.isTemplateLiteral(result) && result.quasis.length === 2 && result.quasis[0].value.raw === "" && result.quasis[1].value.raw === "" && result.expressions.length === 1 && path.parent && t.isArrowFunctionExpression(path.parent) && path.parent.body === path.node) result = result.expressions[0];
9699
+ path.replaceWith(result);
9691
9700
  } catch (err) {
9692
9701
  console.warn("[gea] Failed to transform JSX element:", err instanceof Error ? err.message : err);
9693
9702
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geajs/vite-plugin",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Vite plugin for Gea framework - JSX/TSX transform, reactivity, HMR",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",