@pandacss/compiler 2.0.0-beta.8 → 2.0.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.ts CHANGED
@@ -1,162 +1,20 @@
1
1
  import * as _pandacss_compiler_shared from '@pandacss/compiler-shared';
2
- import { SerializedConfig, Span, Diagnostic, MatchCategory, ExtractedCall, ExtractedJsx, ExtractResult, Compiler, BuildInfoNative, DesignSystemManifestInput, DesignSystemManifest, DesignSystemChainPlan, FileInspectionResult, SerializedHookFilter, CompileOutput, BaseDriver, DesignSystemWatchTarget, DesignSystemWatchFileKind, SourceChange, DiffConfigResult, CodegenOptions, CompilerOptions, ConfigSnapshot } 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';
3
3
  export * from '@pandacss/compiler-shared';
4
- export { createUsageReport } from '@pandacss/compiler-shared';
4
+ export { NativeSourceTransformer, NativeTransformSourceInput, TransformSourceOptions, TransformSourceResult, createUsageReport } from '@pandacss/compiler-shared';
5
+ import { C as CompileInput, T as TraceOptions, N as NativeCompiler } from './types-CxQirxMo.js';
6
+ export { n as CompilerConstructor, i as ExtractDebugResult, E as ExtractedCallsResult, h as ExtractedJsxResult, j as ExtractorSession, k as ExtractorSessionConstructor, b as ImportKind, c as ImportRecord, d as ImportScanResult, a as ImportSpecifier, I as ImportSpecifierKind, J as JsxFramework, g as MatchedImport, M as Matcher, e as Matchers, o as NativeBinding, l as NativeCompilerOptions, m as RawCompiler, R as RawSourceTransformBinding, f as TokenDictionary } from './types-CxQirxMo.js';
7
+ import * as _pandacss_config from '@pandacss/config';
5
8
  import { LoadConfigResult } from '@pandacss/config';
6
9
 
