@pandacss/parser 0.15.2 → 0.15.4
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.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +26 -8
- package/dist/index.mjs +26 -8
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -42,12 +42,15 @@ type ParserRecipeNode = Generator['recipes']['details'][number];
|
|
|
42
42
|
type ParserNodeOptions = ParserPatternNode | ParserRecipeNode;
|
|
43
43
|
type ParserOptions = {
|
|
44
44
|
importMap: Record<'css' | 'recipe' | 'pattern' | 'jsx', string[]>;
|
|
45
|
-
jsx
|
|
45
|
+
jsx: {
|
|
46
|
+
framework: string | undefined;
|
|
46
47
|
factory: string;
|
|
47
48
|
styleProps: Exclude<Config['jsxStyleProps'], undefined>;
|
|
48
49
|
nodes: ParserNodeOptions[];
|
|
49
50
|
isStyleProp: (prop: string) => boolean;
|
|
50
51
|
};
|
|
52
|
+
patternKeys: string[];
|
|
53
|
+
recipeKeys: string[];
|
|
51
54
|
getRecipesByJsxName: (jsxName: string) => ParserRecipeNode[];
|
|
52
55
|
getPatternsByJsxName: (jsxName: string) => ParserPatternNode[];
|
|
53
56
|
tsOptions?: ConfigTsOptions;
|
package/dist/index.d.ts
CHANGED
|
@@ -42,12 +42,15 @@ type ParserRecipeNode = Generator['recipes']['details'][number];
|
|
|
42
42
|
type ParserNodeOptions = ParserPatternNode | ParserRecipeNode;
|
|
43
43
|
type ParserOptions = {
|
|
44
44
|
importMap: Record<'css' | 'recipe' | 'pattern' | 'jsx', string[]>;
|
|
45
|
-
jsx
|
|
45
|
+
jsx: {
|
|
46
|
+
framework: string | undefined;
|
|
46
47
|
factory: string;
|
|
47
48
|
styleProps: Exclude<Config['jsxStyleProps'], undefined>;
|
|
48
49
|
nodes: ParserNodeOptions[];
|
|
49
50
|
isStyleProp: (prop: string) => boolean;
|
|
50
51
|
};
|
|
52
|
+
patternKeys: string[];
|
|
53
|
+
recipeKeys: string[];
|
|
51
54
|
getRecipesByJsxName: (jsxName: string) => ParserRecipeNode[];
|
|
52
55
|
getPatternsByJsxName: (jsxName: string) => ParserPatternNode[];
|
|
53
56
|
tsOptions?: ConfigTsOptions;
|
package/dist/index.js
CHANGED
|
@@ -81,8 +81,12 @@ function getImportDeclarations(file, options) {
|
|
|
81
81
|
find(id) {
|
|
82
82
|
return result.find((o) => o.alias === id);
|
|
83
83
|
},
|
|
84
|
-
createMatch(mod) {
|
|
85
|
-
const mods = result.filter((o) =>
|
|
84
|
+
createMatch(mod, keys) {
|
|
85
|
+
const mods = result.filter((o) => {
|
|
86
|
+
const isFromMod = o.mod.includes(mod) || o.importMapValue === mod;
|
|
87
|
+
const isOneOfKeys = keys.includes(o.name);
|
|
88
|
+
return isFromMod && isOneOfKeys;
|
|
89
|
+
});
|
|
86
90
|
return (0, import_shared.memo)((id) => !!mods.find((mod2) => mod2.alias === id || mod2.name === id));
|
|
87
91
|
},
|
|
88
92
|
match(id) {
|
|
@@ -217,7 +221,7 @@ function createParser(options) {
|
|
|
217
221
|
createImportMatcher(importMap.recipe),
|
|
218
222
|
createImportMatcher(importMap.pattern)
|
|
219
223
|
];
|
|
220
|
-
if (jsx) {
|
|
224
|
+
if (jsx.framework) {
|
|
221
225
|
importRegex.push(createImportMatcher(importMap.jsx, [jsx.factory, ...jsx.nodes.map((node) => node.jsxName)]));
|
|
222
226
|
}
|
|
223
227
|
return function parse2(sourceFile) {
|
|
@@ -252,8 +256,8 @@ function createParser(options) {
|
|
|
252
256
|
);
|
|
253
257
|
const [css] = importRegex;
|
|
254
258
|
const jsxFactoryAlias = jsx ? imports.getAlias(jsx.factory) : "styled";
|
|
255
|
-
const isValidPattern = imports.createMatch(importMap.pattern);
|
|
256
|
-
const isValidRecipe = imports.createMatch(importMap.recipe);
|
|
259
|
+
const isValidPattern = imports.createMatch(importMap.pattern, options.patternKeys);
|
|
260
|
+
const isValidRecipe = imports.createMatch(importMap.recipe, options.recipeKeys);
|
|
257
261
|
const isValidStyleFn = (name) => name === jsx?.factory;
|
|
258
262
|
const isFactory = (name) => Boolean(jsx && name.startsWith(jsxFactoryAlias));
|
|
259
263
|
const isRawFn = (fullName) => {
|
|
@@ -289,10 +293,10 @@ function createParser(options) {
|
|
|
289
293
|
const functions = /* @__PURE__ */ new Map();
|
|
290
294
|
const components = /* @__PURE__ */ new Map();
|
|
291
295
|
const propertiesMap = /* @__PURE__ */ new Map();
|
|
292
|
-
const
|
|
296
|
+
const recipePropertiesByJsxName = /* @__PURE__ */ new Map();
|
|
293
297
|
const recipeJsxLists = (jsx?.nodes ?? []).filter(isNodeRecipe).reduce(
|
|
294
298
|
(acc, recipe) => {
|
|
295
|
-
|
|
299
|
+
recipePropertiesByJsxName.set(recipe.jsxName, new Set(recipe.props ?? []));
|
|
296
300
|
recipe.jsx?.forEach((jsx2) => {
|
|
297
301
|
if (typeof jsx2 === "string") {
|
|
298
302
|
acc.string.add(jsx2);
|
|
@@ -330,7 +334,7 @@ function createParser(options) {
|
|
|
330
334
|
const isRecipeOrPatternProp = (0, import_shared2.memo)((tagName, propName) => {
|
|
331
335
|
if (isJsxTagRecipe(tagName)) {
|
|
332
336
|
const recipeList = getRecipesByJsxName(tagName);
|
|
333
|
-
return recipeList.some((recipe) =>
|
|
337
|
+
return recipeList.some((recipe) => recipePropertiesByJsxName.get(recipe.jsxName)?.has(propName));
|
|
334
338
|
}
|
|
335
339
|
if (isJsxTagPattern(tagName)) {
|
|
336
340
|
const patternList = getPatternsByJsxName(tagName);
|
|
@@ -455,6 +459,20 @@ function createParser(options) {
|
|
|
455
459
|
} else {
|
|
456
460
|
collector.set("css", result2);
|
|
457
461
|
}
|
|
462
|
+
const options2 = query.box.value[2];
|
|
463
|
+
if (import_extractor.box.isUnresolvable(map) && options2 && import_extractor.box.isMap(options2) && options2.value.has("defaultProps")) {
|
|
464
|
+
const maybeIdentifier = map.getNode();
|
|
465
|
+
if (import_ts_morph.Node.isIdentifier(maybeIdentifier)) {
|
|
466
|
+
const name2 = maybeIdentifier.getText();
|
|
467
|
+
const recipeName = imports.getName(name2);
|
|
468
|
+
collector.setRecipe(recipeName, {
|
|
469
|
+
type: "jsx-recipe",
|
|
470
|
+
name: recipeName,
|
|
471
|
+
box: options2,
|
|
472
|
+
data: combineResult((0, import_extractor.unbox)(options2.value.get("defaultProps")))
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
}
|
|
458
476
|
} else if (query.kind === "tagged-template") {
|
|
459
477
|
const obj = (0, import_shared2.astish)(query.box.value);
|
|
460
478
|
collector.set("css", {
|
package/dist/index.mjs
CHANGED
|
@@ -43,8 +43,12 @@ function getImportDeclarations(file, options) {
|
|
|
43
43
|
find(id) {
|
|
44
44
|
return result.find((o) => o.alias === id);
|
|
45
45
|
},
|
|
46
|
-
createMatch(mod) {
|
|
47
|
-
const mods = result.filter((o) =>
|
|
46
|
+
createMatch(mod, keys) {
|
|
47
|
+
const mods = result.filter((o) => {
|
|
48
|
+
const isFromMod = o.mod.includes(mod) || o.importMapValue === mod;
|
|
49
|
+
const isOneOfKeys = keys.includes(o.name);
|
|
50
|
+
return isFromMod && isOneOfKeys;
|
|
51
|
+
});
|
|
48
52
|
return memo((id) => !!mods.find((mod2) => mod2.alias === id || mod2.name === id));
|
|
49
53
|
},
|
|
50
54
|
match(id) {
|
|
@@ -179,7 +183,7 @@ function createParser(options) {
|
|
|
179
183
|
createImportMatcher(importMap.recipe),
|
|
180
184
|
createImportMatcher(importMap.pattern)
|
|
181
185
|
];
|
|
182
|
-
if (jsx) {
|
|
186
|
+
if (jsx.framework) {
|
|
183
187
|
importRegex.push(createImportMatcher(importMap.jsx, [jsx.factory, ...jsx.nodes.map((node) => node.jsxName)]));
|
|
184
188
|
}
|
|
185
189
|
return function parse2(sourceFile) {
|
|
@@ -214,8 +218,8 @@ function createParser(options) {
|
|
|
214
218
|
);
|
|
215
219
|
const [css] = importRegex;
|
|
216
220
|
const jsxFactoryAlias = jsx ? imports.getAlias(jsx.factory) : "styled";
|
|
217
|
-
const isValidPattern = imports.createMatch(importMap.pattern);
|
|
218
|
-
const isValidRecipe = imports.createMatch(importMap.recipe);
|
|
221
|
+
const isValidPattern = imports.createMatch(importMap.pattern, options.patternKeys);
|
|
222
|
+
const isValidRecipe = imports.createMatch(importMap.recipe, options.recipeKeys);
|
|
219
223
|
const isValidStyleFn = (name) => name === jsx?.factory;
|
|
220
224
|
const isFactory = (name) => Boolean(jsx && name.startsWith(jsxFactoryAlias));
|
|
221
225
|
const isRawFn = (fullName) => {
|
|
@@ -251,10 +255,10 @@ function createParser(options) {
|
|
|
251
255
|
const functions = /* @__PURE__ */ new Map();
|
|
252
256
|
const components = /* @__PURE__ */ new Map();
|
|
253
257
|
const propertiesMap = /* @__PURE__ */ new Map();
|
|
254
|
-
const
|
|
258
|
+
const recipePropertiesByJsxName = /* @__PURE__ */ new Map();
|
|
255
259
|
const recipeJsxLists = (jsx?.nodes ?? []).filter(isNodeRecipe).reduce(
|
|
256
260
|
(acc, recipe) => {
|
|
257
|
-
|
|
261
|
+
recipePropertiesByJsxName.set(recipe.jsxName, new Set(recipe.props ?? []));
|
|
258
262
|
recipe.jsx?.forEach((jsx2) => {
|
|
259
263
|
if (typeof jsx2 === "string") {
|
|
260
264
|
acc.string.add(jsx2);
|
|
@@ -292,7 +296,7 @@ function createParser(options) {
|
|
|
292
296
|
const isRecipeOrPatternProp = memo2((tagName, propName) => {
|
|
293
297
|
if (isJsxTagRecipe(tagName)) {
|
|
294
298
|
const recipeList = getRecipesByJsxName(tagName);
|
|
295
|
-
return recipeList.some((recipe) =>
|
|
299
|
+
return recipeList.some((recipe) => recipePropertiesByJsxName.get(recipe.jsxName)?.has(propName));
|
|
296
300
|
}
|
|
297
301
|
if (isJsxTagPattern(tagName)) {
|
|
298
302
|
const patternList = getPatternsByJsxName(tagName);
|
|
@@ -417,6 +421,20 @@ function createParser(options) {
|
|
|
417
421
|
} else {
|
|
418
422
|
collector.set("css", result2);
|
|
419
423
|
}
|
|
424
|
+
const options2 = query.box.value[2];
|
|
425
|
+
if (box.isUnresolvable(map) && options2 && box.isMap(options2) && options2.value.has("defaultProps")) {
|
|
426
|
+
const maybeIdentifier = map.getNode();
|
|
427
|
+
if (Node.isIdentifier(maybeIdentifier)) {
|
|
428
|
+
const name2 = maybeIdentifier.getText();
|
|
429
|
+
const recipeName = imports.getName(name2);
|
|
430
|
+
collector.setRecipe(recipeName, {
|
|
431
|
+
type: "jsx-recipe",
|
|
432
|
+
name: recipeName,
|
|
433
|
+
box: options2,
|
|
434
|
+
data: combineResult(unbox(options2.value.get("defaultProps")))
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
}
|
|
420
438
|
} else if (query.kind === "tagged-template") {
|
|
421
439
|
const obj = astish(query.box.value);
|
|
422
440
|
collector.set("css", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/parser",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.4",
|
|
4
4
|
"description": "The static parser for panda css",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
"magic-string": "^0.30.2",
|
|
17
17
|
"ts-morph": "19.0.0",
|
|
18
18
|
"ts-pattern": "5.0.5",
|
|
19
|
-
"@pandacss/config": "^0.15.
|
|
20
|
-
"@pandacss/extractor": "0.15.
|
|
21
|
-
"@pandacss/is-valid-prop": "0.15.
|
|
22
|
-
"@pandacss/logger": "0.15.
|
|
23
|
-
"@pandacss/shared": "0.15.
|
|
24
|
-
"@pandacss/types": "0.15.
|
|
19
|
+
"@pandacss/config": "^0.15.4",
|
|
20
|
+
"@pandacss/extractor": "0.15.4",
|
|
21
|
+
"@pandacss/is-valid-prop": "0.15.4",
|
|
22
|
+
"@pandacss/logger": "0.15.4",
|
|
23
|
+
"@pandacss/shared": "0.15.4",
|
|
24
|
+
"@pandacss/types": "0.15.4"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"hookable": "5.5.3",
|
|
28
|
-
"@pandacss/fixture": "0.15.
|
|
29
|
-
"@pandacss/generator": "0.15.
|
|
28
|
+
"@pandacss/fixture": "0.15.4",
|
|
29
|
+
"@pandacss/generator": "0.15.4"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"dist"
|