@pandacss/parser 0.0.0-dev-20230530122200 → 0.0.0-dev-20230530153755

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,8 +1,36 @@
1
- import * as _pandacss_types from '@pandacss/types';
2
- import { AnyRecipeConfig } from '@pandacss/types';
1
+ import { ResultItem, AnyRecipeConfig } from '@pandacss/types';
3
2
  import * as ts_morph from 'ts-morph';
4
3
  import { ProjectOptions as ProjectOptions$1 } from 'ts-morph';
5
4
 
5
+ declare class ParserResult {
6
+ jsx: Set<ResultItem>;
7
+ css: Set<ResultItem>;
8
+ cva: Set<ResultItem>;
9
+ recipe: Map<string, Set<ResultItem>>;
10
+ pattern: Map<string, Set<ResultItem>>;
11
+ set(name: 'cva' | 'css', result: ResultItem): void;
12
+ setCva(result: ResultItem): void;
13
+ setJsx(result: ResultItem): void;
14
+ setPattern(name: string, result: ResultItem): void;
15
+ setRecipe(name: string, result: ResultItem): void;
16
+ isEmpty(): boolean;
17
+ toArray(): ResultItem[];
18
+ toJSON(): {
19
+ css: ResultItem[];
20
+ cva: ResultItem[];
21
+ recipe: {
22
+ [k: string]: ResultItem[];
23
+ };
24
+ pattern: {
25
+ [k: string]: ResultItem[];
26
+ };
27
+ jsx: ResultItem[];
28
+ };
29
+ merge(result: ParserResult): this;
30
+ static fromJson(json: string): ParserResult;
31
+ }
32
+ declare const createParserResult: () => ParserResult;
33
+
6
34
  type ParserPatternNode = {
7
35
  name: string;
8
36
  type: 'pattern';
@@ -37,10 +65,10 @@ declare const createProject: ({ getFiles, readFile, parserOptions, ...projectOpt
37
65
  getSourceFile: (filePath: string) => ts_morph.SourceFile | undefined;
38
66
  removeSourceFile: (filePath: string) => void;
39
67
  createSourceFile: (filePath: string) => ts_morph.SourceFile;
40
- parseSourceFile: (filePath: string) => _pandacss_types.ParserResult | undefined;
68
+ parseSourceFile: (filePath: string) => ParserResult | undefined;
41
69
  reloadSourceFile: (filePath: string) => ts_morph.FileSystemRefreshResult | undefined;
42
70
  reloadSourceFiles: () => void;
43
71
  };
44
72
  type Project = ReturnType<typeof createProject>;
45
73
 
46
- export { Project, ProjectOptions, createProject };
74
+ export { ParserResult, Project, ProjectOptions, createParserResult, createProject };
package/dist/index.js CHANGED
@@ -20,6 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
+ ParserResult: () => ParserResult,
24
+ createParserResult: () => createParserResult,
23
25
  createProject: () => createProject
24
26
  });
25
27
  module.exports = __toCommonJS(src_exports);
@@ -78,33 +80,33 @@ function getImportDeclarations(file, options) {
78
80
  }
79
81
 
80
82
  // src/parser-result.ts
