@pandacss/parser 0.27.3 → 0.29.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ParserOptions } from '@pandacss/core';
2
- import { ParserResultInterface, ResultItem, Runtime, PandaHookable, ConfigTsOptions } from '@pandacss/types';
2
+ import { ParserResultInterface, ResultItem, 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
 
@@ -47,7 +47,7 @@ declare function createParser(context: ParserOptions): (sourceFile: SourceFile |
47
47
  interface ProjectOptions extends ProjectOptions$1 {
48
48
  readFile: Runtime['fs']['readFileSync'];
49
49
  getFiles(): string[];
50
- hooks: PandaHookable;
50
+ hooks: Partial<PandaHooks>;
51
51
  parserOptions: ParserOptions;
52
52
  tsOptions?: ConfigTsOptions;
53
53
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ParserOptions } from '@pandacss/core';
2
- import { ParserResultInterface, ResultItem, Runtime, PandaHookable, ConfigTsOptions } from '@pandacss/types';
2
+ import { ParserResultInterface, ResultItem, 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
 
@@ -47,7 +47,7 @@ declare function createParser(context: ParserOptions): (sourceFile: SourceFile |
47
47
  interface ProjectOptions extends ProjectOptions$1 {
48
48
  readFile: Runtime['fs']['readFileSync'];
49
49
  getFiles(): string[];
50
- hooks: PandaHookable;
50
+ hooks: Partial<PandaHooks>;
51
51
  parserOptions: ParserOptions;
52
52
  tsOptions?: ConfigTsOptions;
53
53
  }
package/dist/index.js CHANGED
@@ -115,7 +115,7 @@ var ParserResult = class {
115
115
  this.setSva(result);
116
116
  break;
117
117
  default:
118
- throw new Error(`Unknown result type ${name}`);
118
+ throw new import_shared.PandaError("UNKNOWN_TYPE", `Unknown result type ${name}`);
119
119
  }
120
120
  }
121
121
  setCss(result) {
@@ -578,14 +578,14 @@ var Project = class {
578
578
  const sourceFile = this.project.getSourceFile(filePath);
579
579
  if (!sourceFile)
580
580
  return;
581
- const content = sourceFile.getText();
582
- const transformed = this.transformFile(filePath, content);
583
- if (content !== transformed) {
581
+ const original = sourceFile.getText();
582
+ const custom = hooks["parser:before"]?.({ filePath, content: original });
583
+ const transformed = custom ?? this.transformFile(filePath, original);
584
+ if (original !== transformed) {
584
585
  sourceFile.replaceWithText(transformed);
585
586
  }
586
- hooks.callHook("parser:before", filePath, content);
587
587
  const result = this.parser(sourceFile, encoder)?.setFilePath(filePath);
588
- hooks.callHook("parser:after", filePath, result);
588
+ hooks["parser:after"]?.({ filePath, result });
589
589
  return result;
590
590
  };
591
591
  transformFile = (filePath, content) => {
package/dist/index.mjs CHANGED
@@ -49,7 +49,7 @@ function getImportDeclarations(context, sourceFile) {
49
49
  }
50
50
 
51
51
  // src/parser-result.ts
52
- import { getOrCreateSet } from "@pandacss/shared";
52
+ import { PandaError, getOrCreateSet } from "@pandacss/shared";
53
53
  var ParserResult = class {
54
54
  constructor(context, encoder) {
55
55
  this.context = context;
@@ -81,7 +81,7 @@ var ParserResult = class {
81
81
  this.setSva(result);
82
82
  break;
83
83
  default:
84
- throw new Error(`Unknown result type ${name}`);
84
+ throw new PandaError("UNKNOWN_TYPE", `Unknown result type ${name}`);
85
85
  }
86
86
  }
87
87
  setCss(result) {
@@ -544,14 +544,14 @@ var Project = class {
544
544
  const sourceFile = this.project.getSourceFile(filePath);
545
545
  if (!sourceFile)
546
546
  return;
547
- const content = sourceFile.getText();
548
- const transformed = this.transformFile(filePath, content);
549
- if (content !== transformed) {
547
+ const original = sourceFile.getText();
548
+ const custom = hooks["parser:before"]?.({ filePath, content: original });
549
+ const transformed = custom ?? this.transformFile(filePath, original);
550
+ if (original !== transformed) {
550
551
  sourceFile.replaceWithText(transformed);
551
552
  }
552
- hooks.callHook("parser:before", filePath, content);
553
553
  const result = this.parser(sourceFile, encoder)?.setFilePath(filePath);
554
- hooks.callHook("parser:after", filePath, result);
554
+ hooks["parser:after"]?.({ filePath, result });
555
555
  return result;
556
556
  };
557
557
  transformFile = (filePath, content) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/parser",
3
- "version": "0.27.3",
3
+ "version": "0.29.0",
4
4
  "description": "The static parser for panda css",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -32,17 +32,16 @@
32
32
  "magic-string": "0.30.5",
33
33
  "ts-morph": "19.0.0",
34
34
  "ts-pattern": "5.0.5",
35
- "@pandacss/config": "^0.27.3",
36
- "@pandacss/core": "^0.27.3",
37
- "@pandacss/extractor": "0.27.3",
38
- "@pandacss/logger": "0.27.3",
39
- "@pandacss/shared": "0.27.3",
40
- "@pandacss/types": "0.27.3"
35
+ "@pandacss/config": "^0.29.0",
36
+ "@pandacss/core": "^0.29.0",
37
+ "@pandacss/extractor": "0.29.0",
38
+ "@pandacss/logger": "0.29.0",
39
+ "@pandacss/shared": "0.29.0",
40
+ "@pandacss/types": "0.29.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@vue/compiler-core": "3.3.4",
44
- "hookable": "5.5.3",
45
- "@pandacss/generator": "0.27.3"
44
+ "@pandacss/generator": "0.29.0"
46
45
  },
47
46
  "files": [
48
47
  "dist"