@pandacss/parser 0.0.0-dev-20230614111156 → 0.0.0-dev-20230614142625

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
@@ -1,6 +1,6 @@
1
1
  import * as ts_morph from 'ts-morph';
2
2
  import { ProjectOptions as ProjectOptions$1 } from 'ts-morph';
3
- import { ResultItem, RecipeConfig } from '@pandacss/types';
3
+ import { ResultItem, RecipeConfig, PandaHookable } from '@pandacss/types';
4
4
 
5
5
  declare class ParserResult {
6
6
  jsx: Set<ResultItem>;
@@ -8,12 +8,14 @@ declare class ParserResult {
8
8
  cva: Set<ResultItem>;
9
9
  recipe: Map<string, Set<ResultItem>>;
10
10
  pattern: Map<string, Set<ResultItem>>;
11
+ filePath: string | undefined;
11
12
  set(name: 'cva' | 'css', result: ResultItem): void;
12
13
  setCva(result: ResultItem): void;
13
14
  setJsx(result: ResultItem): void;
14
15
  setPattern(name: string, result: ResultItem): void;
15
16
  setRecipe(name: string, result: ResultItem): void;
16
17
  isEmpty(): boolean;
18
+ setFilePath(filePath: string): this;
17
19
  toArray(): ResultItem[];
18
20
  toJSON(): {
19
21
  css: ResultItem[];
@@ -59,9 +61,10 @@ type ParserOptions = {
59
61
  type ProjectOptions = Partial<ProjectOptions$1> & {
60
62
  readFile: (filePath: string) => string;
61
63
  getFiles: () => string[];
64
+ hooks: PandaHookable;
62
65
  parserOptions: ParserOptions;
63
66
  };
64
- declare const createProject: ({ getFiles, readFile, parserOptions, ...projectOptions }: ProjectOptions) => {
67
+ declare const createProject: ({ getFiles, readFile, parserOptions, hooks, ...projectOptions }: ProjectOptions) => {
65
68
  getSourceFile: (filePath: string) => ts_morph.SourceFile | undefined;
66
69
  removeSourceFile: (filePath: string) => void;
67
70
  createSourceFile: (filePath: string) => ts_morph.SourceFile;
package/dist/index.js CHANGED
@@ -93,6 +93,7 @@ var ParserResult = class {
93
93
  cva = /* @__PURE__ */ new Set();
94
94
  recipe = /* @__PURE__ */ new Map();
95
95
  pattern = /* @__PURE__ */ new Map();
96
+ filePath;
96
97
  set(name, result) {
97
98
  this[name].add({ type: "object", ...result });
98
99
  }
@@ -113,6 +114,10 @@ var ParserResult = class {
113
114
  isEmpty() {
114
115
  return this.css.size === 0 && this.cva.size === 0 && this.recipe.size === 0 && this.pattern.size === 0 && this.jsx.size === 0;
115
116
  }
117
+ setFilePath(filePath) {
118
+ this.filePath = filePath;
119
+ return this;
120
+ }
116
121
  toArray() {
117
122
  const result = [];
118
123
  this.css.forEach((item) => result.push(item));
@@ -379,7 +384,7 @@ var createTsProject = (options) => new import_ts_morph2.Project({
379
384
  ...options.compilerOptions
380
385
  }
381
386
  });
382
- var createProject = ({ getFiles, readFile, parserOptions, ...projectOptions }) => (0, import_lil_fp.pipe)(
387
+ var createProject = ({ getFiles, readFile, parserOptions, hooks, ...projectOptions }) => (0, import_lil_fp.pipe)(
383
388
  {
384
389
  project: createTsProject(projectOptions),
385
390
  parser: createParser(parserOptions)
@@ -400,7 +405,21 @@ var createProject = ({ getFiles, readFile, parserOptions, ...projectOptions }) =
400
405
  scriptKind: import_ts_morph2.ScriptKind.TSX
401
406
  }),
402
407
  parseSourceFile: (filePath) => {
403
- return filePath.endsWith(".json") ? ParserResult.fromJSON(readFile(filePath)) : parser(project.getSourceFile(filePath));
408
+ if (filePath.endsWith(".json")) {
409
+ const content2 = readFile(filePath);
410
+ hooks.callHook("parser:before", filePath, content2);
411
+ const result2 = ParserResult.fromJSON(content2).setFilePath(filePath);
412
+ hooks.callHook("parser:after", filePath, result2);
413
+ return result2;
414
+ }
415
+ const sourceFile = project.getSourceFile(filePath);
416
+ if (!sourceFile)
417
+ return;
418
+ const content = sourceFile.getText();
419
+ hooks.callHook("parser:before", filePath, content);
420
+ const result = parser(sourceFile)?.setFilePath(filePath);
421
+ hooks.callHook("parser:after", filePath, result);
422
+ return result;
404
423
  }
405
424
  })),
406
425
  (0, import_lil_fp.tap)(({ createSourceFile }) => {
package/dist/index.mjs CHANGED
@@ -65,6 +65,7 @@ var ParserResult = class {
65
65
  cva = /* @__PURE__ */ new Set();
66
66
  recipe = /* @__PURE__ */ new Map();
67
67
  pattern = /* @__PURE__ */ new Map();
68
+ filePath;
68
69
  set(name, result) {
69
70
  this[name].add({ type: "object", ...result });
70
71
  }
@@ -85,6 +86,10 @@ var ParserResult = class {
85
86
  isEmpty() {
86
87
  return this.css.size === 0 && this.cva.size === 0 && this.recipe.size === 0 && this.pattern.size === 0 && this.jsx.size === 0;
87
88
  }
89
+ setFilePath(filePath) {
90
+ this.filePath = filePath;
91
+ return this;
92
+ }
88
93
  toArray() {
89
94
  const result = [];
90
95
  this.css.forEach((item) => result.push(item));
@@ -351,7 +356,7 @@ var createTsProject = (options) => new TsProject({
351
356
  ...options.compilerOptions
352
357
  }
353
358
  });
354
- var createProject = ({ getFiles, readFile, parserOptions, ...projectOptions }) => pipe(
359
+ var createProject = ({ getFiles, readFile, parserOptions, hooks, ...projectOptions }) => pipe(
355
360
  {
356
361
  project: createTsProject(projectOptions),
357
362
  parser: createParser(parserOptions)
@@ -372,7 +377,21 @@ var createProject = ({ getFiles, readFile, parserOptions, ...projectOptions }) =
372
377
  scriptKind: ScriptKind.TSX
373
378
  }),
374
379
  parseSourceFile: (filePath) => {
375
- return filePath.endsWith(".json") ? ParserResult.fromJSON(readFile(filePath)) : parser(project.getSourceFile(filePath));
380
+ if (filePath.endsWith(".json")) {
381
+ const content2 = readFile(filePath);
382
+ hooks.callHook("parser:before", filePath, content2);
383
+ const result2 = ParserResult.fromJSON(content2).setFilePath(filePath);
384
+ hooks.callHook("parser:after", filePath, result2);
385
+ return result2;
386
+ }
387
+ const sourceFile = project.getSourceFile(filePath);
388
+ if (!sourceFile)
389
+ return;
390
+ const content = sourceFile.getText();
391
+ hooks.callHook("parser:before", filePath, content);
392
+ const result = parser(sourceFile)?.setFilePath(filePath);
393
+ hooks.callHook("parser:after", filePath, result);
394
+ return result;
376
395
  }
377
396
  })),
378
397
  tap(({ createSourceFile }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/parser",
3
- "version": "0.0.0-dev-20230614111156",
3
+ "version": "0.0.0-dev-20230614142625",
4
4
  "description": "The static parser for panda css",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -14,15 +14,16 @@
14
14
  "lil-fp": "1.4.5",
15
15
  "ts-morph": "18.0.0",
16
16
  "ts-pattern": "4.3.0",
17
- "@pandacss/extractor": "0.0.0-dev-20230614111156",
18
- "@pandacss/is-valid-prop": "0.0.0-dev-20230614111156",
19
- "@pandacss/logger": "0.0.0-dev-20230614111156",
20
- "@pandacss/shared": "0.0.0-dev-20230614111156",
21
- "@pandacss/types": "0.0.0-dev-20230614111156"
17
+ "@pandacss/extractor": "0.0.0-dev-20230614142625",
18
+ "@pandacss/is-valid-prop": "0.0.0-dev-20230614142625",
19
+ "@pandacss/logger": "0.0.0-dev-20230614142625",
20
+ "@pandacss/shared": "0.0.0-dev-20230614142625",
21
+ "@pandacss/types": "0.0.0-dev-20230614142625"
22
22
  },
23
23
  "devDependencies": {
24
- "@pandacss/fixture": "0.0.0-dev-20230614111156",
25
- "@pandacss/generator": "0.0.0-dev-20230614111156"
24
+ "hookable": "5.5.3",
25
+ "@pandacss/fixture": "0.0.0-dev-20230614142625",
26
+ "@pandacss/generator": "0.0.0-dev-20230614142625"
26
27
  },
27
28
  "files": [
28
29
  "dist"