@geajs/vite-plugin 1.0.26 → 1.0.28
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.
- package/dist/index.js +138 -37
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import
|
|
2
|
+
import babelGenerator3 from "@babel/generator";
|
|
3
3
|
import babelTraverse2 from "@babel/traverse";
|
|
4
4
|
|
|
5
5
|
// src/parse.ts
|
|
@@ -1559,9 +1559,7 @@ function replaceIdentifierWithClonedExpr(node, name, expr) {
|
|
|
1559
1559
|
}
|
|
1560
1560
|
function optimizeBoundValueAliasesInSequence(stmts) {
|
|
1561
1561
|
const out = [...stmts];
|
|
1562
|
-
|
|
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
|
}
|
|
@@ -5682,13 +5678,15 @@ import { appendToBody, id as id3, js as js2, jsMethod } from "eszter";
|
|
|
5682
5678
|
import { createRequire as createRequire6 } from "module";
|
|
5683
5679
|
var require7 = createRequire6(import.meta.url);
|
|
5684
5680
|
var traverse6 = require7("@babel/traverse").default;
|
|
5685
|
-
function rewriteItemVarInExpression(expr, fromVar, toVar) {
|
|
5686
|
-
|
|
5681
|
+
function rewriteItemVarInExpression(expr, fromVar, toVar, renames) {
|
|
5682
|
+
const renameMap = new Map(renames || []);
|
|
5683
|
+
renameMap.set(fromVar, toVar);
|
|
5687
5684
|
const cloned = t11.cloneNode(expr, true);
|
|
5688
5685
|
traverse6(t11.program([t11.expressionStatement(cloned)]), {
|
|
5689
5686
|
noScope: true,
|
|
5690
5687
|
Identifier(path) {
|
|
5691
|
-
|
|
5688
|
+
const replacement = renameMap.get(path.node.name);
|
|
5689
|
+
if (replacement) path.node.name = replacement;
|
|
5692
5690
|
}
|
|
5693
5691
|
});
|
|
5694
5692
|
return cloned;
|
|
@@ -5766,20 +5764,62 @@ function collectItemTemplatePropTree(template, itemVar) {
|
|
|
5766
5764
|
});
|
|
5767
5765
|
return tree;
|
|
5768
5766
|
}
|
|
5769
|
-
function
|
|
5767
|
+
function getCalleeMemberChainFromItem(callee, itemVar) {
|
|
5768
|
+
const chain = [];
|
|
5769
|
+
let node = callee;
|
|
5770
|
+
while (t11.isMemberExpression(node) && !node.computed && t11.isIdentifier(node.property)) {
|
|
5771
|
+
chain.unshift(node.property.name);
|
|
5772
|
+
node = node.object;
|
|
5773
|
+
}
|
|
5774
|
+
if (!t11.isIdentifier(node, { name: itemVar }) || chain.length === 0) return null;
|
|
5775
|
+
return chain;
|
|
5776
|
+
}
|
|
5777
|
+
function collectItemCalleePropertyPaths(template, itemVar) {
|
|
5778
|
+
const paths = /* @__PURE__ */ new Set();
|
|
5779
|
+
const program12 = t11.program([t11.expressionStatement(t11.cloneNode(template, true))]);
|
|
5780
|
+
traverse6(program12, {
|
|
5781
|
+
noScope: true,
|
|
5782
|
+
CallExpression(path) {
|
|
5783
|
+
const chain = getCalleeMemberChainFromItem(path.node.callee, itemVar);
|
|
5784
|
+
if (chain) paths.add(chain.join("."));
|
|
5785
|
+
}
|
|
5786
|
+
});
|
|
5787
|
+
return paths;
|
|
5788
|
+
}
|
|
5789
|
+
function buildDummyFromTree(tree, keyPathParts, calleePaths, pathPrefix = []) {
|
|
5770
5790
|
const props = [];
|
|
5771
5791
|
for (const [key, value] of Object.entries(tree)) {
|
|
5792
|
+
const pathHere = [...pathPrefix, key];
|
|
5793
|
+
const pathStr = pathHere.join(".");
|
|
5772
5794
|
const matchesKeyPath = keyPathParts && keyPathParts.length > 0 && keyPathParts[0] === key;
|
|
5773
5795
|
if (matchesKeyPath && keyPathParts.length === 1) {
|
|
5774
5796
|
props.push(t11.objectProperty(t11.identifier(key), t11.numericLiteral(0)));
|
|
5775
5797
|
} else if (matchesKeyPath) {
|
|
5776
5798
|
props.push(
|
|
5777
|
-
t11.objectProperty(
|
|
5799
|
+
t11.objectProperty(
|
|
5800
|
+
t11.identifier(key),
|
|
5801
|
+
buildDummyFromTree(
|
|
5802
|
+
value === true ? {} : value,
|
|
5803
|
+
keyPathParts.slice(1),
|
|
5804
|
+
calleePaths,
|
|
5805
|
+
pathHere
|
|
5806
|
+
)
|
|
5807
|
+
)
|
|
5778
5808
|
);
|
|
5779
5809
|
} else if (value === true) {
|
|
5780
|
-
props.push(
|
|
5810
|
+
props.push(
|
|
5811
|
+
t11.objectProperty(
|
|
5812
|
+
t11.identifier(key),
|
|
5813
|
+
calleePaths.has(pathStr) ? (
|
|
5814
|
+
// Return empty string so `${item.content()}` in template init does not inject "null" / escaped markup.
|
|
5815
|
+
t11.arrowFunctionExpression([], t11.stringLiteral(""), true)
|
|
5816
|
+
) : t11.stringLiteral(" ")
|
|
5817
|
+
)
|
|
5818
|
+
);
|
|
5781
5819
|
} else {
|
|
5782
|
-
props.push(
|
|
5820
|
+
props.push(
|
|
5821
|
+
t11.objectProperty(t11.identifier(key), buildDummyFromTree(value, null, calleePaths, pathHere))
|
|
5822
|
+
);
|
|
5783
5823
|
}
|
|
5784
5824
|
}
|
|
5785
5825
|
return t11.objectExpression(props);
|
|
@@ -5790,7 +5830,6 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
|
|
|
5790
5830
|
const arrayName = arrayPath.replace(/\./g, "");
|
|
5791
5831
|
const capName = arrayName.charAt(0).toUpperCase() + arrayName.slice(1);
|
|
5792
5832
|
const methodName = `patch${capName}Item`;
|
|
5793
|
-
const containerProp = `__${arrayPath.replace(/\./g, "_")}_container`;
|
|
5794
5833
|
const itemIdProperty = arrayMap.itemIdProperty;
|
|
5795
5834
|
const itemTemplateRootIsComponent = t11.isJSXElement(arrayMap.itemTemplate) && isComponentTag(getJSXTagName(arrayMap.itemTemplate.openingElement.name));
|
|
5796
5835
|
if (itemTemplateRootIsComponent) return { method: null, privateFields: [] };
|
|
@@ -5999,7 +6038,8 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
|
|
|
5999
6038
|
}
|
|
6000
6039
|
}
|
|
6001
6040
|
}
|
|
6002
|
-
const
|
|
6041
|
+
const keyRenames = arrayMap.indexVariable ? /* @__PURE__ */ new Map([[arrayMap.indexVariable, "__idx"]]) : void 0;
|
|
6042
|
+
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
6043
|
const itemIdExpr = t11.callExpression(t11.identifier("String"), [rawItemIdExpr]);
|
|
6004
6044
|
body.push(
|
|
6005
6045
|
t11.expressionStatement(t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaKey")), itemIdExpr))
|
|
@@ -6036,6 +6076,26 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
|
|
|
6036
6076
|
privateFields: patchPrivateFields
|
|
6037
6077
|
};
|
|
6038
6078
|
}
|
|
6079
|
+
function textPatchHasItemMethodCall(expr, itemVar) {
|
|
6080
|
+
const calleeIsItemMethod = (callee) => t11.isMemberExpression(callee) && !callee.computed && t11.isIdentifier(callee.object, { name: itemVar });
|
|
6081
|
+
const visit = (e) => {
|
|
6082
|
+
let found = false;
|
|
6083
|
+
traverse6(t11.program([t11.expressionStatement(t11.cloneNode(e, true))]), {
|
|
6084
|
+
noScope: true,
|
|
6085
|
+
CallExpression(p) {
|
|
6086
|
+
if (calleeIsItemMethod(p.node.callee)) {
|
|
6087
|
+
found = true;
|
|
6088
|
+
p.stop();
|
|
6089
|
+
}
|
|
6090
|
+
}
|
|
6091
|
+
});
|
|
6092
|
+
return found;
|
|
6093
|
+
};
|
|
6094
|
+
if (t11.isTemplateLiteral(expr)) {
|
|
6095
|
+
return expr.expressions.some((ex) => visit(ex));
|
|
6096
|
+
}
|
|
6097
|
+
return visit(expr);
|
|
6098
|
+
}
|
|
6039
6099
|
function collectPatchEntries(arrayMap) {
|
|
6040
6100
|
const cloned = t11.cloneNode(arrayMap.itemTemplate, true);
|
|
6041
6101
|
const tempFile = t11.file(t11.program([t11.expressionStatement(cloned)]));
|
|
@@ -6047,7 +6107,7 @@ function collectPatchEntries(arrayMap) {
|
|
|
6047
6107
|
});
|
|
6048
6108
|
const modified = tempFile.program.body[0].expression;
|
|
6049
6109
|
const entries = [];
|
|
6050
|
-
|
|
6110
|
+
let requiresRerender = templateRequiresRerender(tempFile);
|
|
6051
6111
|
if (t11.isJSXElement(modified)) {
|
|
6052
6112
|
const rootTagName = getJSXTagName(modified.openingElement.name);
|
|
6053
6113
|
const rootIsComponent = isComponentTag(rootTagName);
|
|
@@ -6056,6 +6116,14 @@ function collectPatchEntries(arrayMap) {
|
|
|
6056
6116
|
for (const ent of entries) {
|
|
6057
6117
|
ent.expression = optionalizeMemberChainsAfterComputedItemKey(ent.expression, "item");
|
|
6058
6118
|
}
|
|
6119
|
+
if (!requiresRerender) {
|
|
6120
|
+
for (const ent of entries) {
|
|
6121
|
+
if (ent.type === "text" && textPatchHasItemMethodCall(ent.expression, "item")) {
|
|
6122
|
+
requiresRerender = true;
|
|
6123
|
+
break;
|
|
6124
|
+
}
|
|
6125
|
+
}
|
|
6126
|
+
}
|
|
6059
6127
|
return { entries, requiresRerender };
|
|
6060
6128
|
}
|
|
6061
6129
|
function walkJSXForPatch(node, path, entries, rootIsComponent = false) {
|
|
@@ -6344,10 +6412,12 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
|
|
|
6344
6412
|
}
|
|
6345
6413
|
const propTree = collectItemTemplatePropTree(arrayMap.itemTemplate, arrayMap.itemVariable);
|
|
6346
6414
|
const containerRef = t11.memberExpression(t11.thisExpression(), t11.identifier(containerProp));
|
|
6347
|
-
const
|
|
6415
|
+
const dcFieldSuffix = arrayMap.containerBindingId ?? arrayPath.replace(/\./g, "_");
|
|
6416
|
+
const dcPrivateName = `__dc_${dcFieldSuffix}`;
|
|
6417
|
+
const privateDcField = t11.memberExpression(t11.thisExpression(), t11.privateName(t11.identifier(dcPrivateName)));
|
|
6348
6418
|
const cVar = t11.identifier("__c");
|
|
6349
6419
|
const elVar = t11.identifier("el");
|
|
6350
|
-
const privateFields = [
|
|
6420
|
+
const privateFields = [dcPrivateName];
|
|
6351
6421
|
const body = [];
|
|
6352
6422
|
if (useRawStoreCache) {
|
|
6353
6423
|
const privateRsField = t11.memberExpression(t11.thisExpression(), t11.privateName(t11.identifier("__rs")));
|
|
@@ -6380,10 +6450,11 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
|
|
|
6380
6450
|
)
|
|
6381
6451
|
])
|
|
6382
6452
|
);
|
|
6383
|
-
const isPrimitiveKey =
|
|
6453
|
+
const isPrimitiveKey = (itemIdProperty === ITEM_IS_KEY || !itemIdProperty) && !arrayMap.keyExpression && Object.keys(propTree).length === 0;
|
|
6454
|
+
const calleePaths = collectItemCalleePropertyPaths(arrayMap.itemTemplate, arrayMap.itemVariable);
|
|
6384
6455
|
const dummyItem = isPrimitiveKey ? t11.stringLiteral("__dummy__") : (() => {
|
|
6385
6456
|
if (itemIdProperty) ensureDummyTreePath(propTree, itemIdProperty);
|
|
6386
|
-
return buildDummyFromTree(propTree, itemIdProperty ? normalizePathParts(itemIdProperty) : null);
|
|
6457
|
+
return buildDummyFromTree(propTree, itemIdProperty ? normalizePathParts(itemIdProperty) : null, calleePaths);
|
|
6387
6458
|
})();
|
|
6388
6459
|
const hasRootClassNamePatch = patchedEntries.some((e) => e.type === "className" && e.childPath.length === 0);
|
|
6389
6460
|
const tplInit = [
|
|
@@ -6654,7 +6725,11 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
|
|
|
6654
6725
|
}
|
|
6655
6726
|
}
|
|
6656
6727
|
}
|
|
6657
|
-
const
|
|
6728
|
+
const createKeyRenames = arrayMap.indexVariable ? /* @__PURE__ */ new Map([[arrayMap.indexVariable, "__idx"]]) : void 0;
|
|
6729
|
+
const rawPatchItemIdExpr = arrayMap.keyExpression ? t11.cloneNode(
|
|
6730
|
+
rewriteItemVarInExpression(arrayMap.keyExpression, arrayMap.itemVariable, "item", createKeyRenames),
|
|
6731
|
+
true
|
|
6732
|
+
) : itemIdProperty && itemIdProperty !== ITEM_IS_KEY ? t11.logicalExpression("??", buildOptionalMemberChain(t11.identifier("item"), itemIdProperty), t11.identifier("item")) : t11.identifier("item");
|
|
6658
6733
|
const patchItemIdExpr = t11.callExpression(t11.identifier("String"), [rawPatchItemIdExpr]);
|
|
6659
6734
|
body.push(
|
|
6660
6735
|
t11.expressionStatement(
|
|
@@ -6827,7 +6902,7 @@ function buildEventIdExpr(suffix) {
|
|
|
6827
6902
|
t12.stringLiteral("-" + suffix)
|
|
6828
6903
|
);
|
|
6829
6904
|
}
|
|
6830
|
-
function jsxToStaticHtml(node, refCounter, elementPath = [],
|
|
6905
|
+
function jsxToStaticHtml(node, refCounter, elementPath = [], _isRoot = true) {
|
|
6831
6906
|
const tagName = getJSXTagName(node.openingElement.name);
|
|
6832
6907
|
const isComp = Boolean(tagName && isComponentTag(tagName));
|
|
6833
6908
|
if (isComp) return null;
|
|
@@ -7467,7 +7542,9 @@ function buildCloneTemplateBody(identityPatches, contentPatches, cloneCtx) {
|
|
|
7467
7542
|
|
|
7468
7543
|
// src/generate-events.ts
|
|
7469
7544
|
import * as t13 from "@babel/types";
|
|
7545
|
+
import babelGenerator from "@babel/generator";
|
|
7470
7546
|
import { id as id4, jsBlockBody, jsMethod as jsMethod2 } from "eszter";
|
|
7547
|
+
var generate2 = typeof babelGenerator.default === "function" ? babelGenerator.default : babelGenerator;
|
|
7471
7548
|
function getTemplateParamContext(classBody2) {
|
|
7472
7549
|
const templateMethod = classBody2.body.find(
|
|
7473
7550
|
(m) => t13.isClassMethod(m) && t13.isIdentifier(m.key) && m.key.name === "template"
|
|
@@ -7491,12 +7568,26 @@ function getTemplateParamContext(classBody2) {
|
|
|
7491
7568
|
function getMapContextKey(ctx) {
|
|
7492
7569
|
const store = ctx.storeVar || "store";
|
|
7493
7570
|
const path = ctx.arrayPathParts.join("_");
|
|
7494
|
-
|
|
7571
|
+
const keyPart = ctx.keyExpression ? `expr:${generate2(ctx.keyExpression).code}` : ctx.itemIdProperty;
|
|
7572
|
+
return `${store}_${path}_${keyPart}`;
|
|
7495
7573
|
}
|
|
7496
7574
|
function ensureMapItemHelper(classBody2, ctx, helperName) {
|
|
7497
7575
|
if (classBody2.body.some((m) => t13.isClassMethod(m) && t13.isIdentifier(m.key) && m.key.name === helperName)) return;
|
|
7498
7576
|
const itemsExpr = buildArrayItemsExpr(ctx);
|
|
7499
|
-
const findPredicate = ctx.
|
|
7577
|
+
const findPredicate = ctx.keyExpression ? t13.arrowFunctionExpression(
|
|
7578
|
+
[t13.identifier("__candidate")],
|
|
7579
|
+
t13.binaryExpression(
|
|
7580
|
+
"===",
|
|
7581
|
+
t13.callExpression(t13.identifier("String"), [
|
|
7582
|
+
rewriteItemVarInExpression(
|
|
7583
|
+
t13.cloneNode(ctx.keyExpression, true),
|
|
7584
|
+
ctx.itemVariable,
|
|
7585
|
+
"__candidate"
|
|
7586
|
+
)
|
|
7587
|
+
]),
|
|
7588
|
+
t13.identifier("__itemId")
|
|
7589
|
+
)
|
|
7590
|
+
) : ctx.itemIdProperty && ctx.itemIdProperty !== ITEM_IS_KEY ? t13.arrowFunctionExpression(
|
|
7500
7591
|
[t13.identifier("__candidate")],
|
|
7501
7592
|
t13.binaryExpression(
|
|
7502
7593
|
"===",
|
|
@@ -8163,7 +8254,7 @@ function buildPropsBuilderMethod(child) {
|
|
|
8163
8254
|
}
|
|
8164
8255
|
|
|
8165
8256
|
// src/apply-reactivity.ts
|
|
8166
|
-
import
|
|
8257
|
+
import babelGenerator2 from "@babel/generator";
|
|
8167
8258
|
import * as t20 from "@babel/types";
|
|
8168
8259
|
import { appendToBody as appendToBody5, id as id11, js as js6, jsBlockBody as jsBlockBody4, jsExpr as jsExpr4, jsMethod as jsMethod8 } from "eszter";
|
|
8169
8260
|
|
|
@@ -9262,10 +9353,7 @@ function buildElsLookup(elsRef, containerRef, idExpr, rowVar, containerBindingId
|
|
|
9262
9353
|
t17.binaryExpression(
|
|
9263
9354
|
"<",
|
|
9264
9355
|
t17.identifier("__i"),
|
|
9265
|
-
t17.memberExpression(
|
|
9266
|
-
t17.memberExpression(ctrLocal, t17.identifier("children")),
|
|
9267
|
-
t17.identifier("length")
|
|
9268
|
-
)
|
|
9356
|
+
t17.memberExpression(t17.memberExpression(ctrLocal, t17.identifier("children")), t17.identifier("length"))
|
|
9269
9357
|
),
|
|
9270
9358
|
t17.updateExpression("++", t17.identifier("__i")),
|
|
9271
9359
|
t17.blockStatement([
|
|
@@ -9751,6 +9839,7 @@ function generateRenderItemMethod(arrayMap, imports, eventHandlers, eventIdCount
|
|
|
9751
9839
|
h.mapContext = {
|
|
9752
9840
|
arrayPathParts: arrayMap.arrayPathParts || normalizePathParts(arrayMap.arrayPath || ""),
|
|
9753
9841
|
itemIdProperty: arrayMap.itemIdProperty || "id",
|
|
9842
|
+
...arrayMap.keyExpression ? { keyExpression: t18.cloneNode(arrayMap.keyExpression, true) } : {},
|
|
9754
9843
|
itemVariable: arrayMap.itemVariable,
|
|
9755
9844
|
indexVariable: arrayMap.indexVariable,
|
|
9756
9845
|
isImportedState: arrayMap.isImportedState || false,
|
|
@@ -9931,7 +10020,7 @@ function generateComponentArrayResult(um, arrayPropName, imports, propNames, _cl
|
|
|
9931
10020
|
|
|
9932
10021
|
// src/apply-reactivity.ts
|
|
9933
10022
|
import { createRequire as createRequire12 } from "module";
|
|
9934
|
-
var
|
|
10023
|
+
var generate3 = "default" in babelGenerator2 ? babelGenerator2.default : babelGenerator2;
|
|
9935
10024
|
var URL_ATTRS3 = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "cite", "poster", "background"]);
|
|
9936
10025
|
var require13 = createRequire12(import.meta.url);
|
|
9937
10026
|
var traverse12 = require13("@babel/traverse").default;
|
|
@@ -12382,7 +12471,7 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
|
|
|
12382
12471
|
const bodyGroups = /* @__PURE__ */ new Map();
|
|
12383
12472
|
for (const entry of methodEntries) {
|
|
12384
12473
|
const { storeVar } = parseObserveKey(entry.observeKey);
|
|
12385
|
-
const bodyCode = (storeVar || "") + ":" +
|
|
12474
|
+
const bodyCode = (storeVar || "") + ":" + generate3(t20.blockStatement(entry.method.body.body)).code;
|
|
12386
12475
|
if (!bodyGroups.has(bodyCode)) bodyGroups.set(bodyCode, []);
|
|
12387
12476
|
bodyGroups.get(bodyCode).push(entry);
|
|
12388
12477
|
}
|
|
@@ -12740,15 +12829,16 @@ function generateMapRegistration(arrayMap, unresolvedMap, templatePropNames, who
|
|
|
12740
12829
|
if (unresolvedMap.keyExpression) {
|
|
12741
12830
|
const keyExpr = t20.cloneNode(unresolvedMap.keyExpression, true);
|
|
12742
12831
|
const itemVar = unresolvedMap.itemVariable;
|
|
12832
|
+
const idxVar = unresolvedMap.indexVariable;
|
|
12743
12833
|
traverse12(t20.program([t20.expressionStatement(keyExpr)]), {
|
|
12744
12834
|
noScope: true,
|
|
12745
12835
|
Identifier(path) {
|
|
12746
12836
|
if (path.node.name === itemVar) path.node.name = "__k";
|
|
12837
|
+
else if (idxVar && path.node.name === idxVar) path.node.name = "__ki";
|
|
12747
12838
|
}
|
|
12748
12839
|
});
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
);
|
|
12840
|
+
const keyFnParams = idxVar ? [t20.identifier("__k"), t20.identifier("__ki")] : [t20.identifier("__k")];
|
|
12841
|
+
registerArgs.push(t20.arrowFunctionExpression(keyFnParams, t20.callExpression(t20.identifier("String"), [keyExpr])));
|
|
12752
12842
|
} else if (arrayMap.itemIdProperty && arrayMap.itemIdProperty !== ITEM_IS_KEY) {
|
|
12753
12843
|
registerArgs.push(t20.stringLiteral(arrayMap.itemIdProperty));
|
|
12754
12844
|
}
|
|
@@ -14519,7 +14609,7 @@ function resolveDefault(mod) {
|
|
|
14519
14609
|
throw new Error("resolveDefault: expected a function or module with default export");
|
|
14520
14610
|
}
|
|
14521
14611
|
var traverse16 = resolveDefault(babelTraverse2);
|
|
14522
|
-
var
|
|
14612
|
+
var generate4 = resolveDefault(babelGenerator3);
|
|
14523
14613
|
function hasSSREnvironment(ctx) {
|
|
14524
14614
|
if (!("environment" in ctx)) return false;
|
|
14525
14615
|
const env = ctx.environment;
|
|
@@ -14755,6 +14845,13 @@ function isComponentImportSource(source) {
|
|
|
14755
14845
|
if (source.startsWith("node:")) return false;
|
|
14756
14846
|
return true;
|
|
14757
14847
|
}
|
|
14848
|
+
function looksLikeGeaFunctionalComponentSource(source) {
|
|
14849
|
+
if (!source.includes("<") || !source.includes(">")) return false;
|
|
14850
|
+
if (/export\s+default\s+async\s+function\b/.test(source)) return true;
|
|
14851
|
+
if (/export\s+default\s+function\b/.test(source)) return true;
|
|
14852
|
+
if (/export\s+default\s*\([^)]*\)\s*=>\s*/.test(source)) return true;
|
|
14853
|
+
return false;
|
|
14854
|
+
}
|
|
14758
14855
|
function geaPlugin() {
|
|
14759
14856
|
const storeModules = /* @__PURE__ */ new Set();
|
|
14760
14857
|
const componentModules = /* @__PURE__ */ new Set();
|
|
@@ -14814,6 +14911,10 @@ function geaPlugin() {
|
|
|
14814
14911
|
componentModules.add(filePath);
|
|
14815
14912
|
return true;
|
|
14816
14913
|
}
|
|
14914
|
+
if (looksLikeGeaFunctionalComponentSource(source)) {
|
|
14915
|
+
componentModules.add(filePath);
|
|
14916
|
+
return true;
|
|
14917
|
+
}
|
|
14817
14918
|
return false;
|
|
14818
14919
|
} catch {
|
|
14819
14920
|
return false;
|
|
@@ -14896,7 +14997,7 @@ ${entries.join(",\n")}
|
|
|
14896
14997
|
convertFunctionalToClass(ast, functionalComponentInfo, imports);
|
|
14897
14998
|
componentClassName = functionalComponentInfo.name;
|
|
14898
14999
|
componentClassNames = [functionalComponentInfo.name];
|
|
14899
|
-
const freshCode =
|
|
15000
|
+
const freshCode = generate4(ast, { retainLines: true }).code;
|
|
14900
15001
|
const freshParsed = parseSource(freshCode);
|
|
14901
15002
|
if (freshParsed) {
|
|
14902
15003
|
ast = freshParsed.ast;
|
|
@@ -15018,7 +15119,7 @@ ${entries.join(",\n")}
|
|
|
15018
15119
|
if (!transformed) return null;
|
|
15019
15120
|
ensureImport(ast, "@geajs/core", "__escapeHtml");
|
|
15020
15121
|
ensureImport(ast, "@geajs/core", "__sanitizeAttr");
|
|
15021
|
-
const output =
|
|
15122
|
+
const output = generate4(ast, { sourceMaps: true, sourceFileName: cleanId }, code);
|
|
15022
15123
|
return { code: output.code, map: output.map };
|
|
15023
15124
|
} catch (error) {
|
|
15024
15125
|
if (error?.__geaCompileError) {
|