@plumeria/vite-plugin 6.0.2 → 6.1.0
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 +74 -8
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -86,9 +86,26 @@ export function plumeria(options = {}) {
|
|
|
86
86
|
const localConsts = collectLocalConsts(ast);
|
|
87
87
|
const resourcePath = id;
|
|
88
88
|
const importMap = {};
|
|
89
|
+
const plumeriaAliases = {};
|
|
89
90
|
traverse(ast, {
|
|
90
91
|
ImportDeclaration({ node }) {
|
|
91
92
|
const sourcePath = node.source.value;
|
|
93
|
+
if (sourcePath === '@plumeria/core') {
|
|
94
|
+
node.specifiers.forEach((specifier) => {
|
|
95
|
+
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
96
|
+
plumeriaAliases[specifier.local.value] = 'NAMESPACE';
|
|
97
|
+
}
|
|
98
|
+
else if (specifier.type === 'ImportDefaultSpecifier') {
|
|
99
|
+
plumeriaAliases[specifier.local.value] = 'NAMESPACE';
|
|
100
|
+
}
|
|
101
|
+
else if (specifier.type === 'ImportSpecifier') {
|
|
102
|
+
const importedName = specifier.imported
|
|
103
|
+
? specifier.imported.value
|
|
104
|
+
: specifier.local.value;
|
|
105
|
+
plumeriaAliases[specifier.local.value] = importedName;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
92
109
|
const actualPath = resolveImportPath(sourcePath, resourcePath);
|
|
93
110
|
if (actualPath) {
|
|
94
111
|
node.specifiers.forEach((specifier) => {
|
|
@@ -195,14 +212,31 @@ export function plumeria(options = {}) {
|
|
|
195
212
|
}
|
|
196
213
|
};
|
|
197
214
|
const registerStyle = (node, declSpan, isExported) => {
|
|
215
|
+
let propName;
|
|
198
216
|
if (t.isIdentifier(node.id) &&
|
|
199
217
|
node.init &&
|
|
200
218
|
t.isCallExpression(node.init) &&
|
|
201
|
-
t.isMemberExpression(node.init.callee) &&
|
|
202
|
-
t.isIdentifier(node.init.callee.object, { name: 'css' }) &&
|
|
203
|
-
t.isIdentifier(node.init.callee.property) &&
|
|
204
219
|
node.init.arguments.length >= 1) {
|
|
205
|
-
const
|
|
220
|
+
const callee = node.init.callee;
|
|
221
|
+
if (t.isMemberExpression(callee) &&
|
|
222
|
+
t.isIdentifier(callee.object) &&
|
|
223
|
+
t.isIdentifier(callee.property)) {
|
|
224
|
+
const objectName = callee.object.value;
|
|
225
|
+
const propertyName = callee.property.value;
|
|
226
|
+
const alias = plumeriaAliases[objectName];
|
|
227
|
+
if (alias === 'NAMESPACE' || objectName === 'css') {
|
|
228
|
+
propName = propertyName;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else if (t.isIdentifier(callee)) {
|
|
232
|
+
const calleeName = callee.value;
|
|
233
|
+
const originalName = plumeriaAliases[calleeName];
|
|
234
|
+
if (originalName) {
|
|
235
|
+
propName = originalName;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (propName) {
|
|
206
240
|
if (propName === 'create' &&
|
|
207
241
|
t.isObjectExpression(node.init.arguments[0].expression)) {
|
|
208
242
|
const obj = objectExpressionToObject(node.init.arguments[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedThemeTable, mergedCreateTable, mergedVariantsTable);
|
|
@@ -321,10 +355,25 @@ export function plumeria(options = {}) {
|
|
|
321
355
|
},
|
|
322
356
|
CallExpression({ node }) {
|
|
323
357
|
const callee = node.callee;
|
|
358
|
+
let propName;
|
|
324
359
|
if (t.isMemberExpression(callee) &&
|
|
325
|
-
t.isIdentifier(callee.object
|
|
360
|
+
t.isIdentifier(callee.object) &&
|
|
326
361
|
t.isIdentifier(callee.property)) {
|
|
327
|
-
const
|
|
362
|
+
const objectName = callee.object.value;
|
|
363
|
+
const propertyName = callee.property.value;
|
|
364
|
+
const alias = plumeriaAliases[objectName];
|
|
365
|
+
if (alias === 'NAMESPACE' || objectName === 'css') {
|
|
366
|
+
propName = propertyName;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
else if (t.isIdentifier(callee)) {
|
|
370
|
+
const calleeName = callee.value;
|
|
371
|
+
const originalName = plumeriaAliases[calleeName];
|
|
372
|
+
if (originalName) {
|
|
373
|
+
propName = originalName;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (propName) {
|
|
328
377
|
const args = node.arguments;
|
|
329
378
|
if (propName === 'keyframes' &&
|
|
330
379
|
args.length > 0 &&
|
|
@@ -418,9 +467,26 @@ export function plumeria(options = {}) {
|
|
|
418
467
|
},
|
|
419
468
|
CallExpression({ node }) {
|
|
420
469
|
const callee = node.callee;
|
|
470
|
+
let isPropsCall = false;
|
|
421
471
|
if (t.isMemberExpression(callee) &&
|
|
422
|
-
t.isIdentifier(callee.object
|
|
423
|
-
t.isIdentifier(callee.property
|
|
472
|
+
t.isIdentifier(callee.object) &&
|
|
473
|
+
t.isIdentifier(callee.property)) {
|
|
474
|
+
const objectName = callee.object.value;
|
|
475
|
+
const propertyName = callee.property.value;
|
|
476
|
+
const alias = plumeriaAliases[objectName];
|
|
477
|
+
if ((alias === 'NAMESPACE' || objectName === 'css') &&
|
|
478
|
+
propertyName === 'props') {
|
|
479
|
+
isPropsCall = true;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
else if (t.isIdentifier(callee)) {
|
|
483
|
+
const calleeName = callee.value;
|
|
484
|
+
const originalName = plumeriaAliases[calleeName];
|
|
485
|
+
if (originalName === 'props') {
|
|
486
|
+
isPropsCall = true;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
if (isPropsCall) {
|
|
424
490
|
const args = node.arguments;
|
|
425
491
|
const resolveStyleObject = (expr) => {
|
|
426
492
|
if (t.isObjectExpression(expr)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/vite-plugin",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
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": "^6.0
|
|
25
|
+
"@plumeria/utils": "^6.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@swc/core": "1.15.8",
|