7
- interface CompileInput {
8
- files?: Array<{
9
- path: string;
10
- content: string;
11
- }>;
12
- config?: SerializedConfig;
13
- cwd?: string;
14
- cacheDir?: string;
15
- emitLayerDeclaration?: boolean;
16
- }
17
- type ImportSpecifierKind = 'named' | 'default' | 'namespace';
18
- interface ImportSpecifier {
19
- kind: ImportSpecifierKind;
20
- imported: string;
21
- local: string;
22
- typeOnly: boolean;
23
- span: Span;
24
- }
25
- type ImportKind = 'sideEffect' | 'value';
26
- interface ImportRecord {
27
- module: string;
28
- kind: ImportKind;
29
- typeOnly: boolean;
30
- specifiers: ImportSpecifier[];
31
- span: Span;
32
- }
33
- interface ImportScanResult {
34
- imports: ImportRecord[];
35
- diagnostics: Diagnostic[];
36
- }
37
- interface Matcher {
38
- modules: string[];
39
- /** Omit to match any imported name (used for recipes/patterns). */
40
- names?: string[];
41
- }
42
- type JsxFramework = 'react' | 'solid' | 'preact' | 'vue' | 'qwik' | (string & {});
43
- type CssSyntax = 'template-literal' | 'object-literal';
44
- interface Matchers {
45
- css: Matcher;
46
- recipe: Matcher;
47
- pattern: Matcher;
48
- jsx?: Matcher;
49
- tokens: Matcher;
50
- /** Configured JSX framework. Enables JSX-aware extraction diagnostics. */
51
- jsxFramework?: JsxFramework;
52
- /** Resolved Panda token dictionary. When present, `token('path')` and
53
- * `token.var('path')` calls fold to their dictionary value during
54
- * extraction. */
55
- tokenDictionary?: TokenDictionary;
56
- /** Resolved JSX factory names that accept member-chain tags (`<styled.div>`). */
57
- jsxFactories?: string[];
58
- /** CSS authoring syntax preference. Omit for object-literal mode. */
59
- syntax?: CssSyntax;
60
- }
61
- /** Two parallel `path → string` maps backing `token()` resolution.
62
- * - `values['colors.red.500']` → raw value, e.g. `'#ef4444'`
63
- * - `vars['colors.red.500']` → CSS-var form, e.g. `'var(--colors-red-500)'` */
64
- interface TokenDictionary {
65
- values: Record<string, string>;
66
- vars: Record<string, string>;
67
- }
68
- interface MatchedImport {
69
- category: MatchCategory;
70
- module: string;
71
- name: string;
72
- alias: string;
73
- kind: ImportSpecifierKind;
74
- }
75
- interface ExtractedCallsResult {
76
- calls: ExtractedCall[];
77
- diagnostics: Diagnostic[];
78
- }
79
- interface ExtractedJsxResult {
80
- jsx: ExtractedJsx[];
81
- diagnostics: Diagnostic[];
82
- }
83
- /** Full result including raw + matched imports, for tooling / parity flows. */
84
- interface ExtractDebugResult {
85
- imports: ImportRecord[];
86
- matched: MatchedImport[];
87
- calls: ExtractedCall[];
88
- jsx: ExtractedJsx[];
89
- diagnostics: Diagnostic[];
90
- }
91
- /** Reusable extractor session — built once from a `Matchers` config, then
92
- * called per file. For one-off use, prefer a `Compiler` + `extractFileSource`. */
93
- interface ExtractorSession {
94
- extract(path: string, source: string): ExtractResult;
95
- extractDebug(path: string, source: string): ExtractDebugResult;
96
- matchImports(scan: ImportScanResult): MatchedImport[];
97
- }
98
- interface ExtractorSessionConstructor {
99
- new (matchers: Matchers): ExtractorSession;
100
- }
101
- interface TraceOptions {
102
- /** Tracing filter, e.g. "trace", "debug", or "pandacss_project=trace". */
103
- filter?: string;
104
- /** `fmt` writes to stderr; `chrome-json` writes a Chrome trace file. */
105
- output?: 'fmt' | 'chrome-json';
106
- /** Required for useful `chrome-json` output. Defaults to `.panda/trace.json`. */
107
- file?: string;
108
- }
109
- interface NativeCompilerOptions {
110
- crossFile?: boolean;
111
- }
112
- interface RawDesignSystemBinding {
113
- createDesignSystemManifest(input: DesignSystemManifestInput): DesignSystemManifest;
114
- designSystemManifestSchemaVersion(): number;
115
- resolveDesignSystemChain(manifests: DesignSystemManifest[]): DesignSystemChainPlan;
116
- }
117
- interface RawFileSystemBinding {
118
- readFile(path: string): string | null | undefined;
119
- exists(path: string): boolean;
120
- }
121
- interface RawPathBinding {
122
- realpath(path: string): string;
123
- resolvePath(path: string, cwd?: string): string;
124
- joinPath(parts: string[]): string;
125
- dirname(path: string): string;
126
- }
127
- /** The raw native instance — superset of {@link Compiler} carrying the internal
128
- * methods the facade hides. */
129
- interface RawCompiler extends Compiler, BuildInfoNative, RawDesignSystemBinding, RawFileSystemBinding, RawPathBinding {
130
- inspectFileSource(path: string, source: string): Omit<FileInspectionResult, 'path'>;
131
- token_dictionary?(): TokenDictionary | undefined;
132
- registerUtilityTransform?(id: string, callback: (resolved: unknown, original: unknown) => unknown): void;
133
- registerPatternTransform?(id: string, callback: (props: unknown, helpers: Record<string, unknown>) => unknown): void;
134
- registerSourceTransform?(id: string, filter: SerializedHookFilter | undefined, callback: (filePath: string, content: string) => string | undefined): void;
135
- }
136
- interface CompilerConstructor {
137
- fromConfig(config: SerializedConfig, options?: NativeCompilerOptions, utilityValuesCallbacks?: Record<string, (tokenDictionary: TokenDictionary | undefined) => unknown>): RawCompiler;
138
- }
139
- interface NativeBinding {
140
- startTracing?(options?: TraceOptions): boolean;
141
- flushTracing?(): void;
142
- shutdownTracing?(): boolean;
143
- compile(input?: CompileInput): CompileOutput;
144
- scanImports(path: string, source: string): ImportScanResult;
145
- matchImports(scan: ImportScanResult, matchers: Matchers): MatchedImport[];
146
- extractCalls(path: string, source: string, matched: MatchedImport[], matchers: Matchers): ExtractedCallsResult;
147
- extractJsx(path: string, source: string, matched: MatchedImport[], matchers: Matchers): ExtractedJsxResult;
148
- extract(path: string, source: string, matchers: Matchers): ExtractResult;
149
- extractDebug(path: string, source: string, matchers: Matchers): ExtractDebugResult;
150
- Extractor: ExtractorSessionConstructor;
151
- Compiler: CompilerConstructor;
152
- }
153
-
154
10
  interface NodeDriverOptions {
155
11
  cwd: string;
156
12
  /** Explicit config file (relative to `cwd`); otherwise discovered upward. */
157
13
  configPath?: string;
158
14
  /** Override the config's `include` globs (e.g. CLI `--include`). Empty/omitted keeps the config value. */
159
15
  include?: string[];
16
+ /** Record which config or preset defined each entry, for `spec()` provenance. */
17
+ trackSources?: boolean;
160
18
  }
