@pandacss/types 0.27.2 → 0.28.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.
@@ -1,3 +1,4 @@
1
+ import { type Difference } from 'microdiff'
1
2
  import type { Nullable } from './shared'
2
3
 
3
4
  export interface ArtifactContent {
@@ -49,3 +50,9 @@ export interface ArtifactFilters {
49
50
  ids?: ArtifactId[]
50
51
  affecteds?: AffectedArtifacts
51
52
  }
53
+
54
+ export interface DiffConfigResult {
55
+ hasConfigChanged: boolean
56
+ artifacts: Set<ArtifactId>
57
+ diffs: Difference[]
58
+ }
package/dist/config.d.ts CHANGED
@@ -364,16 +364,20 @@ export interface ConfigTsOptions {
364
364
  pathMappings: PathMapping[]
365
365
  }
366
366
 
367
- export interface LoadConfigResult {
367
+ export interface LoadTsConfigResult {
368
+ tsconfig?: TSConfig
369
+ tsOptions?: ConfigTsOptions
370
+ tsconfigFile?: string
371
+ }
372
+
373
+ export interface LoadConfigResult extends LoadTsConfigResult {
368
374
  /** Config path */
369
375
  path: string
370
376
  config: UserConfig
371
377
  serialized: string
372
378
  deserialize: () => Config
373
- tsconfig?: TSConfig
374
- tsOptions?: ConfigTsOptions
375
- tsconfigFile?: string
376
379
  dependencies: string[]
380
+ hooks: Partial<PandaHooks>
377
381
  }
378
382
 
379
383
  export interface HashOptions {
@@ -0,0 +1,56 @@
1
+ import type { UserConfig } from './config'
2
+ import type { RecipeDefinition, RecipeVariantRecord, SlotRecipeDefinition, SlotRecipeVariantRecord } from './recipe'
3
+ import type { AtomicStyleResult, RecipeBaseResult } from './style-rules'
4
+ import type { SystemStyleObject } from './system-types'
5
+
6
+ export interface BaseRule {
7
+ getClassNames: () => string[]
8
+ toCss: () => string
9
+ }
10
+
11
+ export interface AtomicRule extends BaseRule {
12
+ styles: SystemStyleObject
13
+ }
14
+
15
+ export interface AtomicRecipeRule extends BaseRule {
16
+ config: RecipeDefinition<any> | SlotRecipeDefinition<string, any>
17
+ }
18
+
19
+ export interface RecipeVariantsRule extends BaseRule {
20
+ variants: RecipeVariantRecord
21
+ }
22
+
23
+ export interface ProcessorInterface {
24
+ css(styles: SystemStyleObject): AtomicRule
25
+ cva(recipeConfig: RecipeDefinition<RecipeVariantRecord>): AtomicRecipeRule
26
+ sva(recipeConfig: SlotRecipeDefinition<string, SlotRecipeVariantRecord<string>>): AtomicRecipeRule
27
+ recipe(name: string, variants?: RecipeVariantRecord): RecipeVariantsRule | undefined
28
+ }
29
+
30
+ export interface HooksApiInterface {
31
+ /**
32
+ * The resolved config (after all the presets are loaded and merged)
33
+ */
34
+ config: UserConfig
35
+ /**
36
+ * The path to the config file
37
+ */
38
+ configPath: string
39
+ /**
40
+ * The list of all the config dependencies (direct/transitive imports) filepaths
41
+ */
42
+ configDependencies: string[]
43
+ //
44
+ /**
45
+ * The processor can be used to generate atomic or recipe classes
46
+ */
47
+ processor: ProcessorInterface
48
+ /**
49
+ * Map that contains all the utility classNames
50
+ */
51
+ classNames: Map<string, string>
52
+ /**
53
+ * Map that contains all the classNames found (and therefore generated) in the app code
54
+ */
55
+ generatedClassNames: Map<string, AtomicStyleResult | RecipeBaseResult>
56
+ }
package/dist/hooks.d.ts CHANGED
@@ -1,44 +1,61 @@
1
- import type { HookKeys, Hookable } from 'hookable'
1
+ import type { ArtifactId, DiffConfigResult } from './artifact'
2
2
  import type { LoadConfigResult, UserConfig } from './config'
3
+ import type { HooksApiInterface } from './hooks-api'
3
4
  import type { ParserResultInterface } from './parser'
4
5
 
5
- type MaybeAsyncReturn = Promise<void> | void
6
+ type MaybeAsyncReturn<T = void> = Promise<T> | T
6
7
 
7
8
  export interface PandaHooks {
8
9
  /**
9
10
  * Called when the config is resolved, after all the presets are loaded and merged.
11
+ * This is the first hook called, you can use it to tweak the config before the context is created.
10
12
  */
11
- 'config:resolved': (conf: LoadConfigResult) => MaybeAsyncReturn
13
+ 'config:resolved': (args: { conf: LoadConfigResult }) => MaybeAsyncReturn
14
+ /**
15
+ * Called when the Panda context has been created and the API is ready to be used.
16
+ */
17
+ 'context:created': (args: { ctx: HooksApiInterface; logger: LoggerInterface }) => void
12
18
  /**
13
19
  * Called when the config file or one of its dependencies (imports) has changed.
14
20
  */
15
- 'config:change': (ctx: UserConfig) => MaybeAsyncReturn
21
+ 'config:change': (args: { config: UserConfig; changes: DiffConfigResult }) => MaybeAsyncReturn
16
22
  /**
17
23
  * Called after reading the file content but before parsing it.
24
+ * You can use this hook to transform the file content to a tsx-friendly syntax so that Panda's parser can parse it.
25
+ * 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.
18
26
  */
19
- 'parser:before': (file: string, content: string) => void
27
+ 'parser:before': (args: { filePath: string; content: string }) => string | void
20
28
  /**
21
29
  * Called after the file styles are extracted and processed into the resulting ParserResult object.
30
+ * You can also use this hook to add your own extraction results from your custom parser to the ParserResult object.
22
31
  */
23
- 'parser:after': (file: string, result: ParserResultInterface | undefined) => void
24
- /**
25
- * Called after the extracted ParserResult has been transformed to a CSS string
26
- */
27
- 'parser:css': (file: string, css: string | undefined) => void
32
+ 'parser:after': (args: { filePath: string; result: ParserResultInterface | undefined }) => void
28
33
  /**
29
- * Called before generating the design-system CSS files (global, static, preflight, tokens, keyframes)
34
+ * Called after the codegen is completed
30
35
  */
31
- 'generator:css': (
32
- file: 'global.css' | 'static.css' | 'reset.css' | 'tokens.css' | 'keyframes.css' | 'styles.css',
33
- css: string,
34
- ) => void
36
+ 'codegen:done': (args: { changed: ArtifactId[] | undefined }) => MaybeAsyncReturn
35
37
  /**
36
- * Called after the codegen is completed
38
+ * Called right before adding the design-system CSS (global, static, preflight, tokens, keyframes) to the final CSS
39
+ * Called right before writing/injecting the final CSS (styles.css) that contains the design-system CSS and the parser CSS
40
+ * You can use it to tweak the CSS content before it's written to disk or injected through the postcss plugin.
37
41
  */
38
- 'generator:done': () => void | Promise<void>
42
+ 'cssgen:done': (args: {
43
+ artifact: 'global' | 'static' | 'reset' | 'tokens' | 'keyframes' | 'styles.css'
44
+ content: string
45
+ }) => string | void
39
46
  }
40
47
 
41
- export type PandaHookable = Hookable<PandaHooks, HookKeys<PandaHooks>>
42
- export interface ConfigResultWithHooks extends LoadConfigResult {
43
- hooks: PandaHookable
48
+ export interface LoggerInterface {
49
+ level: 'debug' | 'info' | 'warn' | 'error' | 'silent'
50
+ print(data: any): void
51
+ warn: (type: string, data: any) => void
52
+ info: (type: string, data: any) => void
53
+ debug: (type: string, data: any) => void
54
+ error: (type: string, data: any) => void
55
+ log: (data: string) => void
56
+ time: {
57
+ info: (msg: string) => (_msg?: string) => void
58
+ debug: (msg: string) => (_msg?: string) => void
59
+ }
60
+ isDebug: boolean
44
61
  }
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export type * from './composition'
4
4
  export type * from './conditions'
5
5
  export type * from './config'
6
6
  export type * from './hooks'
7
+ export type * from './hooks-api'
7
8
  export type * from './parser'
8
9
  export type * from './parts'
9
10
  export type * from './pattern'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/types",
3
- "version": "0.27.2",
3
+ "version": "0.28.0",
4
4
  "description": "The types for css panda",
5
5
  "main": "dist/index.d.ts",
6
6
  "author": "Segun Adebayo <joseshegs@gmail.com>",
@@ -27,10 +27,10 @@
27
27
  ],
28
28
  "devDependencies": {
29
29
  "csstype": "3.1.3",
30
- "hookable": "5.5.3",
30
+ "microdiff": "^1.3.2",
31
31
  "ncp": "^2.0.0",
32
32
  "pkg-types": "1.0.3",
33
- "@pandacss/extractor": "0.27.2"
33
+ "@pandacss/extractor": "0.28.0"
34
34
  },
35
35
  "scripts": {
36
36
  "dev": "tsx scripts/watch.ts",