81
- var createParserResult = () => ({
82
- jsx: /* @__PURE__ */ new Set(),
83
- css: /* @__PURE__ */ new Set(),
84
- cva: /* @__PURE__ */ new Set(),
85
- recipe: /* @__PURE__ */ new Map(),
86
- pattern: /* @__PURE__ */ new Map(),
83
+ var ParserResult = class {
84
+ jsx = /* @__PURE__ */ new Set();
85
+ css = /* @__PURE__ */ new Set();
86
+ cva = /* @__PURE__ */ new Set();
87
+ recipe = /* @__PURE__ */ new Map();
88
+ pattern = /* @__PURE__ */ new Map();
87
89
  set(name, result) {
88
90
  this[name].add({ type: "object", ...result });
89
- },
91
+ }
90
92
  setCva(result) {
91
93
  this.cva.add({ type: "cva", ...result });
92
- },
94
+ }
93
95
  setJsx(result) {
94
96
  this.jsx.add({ type: "jsx", ...result });
95
- },
97
+ }
96
98
  setPattern(name, result) {
97
99
  this.pattern.get(name) ?? this.pattern.set(name, /* @__PURE__ */ new Set());
98
100
  this.pattern.get(name)?.add({ type: "pattern", name, ...result });
99
- },
101
+ }
100
102
  setRecipe(name, result) {
101
103
  this.recipe.get(name) ?? this.recipe.set(name, /* @__PURE__ */ new Set());
102
104
  this.recipe.get(name)?.add({ type: "recipe", ...result });
103
- },
105
+ }
104
106
  isEmpty() {
105
107
  return this.css.size === 0 && this.cva.size === 0 && this.recipe.size === 0 && this.pattern.size === 0 && this.jsx.size === 0;
106
- },
107
- getAll() {
108
+ }
109
+ toArray() {
108
110
  const result = [];
109
111
  this.css.forEach((item) => result.push(item));
110
112
  this.cva.forEach((item) => result.push(item));
@@ -113,7 +115,41 @@ var createParserResult = () => ({
113
115
  this.jsx.forEach((item) => result.push(item));
114
116
  return result;
115
117
  }
116
- });
118
+ toJSON() {
119
+ return {
120
+ css: Array.from(this.css),
121
+ cva: Array.from(this.cva),
122
+ recipe: Object.fromEntries(Array.from(this.recipe.entries()).map(([key, value]) => [key, Array.from(value)])),
123
+ pattern: Object.fromEntries(Array.from(this.pattern.entries()).map(([key, value]) => [key, Array.from(value)])),
124
+ jsx: Array.from(this.jsx)
125
+ };
126
+ }
127
+ merge(result) {
128
+ result.css.forEach((item) => this.css.add(item));
129
+ result.cva.forEach((item) => this.cva.add(item));
130
+ result.recipe.forEach((items, name) => {
131
+ this.recipe.get(name) ?? this.recipe.set(name, /* @__PURE__ */ new Set());
132
+ items.forEach((item) => this.recipe.get(name)?.add(item));
133
+ });
134
+ result.pattern.forEach((items, name) => {
135
+ this.pattern.get(name) ?? this.pattern.set(name, /* @__PURE__ */ new Set());
136
+ items.forEach((item) => this.pattern.get(name)?.add(item));
137
+ });
138
+ result.jsx.forEach((item) => this.jsx.add(item));
139
+ return this;
140
+ }
141
+ static fromJson(json) {
142
+ const data = JSON.parse(json);
143
+ const result = new ParserResult();
144
+ result.css = new Set(data.css);
145
+ result.cva = new Set(data.cva);
146
+ result.recipe = new Map(Object.entries(data.recipe));
147
+ result.pattern = new Map(Object.entries(data.pattern));
148
+ result.jsx = new Set(data.jsx);
149
+ return result;
150
+ }
151
+ };
152
+ var createParserResult = () => new ParserResult();
117
153
 
118
154
  // src/parser.ts
119
155
  var isNodeRecipe = (node) => node.type === "recipe";
@@ -376,5 +412,7 @@ var createProject = ({ getFiles, readFile, parserOptions, ...projectOptions }) =
376
412
  );
377
413
  // Annotate the CommonJS export names for ESM import in node:
378
414
  0 && (module.exports = {
415
+ ParserResult,
416
+ createParserResult,
379
417
  createProject
380
418
  });
package/dist/index.mjs CHANGED
@@ -52,33 +52,33 @@ function getImportDeclarations(file, options) {
52
52
  }
53
53
 
54
54
  // src/parser-result.ts
