@pandacss/types 0.30.0 → 0.30.2

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.
Files changed (2) hide show
  1. package/dist/hooks.d.ts +93 -21
  2. package/package.json +2 -2
package/dist/hooks.d.ts CHANGED
@@ -21,44 +21,45 @@ export interface PandaHooks {
21
21
  /**
22
22
  * Called when the Panda context has been created and the API is ready to be used.
23
23
  */
24
- 'context:created': (args: { ctx: HooksApiInterface; logger: LoggerInterface }) => void
24
+ 'context:created': (args: ContextCreatedHookArgs) => void
25
25
  /**
26
26
  * Called when the config file or one of its dependencies (imports) has changed.
27
27
  */
28
- 'config:change': (args: { config: UserConfig; changes: DiffConfigResult }) => MaybeAsyncReturn
28
+ 'config:change': (args: ConfigChangeHookArgs) => MaybeAsyncReturn
29
29
  /**
30
30
  * Called after reading the file content but before parsing it.
31
31
  * You can use this hook to transform the file content to a tsx-friendly syntax so that Panda's parser can parse it.
32
32
  * You can also use this hook to parse the file's content on your side using a custom parser, in this case you don't have to return anything.
33
33
  */
34
- 'parser:before': (args: { filePath: string; content: string }) => string | void
34
+ 'parser:before': (args: ParserResultBeforeHookArgs) => string | void
35
35
  /**
36
36
  * Called after the file styles are extracted and processed into the resulting ParserResult object.
37
37
  * You can also use this hook to add your own extraction results from your custom parser to the ParserResult object.
38
38
  */
39
- 'parser:after': (args: { filePath: string; result: ParserResultInterface | undefined }) => void
39
+ 'parser:after': (args: ParserResultAfterHookArgs) => void
40
40
  /**
41
41
  * Called right before writing the codegen files to disk.
42
42
  * You can use this hook to tweak the codegen files before they are written to disk.
43
43
  */
44
- 'codegen:prepare': (args: { artifacts: Artifact[]; changed: ArtifactId[] | undefined }) => MaybeAsyncReturn
44
+ 'codegen:prepare': (args: CodegenPrepareHookArgs) => MaybeAsyncReturn
45
45
  /**
46
46
  * Called after the codegen is completed
47
47
  */
48
- 'codegen:done': (args: { changed: ArtifactId[] | undefined }) => MaybeAsyncReturn
48
+ 'codegen:done': (args: CodegenDoneHookArgs) => MaybeAsyncReturn
49
49
  /**
50
50
  * Called right before adding the design-system CSS (global, static, preflight, tokens, keyframes) to the final CSS
51
51
  * Called right before writing/injecting the final CSS (styles.css) that contains the design-system CSS and the parser CSS
52
52
  * You can use it to tweak the CSS content before it's written to disk or injected through the postcss plugin.
53
53
  */
54
- 'cssgen:done': (args: {
55
- artifact: 'global' | 'static' | 'reset' | 'tokens' | 'keyframes' | 'styles.css'
56
- content: string
57
- }) => string | void
54
+ 'cssgen:done': (args: CssgenDoneHookArgs) => string | void
58
55
  }
59
56
 
60
57
  type MaybeAsyncReturn<T = void> = Promise<T> | T
61
58
 
