@pandacss/parser 0.0.0-dev-20230418111141 → 0.0.0-dev-20230419091337

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.ts CHANGED
@@ -37,7 +37,7 @@ declare const createProject: ({ getFiles, readFile, parserOptions, ...projectOpt
37
37
  getSourceFile: (filePath: string) => ts_morph.SourceFile | undefined;
38
38
  removeSourceFile: (filePath: string) => void;
39
39
  createSourceFile: (filePath: string) => ts_morph.SourceFile;
40
- parseSourceFile: (filePath: string, properties: string[]) => _pandacss_types.ParserResult | undefined;
40
+ parseSourceFile: (filePath: string) => _pandacss_types.ParserResult | undefined;
41
41
  reloadSourceFile: (filePath: string) => ts_morph.FileSystemRefreshResult | undefined;
42
42
  reloadSourceFiles: () => void;
43
43
  };
package/dist/index.js CHANGED
@@ -132,7 +132,7 @@ var combineResult = (unboxed) => {
132
132
  };
133
133
  var defaultEnv = { preset: "NONE" };
134
134
  function createParser(options) {
135
- return function parse(sourceFile, styleProperties) {
135
+ return function parse(sourceFile) {
136
136
  if (!sourceFile)
137
137
  return;
138
138
  const filePath = sourceFile.getFilePath();
@@ -175,7 +175,7 @@ function createParser(options) {
175
175
  });
176
176
  const functions = /* @__PURE__ */ new Map();
177
177
  const components = /* @__PURE__ */ new Map();
178
- const propertiesMap = new Map(styleProperties.map((prop) => [prop, true]));
178
+ const propertiesMap = /* @__PURE__ */ new Map();
179
179
  const recipePropertiesByName = /* @__PURE__ */ new Map();
180
180
  const recipeJsxLists = (jsx?.nodes ?? []).filter(isNodeRecipe).reduce(
181
181
  (acc, recipe) => {
@@ -195,12 +195,11 @@ function createParser(options) {
195
195
  const cssAlias = imports.getAlias("css");
196
196
  if (options.jsx) {
197
197
  options.jsx.nodes.forEach((node) => {
198
- const properties = node.props ? new Map(propertiesMap) : propertiesMap;
199
198
  const alias = imports.getAlias(node.name);
200
- node.props?.forEach((prop) => properties.set(prop, true));
201
- functions.set(node.baseName, properties);
202
- functions.set(alias, properties);
203
- components.set(alias, properties);
199
+ node.props?.forEach((prop) => propertiesMap.set(prop, true));
200
+ functions.set(node.baseName, propertiesMap);
201
+ functions.set(alias, propertiesMap);
202
+ components.set(alias, propertiesMap);
204
203
  });
205
204
  }
206
205
  const getRecipeName = (0, import_shared2.memo)(options.getRecipeName);
@@ -215,13 +214,11 @@ function createParser(options) {
215
214
  const matchTagProp = (0, import_shared2.memo)((tagName, propName) => {
216
215
  if (propertiesMap.size === 0)
217
216
  return true;
218
- if (Boolean(components.get(tagName)?.get(propName)) || propertiesMap.has(propName))
217
+ if (Boolean(components.get(tagName)?.has(propName)) || options.jsx?.isStyleProp(propName) || propertiesMap.has(propName))
219
218
  return true;
220
219
  if (isJsxTagRecipe(tagName)) {
221
220
  const recipe = getRecipeByName(getRecipeName(tagName));
222
- if (recipe) {
223
- return recipePropertiesByName.get(recipe.name)?.has(propName) ?? false;
224
- }
221
+ return recipe != null && !!recipePropertiesByName.get(recipe.name)?.has(propName);
225
222
  }
226
223
  return false;
227
224
  });
@@ -230,20 +227,7 @@ function createParser(options) {
230
227
  return true;
231
228
  if (fnName === cvaAlias || fnName === cssAlias || fnName.startsWith(jsxFactoryAlias))
232
229
  return true;
233
- return Boolean(functions.get(fnName));
234
- });
235
- const matchFnProp = (0, import_shared2.memo)((fnName, propName) => {
236
- if (propertiesMap.size === 0)
237
- return true;
238
- if (recipes.has(fnName) || patterns.has(fnName))
239
- return true;
240
- if (fnName === cvaAlias)
241
- return true;
242
- if (fnName.startsWith(jsxFactoryAlias))
243
- return true;
244
- if (fnName === cssAlias)
245
- return Boolean(propertiesMap.get(propName) || propName === "selectors");
246
- return Boolean(functions.get(fnName)?.get(propName));
230
+ return functions.has(fnName);
247
231
  });
248
232
  const measure = import_logger.logger.time.debug(`Tokens extracted from ${filePath}`);
249
233
  const extractResultByName = (0, import_extractor.extract)({
@@ -254,7 +238,7 @@ function createParser(options) {
254
238
  },
255
239
  functions: {
256
240
  matchFn: (prop) => matchFn(prop.fnName),
257
- matchProp: (prop) => matchFnProp(prop.fnName, prop.propName),
241
+ matchProp: () => true,
258
242
  matchArg: (prop) => {
259
243
  if (prop.fnName === jsxFactoryAlias && prop.index === 1 && import_ts_morph.Node.isIdentifier(prop.argNode))
260
244
  return false;
@@ -331,7 +315,7 @@ function createParser(options) {
331
315
  return collector;
332
316
  };
333
317
  }
334
- var isUpperCase = (value) => value[0] === value[0].toUpperCase();
318
+ var isUpperCase = (value) => value[0] === value[0]?.toUpperCase();
335
319
 
336
320
  // src/project.ts
337
321
  var createTsProject = (options) => new import_ts_morph2.Project({
@@ -362,8 +346,8 @@ var createProject = ({ getFiles, readFile, parserOptions, ...projectOptions }) =
362
346
  overwrite: true,
363
347
  scriptKind: import_ts_morph2.ScriptKind.TSX
364
348
  }),
365
- parseSourceFile: (filePath, properties) => {
366
- return parser(project.getSourceFile(filePath), properties);
349
+ parseSourceFile: (filePath) => {
350
+ return parser(project.getSourceFile(filePath));
367
351
  }
368
352
  })),
369
353
  (0, import_lil_fp.tap)(({ createSourceFile }) => {
package/dist/index.mjs CHANGED
@@ -106,7 +106,7 @@ var combineResult = (unboxed) => {
106
106
  };
107
107
  var defaultEnv = { preset: "NONE" };
108
108
  function createParser(options) {
109
- return function parse(sourceFile, styleProperties) {
109
+ return function parse(sourceFile) {
110
110
  if (!sourceFile)
111
111
  return;
112
112
  const filePath = sourceFile.getFilePath();
@@ -149,7 +149,7 @@ function createParser(options) {
149
149
  });
150
150
  const functions = /* @__PURE__ */ new Map();
151
151
  const components = /* @__PURE__ */ new Map();
152
- const propertiesMap = new Map(styleProperties.map((prop) => [prop, true]));
152
+ const propertiesMap = /* @__PURE__ */ new Map();
153
153
  const recipePropertiesByName = /* @__PURE__ */ new Map();
154
154
  const recipeJsxLists = (jsx?.nodes ?? []).filter(isNodeRecipe).reduce(
155
155
  (acc, recipe) => {
@@ -169,12 +169,11 @@ function createParser(options) {
169
169
  const cssAlias = imports.getAlias("css");
170
170
  if (options.jsx) {
171
171
  options.jsx.nodes.forEach((node) => {
172
- const properties = node.props ? new Map(propertiesMap) : propertiesMap;
173
172
  const alias = imports.getAlias(node.name);
174
- node.props?.forEach((prop) => properties.set(prop, true));
175
- functions.set(node.baseName, properties);
176
- functions.set(alias, properties);
177
- components.set(alias, properties);
173
+ node.props?.forEach((prop) => propertiesMap.set(prop, true));
174
+ functions.set(node.baseName, propertiesMap);
175
+ functions.set(alias, propertiesMap);
176
+ components.set(alias, propertiesMap);
178
177
  });
179
178
  }
180
179
  const getRecipeName = memo2(options.getRecipeName);
@@ -189,13 +188,11 @@ function createParser(options) {
189
188
  const matchTagProp = memo2((tagName, propName) => {
190
189
  if (propertiesMap.size === 0)
191
190
  return true;
192
- if (Boolean(components.get(tagName)?.get(propName)) || propertiesMap.has(propName))
191
+ if (Boolean(components.get(tagName)?.has(propName)) || options.jsx?.isStyleProp(propName) || propertiesMap.has(propName))
193
192
  return true;
194
193
  if (isJsxTagRecipe(tagName)) {
195
194
  const recipe = getRecipeByName(getRecipeName(tagName));
196
- if (recipe) {
197
- return recipePropertiesByName.get(recipe.name)?.has(propName) ?? false;
198
- }
195
+ return recipe != null && !!recipePropertiesByName.get(recipe.name)?.has(propName);
199
196
  }
200
197
  return false;
201
198
  });
@@ -204,20 +201,7 @@ function createParser(options) {
204
201
  return true;
205
202
  if (fnName === cvaAlias || fnName === cssAlias || fnName.startsWith(jsxFactoryAlias))
206
203
  return true;
207
- return Boolean(functions.get(fnName));
208
- });
209
- const matchFnProp = memo2((fnName, propName) => {
210
- if (propertiesMap.size === 0)
211
- return true;
212
- if (recipes.has(fnName) || patterns.has(fnName))
213
- return true;
214
- if (fnName === cvaAlias)
215
- return true;
216
- if (fnName.startsWith(jsxFactoryAlias))
217
- return true;
218
- if (fnName === cssAlias)
219
- return Boolean(propertiesMap.get(propName) || propName === "selectors");
220
- return Boolean(functions.get(fnName)?.get(propName));
204
+ return functions.has(fnName);
221
205
  });
222
206
  const measure = logger.time.debug(`Tokens extracted from ${filePath}`);
223
207
  const extractResultByName = extract({
@@ -228,7 +212,7 @@ function createParser(options) {
228
212
  },
229
213
  functions: {
230
214
  matchFn: (prop) => matchFn(prop.fnName),
231
- matchProp: (prop) => matchFnProp(prop.fnName, prop.propName),
215
+ matchProp: () => true,
232
216
  matchArg: (prop) => {
233
217
  if (prop.fnName === jsxFactoryAlias && prop.index === 1 && Node.isIdentifier(prop.argNode))
234
218
  return false;
@@ -305,7 +289,7 @@ function createParser(options) {
305
289
  return collector;
306
290
  };
307
291
  }
308
- var isUpperCase = (value) => value[0] === value[0].toUpperCase();
292
+ var isUpperCase = (value) => value[0] === value[0]?.toUpperCase();
309
293
 
310
294
  // src/project.ts
311
295
  var createTsProject = (options) => new TsProject({
@@ -336,8 +320,8 @@ var createProject = ({ getFiles, readFile, parserOptions, ...projectOptions }) =
336
320
  overwrite: true,
337
321
  scriptKind: ScriptKind.TSX
338
322
  }),
339
- parseSourceFile: (filePath, properties) => {
340
- return parser(project.getSourceFile(filePath), properties);
323
+ parseSourceFile: (filePath) => {
324
+ return parser(project.getSourceFile(filePath));
341
325
  }
342
326
  })),
343
327
  tap(({ createSourceFile }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/parser",
3
- "version": "0.0.0-dev-20230418111141",
3
+ "version": "0.0.0-dev-20230419091337",
4
4
  "description": "The static parser for panda css",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -14,15 +14,15 @@
14
14
  "lil-fp": "1.4.5",
15
15
  "ts-morph": "18.0.0",
16
16
  "ts-pattern": "4.2.2",
17
- "@pandacss/extractor": "0.0.0-dev-20230418111141",
18
- "@pandacss/is-valid-prop": "0.0.0-dev-20230418111141",
19
- "@pandacss/logger": "0.0.0-dev-20230418111141",
20
- "@pandacss/shared": "0.0.0-dev-20230418111141",
21
- "@pandacss/types": "0.0.0-dev-20230418111141"
17
+ "@pandacss/extractor": "0.0.0-dev-20230419091337",
18
+ "@pandacss/is-valid-prop": "0.0.0-dev-20230419091337",
19
+ "@pandacss/logger": "0.0.0-dev-20230419091337",
20
+ "@pandacss/shared": "0.0.0-dev-20230419091337",
21
+ "@pandacss/types": "0.0.0-dev-20230419091337"
22
22
  },
23
23
  "devDependencies": {
24
- "@pandacss/fixture": "0.0.0-dev-20230418111141",
25
- "@pandacss/generator": "0.0.0-dev-20230418111141"
24
+ "@pandacss/fixture": "0.0.0-dev-20230419091337",
25
+ "@pandacss/generator": "0.0.0-dev-20230419091337"
26
26
  },
27
27
  "files": [
28
28
  "dist"