@geajs/vite-plugin 1.0.26 → 1.0.27

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 +13 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5682,13 +5682,15 @@ import { appendToBody, id as id3, js as js2, jsMethod } from "eszter";
5682
5682
  import { createRequire as createRequire6 } from "module";
5683
5683
  var require7 = createRequire6(import.meta.url);
5684
5684
  var traverse6 = require7("@babel/traverse").default;
5685
- function rewriteItemVarInExpression(expr, fromVar, toVar) {
5686
- if (fromVar === toVar) return expr;
5685
+ function rewriteItemVarInExpression(expr, fromVar, toVar, renames) {
5686
+ const renameMap = new Map(renames || []);
5687
+ renameMap.set(fromVar, toVar);
5687
5688
  const cloned = t11.cloneNode(expr, true);
5688
5689
  traverse6(t11.program([t11.expressionStatement(cloned)]), {
5689
5690
  noScope: true,
5690
5691
  Identifier(path) {
5691
- if (path.node.name === fromVar) path.node.name = toVar;
5692
+ const replacement = renameMap.get(path.node.name);
5693
+ if (replacement) path.node.name = replacement;
5692
5694
  }
5693
5695
  });
5694
5696
  return cloned;
@@ -5999,7 +6001,8 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
5999
6001
  }
6000
6002
  }
6001
6003
  }
6002
- const rawItemIdExpr = arrayMap.keyExpression ? t11.cloneNode(rewriteItemVarInExpression(arrayMap.keyExpression, arrayMap.itemVariable, "item"), true) : itemIdProperty && itemIdProperty !== ITEM_IS_KEY ? t11.logicalExpression("??", buildOptionalMemberChain(t11.identifier("item"), itemIdProperty), t11.identifier("item")) : t11.identifier("item");
6004
+ const keyRenames = arrayMap.indexVariable ? /* @__PURE__ */ new Map([[arrayMap.indexVariable, "__idx"]]) : void 0;
6005
+ 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");
6003
6006
  const itemIdExpr = t11.callExpression(t11.identifier("String"), [rawItemIdExpr]);
6004
6007
  body.push(
6005
6008
  t11.expressionStatement(t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaKey")), itemIdExpr))
@@ -6654,7 +6657,8 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
6654
6657
  }
6655
6658
  }
6656
6659
  }
6657
- const rawPatchItemIdExpr = arrayMap.keyExpression ? t11.cloneNode(rewriteItemVarInExpression(arrayMap.keyExpression, arrayMap.itemVariable, "item"), true) : itemIdProperty && itemIdProperty !== ITEM_IS_KEY ? t11.logicalExpression("??", buildOptionalMemberChain(t11.identifier("item"), itemIdProperty), t11.identifier("item")) : t11.identifier("item");
6660
+ 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");
6658
6662
  const patchItemIdExpr = t11.callExpression(t11.identifier("String"), [rawPatchItemIdExpr]);
6659
6663
  body.push(
6660
6664
  t11.expressionStatement(
@@ -12740,14 +12744,17 @@ function generateMapRegistration(arrayMap, unresolvedMap, templatePropNames, who
12740
12744
  if (unresolvedMap.keyExpression) {
12741
12745
  const keyExpr = t20.cloneNode(unresolvedMap.keyExpression, true);
12742
12746
  const itemVar = unresolvedMap.itemVariable;
12747
+ const idxVar = unresolvedMap.indexVariable;
12743
12748
  traverse12(t20.program([t20.expressionStatement(keyExpr)]), {
12744
12749
  noScope: true,
12745
12750
  Identifier(path) {
12746
12751
  if (path.node.name === itemVar) path.node.name = "__k";
12752
+ else if (idxVar && path.node.name === idxVar) path.node.name = "__ki";
12747
12753
  }
12748
12754
  });
12755
+ const keyFnParams = idxVar ? [t20.identifier("__k"), t20.identifier("__ki")] : [t20.identifier("__k")];
12749
12756
  registerArgs.push(
12750
- t20.arrowFunctionExpression([t20.identifier("__k")], t20.callExpression(t20.identifier("String"), [keyExpr]))
12757
+ t20.arrowFunctionExpression(keyFnParams, t20.callExpression(t20.identifier("String"), [keyExpr]))
12751
12758
  );
12752
12759
  } else if (arrayMap.itemIdProperty && arrayMap.itemIdProperty !== ITEM_IS_KEY) {
12753
12760
  registerArgs.push(t20.stringLiteral(arrayMap.itemIdProperty));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geajs/vite-plugin",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "description": "Vite plugin for Gea framework - JSX/TSX transform, reactivity, HMR",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",