@plumeria/unplugin 18.3.13 → 18.3.14
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/core.js +30 -7
- package/dist/core.mjs +30 -7
- package/package.json +2 -2
package/dist/core.js
CHANGED
|
@@ -53,6 +53,18 @@ const unwrapExport = (node) => {
|
|
|
53
53
|
const isFunctionNode = (node) => node?.type === 'FunctionDeclaration' ||
|
|
54
54
|
node?.type === 'FunctionExpression' ||
|
|
55
55
|
node?.type === 'ArrowFunctionExpression';
|
|
56
|
+
const componentFunctionOf = (node) => {
|
|
57
|
+
if (isFunctionNode(node))
|
|
58
|
+
return node;
|
|
59
|
+
if (node?.type === 'CallExpression') {
|
|
60
|
+
for (const arg of node.arguments ?? []) {
|
|
61
|
+
const fn = componentFunctionOf(arg.expression);
|
|
62
|
+
if (fn)
|
|
63
|
+
return fn;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
};
|
|
56
68
|
const isStaticArgValue = (node) => node.type === 'StringLiteral' ||
|
|
57
69
|
node.type === 'NumericLiteral' ||
|
|
58
70
|
node.type === 'BooleanLiteral' ||
|
|
@@ -334,13 +346,18 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
334
346
|
node: statement,
|
|
335
347
|
});
|
|
336
348
|
}
|
|
349
|
+
else if (statement?.type === 'CallExpression') {
|
|
350
|
+
const fn = componentFunctionOf(statement);
|
|
351
|
+
if (fn)
|
|
352
|
+
components.push({ name: 'default', node: fn });
|
|
353
|
+
}
|
|
337
354
|
else if (utils_1.t.isVariableDeclaration(statement)) {
|
|
338
355
|
for (const decl of statement.declarations) {
|
|
339
|
-
if (utils_1.t.isIdentifier(decl.id)
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
356
|
+
if (!utils_1.t.isIdentifier(decl.id))
|
|
357
|
+
continue;
|
|
358
|
+
const fn = componentFunctionOf(decl.init);
|
|
359
|
+
if (fn)
|
|
360
|
+
components.push({ name: decl.id.value, node: fn });
|
|
344
361
|
}
|
|
345
362
|
}
|
|
346
363
|
}
|
|
@@ -862,12 +879,18 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
862
879
|
if (isFunctionNode(statement)) {
|
|
863
880
|
addFirstParamName(statement);
|
|
864
881
|
}
|
|
882
|
+
else if (statement?.type === 'CallExpression') {
|
|
883
|
+
const fn = componentFunctionOf(statement);
|
|
884
|
+
if (fn)
|
|
885
|
+
addFirstParamName(fn);
|
|
886
|
+
}
|
|
865
887
|
else if (utils_1.t.isVariableDeclaration(statement)) {
|
|
866
888
|
for (const decl of statement.declarations) {
|
|
867
889
|
if (!utils_1.t.isIdentifier(decl.id) || !decl.init)
|
|
868
890
|
continue;
|
|
869
|
-
|
|
870
|
-
|
|
891
|
+
const fn = componentFunctionOf(decl.init);
|
|
892
|
+
if (fn)
|
|
893
|
+
addFirstParamName(fn);
|
|
871
894
|
}
|
|
872
895
|
}
|
|
873
896
|
}
|
package/dist/core.mjs
CHANGED
|
@@ -17,6 +17,18 @@ const unwrapExport = (node) => {
|
|
|
17
17
|
const isFunctionNode = (node) => node?.type === 'FunctionDeclaration' ||
|
|
18
18
|
node?.type === 'FunctionExpression' ||
|
|
19
19
|
node?.type === 'ArrowFunctionExpression';
|
|
20
|
+
const componentFunctionOf = (node) => {
|
|
21
|
+
if (isFunctionNode(node))
|
|
22
|
+
return node;
|
|
23
|
+
if (node?.type === 'CallExpression') {
|
|
24
|
+
for (const arg of node.arguments ?? []) {
|
|
25
|
+
const fn = componentFunctionOf(arg.expression);
|
|
26
|
+
if (fn)
|
|
27
|
+
return fn;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
};
|
|
20
32
|
const isStaticArgValue = (node) => node.type === 'StringLiteral' ||
|
|
21
33
|
node.type === 'NumericLiteral' ||
|
|
22
34
|
node.type === 'BooleanLiteral' ||
|
|
@@ -298,13 +310,18 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
298
310
|
node: statement,
|
|
299
311
|
});
|
|
300
312
|
}
|
|
313
|
+
else if (statement?.type === 'CallExpression') {
|
|
314
|
+
const fn = componentFunctionOf(statement);
|
|
315
|
+
if (fn)
|
|
316
|
+
components.push({ name: 'default', node: fn });
|
|
317
|
+
}
|
|
301
318
|
else if (t.isVariableDeclaration(statement)) {
|
|
302
319
|
for (const decl of statement.declarations) {
|
|
303
|
-
if (t.isIdentifier(decl.id)
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
320
|
+
if (!t.isIdentifier(decl.id))
|
|
321
|
+
continue;
|
|
322
|
+
const fn = componentFunctionOf(decl.init);
|
|
323
|
+
if (fn)
|
|
324
|
+
components.push({ name: decl.id.value, node: fn });
|
|
308
325
|
}
|
|
309
326
|
}
|
|
310
327
|
}
|
|
@@ -826,12 +843,18 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
826
843
|
if (isFunctionNode(statement)) {
|
|
827
844
|
addFirstParamName(statement);
|
|
828
845
|
}
|
|
846
|
+
else if (statement?.type === 'CallExpression') {
|
|
847
|
+
const fn = componentFunctionOf(statement);
|
|
848
|
+
if (fn)
|
|
849
|
+
addFirstParamName(fn);
|
|
850
|
+
}
|
|
829
851
|
else if (t.isVariableDeclaration(statement)) {
|
|
830
852
|
for (const decl of statement.declarations) {
|
|
831
853
|
if (!t.isIdentifier(decl.id) || !decl.init)
|
|
832
854
|
continue;
|
|
833
|
-
|
|
834
|
-
|
|
855
|
+
const fn = componentFunctionOf(decl.init);
|
|
856
|
+
if (fn)
|
|
857
|
+
addFirstParamName(fn);
|
|
835
858
|
}
|
|
836
859
|
}
|
|
837
860
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/unplugin",
|
|
3
|
-
"version": "18.3.
|
|
3
|
+
"version": "18.3.14",
|
|
4
4
|
"description": "Universal Plumeria plugin for various build tools",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"dependencies": {
|
|
95
95
|
"@rollup/pluginutils": "^5.4.0",
|
|
96
96
|
"unplugin": "^3.0.0",
|
|
97
|
-
"@plumeria/utils": "^18.3.
|
|
97
|
+
"@plumeria/utils": "^18.3.14"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@swc/core": "1.15.47",
|