@pandacss/compiler 2.0.0-beta.1 → 2.0.0-beta.10

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.ts CHANGED
@@ -1,162 +1,92 @@
1
- import { SerializedConfig, Span, Diagnostic, MatchCategory, ExtractedCall, ExtractedJsx, ExtractResult, Compiler, SerializedHookFilter, CompileOutput, Driver, CompilerOptions, ConfigSnapshot } from '@pandacss/compiler-shared';
1
+ import * as _pandacss_compiler_shared from '@pandacss/compiler-shared';
2
+ import { BaseDriver, Diagnostic, CodegenOverlay, DesignSystemWatchTarget, DesignSystemWatchFileKind, SourceChange, DiffConfigResult, CodegenOptions, CompileOptions, CompileOutput, WriteCssOptions, WriteCssResult, WriteLayerCssOptions, WriteSplitCssOptions, WriteSplitCssResult, SerializedConfig, CompilerOptions, ConfigSnapshot } from '@pandacss/compiler-shared';
2
3
  export * from '@pandacss/compiler-shared';
3
-
4
- interface CompileInput {
5
- files?: Array<{
6
- path: string;
7
- content: string;
8
- }>;
9
- config?: SerializedConfig;
10
- cwd?: string;
11
- cacheDir?: string;
12
- emitLayerDeclaration?: boolean;
13
- }
14
- type ImportSpecifierKind = 'named' | 'default' | 'namespace';
15
- interface ImportSpecifier {
16
- kind: ImportSpecifierKind;
17
- imported: string;
18
- local: string;
19
- typeOnly: boolean;
20
- span: Span;
21
- }
22
- type ImportKind = 'sideEffect' | 'value';
23
- interface ImportRecord {
24
- module: string;
25
- kind: ImportKind;
26
- typeOnly: boolean;
27
- specifiers: ImportSpecifier[];
28
- span: Span;
29
- }
30
- interface ImportScanResult {
31
- imports: ImportRecord[];
32
- diagnostics: Diagnostic[];
33
- }
34
- interface Matcher {
35
- modules: string[];
36
- /** Omit to match any imported name (used for recipes/patterns). */
37
- names?: string[];
38
- }
39
- type JsxFramework = 'react' | 'solid' | 'preact' | 'vue' | 'qwik' | (string & {});
40
- type CssSyntax = 'template-literal' | 'object-literal';
41
- interface Matchers {
42
- css: Matcher;
43
- recipe: Matcher;
44
- pattern: Matcher;
45
- jsx?: Matcher;
46
- tokens: Matcher;
47
- /** Configured JSX framework. Enables JSX-aware extraction diagnostics. */
48
- jsxFramework?: JsxFramework;
49
- /** Resolved Panda token dictionary. When present, `token('path')` and
50
- * `token.var('path')` calls fold to their dictionary value during
51
- * extraction. */
52
- tokenDictionary?: TokenDictionary;
53
- /** Resolved JSX factory names that accept member-chain tags (`<styled.div>`). */
54
- jsxFactories?: string[];
55
- /** CSS authoring syntax preference. Omit for object-literal mode. */
56
- syntax?: CssSyntax;
57
- }
58
- /** Two parallel `path → string` maps backing `token()` resolution.
59
- * - `values['colors.red.500']` → raw value, e.g. `'#ef4444'`
60
- * - `vars['colors.red.500']` → CSS-var form, e.g. `'var(--colors-red-500)'` */
61
- interface TokenDictionary {
62
- values: Record<string, string>;
63
- vars: Record<string, string>;
64
- }
65
- interface MatchedImport {
66
- category: MatchCategory;
67
- module: string;
68
- name: string;
69
- alias: string;
70
- kind: ImportSpecifierKind;
71
- }
72
- interface ExtractedCallsResult {
73
- calls: ExtractedCall[];
74
- diagnostics: Diagnostic[];
75
- }
76
- interface ExtractedJsxResult {
77
- jsx: ExtractedJsx[];
78
- diagnostics: Diagnostic[];
79
- }
80
- /** Full result including raw + matched imports, for tooling / parity flows. */
81
- interface ExtractDebugResult {
82
- imports: ImportRecord[];
83
- matched: MatchedImport[];
84
- calls: ExtractedCall[];
85
- jsx: ExtractedJsx[];
86
- diagnostics: Diagnostic[];
87
- }
88
- /** Reusable extractor session — built once from a `Matchers` config, then
89
- * called per file. For one-off use, prefer a `Compiler` + `extractFileSource`. */
90
- interface ExtractorSession {
91
- extract(path: string, source: string): ExtractResult;
92
- extractDebug(path: string, source: string): ExtractDebugResult;
93
- matchImports(scan: ImportScanResult): MatchedImport[];
94
- }
95
- interface ExtractorSessionConstructor {
96
- new (matchers: Matchers): ExtractorSession;
97
- }
98
- interface TraceOptions {
99
- /** Tracing filter, e.g. "trace", "debug", or "pandacss_project=trace". */
100
- filter?: string;
101
- /** `fmt` writes to stderr; `chrome-json` writes a Chrome trace file. */
102
- output?: 'fmt' | 'chrome-json';
103
- /** Required for useful `chrome-json` output. Defaults to `.panda/trace.json`. */
104
- file?: string;
105
- }
106
- interface NativeCompilerOptions {
107
- crossFile?: boolean;
108
- }
109
- /** The raw native instance — superset of {@link Compiler} carrying the internal
110
- * methods the facade hides. */
111
- interface RawCompiler extends Compiler {
112
- token_dictionary?(): TokenDictionary | undefined;
113
- registerUtilityTransform?(id: string, callback: (resolved: unknown, original: unknown) => unknown): void;
114
- registerPatternTransform?(id: string, callback: (props: unknown, helpers: Record<string, unknown>) => unknown): void;
115
- registerSourceTransform?(id: string, filter: SerializedHookFilter | undefined, callback: (filePath: string, content: string) => string | undefined): void;
116
- }
117
- interface CompilerConstructor {
118
- fromConfig(config: SerializedConfig, options?: NativeCompilerOptions, utilityValuesCallbacks?: Record<string, (tokenDictionary: TokenDictionary | undefined) => unknown>): RawCompiler;
119
- }
120
- interface NativeBinding {
121
- startTracing?(options?: TraceOptions): boolean;
122
- flushTracing?(): void;
123
- shutdownTracing?(): boolean;
124
- compile(input?: CompileInput): CompileOutput;
125
- scanImports(path: string, source: string): ImportScanResult;
126
- matchImports(scan: ImportScanResult, matchers: Matchers): MatchedImport[];
127
- extractCalls(path: string, source: string, matched: MatchedImport[], matchers: Matchers): ExtractedCallsResult;
128
- extractJsx(path: string, source: string, matched: MatchedImport[], matchers: Matchers): ExtractedJsxResult;
129
- extract(path: string, source: string, matchers: Matchers): ExtractResult;
130
- extractDebug(path: string, source: string, matchers: Matchers): ExtractDebugResult;
131
- Extractor: ExtractorSessionConstructor;
132
- Compiler: CompilerConstructor;
133
- }
4
+ export { NativeSourceTransformer, NativeTransformSourceInput, TransformSourceOptions, TransformSourceResult, createUsageReport } from '@pandacss/compiler-shared';
5
+ import { C as CompileInput, T as TraceOptions, N as NativeCompiler } from './types-DR9fSNfa.js';
6
+ export { o as CompilerConstructor, e as CssSyntax, j as ExtractDebugResult, E as ExtractedCallsResult, i as ExtractedJsxResult, k as ExtractorSession, l as ExtractorSessionConstructor, b as ImportKind, c as ImportRecord, d as ImportScanResult, a as ImportSpecifier, I as ImportSpecifierKind, J as JsxFramework, h as MatchedImport, M as Matcher, f as Matchers, p as NativeBinding, m as NativeCompilerOptions, n as RawCompiler, R as RawSourceTransformBinding, g as TokenDictionary } from './types-DR9fSNfa.js';
7
+ import { LoadConfigResult } from '@pandacss/config';
134
8
 
