@pandacss/parser 0.36.0 → 0.37.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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +22 -8
- package/dist/index.mjs +22 -8
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParserOptions } from '@pandacss/core';
|
|
2
|
-
import { ParserResultInterface, ResultItem, ParserResultConfigureOptions, Runtime, PandaHooks, ConfigTsOptions } from '@pandacss/types';
|
|
2
|
+
import { ParserResultInterface, ResultItem, ParserResultConfigureOptions, JsxFactoryResultTransform, Runtime, PandaHooks, ConfigTsOptions } from '@pandacss/types';
|
|
3
3
|
import { SourceFile, ProjectOptions as ProjectOptions$1, Project as Project$1, FileSystemRefreshResult } from 'ts-morph';
|
|
4
4
|
import { Generator } from '@pandacss/generator';
|
|
5
5
|
|
|
@@ -42,7 +42,7 @@ declare class ParserResult implements ParserResultInterface {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
declare function createParser(context: ParserOptions): (sourceFile: SourceFile | undefined, encoder?: Generator['encoder'], options?: ParserResultConfigureOptions) => ParserResult | undefined;
|
|
45
|
+
declare function createParser(context: ParserOptions): (sourceFile: SourceFile | undefined, encoder?: Generator['encoder'], options?: ParserResultConfigureOptions & Partial<JsxFactoryResultTransform>) => ParserResult | undefined;
|
|
46
46
|
|
|
47
47
|
interface ProjectOptions extends ProjectOptions$1 {
|
|
48
48
|
readFile: Runtime['fs']['readFileSync'];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParserOptions } from '@pandacss/core';
|
|
2
|
-
import { ParserResultInterface, ResultItem, ParserResultConfigureOptions, Runtime, PandaHooks, ConfigTsOptions } from '@pandacss/types';
|
|
2
|
+
import { ParserResultInterface, ResultItem, ParserResultConfigureOptions, JsxFactoryResultTransform, Runtime, PandaHooks, ConfigTsOptions } from '@pandacss/types';
|
|
3
3
|
import { SourceFile, ProjectOptions as ProjectOptions$1, Project as Project$1, FileSystemRefreshResult } from 'ts-morph';
|
|
4
4
|
import { Generator } from '@pandacss/generator';
|
|
5
5
|
|
|
@@ -42,7 +42,7 @@ declare class ParserResult implements ParserResultInterface {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
declare function createParser(context: ParserOptions): (sourceFile: SourceFile | undefined, encoder?: Generator['encoder'], options?: ParserResultConfigureOptions) => ParserResult | undefined;
|
|
45
|
+
declare function createParser(context: ParserOptions): (sourceFile: SourceFile | undefined, encoder?: Generator['encoder'], options?: ParserResultConfigureOptions & Partial<JsxFactoryResultTransform>) => ParserResult | undefined;
|
|
46
46
|
|
|
47
47
|
interface ProjectOptions extends ProjectOptions$1 {
|
|
48
48
|
readFile: Runtime['fs']['readFileSync'];
|
package/dist/index.js
CHANGED
|
@@ -351,14 +351,16 @@ function createParser(context) {
|
|
|
351
351
|
if (query.kind === "call-expression" && query.box.value[1]) {
|
|
352
352
|
const map = query.box.value[1];
|
|
353
353
|
const boxNode = import_extractor.box.isMap(map) ? map : import_extractor.box.fallback(query.box);
|
|
354
|
-
const
|
|
354
|
+
const combined = combineResult((0, import_extractor.unbox)(boxNode));
|
|
355
|
+
const transformed = options?.transform?.({ type: "jsx-factory", data: combined });
|
|
356
|
+
const result2 = { name, box: boxNode, data: transformed ?? combined };
|
|
355
357
|
if (import_extractor.box.isRecipe(map)) {
|
|
356
358
|
parserResult.setCva(result2);
|
|
357
359
|
} else {
|
|
358
360
|
parserResult.set("css", result2);
|
|
359
361
|
}
|
|
360
|
-
const
|
|
361
|
-
if (import_extractor.box.isUnresolvable(map) &&
|
|
362
|
+
const recipeOptions = query.box.value[2];
|
|
363
|
+
if (import_extractor.box.isUnresolvable(map) && recipeOptions && import_extractor.box.isMap(recipeOptions) && recipeOptions.value.has("defaultProps")) {
|
|
362
364
|
const maybeIdentifier = map.getNode();
|
|
363
365
|
if (import_ts_morph.Node.isIdentifier(maybeIdentifier)) {
|
|
364
366
|
const name2 = maybeIdentifier.getText();
|
|
@@ -366,8 +368,8 @@ function createParser(context) {
|
|
|
366
368
|
parserResult.setRecipe(recipeName, {
|
|
367
369
|
type: "jsx-recipe",
|
|
368
370
|
name: recipeName,
|
|
369
|
-
box:
|
|
370
|
-
data: combineResult((0, import_extractor.unbox)(
|
|
371
|
+
box: recipeOptions,
|
|
372
|
+
data: combineResult((0, import_extractor.unbox)(recipeOptions.value.get("defaultProps")))
|
|
371
373
|
});
|
|
372
374
|
}
|
|
373
375
|
}
|
|
@@ -385,7 +387,9 @@ function createParser(context) {
|
|
|
385
387
|
if (query.kind === "call-expression") {
|
|
386
388
|
const map = query.box.value[0];
|
|
387
389
|
const boxNode = import_extractor.box.isMap(map) ? map : import_extractor.box.fallback(query.box);
|
|
388
|
-
const
|
|
390
|
+
const combined = combineResult((0, import_extractor.unbox)(boxNode));
|
|
391
|
+
const transformed = options?.transform?.({ type: "jsx-factory", data: combined });
|
|
392
|
+
const result2 = { name: name2, box: boxNode, data: transformed ?? combined };
|
|
389
393
|
if (import_extractor.box.isRecipe(map)) {
|
|
390
394
|
parserResult.setCva(result2);
|
|
391
395
|
} else {
|
|
@@ -406,11 +410,11 @@ function createParser(context) {
|
|
|
406
410
|
result.queryList.forEach((query) => {
|
|
407
411
|
const data = combineResult((0, import_extractor.unbox)(query.box));
|
|
408
412
|
switch (true) {
|
|
409
|
-
case file.isJsxFactory(name): {
|
|
413
|
+
case (file.isJsxFactory(name) || file.isJsxFactory(alias)): {
|
|
410
414
|
parserResult.setJsx({ type: "jsx-factory", name, box: query.box, data });
|
|
411
415
|
break;
|
|
412
416
|
}
|
|
413
|
-
case jsx.isJsxTagPattern(name): {
|
|
417
|
+
case (jsx.isJsxTagPattern(name) || jsx.isJsxTagPattern(alias)): {
|
|
414
418
|
parserResult.setPattern(name, { type: "jsx-pattern", name, box: query.box, data });
|
|
415
419
|
break;
|
|
416
420
|
}
|
|
@@ -421,6 +425,13 @@ function createParser(context) {
|
|
|
421
425
|
});
|
|
422
426
|
break;
|
|
423
427
|
}
|
|
428
|
+
case jsx.isJsxTagRecipe(alias): {
|
|
429
|
+
const matchingRecipes = recipes.filter(alias);
|
|
430
|
+
matchingRecipes.map((recipe) => {
|
|
431
|
+
parserResult.setRecipe(recipe.baseName, { type: "jsx-recipe", name: alias, box: query.box, data });
|
|
432
|
+
});
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
424
435
|
default: {
|
|
425
436
|
parserResult.setJsx({ type: "jsx", name, box: query.box, data });
|
|
426
437
|
}
|
|
@@ -622,6 +633,9 @@ var Project = class {
|
|
|
622
633
|
if (original !== transformed) {
|
|
623
634
|
sourceFile.replaceWithText(transformed);
|
|
624
635
|
}
|
|
636
|
+
if (hooks["parser:preprocess"]) {
|
|
637
|
+
options.transform = hooks["parser:preprocess"];
|
|
638
|
+
}
|
|
625
639
|
const result = this.parser(sourceFile, encoder, options)?.setFilePath(filePath);
|
|
626
640
|
hooks["parser:after"]?.({ filePath, result });
|
|
627
641
|
return result;
|
package/dist/index.mjs
CHANGED
|
@@ -317,14 +317,16 @@ function createParser(context) {
|
|
|
317
317
|
if (query.kind === "call-expression" && query.box.value[1]) {
|
|
318
318
|
const map = query.box.value[1];
|
|
319
319
|
const boxNode = box.isMap(map) ? map : box.fallback(query.box);
|
|
320
|
-
const
|
|
320
|
+
const combined = combineResult(unbox(boxNode));
|
|
321
|
+
const transformed = options?.transform?.({ type: "jsx-factory", data: combined });
|
|
322
|
+
const result2 = { name, box: boxNode, data: transformed ?? combined };
|
|
321
323
|
if (box.isRecipe(map)) {
|
|
322
324
|
parserResult.setCva(result2);
|
|
323
325
|
} else {
|
|
324
326
|
parserResult.set("css", result2);
|
|
325
327
|
}
|
|
326
|
-
const
|
|
327
|
-
if (box.isUnresolvable(map) &&
|
|
328
|
+
const recipeOptions = query.box.value[2];
|
|
329
|
+
if (box.isUnresolvable(map) && recipeOptions && box.isMap(recipeOptions) && recipeOptions.value.has("defaultProps")) {
|
|
328
330
|
const maybeIdentifier = map.getNode();
|
|
329
331
|
if (Node.isIdentifier(maybeIdentifier)) {
|
|
330
332
|
const name2 = maybeIdentifier.getText();
|
|
@@ -332,8 +334,8 @@ function createParser(context) {
|
|
|
332
334
|
parserResult.setRecipe(recipeName, {
|
|
333
335
|
type: "jsx-recipe",
|
|
334
336
|
name: recipeName,
|
|
335
|
-
box:
|
|
336
|
-
data: combineResult(unbox(
|
|
337
|
+
box: recipeOptions,
|
|
338
|
+
data: combineResult(unbox(recipeOptions.value.get("defaultProps")))
|
|
337
339
|
});
|
|
338
340
|
}
|
|
339
341
|
}
|
|
@@ -351,7 +353,9 @@ function createParser(context) {
|
|
|
351
353
|
if (query.kind === "call-expression") {
|
|
352
354
|
const map = query.box.value[0];
|
|
353
355
|
const boxNode = box.isMap(map) ? map : box.fallback(query.box);
|
|
354
|
-
const
|
|
356
|
+
const combined = combineResult(unbox(boxNode));
|
|
357
|
+
const transformed = options?.transform?.({ type: "jsx-factory", data: combined });
|
|
358
|
+
const result2 = { name: name2, box: boxNode, data: transformed ?? combined };
|
|
355
359
|
if (box.isRecipe(map)) {
|
|
356
360
|
parserResult.setCva(result2);
|
|
357
361
|
} else {
|
|
@@ -372,11 +376,11 @@ function createParser(context) {
|
|
|
372
376
|
result.queryList.forEach((query) => {
|
|
373
377
|
const data = combineResult(unbox(query.box));
|
|
374
378
|
switch (true) {
|
|
375
|
-
case file.isJsxFactory(name): {
|
|
379
|
+
case (file.isJsxFactory(name) || file.isJsxFactory(alias)): {
|
|
376
380
|
parserResult.setJsx({ type: "jsx-factory", name, box: query.box, data });
|
|
377
381
|
break;
|
|
378
382
|
}
|
|
379
|
-
case jsx.isJsxTagPattern(name): {
|
|
383
|
+
case (jsx.isJsxTagPattern(name) || jsx.isJsxTagPattern(alias)): {
|
|
380
384
|
parserResult.setPattern(name, { type: "jsx-pattern", name, box: query.box, data });
|
|
381
385
|
break;
|
|
382
386
|
}
|
|
@@ -387,6 +391,13 @@ function createParser(context) {
|
|
|
387
391
|
});
|
|
388
392
|
break;
|
|
389
393
|
}
|
|
394
|
+
case jsx.isJsxTagRecipe(alias): {
|
|
395
|
+
const matchingRecipes = recipes.filter(alias);
|
|
396
|
+
matchingRecipes.map((recipe) => {
|
|
397
|
+
parserResult.setRecipe(recipe.baseName, { type: "jsx-recipe", name: alias, box: query.box, data });
|
|
398
|
+
});
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
390
401
|
default: {
|
|
391
402
|
parserResult.setJsx({ type: "jsx", name, box: query.box, data });
|
|
392
403
|
}
|
|
@@ -588,6 +599,9 @@ var Project = class {
|
|
|
588
599
|
if (original !== transformed) {
|
|
589
600
|
sourceFile.replaceWithText(transformed);
|
|
590
601
|
}
|
|
602
|
+
if (hooks["parser:preprocess"]) {
|
|
603
|
+
options.transform = hooks["parser:preprocess"];
|
|
604
|
+
}
|
|
591
605
|
const result = this.parser(sourceFile, encoder, options)?.setFilePath(filePath);
|
|
592
606
|
hooks["parser:after"]?.({ filePath, result });
|
|
593
607
|
return result;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "The static parser for panda css",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
"magic-string": "0.30.8",
|
|
33
33
|
"ts-morph": "21.0.1",
|
|
34
34
|
"ts-pattern": "5.0.8",
|
|
35
|
-
"@pandacss/config": "^0.
|
|
36
|
-
"@pandacss/core": "^0.
|
|
37
|
-
"@pandacss/extractor": "0.
|
|
38
|
-
"@pandacss/logger": "0.
|
|
39
|
-
"@pandacss/shared": "0.
|
|
40
|
-
"@pandacss/types": "0.
|
|
35
|
+
"@pandacss/config": "^0.37.0",
|
|
36
|
+
"@pandacss/core": "^0.37.0",
|
|
37
|
+
"@pandacss/extractor": "0.37.0",
|
|
38
|
+
"@pandacss/logger": "0.37.0",
|
|
39
|
+
"@pandacss/shared": "0.37.0",
|
|
40
|
+
"@pandacss/types": "0.37.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@vue/compiler-core": "3.4.19",
|
|
44
|
-
"@pandacss/generator": "0.
|
|
44
|
+
"@pandacss/generator": "0.37.0"
|
|
45
45
|
},
|
|
46
46
|
"files": [
|
|
47
47
|
"dist"
|