@geajs/vite-plugin 1.1.0 → 1.1.2
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 +78 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3773,6 +3773,16 @@ function analyzeChildren(node, tagName, elementPath, bindings, propBindings, arr
|
|
|
3773
3773
|
);
|
|
3774
3774
|
const slotCountAfter = conditionalSlots?.length ?? 0;
|
|
3775
3775
|
const slotId = slotCountAfter > slotCountBefore ? conditionalSlots[slotCountAfter - 1].slotId : void 0;
|
|
3776
|
+
if (slotCountAfter > slotCountBefore && conditionalSlots && conditionalSlotNodeMap && templateSetupContext) {
|
|
3777
|
+
registerNestedConditionalsInBranches(
|
|
3778
|
+
expr,
|
|
3779
|
+
stateRefs,
|
|
3780
|
+
templateSetupContext,
|
|
3781
|
+
conditionalSlots,
|
|
3782
|
+
conditionalSlotNodeMap,
|
|
3783
|
+
classBody2
|
|
3784
|
+
);
|
|
3785
|
+
}
|
|
3776
3786
|
nestedMapCalls.forEach(({ mapExpr, parentElement, containerPath }) => {
|
|
3777
3787
|
let mapNode = node;
|
|
3778
3788
|
let mapElementPath = elementPath;
|
|
@@ -4320,6 +4330,59 @@ function extractConditionalControlExpression(expr) {
|
|
|
4320
4330
|
}
|
|
4321
4331
|
return null;
|
|
4322
4332
|
}
|
|
4333
|
+
function registerNestedConditionalsInBranches(expr, stateRefs, templateSetupContext, conditionalSlots, conditionalSlotNodeMap, classBody2) {
|
|
4334
|
+
function visitChildren(children) {
|
|
4335
|
+
for (const child of children) {
|
|
4336
|
+
if (t9.isJSXElement(child)) visitChildren(child.children);
|
|
4337
|
+
else if (t9.isJSXFragment(child)) visitChildren(child.children);
|
|
4338
|
+
else if (t9.isJSXExpressionContainer(child) && !t9.isJSXEmptyExpression(child.expression)) {
|
|
4339
|
+
const innerExpr = child.expression;
|
|
4340
|
+
if (!expressionMayProduceJSX(innerExpr)) continue;
|
|
4341
|
+
const conditionExpr = extractConditionalControlExpression(innerExpr);
|
|
4342
|
+
if (!conditionExpr) continue;
|
|
4343
|
+
const condSetupStatements = collectTemplateSetupStatements(conditionExpr, templateSetupContext);
|
|
4344
|
+
const fullSetupStatements = collectTemplateSetupStatements(innerExpr, templateSetupContext);
|
|
4345
|
+
const allDeps = collectExpressionDependencies(conditionExpr, stateRefs, condSetupStatements);
|
|
4346
|
+
if (allDeps.length === 0) continue;
|
|
4347
|
+
const slotId = `c${conditionalSlots.length}`;
|
|
4348
|
+
conditionalSlots.push({
|
|
4349
|
+
slotId,
|
|
4350
|
+
conditionExpr: t9.cloneNode(conditionExpr, true),
|
|
4351
|
+
setupStatements: condSetupStatements.map((s) => t9.cloneNode(s, true)),
|
|
4352
|
+
htmlSetupStatements: fullSetupStatements.map((s) => t9.cloneNode(s, true)),
|
|
4353
|
+
...expressionContainsComponentJSX(innerExpr) ? { hasCompiledChildren: true } : {},
|
|
4354
|
+
dependentPropNames: [],
|
|
4355
|
+
dependencies: allDeps.map((dep) => ({
|
|
4356
|
+
observeKey: dep.observeKey,
|
|
4357
|
+
pathParts: [...dep.pathParts],
|
|
4358
|
+
...dep.storeVar ? { storeVar: dep.storeVar } : {}
|
|
4359
|
+
})),
|
|
4360
|
+
originalExpr: t9.cloneNode(innerExpr, true)
|
|
4361
|
+
});
|
|
4362
|
+
conditionalSlotNodeMap.set(innerExpr, slotId);
|
|
4363
|
+
registerNestedConditionalsInBranches(
|
|
4364
|
+
innerExpr,
|
|
4365
|
+
stateRefs,
|
|
4366
|
+
templateSetupContext,
|
|
4367
|
+
conditionalSlots,
|
|
4368
|
+
conditionalSlotNodeMap,
|
|
4369
|
+
classBody2
|
|
4370
|
+
);
|
|
4371
|
+
}
|
|
4372
|
+
}
|
|
4373
|
+
}
|
|
4374
|
+
function visitBranch(node) {
|
|
4375
|
+
if (t9.isJSXElement(node)) visitChildren(node.children);
|
|
4376
|
+
else if (t9.isJSXFragment(node)) visitChildren(node.children);
|
|
4377
|
+
else if (t9.isParenthesizedExpression(node)) visitBranch(node.expression);
|
|
4378
|
+
}
|
|
4379
|
+
if (t9.isConditionalExpression(expr)) {
|
|
4380
|
+
visitBranch(expr.consequent);
|
|
4381
|
+
visitBranch(expr.alternate);
|
|
4382
|
+
} else if (t9.isLogicalExpression(expr) && expr.operator === "&&") {
|
|
4383
|
+
visitBranch(expr.right);
|
|
4384
|
+
}
|
|
4385
|
+
}
|
|
4323
4386
|
function buildDerivedPropBindings(expr, type, attributeName, elementPath, propsParamName, destructuredPropNames, templateSetupContext, classBody2) {
|
|
4324
4387
|
if (t9.isJSXEmptyExpression(expr) || !templateSetupContext) return [];
|
|
4325
4388
|
const setupStatements = collectTemplateSetupStatements(expr, templateSetupContext);
|
|
@@ -5724,8 +5787,15 @@ function processChildren(children, parts, ctx, elementPath, dcCursor, directChil
|
|
|
5724
5787
|
appendString(parts, `-->`);
|
|
5725
5788
|
pushString(parts, "");
|
|
5726
5789
|
const slotCtx = { ...ctx, elementPathPrefix: "__cs_" + slot.slotId };
|
|
5790
|
+
const eventIdBefore = ctx.eventIdCounter?.value ?? 0;
|
|
5727
5791
|
let condExpr = transformJSXExpression(rawExpr, slotCtx);
|
|
5728
|
-
const
|
|
5792
|
+
const extractCtx = {
|
|
5793
|
+
...ctx,
|
|
5794
|
+
isRoot: false,
|
|
5795
|
+
eventHandlers: ctx.eventHandlers ? [] : void 0,
|
|
5796
|
+
eventIdCounter: ctx.eventIdCounter ? { value: eventIdBefore } : void 0
|
|
5797
|
+
};
|
|
5798
|
+
const extracted = extractHtmlTemplatesFromRawConditional(rawExpr, extractCtx, slot.slotId) ?? extractHtmlTemplatesFromConditional(condExpr);
|
|
5729
5799
|
slot.truthyHtmlExpr = extracted.truthyHtmlExpr;
|
|
5730
5800
|
slot.falsyHtmlExpr = extracted.falsyHtmlExpr;
|
|
5731
5801
|
if (expressionMayBeFalsy(rawExpr)) {
|
|
@@ -7923,7 +7993,13 @@ function appendEventsGetterHandlers(classBody2, handlers, paramContext, setupSta
|
|
|
7923
7993
|
eventsObject.properties.push(eventTypeProp);
|
|
7924
7994
|
}
|
|
7925
7995
|
const selectorMap = eventTypeProp.value;
|
|
7926
|
-
|
|
7996
|
+
const selectorCode = generate2(selectorExpr).code;
|
|
7997
|
+
const isDuplicate = selectorMap.properties.some(
|
|
7998
|
+
(prop) => t13.isObjectProperty(prop) && generate2(prop.key).code === selectorCode
|
|
7999
|
+
);
|
|
8000
|
+
if (!isDuplicate) {
|
|
8001
|
+
selectorMap.properties.push(t13.objectProperty(selectorExpr, handlerRef, !handler.selector));
|
|
8002
|
+
}
|
|
7927
8003
|
});
|
|
7928
8004
|
}
|
|
7929
8005
|
function buildSelectorHandlerMethod(handler, methodName, paramContext, setupStatements) {
|