@plumeria/vite-plugin 4.1.0 → 4.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 +47 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -243,11 +243,10 @@ export function plumeria(options = {}) {
|
|
|
243
243
|
if (styleInfo && !styleInfo.hasDynamicAccess) {
|
|
244
244
|
const atomMap = styleInfo.hashMap[node.property.value];
|
|
245
245
|
if (atomMap) {
|
|
246
|
-
const combinedHash = Object.values(atomMap).join(' ');
|
|
247
246
|
replacements.push({
|
|
248
247
|
start: node.span.start - ast.span.start,
|
|
249
248
|
end: node.span.end - ast.span.start,
|
|
250
|
-
content: JSON.stringify(
|
|
249
|
+
content: JSON.stringify(atomMap),
|
|
251
250
|
});
|
|
252
251
|
}
|
|
253
252
|
}
|
|
@@ -298,7 +297,31 @@ export function plumeria(options = {}) {
|
|
|
298
297
|
}
|
|
299
298
|
return false;
|
|
300
299
|
};
|
|
300
|
+
const hasDynamicAccess = (expr) => {
|
|
301
|
+
if (t.isMemberExpression(expr) && t.isIdentifier(expr.object)) {
|
|
302
|
+
const info = localCreateStyles[expr.object.value];
|
|
303
|
+
if (info && info.hasDynamicAccess)
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
if (t.isIdentifier(expr)) {
|
|
307
|
+
const info = localCreateStyles[expr.value];
|
|
308
|
+
if (info && info.hasDynamicAccess)
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
if (t.isConditionalExpression(expr)) {
|
|
312
|
+
return (hasDynamicAccess(expr.consequent) ||
|
|
313
|
+
hasDynamicAccess(expr.alternate));
|
|
314
|
+
}
|
|
315
|
+
if (t.isBinaryExpression(expr) &&
|
|
316
|
+
(expr.operator === '&&' ||
|
|
317
|
+
expr.operator === '||' ||
|
|
318
|
+
expr.operator === '??')) {
|
|
319
|
+
return (hasDynamicAccess(expr.left) || hasDynamicAccess(expr.right));
|
|
320
|
+
}
|
|
321
|
+
return false;
|
|
322
|
+
};
|
|
301
323
|
const allStatic = args.every((arg) => checkStatic(arg.expression));
|
|
324
|
+
const anyDynamic = args.some((arg) => hasDynamicAccess(arg.expression));
|
|
302
325
|
if (allStatic && args.length > 0) {
|
|
303
326
|
const merged = args.reduce((acc, arg) => {
|
|
304
327
|
const expr = arg.expression;
|
|
@@ -335,6 +358,28 @@ export function plumeria(options = {}) {
|
|
|
335
358
|
});
|
|
336
359
|
}
|
|
337
360
|
}
|
|
361
|
+
else if (anyDynamic) {
|
|
362
|
+
const processExpr = (expr) => {
|
|
363
|
+
if (t.isIdentifier(expr)) {
|
|
364
|
+
const info = localCreateStyles[expr.value];
|
|
365
|
+
if (info && info.hasDynamicAccess) {
|
|
366
|
+
excludedSpans.add(expr.span.start);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
else if (t.isConditionalExpression(expr)) {
|
|
370
|
+
processExpr(expr.consequent);
|
|
371
|
+
processExpr(expr.alternate);
|
|
372
|
+
}
|
|
373
|
+
else if (t.isBinaryExpression(expr) &&
|
|
374
|
+
(expr.operator === '&&' ||
|
|
375
|
+
expr.operator === '||' ||
|
|
376
|
+
expr.operator === '??')) {
|
|
377
|
+
processExpr(expr.left);
|
|
378
|
+
processExpr(expr.right);
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
args.forEach((arg) => processExpr(arg.expression));
|
|
382
|
+
}
|
|
338
383
|
else {
|
|
339
384
|
const processExpr = (expr) => {
|
|
340
385
|
if (t.isMemberExpression(expr) &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/vite-plugin",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Plumeria Vite plugin",
|
|
6
6
|
"author": "Refirst 11",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist/"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@plumeria/utils": "^4.1.
|
|
25
|
+
"@plumeria/utils": "^4.1.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@swc/core": "1.15.8",
|