135
9
  interface NodeDriverOptions {
136
10
  cwd: string;
137
11
  /** Explicit config file (relative to `cwd`); otherwise discovered upward. */
138
12
  configPath?: string;
13
+ /** Override the config's `include` globs (e.g. CLI `--include`). Empty/omitted keeps the config value. */
14
+ include?: string[];
15
+ }
16
+ interface WriteDesignSystemLibOptions {
17
+ outdir?: string;
18
+ files?: string[];
19
+ panda?: string;
20
+ minify?: boolean;
21
+ maxWarnings?: number | string;
22
+ }
23
+ interface WriteDesignSystemLibResult {
24
+ manifestPath: string;
25
+ buildInfoPath: string;
26
+ presetPath: string;
27
+ exportsChanged: boolean;
28
+ parsedFileCount: number;
29
+ diagnostics: Diagnostic[];
139
30
  }
140
31
  /**
141
32
  * {@link Driver} backed by the native compiler (`OsFileSystem`). Loads the
142
33
  * config from disk; `scan` / `codegen` run through the Rust fs engine.
143
34
  */
144
- declare function createNodeDriver(options: NodeDriverOptions): Promise<Driver>;
35
+ declare function createNodeDriver(options: NodeDriverOptions): Promise<NodeDriver>;
36
+ declare class NodeDriver extends BaseDriver {
37
+ #private;
38
+ constructor(options: NodeDriverOptions, loaded: LoadConfigResult);
39
+ get designSystemDiagnostics(): Diagnostic[];
40
+ protected codegenOverlay(): CodegenOverlay | undefined;
41
+ get config(): _pandacss_compiler_shared.SerializedConfig;
42
+ get configPath(): string;
43
+ get configDependencies(): string[];
44
+ designSystemWatchTargets(): DesignSystemWatchTarget[];
45
+ isDesignSystemFile(file: string): DesignSystemWatchFileKind | false;
46
+ private buildDesignSystemFileKinds;
47
+ syncDesignSystemFileChange(change: SourceChange): Promise<boolean>;
48
+ syncDesignSystemSources(): boolean[];
49
+ reload(): Promise<DiffConfigResult>;
50
+ /** Re-hydrate when treeshake import set changes. */
51
+ syncDesignSystemTreeShake(): boolean;
52
+ protected prepareCssOutput(): void;
53
+ applyChange(change: SourceChange): boolean;
54
+ getOutdir(outdir?: string): string;
55
+ writeDesignSystemLib(options?: WriteDesignSystemLibOptions): Promise<WriteDesignSystemLibResult>;
56
+ codegen(options?: CodegenOptions): string[];
57
+ cssgen(options?: CompileOptions): CompileOutput;
58
+ writeCss(options: WriteCssOptions): WriteCssResult;
59
+ writeLayerCss(options: WriteLayerCssOptions): WriteCssResult;
60
+ writeSplitCss(options?: WriteSplitCssOptions): WriteSplitCssResult;
61
+ private runCssgenDone;
62
+ private codegenWithPrepareHooks;
63
+ isConfigFile(file: string): boolean;
64
+ private buildConfigFilePaths;
65
+ private parseDesignSystemLib;
66
+ private compileDesignSystemPreset;
67
+ private writeDesignSystemLibArtifacts;
68
+ }
145
69
 
