@plumeria/unplugin 18.3.11 → 18.3.13
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 +39 -29
- package/dist/core.mjs +39 -29
- package/package.json +2 -2
package/dist/core.js
CHANGED
|
@@ -41,6 +41,18 @@ const zss_engine_1 = require("zss-engine");
|
|
|
41
41
|
const utils_1 = require("@plumeria/utils");
|
|
42
42
|
exports.TARGET_EXTENSIONS = ['ts', 'tsx', 'js', 'jsx'];
|
|
43
43
|
exports.EXTENSION_PATTERN = /\.(ts|tsx|js|jsx)$/;
|
|
44
|
+
const unwrapExport = (node) => {
|
|
45
|
+
if (node?.type === 'ExportDeclaration')
|
|
46
|
+
return node.declaration;
|
|
47
|
+
if (node?.type === 'ExportDefaultDeclaration')
|
|
48
|
+
return node.decl;
|
|
49
|
+
if (node?.type === 'ExportDefaultExpression')
|
|
50
|
+
return node.expression;
|
|
51
|
+
return node;
|
|
52
|
+
};
|
|
53
|
+
const isFunctionNode = (node) => node?.type === 'FunctionDeclaration' ||
|
|
54
|
+
node?.type === 'FunctionExpression' ||
|
|
55
|
+
node?.type === 'ArrowFunctionExpression';
|
|
44
56
|
const isStaticArgValue = (node) => node.type === 'StringLiteral' ||
|
|
45
57
|
node.type === 'NumericLiteral' ||
|
|
46
58
|
node.type === 'BooleanLiteral' ||
|
|
@@ -315,10 +327,10 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
315
327
|
}
|
|
316
328
|
const components = [];
|
|
317
329
|
for (const node of ast.body) {
|
|
318
|
-
const statement =
|
|
319
|
-
if (statement
|
|
330
|
+
const statement = unwrapExport(node);
|
|
331
|
+
if (isFunctionNode(statement)) {
|
|
320
332
|
components.push({
|
|
321
|
-
name: statement.identifier
|
|
333
|
+
name: statement.identifier?.value ?? 'default',
|
|
322
334
|
node: statement,
|
|
323
335
|
});
|
|
324
336
|
}
|
|
@@ -836,30 +848,26 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
836
848
|
});
|
|
837
849
|
const jsxOpeningElementMap = new Map();
|
|
838
850
|
const componentParamNames = new Set();
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
if (utils_1.t.
|
|
842
|
-
|
|
851
|
+
const addFirstParamName = (fn) => {
|
|
852
|
+
const p = fn.params[0];
|
|
853
|
+
if (utils_1.t.isIdentifier(p)) {
|
|
854
|
+
componentParamNames.add(p.value);
|
|
843
855
|
}
|
|
844
|
-
else if (utils_1.t.
|
|
845
|
-
|
|
846
|
-
declarations = node.declaration.declarations;
|
|
856
|
+
else if (p?.pat && utils_1.t.isIdentifier(p.pat)) {
|
|
857
|
+
componentParamNames.add(p.pat.value);
|
|
847
858
|
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
else if (p.pat && utils_1.t.isIdentifier(p.pat)) {
|
|
861
|
-
componentParamNames.add(p.pat.value);
|
|
862
|
-
}
|
|
859
|
+
};
|
|
860
|
+
for (const node of ast.body) {
|
|
861
|
+
const statement = unwrapExport(node);
|
|
862
|
+
if (isFunctionNode(statement)) {
|
|
863
|
+
addFirstParamName(statement);
|
|
864
|
+
}
|
|
865
|
+
else if (utils_1.t.isVariableDeclaration(statement)) {
|
|
866
|
+
for (const decl of statement.declarations) {
|
|
867
|
+
if (!utils_1.t.isIdentifier(decl.id) || !decl.init)
|
|
868
|
+
continue;
|
|
869
|
+
if (isFunctionNode(decl.init))
|
|
870
|
+
addFirstParamName(decl.init);
|
|
863
871
|
}
|
|
864
872
|
}
|
|
865
873
|
}
|
|
@@ -1270,14 +1278,16 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1270
1278
|
? scannedTables.componentPropsTable?.[`${resourcePath}-${owner}`]?.[varName]
|
|
1271
1279
|
: undefined;
|
|
1272
1280
|
if (!possibilities) {
|
|
1281
|
+
const candidates = [];
|
|
1273
1282
|
for (const key of Object.keys(scannedTables.componentPropsTable || {})) {
|
|
1274
1283
|
if (!key.startsWith(`${resourcePath}-`))
|
|
1275
1284
|
continue;
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
}
|
|
1285
|
+
const entries = scannedTables.componentPropsTable?.[key]?.[varName];
|
|
1286
|
+
if (entries)
|
|
1287
|
+
candidates.push(...entries);
|
|
1280
1288
|
}
|
|
1289
|
+
if (candidates.length > 0)
|
|
1290
|
+
possibilities = candidates;
|
|
1281
1291
|
}
|
|
1282
1292
|
if (!possibilities || possibilities.length === 0)
|
|
1283
1293
|
return false;
|
package/dist/core.mjs
CHANGED
|
@@ -5,6 +5,18 @@ import { applyCssValue, genBase36Hash, exceptionCamelCase, camelToKebabCase, isA
|
|
|
5
5
|
import { traverse, collectReferenceIdentifiers, getStyleRecords, getStateWeights, collectLocalConsts, objectExpressionToObject, t, getRootIdentifier, extractOndemandStyles, deepMerge, scanAll, resolveImportPath, getLeadingCommentLength, optimizer, themeHashOf, getFileDependencies, resolveExport, resolveComponentKey, resolveThemeSelector, DEFAULT_STYLE_PROP, } from '@plumeria/utils';
|
|
6
6
|
export const TARGET_EXTENSIONS = ['ts', 'tsx', 'js', 'jsx'];
|
|
7
7
|
export const EXTENSION_PATTERN = /\.(ts|tsx|js|jsx)$/;
|
|
8
|
+
const unwrapExport = (node) => {
|
|
9
|
+
if (node?.type === 'ExportDeclaration')
|
|
10
|
+
return node.declaration;
|
|
11
|
+
if (node?.type === 'ExportDefaultDeclaration')
|
|
12
|
+
return node.decl;
|
|
13
|
+
if (node?.type === 'ExportDefaultExpression')
|
|
14
|
+
return node.expression;
|
|
15
|
+
return node;
|
|
16
|
+
};
|
|
17
|
+
const isFunctionNode = (node) => node?.type === 'FunctionDeclaration' ||
|
|
18
|
+
node?.type === 'FunctionExpression' ||
|
|
19
|
+
node?.type === 'ArrowFunctionExpression';
|
|
8
20
|
const isStaticArgValue = (node) => node.type === 'StringLiteral' ||
|
|
9
21
|
node.type === 'NumericLiteral' ||
|
|
10
22
|
node.type === 'BooleanLiteral' ||
|
|
@@ -279,10 +291,10 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
279
291
|
}
|
|
280
292
|
const components = [];
|
|
281
293
|
for (const node of ast.body) {
|
|
282
|
-
const statement =
|
|
283
|
-
if (statement
|
|
294
|
+
const statement = unwrapExport(node);
|
|
295
|
+
if (isFunctionNode(statement)) {
|
|
284
296
|
components.push({
|
|
285
|
-
name: statement.identifier
|
|
297
|
+
name: statement.identifier?.value ?? 'default',
|
|
286
298
|
node: statement,
|
|
287
299
|
});
|
|
288
300
|
}
|
|
@@ -800,30 +812,26 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
800
812
|
});
|
|
801
813
|
const jsxOpeningElementMap = new Map();
|
|
802
814
|
const componentParamNames = new Set();
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
if (t.
|
|
806
|
-
|
|
815
|
+
const addFirstParamName = (fn) => {
|
|
816
|
+
const p = fn.params[0];
|
|
817
|
+
if (t.isIdentifier(p)) {
|
|
818
|
+
componentParamNames.add(p.value);
|
|
807
819
|
}
|
|
808
|
-
else if (t.
|
|
809
|
-
|
|
810
|
-
declarations = node.declaration.declarations;
|
|
820
|
+
else if (p?.pat && t.isIdentifier(p.pat)) {
|
|
821
|
+
componentParamNames.add(p.pat.value);
|
|
811
822
|
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
else if (p.pat && t.isIdentifier(p.pat)) {
|
|
825
|
-
componentParamNames.add(p.pat.value);
|
|
826
|
-
}
|
|
823
|
+
};
|
|
824
|
+
for (const node of ast.body) {
|
|
825
|
+
const statement = unwrapExport(node);
|
|
826
|
+
if (isFunctionNode(statement)) {
|
|
827
|
+
addFirstParamName(statement);
|
|
828
|
+
}
|
|
829
|
+
else if (t.isVariableDeclaration(statement)) {
|
|
830
|
+
for (const decl of statement.declarations) {
|
|
831
|
+
if (!t.isIdentifier(decl.id) || !decl.init)
|
|
832
|
+
continue;
|
|
833
|
+
if (isFunctionNode(decl.init))
|
|
834
|
+
addFirstParamName(decl.init);
|
|
827
835
|
}
|
|
828
836
|
}
|
|
829
837
|
}
|
|
@@ -1234,14 +1242,16 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1234
1242
|
? scannedTables.componentPropsTable?.[`${resourcePath}-${owner}`]?.[varName]
|
|
1235
1243
|
: undefined;
|
|
1236
1244
|
if (!possibilities) {
|
|
1245
|
+
const candidates = [];
|
|
1237
1246
|
for (const key of Object.keys(scannedTables.componentPropsTable || {})) {
|
|
1238
1247
|
if (!key.startsWith(`${resourcePath}-`))
|
|
1239
1248
|
continue;
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
}
|
|
1249
|
+
const entries = scannedTables.componentPropsTable?.[key]?.[varName];
|
|
1250
|
+
if (entries)
|
|
1251
|
+
candidates.push(...entries);
|
|
1244
1252
|
}
|
|
1253
|
+
if (candidates.length > 0)
|
|
1254
|
+
possibilities = candidates;
|
|
1245
1255
|
}
|
|
1246
1256
|
if (!possibilities || possibilities.length === 0)
|
|
1247
1257
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/unplugin",
|
|
3
|
-
"version": "18.3.
|
|
3
|
+
"version": "18.3.13",
|
|
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.13"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@swc/core": "1.15.47",
|