@pandacss/parser 0.48.1 → 0.50.0

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
@@ -1,5 +1,6 @@
1
- import { ParserOptions } from '@pandacss/core';
1
+ import * as _pandacss_types from '@pandacss/types';
2
2
  import { ParserResultInterface, ResultItem, ParserResultConfigureOptions, JsxFactoryResultTransform, Runtime, PandaHooks, ConfigTsOptions } from '@pandacss/types';
3
+ import { ParserOptions } from '@pandacss/core';
3
4
  import { SourceFile, ProjectOptions as ProjectOptions$1, Project as Project$1, FileSystemRefreshResult } from 'ts-morph';
4
5
  import { Generator } from '@pandacss/generator';
5
6
 
@@ -55,6 +56,7 @@ declare class Project {
55
56
  private options;
56
57
  project: Project$1;
57
58
  parser: ReturnType<typeof createParser>;
59
+ get parserOptions(): ParserOptions;
58
60
  constructor(options: ProjectOptions);
59
61
  get files(): string[];
60
62
  getSourceFile: (filePath: string) => SourceFile | undefined;
@@ -69,6 +71,7 @@ declare class Project {
69
71
  parseJson: (filePath: string) => ParserResult;
70
72
  parseSourceFile: (filePath: string, encoder?: ParserOptions['encoder']) => ParserResult | undefined;
71
73
  transformFile: (filePath: string, content: string) => string;
74
+ classify: (fileMap: Map<string, ParserResultInterface>) => _pandacss_types.ClassifyReport;
72
75
  }
73
76
 
74
77
  export { ParserResult, Project, type ProjectOptions };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { ParserOptions } from '@pandacss/core';
1
+ import * as _pandacss_types from '@pandacss/types';
2
2
  import { ParserResultInterface, ResultItem, ParserResultConfigureOptions, JsxFactoryResultTransform, Runtime, PandaHooks, ConfigTsOptions } from '@pandacss/types';
3
+ import { ParserOptions } from '@pandacss/core';
3
4
  import { SourceFile, ProjectOptions as ProjectOptions$1, Project as Project$1, FileSystemRefreshResult } from 'ts-morph';
4
5
  import { Generator } from '@pandacss/generator';
5
6
 
@@ -55,6 +56,7 @@ declare class Project {
55
56
  private options;
56
57
  project: Project$1;
57
58
  parser: ReturnType<typeof createParser>;
59
+ get parserOptions(): ParserOptions;
58
60
  constructor(options: ProjectOptions);
59
61
  get files(): string[];
60
62
  getSourceFile: (filePath: string) => SourceFile | undefined;
@@ -69,6 +71,7 @@ declare class Project {
69
71
  parseJson: (filePath: string) => ParserResult;
70
72
  parseSourceFile: (filePath: string, encoder?: ParserOptions['encoder']) => ParserResult | undefined;
71
73
  transformFile: (filePath: string, content: string) => string;
74
+ classify: (fileMap: Map<string, ParserResultInterface>) => _pandacss_types.ClassifyReport;
72
75
  }
73
76
 
74
77
  export { ParserResult, Project, type ProjectOptions };
package/dist/index.js CHANGED
@@ -38,10 +38,422 @@ module.exports = __toCommonJS(src_exports);
38
38
  // src/project.ts
39
39
  var import_ts_morph2 = require("ts-morph");
40
40
 
41
- // src/parser.ts
41
+ // src/classify.ts
42
42
  var import_extractor = require("@pandacss/extractor");
43
+ var import_shared = require("@pandacss/shared");
44
+ function addTo(map, key, value) {
45
+ const set = map.get(key) ?? /* @__PURE__ */ new Set();
46
+ set.add(value);
47
+ map.set(key, set);
48
+ }
49
+ function classifyProject(ctx, resultMap) {
50
+ const byId = /* @__PURE__ */ new Map();
51
+ const byComponentIndex = /* @__PURE__ */ new Map();
52
+ const byFilepath = /* @__PURE__ */ new Map();
53
+ const byComponentInFilepath = /* @__PURE__ */ new Map();
54
+ const globalMaps = createReportMaps();
55
+ const byFilePathMaps = /* @__PURE__ */ new Map();
56
+ const conditions = new Map(Object.entries(ctx.conditions.values));
57
+ const { groupByProp } = getPropertyGroupMap(ctx);
58
+ let id = 0;
59
+ let componentIndex = 0;
60
+ const isKnownUtility = (reportItem, componentReportItem) => {
61
+ const { propName, value, tokenType } = reportItem;
62
+ const utility = ctx.utility.config[propName];
63
+ if (utility) {
64
+ if (ctx.tokens.getByName(`${tokenType}.${value}`))
65
+ return true;
66
+ if (ctx.tokens.getReferences(String(value)).length > 0)
67
+ return true;
68
+ if (ctx.utility.resolveColorMix(String(value)).color)
69
+ return true;
70
+ return false;
71
+ }
72
+ if (componentReportItem.reportItemType === "pattern") {
73
+ const pattern = ctx.patterns.getConfig(componentReportItem.componentName.toLowerCase());
74
+ const patternProp = pattern?.properties?.[propName];
75
+ if (!patternProp)
76
+ return false;
77
+ if (patternProp.type === "boolean" || patternProp.type === "number") {
78
+ return true;
79
+ }
80
+ if (patternProp.type === "property" && patternProp.value) {
81
+ return Boolean(ctx.utility.config[patternProp.value]);
82
+ }
83
+ if (patternProp.type === "enum" && patternProp.value) {
84
+ return Boolean(patternProp.value.includes(String(value)));
85
+ }
86
+ if (patternProp.type === "token") {
87
+ return Boolean(ctx.tokens.getByName(`${patternProp.value}.${value}`));
88
+ }
89
+ return false;
90
+ }
91
+ return false;
92
+ };
93
+ const processPattern = (opts) => {
94
+ const { boxNode, data, item, filepath, localMaps } = opts;
95
+ const name = item.componentName;
96
+ const pattern = ctx.patterns.details.find((p) => p.match.test(name) || p.baseName === name);
97
+ if (!pattern)
98
+ return;
99
+ const cssObj = pattern.config.transform?.(data || {}, import_shared.patternFns) ?? {};
100
+ const newItem = {
101
+ name: "css",
102
+ type: "css",
103
+ box: import_extractor.box.objectToMap((0, import_shared.compact)(cssObj), boxNode.getNode(), boxNode.getStack()),
104
+ data: [cssObj]
105
+ };
106
+ Object.assign(newItem, { debug: true });
107
+ return processResultItem({ item: newItem, kind: "function", localMaps, filepath });
108
+ };
109
+ const processResultItem = (opts) => {
110
+ const { item, kind, filepath, localMaps } = opts;
111
+ if (!item.box || import_extractor.box.isUnresolvable(item.box)) {
112
+ return;
113
+ }
114
+ if (!item.data) {
115
+ return;
116
+ }
117
+ const componentReportItem = {
118
+ componentIndex: String(componentIndex++),
119
+ componentName: item.name,
120
+ reportItemType: item.type,
121
+ kind,
122
+ filepath,
123
+ value: item.data,
124
+ range: item.box.getRange(),
125
+ contains: [],
126
+ debug: Reflect.has(item, "debug")
127
+ };
128
+ if (item.type === "pattern" || item.type === "jsx-pattern") {
129
+ return processPattern({ boxNode: item.box, data: item.data[0], item: componentReportItem, filepath, localMaps });
130
+ }
131
+ if (import_extractor.box.isArray(item.box)) {
132
+ addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex);
133
+ return componentReportItem;
134
+ }
135
+ if (import_extractor.box.isMap(item.box)) {
136
+ addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex);
137
+ processMap({ map: item.box, current: [], componentReportItem, filepath, localMaps });
138
+ return componentReportItem;
139
+ }
140
+ if (item.type === "recipe") {
141
+ addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex);
142
+ return componentReportItem;
143
+ }
144
+ };
145
+ const processResultItemFn = (opts) => {
146
+ const { item, filepath, localMaps, type } = opts;
147
+ const componentReportItem = processResultItem({ item, kind: type, filepath, localMaps });
148
+ if (!componentReportItem)
149
+ return;
150
+ addTo(globalMaps.byComponentOfKind, type, componentReportItem.componentIndex);
151
+ addTo(localMaps.byComponentOfKind, type, componentReportItem.componentIndex);
152
+ byComponentIndex.set(componentReportItem.componentIndex, componentReportItem);
153
+ };
154
+ const processMap = (opts) => {
155
+ const { map, current, componentReportItem, filepath, localMaps, skipRange } = opts;
156
+ const { reportItemType: type, kind, componentName: name } = componentReportItem;
157
+ map.value.forEach((attrNode, attrName) => {
158
+ if (import_extractor.box.isLiteral(attrNode) || import_extractor.box.isEmptyInitializer(attrNode)) {
159
+ const value = import_extractor.box.isLiteral(attrNode) ? attrNode.value : true;
160
+ const propReportItem = {
161
+ index: String(id++),
162
+ componentIndex: String(componentReportItem.componentIndex),
163
+ componentName: name,
164
+ tokenType: void 0,
165
+ propName: attrName,
166
+ reportItemKind: "utility",
167
+ reportItemType: type,
168
+ kind,
169
+ filepath,
170
+ path: current.concat(attrName),
171
+ value,
172
+ isKnownValue: false,
173
+ range: skipRange ? null : map.getRange()
174
+ };
175
+ componentReportItem.contains.push(propReportItem.index);
176
+ if (conditions.has(attrName)) {
177
+ addTo(globalMaps.byConditionName, attrName, propReportItem.index);
178
+ addTo(localMaps.byConditionName, attrName, propReportItem.index);
179
+ propReportItem.propName = current[0] ?? attrName;
180
+ propReportItem.isKnownValue = isKnownUtility(propReportItem, componentReportItem);
181
+ propReportItem.conditionName = attrName;
182
+ } else {
183
+ if (current.length && conditions.has(current[0])) {
184
+ propReportItem.conditionName = current[0];
185
+ addTo(globalMaps.byConditionName, current[0], propReportItem.index);
186
+ addTo(localMaps.byConditionName, current[0], propReportItem.index);
187
+ }
188
+ const propName = ctx.utility.resolveShorthand(attrName);
189
+ const tokenType = ctx.utility.getTokenType(propName);
190
+ if (tokenType) {
191
+ propReportItem.reportItemKind = "token";
192
+ propReportItem.tokenType = tokenType;
193
+ }
194
+ propReportItem.propName = propName;
195
+ propReportItem.isKnownValue = isKnownUtility(propReportItem, componentReportItem);
196
+ addTo(globalMaps.byPropertyName, propName, propReportItem.index);
197
+ addTo(localMaps.byPropertyName, propName, propReportItem.index);
198
+ if (tokenType) {
199
+ addTo(globalMaps.byTokenType, tokenType, propReportItem.index);
200
+ addTo(localMaps.byTokenType, tokenType, propReportItem.index);
201
+ }
202
+ if (propName.toLowerCase().includes("color") || groupByProp.get(propName) === "Color" || tokenType === "colors") {
203
+ addTo(globalMaps.colorsUsed, value, propReportItem.index);
204
+ addTo(localMaps.colorsUsed, value, propReportItem.index);
205
+ }
206
+ if (ctx.utility.shorthands.has(attrName)) {
207
+ addTo(globalMaps.byShorthand, attrName, propReportItem.index);
208
+ addTo(localMaps.byShorthand, attrName, propReportItem.index);
209
+ }
210
+ }
211
+ if (current.length) {
212
+ addTo(globalMaps.byPropertyPath, propReportItem.path.join("."), propReportItem.index);
213
+ addTo(localMaps.byPropertyPath, propReportItem.path.join("."), propReportItem.index);
214
+ }
215
+ addTo(globalMaps.byTokenName, String(value), propReportItem.index);
216
+ addTo(localMaps.byTokenName, String(value), propReportItem.index);
217
+ addTo(globalMaps.byType, type, propReportItem.index);
218
+ addTo(localMaps.byType, type, propReportItem.index);
219
+ addTo(globalMaps.byComponentName, name, propReportItem.index);
220
+ addTo(localMaps.byComponentName, name, propReportItem.index);
221
+ addTo(globalMaps.fromKind, kind, propReportItem.index);
222
+ addTo(localMaps.fromKind, kind, propReportItem.index);
223
+ addTo(byFilepath, filepath, propReportItem.index);
224
+ byId.set(propReportItem.index, propReportItem);
225
+ return;
226
+ }
227
+ if (import_extractor.box.isMap(attrNode) && attrNode.value.size) {
228
+ return processMap({
229
+ map: attrNode,
230
+ current: current.concat(attrName),
231
+ componentReportItem,
232
+ filepath,
233
+ localMaps
234
+ });
235
+ }
236
+ });
237
+ };
238
+ resultMap.forEach((parserResult, filepath) => {
239
+ if (parserResult.isEmpty())
240
+ return;
241
+ const localMaps = createReportMaps();
242
+ const componentFn = (item) => {
243
+ processResultItemFn({ item, filepath, localMaps, type: "component" });
244
+ };
245
+ const functionFn = (item) => {
246
+ processResultItemFn({ item, filepath, localMaps, type: "function" });
247
+ };
248
+ parserResult.jsx.forEach(componentFn);
249
+ parserResult.css.forEach(functionFn);
250
+ parserResult.cva.forEach(functionFn);
251
+ parserResult.pattern.forEach((itemList) => {
252
+ itemList.forEach(functionFn);
253
+ });
254
+ parserResult.recipe.forEach((itemList) => {
255
+ itemList.forEach(functionFn);
256
+ });
257
+ byFilePathMaps.set(filepath, localMaps);
258
+ });
259
+ const pickCount = 10;
260
+ const filesWithMostComponent = Object.fromEntries(
261
+ Array.from(byComponentInFilepath.entries()).map(([filepath, list]) => [filepath, list.size]).sort((a, b) => b[1] - a[1]).slice(0, pickCount)
262
+ );
263
+ Object.entries(ctx.recipes.config).forEach(([key, recipe]) => {
264
+ const localMaps = createReportMaps();
265
+ const functionFn = (styleObject) => {
266
+ if (!styleObject)
267
+ return;
268
+ const componentReportItem = {
269
+ componentIndex: "0",
270
+ componentName: `recipes.${key}.base`,
271
+ reportItemType: "css",
272
+ kind: "function",
273
+ filepath: `theme/recipes/${key}`,
274
+ value: styleObject,
275
+ range: null,
276
+ contains: []
277
+ };
278
+ processMap({
279
+ // @ts-expect-error
280
+ map: import_extractor.box.objectToMap(styleObject, null, []),
281
+ current: [],
282
+ filepath: `@config/theme/recipes/${key}`,
283
+ skipRange: true,
284
+ localMaps,
285
+ componentReportItem
286
+ });
287
+ };
288
+ const isSlotRecipe = (v) => ctx.recipes.isSlotRecipe(key);
289
+ if (isSlotRecipe(recipe)) {
290
+ Object.values(recipe.base ?? {}).forEach(functionFn);
291
+ Object.values(recipe.variants ?? {}).forEach((variants) => {
292
+ Object.values(variants).forEach((v) => {
293
+ Object.values(v).forEach(functionFn);
294
+ });
295
+ });
296
+ recipe.compoundVariants?.forEach((v) => {
297
+ Object.values(v.css).forEach(functionFn);
298
+ });
299
+ } else {
300
+ functionFn(recipe.base);
301
+ Object.values(recipe.variants ?? {}).forEach((variants) => {
302
+ Object.values(variants).forEach(functionFn);
303
+ });
304
+ recipe.compoundVariants?.forEach((v) => functionFn(v.css));
305
+ }
306
+ });
307
+ Object.values(ctx.config.globalCss ?? {}).forEach((styleObject) => {
308
+ if (!styleObject)
309
+ return;
310
+ processMap({
311
+ // @ts-expect-error
312
+ map: import_extractor.box.objectToMap(styleObject, null, []),
313
+ current: [],
314
+ filepath: "@config/globalCss",
315
+ skipRange: true,
316
+ localMaps: createReportMaps(),
317
+ componentReportItem: {
318
+ componentIndex: "0",
319
+ componentName: "global",
320
+ reportItemType: "css",
321
+ kind: "function",
322
+ filepath: "global",
323
+ value: styleObject,
324
+ range: null,
325
+ contains: []
326
+ }
327
+ });
328
+ });
329
+ return {
330
+ propById: byId,
331
+ componentById: byComponentIndex,
332
+ details: {
333
+ counts: {
334
+ filesWithTokens: byFilepath.size,
335
+ propNameUsed: globalMaps.byPropertyName.size,
336
+ tokenUsed: globalMaps.byTokenName.size,
337
+ shorthandUsed: globalMaps.byShorthand.size,
338
+ propertyPathUsed: globalMaps.byPropertyPath.size,
339
+ typeUsed: globalMaps.byType.size,
340
+ componentNameUsed: globalMaps.byComponentName.size,
341
+ kindUsed: globalMaps.fromKind.size,
342
+ componentOfKindUsed: globalMaps.byComponentOfKind.size,
343
+ colorsUsed: globalMaps.colorsUsed.size
344
+ },
345
+ stats: {
346
+ filesWithMostComponent,
347
+ mostUseds: getXMostUseds(globalMaps, 10)
348
+ }
349
+ },
350
+ derived: {
351
+ byFilepath,
352
+ byComponentInFilepath,
353
+ globalMaps,
354
+ byFilePathMaps
355
+ }
356
+ };
357
+ }
358
+ var getXMostUseds = (globalMaps, pickCount) => {
359
+ return {
360
+ propNames: getMostUsedInMap(globalMaps.byPropertyName, pickCount),
361
+ tokens: getMostUsedInMap(globalMaps.byTokenName, pickCount),
362
+ shorthands: getMostUsedInMap(globalMaps.byShorthand, pickCount),
363
+ conditions: getMostUsedInMap(globalMaps.byConditionName, pickCount),
364
+ propertyPaths: getMostUsedInMap(globalMaps.byPropertyPath, pickCount),
365
+ categories: getMostUsedInMap(globalMaps.byTokenType, pickCount),
366
+ types: getMostUsedInMap(globalMaps.byType, pickCount),
367
+ componentNames: getMostUsedInMap(globalMaps.byComponentName, pickCount),
368
+ fromKinds: getMostUsedInMap(globalMaps.fromKind, pickCount),
369
+ componentOfKinds: getMostUsedInMap(globalMaps.byComponentOfKind, pickCount),
370
+ colors: getMostUsedInMap(globalMaps.colorsUsed, pickCount)
371
+ };
372
+ };
373
+ var getMostUsedInMap = (map, pickCount) => {
374
+ return Array.from(map.entries()).map(([key, list]) => [key, list.size]).sort((a, b) => b[1] - a[1]).slice(0, pickCount).map(([key, count]) => ({ key, count }));
375
+ };
376
+ var defaultGroupNames = [
377
+ "System",
378
+ "Container",
379
+ "Display",
380
+ "Visibility",
381
+ "Position",
382
+ "Transform",
383
+ "Flex Layout",
384
+ "Grid Layout",
385
+ "Layout",
386
+ "Border",
387
+ "Border Radius",
388
+ "Width",
389
+ "Height",
390
+ "Margin",
391
+ "Padding",
392
+ "Color",
393
+ "Typography",
394
+ "Background",
395
+ "Shadow",
396
+ "Table",
397
+ "List",
398
+ "Scroll",
399
+ "Interactivity",
400
+ "Transition",
401
+ "Effect",
402
+ "Other"
403
+ ];
404
+ function getPropertyGroupMap(ctx) {
405
+ const groups = new Map(defaultGroupNames.map((name) => [name, /* @__PURE__ */ new Set()]));
406
+ const groupByProp = /* @__PURE__ */ new Map();
407
+ const systemGroup = groups.get("System");
408
+ systemGroup.add("base");
409
+ systemGroup.add("colorPalette");
410
+ const otherStyleProps = groups.get("Other");
411
+ Object.entries(ctx.utility.config).map(([key, value]) => {
412
+ const group = value?.group;
413
+ if (!group) {
414
+ otherStyleProps.add(key);
415
+ return;
416
+ }
417
+ if (!groups.has(group)) {
418
+ groups.set(group, /* @__PURE__ */ new Set());
419
+ }
420
+ const set = groups.get(group);
421
+ if (value.shorthand) {
422
+ if (Array.isArray(value.shorthand)) {
423
+ value.shorthand.forEach((shorthand) => {
424
+ set.add(shorthand);
425
+ groupByProp.set(shorthand, group);
426
+ });
427
+ } else {
428
+ set.add(value.shorthand);
429
+ groupByProp.set(value.shorthand, group);
430
+ }
431
+ }
432
+ set.add(key);
433
+ groupByProp.set(key, group);
434
+ });
435
+ return { groups, groupByProp };
436
+ }
437
+ function createReportMaps() {
438
+ return {
439
+ byComponentOfKind: /* @__PURE__ */ new Map(),
440
+ byPropertyName: /* @__PURE__ */ new Map(),
441
+ byTokenType: /* @__PURE__ */ new Map(),
442
+ byConditionName: /* @__PURE__ */ new Map(),
443
+ byShorthand: /* @__PURE__ */ new Map(),
444
+ byTokenName: /* @__PURE__ */ new Map(),
445
+ byPropertyPath: /* @__PURE__ */ new Map(),
446
+ fromKind: /* @__PURE__ */ new Map(),
447
+ byType: /* @__PURE__ */ new Map(),
448
+ byComponentName: /* @__PURE__ */ new Map(),
449
+ colorsUsed: /* @__PURE__ */ new Map()
450
+ };
451
+ }
452
+
453
+ // src/parser.ts
454
+ var import_extractor2 = require("@pandacss/extractor");
43
455
  var import_logger = require("@pandacss/logger");