146
- /** One-shot stateless compile: build a compiler from `config`, parse every
147
- * input file, and emit the stylesheet. Callback-bearing configs
148
- * (`utilities.*.transform`, `patterns.*.transform`) are *not* supported here —
149
- * use [`createCompiler`] + `options.callbacks` for those. */
70
+ /**
71
+ * One-shot stateless compile: build a compiler from `config`, parse every
72
+ * input file, and emit the stylesheet. Callback-bearing configs
73
+ * (`utilities.*.transform`, `patterns.*.transform`) are *not* supported here -
74
+ * use [`createCompiler`] + `options.callbacks` for those.
75
+ */
150
76
  declare function compile(input?: CompileInput): CompileOutput;
151
77
  declare function startTracing(options?: TraceOptions): boolean;
152
78
  declare function flushTracing(): void;
79
+ /** Renders `timings.json` from spans collected so far. Call before `shutdownTracing`. */
80
+ declare function takeTimingsJson(): string | undefined;
153
81
  declare function shutdownTracing(): boolean;
154
- declare function createCompiler(config: SerializedConfig, options?: CompilerOptions): Compiler;
155
- /** Like {@link createCompiler}, but takes a snapshot; its callbacks merge under
156
- * any in `options.callbacks`. */
157
- declare function createCompilerFromSnapshot(snapshot: ConfigSnapshot, options?: CompilerOptions): Compiler;
82
+ declare function createCompiler(config: SerializedConfig, options?: CompilerOptions): NativeCompiler;
83
+ /**
84
+ * Like {@link createCompiler}, but takes a snapshot; its callbacks merge under
85
+ * any in `options.callbacks`.
86
+ */
87
+ declare function createCompilerFromSnapshot(snapshot: ConfigSnapshot, options?: CompilerOptions): NativeCompiler;
158
88
  declare function getBindingInfo(): {
159
89
  native: boolean;
160
90
  };
161
91
 
