@pandacss/parser 0.15.1 → 0.15.3

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 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) => o.mod.includes(mod) || o.importMapValue === mod);
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) => {
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) => o.mod.includes(mod) || o.importMapValue === mod);
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) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/parser",
3
- "version": "0.15.1",
3
+ "version": "0.15.3",
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.1",
20
- "@pandacss/extractor": "0.15.1",
21
- "@pandacss/is-valid-prop": "0.15.1",
22
- "@pandacss/logger": "0.15.1",
23
- "@pandacss/shared": "0.15.1",
24
- "@pandacss/types": "0.15.1"
19
+ "@pandacss/config": "^0.15.3",
20
+ "@pandacss/extractor": "0.15.3",
21
+ "@pandacss/is-valid-prop": "0.15.3",
22
+ "@pandacss/logger": "0.15.3",
23
+ "@pandacss/shared": "0.15.3",
24
+ "@pandacss/types": "0.15.3"
25
25
  },
26
26
  "devDependencies": {
27
27
  "hookable": "5.5.3",
28
- "@pandacss/fixture": "0.15.1",
29
- "@pandacss/generator": "0.15.1"
28
+ "@pandacss/fixture": "0.15.3",
29
+ "@pandacss/generator": "0.15.3"
30
30
  },
31
31
  "files": [
32
32
  "dist"