59
+ /* -----------------------------------------------------------------------------
60
+ * Token hooks
61
+ * -----------------------------------------------------------------------------*/
62
+
62
63
  interface TokenCssVarOptions {
63
64
  fallback?: string
64
65
  prefix?: string
@@ -79,6 +80,10 @@ export interface TokenCreatedHookArgs {
79
80
  configure(opts: TokenConfigureOptions): void
80
81
  }
81
82
 
83
+ /* -----------------------------------------------------------------------------
84
+ * Utility hooks
85
+ * -----------------------------------------------------------------------------*/
86
+
82
87
  export interface UtilityConfigureOptions {
83
88
  toHash?(path: string[], toHash: (str: string) => string): string
84
89
  }
@@ -87,6 +92,29 @@ export interface UtilityCreatedHookArgs {
87
92
  configure(opts: UtilityConfigureOptions): void
88
93
  }
89
94
 
95
+ /* -----------------------------------------------------------------------------
96
+ * Config hooks
97
+ * -----------------------------------------------------------------------------*/
98
+
99
+ interface CallbackItem {
100
+ value: any
101
+ path: string
102
+ depth: number
103
+ parent: any[] | Record<string, unknown>
104
+ key: string
105
+ }
106
+
107
+ type CallbackFn = (args: CallbackItem) => void
108
+
109
+ interface TraverseOptions {
110
+ separator: string
111
+ maxDepth?: number | undefined
112
+ }
113
+
114
+ interface TraverseFn {
115
+ (obj: any, callback: CallbackFn, options?: TraverseOptions): void
116
+ }
117
+
90
118
  interface ConfigResolvedHookUtils {
91
119
  omit: <T, K extends keyof T | (string & {})>(obj: T, paths: K[]) => Omit<T, K>
92
120
  traverse: TraverseFn
@@ -99,16 +127,60 @@ export interface ConfigResolvedHookArgs {
99
127
  utils: ConfigResolvedHookUtils
100
128
  }
101
129
 
102
- type CallbackFn = (args: CallbackItem) => void
103
- type CallbackItem = { value: any; path: string; depth: number; parent: any[] | Record<string, unknown>; key: string }
130
+ export interface ConfigChangeHookArgs {
131
+ config: UserConfig
132
+ changes: DiffConfigResult
133
+ }
104
134
 
105
- interface TraverseFn {
106
- (
107
- obj: any,
108
- callback: CallbackFn,
109
- options?: {
110
- separator: string
111
- maxDepth?: number | undefined
112
- },
113
- ): void
135
+ /* -----------------------------------------------------------------------------
136
+ * Parser hooks
137
+ * -----------------------------------------------------------------------------*/
138
+
139
+ export interface ParserResultConfigureOptions {
140
+ matchTag?: (tag: string, isPandaComponent: boolean) => boolean
141
+ matchTagProp?: (tag: string, prop: string) => boolean
142
+ }
143
+
144
+ export interface ParserResultBeforeHookArgs {
145
+ filePath: string
146
+ content: string
147
+ configure: (opts: ParserResultConfigureOptions) => void
148
+ }
149
+
150
+ export interface ParserResultAfterHookArgs {
151
+ filePath: string
152
+ result: ParserResultInterface | undefined
153
+ }
154
+
155
+ /* -----------------------------------------------------------------------------
156
+ * Codegen hooks
157
+ * -----------------------------------------------------------------------------*/
158
+
159
+ export interface CodegenPrepareHookArgs {
160
+ artifacts: Artifact[]
161
+ changed: ArtifactId[] | undefined
162
+ }
163
+
164
+ export interface CodegenDoneHookArgs {
165
+ changed: ArtifactId[] | undefined
166
+ }
167
+
168
+ /* -----------------------------------------------------------------------------
169
+ * Cssgen hooks
170
+ * -----------------------------------------------------------------------------*/
171
+
172
+ type CssgenArtifact = 'global' | 'static' | 'reset' | 'tokens' | 'keyframes' | 'styles.css'
173
+
174
+ export interface CssgenDoneHookArgs {
175
+ artifact: CssgenArtifact
176
+ content: string
177
+ }
178
+
179
+ /* -----------------------------------------------------------------------------
180
+ * Context hooks
181
+ * -----------------------------------------------------------------------------*/
182
+
183
+ export interface ContextCreatedHookArgs {
184
+ ctx: HooksApiInterface
185
+ logger: LoggerInterface
114
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/types",
3
- "version": "0.30.0",
3
+ "version": "0.30.2",
4
4
  "description": "The types for css panda",
5
5
  "main": "dist/index.d.ts",
6
6
  "author": "Segun Adebayo <joseshegs@gmail.com>",
@@ -30,7 +30,7 @@
30
30
  "microdiff": "^1.3.2",
31
31
  "ncp": "^2.0.0",
32
32
  "pkg-types": "1.0.3",
33
- "@pandacss/extractor": "0.30.0"
33
+ "@pandacss/extractor": "0.30.2"
34
34
  },
35
35
  "scripts": {
36
36
  "dev": "tsx scripts/watch.ts",