@pandacss/parser 0.0.0-dev-20230417181739 → 0.0.0-dev-20230418111125
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.js +22 -30
- package/dist/index.mjs +22 -30
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -79,36 +79,39 @@ function getImportDeclarations(file, options) {
|
|
|
79
79
|
|
|
80
80
|
// src/parser-result.ts
|
|
81
81
|
var createParserResult = () => ({
|
|
82
|
-
all: /* @__PURE__ */ new Set(),
|
|
83
82
|
jsx: /* @__PURE__ */ new Set(),
|
|
84
83
|
css: /* @__PURE__ */ new Set(),
|
|
85
84
|
cva: /* @__PURE__ */ new Set(),
|
|
86
85
|
recipe: /* @__PURE__ */ new Map(),
|
|
87
86
|
pattern: /* @__PURE__ */ new Map(),
|
|
88
87
|
set(name, result) {
|
|
89
|
-
|
|
90
|
-
this[name].add(obj);
|
|
91
|
-
this.all.add(obj);
|
|
88
|
+
this[name].add({ type: "object", ...result });
|
|
92
89
|
},
|
|
93
90
|
setCva(result) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
this.cva.add({ type: "cva", ...result });
|
|
92
|
+
},
|
|
93
|
+
setJsx(result) {
|
|
94
|
+
this.jsx.add({ type: "jsx", ...result });
|
|
97
95
|
},
|
|
98
96
|
setPattern(name, result) {
|
|
99
97
|
this.pattern.get(name) ?? this.pattern.set(name, /* @__PURE__ */ new Set());
|
|
100
|
-
|
|
101
|
-
this.pattern.get(name)?.add(pattern);
|
|
102
|
-
this.all.add(pattern);
|
|
98
|
+
this.pattern.get(name)?.add({ type: "pattern", name, ...result });
|
|
103
99
|
},
|
|
104
100
|
setRecipe(name, result) {
|
|
105
101
|
this.recipe.get(name) ?? this.recipe.set(name, /* @__PURE__ */ new Set());
|
|
106
|
-
|
|
107
|
-
this.recipe.get(name)?.add(recipe);
|
|
108
|
-
this.all.add(recipe);
|
|
102
|
+
this.recipe.get(name)?.add({ type: "recipe", ...result });
|
|
109
103
|
},
|
|
110
104
|
isEmpty() {
|
|
111
|
-
return this.
|
|
105
|
+
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
|
+
const result = [];
|
|
109
|
+
this.css.forEach((item) => result.push(item));
|
|
110
|
+
this.cva.forEach((item) => result.push(item));
|
|
111
|
+
this.recipe.forEach((items) => items.forEach((item) => result.push(item)));
|
|
112
|
+
this.pattern.forEach((items) => items.forEach((item) => result.push(item)));
|
|
113
|
+
this.jsx.forEach((item) => result.push(item));
|
|
114
|
+
return result;
|
|
112
115
|
}
|
|
113
116
|
});
|
|
114
117
|
|
|
@@ -205,6 +208,8 @@ function createParser(options) {
|
|
|
205
208
|
(tagName) => recipeJsxLists.string.has(tagName) || recipeJsxLists.regex.some((regex) => regex.test(tagName))
|
|
206
209
|
);
|
|
207
210
|
const matchTag = (0, import_shared2.memo)((tagName) => {
|
|
211
|
+
if (!tagName)
|
|
212
|
+
return false;
|
|
208
213
|
return components.has(tagName) || isUpperCase(tagName) || tagName.startsWith(jsxFactoryAlias) || isJsxTagRecipe(tagName);
|
|
209
214
|
});
|
|
210
215
|
const matchTagProp = (0, import_shared2.memo)((tagName, propName) => {
|
|
@@ -227,19 +232,6 @@ function createParser(options) {
|
|
|
227
232
|
return true;
|
|
228
233
|
return Boolean(functions.get(fnName));
|
|
229
234
|
});
|
|
230
|
-
const matchFnProp = (0, import_shared2.memo)((fnName, propName) => {
|
|
231
|
-
if (propertiesMap.size === 0)
|
|
232
|
-
return true;
|
|
233
|
-
if (recipes.has(fnName) || patterns.has(fnName))
|
|
234
|
-
return true;
|
|
235
|
-
if (fnName === cvaAlias)
|
|
236
|
-
return true;
|
|
237
|
-
if (fnName.startsWith(jsxFactoryAlias))
|
|
238
|
-
return true;
|
|
239
|
-
if (fnName === cssAlias)
|
|
240
|
-
return Boolean(propertiesMap.get(propName) || propName === "selectors");
|
|
241
|
-
return Boolean(functions.get(fnName)?.get(propName));
|
|
242
|
-
});
|
|
243
235
|
const measure = import_logger.logger.time.debug(`Tokens extracted from ${filePath}`);
|
|
244
236
|
const extractResultByName = (0, import_extractor.extract)({
|
|
245
237
|
ast: sourceFile,
|
|
@@ -249,7 +241,7 @@ function createParser(options) {
|
|
|
249
241
|
},
|
|
250
242
|
functions: {
|
|
251
243
|
matchFn: (prop) => matchFn(prop.fnName),
|
|
252
|
-
matchProp: (
|
|
244
|
+
matchProp: () => true,
|
|
253
245
|
matchArg: (prop) => {
|
|
254
246
|
if (prop.fnName === jsxFactoryAlias && prop.index === 1 && import_ts_morph.Node.isIdentifier(prop.argNode))
|
|
255
247
|
return false;
|
|
@@ -305,7 +297,7 @@ function createParser(options) {
|
|
|
305
297
|
(0, import_ts_pattern.match)(name).when(
|
|
306
298
|
(name2) => jsx && name2.startsWith(jsxFactoryAlias),
|
|
307
299
|
(name2) => {
|
|
308
|
-
collector.
|
|
300
|
+
collector.setJsx({ name: name2, box: query.box, type: "jsx-factory", data });
|
|
309
301
|
}
|
|
310
302
|
).when(
|
|
311
303
|
(name2) => jsxPatternNodes.test(name2),
|
|
@@ -318,7 +310,7 @@ function createParser(options) {
|
|
|
318
310
|
collector.setRecipe(getRecipeName(name2), { type: "jsx-recipe", name: name2, box: query.box, data });
|
|
319
311
|
}
|
|
320
312
|
).otherwise(() => {
|
|
321
|
-
collector.
|
|
313
|
+
collector.setJsx({ name, box: query.box, type: "jsx", data });
|
|
322
314
|
});
|
|
323
315
|
});
|
|
324
316
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -53,36 +53,39 @@ function getImportDeclarations(file, options) {
|
|
|
53
53
|
|
|
54
54
|
// src/parser-result.ts
|
|
55
55
|
var createParserResult = () => ({
|
|
56
|
-
all: /* @__PURE__ */ new Set(),
|
|
57
56
|
jsx: /* @__PURE__ */ new Set(),
|
|
58
57
|
css: /* @__PURE__ */ new Set(),
|
|
59
58
|
cva: /* @__PURE__ */ new Set(),
|
|
60
59
|
recipe: /* @__PURE__ */ new Map(),
|
|
61
60
|
pattern: /* @__PURE__ */ new Map(),
|
|
62
61
|
set(name, result) {
|
|
63
|
-
|
|
64
|
-
this[name].add(obj);
|
|
65
|
-
this.all.add(obj);
|
|
62
|
+
this[name].add({ type: "object", ...result });
|
|
66
63
|
},
|
|
67
64
|
setCva(result) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
this.cva.add({ type: "cva", ...result });
|
|
66
|
+
},
|
|
67
|
+
setJsx(result) {
|
|
68
|
+
this.jsx.add({ type: "jsx", ...result });
|
|
71
69
|
},
|
|
72
70
|
setPattern(name, result) {
|
|
73
71
|
this.pattern.get(name) ?? this.pattern.set(name, /* @__PURE__ */ new Set());
|
|
74
|
-
|
|
75
|
-
this.pattern.get(name)?.add(pattern);
|
|
76
|
-
this.all.add(pattern);
|
|
72
|
+
this.pattern.get(name)?.add({ type: "pattern", name, ...result });
|
|
77
73
|
},
|
|
78
74
|
setRecipe(name, result) {
|
|
79
75
|
this.recipe.get(name) ?? this.recipe.set(name, /* @__PURE__ */ new Set());
|
|
80
|
-
|
|
81
|
-
this.recipe.get(name)?.add(recipe);
|
|
82
|
-
this.all.add(recipe);
|
|
76
|
+
this.recipe.get(name)?.add({ type: "recipe", ...result });
|
|
83
77
|
},
|
|
84
78
|
isEmpty() {
|
|
85
|
-
return this.
|
|
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() {
|
|
82
|
+
const result = [];
|
|
83
|
+
this.css.forEach((item) => result.push(item));
|
|
84
|
+
this.cva.forEach((item) => result.push(item));
|
|
85
|
+
this.recipe.forEach((items) => items.forEach((item) => result.push(item)));
|
|
86
|
+
this.pattern.forEach((items) => items.forEach((item) => result.push(item)));
|
|
87
|
+
this.jsx.forEach((item) => result.push(item));
|
|
88
|
+
return result;
|
|
86
89
|
}
|
|
87
90
|
});
|
|
88
91
|
|
|
@@ -179,6 +182,8 @@ function createParser(options) {
|
|
|
179
182
|
(tagName) => recipeJsxLists.string.has(tagName) || recipeJsxLists.regex.some((regex) => regex.test(tagName))
|
|
180
183
|
);
|
|
181
184
|
const matchTag = memo2((tagName) => {
|
|
185
|
+
if (!tagName)
|
|
186
|
+
return false;
|
|
182
187
|
return components.has(tagName) || isUpperCase(tagName) || tagName.startsWith(jsxFactoryAlias) || isJsxTagRecipe(tagName);
|
|
183
188
|
});
|
|
184
189
|
const matchTagProp = memo2((tagName, propName) => {
|
|
@@ -201,19 +206,6 @@ function createParser(options) {
|
|
|
201
206
|
return true;
|
|
202
207
|
return Boolean(functions.get(fnName));
|
|
203
208
|
});
|
|
204
|
-
const matchFnProp = memo2((fnName, propName) => {
|
|
205
|
-
if (propertiesMap.size === 0)
|
|
206
|
-
return true;
|
|
207
|
-
if (recipes.has(fnName) || patterns.has(fnName))
|
|
208
|
-
return true;
|
|
209
|
-
if (fnName === cvaAlias)
|
|
210
|
-
return true;
|
|
211
|
-
if (fnName.startsWith(jsxFactoryAlias))
|
|
212
|
-
return true;
|
|
213
|
-
if (fnName === cssAlias)
|
|
214
|
-
return Boolean(propertiesMap.get(propName) || propName === "selectors");
|
|
215
|
-
return Boolean(functions.get(fnName)?.get(propName));
|
|
216
|
-
});
|
|
217
209
|
const measure = logger.time.debug(`Tokens extracted from ${filePath}`);
|
|
218
210
|
const extractResultByName = extract({
|
|
219
211
|
ast: sourceFile,
|
|
@@ -223,7 +215,7 @@ function createParser(options) {
|
|
|
223
215
|
},
|
|
224
216
|
functions: {
|
|
225
217
|
matchFn: (prop) => matchFn(prop.fnName),
|
|
226
|
-
matchProp: (
|
|
218
|
+
matchProp: () => true,
|
|
227
219
|
matchArg: (prop) => {
|
|
228
220
|
if (prop.fnName === jsxFactoryAlias && prop.index === 1 && Node.isIdentifier(prop.argNode))
|
|
229
221
|
return false;
|
|
@@ -279,7 +271,7 @@ function createParser(options) {
|
|
|
279
271
|
match(name).when(
|
|
280
272
|
(name2) => jsx && name2.startsWith(jsxFactoryAlias),
|
|
281
273
|
(name2) => {
|
|
282
|
-
collector.
|
|
274
|
+
collector.setJsx({ name: name2, box: query.box, type: "jsx-factory", data });
|
|
283
275
|
}
|
|
284
276
|
).when(
|
|
285
277
|
(name2) => jsxPatternNodes.test(name2),
|
|
@@ -292,7 +284,7 @@ function createParser(options) {
|
|
|
292
284
|
collector.setRecipe(getRecipeName(name2), { type: "jsx-recipe", name: name2, box: query.box, data });
|
|
293
285
|
}
|
|
294
286
|
).otherwise(() => {
|
|
295
|
-
collector.
|
|
287
|
+
collector.setJsx({ name, box: query.box, type: "jsx", data });
|
|
296
288
|
});
|
|
297
289
|
});
|
|
298
290
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/parser",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20230418111125",
|
|
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.2.2",
|
|
17
|
-
"@pandacss/extractor": "0.0.0-dev-
|
|
18
|
-
"@pandacss/is-valid-prop": "0.0.0-dev-
|
|
19
|
-
"@pandacss/logger": "0.0.0-dev-
|
|
20
|
-
"@pandacss/shared": "0.0.0-dev-
|
|
21
|
-
"@pandacss/types": "0.0.0-dev-
|
|
17
|
+
"@pandacss/extractor": "0.0.0-dev-20230418111125",
|
|
18
|
+
"@pandacss/is-valid-prop": "0.0.0-dev-20230418111125",
|
|
19
|
+
"@pandacss/logger": "0.0.0-dev-20230418111125",
|
|
20
|
+
"@pandacss/shared": "0.0.0-dev-20230418111125",
|
|
21
|
+
"@pandacss/types": "0.0.0-dev-20230418111125"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@pandacss/fixture": "0.0.0-dev-
|
|
25
|
-
"@pandacss/generator": "0.0.0-dev-
|
|
24
|
+
"@pandacss/fixture": "0.0.0-dev-20230418111125",
|
|
25
|
+
"@pandacss/generator": "0.0.0-dev-20230418111125"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist"
|