@pandacss/compiler 2.0.0-beta.2 → 2.0.0-beta.20

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,102 @@
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-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';
8
+ import { LoadConfigResult } from '@pandacss/config';
134
9
 
135
10
  interface NodeDriverOptions {
136
11
  cwd: string;
137
12
  /** Explicit config file (relative to `cwd`); otherwise discovered upward. */
138
13
  configPath?: string;
14
+ /** Override the config's `include` globs (e.g. CLI `--include`). Empty/omitted keeps the config value. */
15
+ include?: string[];
16
+ /** Record which config or preset defined each entry, for `spec()` provenance. */
17
+ trackSources?: boolean;
18
+ }
19
+ interface WriteDesignSystemLibOptions {
20
+ outdir?: string;
21
+ files?: string[];
22
+ panda?: string;
23
+ minify?: boolean;
24
+ maxWarnings?: number | string;
25
+ /** An already-written spec file; recorded in lib.json relative to the manifest. */
26
+ spec?: string;
27
+ }
28
+ interface WriteDesignSystemLibResult {
29
+ manifestPath: string;
30
+ buildInfoPath: string;
31
+ presetPath: string;
32
+ exportsChanged: boolean;
33
+ parsedFileCount: number;
34
+ diagnostics: Diagnostic[];
139
35
  }
140
36
  /**
141
37
  * {@link Driver} backed by the native compiler (`OsFileSystem`). Loads the
142
38
  * config from disk; `scan` / `codegen` run through the Rust fs engine.
143
39
  */
144
- declare function createNodeDriver(options: NodeDriverOptions): Promise<Driver>;
40
+ declare function createNodeDriver(options: NodeDriverOptions): Promise<NodeDriver>;
41
+ declare class NodeDriver extends BaseDriver {
42
+ #private;
43
+ constructor(options: NodeDriverOptions, loaded: LoadConfigResult);
44
+ get designSystemDiagnostics(): Diagnostic[];
45
+ protected configSources(): _pandacss_config.ConfigSources | undefined;
46
+ protected codegenOverlay(): CodegenOverlay | undefined;
47
+ get config(): _pandacss_compiler_shared.SerializedConfig;
48
+ get configPath(): string;
49
+ get configDependencies(): string[];
50
+ designSystemWatchTargets(): DesignSystemWatchTarget[];
51
+ isDesignSystemFile(file: string): DesignSystemWatchFileKind | false;
52
+ private buildDesignSystemFileKinds;
53
+ syncDesignSystemFileChange(change: SourceChange): Promise<boolean>;
54
+ syncDesignSystemSources(): boolean[];
55
+ reload(): Promise<DiffConfigResult>;
56
+ /** Re-hydrate when treeshake import set changes. */
57
+ syncDesignSystemTreeShake(): boolean;
58
+ protected prepareCssOutput(): void;
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;
64
+ getOutdir(outdir?: string): string;
65
+ writeDesignSystemLib(options?: WriteDesignSystemLibOptions): Promise<WriteDesignSystemLibResult>;
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;
72
+ private codegenWithPrepareHooks;
73
+ isConfigFile(file: string): boolean;
74
+ private buildConfigFilePaths;
75
+ private parseDesignSystemLib;
76
+ private compileDesignSystemPreset;
77
+ private writeDesignSystemLibArtifacts;
78
+ }
145
79
 
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. */
80
+ /**
81
+ * One-shot stateless compile: build a compiler from `config`, parse every
82
+ * input file, and emit the stylesheet. Callback-bearing configs
83
+ * (`utilities.*.transform`, `patterns.*.transform`) are *not* supported here -
84
+ * use [`createCompiler`] + `options.callbacks` for those.
85
+ */
150
86
  declare function compile(input?: CompileInput): CompileOutput;
151
87
  declare function startTracing(options?: TraceOptions): boolean;
152
88
  declare function flushTracing(): void;
89
+ /** Renders `timings.json` from spans collected so far. Call before `shutdownTracing`. */
90
+ declare function takeTimingsJson(): string | undefined;
153
91
  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;
92
+ declare function createCompiler(config: SerializedConfig, options?: CompilerOptions): NativeCompiler;
93
+ /**
94
+ * Like {@link createCompiler}, but takes a snapshot; its callbacks merge under
95
+ * any in `options.callbacks`.
96
+ */
97
+ declare function createCompilerFromSnapshot(snapshot: ConfigSnapshot, options?: CompilerOptions): NativeCompiler;
158
98
  declare function getBindingInfo(): {
159
99
  native: boolean;
160
100
  };
161
101
 
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 };
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
@@ -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-NMSLTU6L.js";
11
+ startTracing,
12
+ takeTimingsJson
13
+ } from "./chunk-CDATBPPB.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-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-NMSLTU6L.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 };