@pandacss/parser 0.17.0 → 0.17.2
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 +14 -12
- package/dist/index.d.ts +14 -12
- package/dist/index.js +66 -58
- package/dist/index.mjs +66 -58
- package/package.json +20 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
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
|
-
|
|
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) =>
|
|
72
|
-
addSourceFile: (filePath: string, content: string) =>
|
|
71
|
+
createSourceFile: (filePath: string) => SourceFile;
|
|
72
|
+
addSourceFile: (filePath: string, content: string) => SourceFile;
|
|
73
73
|
parseSourceFile: (filePath: string) => ParserResult | undefined;
|
|
74
|
-
reloadSourceFile: (filePath: string) =>
|
|
74
|
+
reloadSourceFile: (filePath: string) => void;
|
|
75
75
|
reloadSourceFiles: () => void;
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
files: string[];
|
|
77
|
+
getFiles: () => string[];
|
|
78
|
+
readFile: (filePath: string) => string;
|
|
79
|
+
}
|
|
78
80
|
|
|
79
|
-
export {
|
|
81
|
+
export { PandaProject, ParserResult, createParserResult, createProject };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
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
|
-
|
|
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) =>
|
|
72
|
-
addSourceFile: (filePath: string, content: string) =>
|
|
71
|
+
createSourceFile: (filePath: string) => SourceFile;
|
|
72
|
+
addSourceFile: (filePath: string, content: string) => SourceFile;
|
|
73
73
|
parseSourceFile: (filePath: string) => ParserResult | undefined;
|
|
74
|
-
reloadSourceFile: (filePath: string) =>
|
|
74
|
+
reloadSourceFile: (filePath: string) => void;
|
|
75
75
|
reloadSourceFiles: () => void;
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
files: string[];
|
|
77
|
+
getFiles: () => string[];
|
|
78
|
+
readFile: (filePath: string) => string;
|
|
79
|
+
}
|
|
78
80
|
|
|
79
|
-
export {
|
|
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 = ({
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
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
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
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
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
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
|
-
|
|
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 = ({
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
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
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
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
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
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
|
-
|
|
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.17.
|
|
3
|
+
"version": "0.17.2",
|
|
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.17.
|
|
20
|
-
"@pandacss/extractor": "0.17.
|
|
21
|
-
"@pandacss/is-valid-prop": "0.17.
|
|
22
|
-
"@pandacss/logger": "0.17.
|
|
23
|
-
"@pandacss/shared": "0.17.
|
|
24
|
-
"@pandacss/types": "0.17.
|
|
30
|
+
"@pandacss/config": "^0.17.2",
|
|
31
|
+
"@pandacss/extractor": "0.17.2",
|
|
32
|
+
"@pandacss/is-valid-prop": "0.17.2",
|
|
33
|
+
"@pandacss/logger": "0.17.2",
|
|
34
|
+
"@pandacss/shared": "0.17.2",
|
|
35
|
+
"@pandacss/types": "0.17.2"
|
|
25
36
|
},
|
|
26
37
|
"devDependencies": {
|
|
27
38
|
"hookable": "5.5.3",
|
|
28
|
-
"@pandacss/fixture": "0.17.
|
|
29
|
-
"@pandacss/generator": "0.17.
|
|
39
|
+
"@pandacss/fixture": "0.17.2",
|
|
40
|
+
"@pandacss/generator": "0.17.2"
|
|
30
41
|
},
|
|
31
42
|
"files": [
|
|
32
43
|
"dist"
|