@pandacss/parser 0.36.1 → 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 +13 -6
- package/dist/index.mjs +13 -6
- 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 {
|
|
@@ -629,6 +633,9 @@ var Project = class {
|
|
|
629
633
|
if (original !== transformed) {
|
|
630
634
|
sourceFile.replaceWithText(transformed);
|
|
631
635
|
}
|
|
636
|
+
if (hooks["parser:preprocess"]) {
|
|
637
|
+
options.transform = hooks["parser:preprocess"];
|
|
638
|
+
}
|
|
632
639
|
const result = this.parser(sourceFile, encoder, options)?.setFilePath(filePath);
|
|
633
640
|
hooks["parser:after"]?.({ filePath, result });
|
|
634
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 {
|
|
@@ -595,6 +599,9 @@ var Project = class {
|
|
|
595
599
|
if (original !== transformed) {
|
|
596
600
|
sourceFile.replaceWithText(transformed);
|
|
597
601
|
}
|
|
602
|
+
if (hooks["parser:preprocess"]) {
|
|
603
|
+
options.transform = hooks["parser:preprocess"];
|
|
604
|
+
}
|
|
598
605
|
const result = this.parser(sourceFile, encoder, options)?.setFilePath(filePath);
|
|
599
606
|
hooks["parser:after"]?.({ filePath, result });
|
|
600
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"
|