@pandacss/compiler 2.0.0-beta.7 → 2.0.0-beta.9

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,156 +1,11 @@
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, DesignSystemWatchTarget, DesignSystemWatchFileKind, SourceChange, DiffConfigResult, CodegenOptions, CompileOptions, CompileOutput, WriteCssOptions, WriteCssResult, WriteLayerCssOptions, WriteSplitCssOptions, WriteFilesResult, 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-DsStlLvF.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-DsStlLvF.js';
5
7
  import { LoadConfigResult } from '@pandacss/config';
6
8
 
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
9
  interface NodeDriverOptions {
155
10
  cwd: string;
156
11
  /** Explicit config file (relative to `cwd`); otherwise discovered upward. */
@@ -188,11 +43,17 @@ declare class NodeDriver extends BaseDriver {
188
43
  designSystemWatchTargets(): DesignSystemWatchTarget[];
189
44
  isDesignSystemFile(file: string): DesignSystemWatchFileKind | false;
190
45
  syncDesignSystemFileChange(change: SourceChange): Promise<boolean>;
46
+ syncDesignSystemSources(): boolean[];
191
47
  reload(): Promise<DiffConfigResult>;
192
48
  applyChange(change: SourceChange): boolean;
193
49
  getOutdir(outdir?: string): string;
194
50
  writeDesignSystemLib(options?: WriteDesignSystemLibOptions): Promise<WriteDesignSystemLibResult>;
195
51
  codegen(options?: CodegenOptions): string[];
52
+ cssgen(options?: CompileOptions): CompileOutput;
53
+ writeCss(options: WriteCssOptions): WriteCssResult;
54
+ writeLayerCss(options: WriteLayerCssOptions): WriteCssResult;
55
+ writeSplitCss(options?: WriteSplitCssOptions): WriteFilesResult;
56
+ private runCssgenDone;
196
57
  private codegenWithPrepareHooks;
197
58
  isConfigFile(file: string): boolean;
198
59
  private parseDesignSystemLib;
@@ -209,15 +70,17 @@ declare class NodeDriver extends BaseDriver {
209
70
  declare function compile(input?: CompileInput): CompileOutput;
210
71
  declare function startTracing(options?: TraceOptions): boolean;
211
72
  declare function flushTracing(): void;
73
+ /** Renders `timings.json` from spans collected so far. Call before `shutdownTracing`. */
74
+ declare function takeTimingsJson(): string | undefined;
212
75
  declare function shutdownTracing(): boolean;
213
- declare function createCompiler(config: SerializedConfig, options?: CompilerOptions): Compiler;
76
+ declare function createCompiler(config: SerializedConfig, options?: CompilerOptions): NativeCompiler;
214
77
  /**
215
78
  * Like {@link createCompiler}, but takes a snapshot; its callbacks merge under
216
79
  * any in `options.callbacks`.
217
80
  */
218
- declare function createCompilerFromSnapshot(snapshot: ConfigSnapshot, options?: CompilerOptions): Compiler;
81
+ declare function createCompilerFromSnapshot(snapshot: ConfigSnapshot, options?: CompilerOptions): NativeCompiler;
219
82
  declare function getBindingInfo(): {
220
83
  native: boolean;
221
84
  };
222
85
 
223
- 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 };
86
+ 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-VRB2SXJJ.js";
11
+ startTracing,
12
+ takeTimingsJson
13
+ } from "./chunk-G4RVGB4O.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-DsStlLvF.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-VRB2SXJJ.js";
3
+ } from "./chunk-G4RVGB4O.js";
4
4
 
5
5
  // src/loader.ts
6
6
  import { loadConfig } from "@pandacss/config";
