@geajs/vite-plugin 1.0.21 → 1.0.23
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 +46 -93
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5203,10 +5203,10 @@ function processElement(node, parts, ctx, elementPath = []) {
|
|
|
5203
5203
|
if (ctx.inMapCallback && elementPath.length === 0 && ctx.mapItemVariable) {
|
|
5204
5204
|
const itemVar = ctx.mapItemVariable;
|
|
5205
5205
|
const itemIdProp = ctx.mapItemIdProperty;
|
|
5206
|
-
const
|
|
5206
|
+
const itemIdExpr = itemIdProp && itemIdProp !== ITEM_IS_KEY ? t10.logicalExpression("??", buildOptionalMemberChain(t10.identifier(itemVar), itemIdProp), t10.identifier(itemVar)) : t10.callExpression(t10.identifier("String"), [t10.identifier(itemVar)]);
|
|
5207
5207
|
{
|
|
5208
5208
|
parts.push({ type: "string", value: html + ' data-gea-item-id="' });
|
|
5209
|
-
parts.push({ type: "expression", value:
|
|
5209
|
+
parts.push({ type: "expression", value: itemIdExpr });
|
|
5210
5210
|
html = '"';
|
|
5211
5211
|
}
|
|
5212
5212
|
}
|
|
@@ -5925,17 +5925,16 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
|
|
|
5925
5925
|
t11.ifStatement(
|
|
5926
5926
|
t11.binaryExpression(
|
|
5927
5927
|
"!==",
|
|
5928
|
-
t11.callExpression(
|
|
5929
|
-
t11.
|
|
5930
|
-
|
|
5931
|
-
),
|
|
5928
|
+
t11.callExpression(t11.memberExpression(t11.cloneNode(navExpr, true), t11.identifier("getAttribute")), [
|
|
5929
|
+
t11.stringLiteral(entry.attributeName)
|
|
5930
|
+
]),
|
|
5932
5931
|
t11.identifier("__newAttr")
|
|
5933
5932
|
),
|
|
5934
5933
|
t11.expressionStatement(
|
|
5935
|
-
t11.callExpression(
|
|
5936
|
-
t11.
|
|
5937
|
-
|
|
5938
|
-
)
|
|
5934
|
+
t11.callExpression(t11.memberExpression(t11.cloneNode(navExpr, true), t11.identifier("setAttribute")), [
|
|
5935
|
+
t11.stringLiteral(entry.attributeName),
|
|
5936
|
+
t11.identifier("__newAttr")
|
|
5937
|
+
])
|
|
5939
5938
|
)
|
|
5940
5939
|
)
|
|
5941
5940
|
])
|
|
@@ -5947,9 +5946,9 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
|
|
|
5947
5946
|
}
|
|
5948
5947
|
}
|
|
5949
5948
|
const rawItemIdExpr = itemIdProperty && itemIdProperty !== ITEM_IS_KEY ? t11.logicalExpression("??", buildOptionalMemberChain(t11.identifier("item"), itemIdProperty), t11.identifier("item")) : t11.identifier("item");
|
|
5950
|
-
const
|
|
5949
|
+
const itemIdExpr = t11.callExpression(t11.identifier("String"), [rawItemIdExpr]);
|
|
5951
5950
|
body.push(
|
|
5952
|
-
t11.expressionStatement(t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaKey")),
|
|
5951
|
+
t11.expressionStatement(t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaKey")), itemIdExpr))
|
|
5953
5952
|
);
|
|
5954
5953
|
const rowElsProp = `__rowEls_${arrayMap.containerBindingId ?? "list"}`;
|
|
5955
5954
|
const privateElsRef = t11.memberExpression(t11.thisExpression(), t11.privateName(t11.identifier(rowElsProp)));
|
|
@@ -5963,7 +5962,7 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
|
|
|
5963
5962
|
t11.cloneNode(privateElsRef),
|
|
5964
5963
|
t11.assignmentExpression("=", t11.cloneNode(privateElsRef), t11.objectExpression([]))
|
|
5965
5964
|
),
|
|
5966
|
-
t11.cloneNode(
|
|
5965
|
+
t11.cloneNode(itemIdExpr, true),
|
|
5967
5966
|
true
|
|
5968
5967
|
),
|
|
5969
5968
|
elVar
|
|
@@ -5971,36 +5970,6 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
|
|
|
5971
5970
|
)
|
|
5972
5971
|
);
|
|
5973
5972
|
const patchPrivateFields = [rowElsProp];
|
|
5974
|
-
if (false) {
|
|
5975
|
-
const bindId = arrayMap.containerBindingId;
|
|
5976
|
-
const privateIdField = t11.memberExpression(t11.thisExpression(), t11.privateName(t11.identifier("__id")));
|
|
5977
|
-
patchPrivateFields.push("__id");
|
|
5978
|
-
body.push(
|
|
5979
|
-
t11.expressionStatement(
|
|
5980
|
-
t11.assignmentExpression(
|
|
5981
|
-
"=",
|
|
5982
|
-
t11.memberExpression(elVar, t11.identifier("id")),
|
|
5983
|
-
t11.binaryExpression(
|
|
5984
|
-
"+",
|
|
5985
|
-
t11.binaryExpression(
|
|
5986
|
-
"+",
|
|
5987
|
-
t11.logicalExpression(
|
|
5988
|
-
"||",
|
|
5989
|
-
t11.cloneNode(privateIdField),
|
|
5990
|
-
t11.assignmentExpression(
|
|
5991
|
-
"=",
|
|
5992
|
-
t11.cloneNode(privateIdField),
|
|
5993
|
-
t11.memberExpression(t11.thisExpression(), t11.identifier("id_"))
|
|
5994
|
-
)
|
|
5995
|
-
),
|
|
5996
|
-
t11.stringLiteral("-" + bindId + "-gk-")
|
|
5997
|
-
),
|
|
5998
|
-
t11.cloneNode(itemIdExpr2, true)
|
|
5999
|
-
)
|
|
6000
|
-
)
|
|
6001
|
-
)
|
|
6002
|
-
);
|
|
6003
|
-
}
|
|
6004
5973
|
body.push(
|
|
6005
5974
|
t11.expressionStatement(
|
|
6006
5975
|
t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaItem")), t11.identifier("item"))
|
|
@@ -6611,17 +6580,16 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
|
|
|
6611
6580
|
t11.ifStatement(
|
|
6612
6581
|
t11.binaryExpression(
|
|
6613
6582
|
"!==",
|
|
6614
|
-
t11.callExpression(
|
|
6615
|
-
t11.
|
|
6616
|
-
|
|
6617
|
-
),
|
|
6583
|
+
t11.callExpression(t11.memberExpression(t11.cloneNode(navExpr, true), t11.identifier("getAttribute")), [
|
|
6584
|
+
t11.stringLiteral(entry.attributeName)
|
|
6585
|
+
]),
|
|
6618
6586
|
t11.identifier("__newAttr")
|
|
6619
6587
|
),
|
|
6620
6588
|
t11.expressionStatement(
|
|
6621
|
-
t11.callExpression(
|
|
6622
|
-
t11.
|
|
6623
|
-
|
|
6624
|
-
)
|
|
6589
|
+
t11.callExpression(t11.memberExpression(t11.cloneNode(navExpr, true), t11.identifier("setAttribute")), [
|
|
6590
|
+
t11.stringLiteral(entry.attributeName),
|
|
6591
|
+
t11.identifier("__newAttr")
|
|
6592
|
+
])
|
|
6625
6593
|
)
|
|
6626
6594
|
)
|
|
6627
6595
|
])
|
|
@@ -6639,36 +6607,6 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
|
|
|
6639
6607
|
t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaKey")), patchItemIdExpr)
|
|
6640
6608
|
)
|
|
6641
6609
|
);
|
|
6642
|
-
if (false) {
|
|
6643
|
-
const bindId = arrayMap.containerBindingId;
|
|
6644
|
-
const privateIdField = t11.memberExpression(t11.thisExpression(), t11.privateName(t11.identifier("__id")));
|
|
6645
|
-
privateFields.push("__id");
|
|
6646
|
-
body.push(
|
|
6647
|
-
t11.expressionStatement(
|
|
6648
|
-
t11.assignmentExpression(
|
|
6649
|
-
"=",
|
|
6650
|
-
t11.memberExpression(elVar, t11.identifier("id")),
|
|
6651
|
-
t11.binaryExpression(
|
|
6652
|
-
"+",
|
|
6653
|
-
t11.binaryExpression(
|
|
6654
|
-
"+",
|
|
6655
|
-
t11.logicalExpression(
|
|
6656
|
-
"||",
|
|
6657
|
-
t11.cloneNode(privateIdField),
|
|
6658
|
-
t11.assignmentExpression(
|
|
6659
|
-
"=",
|
|
6660
|
-
t11.cloneNode(privateIdField),
|
|
6661
|
-
t11.memberExpression(t11.thisExpression(), t11.identifier("id_"))
|
|
6662
|
-
)
|
|
6663
|
-
),
|
|
6664
|
-
t11.stringLiteral("-" + bindId + "-gk-")
|
|
6665
|
-
),
|
|
6666
|
-
t11.cloneNode(itemIdExpr, true)
|
|
6667
|
-
)
|
|
6668
|
-
)
|
|
6669
|
-
)
|
|
6670
|
-
);
|
|
6671
|
-
}
|
|
6672
6610
|
body.push(
|
|
6673
6611
|
t11.expressionStatement(
|
|
6674
6612
|
t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaItem")), t11.identifier("item"))
|
|
@@ -11222,8 +11160,6 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
|
|
|
11222
11160
|
);
|
|
11223
11161
|
if (!stateProps.has(dep.observeKey)) stateProps.set(dep.observeKey, dep.pathParts);
|
|
11224
11162
|
}
|
|
11225
|
-
const propDeps = deps.filter((dep) => !dep.storeVar && dep.pathParts[0] === "props");
|
|
11226
|
-
if (propDeps.length === 0) return;
|
|
11227
11163
|
const usedPropNames = /* @__PURE__ */ new Set();
|
|
11228
11164
|
const scanNodes = [
|
|
11229
11165
|
...(info.computationSetupStatements || []).map((s) => t20.cloneNode(s, true))
|
|
@@ -11231,6 +11167,11 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
|
|
|
11231
11167
|
if (info.computationExpr) {
|
|
11232
11168
|
scanNodes.push(t20.expressionStatement(t20.cloneNode(info.computationExpr, true)));
|
|
11233
11169
|
}
|
|
11170
|
+
const addPropNameFromMember = (path) => {
|
|
11171
|
+
if (templateWholeParam && t20.isIdentifier(path.node.object, { name: templateWholeParam }) && t20.isIdentifier(path.node.property) && !path.node.computed) {
|
|
11172
|
+
usedPropNames.add(path.node.property.name);
|
|
11173
|
+
}
|
|
11174
|
+
};
|
|
11234
11175
|
if (scanNodes.length > 0) {
|
|
11235
11176
|
const prog = t20.program(scanNodes);
|
|
11236
11177
|
traverse12(prog, {
|
|
@@ -11238,13 +11179,25 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
|
|
|
11238
11179
|
Identifier(path) {
|
|
11239
11180
|
if (templatePropNames.has(path.node.name)) usedPropNames.add(path.node.name);
|
|
11240
11181
|
},
|
|
11241
|
-
MemberExpression
|
|
11242
|
-
|
|
11243
|
-
|
|
11182
|
+
MemberExpression: addPropNameFromMember
|
|
11183
|
+
});
|
|
11184
|
+
}
|
|
11185
|
+
if (info.itemTemplate) {
|
|
11186
|
+
const skipVars = /* @__PURE__ */ new Set([info.itemVariable, ...info.indexVariable ? [info.indexVariable] : []]);
|
|
11187
|
+
const templateProg = t20.program([
|
|
11188
|
+
t20.expressionStatement(t20.cloneNode(info.itemTemplate, true))
|
|
11189
|
+
]);
|
|
11190
|
+
traverse12(templateProg, {
|
|
11191
|
+
noScope: true,
|
|
11192
|
+
Identifier(path) {
|
|
11193
|
+
if (!skipVars.has(path.node.name) && templatePropNames.has(path.node.name)) {
|
|
11194
|
+
usedPropNames.add(path.node.name);
|
|
11244
11195
|
}
|
|
11245
|
-
}
|
|
11196
|
+
},
|
|
11197
|
+
MemberExpression: addPropNameFromMember
|
|
11246
11198
|
});
|
|
11247
11199
|
}
|
|
11200
|
+
if (usedPropNames.size === 0) return;
|
|
11248
11201
|
unresolvedMapPropRefreshDeps.push({
|
|
11249
11202
|
mapIdx: getMapIndex(binding.arrayPathParts),
|
|
11250
11203
|
propNames: Array.from(usedPropNames)
|
|
@@ -12390,7 +12343,10 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
|
|
|
12390
12343
|
}
|
|
12391
12344
|
}
|
|
12392
12345
|
}
|
|
12393
|
-
|
|
12346
|
+
for (const olc of observeListConfigs) {
|
|
12347
|
+
ensureStoreGroup(olc.storeVar);
|
|
12348
|
+
}
|
|
12349
|
+
if (importedStores.size > 0 || localObserveHandlers.size > 0 || mapRegistrations.length > 0 || observeListConfigs.length > 0) {
|
|
12394
12350
|
const storeConfigs = Array.from(importedStores.entries()).map(([storeVar, config]) => ({
|
|
12395
12351
|
storeVar,
|
|
12396
12352
|
captureExpression: config.captureExpression,
|
|
@@ -12405,9 +12361,6 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
|
|
|
12405
12361
|
})
|
|
12406
12362
|
)
|
|
12407
12363
|
}));
|
|
12408
|
-
for (const olc of observeListConfigs) {
|
|
12409
|
-
ensureStoreGroup(olc.storeVar);
|
|
12410
|
-
}
|
|
12411
12364
|
if (storeConfigs.length > 0 || mapRegistrations.length > 0 || observeListConfigs.length > 0) {
|
|
12412
12365
|
const createdHooksMethod = generateCreatedHooks(
|
|
12413
12366
|
storeConfigs,
|
|
@@ -13344,7 +13297,7 @@ function injectMapItemAttrsIntoTemplate(templateMethod, mapInfos) {
|
|
|
13344
13297
|
const tagName = tagPart.slice(1).toLowerCase();
|
|
13345
13298
|
const isIntrinsicRoot = !tagName.includes("-");
|
|
13346
13299
|
const eventAttr = info.eventToken && isIntrinsicRoot ? ` data-gea-event="${info.eventToken}"` : "";
|
|
13347
|
-
const
|
|
13300
|
+
const itemIdExpr = info.itemIdProperty && info.itemIdProperty !== ITEM_IS_KEY ? t20.logicalExpression(
|
|
13348
13301
|
"??",
|
|
13349
13302
|
buildOptionalMemberChain(t20.identifier(info.itemVariable), info.itemIdProperty),
|
|
13350
13303
|
t20.identifier(info.itemVariable)
|
|
@@ -13358,7 +13311,7 @@ function injectMapItemAttrsIntoTemplate(templateMethod, mapInfos) {
|
|
|
13358
13311
|
),
|
|
13359
13312
|
...rootTL.quasis.slice(1)
|
|
13360
13313
|
];
|
|
13361
|
-
rootTL.expressions = [
|
|
13314
|
+
rootTL.expressions = [itemIdExpr, ...rootTL.expressions];
|
|
13362
13315
|
}
|
|
13363
13316
|
}
|
|
13364
13317
|
});
|