44
- var import_shared2 = require("@pandacss/shared");
456
+ var import_shared3 = require("@pandacss/shared");
45
457
  var import_ts_morph = require("ts-morph");
46
458
  var import_ts_pattern = require("ts-pattern");
47
459
 
@@ -96,7 +508,7 @@ function getImportDeclarations(context, sourceFile) {
96
508
  }
97
509
 
98
510
  // src/parser-result.ts
99
- var import_shared = require("@pandacss/shared");
511
+ var import_shared2 = require("@pandacss/shared");
100
512
  var ParserResult = class {
101
513
  constructor(context, encoder) {
102
514
  this.context = context;
@@ -128,7 +540,7 @@ var ParserResult = class {
128
540
  this.setSva(result);
129
541
  break;
130
542
  default:
131
- throw new import_shared.PandaError("UNKNOWN_TYPE", `Unknown result type ${name}`);
543
+ throw new import_shared2.PandaError("UNKNOWN_TYPE", `Unknown result type ${name}`);
132
544
  }
133
545
  }
134
546
  setCss(result) {
@@ -152,7 +564,7 @@ var ParserResult = class {
152
564
  result.data.forEach((obj) => encoder.processStyleProps(obj));
153
565
  }
154
566
  setPattern(name, result) {
155
- const set = (0, import_shared.getOrCreateSet)(this.pattern, name);
567
+ const set = (0, import_shared2.getOrCreateSet)(this.pattern, name);
156
568
  set.add(this.append(Object.assign({ type: "pattern", name }, result)));
157
569
  const encoder = this.encoder;
158
570
  result.data.forEach(
@@ -160,7 +572,7 @@ var ParserResult = class {
160
572
  );
161
573
  }
162
574
  setRecipe(recipeName, result) {
163
- const set = (0, import_shared.getOrCreateSet)(this.recipe, recipeName);
575
+ const set = (0, import_shared2.getOrCreateSet)(this.recipe, recipeName);
164
576
  set.add(this.append(Object.assign({ type: "recipe" }, result)));
165
577
  const encoder = this.encoder;
166
578
  const recipes = this.context.recipes;
@@ -193,11 +605,11 @@ var ParserResult = class {
193
605
  result.sva.forEach((item) => this.sva.add(this.append(item)));
194
606
  result.jsx.forEach((item) => this.jsx.add(this.append(item)));
195
607
  result.recipe.forEach((items, name) => {
196
- const set = (0, import_shared.getOrCreateSet)(this.recipe, name);
608
+ const set = (0, import_shared2.getOrCreateSet)(this.recipe, name);
197
609
  items.forEach((item) => set.add(this.append(item)));
198
610
  });
199
611
  result.pattern.forEach((items, name) => {
200
- const set = (0, import_shared.getOrCreateSet)(this.pattern, name);
612
+ const set = (0, import_shared2.getOrCreateSet)(this.pattern, name);
201
613
  items.forEach((item) => set.add(this.append(item)));
202
614
  });
203
615
  return this;
@@ -228,7 +640,8 @@ var evaluateOptions = {
228
640
  environment: defaultEnv
229
641
  };
230
642
  function createParser(context) {
231
- const { jsx, imports, recipes, syntax } = context;
643
+ const { jsx, imports, recipes, config } = context;
644
+ const syntax = config.syntax;
232
645
  return function parse2(sourceFile, encoder, options) {
233
646
  if (!sourceFile)
234
647
  return;
@@ -243,7 +656,7 @@ function createParser(context) {
243
656
  if (file.isEmpty() && !jsx.isEnabled) {
244
657
  return parserResult;
245
658
  }
246
- const extractResultByName = (0, import_extractor.extract)({
659
+ const extractResultByName = (0, import_extractor2.extract)({
247
660
  ast: sourceFile,
248
661
  components: jsx.isEnabled ? {
249
662
  matchTag: (prop) => {
@@ -306,22 +719,22 @@ function createParser(context) {
306
719
  name: name2,
307
720
  box: query.box,
308
721
  data: query.box.value.reduce(
309
- (acc, value) => [...acc, ...combineResult((0, import_extractor.unbox)(value))],
722
+ (acc, value) => [...acc, ...combineResult((0, import_extractor2.unbox)(value))],
310
723
  []
311
724
  )
312
725
  });
313
726
  } else {
314
727
  parserResult.set(name2, {
315
728
  name: name2,
316
- box: query.box.value[0] ?? import_extractor.box.fallback(query.box),
317
- data: combineResult((0, import_extractor.unbox)(query.box.value[0]))
729
+ box: query.box.value[0] ?? import_extractor2.box.fallback(query.box),
730
+ data: combineResult((0, import_extractor2.unbox)(query.box.value[0]))
318
731
  });
319
732
  }
320
733
  } else if (query.kind === "tagged-template") {
321
- const obj = (0, import_shared2.astish)(query.box.value);
734
+ const obj = (0, import_shared3.astish)(query.box.value);
322
735
  parserResult.set(name2, {
323
736
  name: name2,
324
- box: query.box ?? import_extractor.box.fallback(query.box),
737
+ box: query.box ?? import_extractor2.box.fallback(query.box),
325
738
  data: [obj]
326
739
  });
327
740
  }
@@ -331,8 +744,8 @@ function createParser(context) {
331
744
  if (query.kind === "call-expression") {
332
745
  parserResult.setPattern(name2, {
333
746
  name: name2,
334
- box: query.box.value[0] ?? import_extractor.box.fallback(query.box),
335
- data: combineResult((0, import_extractor.unbox)(query.box.value[0]))
747
+ box: query.box.value[0] ?? import_extractor2.box.fallback(query.box),
748
+ data: combineResult((0, import_extractor2.unbox)(query.box.value[0]))
336
749
  });
337
750
  }
338
751
  });
@@ -341,8 +754,8 @@ function createParser(context) {
341
754
  if (query.kind === "call-expression") {
342
755
  parserResult.setRecipe(name2, {
343
756
  name: name2,
344
- box: query.box.value[0] ?? import_extractor.box.fallback(query.box),
345
- data: combineResult((0, import_extractor.unbox)(query.box.value[0]))
757
+ box: query.box.value[0] ?? import_extractor2.box.fallback(query.box),
758
+ data: combineResult((0, import_extractor2.unbox)(query.box.value[0]))
346
759
  });
347
760
  }
348
761
  });
@@ -350,17 +763,17 @@ function createParser(context) {
350
763
  result.queryList.forEach((query) => {
351
764
  if (query.kind === "call-expression" && query.box.value[1]) {
352
765
  const map = query.box.value[1];
353
- const boxNode = import_extractor.box.isMap(map) ? map : import_extractor.box.fallback(query.box);
354
- const combined = combineResult((0, import_extractor.unbox)(boxNode));
766
+ const boxNode = import_extractor2.box.isMap(map) ? map : import_extractor2.box.fallback(query.box);
767
+ const combined = combineResult((0, import_extractor2.unbox)(boxNode));
355
768
  const transformed = options?.transform?.({ type: "jsx-factory", data: combined });
356
769
  const result2 = { name, box: boxNode, data: transformed ?? combined };
357
- if (import_extractor.box.isRecipe(map)) {
770
+ if (import_extractor2.box.isRecipe(map)) {
358
771
  parserResult.setCva(result2);
359
772
  } else {
360
773
  parserResult.set("css", result2);
361
774
  }
362
775
  const recipeOptions = query.box.value[2];
363
- if (import_extractor.box.isUnresolvable(map) && recipeOptions && import_extractor.box.isMap(recipeOptions) && recipeOptions.value.has("defaultProps")) {
776
+ if (import_extractor2.box.isUnresolvable(map) && recipeOptions && import_extractor2.box.isMap(recipeOptions) && recipeOptions.value.has("defaultProps")) {
364
777
  const maybeIdentifier = map.getNode();
365
778
  if (import_ts_morph.Node.isIdentifier(maybeIdentifier)) {
366
779
  const name2 = maybeIdentifier.getText();
@@ -369,15 +782,15 @@ function createParser(context) {
369
782
  type: "jsx-recipe",
370
783
  name: recipeName,
371
784
  box: recipeOptions,
372
- data: combineResult((0, import_extractor.unbox)(recipeOptions.value.get("defaultProps")))
785
+ data: combineResult((0, import_extractor2.unbox)(recipeOptions.value.get("defaultProps")))
373
786
  });
374
787
  }
375
788
  }
376
789
  } else if (query.kind === "tagged-template") {
377
- const obj = (0, import_shared2.astish)(query.box.value);
790
+ const obj = (0, import_shared3.astish)(query.box.value);
378
791
  parserResult.set("css", {
379
792
  name,
380
- box: query.box ?? import_extractor.box.fallback(query.box),
793
+ box: query.box ?? import_extractor2.box.fallback(query.box),
381
794
  data: [obj]
382
795
  });
383
796
  }
@@ -386,20 +799,20 @@ function createParser(context) {
386
799
  result.queryList.forEach((query) => {
387
800
  if (query.kind === "call-expression") {
388
801
  const map = query.box.value[0];
389
- const boxNode = import_extractor.box.isMap(map) ? map : import_extractor.box.fallback(query.box);
390
- const combined = combineResult((0, import_extractor.unbox)(boxNode));
802
+ const boxNode = import_extractor2.box.isMap(map) ? map : import_extractor2.box.fallback(query.box);
803
+ const combined = combineResult((0, import_extractor2.unbox)(boxNode));
391
804
  const transformed = options?.transform?.({ type: "jsx-factory", data: combined });
392
805
  const result2 = { name: name2, box: boxNode, data: transformed ?? combined };
393
- if (import_extractor.box.isRecipe(map)) {
806
+ if (import_extractor2.box.isRecipe(map)) {
394
807
  parserResult.setCva(result2);
395
808
  } else {
396
809
  parserResult.set("css", result2);
397
810
  }
398
811
  } else if (query.kind === "tagged-template") {
399
- const obj = (0, import_shared2.astish)(query.box.value);
812
+ const obj = (0, import_shared3.astish)(query.box.value);
400
813
  parserResult.set("css", {
401
814
  name: name2,
402
- box: query.box ?? import_extractor.box.fallback(query.box),
815
+ box: query.box ?? import_extractor2.box.fallback(query.box),
403
816
  data: [obj]
404
817
  });
405
818
  }
@@ -408,7 +821,7 @@ function createParser(context) {
408
821
  });
409
822
  } else if (jsx.isEnabled && result.kind === "component") {
410
823
  result.queryList.forEach((query) => {
411
- const data = combineResult((0, import_extractor.unbox)(query.box));
824
+ const data = combineResult((0, import_extractor2.unbox)(query.box));
412
825
  switch (true) {
413
826
  case (file.isJsxFactory(name) || file.isJsxFactory(alias)): {
414
827
  parserResult.setJsx({ type: "jsx-factory", name, box: query.box, data });
@@ -551,6 +964,9 @@ var Project = class {
551
964
  }
552
965
  project;
553
966
  parser;
967
+ get parserOptions() {
968
+ return this.options.parserOptions;
969
+ }
554
970
  get files() {
555
971
  return this.options.getFiles();
556
972
  }
@@ -649,6 +1065,10 @@ var Project = class {
649
1065
  }
650
1066
  return content;
651
1067
  };
1068
+ classify = (fileMap) => {
1069
+ const { parserOptions } = this.options;
1070
+ return classifyProject(parserOptions, fileMap);
1071
+ };
652
1072
  };
653
1073
  // Annotate the CommonJS export names for ESM import in node:
654
1074
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -4,8 +4,420 @@ import {
4
4
  Project as TsProject
5
5
  } from "ts-morph";
6
6
 
7
+ // src/classify.ts
8
+ import { box } from "@pandacss/extractor";
9
+ import { compact, patternFns } from "@pandacss/shared";
10
+ function addTo(map, key, value) {
11
+ const set = map.get(key) ?? /* @__PURE__ */ new Set();
12
+ set.add(value);
13
+ map.set(key, set);
14
+ }
15
+ function classifyProject(ctx, resultMap) {
16
+ const byId = /* @__PURE__ */ new Map();
17
+ const byComponentIndex = /* @__PURE__ */ new Map();
18
+ const byFilepath = /* @__PURE__ */ new Map();
19
+ const byComponentInFilepath = /* @__PURE__ */ new Map();
20
+ const globalMaps = createReportMaps();
21
+ const byFilePathMaps = /* @__PURE__ */ new Map();
22
+ const conditions = new Map(Object.entries(ctx.conditions.values));
23
+ const { groupByProp } = getPropertyGroupMap(ctx);
24
+ let id = 0;
25
+ let componentIndex = 0;
26
+ const isKnownUtility = (reportItem, componentReportItem) => {
27
+ const { propName, value, tokenType } = reportItem;
28
+ const utility = ctx.utility.config[propName];
29
+ if (utility) {
30
+ if (ctx.tokens.getByName(`${tokenType}.${value}`))
31
+ return true;
32
+ if (ctx.tokens.getReferences(String(value)).length > 0)
33
+ return true;
34
+ if (ctx.utility.resolveColorMix(String(value)).color)
35
+ return true;
36
+ return false;
37
+ }
38
+ if (componentReportItem.reportItemType === "pattern") {
39
+ const pattern = ctx.patterns.getConfig(componentReportItem.componentName.toLowerCase());
40
+ const patternProp = pattern?.properties?.[propName];
41
+ if (!patternProp)
42
+ return false;
43
+ if (patternProp.type === "boolean" || patternProp.type === "number") {
44
+ return true;
45
+ }
46
+ if (patternProp.type === "property" && patternProp.value) {
47
+ return Boolean(ctx.utility.config[patternProp.value]);
48
+ }
49
+ if (patternProp.type === "enum" && patternProp.value) {
50
+ return Boolean(patternProp.value.includes(String(value)));
51
+ }
52
+ if (patternProp.type === "token") {
53
+ return Boolean(ctx.tokens.getByName(`${patternProp.value}.${value}`));
54
+ }
55
+ return false;
56
+ }
57
+ return false;
58
+ };
59
+ const processPattern = (opts) => {
60
+ const { boxNode, data, item, filepath, localMaps } = opts;
61
+ const name = item.componentName;
62
+ const pattern = ctx.patterns.details.find((p) => p.match.test(name) || p.baseName === name);
63
+ if (!pattern)
64
+ return;
65
+ const cssObj = pattern.config.transform?.(data || {}, patternFns) ?? {};
66
+ const newItem = {
67
+ name: "css",
68
+ type: "css",
69
+ box: box.objectToMap(compact(cssObj), boxNode.getNode(), boxNode.getStack()),
70
+ data: [cssObj]
71
+ };
72
+ Object.assign(newItem, { debug: true });
73
+ return processResultItem({ item: newItem, kind: "function", localMaps, filepath });
74
+ };
75
+ const processResultItem = (opts) => {
76
+ const { item, kind, filepath, localMaps } = opts;
77
+ if (!item.box || box.isUnresolvable(item.box)) {
78
+ return;
79
+ }
80
+ if (!item.data) {
81
+ return;
82
+ }
83
+ const componentReportItem = {
84
+ componentIndex: String(componentIndex++),
85
+ componentName: item.name,
86
+ reportItemType: item.type,
87
+ kind,
88
+ filepath,
89
+ value: item.data,
90
+ range: item.box.getRange(),
91
+ contains: [],
92
+ debug: Reflect.has(item, "debug")
93
+ };
94
+ if (item.type === "pattern" || item.type === "jsx-pattern") {
95
+ return processPattern({ boxNode: item.box, data: item.data[0], item: componentReportItem, filepath, localMaps });
96
+ }
97
+ if (box.isArray(item.box)) {
98
+ addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex);
99
+ return componentReportItem;
100
+ }
101
+ if (box.isMap(item.box)) {
102
+ addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex);
103
+ processMap({ map: item.box, current: [], componentReportItem, filepath, localMaps });
104
+ return componentReportItem;
105
+ }
106
+ if (item.type === "recipe") {
107
+ addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex);
108
+ return componentReportItem;
109
+ }
110
+ };
111
+ const processResultItemFn = (opts) => {
112
+ const { item, filepath, localMaps, type } = opts;
113
+ const componentReportItem = processResultItem({ item, kind: type, filepath, localMaps });
114
+ if (!componentReportItem)
115
+ return;
116
+ addTo(globalMaps.byComponentOfKind, type, componentReportItem.componentIndex);
117
+ addTo(localMaps.byComponentOfKind, type, componentReportItem.componentIndex);
118
+ byComponentIndex.set(componentReportItem.componentIndex, componentReportItem);
119
+ };
120
+ const processMap = (opts) => {
121
+ const { map, current, componentReportItem, filepath, localMaps, skipRange } = opts;
122
+ const { reportItemType: type, kind, componentName: name } = componentReportItem;
123
+ map.value.forEach((attrNode, attrName) => {
124
+ if (box.isLiteral(attrNode) || box.isEmptyInitializer(attrNode)) {
125
+ const value = box.isLiteral(attrNode) ? attrNode.value : true;
126
+ const propReportItem = {
127
+ index: String(id++),
128
+ componentIndex: String(componentReportItem.componentIndex),
129
+ componentName: name,
130
+ tokenType: void 0,
131
+ propName: attrName,
132
+ reportItemKind: "utility",
133
+ reportItemType: type,
134
+ kind,
135
+ filepath,
136
+ path: current.concat(attrName),
137
+ value,
138
+ isKnownValue: false,
139
+ range: skipRange ? null : map.getRange()
140
+ };
141
+ componentReportItem.contains.push(propReportItem.index);
142
+ if (conditions.has(attrName)) {
143
+ addTo(globalMaps.byConditionName, attrName, propReportItem.index);
144
+ addTo(localMaps.byConditionName, attrName, propReportItem.index);
145
+ propReportItem.propName = current[0] ?? attrName;
146
+ propReportItem.isKnownValue = isKnownUtility(propReportItem, componentReportItem);
147
+ propReportItem.conditionName = attrName;
148
+ } else {
149
+ if (current.length && conditions.has(current[0])) {
150
+ propReportItem.conditionName = current[0];
151
+ addTo(globalMaps.byConditionName, current[0], propReportItem.index);
152
+ addTo(localMaps.byConditionName, current[0], propReportItem.index);
153
+ }
154
+ const propName = ctx.utility.resolveShorthand(attrName);
155
+ const tokenType = ctx.utility.getTokenType(propName);
156
+ if (tokenType) {
157
+ propReportItem.reportItemKind = "token";
158
+ propReportItem.tokenType = tokenType;
159
+ }
160
+ propReportItem.propName = propName;
161
+ propReportItem.isKnownValue = isKnownUtility(propReportItem, componentReportItem);
162
+ addTo(globalMaps.byPropertyName, propName, propReportItem.index);
163
+ addTo(localMaps.byPropertyName, propName, propReportItem.index);
164
+ if (tokenType) {
165
+ addTo(globalMaps.byTokenType, tokenType, propReportItem.index);
166
+ addTo(localMaps.byTokenType, tokenType, propReportItem.index);
167
+ }
168
+ if (propName.toLowerCase().includes("color") || groupByProp.get(propName) === "Color" || tokenType === "colors") {
169
+ addTo(globalMaps.colorsUsed, value, propReportItem.index);
170
+ addTo(localMaps.colorsUsed, value, propReportItem.index);
171
+ }
172
+ if (ctx.utility.shorthands.has(attrName)) {
173
+ addTo(globalMaps.byShorthand, attrName, propReportItem.index);
174
+ addTo(localMaps.byShorthand, attrName, propReportItem.index);
175
+ }
176
+ }
177
+ if (current.length) {
178
+ addTo(globalMaps.byPropertyPath, propReportItem.path.join("."), propReportItem.index);
179
+ addTo(localMaps.byPropertyPath, propReportItem.path.join("."), propReportItem.index);
180
+ }
181
+ addTo(globalMaps.byTokenName, String(value), propReportItem.index);
182
+ addTo(localMaps.byTokenName, String(value), propReportItem.index);
183
+ addTo(globalMaps.byType, type, propReportItem.index);
184
+ addTo(localMaps.byType, type, propReportItem.index);
185
+ addTo(globalMaps.byComponentName, name, propReportItem.index);
186
+ addTo(localMaps.byComponentName, name, propReportItem.index);
187
+ addTo(globalMaps.fromKind, kind, propReportItem.index);
188
+ addTo(localMaps.fromKind, kind, propReportItem.index);
189
+ addTo(byFilepath, filepath, propReportItem.index);
190
+ byId.set(propReportItem.index, propReportItem);
191
+ return;
192
+ }
193
+ if (box.isMap(attrNode) && attrNode.value.size) {
194
+ return processMap({
195
+ map: attrNode,
196
+ current: current.concat(attrName),
197
+ componentReportItem,
198
+ filepath,
199
+ localMaps
200
+ });
201
+ }
202
+ });
203
+ };
204
+ resultMap.forEach((parserResult, filepath) => {
205
+ if (parserResult.isEmpty())
206
+ return;
207
+ const localMaps = createReportMaps();
208
+ const componentFn = (item) => {
209
+ processResultItemFn({ item, filepath, localMaps, type: "component" });
210
+ };
211
+ const functionFn = (item) => {
212
+ processResultItemFn({ item, filepath, localMaps, type: "function" });
213
+ };
214
+ parserResult.jsx.forEach(componentFn);
215
+ parserResult.css.forEach(functionFn);
216
+ parserResult.cva.forEach(functionFn);
217
+ parserResult.pattern.forEach((itemList) => {
218
+ itemList.forEach(functionFn);
219
+ });
220
+ parserResult.recipe.forEach((itemList) => {
221
+ itemList.forEach(functionFn);
222
+ });
223
+ byFilePathMaps.set(filepath, localMaps);
224
+ });
225
+ const pickCount = 10;
226
+ const filesWithMostComponent = Object.fromEntries(
227
+ Array.from(byComponentInFilepath.entries()).map(([filepath, list]) => [filepath, list.size]).sort((a, b) => b[1] - a[1]).slice(0, pickCount)
228
+ );
229
+ Object.entries(ctx.recipes.config).forEach(([key, recipe]) => {
230
+ const localMaps = createReportMaps();
231
+ const functionFn = (styleObject) => {
232
+ if (!styleObject)
233
+ return;
234
+ const componentReportItem = {
235
+ componentIndex: "0",
236
+ componentName: `recipes.${key}.base`,
237
+ reportItemType: "css",
238
+ kind: "function",
239
+ filepath: `theme/recipes/${key}`,
240
+ value: styleObject,
241
+ range: null,
242
+ contains: []
243
+ };
244
+ processMap({
245
+ // @ts-expect-error
246
+ map: box.objectToMap(styleObject, null, []),
247
+ current: [],
248
+ filepath: `@config/theme/recipes/${key}`,
249
+ skipRange: true,
250
+ localMaps,
251
+ componentReportItem
252
+ });
253
+ };
254
+ const isSlotRecipe = (v) => ctx.recipes.isSlotRecipe(key);
255
+ if (isSlotRecipe(recipe)) {
256
+ Object.values(recipe.base ?? {}).forEach(functionFn);
257
+ Object.values(recipe.variants ?? {}).forEach((variants) => {
258
+ Object.values(variants).forEach((v) => {
259
+ Object.values(v).forEach(functionFn);
260
+ });
261
+ });
262
+ recipe.compoundVariants?.forEach((v) => {
263
+ Object.values(v.css).forEach(functionFn);
264
+ });
265
+ } else {
266
+ functionFn(recipe.base);
267
+ Object.values(recipe.variants ?? {}).forEach((variants) => {
268
+ Object.values(variants).forEach(functionFn);
269
+ });
270
+ recipe.compoundVariants?.forEach((v) => functionFn(v.css));
271
+ }
272
+ });
273
+ Object.values(ctx.config.globalCss ?? {}).forEach((styleObject) => {
274
+ if (!styleObject)
275
+ return;
276
+ processMap({
277
+ // @ts-expect-error
278
+ map: box.objectToMap(styleObject, null, []),
279
+ current: [],
280
+ filepath: "@config/globalCss",
281
+ skipRange: true,
282
+ localMaps: createReportMaps(),
283
+ componentReportItem: {
284
+ componentIndex: "0",
285
+ componentName: "global",
286
+ reportItemType: "css",
287
+ kind: "function",
288
+ filepath: "global",
289
+ value: styleObject,
290
+ range: null,
291
+ contains: []
292
+ }
293
+ });
294
+ });
295
+ return {
296
+ propById: byId,
297
+ componentById: byComponentIndex,
298
+ details: {
299
+ counts: {
300
+ filesWithTokens: byFilepath.size,
301
+ propNameUsed: globalMaps.byPropertyName.size,
302
+ tokenUsed: globalMaps.byTokenName.size,
303
+ shorthandUsed: globalMaps.byShorthand.size,
304
+ propertyPathUsed: globalMaps.byPropertyPath.size,
305
+ typeUsed: globalMaps.byType.size,
306
+ componentNameUsed: globalMaps.byComponentName.size,
307
+ kindUsed: globalMaps.fromKind.size,
308
+ componentOfKindUsed: globalMaps.byComponentOfKind.size,
309
+ colorsUsed: globalMaps.colorsUsed.size
310
+ },
311
+ stats: {
312
+ filesWithMostComponent,
313
+ mostUseds: getXMostUseds(globalMaps, 10)
314
+ }
315
+ },
316
+ derived: {
317
+ byFilepath,
318
+ byComponentInFilepath,
319
+ globalMaps,
320
+ byFilePathMaps
321
+ }
322
+ };
323
+ }
324
+ var getXMostUseds = (globalMaps, pickCount) => {
325
+ return {
326
+ propNames: getMostUsedInMap(globalMaps.byPropertyName, pickCount),
327
+ tokens: getMostUsedInMap(globalMaps.byTokenName, pickCount),
328
+ shorthands: getMostUsedInMap(globalMaps.byShorthand, pickCount),
329
+ conditions: getMostUsedInMap(globalMaps.byConditionName, pickCount),
330
+ propertyPaths: getMostUsedInMap(globalMaps.byPropertyPath, pickCount),
331
+ categories: getMostUsedInMap(globalMaps.byTokenType, pickCount),
332
+ types: getMostUsedInMap(globalMaps.byType, pickCount),
333
+ componentNames: getMostUsedInMap(globalMaps.byComponentName, pickCount),
334
+ fromKinds: getMostUsedInMap(globalMaps.fromKind, pickCount),
335
+ componentOfKinds: getMostUsedInMap(globalMaps.byComponentOfKind, pickCount),
336
+ colors: getMostUsedInMap(globalMaps.colorsUsed, pickCount)
337
+ };
338
+ };
339
+ var getMostUsedInMap = (map, pickCount) => {
340
+ return Array.from(map.entries()).map(([key, list]) => [key, list.size]).sort((a, b) => b[1] - a[1]).slice(0, pickCount).map(([key, count]) => ({ key, count }));
341
+ };
342
+ var defaultGroupNames = [
343
+ "System",
344
+ "Container",
345
+ "Display",
346
+ "Visibility",
347
+ "Position",
348
+ "Transform",
349
+ "Flex Layout",
350
+ "Grid Layout",
351
+ "Layout",
352
+ "Border",
353
+ "Border Radius",
354
+ "Width",
355
+ "Height",
356
+ "Margin",
357
+ "Padding",
358
+ "Color",
359
+ "Typography",
360
+ "Background",
361
+ "Shadow",
362
+ "Table",
363
+ "List",
364
+ "Scroll",
365
+ "Interactivity",
366
+ "Transition",
367
+ "Effect",
368
+ "Other"
369
+ ];
370
+ function getPropertyGroupMap(ctx) {
371
+ const groups = new Map(defaultGroupNames.map((name) => [name, /* @__PURE__ */ new Set()]));
372
+ const groupByProp = /* @__PURE__ */ new Map();
373
+ const systemGroup = groups.get("System");
374
+ systemGroup.add("base");
375
+ systemGroup.add("colorPalette");
376
+ const otherStyleProps = groups.get("Other");
377
+ Object.entries(ctx.utility.config).map(([key, value]) => {
378
+ const group = value?.group;
379
+ if (!group) {
380
+ otherStyleProps.add(key);
381
+ return;
382
+ }
383
+ if (!groups.has(group)) {
384
+ groups.set(group, /* @__PURE__ */ new Set());
385
+ }
386
+ const set = groups.get(group);
387
+ if (value.shorthand) {
388
+ if (Array.isArray(value.shorthand)) {
389
+ value.shorthand.forEach((shorthand) => {
390
+ set.add(shorthand);
391
+ groupByProp.set(shorthand, group);
392
+ });
393
+ } else {
394
+ set.add(value.shorthand);
395
+ groupByProp.set(value.shorthand, group);
396
+ }
397
+ }
398
+ set.add(key);
399
+ groupByProp.set(key, group);
400
+ });
401
+ return { groups, groupByProp };
402
+ }
403
+ function createReportMaps() {
404
+ return {
405
+ byComponentOfKind: /* @__PURE__ */ new Map(),
406
+ byPropertyName: /* @__PURE__ */ new Map(),
407
+ byTokenType: /* @__PURE__ */ new Map(),
408
+ byConditionName: /* @__PURE__ */ new Map(),
409
+ byShorthand: /* @__PURE__ */ new Map(),
410
+ byTokenName: /* @__PURE__ */ new Map(),
411
+ byPropertyPath: /* @__PURE__ */ new Map(),
412
+ fromKind: /* @__PURE__ */ new Map(),
413
+ byType: /* @__PURE__ */ new Map(),
414
+ byComponentName: /* @__PURE__ */ new Map(),
415
+ colorsUsed: /* @__PURE__ */ new Map()
416
+ };
417
+ }
418
+
7
419
  // src/parser.ts
8
- import { box, extract, unbox } from "@pandacss/extractor";
420
+ import { box as box2, extract, unbox } from "@pandacss/extractor";
9
421
  import { logger } from "@pandacss/logger";
10
422
  import { astish } from "@pandacss/shared";
11
423
  import { Node } from "ts-morph";
@@ -194,7 +606,8 @@ var evaluateOptions = {
194
606
  environment: defaultEnv
195
607
  };
196
608
  function createParser(context) {
197
- const { jsx, imports, recipes, syntax } = context;
609
+ const { jsx, imports, recipes, config } = context;
610
+ const syntax = config.syntax;
198
611
  return function parse2(sourceFile, encoder, options) {
199
612
  if (!sourceFile)
200
613
  return;
@@ -279,7 +692,7 @@ function createParser(context) {
279
692
  } else {
280
693
  parserResult.set(name2, {
281
694
  name: name2,
282
- box: query.box.value[0] ?? box.fallback(query.box),
695
+ box: query.box.value[0] ?? box2.fallback(query.box),
283
696
  data: combineResult(unbox(query.box.value[0]))
284
697
  });
285
698
  }
@@ -287,7 +700,7 @@ function createParser(context) {
287
700
  const obj = astish(query.box.value);
288
701
  parserResult.set(name2, {
289
702
  name: name2,
290
- box: query.box ?? box.fallback(query.box),
703
+ box: query.box ?? box2.fallback(query.box),
291
704
  data: [obj]
292
705
  });
293
706
  }
@@ -297,7 +710,7 @@ function createParser(context) {
297
710
  if (query.kind === "call-expression") {
298
711
  parserResult.setPattern(name2, {
299
712
  name: name2,
300
- box: query.box.value[0] ?? box.fallback(query.box),
713
+ box: query.box.value[0] ?? box2.fallback(query.box),
301
714
  data: combineResult(unbox(query.box.value[0]))
302
715
  });
303
716
  }
@@ -307,7 +720,7 @@ function createParser(context) {
307
720
  if (query.kind === "call-expression") {
308
721
  parserResult.setRecipe(name2, {
309
722
  name: name2,
310
- box: query.box.value[0] ?? box.fallback(query.box),
723
+ box: query.box.value[0] ?? box2.fallback(query.box),
311
724
  data: combineResult(unbox(query.box.value[0]))
312
725
  });
313
726
  }
@@ -316,17 +729,17 @@ function createParser(context) {
316
729
  result.queryList.forEach((query) => {
317
730
  if (query.kind === "call-expression" && query.box.value[1]) {
318
731
  const map = query.box.value[1];
319
- const boxNode = box.isMap(map) ? map : box.fallback(query.box);
732
+ const boxNode = box2.isMap(map) ? map : box2.fallback(query.box);
320
733
  const combined = combineResult(unbox(boxNode));
321
734
  const transformed = options?.transform?.({ type: "jsx-factory", data: combined });
322
735
  const result2 = { name, box: boxNode, data: transformed ?? combined };
323
- if (box.isRecipe(map)) {
736
+ if (box2.isRecipe(map)) {
324
737
  parserResult.setCva(result2);
325
738
  } else {
326
739
  parserResult.set("css", result2);
327
740
  }
328
741
  const recipeOptions = query.box.value[2];
329
- if (box.isUnresolvable(map) && recipeOptions && box.isMap(recipeOptions) && recipeOptions.value.has("defaultProps")) {
742
+ if (box2.isUnresolvable(map) && recipeOptions && box2.isMap(recipeOptions) && recipeOptions.value.has("defaultProps")) {
330
743
  const maybeIdentifier = map.getNode();
331
744
  if (Node.isIdentifier(maybeIdentifier)) {
332
745
  const name2 = maybeIdentifier.getText();
@@ -343,7 +756,7 @@ function createParser(context) {
343
756
  const obj = astish(query.box.value);
344
757
  parserResult.set("css", {
345
758
  name,
346
- box: query.box ?? box.fallback(query.box),
759
+ box: query.box ?? box2.fallback(query.box),
347
760
  data: [obj]
348
761
  });
349
762
  }
@@ -352,11 +765,11 @@ function createParser(context) {
352
765
  result.queryList.forEach((query) => {
353
766
  if (query.kind === "call-expression") {
354
767
  const map = query.box.value[0];
355
- const boxNode = box.isMap(map) ? map : box.fallback(query.box);
768
+ const boxNode = box2.isMap(map) ? map : box2.fallback(query.box);
356
769
  const combined = combineResult(unbox(boxNode));
357
770
  const transformed = options?.transform?.({ type: "jsx-factory", data: combined });
358
771
  const result2 = { name: name2, box: boxNode, data: transformed ?? combined };
359
- if (box.isRecipe(map)) {
772
+ if (box2.isRecipe(map)) {
360
773
  parserResult.setCva(result2);
361
774
  } else {
362
775
  parserResult.set("css", result2);
@@ -365,7 +778,7 @@ function createParser(context) {
365
778
  const obj = astish(query.box.value);
366
779
  parserResult.set("css", {
367
780
  name: name2,
368
- box: query.box ?? box.fallback(query.box),
781
+ box: query.box ?? box2.fallback(query.box),
369
782
  data: [obj]
370
783
  });
371
784
  }
@@ -517,6 +930,9 @@ var Project = class {
517
930
  }
518
931
  project;
519
932
  parser;
933
+ get parserOptions() {
934
+ return this.options.parserOptions;
935
+ }
520
936
  get files() {
521
937
  return this.options.getFiles();
522
938
  }
@@ -615,6 +1031,10 @@ var Project = class {
615
1031
  }
616
1032
  return content;
617
1033
  };
1034
+ classify = (fileMap) => {
1035
+ const { parserOptions } = this.options;
1036
+ return classifyProject(parserOptions, fileMap);
1037
+ };
618
1038
  };
619
1039
  export {
620
1040
  ParserResult,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/parser",
3
- "version": "0.48.1",
3
+ "version": "0.50.0",
4
4
  "description": "The static parser for panda css",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -29,19 +29,19 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@vue/compiler-sfc": "3.4.19",
32
- "magic-string": "0.30.14",
32
+ "magic-string": "0.30.17",
33
33
  "ts-morph": "21.0.1",
34
34
  "ts-pattern": "5.0.8",
35
- "@pandacss/config": "^0.48.1",
36
- "@pandacss/core": "^0.48.1",
37
- "@pandacss/extractor": "0.48.1",
38
- "@pandacss/logger": "0.48.1",
39
- "@pandacss/shared": "0.48.1",
40
- "@pandacss/types": "0.48.1"
35
+ "@pandacss/config": "^0.50.0",
36
+ "@pandacss/core": "^0.50.0",
37
+ "@pandacss/extractor": "0.50.0",
38
+ "@pandacss/logger": "0.50.0",
39
+ "@pandacss/shared": "0.50.0",
40
+ "@pandacss/types": "0.50.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@vue/compiler-core": "3.4.19",
44
- "@pandacss/generator": "0.48.1"
44
+ "@pandacss/generator": "0.50.0"
45
45
  },
46
46
  "files": [
47
47
  "dist"