162
- export { type CompileInput, type CompilerConstructor, type CssSyntax, type ExtractDebugResult, type ExtractedCallsResult, type ExtractedJsxResult, type ExtractorSession, type ExtractorSessionConstructor, type ImportKind, type ImportRecord, type ImportScanResult, type ImportSpecifier, type ImportSpecifierKind, type JsxFramework, type MatchedImport, type Matcher, type Matchers, type NativeBinding, type NativeCompilerOptions, type NodeDriverOptions, type RawCompiler, type TokenDictionary, type TraceOptions, compile, createCompiler, createCompilerFromSnapshot, createNodeDriver, flushTracing, getBindingInfo, shutdownTracing, startTracing };
92
+ export { CompileInput, NativeCompiler, NodeDriver, type NodeDriverOptions, TraceOptions, type WriteDesignSystemLibOptions, type WriteDesignSystemLibResult, compile, createCompiler, createCompilerFromSnapshot, createNodeDriver, flushTracing, getBindingInfo, shutdownTracing, startTracing, takeTimingsJson };
package/dist/index.js CHANGED
@@ -1,20 +1,26 @@
1
1
  import {
2
+ NodeDriver,
2
3
  compile,
3
4
  createCompiler,
4
5
  createCompilerFromSnapshot,
5
6
  createNodeDriver,
7
+ createUsageReport,
6
8
  flushTracing,
7
9
  getBindingInfo,
8
10
  shutdownTracing,
9
- startTracing
10
- } from "./chunk-7OM4CBA4.js";
11
+ startTracing,
12
+ takeTimingsJson
13
+ } from "./chunk-73WPZHEX.js";
11
14
  export {
15
+ NodeDriver,
12
16
  compile,
13
17
  createCompiler,
14
18
  createCompilerFromSnapshot,
15
19
  createNodeDriver,
20
+ createUsageReport,
16
21
  flushTracing,
17
22
  getBindingInfo,
18
23
  shutdownTracing,
19
- startTracing
24
+ startTracing,
25
+ takeTimingsJson
20
26
  };
package/dist/loader.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { Compiler, CompilerOptions } from '@pandacss/compiler-shared';
1
+ import { CompilerOptions } from '@pandacss/compiler-shared';
2
2
  import { LoadConfigOptions } from '@pandacss/config';
3
3
  export { LoadConfigOptions, LoadConfigResult } from '@pandacss/config';
4
+ import { N as NativeCompiler } from './types-DR9fSNfa.js';
4
5
 
5
6
  interface LoadCompilerResult {
6
7
  /** The compiler built from the loaded config snapshot. */
7
- compiler: Compiler;
8
+ compiler: NativeCompiler;
8
9
  /** Resolved config path. */
9
10
  path: string;
10
11
  /** Module ids to watch for invalidation. */
package/dist/loader.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createCompilerFromSnapshot
3
- } from "./chunk-7OM4CBA4.js";
3
+ } from "./chunk-73WPZHEX.js";
4
4
 
5
5
  // src/loader.ts
6
6
  import { loadConfig } from "@pandacss/config";