161
19
  interface WriteDesignSystemLibOptions {
162
20
  outdir?: string;
@@ -164,6 +22,8 @@ interface WriteDesignSystemLibOptions {
164
22
  panda?: string;
165
23
  minify?: boolean;
166
24
  maxWarnings?: number | string;
25
+ /** An already-written spec file; recorded in lib.json relative to the manifest. */
26
+ spec?: string;
167
27
  }
168
28
  interface WriteDesignSystemLibResult {
169
29
  manifestPath: string;
@@ -182,20 +42,36 @@ declare class NodeDriver extends BaseDriver {
182
42
  #private;
183
43
  constructor(options: NodeDriverOptions, loaded: LoadConfigResult);
184
44
  get designSystemDiagnostics(): Diagnostic[];
45
+ protected configSources(): _pandacss_config.ConfigSources | undefined;
46
+ protected codegenOverlay(): CodegenOverlay | undefined;
185
47
  get config(): _pandacss_compiler_shared.SerializedConfig;
186
48
  get configPath(): string;
187
49
  get configDependencies(): string[];
188
50
  designSystemWatchTargets(): DesignSystemWatchTarget[];
189
51
  isDesignSystemFile(file: string): DesignSystemWatchFileKind | false;
52
+ private buildDesignSystemFileKinds;
190
53
  syncDesignSystemFileChange(change: SourceChange): Promise<boolean>;
191
54
  syncDesignSystemSources(): boolean[];
192
55
  reload(): Promise<DiffConfigResult>;
56
+ /** Re-hydrate when treeshake import set changes. */
57
+ syncDesignSystemTreeShake(): boolean;
58
+ protected prepareCssOutput(): void;
193
59
  applyChange(change: SourceChange): boolean;
60
+ private applySourceChange;
61
+ /** Known files always refresh; unknown project paths must match the source globs. */
62
+ private admitSourceChange;
63
+ private recordSourceChange;
194
64
  getOutdir(outdir?: string): string;
195
65
  writeDesignSystemLib(options?: WriteDesignSystemLibOptions): Promise<WriteDesignSystemLibResult>;
196
66
  codegen(options?: CodegenOptions): string[];
67
+ cssgen(options?: CompileOptions): CompileOutput;
68
+ writeCss(options: WriteCssOptions): WriteCssResult;
69
+ writeLayerCss(options: WriteLayerCssOptions): WriteCssResult;
70
+ writeSplitCss(options?: WriteSplitCssOptions): WriteSplitCssResult;
71
+ private runCssgenDone;
197
72
  private codegenWithPrepareHooks;
198
73
  isConfigFile(file: string): boolean;
74
+ private buildConfigFilePaths;
199
75
  private parseDesignSystemLib;
200
76
  private compileDesignSystemPreset;
201
77
  private writeDesignSystemLibArtifacts;
@@ -210,15 +86,17 @@ declare class NodeDriver extends BaseDriver {
210
86
  declare function compile(input?: CompileInput): CompileOutput;
211
87
  declare function startTracing(options?: TraceOptions): boolean;
212
88
  declare function flushTracing(): void;
89
+ /** Renders `timings.json` from spans collected so far. Call before `shutdownTracing`. */
90
+ declare function takeTimingsJson(): string | undefined;
213
91
  declare function shutdownTracing(): boolean;
214
- declare function createCompiler(config: SerializedConfig, options?: CompilerOptions): Compiler;
92
+ declare function createCompiler(config: SerializedConfig, options?: CompilerOptions): NativeCompiler;
215
93
  /**
216
94
  * Like {@link createCompiler}, but takes a snapshot; its callbacks merge under
217
95
  * any in `options.callbacks`.
218
96
  */
219
- declare function createCompilerFromSnapshot(snapshot: ConfigSnapshot, options?: CompilerOptions): Compiler;
97
+ declare function createCompilerFromSnapshot(snapshot: ConfigSnapshot, options?: CompilerOptions): NativeCompiler;
220
98
  declare function getBindingInfo(): {
221
99
  native: boolean;
222
100
  };
223
101
 
224
- 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, NodeDriver, type NodeDriverOptions, type RawCompiler, type TokenDictionary, type TraceOptions, type WriteDesignSystemLibOptions, type WriteDesignSystemLibResult, compile, createCompiler, createCompilerFromSnapshot, createNodeDriver, flushTracing, getBindingInfo, shutdownTracing, startTracing };
102
+ 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
@@ -8,8 +8,9 @@ import {
8
8
  flushTracing,
9
9
  getBindingInfo,
10
10
  shutdownTracing,
11
- startTracing
12
- } from "./chunk-QPHZ2RG2.js";
11
+ startTracing,
12
+ takeTimingsJson
13
+ } from "./chunk-CDATBPPB.js";
13
14
  export {
14
15
  NodeDriver,
15
16
  compile,
@@ -20,5 +21,6 @@ export {
20
21
  flushTracing,
21
22
  getBindingInfo,
22
23
  shutdownTracing,
23
- startTracing
24
+ startTracing,
25
+ takeTimingsJson
24
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-CxQirxMo.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-QPHZ2RG2.js";
3
+ } from "./chunk-CDATBPPB.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 };