@pandacss/parser 0.8.0 → 0.9.0
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 +6 -15
- package/dist/index.d.ts +6 -15
- package/dist/index.js +32 -15
- package/dist/index.mjs +32 -15
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as ts_morph from 'ts-morph';
|
|
2
2
|
import { ProjectOptions as ProjectOptions$1 } from 'ts-morph';
|
|
3
|
-
import { ResultItem,
|
|
3
|
+
import { ResultItem, ConfigTsOptions, Runtime, PandaHookable } from '@pandacss/types';
|
|
4
|
+
import { Generator } from '@pandacss/generator';
|
|
4
5
|
|
|
5
6
|
declare class ParserResult {
|
|
6
7
|
jsx: Set<ResultItem>;
|
|
@@ -33,19 +34,8 @@ declare class ParserResult {
|
|
|
33
34
|
}
|
|
34
35
|
declare const createParserResult: () => ParserResult;
|
|
35
36
|
|
|
36
|
-
type ParserPatternNode =
|
|
37
|
-
|
|
38
|
-
type: 'pattern';
|
|
39
|
-
props?: string[];
|
|
40
|
-
baseName: string;
|
|
41
|
-
};
|
|
42
|
-
type ParserRecipeNode = {
|
|
43
|
-
name: string;
|
|
44
|
-
type: 'recipe';
|
|
45
|
-
props: string[];
|
|
46
|
-
baseName: string;
|
|
47
|
-
jsx: RecipeConfig['jsx'];
|
|
48
|
-
};
|
|
37
|
+
type ParserPatternNode = Generator['patterns']['details'][number];
|
|
38
|
+
type ParserRecipeNode = Generator['recipes']['details'][number];
|
|
49
39
|
type ParserNodeOptions = ParserPatternNode | ParserRecipeNode;
|
|
50
40
|
type ParserOptions = {
|
|
51
41
|
importMap: Record<'css' | 'recipe' | 'pattern' | 'jsx', string[]>;
|
|
@@ -54,7 +44,8 @@ type ParserOptions = {
|
|
|
54
44
|
nodes: ParserNodeOptions[];
|
|
55
45
|
isStyleProp: (prop: string) => boolean;
|
|
56
46
|
};
|
|
57
|
-
getRecipesByJsxName: (jsxName: string) =>
|
|
47
|
+
getRecipesByJsxName: (jsxName: string) => ParserRecipeNode[];
|
|
48
|
+
getPatternsByJsxName: (jsxName: string) => ParserPatternNode[];
|
|
58
49
|
tsOptions?: ConfigTsOptions;
|
|
59
50
|
join: Runtime['path']['join'];
|
|
60
51
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as ts_morph from 'ts-morph';
|
|
2
2
|
import { ProjectOptions as ProjectOptions$1 } from 'ts-morph';
|
|
3
|
-
import { ResultItem,
|
|
3
|
+
import { ResultItem, ConfigTsOptions, Runtime, PandaHookable } from '@pandacss/types';
|
|
4
|
+
import { Generator } from '@pandacss/generator';
|
|
4
5
|
|
|
5
6
|
declare class ParserResult {
|
|
6
7
|
jsx: Set<ResultItem>;
|
|
@@ -33,19 +34,8 @@ declare class ParserResult {
|
|
|
33
34
|
}
|
|
34
35
|
declare const createParserResult: () => ParserResult;
|
|
35
36
|
|
|
36
|
-
type ParserPatternNode =
|
|
37
|
-
|
|
38
|
-
type: 'pattern';
|
|
39
|
-
props?: string[];
|
|
40
|
-
baseName: string;
|
|
41
|
-
};
|
|
42
|
-
type ParserRecipeNode = {
|
|
43
|
-
name: string;
|
|
44
|
-
type: 'recipe';
|
|
45
|
-
props: string[];
|
|
46
|
-
baseName: string;
|
|
47
|
-
jsx: RecipeConfig['jsx'];
|
|
48
|
-
};
|
|
37
|
+
type ParserPatternNode = Generator['patterns']['details'][number];
|
|
38
|
+
type ParserRecipeNode = Generator['recipes']['details'][number];
|
|
49
39
|
type ParserNodeOptions = ParserPatternNode | ParserRecipeNode;
|
|
50
40
|
type ParserOptions = {
|
|
51
41
|
importMap: Record<'css' | 'recipe' | 'pattern' | 'jsx', string[]>;
|
|
@@ -54,7 +44,8 @@ type ParserOptions = {
|
|
|
54
44
|
nodes: ParserNodeOptions[];
|
|
55
45
|
isStyleProp: (prop: string) => boolean;
|
|
56
46
|
};
|
|
57
|
-
getRecipesByJsxName: (jsxName: string) =>
|
|
47
|
+
getRecipesByJsxName: (jsxName: string) => ParserRecipeNode[];
|
|
48
|
+
getPatternsByJsxName: (jsxName: string) => ParserPatternNode[];
|
|
58
49
|
tsOptions?: ConfigTsOptions;
|
|
59
50
|
join: Runtime['path']['join'];
|
|
60
51
|
};
|
package/dist/index.js
CHANGED
|
@@ -177,6 +177,7 @@ var createParserResult = () => new ParserResult();
|
|
|
177
177
|
// src/parser.ts
|
|
178
178
|
var import_ts_path = require("@pandacss/config/ts-path");
|
|
179
179
|
var isNodeRecipe = (node) => node.type === "recipe";
|
|
180
|
+
var isNodePattern = (node) => node.type === "pattern";
|
|
180
181
|
var cvaProps = ["compoundVariants", "defaultVariants", "variants", "base"];
|
|
181
182
|
var isCva = (map) => cvaProps.some((prop) => map.has(prop));
|
|
182
183
|
function createImportMatcher(mod, values) {
|
|
@@ -199,7 +200,7 @@ var fallback = (box2) => ({
|
|
|
199
200
|
});
|
|
200
201
|
var defaultEnv = { preset: "NONE" };
|
|
201
202
|
function createParser(options) {
|
|
202
|
-
const { jsx, getRecipesByJsxName, tsOptions, join } = options;
|
|
203
|
+
const { jsx, getRecipesByJsxName, getPatternsByJsxName, tsOptions, join } = options;
|
|
203
204
|
const importMap = Object.fromEntries(Object.entries(options.importMap).map(([key, value]) => [key, join(...value)]));
|
|
204
205
|
const importRegex = [
|
|
205
206
|
createImportMatcher(importMap.css, ["css", "cva"]),
|
|
@@ -207,7 +208,7 @@ function createParser(options) {
|
|
|
207
208
|
createImportMatcher(importMap.pattern)
|
|
208
209
|
];
|
|
209
210
|
if (jsx) {
|
|
210
|
-
importRegex.push(createImportMatcher(importMap.jsx, [jsx.factory, ...jsx.nodes.map((node) => node.
|
|
211
|
+
importRegex.push(createImportMatcher(importMap.jsx, [jsx.factory, ...jsx.nodes.map((node) => node.jsxName)]));
|
|
211
212
|
}
|
|
212
213
|
return function parse2(sourceFile) {
|
|
213
214
|
if (!sourceFile)
|
|
@@ -249,8 +250,20 @@ function createParser(options) {
|
|
|
249
250
|
const name = fullName.split(".raw")[0] ?? "";
|
|
250
251
|
return name === "css" || isValidPattern(name) || isValidRecipe(name);
|
|
251
252
|
};
|
|
252
|
-
const
|
|
253
|
-
|
|
253
|
+
const patternPropertiesByName = /* @__PURE__ */ new Map();
|
|
254
|
+
const patternJsxLists = (jsx?.nodes ?? []).filter(isNodePattern).reduce(
|
|
255
|
+
(acc, pattern) => {
|
|
256
|
+
patternPropertiesByName.set(pattern.jsxName, new Set(pattern.props ?? []));
|
|
257
|
+
pattern.jsx?.forEach((jsx2) => {
|
|
258
|
+
if (typeof jsx2 === "string") {
|
|
259
|
+
acc.string.add(jsx2);
|
|
260
|
+
} else {
|
|
261
|
+
acc.regex.push(jsx2);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
return acc;
|
|
265
|
+
},
|
|
266
|
+
{ string: /* @__PURE__ */ new Set(), regex: [] }
|
|
254
267
|
);
|
|
255
268
|
const recipes = /* @__PURE__ */ new Set();
|
|
256
269
|
const patterns = /* @__PURE__ */ new Set();
|
|
@@ -269,7 +282,7 @@ function createParser(options) {
|
|
|
269
282
|
const recipePropertiesByName = /* @__PURE__ */ new Map();
|
|
270
283
|
const recipeJsxLists = (jsx?.nodes ?? []).filter(isNodeRecipe).reduce(
|
|
271
284
|
(acc, recipe) => {
|
|
272
|
-
recipePropertiesByName.set(recipe.
|
|
285
|
+
recipePropertiesByName.set(recipe.jsxName, new Set(recipe.props ?? []));
|
|
273
286
|
recipe.jsx?.forEach((jsx2) => {
|
|
274
287
|
if (typeof jsx2 === "string") {
|
|
275
288
|
acc.string.add(jsx2);
|
|
@@ -285,7 +298,7 @@ function createParser(options) {
|
|
|
285
298
|
const cssAlias = imports.getAlias("css");
|
|
286
299
|
if (options.jsx) {
|
|
287
300
|
options.jsx.nodes.forEach((node) => {
|
|
288
|
-
const alias = imports.getAlias(node.
|
|
301
|
+
const alias = imports.getAlias(node.jsxName);
|
|
289
302
|
node.props?.forEach((prop) => propertiesMap.set(prop, true));
|
|
290
303
|
functions.set(node.baseName, propertiesMap);
|
|
291
304
|
functions.set(alias, propertiesMap);
|
|
@@ -295,17 +308,24 @@ function createParser(options) {
|
|
|
295
308
|
const isJsxTagRecipe = (0, import_shared2.memo)(
|
|
296
309
|
(tagName) => recipeJsxLists.string.has(tagName) || recipeJsxLists.regex.some((regex) => regex.test(tagName))
|
|
297
310
|
);
|
|
311
|
+
const isJsxTagPattern = (0, import_shared2.memo)(
|
|
312
|
+
(tagName) => patternJsxLists.string.has(tagName) || patternJsxLists.regex.some((regex) => regex.test(tagName))
|
|
313
|
+
);
|
|
298
314
|
const matchTag = (0, import_shared2.memo)((tagName) => {
|
|
299
315
|
if (!tagName)
|
|
300
316
|
return false;
|
|
301
|
-
return components.has(tagName) || isUpperCase(tagName) || isFactory(tagName) || isJsxTagRecipe(tagName);
|
|
317
|
+
return components.has(tagName) || isUpperCase(tagName) || isFactory(tagName) || isJsxTagRecipe(tagName) || isJsxTagPattern(tagName);
|
|
302
318
|
});
|
|
303
319
|
const matchTagProp = (0, import_shared2.memo)((tagName, propName) => {
|
|
304
320
|
if (Boolean(components.get(tagName)?.has(propName)) || options.jsx?.isStyleProp(propName) || propertiesMap.has(propName))
|
|
305
321
|
return true;
|
|
306
322
|
if (isJsxTagRecipe(tagName)) {
|
|
307
323
|
const recipeList = getRecipesByJsxName(tagName);
|
|
308
|
-
return recipeList.some((recipe) => recipePropertiesByName.get(recipe.
|
|
324
|
+
return recipeList.some((recipe) => recipePropertiesByName.get(recipe.baseName)?.has(propName));
|
|
325
|
+
}
|
|
326
|
+
if (isJsxTagPattern(tagName)) {
|
|
327
|
+
const patternList = getPatternsByJsxName(tagName);
|
|
328
|
+
return patternList.some((pattern) => patternPropertiesByName.get(pattern.baseName)?.has(propName));
|
|
309
329
|
}
|
|
310
330
|
return false;
|
|
311
331
|
});
|
|
@@ -429,15 +449,12 @@ function createParser(options) {
|
|
|
429
449
|
const data = combineResult((0, import_extractor.unbox)(query.box));
|
|
430
450
|
(0, import_ts_pattern.match)(name).when(isFactory, (name2) => {
|
|
431
451
|
collector.setJsx({ name: name2, box: query.box, type: "jsx-factory", data });
|
|
432
|
-
}).when(
|
|
433
|
-
(name2
|
|
434
|
-
|
|
435
|
-
collector.setPattern(name2, { type: "jsx-pattern", name: name2, box: query.box, data });
|
|
436
|
-
}
|
|
437
|
-
).when(isJsxTagRecipe, (name2) => {
|
|
452
|
+
}).when(isJsxTagPattern, (name2) => {
|
|
453
|
+
collector.setPattern(name2, { type: "jsx-pattern", name: name2, box: query.box, data });
|
|
454
|
+
}).when(isJsxTagRecipe, (name2) => {
|
|
438
455
|
const recipeList = getRecipesByJsxName(name2);
|
|
439
456
|
recipeList.map((recipe) => {
|
|
440
|
-
collector.setRecipe(recipe.
|
|
457
|
+
collector.setRecipe(recipe.baseName, { type: "jsx-recipe", name: name2, box: query.box, data });
|
|
441
458
|
});
|
|
442
459
|
}).otherwise(() => {
|
|
443
460
|
collector.setJsx({ name, box: query.box, type: "jsx", data });
|
package/dist/index.mjs
CHANGED
|
@@ -139,6 +139,7 @@ var createParserResult = () => new ParserResult();
|
|
|
139
139
|
// src/parser.ts
|
|
140
140
|
import { resolveTsPathPattern } from "@pandacss/config/ts-path";
|
|
141
141
|
var isNodeRecipe = (node) => node.type === "recipe";
|
|
142
|
+
var isNodePattern = (node) => node.type === "pattern";
|
|
142
143
|
var cvaProps = ["compoundVariants", "defaultVariants", "variants", "base"];
|
|
143
144
|
var isCva = (map) => cvaProps.some((prop) => map.has(prop));
|
|
144
145
|
function createImportMatcher(mod, values) {
|
|
@@ -161,7 +162,7 @@ var fallback = (box2) => ({
|
|
|
161
162
|
});
|
|
162
163
|
var defaultEnv = { preset: "NONE" };
|
|
163
164
|
function createParser(options) {
|
|
164
|
-
const { jsx, getRecipesByJsxName, tsOptions, join } = options;
|
|
165
|
+
const { jsx, getRecipesByJsxName, getPatternsByJsxName, tsOptions, join } = options;
|
|
165
166
|
const importMap = Object.fromEntries(Object.entries(options.importMap).map(([key, value]) => [key, join(...value)]));
|
|
166
167
|
const importRegex = [
|
|
167
168
|
createImportMatcher(importMap.css, ["css", "cva"]),
|
|
@@ -169,7 +170,7 @@ function createParser(options) {
|
|
|
169
170
|
createImportMatcher(importMap.pattern)
|
|
170
171
|
];
|
|
171
172
|
if (jsx) {
|
|
172
|
-
importRegex.push(createImportMatcher(importMap.jsx, [jsx.factory, ...jsx.nodes.map((node) => node.
|
|
173
|
+
importRegex.push(createImportMatcher(importMap.jsx, [jsx.factory, ...jsx.nodes.map((node) => node.jsxName)]));
|
|
173
174
|
}
|
|
174
175
|
return function parse2(sourceFile) {
|
|
175
176
|
if (!sourceFile)
|
|
@@ -211,8 +212,20 @@ function createParser(options) {
|
|
|
211
212
|
const name = fullName.split(".raw")[0] ?? "";
|
|
212
213
|
return name === "css" || isValidPattern(name) || isValidRecipe(name);
|
|
213
214
|
};
|
|
214
|
-
const
|
|
215
|
-
|
|
215
|
+
const patternPropertiesByName = /* @__PURE__ */ new Map();
|
|
216
|
+
const patternJsxLists = (jsx?.nodes ?? []).filter(isNodePattern).reduce(
|
|
217
|
+
(acc, pattern) => {
|
|
218
|
+
patternPropertiesByName.set(pattern.jsxName, new Set(pattern.props ?? []));
|
|
219
|
+
pattern.jsx?.forEach((jsx2) => {
|
|
220
|
+
if (typeof jsx2 === "string") {
|
|
221
|
+
acc.string.add(jsx2);
|
|
222
|
+
} else {
|
|
223
|
+
acc.regex.push(jsx2);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
return acc;
|
|
227
|
+
},
|
|
228
|
+
{ string: /* @__PURE__ */ new Set(), regex: [] }
|
|
216
229
|
);
|
|
217
230
|
const recipes = /* @__PURE__ */ new Set();
|
|
218
231
|
const patterns = /* @__PURE__ */ new Set();
|
|
@@ -231,7 +244,7 @@ function createParser(options) {
|
|
|
231
244
|
const recipePropertiesByName = /* @__PURE__ */ new Map();
|
|
232
245
|
const recipeJsxLists = (jsx?.nodes ?? []).filter(isNodeRecipe).reduce(
|
|
233
246
|
(acc, recipe) => {
|
|
234
|
-
recipePropertiesByName.set(recipe.
|
|
247
|
+
recipePropertiesByName.set(recipe.jsxName, new Set(recipe.props ?? []));
|
|
235
248
|
recipe.jsx?.forEach((jsx2) => {
|
|
236
249
|
if (typeof jsx2 === "string") {
|
|
237
250
|
acc.string.add(jsx2);
|
|
@@ -247,7 +260,7 @@ function createParser(options) {
|
|
|
247
260
|
const cssAlias = imports.getAlias("css");
|
|
248
261
|
if (options.jsx) {
|
|
249
262
|
options.jsx.nodes.forEach((node) => {
|
|
250
|
-
const alias = imports.getAlias(node.
|
|
263
|
+
const alias = imports.getAlias(node.jsxName);
|
|
251
264
|
node.props?.forEach((prop) => propertiesMap.set(prop, true));
|
|
252
265
|
functions.set(node.baseName, propertiesMap);
|
|
253
266
|
functions.set(alias, propertiesMap);
|
|
@@ -257,17 +270,24 @@ function createParser(options) {
|
|
|
257
270
|
const isJsxTagRecipe = memo2(
|
|
258
271
|
(tagName) => recipeJsxLists.string.has(tagName) || recipeJsxLists.regex.some((regex) => regex.test(tagName))
|
|
259
272
|
);
|
|
273
|
+
const isJsxTagPattern = memo2(
|
|
274
|
+
(tagName) => patternJsxLists.string.has(tagName) || patternJsxLists.regex.some((regex) => regex.test(tagName))
|
|
275
|
+
);
|
|
260
276
|
const matchTag = memo2((tagName) => {
|
|
261
277
|
if (!tagName)
|
|
262
278
|
return false;
|
|
263
|
-
return components.has(tagName) || isUpperCase(tagName) || isFactory(tagName) || isJsxTagRecipe(tagName);
|
|
279
|
+
return components.has(tagName) || isUpperCase(tagName) || isFactory(tagName) || isJsxTagRecipe(tagName) || isJsxTagPattern(tagName);
|
|
264
280
|
});
|
|
265
281
|
const matchTagProp = memo2((tagName, propName) => {
|
|
266
282
|
if (Boolean(components.get(tagName)?.has(propName)) || options.jsx?.isStyleProp(propName) || propertiesMap.has(propName))
|
|
267
283
|
return true;
|
|
268
284
|
if (isJsxTagRecipe(tagName)) {
|
|
269
285
|
const recipeList = getRecipesByJsxName(tagName);
|
|
270
|
-
return recipeList.some((recipe) => recipePropertiesByName.get(recipe.
|
|
286
|
+
return recipeList.some((recipe) => recipePropertiesByName.get(recipe.baseName)?.has(propName));
|
|
287
|
+
}
|
|
288
|
+
if (isJsxTagPattern(tagName)) {
|
|
289
|
+
const patternList = getPatternsByJsxName(tagName);
|
|
290
|
+
return patternList.some((pattern) => patternPropertiesByName.get(pattern.baseName)?.has(propName));
|
|
271
291
|
}
|
|
272
292
|
return false;
|
|
273
293
|
});
|
|
@@ -391,15 +411,12 @@ function createParser(options) {
|
|
|
391
411
|
const data = combineResult(unbox(query.box));
|
|
392
412
|
match(name).when(isFactory, (name2) => {
|
|
393
413
|
collector.setJsx({ name: name2, box: query.box, type: "jsx-factory", data });
|
|
394
|
-
}).when(
|
|
395
|
-
(name2
|
|
396
|
-
|
|
397
|
-
collector.setPattern(name2, { type: "jsx-pattern", name: name2, box: query.box, data });
|
|
398
|
-
}
|
|
399
|
-
).when(isJsxTagRecipe, (name2) => {
|
|
414
|
+
}).when(isJsxTagPattern, (name2) => {
|
|
415
|
+
collector.setPattern(name2, { type: "jsx-pattern", name: name2, box: query.box, data });
|
|
416
|
+
}).when(isJsxTagRecipe, (name2) => {
|
|
400
417
|
const recipeList = getRecipesByJsxName(name2);
|
|
401
418
|
recipeList.map((recipe) => {
|
|
402
|
-
collector.setRecipe(recipe.
|
|
419
|
+
collector.setRecipe(recipe.baseName, { type: "jsx-recipe", name: name2, box: query.box, data });
|
|
403
420
|
});
|
|
404
421
|
}).otherwise(() => {
|
|
405
422
|
collector.setJsx({ name, box: query.box, type: "jsx", data });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "The static parser for panda css",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
"magic-string": "^0.30.1",
|
|
17
17
|
"ts-morph": "19.0.0",
|
|
18
18
|
"ts-pattern": "5.0.4",
|
|
19
|
-
"@pandacss/config": "^0.
|
|
20
|
-
"@pandacss/extractor": "0.
|
|
21
|
-
"@pandacss/is-valid-prop": "0.
|
|
22
|
-
"@pandacss/logger": "0.
|
|
23
|
-
"@pandacss/shared": "0.
|
|
24
|
-
"@pandacss/types": "0.
|
|
19
|
+
"@pandacss/config": "^0.9.0",
|
|
20
|
+
"@pandacss/extractor": "0.9.0",
|
|
21
|
+
"@pandacss/is-valid-prop": "0.9.0",
|
|
22
|
+
"@pandacss/logger": "0.9.0",
|
|
23
|
+
"@pandacss/shared": "0.9.0",
|
|
24
|
+
"@pandacss/types": "0.9.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"hookable": "5.5.3",
|
|
28
|
-
"@pandacss/fixture": "0.
|
|
29
|
-
"@pandacss/generator": "0.
|
|
28
|
+
"@pandacss/fixture": "0.9.0",
|
|
29
|
+
"@pandacss/generator": "0.9.0"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"dist"
|