@@ -0,0 +1,108 @@
1
+ import { Compiler, Diagnostic, FileInspectionResult, Spec, Deprecation } from '@pandacss/compiler-shared';
2
+ import { LoadConfigResult } from '@pandacss/config';
3
+ import { ImportMapOutput } from '@pandacss/types';
4
+
5
+ interface NativeCompiler extends Compiler {
6
+ }
7
+
8
+ interface ProjectKey {
9
+ cwd: string;
10
+ /** Explicit config file (relative to `cwd`); otherwise discovered upward. */
11
+ configPath?: string;
12
+ }
13
+ interface Project {
14
+ compiler: NativeCompiler;
15
+ configPath: string;
16
+ dependencies: string[];
17
+ outdir: string;
18
+ /** Non-fatal issues surfaced while hydrating a consumed design-system package. */
19
+ designSystemDiagnostics: Diagnostic[];
20
+ /** Treeshake import fingerprint (watch sync). */
21
+ designSystemTreeshakeKey?: string;
22
+ }
23
+ declare function createProjectFromLoadedConfig(loaded: LoadConfigResult): Project;
24
+ declare function createProjectFromConfig(key: ProjectKey): Promise<Project>;
25
+
26
+ interface FileInspectionCacheEntry {
27
+ sourceKey: string;
28
+ result: FileInspectionResult;
29
+ }
30
+ /** Caches `compiler.inspectFile()` results per `(compiler, path)`, invalidated by source content. */
31
+ declare class FileInspector {
32
+ #private;
33
+ inspect(compiler: Compiler, path: string, source: string): FileInspectionResult;
34
+ clear(compiler?: Compiler): void;
35
+ }
36
+ declare function sourceCacheKey(source: string): string;
37
+
38
+ interface ProjectRegistryOptions {
39
+ createProject?: (key: ProjectKey) => Promise<Project>;
40
+ }
41
+ declare class ProjectRegistry {
42
+ #private;
43
+ constructor(options?: ProjectRegistryOptions);
44
+ getProject(key: ProjectKey): Promise<Project>;
45
+ invalidate(_changedPaths?: string[]): void;
46
+ }
47
+
48
+ declare class SpecIndex {
49
+ #private;
50
+ readonly spec: Spec;
51
+ constructor(spec: Spec);
52
+ resolveTokenValue(path: string): string | undefined;
53
+ resolveTokenPaths(prefix?: string): string[];
54
+ resolveTokenDeprecation(path: string): Deprecation | undefined;
55
+ hasCondition(name: string): boolean;
56
+ /** Bare style-object keys: named/custom conditions plus breakpoints (`sm`, `md`, ...). */
57
+ resolveStyleObjectKeys(): string[];
58
+ resolveTokenCategoryForProperty(property: string): string | undefined;
59
+ resolveLiteralsForProperty(property: string): string[] | undefined;
60
+ resolveKeyframeNames(prefix?: string): string[];
61
+ /** Token category names actually present in this config (`colors`, `spacing`, ...). */
62
+ resolveTokenCategories(prefix?: string): string[];
63
+ }
64
+
65
+ interface ConfigTokenRefSpan {
66
+ start: number;
67
+ end: number;
68
+ pathStart: number;
69
+ pathEnd: number;
70
+ path: string;
71
+ }
72
+ declare function findConfigTokenRefs(text: string): ConfigTokenRefSpan[];
73
+ declare function findConfigTokenRefAt(text: string, position: number): ConfigTokenRefSpan | undefined;
74
+ declare function completeConfigTokenPath(prefix: string, index: SpecIndex): string[];
75
+
76
+ type StyleObjectCursorKind = 'key' | 'value';
77
+ interface StyleObjectContext {
78
+ existingKeys: string[];
79
+ cursorKind: StyleObjectCursorKind;
80
+ /**
81
+ * Style-object-relative key chain leading to the cursor (see typescript-plugin's
82
+ * `getStyleObjectCursorInfo`) — e.g. `['color']`, or `['backgroundColor', 'sm']` for a
83
+ * utility's own inline conditional value (`backgroundColor: { sm: 're' }`).
84
+ */
85
+ propertyPath: string[];
86
+ prefix: string;
87
+ }
88
+ type CompletionEntryKind = 'utility' | 'condition' | 'token' | 'keyframe' | 'literal' | 'keyword' | 'category';
89
+ interface CompletionEntry {
90
+ name: string;
91
+ kind: CompletionEntryKind;
92
+ }
93
+ declare function completeConfigStyleObject(context: StyleObjectContext, index: SpecIndex): CompletionEntry[];
94
+
95
+ type SemanticTokenCursorKind = 'category' | 'condition';
96
+ interface SemanticTokenContext {
97
+ cursorKind: SemanticTokenCursorKind;
98
+ existingKeys: string[];
99
+ prefix: string;
100
+ }
101
+ declare function completeSemanticTokenObject(context: SemanticTokenContext, index: SpecIndex): CompletionEntry[];
102
+
103
+ interface ResolveModuleTargetOptions {
104
+ outdir: string;
105
+ }
106
+ declare function resolveModuleTarget(specifier: string, importMap: ImportMapOutput, options: ResolveModuleTargetOptions): string | undefined;
107
+
108
+ export { type CompletionEntry, type CompletionEntryKind, type ConfigTokenRefSpan, type FileInspectionCacheEntry, FileInspector, type Project, type ProjectKey, ProjectRegistry, type ProjectRegistryOptions, type ResolveModuleTargetOptions, type SemanticTokenContext, type SemanticTokenCursorKind, SpecIndex, type StyleObjectContext, type StyleObjectCursorKind, completeConfigStyleObject, completeConfigTokenPath, completeSemanticTokenObject, createProjectFromConfig, createProjectFromLoadedConfig, findConfigTokenRefAt, findConfigTokenRefs, resolveModuleTarget, sourceCacheKey };