@@ -0,0 +1,105 @@
1
+ import { Compiler, Diagnostic, FileInspectionResult, Spec, Deprecation, ImportMapOutput } from '@pandacss/compiler-shared';
2
+ import { LoadConfigResult } from '@pandacss/config';
3
+
4
+ interface NativeCompiler extends Compiler {
5
+ }
6
+
7
+ interface ProjectKey {
8
+ cwd: string;
9
+ /** Explicit config file (relative to `cwd`); otherwise discovered upward. */
10
+ configPath?: string;
11
+ }
12
+ interface Project {
13
+ compiler: NativeCompiler;
14
+ configPath: string;
15
+ dependencies: string[];
16
+ outdir: string;
17
+ /** Non-fatal issues surfaced while hydrating a consumed design-system package. */
18
+ designSystemDiagnostics: Diagnostic[];
19
+ }
20
+ declare function createProjectFromLoadedConfig(loaded: LoadConfigResult): Project;
21
+ declare function createProjectFromConfig(key: ProjectKey): Promise<Project>;
22
+
23
+ interface FileInspectionCacheEntry {
24
+ sourceKey: string;
25
+ result: FileInspectionResult;
26
+ }
27
+ /** Caches `compiler.inspectFile()` results per `(compiler, path)`, invalidated by source content. */
28
+ declare class FileInspector {
29
+ #private;
30
+ inspect(compiler: Compiler, path: string, source: string): FileInspectionResult;
31
+ clear(compiler?: Compiler): void;
32
+ }
33
+ declare function sourceCacheKey(source: string): string;
34
+
35
+ interface ProjectRegistryOptions {
36
+ createProject?: (key: ProjectKey) => Promise<Project>;
37
+ }
38
+ declare class ProjectRegistry {
39
+ #private;
40
+ constructor(options?: ProjectRegistryOptions);
41
+ getProject(key: ProjectKey): Promise<Project>;
42
+ invalidate(_changedPaths?: string[]): void;
43
+ }
44
+
45
+ declare class SpecIndex {
46
+ #private;
47
+ readonly spec: Spec;
48
+ constructor(spec: Spec);
49
+ resolveTokenValue(path: string): string | undefined;
50
+ resolveTokenPaths(prefix?: string): string[];
51
+ resolveTokenDeprecation(path: string): Deprecation | undefined;
52
+ hasCondition(name: string): boolean;
53
+ /** Bare style-object keys: named/custom conditions plus breakpoints (`sm`, `md`, ...). */
54
+ resolveStyleObjectKeys(): string[];
55
+ resolveTokenCategoryForProperty(property: string): string | undefined;
56
+ resolveLiteralsForProperty(property: string): string[] | undefined;
57
+ resolveKeyframeNames(prefix?: string): string[];
58
+ /** Token category names actually present in this config (`colors`, `spacing`, ...). */
59
+ resolveTokenCategories(prefix?: string): string[];
60
+ }
61
+
62
+ interface ConfigTokenRefSpan {
63
+ start: number;
64
+ end: number;
65
+ pathStart: number;
66
+ pathEnd: number;
67
+ path: string;
68
+ }
69
+ declare function findConfigTokenRefs(text: string): ConfigTokenRefSpan[];
70
+ declare function findConfigTokenRefAt(text: string, position: number): ConfigTokenRefSpan | undefined;
71
+ declare function completeConfigTokenPath(prefix: string, index: SpecIndex): string[];
72
+
73
+ type StyleObjectCursorKind = 'key' | 'value';
74
+ interface StyleObjectContext {
75
+ existingKeys: string[];
76
+ cursorKind: StyleObjectCursorKind;
77
+ /**
78
+ * Style-object-relative key chain leading to the cursor (see typescript-plugin's
79
+ * `getStyleObjectCursorInfo`) — e.g. `['color']`, or `['backgroundColor', 'sm']` for a
80
+ * utility's own inline conditional value (`backgroundColor: { sm: 're' }`).
81
+ */
82
+ propertyPath: string[];
83
+ prefix: string;
84
+ }
85
+ type CompletionEntryKind = 'utility' | 'condition' | 'token' | 'keyframe' | 'literal' | 'keyword' | 'category';
86
+ interface CompletionEntry {
87
+ name: string;
88
+ kind: CompletionEntryKind;
89
+ }
90
+ declare function completeConfigStyleObject(context: StyleObjectContext, index: SpecIndex): CompletionEntry[];
91
+
92
+ type SemanticTokenCursorKind = 'category' | 'condition';
93
+ interface SemanticTokenContext {
94
+ cursorKind: SemanticTokenCursorKind;
95
+ existingKeys: string[];
96
+ prefix: string;
97
+ }
98
+ declare function completeSemanticTokenObject(context: SemanticTokenContext, index: SpecIndex): CompletionEntry[];
99
+
100
+ interface ResolveModuleTargetOptions {
101
+ outdir: string;
102
+ }
103
+ declare function resolveModuleTarget(specifier: string, importMap: ImportMapOutput, options: ResolveModuleTargetOptions): string | undefined;
104
+
105
+ 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 };