@geajs/vite-plugin 1.0.20 → 1.0.22
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 +121 -101
- 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
|
}
|
|
@@ -5918,12 +5918,26 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
|
|
|
5918
5918
|
t11.stringLiteral(entry.attributeName)
|
|
5919
5919
|
])
|
|
5920
5920
|
),
|
|
5921
|
-
t11.
|
|
5922
|
-
t11.
|
|
5923
|
-
t11.
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5921
|
+
t11.blockStatement([
|
|
5922
|
+
t11.variableDeclaration("const", [
|
|
5923
|
+
t11.variableDeclarator(t11.identifier("__newAttr"), t11.callExpression(t11.identifier("String"), [attrVal]))
|
|
5924
|
+
]),
|
|
5925
|
+
t11.ifStatement(
|
|
5926
|
+
t11.binaryExpression(
|
|
5927
|
+
"!==",
|
|
5928
|
+
t11.callExpression(t11.memberExpression(t11.cloneNode(navExpr, true), t11.identifier("getAttribute")), [
|
|
5929
|
+
t11.stringLiteral(entry.attributeName)
|
|
5930
|
+
]),
|
|
5931
|
+
t11.identifier("__newAttr")
|
|
5932
|
+
),
|
|
5933
|
+
t11.expressionStatement(
|
|
5934
|
+
t11.callExpression(t11.memberExpression(t11.cloneNode(navExpr, true), t11.identifier("setAttribute")), [
|
|
5935
|
+
t11.stringLiteral(entry.attributeName),
|
|
5936
|
+
t11.identifier("__newAttr")
|
|
5937
|
+
])
|
|
5938
|
+
)
|
|
5939
|
+
)
|
|
5940
|
+
])
|
|
5927
5941
|
)
|
|
5928
5942
|
);
|
|
5929
5943
|
}
|
|
@@ -5932,9 +5946,9 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
|
|
|
5932
5946
|
}
|
|
5933
5947
|
}
|
|
5934
5948
|
const rawItemIdExpr = itemIdProperty && itemIdProperty !== ITEM_IS_KEY ? t11.logicalExpression("??", buildOptionalMemberChain(t11.identifier("item"), itemIdProperty), t11.identifier("item")) : t11.identifier("item");
|
|
5935
|
-
const
|
|
5949
|
+
const itemIdExpr = t11.callExpression(t11.identifier("String"), [rawItemIdExpr]);
|
|
5936
5950
|
body.push(
|
|
5937
|
-
t11.expressionStatement(t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaKey")),
|
|
5951
|
+
t11.expressionStatement(t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaKey")), itemIdExpr))
|
|
5938
5952
|
);
|
|
5939
5953
|
const rowElsProp = `__rowEls_${arrayMap.containerBindingId ?? "list"}`;
|
|
5940
5954
|
const privateElsRef = t11.memberExpression(t11.thisExpression(), t11.privateName(t11.identifier(rowElsProp)));
|
|
@@ -5948,7 +5962,7 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
|
|
|
5948
5962
|
t11.cloneNode(privateElsRef),
|
|
5949
5963
|
t11.assignmentExpression("=", t11.cloneNode(privateElsRef), t11.objectExpression([]))
|
|
5950
5964
|
),
|
|
5951
|
-
t11.cloneNode(
|
|
5965
|
+
t11.cloneNode(itemIdExpr, true),
|
|
5952
5966
|
true
|
|
5953
5967
|
),
|
|
5954
5968
|
elVar
|
|
@@ -5956,36 +5970,6 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
|
|
|
5956
5970
|
)
|
|
5957
5971
|
);
|
|
5958
5972
|
const patchPrivateFields = [rowElsProp];
|
|
5959
|
-
if (false) {
|
|
5960
|
-
const bindId = arrayMap.containerBindingId;
|
|
5961
|
-
const privateIdField = t11.memberExpression(t11.thisExpression(), t11.privateName(t11.identifier("__id")));
|
|
5962
|
-
patchPrivateFields.push("__id");
|
|
5963
|
-
body.push(
|
|
5964
|
-
t11.expressionStatement(
|
|
5965
|
-
t11.assignmentExpression(
|
|
5966
|
-
"=",
|
|
5967
|
-
t11.memberExpression(elVar, t11.identifier("id")),
|
|
5968
|
-
t11.binaryExpression(
|
|
5969
|
-
"+",
|
|
5970
|
-
t11.binaryExpression(
|
|
5971
|
-
"+",
|
|
5972
|
-
t11.logicalExpression(
|
|
5973
|
-
"||",
|
|
5974
|
-
t11.cloneNode(privateIdField),
|
|
5975
|
-
t11.assignmentExpression(
|
|
5976
|
-
"=",
|
|
5977
|
-
t11.cloneNode(privateIdField),
|
|
5978
|
-
t11.memberExpression(t11.thisExpression(), t11.identifier("id_"))
|
|
5979
|
-
)
|
|
5980
|
-
),
|
|
5981
|
-
t11.stringLiteral("-" + bindId + "-gk-")
|
|
5982
|
-
),
|
|
5983
|
-
t11.cloneNode(itemIdExpr2, true)
|
|
5984
|
-
)
|
|
5985
|
-
)
|
|
5986
|
-
)
|
|
5987
|
-
);
|
|
5988
|
-
}
|
|
5989
5973
|
body.push(
|
|
5990
5974
|
t11.expressionStatement(
|
|
5991
5975
|
t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaItem")), t11.identifier("item"))
|
|
@@ -6589,12 +6573,26 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
|
|
|
6589
6573
|
t11.stringLiteral(entry.attributeName)
|
|
6590
6574
|
])
|
|
6591
6575
|
),
|
|
6592
|
-
t11.
|
|
6593
|
-
t11.
|
|
6594
|
-
t11.
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6576
|
+
t11.blockStatement([
|
|
6577
|
+
t11.variableDeclaration("const", [
|
|
6578
|
+
t11.variableDeclarator(t11.identifier("__newAttr"), t11.callExpression(t11.identifier("String"), [attrVal]))
|
|
6579
|
+
]),
|
|
6580
|
+
t11.ifStatement(
|
|
6581
|
+
t11.binaryExpression(
|
|
6582
|
+
"!==",
|
|
6583
|
+
t11.callExpression(t11.memberExpression(t11.cloneNode(navExpr, true), t11.identifier("getAttribute")), [
|
|
6584
|
+
t11.stringLiteral(entry.attributeName)
|
|
6585
|
+
]),
|
|
6586
|
+
t11.identifier("__newAttr")
|
|
6587
|
+
),
|
|
6588
|
+
t11.expressionStatement(
|
|
6589
|
+
t11.callExpression(t11.memberExpression(t11.cloneNode(navExpr, true), t11.identifier("setAttribute")), [
|
|
6590
|
+
t11.stringLiteral(entry.attributeName),
|
|
6591
|
+
t11.identifier("__newAttr")
|
|
6592
|
+
])
|
|
6593
|
+
)
|
|
6594
|
+
)
|
|
6595
|
+
])
|
|
6598
6596
|
)
|
|
6599
6597
|
);
|
|
6600
6598
|
}
|
|
@@ -6609,36 +6607,6 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
|
|
|
6609
6607
|
t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaKey")), patchItemIdExpr)
|
|
6610
6608
|
)
|
|
6611
6609
|
);
|
|
6612
|
-
if (false) {
|
|
6613
|
-
const bindId = arrayMap.containerBindingId;
|
|
6614
|
-
const privateIdField = t11.memberExpression(t11.thisExpression(), t11.privateName(t11.identifier("__id")));
|
|
6615
|
-
privateFields.push("__id");
|
|
6616
|
-
body.push(
|
|
6617
|
-
t11.expressionStatement(
|
|
6618
|
-
t11.assignmentExpression(
|
|
6619
|
-
"=",
|
|
6620
|
-
t11.memberExpression(elVar, t11.identifier("id")),
|
|
6621
|
-
t11.binaryExpression(
|
|
6622
|
-
"+",
|
|
6623
|
-
t11.binaryExpression(
|
|
6624
|
-
"+",
|
|
6625
|
-
t11.logicalExpression(
|
|
6626
|
-
"||",
|
|
6627
|
-
t11.cloneNode(privateIdField),
|
|
6628
|
-
t11.assignmentExpression(
|
|
6629
|
-
"=",
|
|
6630
|
-
t11.cloneNode(privateIdField),
|
|
6631
|
-
t11.memberExpression(t11.thisExpression(), t11.identifier("id_"))
|
|
6632
|
-
)
|
|
6633
|
-
),
|
|
6634
|
-
t11.stringLiteral("-" + bindId + "-gk-")
|
|
6635
|
-
),
|
|
6636
|
-
t11.cloneNode(itemIdExpr, true)
|
|
6637
|
-
)
|
|
6638
|
-
)
|
|
6639
|
-
)
|
|
6640
|
-
);
|
|
6641
|
-
}
|
|
6642
6610
|
body.push(
|
|
6643
6611
|
t11.expressionStatement(
|
|
6644
6612
|
t11.assignmentExpression("=", t11.memberExpression(elVar, t11.identifier("__geaItem")), t11.identifier("item"))
|
|
@@ -8530,15 +8498,32 @@ function buildPropPatcherFunction(binding, propName) {
|
|
|
8530
8498
|
t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
|
|
8531
8499
|
)
|
|
8532
8500
|
)
|
|
8533
|
-
) : t17.
|
|
8534
|
-
t17.
|
|
8535
|
-
t17.
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8501
|
+
) : t17.blockStatement([
|
|
8502
|
+
t17.variableDeclaration("const", [
|
|
8503
|
+
t17.variableDeclarator(
|
|
8504
|
+
t17.identifier("__newAttr"),
|
|
8505
|
+
URL_ATTRS2.has(attrName) ? t17.callExpression(t17.identifier("__sanitizeAttr"), [
|
|
8506
|
+
t17.stringLiteral(attrName),
|
|
8507
|
+
t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
|
|
8508
|
+
]) : t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
|
|
8509
|
+
)
|
|
8510
|
+
]),
|
|
8511
|
+
t17.ifStatement(
|
|
8512
|
+
t17.binaryExpression(
|
|
8513
|
+
"!==",
|
|
8514
|
+
t17.callExpression(t17.memberExpression(t17.cloneNode(target, true), t17.identifier("getAttribute")), [
|
|
8515
|
+
t17.stringLiteral(attrName)
|
|
8516
|
+
]),
|
|
8517
|
+
t17.identifier("__newAttr")
|
|
8518
|
+
),
|
|
8519
|
+
t17.expressionStatement(
|
|
8520
|
+
t17.callExpression(t17.memberExpression(t17.cloneNode(target, true), t17.identifier("setAttribute")), [
|
|
8521
|
+
t17.stringLiteral(attrName),
|
|
8522
|
+
t17.identifier("__newAttr")
|
|
8523
|
+
])
|
|
8524
|
+
)
|
|
8525
|
+
)
|
|
8526
|
+
]);
|
|
8542
8527
|
return t17.arrowFunctionExpression(
|
|
8543
8528
|
[row, value],
|
|
8544
8529
|
t17.blockStatement([
|
|
@@ -8680,12 +8665,29 @@ function buildPatchEntryPropPatcher(entry) {
|
|
|
8680
8665
|
t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
|
|
8681
8666
|
)
|
|
8682
8667
|
)
|
|
8683
|
-
) : t17.
|
|
8684
|
-
t17.
|
|
8685
|
-
t17.
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8668
|
+
) : t17.blockStatement([
|
|
8669
|
+
t17.variableDeclaration("const", [
|
|
8670
|
+
t17.variableDeclarator(
|
|
8671
|
+
t17.identifier("__newAttr"),
|
|
8672
|
+
t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
|
|
8673
|
+
)
|
|
8674
|
+
]),
|
|
8675
|
+
t17.ifStatement(
|
|
8676
|
+
t17.binaryExpression(
|
|
8677
|
+
"!==",
|
|
8678
|
+
t17.callExpression(t17.memberExpression(t17.cloneNode(target, true), t17.identifier("getAttribute")), [
|
|
8679
|
+
t17.stringLiteral(attrName)
|
|
8680
|
+
]),
|
|
8681
|
+
t17.identifier("__newAttr")
|
|
8682
|
+
),
|
|
8683
|
+
t17.expressionStatement(
|
|
8684
|
+
t17.callExpression(t17.memberExpression(t17.cloneNode(target, true), t17.identifier("setAttribute")), [
|
|
8685
|
+
t17.stringLiteral(attrName),
|
|
8686
|
+
t17.identifier("__newAttr")
|
|
8687
|
+
])
|
|
8688
|
+
)
|
|
8689
|
+
)
|
|
8690
|
+
]);
|
|
8689
8691
|
return t17.arrowFunctionExpression(
|
|
8690
8692
|
[row, value, item],
|
|
8691
8693
|
t17.blockStatement([
|
|
@@ -9144,7 +9146,10 @@ function buildConditionalPatchStatement(binding, target, itemVariable) {
|
|
|
9144
9146
|
if (__attrValue == null || __attrValue === false) {
|
|
9145
9147
|
${jsExpr3`${target}.removeAttribute(${binding.attributeName || "class"})`};
|
|
9146
9148
|
} else {
|
|
9147
|
-
|
|
9149
|
+
const __newAttr = String(__attrValue);
|
|
9150
|
+
if (${jsExpr3`${target}.getAttribute(${binding.attributeName || "class"})`} !== __newAttr) {
|
|
9151
|
+
${jsExpr3`${target}.setAttribute(${binding.attributeName || "class"}, __newAttr)`};
|
|
9152
|
+
}
|
|
9148
9153
|
}
|
|
9149
9154
|
`
|
|
9150
9155
|
);
|
|
@@ -11155,8 +11160,6 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
|
|
|
11155
11160
|
);
|
|
11156
11161
|
if (!stateProps.has(dep.observeKey)) stateProps.set(dep.observeKey, dep.pathParts);
|
|
11157
11162
|
}
|
|
11158
|
-
const propDeps = deps.filter((dep) => !dep.storeVar && dep.pathParts[0] === "props");
|
|
11159
|
-
if (propDeps.length === 0) return;
|
|
11160
11163
|
const usedPropNames = /* @__PURE__ */ new Set();
|
|
11161
11164
|
const scanNodes = [
|
|
11162
11165
|
...(info.computationSetupStatements || []).map((s) => t20.cloneNode(s, true))
|
|
@@ -11164,6 +11167,11 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
|
|
|
11164
11167
|
if (info.computationExpr) {
|
|
11165
11168
|
scanNodes.push(t20.expressionStatement(t20.cloneNode(info.computationExpr, true)));
|
|
11166
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
|
+
};
|
|
11167
11175
|
if (scanNodes.length > 0) {
|
|
11168
11176
|
const prog = t20.program(scanNodes);
|
|
11169
11177
|
traverse12(prog, {
|
|
@@ -11171,13 +11179,25 @@ function applyStaticReactivity(ast, originalAST, className, sourceFile, imports,
|
|
|
11171
11179
|
Identifier(path) {
|
|
11172
11180
|
if (templatePropNames.has(path.node.name)) usedPropNames.add(path.node.name);
|
|
11173
11181
|
},
|
|
11174
|
-
MemberExpression
|
|
11175
|
-
|
|
11176
|
-
|
|
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);
|
|
11177
11195
|
}
|
|
11178
|
-
}
|
|
11196
|
+
},
|
|
11197
|
+
MemberExpression: addPropNameFromMember
|
|
11179
11198
|
});
|
|
11180
11199
|
}
|
|
11200
|
+
if (usedPropNames.size === 0) return;
|
|
11181
11201
|
unresolvedMapPropRefreshDeps.push({
|
|
11182
11202
|
mapIdx: getMapIndex(binding.arrayPathParts),
|
|
11183
11203
|
propNames: Array.from(usedPropNames)
|
|
@@ -13277,7 +13297,7 @@ function injectMapItemAttrsIntoTemplate(templateMethod, mapInfos) {
|
|
|
13277
13297
|
const tagName = tagPart.slice(1).toLowerCase();
|
|
13278
13298
|
const isIntrinsicRoot = !tagName.includes("-");
|
|
13279
13299
|
const eventAttr = info.eventToken && isIntrinsicRoot ? ` data-gea-event="${info.eventToken}"` : "";
|
|
13280
|
-
const
|
|
13300
|
+
const itemIdExpr = info.itemIdProperty && info.itemIdProperty !== ITEM_IS_KEY ? t20.logicalExpression(
|
|
13281
13301
|
"??",
|
|
13282
13302
|
buildOptionalMemberChain(t20.identifier(info.itemVariable), info.itemIdProperty),
|
|
13283
13303
|
t20.identifier(info.itemVariable)
|
|
@@ -13291,7 +13311,7 @@ function injectMapItemAttrsIntoTemplate(templateMethod, mapInfos) {
|
|
|
13291
13311
|
),
|
|
13292
13312
|
...rootTL.quasis.slice(1)
|
|
13293
13313
|
];
|
|
13294
|
-
rootTL.expressions = [
|
|
13314
|
+
rootTL.expressions = [itemIdExpr, ...rootTL.expressions];
|
|
13295
13315
|
}
|
|
13296
13316
|
}
|
|
13297
13317
|
});
|