55
- var createParserResult = () => ({
56
- jsx: /* @__PURE__ */ new Set(),
57
- css: /* @__PURE__ */ new Set(),
58
- cva: /* @__PURE__ */ new Set(),
59
- recipe: /* @__PURE__ */ new Map(),
60
- pattern: /* @__PURE__ */ new Map(),
55
+ var ParserResult = class {
56
+ jsx = /* @__PURE__ */ new Set();
57
+ css = /* @__PURE__ */ new Set();
58
+ cva = /* @__PURE__ */ new Set();
59
+ recipe = /* @__PURE__ */ new Map();
60
+ pattern = /* @__PURE__ */ new Map();
61
61
  set(name, result) {
62
62
  this[name].add({ type: "object", ...result });
63
- },
63
+ }
64
64
  setCva(result) {
65
65
  this.cva.add({ type: "cva", ...result });
66
- },
66
+ }
67
67
  setJsx(result) {
68
68
  this.jsx.add({ type: "jsx", ...result });
69
- },
69
+ }
70
70
  setPattern(name, result) {
71
71
  this.pattern.get(name) ?? this.pattern.set(name, /* @__PURE__ */ new Set());
72
72
  this.pattern.get(name)?.add({ type: "pattern", name, ...result });
73
- },
73
+ }
74
74
  setRecipe(name, result) {
75
75
  this.recipe.get(name) ?? this.recipe.set(name, /* @__PURE__ */ new Set());
76
76
  this.recipe.get(name)?.add({ type: "recipe", ...result });
77
- },
77
+ }
78
78
  isEmpty() {
79
79
  return this.css.size === 0 && this.cva.size === 0 && this.recipe.size === 0 && this.pattern.size === 0 && this.jsx.size === 0;
80
- },
81
- getAll() {
80
+ }
81
+ toArray() {
82
82
  const result = [];
83
83
  this.css.forEach((item) => result.push(item));
84
84
  this.cva.forEach((item) => result.push(item));
@@ -87,7 +87,41 @@ var createParserResult = () => ({
87
87
  this.jsx.forEach((item) => result.push(item));
88
88
  return result;
89
89
  }
90
- });
90
+ toJSON() {
91
+ return {
92
+ css: Array.from(this.css),
93
+ cva: Array.from(this.cva),
94
+ recipe: Object.fromEntries(Array.from(this.recipe.entries()).map(([key, value]) => [key, Array.from(value)])),
95
+ pattern: Object.fromEntries(Array.from(this.pattern.entries()).map(([key, value]) => [key, Array.from(value)])),
96
+ jsx: Array.from(this.jsx)
97
+ };
98
+ }
99
+ merge(result) {
100
+ result.css.forEach((item) => this.css.add(item));
101
+ result.cva.forEach((item) => this.cva.add(item));
102
+ result.recipe.forEach((items, name) => {
103
+ this.recipe.get(name) ?? this.recipe.set(name, /* @__PURE__ */ new Set());
104
+ items.forEach((item) => this.recipe.get(name)?.add(item));
105
+ });
106
+ result.pattern.forEach((items, name) => {
107
+ this.pattern.get(name) ?? this.pattern.set(name, /* @__PURE__ */ new Set());
108
+ items.forEach((item) => this.pattern.get(name)?.add(item));
109
+ });
110
+ result.jsx.forEach((item) => this.jsx.add(item));
111
+ return this;
112
+ }
113
+ static fromJson(json) {
114
+ const data = JSON.parse(json);
115
+ const result = new ParserResult();
116
+ result.css = new Set(data.css);
117
+ result.cva = new Set(data.cva);
118
+ result.recipe = new Map(Object.entries(data.recipe));
119
+ result.pattern = new Map(Object.entries(data.pattern));
120
+ result.jsx = new Set(data.jsx);
121
+ return result;
122
+ }
123
+ };
124
+ var createParserResult = () => new ParserResult();
91
125
 
92
126
  // src/parser.ts
93
127
  var isNodeRecipe = (node) => node.type === "recipe";
@@ -349,5 +383,7 @@ var createProject = ({ getFiles, readFile, parserOptions, ...projectOptions }) =
349
383
  Obj.omit(["project", "parser"])
350
384
  );
351
385
  export {
386
+ ParserResult,
387
+ createParserResult,
352
388
  createProject
353
389
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/parser",
3
- "version": "0.0.0-dev-20230530122200",
3
+ "version": "0.0.0-dev-20230530153755",
4
4
  "description": "The static parser for panda css",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -14,15 +14,15 @@
14
14
  "lil-fp": "1.4.5",
15
15
  "ts-morph": "18.0.0",
16
16
  "ts-pattern": "4.3.0",
17
- "@pandacss/extractor": "0.0.0-dev-20230530122200",
18
- "@pandacss/is-valid-prop": "0.0.0-dev-20230530122200",
19
- "@pandacss/logger": "0.0.0-dev-20230530122200",
20
- "@pandacss/shared": "0.0.0-dev-20230530122200",
21
- "@pandacss/types": "0.0.0-dev-20230530122200"
17
+ "@pandacss/extractor": "0.0.0-dev-20230530153755",
18
+ "@pandacss/is-valid-prop": "0.0.0-dev-20230530153755",
19
+ "@pandacss/logger": "0.0.0-dev-20230530153755",
20
+ "@pandacss/shared": "0.0.0-dev-20230530153755",
21
+ "@pandacss/types": "0.0.0-dev-20230530153755"
22
22
  },
23
23
  "devDependencies": {
24
- "@pandacss/fixture": "0.0.0-dev-20230530122200",
25
- "@pandacss/generator": "0.0.0-dev-20230530122200"
24
+ "@pandacss/fixture": "0.0.0-dev-20230530153755",
25
+ "@pandacss/generator": "0.0.0-dev-20230530153755"
26
26
  },
27
27
  "files": [
28
28
  "dist"