@pandacss/parser 0.16.0 → 0.17.1

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,4 @@
1
- import * as ts_morph from 'ts-morph';
2
- import { ProjectOptions as ProjectOptions$1 } from 'ts-morph';
1
+ import { ProjectOptions as ProjectOptions$1, SourceFile } from 'ts-morph';
3
2
  import { ResultItem, Config, ConfigTsOptions, Runtime, PandaHookable } from '@pandacss/types';
4
3
  import { Generator } from '@pandacss/generator';
5
4
 
@@ -40,7 +39,7 @@ declare const createParserResult: () => ParserResult;
40
39
  type ParserPatternNode = Generator['patterns']['details'][number];
41
40
  type ParserRecipeNode = Generator['recipes']['details'][number];
42
41
  type ParserNodeOptions = ParserPatternNode | ParserRecipeNode;
43
- type ParserOptions = {
42
+ interface ParserOptions {
44
43
  importMap: Record<'css' | 'recipe' | 'pattern' | 'jsx', string[]>;
45
44
  jsx: {
46
45
  framework: string | undefined;
@@ -55,7 +54,7 @@ type ParserOptions = {
55
54
  getPatternsByJsxName: (jsxName: string) => ParserPatternNode[];
56
55
  tsOptions?: ConfigTsOptions;
57
56
  join: Runtime['path']['join'];
58
- };
57
+ }
59
58
 
60
59
  type ProjectOptions = Partial<ProjectOptions$1> & {
61
60
  readFile: Runtime['fs']['readFileSync'];
@@ -65,15 +64,18 @@ type ProjectOptions = Partial<ProjectOptions$1> & {
65
64
  tsOptions?: ConfigTsOptions;
66
65
  };
67
66
 
68
- declare const createProject: ({ getFiles, readFile, parserOptions, hooks, ...projectOptions }: ProjectOptions) => {
69
- getSourceFile: (filePath: string) => ts_morph.SourceFile | undefined;
67
+ declare const createProject: ({ getFiles, readFile, parserOptions, hooks, ...projectOptions }: ProjectOptions) => PandaProject;
68
+ interface PandaProject {
69
+ getSourceFile: (filePath: string) => SourceFile | undefined;
70
70
  removeSourceFile: (filePath: string) => void;
71
- createSourceFile: (filePath: string) => ts_morph.SourceFile;
72
- addSourceFile: (filePath: string, content: string) => ts_morph.SourceFile;
71
+ createSourceFile: (filePath: string) => SourceFile;
72
+ addSourceFile: (filePath: string, content: string) => SourceFile;
73
73
  parseSourceFile: (filePath: string) => ParserResult | undefined;
74
- reloadSourceFile: (filePath: string) => ts_morph.FileSystemRefreshResult | undefined;
74
+ reloadSourceFile: (filePath: string) => void;
75
75
  reloadSourceFiles: () => void;
76
- };
77
- type Project = ReturnType<typeof createProject>;
76
+ files: string[];
77
+ getFiles: () => string[];
78
+ readFile: (filePath: string) => string;
79
+ }
78
80
 
79
- export { ParserResult, Project, createParserResult, createProject };
81
+ export { PandaProject, ParserResult, createParserResult, createProject };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import * as ts_morph from 'ts-morph';
2
- import { ProjectOptions as ProjectOptions$1 } from 'ts-morph';
1
+ import { ProjectOptions as ProjectOptions$1, SourceFile } from 'ts-morph';
3
2
  import { ResultItem, Config, ConfigTsOptions, Runtime, PandaHookable } from '@pandacss/types';
4
3
  import { Generator } from '@pandacss/generator';
5
4
 
@@ -40,7 +39,7 @@ declare const createParserResult: () => ParserResult;
40
39
  type ParserPatternNode = Generator['patterns']['details'][number];
41
40
  type ParserRecipeNode = Generator['recipes']['details'][number];
42
41
  type ParserNodeOptions = ParserPatternNode | ParserRecipeNode;
43
- type ParserOptions = {
42
+ interface ParserOptions {
44
43
  importMap: Record<'css' | 'recipe' | 'pattern' | 'jsx', string[]>;
45
44
  jsx: {
46
45
  framework: string | undefined;
@@ -55,7 +54,7 @@ type ParserOptions = {
55
54
  getPatternsByJsxName: (jsxName: string) => ParserPatternNode[];
56
55
  tsOptions?: ConfigTsOptions;
57
56
  join: Runtime['path']['join'];
58
- };
57
+ }
59
58
 
60
59
  type ProjectOptions = Partial<ProjectOptions$1> & {
61
60
  readFile: Runtime['fs']['readFileSync'];
@@ -65,15 +64,18 @@ type ProjectOptions = Partial<ProjectOptions$1> & {
65
64
  tsOptions?: ConfigTsOptions;
66
65
  };
67
66
 
68
- declare const createProject: ({ getFiles, readFile, parserOptions, hooks, ...projectOptions }: ProjectOptions) => {
69
- getSourceFile: (filePath: string) => ts_morph.SourceFile | undefined;
67
+ declare const createProject: ({ getFiles, readFile, parserOptions, hooks, ...projectOptions }: ProjectOptions) => PandaProject;
68
+ interface PandaProject {
69
+ getSourceFile: (filePath: string) => SourceFile | undefined;
70
70
  removeSourceFile: (filePath: string) => void;
71
- createSourceFile: (filePath: string) => ts_morph.SourceFile;
72
- addSourceFile: (filePath: string, content: string) => ts_morph.SourceFile;
71
+ createSourceFile: (filePath: string) => SourceFile;
72
+ addSourceFile: (filePath: string, content: string) => SourceFile;
73
73
  parseSourceFile: (filePath: string) => ParserResult | undefined;
74
- reloadSourceFile: (filePath: string) => ts_morph.FileSystemRefreshResult | undefined;
74
+ reloadSourceFile: (filePath: string) => void;
75
75
  reloadSourceFiles: () => void;
76
- };
77
- type Project = ReturnType<typeof createProject>;
76
+ files: string[];
77
+ getFiles: () => string[];
78
+ readFile: (filePath: string) => string;
79
+ }
78
80
 
79
- export { ParserResult, Project, createParserResult, createProject };
81
+ export { PandaProject, ParserResult, createParserResult, createProject };
package/dist/index.js CHANGED
@@ -37,7 +37,6 @@ __export(src_exports, {
37
37
  module.exports = __toCommonJS(src_exports);
38
38
 
39
39
  // src/project.ts
40
- var import_lil_fp = require("lil-fp");
41
40
  var import_ts_morph2 = require("ts-morph");
42
41
 
43
42
  // src/parser.ts
@@ -625,66 +624,75 @@ var createTsProject = (options) => new import_ts_morph2.Project({
625
624
  ...options.compilerOptions
626
625
  }
627
626
  });
628
- var createProject = ({ getFiles, readFile, parserOptions, hooks, ...projectOptions }) => (0, import_lil_fp.pipe)(
629
- {
630
- project: createTsProject(projectOptions),
631
- parser: createParser(parserOptions)
632
- },
633
- import_lil_fp.Obj.assign(({ project, parser }) => ({
634
- getSourceFile: (filePath) => project.getSourceFile(filePath),
635
- removeSourceFile: (filePath) => {
636
- const sourceFile = project.getSourceFile(filePath);
637
- if (sourceFile)
638
- project.removeSourceFile(sourceFile);
639
- },
640
- createSourceFile: (filePath) => project.createSourceFile(filePath, readFile(filePath), {
641
- overwrite: true,
642
- scriptKind: import_ts_morph2.ScriptKind.TSX
643
- }),
644
- addSourceFile: (filePath, content) => project.createSourceFile(filePath, content, {
645
- overwrite: true,
646
- scriptKind: import_ts_morph2.ScriptKind.TSX
647
- }),
648
- parseSourceFile: (filePath) => {
649
- if (filePath.endsWith(".json")) {
650
- const content2 = readFile(filePath);
651
- hooks.callHook("parser:before", filePath, content2);
652
- const result2 = ParserResult.fromJSON(content2).setFilePath(filePath);
653
- hooks.callHook("parser:after", filePath, result2);
654
- return result2;
655
- }
656
- const sourceFile = project.getSourceFile(filePath);
657
- if (!sourceFile)
658
- return;
659
- const content = sourceFile.getText();
660
- const transformed = transformFile(filePath, content);
661
- if (content !== transformed) {
662
- sourceFile.replaceWithText(transformed);
663
- }
664
- hooks.callHook("parser:before", filePath, content);
665
- const result = parser(sourceFile)?.setFilePath(filePath);
666
- hooks.callHook("parser:after", filePath, result);
667
- return result;
627
+ var createProject = ({
628
+ getFiles,
629
+ readFile,
630
+ parserOptions,
631
+ hooks,
632
+ ...projectOptions
633
+ }) => {
634
+ const project = createTsProject(projectOptions);
635
+ const parser = createParser(parserOptions);
636
+ const getSourceFile = (filePath) => project.getSourceFile(filePath);
637
+ const removeSourceFile = (filePath) => {
638
+ const sourceFile = project.getSourceFile(filePath);
639
+ if (sourceFile)
640
+ project.removeSourceFile(sourceFile);
641
+ };
642
+ const createSourceFile = (filePath) => project.createSourceFile(filePath, readFile(filePath), {
643
+ overwrite: true,
644
+ scriptKind: import_ts_morph2.ScriptKind.TSX
645
+ });
646
+ const addSourceFile = (filePath, content) => project.createSourceFile(filePath, content, {
647
+ overwrite: true,
648
+ scriptKind: import_ts_morph2.ScriptKind.TSX
649
+ });
650
+ const parseSourceFile = (filePath) => {
651
+ if (filePath.endsWith(".json")) {
652
+ const content2 = readFile(filePath);
653
+ hooks.callHook("parser:before", filePath, content2);
654
+ const result2 = ParserResult.fromJSON(content2).setFilePath(filePath);
655
+ hooks.callHook("parser:after", filePath, result2);
656
+ return result2;
668
657
  }
669
- })),
670
- (0, import_lil_fp.tap)(({ createSourceFile }) => {
671
- const files = getFiles();
672
- for (const file of files) {
673
- createSourceFile(file);
658
+ const sourceFile = project.getSourceFile(filePath);
659
+ if (!sourceFile)
660
+ return;
661
+ const content = sourceFile.getText();
662
+ const transformed = transformFile(filePath, content);
663
+ if (content !== transformed) {
664
+ sourceFile.replaceWithText(transformed);
674
665
  }
675
- }),
676
- import_lil_fp.Obj.assign(({ getSourceFile, project }) => ({
677
- reloadSourceFile: (filePath) => getSourceFile(filePath)?.refreshFromFileSystemSync(),
678
- reloadSourceFiles: () => {
679
- const files = getFiles();
680
- for (const file of files) {
681
- const source = getSourceFile(file);
682
- source?.refreshFromFileSystemSync() ?? project.addSourceFileAtPath(file);
683
- }
666
+ hooks.callHook("parser:before", filePath, content);
667
+ const result = parser(sourceFile)?.setFilePath(filePath);
668
+ hooks.callHook("parser:after", filePath, result);
669
+ return result;
670
+ };
671
+ const files = getFiles();
672
+ for (const file of files) {
673
+ createSourceFile(file);
674
+ }
675
+ const reloadSourceFile = (filePath) => getSourceFile(filePath)?.refreshFromFileSystemSync();
676
+ const reloadSourceFiles = () => {
677
+ const files2 = getFiles();
678
+ for (const file of files2) {
679
+ const source = getSourceFile(file);
680
+ source?.refreshFromFileSystemSync() ?? project.addSourceFileAtPath(file);
684
681
  }
685
- })),
686
- import_lil_fp.Obj.omit(["project", "parser"])
687
- );
682
+ };
683
+ return {
684
+ getSourceFile,
685
+ removeSourceFile,
686
+ createSourceFile,
687
+ addSourceFile,
688
+ parseSourceFile,
689
+ reloadSourceFile,
690
+ reloadSourceFiles,
691
+ files,
692
+ getFiles,
693
+ readFile
694
+ };
695
+ };
688
696
  var transformFile = (filePath, content) => {
689
697
  if (filePath.endsWith(".vue")) {
690
698
  return vueToTsx(content);
package/dist/index.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  // src/project.ts
2
- import { Obj, pipe, tap } from "lil-fp";
3
2
  import { Project as TsProject, ScriptKind } from "ts-morph";
4
3
 
5
4
  // src/parser.ts
@@ -587,66 +586,75 @@ var createTsProject = (options) => new TsProject({
587
586
  ...options.compilerOptions
588
587
  }
589
588
  });
590
- var createProject = ({ getFiles, readFile, parserOptions, hooks, ...projectOptions }) => pipe(
591
- {
592
- project: createTsProject(projectOptions),
593
- parser: createParser(parserOptions)
594
- },
595
- Obj.assign(({ project, parser }) => ({
596
- getSourceFile: (filePath) => project.getSourceFile(filePath),
597
- removeSourceFile: (filePath) => {
598
- const sourceFile = project.getSourceFile(filePath);
599
- if (sourceFile)
600
- project.removeSourceFile(sourceFile);
601
- },
602
- createSourceFile: (filePath) => project.createSourceFile(filePath, readFile(filePath), {
603
- overwrite: true,
604
- scriptKind: ScriptKind.TSX
605
- }),
606
- addSourceFile: (filePath, content) => project.createSourceFile(filePath, content, {
607
- overwrite: true,
608
- scriptKind: ScriptKind.TSX
609
- }),
610
- parseSourceFile: (filePath) => {
611
- if (filePath.endsWith(".json")) {
612
- const content2 = readFile(filePath);
613
- hooks.callHook("parser:before", filePath, content2);
614
- const result2 = ParserResult.fromJSON(content2).setFilePath(filePath);
615
- hooks.callHook("parser:after", filePath, result2);
616
- return result2;
617
- }
618
- const sourceFile = project.getSourceFile(filePath);
619
- if (!sourceFile)
620
- return;
621
- const content = sourceFile.getText();
622
- const transformed = transformFile(filePath, content);
623
- if (content !== transformed) {
624
- sourceFile.replaceWithText(transformed);
625
- }
626
- hooks.callHook("parser:before", filePath, content);
627
- const result = parser(sourceFile)?.setFilePath(filePath);
628
- hooks.callHook("parser:after", filePath, result);
629
- return result;
589
+ var createProject = ({
590
+ getFiles,
591
+ readFile,
592
+ parserOptions,
593
+ hooks,
594
+ ...projectOptions
595
+ }) => {
596
+ const project = createTsProject(projectOptions);
597
+ const parser = createParser(parserOptions);
598
+ const getSourceFile = (filePath) => project.getSourceFile(filePath);
599
+ const removeSourceFile = (filePath) => {
600
+ const sourceFile = project.getSourceFile(filePath);
601
+ if (sourceFile)
602
+ project.removeSourceFile(sourceFile);
603
+ };
604
+ const createSourceFile = (filePath) => project.createSourceFile(filePath, readFile(filePath), {
605
+ overwrite: true,
606
+ scriptKind: ScriptKind.TSX
607
+ });
608
+ const addSourceFile = (filePath, content) => project.createSourceFile(filePath, content, {
609
+ overwrite: true,
610
+ scriptKind: ScriptKind.TSX
611
+ });
612
+ const parseSourceFile = (filePath) => {
613
+ if (filePath.endsWith(".json")) {
614
+ const content2 = readFile(filePath);
615
+ hooks.callHook("parser:before", filePath, content2);
616
+ const result2 = ParserResult.fromJSON(content2).setFilePath(filePath);
617
+ hooks.callHook("parser:after", filePath, result2);
618
+ return result2;
630
619
  }
631
- })),
632
- tap(({ createSourceFile }) => {
633
- const files = getFiles();
634
- for (const file of files) {
635
- createSourceFile(file);
620
+ const sourceFile = project.getSourceFile(filePath);
621
+ if (!sourceFile)
622
+ return;
623
+ const content = sourceFile.getText();
624
+ const transformed = transformFile(filePath, content);
625
+ if (content !== transformed) {
626
+ sourceFile.replaceWithText(transformed);
636
627
  }
637
- }),
638
- Obj.assign(({ getSourceFile, project }) => ({
639
- reloadSourceFile: (filePath) => getSourceFile(filePath)?.refreshFromFileSystemSync(),
640
- reloadSourceFiles: () => {
641
- const files = getFiles();
642
- for (const file of files) {
643
- const source = getSourceFile(file);
644
- source?.refreshFromFileSystemSync() ?? project.addSourceFileAtPath(file);
645
- }
628
+ hooks.callHook("parser:before", filePath, content);
629
+ const result = parser(sourceFile)?.setFilePath(filePath);
630
+ hooks.callHook("parser:after", filePath, result);
631
+ return result;
632
+ };
633
+ const files = getFiles();
634
+ for (const file of files) {
635
+ createSourceFile(file);
636
+ }
637
+ const reloadSourceFile = (filePath) => getSourceFile(filePath)?.refreshFromFileSystemSync();
638
+ const reloadSourceFiles = () => {
639
+ const files2 = getFiles();
640
+ for (const file of files2) {
641
+ const source = getSourceFile(file);
642
+ source?.refreshFromFileSystemSync() ?? project.addSourceFileAtPath(file);
646
643
  }
647
- })),
648
- Obj.omit(["project", "parser"])
649
- );
644
+ };
645
+ return {
646
+ getSourceFile,
647
+ removeSourceFile,
648
+ createSourceFile,
649
+ addSourceFile,
650
+ parseSourceFile,
651
+ reloadSourceFile,
652
+ reloadSourceFiles,
653
+ files,
654
+ getFiles,
655
+ readFile
656
+ };
657
+ };
650
658
  var transformFile = (filePath, content) => {
651
659
  if (filePath.endsWith(".vue")) {
652
660
  return vueToTsx(content);
package/package.json CHANGED
@@ -1,10 +1,21 @@
1
1
  {
2
2
  "name": "@pandacss/parser",
3
- "version": "0.16.0",
3
+ "version": "0.17.1",
4
4
  "description": "The static parser for panda css",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "source": "./src/index.ts",
11
+ "types": "./dist/index.d.ts",
12
+ "import": {
13
+ "types": "./dist/index.d.mts",
14
+ "default": "./dist/index.mjs"
15
+ },
16
+ "require": "./dist/index.js"
17
+ }
18
+ },
8
19
  "author": "Segun Adebayo <joseshegs@gmail.com>",
9
20
  "sideEffects": false,
10
21
  "publishConfig": {
@@ -16,17 +27,17 @@
16
27
  "magic-string": "^0.30.2",
17
28
  "ts-morph": "19.0.0",
18
29
  "ts-pattern": "5.0.5",
19
- "@pandacss/config": "^0.16.0",
20
- "@pandacss/extractor": "0.16.0",
21
- "@pandacss/is-valid-prop": "0.16.0",
22
- "@pandacss/logger": "0.16.0",
23
- "@pandacss/shared": "0.16.0",
24
- "@pandacss/types": "0.16.0"
30
+ "@pandacss/config": "^0.17.1",
31
+ "@pandacss/shared": "0.17.1",
32
+ "@pandacss/types": "0.17.1",
33
+ "@pandacss/extractor": "0.17.1",
34
+ "@pandacss/logger": "0.17.1",
35
+ "@pandacss/is-valid-prop": "0.17.1"
25
36
  },
26
37
  "devDependencies": {
27
38
  "hookable": "5.5.3",
28
- "@pandacss/fixture": "0.16.0",
29
- "@pandacss/generator": "0.16.0"
39
+ "@pandacss/generator": "0.17.1",
40
+ "@pandacss/fixture": "0.17.1"
30
41
  },
31
42
  "files": [
32
43
  "dist"