@pandacss/parser 0.14.0 → 0.15.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.js +26 -10
- package/dist/index.mjs +26 -10
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -206,7 +206,9 @@ var fallback = (box2) => ({
|
|
|
206
206
|
getNode: () => box2.getNode(),
|
|
207
207
|
getStack: () => box2.getStack()
|
|
208
208
|
});
|
|
209
|
-
var defaultEnv = { preset: "
|
|
209
|
+
var defaultEnv = { preset: "ECMA" };
|
|
210
|
+
var identityFn = (styles) => styles;
|
|
211
|
+
var evaluateOptions = { environment: defaultEnv };
|
|
210
212
|
function createParser(options) {
|
|
211
213
|
const { jsx, getRecipesByJsxName, getPatternsByJsxName, tsOptions, join } = options;
|
|
212
214
|
const importMap = Object.fromEntries(Object.entries(options.importMap).map(([key, value]) => [key, join(...value)]));
|
|
@@ -265,7 +267,7 @@ function createParser(options) {
|
|
|
265
267
|
pattern.jsx?.forEach((jsx2) => {
|
|
266
268
|
if (typeof jsx2 === "string") {
|
|
267
269
|
acc.string.add(jsx2);
|
|
268
|
-
} else {
|
|
270
|
+
} else if (jsx2) {
|
|
269
271
|
acc.regex.push(jsx2);
|
|
270
272
|
}
|
|
271
273
|
});
|
|
@@ -370,7 +372,21 @@ function createParser(options) {
|
|
|
370
372
|
taggedTemplates: {
|
|
371
373
|
matchTaggedTemplate: (tag) => matchFn(tag.fnName)
|
|
372
374
|
},
|
|
373
|
-
getEvaluateOptions: (node) =>
|
|
375
|
+
getEvaluateOptions: (node) => {
|
|
376
|
+
if (!import_ts_morph.Node.isCallExpression(node))
|
|
377
|
+
return evaluateOptions;
|
|
378
|
+
const propAccessExpr = node.getExpression();
|
|
379
|
+
if (!import_ts_morph.Node.isPropertyAccessExpression(propAccessExpr))
|
|
380
|
+
return evaluateOptions;
|
|
381
|
+
let name = propAccessExpr.getText();
|
|
382
|
+
if (!isRawFn(name)) {
|
|
383
|
+
return evaluateOptions;
|
|
384
|
+
}
|
|
385
|
+
name = name.replace(".raw", "");
|
|
386
|
+
return {
|
|
387
|
+
environment: Object.assign({}, defaultEnv, { extra: { [name]: { raw: identityFn } } })
|
|
388
|
+
};
|
|
389
|
+
},
|
|
374
390
|
flags: { skipTraverseFiles: true }
|
|
375
391
|
});
|
|
376
392
|
measure();
|
|
@@ -473,14 +489,14 @@ function createParser(options) {
|
|
|
473
489
|
} else if (result.kind === "component") {
|
|
474
490
|
result.queryList.forEach((query) => {
|
|
475
491
|
const data = combineResult((0, import_extractor.unbox)(query.box));
|
|
476
|
-
(0, import_ts_pattern.match)(name).when(isFactory, (
|
|
477
|
-
collector.setJsx({ name:
|
|
478
|
-
}).when(isJsxTagPattern, (
|
|
479
|
-
collector.setPattern(
|
|
480
|
-
}).when(isJsxTagRecipe, (
|
|
481
|
-
const recipeList = getRecipesByJsxName(
|
|
492
|
+
(0, import_ts_pattern.match)(name).when(isFactory, (jsxName) => {
|
|
493
|
+
collector.setJsx({ name: jsxName, box: query.box, type: "jsx-factory", data });
|
|
494
|
+
}).when(isJsxTagPattern, (jsxName) => {
|
|
495
|
+
collector.setPattern(jsxName, { type: "jsx-pattern", name: jsxName, box: query.box, data });
|
|
496
|
+
}).when(isJsxTagRecipe, (jsxName) => {
|
|
497
|
+
const recipeList = getRecipesByJsxName(jsxName);
|
|
482
498
|
recipeList.map((recipe) => {
|
|
483
|
-
collector.setRecipe(recipe.baseName, { type: "jsx-recipe", name:
|
|
499
|
+
collector.setRecipe(recipe.baseName, { type: "jsx-recipe", name: jsxName, box: query.box, data });
|
|
484
500
|
});
|
|
485
501
|
}).otherwise(() => {
|
|
486
502
|
collector.setJsx({ name, box: query.box, type: "jsx", data });
|
package/dist/index.mjs
CHANGED
|
@@ -168,7 +168,9 @@ var fallback = (box2) => ({
|
|
|
168
168
|
getNode: () => box2.getNode(),
|
|
169
169
|
getStack: () => box2.getStack()
|
|
170
170
|
});
|
|
171
|
-
var defaultEnv = { preset: "
|
|
171
|
+
var defaultEnv = { preset: "ECMA" };
|
|
172
|
+
var identityFn = (styles) => styles;
|
|
173
|
+
var evaluateOptions = { environment: defaultEnv };
|
|
172
174
|
function createParser(options) {
|
|
173
175
|
const { jsx, getRecipesByJsxName, getPatternsByJsxName, tsOptions, join } = options;
|
|
174
176
|
const importMap = Object.fromEntries(Object.entries(options.importMap).map(([key, value]) => [key, join(...value)]));
|
|
@@ -227,7 +229,7 @@ function createParser(options) {
|
|
|
227
229
|
pattern.jsx?.forEach((jsx2) => {
|
|
228
230
|
if (typeof jsx2 === "string") {
|
|
229
231
|
acc.string.add(jsx2);
|
|
230
|
-
} else {
|
|
232
|
+
} else if (jsx2) {
|
|
231
233
|
acc.regex.push(jsx2);
|
|
232
234
|
}
|
|
233
235
|
});
|
|
@@ -332,7 +334,21 @@ function createParser(options) {
|
|
|
332
334
|
taggedTemplates: {
|
|
333
335
|
matchTaggedTemplate: (tag) => matchFn(tag.fnName)
|
|
334
336
|
},
|
|
335
|
-
getEvaluateOptions: (node) =>
|
|
337
|
+
getEvaluateOptions: (node) => {
|
|
338
|
+
if (!Node.isCallExpression(node))
|
|
339
|
+
return evaluateOptions;
|
|
340
|
+
const propAccessExpr = node.getExpression();
|
|
341
|
+
if (!Node.isPropertyAccessExpression(propAccessExpr))
|
|
342
|
+
return evaluateOptions;
|
|
343
|
+
let name = propAccessExpr.getText();
|
|
344
|
+
if (!isRawFn(name)) {
|
|
345
|
+
return evaluateOptions;
|
|
346
|
+
}
|
|
347
|
+
name = name.replace(".raw", "");
|
|
348
|
+
return {
|
|
349
|
+
environment: Object.assign({}, defaultEnv, { extra: { [name]: { raw: identityFn } } })
|
|
350
|
+
};
|
|
351
|
+
},
|
|
336
352
|
flags: { skipTraverseFiles: true }
|
|
337
353
|
});
|
|
338
354
|
measure();
|
|
@@ -435,14 +451,14 @@ function createParser(options) {
|
|
|
435
451
|
} else if (result.kind === "component") {
|
|
436
452
|
result.queryList.forEach((query) => {
|
|
437
453
|
const data = combineResult(unbox(query.box));
|
|
438
|
-
match(name).when(isFactory, (
|
|
439
|
-
collector.setJsx({ name:
|
|
440
|
-
}).when(isJsxTagPattern, (
|
|
441
|
-
collector.setPattern(
|
|
442
|
-
}).when(isJsxTagRecipe, (
|
|
443
|
-
const recipeList = getRecipesByJsxName(
|
|
454
|
+
match(name).when(isFactory, (jsxName) => {
|
|
455
|
+
collector.setJsx({ name: jsxName, box: query.box, type: "jsx-factory", data });
|
|
456
|
+
}).when(isJsxTagPattern, (jsxName) => {
|
|
457
|
+
collector.setPattern(jsxName, { type: "jsx-pattern", name: jsxName, box: query.box, data });
|
|
458
|
+
}).when(isJsxTagRecipe, (jsxName) => {
|
|
459
|
+
const recipeList = getRecipesByJsxName(jsxName);
|
|
444
460
|
recipeList.map((recipe) => {
|
|
445
|
-
collector.setRecipe(recipe.baseName, { type: "jsx-recipe", name:
|
|
461
|
+
collector.setRecipe(recipe.baseName, { type: "jsx-recipe", name: jsxName, box: query.box, data });
|
|
446
462
|
});
|
|
447
463
|
}).otherwise(() => {
|
|
448
464
|
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.15.1",
|
|
4
4
|
"description": "The static parser for panda css",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -15,18 +15,18 @@
|
|
|
15
15
|
"lil-fp": "1.4.5",
|
|
16
16
|
"magic-string": "^0.30.2",
|
|
17
17
|
"ts-morph": "19.0.0",
|
|
18
|
-
"ts-pattern": "5.0.
|
|
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.
|
|
18
|
+
"ts-pattern": "5.0.5",
|
|
19
|
+
"@pandacss/config": "^0.15.1",
|
|
20
|
+
"@pandacss/extractor": "0.15.1",
|
|
21
|
+
"@pandacss/is-valid-prop": "0.15.1",
|
|
22
|
+
"@pandacss/logger": "0.15.1",
|
|
23
|
+
"@pandacss/shared": "0.15.1",
|
|
24
|
+
"@pandacss/types": "0.15.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"hookable": "5.5.3",
|
|
28
|
-
"@pandacss/fixture": "0.
|
|
29
|
-
"@pandacss/generator": "0.
|
|
28
|
+
"@pandacss/fixture": "0.15.1",
|
|
29
|
+
"@pandacss/generator": "0.15.1"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"dist"
|