@pandacss/compiler 2.0.0-beta.9 → 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/binding.cjs +199 -85
- package/dist/{chunk-G4RVGB4O.js → chunk-CDATBPPB.js} +436 -123
- package/dist/index.d.ts +20 -4
- package/dist/index.js +1 -1
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js +1 -1
- package/dist/tooling/index.d.ts +4 -1
- package/dist/tooling/index.js +252 -63
- package/dist/{types-DsStlLvF.d.ts → types-CxQirxMo.d.ts} +4 -7
- package/package.json +21 -17
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as _pandacss_compiler_shared from '@pandacss/compiler-shared';
|
|
2
|
-
import { BaseDriver, Diagnostic, DesignSystemWatchTarget, DesignSystemWatchFileKind, SourceChange, DiffConfigResult, CodegenOptions, CompileOptions, CompileOutput, WriteCssOptions, WriteCssResult, WriteLayerCssOptions, WriteSplitCssOptions,
|
|
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
4
|
export { NativeSourceTransformer, NativeTransformSourceInput, TransformSourceOptions, TransformSourceResult, createUsageReport } from '@pandacss/compiler-shared';
|
|
5
|
-
import { C as CompileInput, T as TraceOptions, N as NativeCompiler } from './types-
|
|
6
|
-
export {
|
|
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';
|
|
7
8
|
import { LoadConfigResult } from '@pandacss/config';
|
|
8
9
|
|
|
9
10
|
interface NodeDriverOptions {
|
|
@@ -12,6 +13,8 @@ interface NodeDriverOptions {
|
|
|
12
13
|
configPath?: string;
|
|
13
14
|
/** Override the config's `include` globs (e.g. CLI `--include`). Empty/omitted keeps the config value. */
|
|
14
15
|
include?: string[];
|
|
16
|
+
/** Record which config or preset defined each entry, for `spec()` provenance. */
|
|
17
|
+
trackSources?: boolean;
|
|
15
18
|
}
|
|
16
19
|
interface WriteDesignSystemLibOptions {
|
|
17
20
|
outdir?: string;
|
|
@@ -19,6 +22,8 @@ interface WriteDesignSystemLibOptions {
|
|
|
19
22
|
panda?: string;
|
|
20
23
|
minify?: boolean;
|
|
21
24
|
maxWarnings?: number | string;
|
|
25
|
+
/** An already-written spec file; recorded in lib.json relative to the manifest. */
|
|
26
|
+
spec?: string;
|
|
22
27
|
}
|
|
23
28
|
interface WriteDesignSystemLibResult {
|
|
24
29
|
manifestPath: string;
|
|
@@ -37,25 +42,36 @@ declare class NodeDriver extends BaseDriver {
|
|
|
37
42
|
#private;
|
|
38
43
|
constructor(options: NodeDriverOptions, loaded: LoadConfigResult);
|
|
39
44
|
get designSystemDiagnostics(): Diagnostic[];
|
|
45
|
+
protected configSources(): _pandacss_config.ConfigSources | undefined;
|
|
46
|
+
protected codegenOverlay(): CodegenOverlay | undefined;
|
|
40
47
|
get config(): _pandacss_compiler_shared.SerializedConfig;
|
|
41
48
|
get configPath(): string;
|
|
42
49
|
get configDependencies(): string[];
|
|
43
50
|
designSystemWatchTargets(): DesignSystemWatchTarget[];
|
|
44
51
|
isDesignSystemFile(file: string): DesignSystemWatchFileKind | false;
|
|
52
|
+
private buildDesignSystemFileKinds;
|
|
45
53
|
syncDesignSystemFileChange(change: SourceChange): Promise<boolean>;
|
|
46
54
|
syncDesignSystemSources(): boolean[];
|
|
47
55
|
reload(): Promise<DiffConfigResult>;
|
|
56
|
+
/** Re-hydrate when treeshake import set changes. */
|
|
57
|
+
syncDesignSystemTreeShake(): boolean;
|
|
58
|
+
protected prepareCssOutput(): void;
|
|
48
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;
|
|
49
64
|
getOutdir(outdir?: string): string;
|
|
50
65
|
writeDesignSystemLib(options?: WriteDesignSystemLibOptions): Promise<WriteDesignSystemLibResult>;
|
|
51
66
|
codegen(options?: CodegenOptions): string[];
|
|
52
67
|
cssgen(options?: CompileOptions): CompileOutput;
|
|
53
68
|
writeCss(options: WriteCssOptions): WriteCssResult;
|
|
54
69
|
writeLayerCss(options: WriteLayerCssOptions): WriteCssResult;
|
|
55
|
-
writeSplitCss(options?: WriteSplitCssOptions):
|
|
70
|
+
writeSplitCss(options?: WriteSplitCssOptions): WriteSplitCssResult;
|
|
56
71
|
private runCssgenDone;
|
|
57
72
|
private codegenWithPrepareHooks;
|
|
58
73
|
isConfigFile(file: string): boolean;
|
|
74
|
+
private buildConfigFilePaths;
|
|
59
75
|
private parseDesignSystemLib;
|
|
60
76
|
private compileDesignSystemPreset;
|
|
61
77
|
private writeDesignSystemLibArtifacts;
|
package/dist/index.js
CHANGED
package/dist/loader.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
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-
|
|
4
|
+
import { N as NativeCompiler } from './types-CxQirxMo.js';
|
|
5
5
|
|
|
6
6
|
interface LoadCompilerResult {
|
|
7
7
|
/** The compiler built from the loaded config snapshot. */
|
package/dist/loader.js
CHANGED
package/dist/tooling/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Compiler, Diagnostic, FileInspectionResult, Spec, Deprecation
|
|
1
|
+
import { Compiler, Diagnostic, FileInspectionResult, Spec, Deprecation } from '@pandacss/compiler-shared';
|
|
2
2
|
import { LoadConfigResult } from '@pandacss/config';
|
|
3
|
+
import { ImportMapOutput } from '@pandacss/types';
|
|
3
4
|
|
|
4
5
|
interface NativeCompiler extends Compiler {
|
|
5
6
|
}
|
|
@@ -16,6 +17,8 @@ interface Project {
|
|
|
16
17
|
outdir: string;
|
|
17
18
|
/** Non-fatal issues surfaced while hydrating a consumed design-system package. */
|
|
18
19
|
designSystemDiagnostics: Diagnostic[];
|
|
20
|
+
/** Treeshake import fingerprint (watch sync). */
|
|
21
|
+
designSystemTreeshakeKey?: string;
|
|
19
22
|
}
|
|
20
23
|
declare function createProjectFromLoadedConfig(loaded: LoadConfigResult): Project;
|
|
21
24
|
declare function createProjectFromConfig(key: ProjectKey): Promise<Project>;
|
package/dist/tooling/index.js
CHANGED
|
@@ -1,31 +1,139 @@
|
|
|
1
1
|
// src/tooling/create-project.ts
|
|
2
2
|
import { defaultConfig } from "@pandacss/compiler-shared";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
collectExportMissingDiagnostics,
|
|
5
|
+
collectNameCollisionDiagnostics,
|
|
6
|
+
loadConfig
|
|
7
|
+
} from "@pandacss/config";
|
|
4
8
|
|
|
5
9
|
// src/design-system.ts
|
|
6
10
|
import "@pandacss/compiler-shared";
|
|
7
|
-
import {
|
|
8
|
-
|
|
11
|
+
import {
|
|
12
|
+
collectArtifactConflicts,
|
|
13
|
+
readPandaVersion
|
|
14
|
+
} from "@pandacss/config";
|
|
15
|
+
function artifactConflictDiagnostics(metadata) {
|
|
16
|
+
return collectArtifactConflicts(metadata).flatMap((conflict) => [
|
|
17
|
+
...conflict.recipes.map((name) => artifactConflict("Recipe", name, conflict.name)),
|
|
18
|
+
...conflict.patterns.map((name) => artifactConflict("Pattern", name, conflict.name))
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
function artifactConflict(kind, name, designSystem) {
|
|
22
|
+
return {
|
|
23
|
+
code: "design_system_artifact_conflict",
|
|
24
|
+
severity: "warning",
|
|
25
|
+
category: "designSystem",
|
|
26
|
+
message: `${kind} ${JSON.stringify(name)} is defined by both ${JSON.stringify(designSystem)} and this config; your definition is merged over the design system's.`
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function hydrateDesignSystem(compiler, options) {
|
|
30
|
+
const { chain, consumerTokenPaths = [], treeshake, importSelections } = options;
|
|
9
31
|
if (!chain || chain.length === 0) {
|
|
10
|
-
return [];
|
|
32
|
+
return { diagnostics: [], treeshakeKey: "" };
|
|
11
33
|
}
|
|
12
34
|
const pandaVersion = readPandaVersion();
|
|
13
35
|
const diagnostics = [];
|
|
14
|
-
|
|
15
|
-
|
|
36
|
+
const appSelections = treeshake ? importSelections ?? collectImportSelections(compiler, chain) : void 0;
|
|
37
|
+
const selections = appSelections && withDependencyImports(compiler, chain, appSelections);
|
|
38
|
+
for (let i = 0; i < chain.length; i++) {
|
|
39
|
+
const ds = chain[i];
|
|
40
|
+
const imports = selections ? selections[i] ?? void 0 : void 0;
|
|
41
|
+
diagnostics.push(...hydrateLevel(compiler, ds, pandaVersion, consumerTokenPaths, imports));
|
|
16
42
|
}
|
|
17
|
-
return
|
|
43
|
+
return {
|
|
44
|
+
diagnostics,
|
|
45
|
+
treeshakeKey: treeshakeKeyFromSelections(chain, appSelections)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
var ALL_MODULES = { kind: "all" };
|
|
49
|
+
var NO_MODULES = { kind: "none" };
|
|
50
|
+
function withDependencyImports(compiler, chain, appSelections) {
|
|
51
|
+
const selections = appSelections.map(selectionFromScan);
|
|
52
|
+
for (let i = chain.length - 1; i > 0; i--) {
|
|
53
|
+
const selected = selections[i];
|
|
54
|
+
if (selected.kind === "none") continue;
|
|
55
|
+
const info = readBuildInfo(compiler, chain[i]);
|
|
56
|
+
for (let ancestorIndex = 0; ancestorIndex < i; ancestorIndex++) {
|
|
57
|
+
const imported = info ? compiler.designSystem.dependencyImports(info, selectionToImports(selected), chain[ancestorIndex].name) : void 0;
|
|
58
|
+
selections[ancestorIndex] = mergeSelection(selections[ancestorIndex], selectionFromImports(imported));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return selections.map(selectionToScan);
|
|
62
|
+
}
|
|
63
|
+
function selectionFromScan(selection) {
|
|
64
|
+
if (selection == null) return ALL_MODULES;
|
|
65
|
+
return selection.length === 0 ? NO_MODULES : { kind: "names", names: selection };
|
|
66
|
+
}
|
|
67
|
+
function selectionFromImports(imports) {
|
|
68
|
+
if (imports === void 0) return ALL_MODULES;
|
|
69
|
+
return imports.length === 0 ? NO_MODULES : { kind: "names", names: imports };
|
|
70
|
+
}
|
|
71
|
+
function selectionToImports(selection) {
|
|
72
|
+
if (selection.kind === "all") return void 0;
|
|
73
|
+
return selection.kind === "none" ? [] : selection.names;
|
|
74
|
+
}
|
|
75
|
+
function selectionToScan(selection) {
|
|
76
|
+
if (selection.kind === "all") return null;
|
|
77
|
+
return selection.kind === "none" ? [] : selection.names;
|
|
78
|
+
}
|
|
79
|
+
function mergeSelection(current, added) {
|
|
80
|
+
if (current.kind === "all" || added.kind === "all") return ALL_MODULES;
|
|
81
|
+
if (current.kind === "none") return added;
|
|
82
|
+
if (added.kind === "none") return current;
|
|
83
|
+
return { kind: "names", names: [.../* @__PURE__ */ new Set([...current.names, ...added.names])] };
|
|
84
|
+
}
|
|
85
|
+
function readBuildInfo(compiler, ds) {
|
|
86
|
+
if (ds.optionMismatch?.length) return void 0;
|
|
87
|
+
try {
|
|
88
|
+
const content = compiler.fs.readFile(ds.buildInfoPath);
|
|
89
|
+
if (content == null) return void 0;
|
|
90
|
+
const info = JSON.parse(content);
|
|
91
|
+
return compiler.buildInfo.validate(info).ok ? info : void 0;
|
|
92
|
+
} catch {
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function collectImportSelections(compiler, chain) {
|
|
97
|
+
return compiler.designSystemImportSelections(
|
|
98
|
+
chain.map((ds) => ({
|
|
99
|
+
packageRoots: getPackageRoots(ds),
|
|
100
|
+
excludeModules: getExcludedModules(ds)
|
|
101
|
+
}))
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
function treeshakeKeyFromSelections(chain, selections) {
|
|
105
|
+
if (!selections?.length) return "";
|
|
106
|
+
return chain.map((ds, i) => `${ds.name}:${JSON.stringify(selections[i] ?? null)}`).join("|");
|
|
107
|
+
}
|
|
108
|
+
var STYLED_SYSTEM_SUBPATHS = ["css", "recipes", "patterns", "jsx", "tokens"];
|
|
109
|
+
function getPackageRoots(ds) {
|
|
110
|
+
return [...new Set([ds.specifier, ds.name].filter((value) => Boolean(value)))];
|
|
111
|
+
}
|
|
112
|
+
function getExcludedModules(ds) {
|
|
113
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
114
|
+
for (const root of getPackageRoots(ds)) {
|
|
115
|
+
for (const sub of STYLED_SYSTEM_SUBPATHS) {
|
|
116
|
+
excluded.add(`${root}/${sub}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const map = ds.importMap;
|
|
120
|
+
if (map) {
|
|
121
|
+
for (const value of [map.css, map.recipes, map.patterns, map.jsx, map.tokens]) {
|
|
122
|
+
if (typeof value === "string" && value.length > 0) excluded.add(value);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return [...excluded];
|
|
18
126
|
}
|
|
19
|
-
function hydrateLevel(compiler, ds, pandaVersion, consumerTokenPaths) {
|
|
127
|
+
function hydrateLevel(compiler, ds, pandaVersion, consumerTokenPaths, imports) {
|
|
20
128
|
const compat = compiler.designSystem.validate(ds.manifest, { pandaVersion });
|
|
21
129
|
if (!compat.ok) {
|
|
22
130
|
throw incompatibleManifestError(compiler, ds, compat.reason, pandaVersion);
|
|
23
131
|
}
|
|
24
|
-
const diagnostics = hydrateArtifacts(compiler, ds, pandaVersion);
|
|
132
|
+
const diagnostics = hydrateArtifacts(compiler, ds, pandaVersion, imports);
|
|
25
133
|
diagnostics.push(...tokenConflictDiagnostics(ds, consumerTokenPaths));
|
|
26
134
|
return diagnostics;
|
|
27
135
|
}
|
|
28
|
-
function hydrateArtifacts(compiler, ds, pandaVersion) {
|
|
136
|
+
function hydrateArtifacts(compiler, ds, pandaVersion, imports) {
|
|
29
137
|
if (ds.optionMismatch && ds.optionMismatch.length > 0) {
|
|
30
138
|
const diagnostic = recoverFromSources(
|
|
31
139
|
compiler,
|
|
@@ -50,7 +158,11 @@ function hydrateArtifacts(compiler, ds, pandaVersion) {
|
|
|
50
158
|
);
|
|
51
159
|
return [diagnostic];
|
|
52
160
|
}
|
|
53
|
-
const result = compiler.designSystem.load(ds.manifest, {
|
|
161
|
+
const result = compiler.designSystem.load(ds.manifest, {
|
|
162
|
+
buildInfo,
|
|
163
|
+
pandaVersion,
|
|
164
|
+
...imports !== void 0 ? { imports } : {}
|
|
165
|
+
});
|
|
54
166
|
if (!result.ok) {
|
|
55
167
|
const issue = result.reason === "schemaVersion" ? {
|
|
56
168
|
kind: "schemaVersion",
|
|
@@ -80,7 +192,8 @@ function extractFallbackSources(compiler, ds) {
|
|
|
80
192
|
if (ds.files.length === 0) {
|
|
81
193
|
return [];
|
|
82
194
|
}
|
|
83
|
-
|
|
195
|
+
const filesCwd = compiler.path.resolve(compiler.path.join([compiler.path.dirname(ds.manifestPath), ".."]));
|
|
196
|
+
return compiler.scan({ include: ds.files, cwd: filesCwd });
|
|
84
197
|
}
|
|
85
198
|
function buildInfoDiagnostic(ds, issue, sourceCount, severity) {
|
|
86
199
|
const reason = buildInfoIssueMessage(issue);
|
|
@@ -91,7 +204,7 @@ function buildInfoDiagnostic(ds, issue, sourceCount, severity) {
|
|
|
91
204
|
category: "designSystem",
|
|
92
205
|
file: ds.buildInfoPath,
|
|
93
206
|
message: `${JSON.stringify(ds.name)} build info ${reason}.${outcome}`,
|
|
94
|
-
help: [`Run \`panda lib\` in ${JSON.stringify(ds.name)} to rebuild panda
|
|
207
|
+
help: [`Run \`panda lib\` in ${JSON.stringify(ds.name)} to rebuild panda/buildinfo.json.`]
|
|
95
208
|
};
|
|
96
209
|
}
|
|
97
210
|
function buildInfoIssueMessage(issue) {
|
|
@@ -143,7 +256,7 @@ function incompatibleManifestError(compiler, ds, reason, pandaVersion) {
|
|
|
143
256
|
severity: "error",
|
|
144
257
|
category: "designSystem",
|
|
145
258
|
file: ds.manifestPath,
|
|
146
|
-
message: `${JSON.stringify(ds.name)} panda
|
|
259
|
+
message: `${JSON.stringify(ds.name)} panda/lib.json uses schemaVersion ${ds.manifest.schemaVersion}; expected ${compiler.designSystem.schemaVersion}.`,
|
|
147
260
|
help: [`Upgrade ${JSON.stringify(ds.name)}, or rebuild it with a compatible version of Panda.`]
|
|
148
261
|
});
|
|
149
262
|
}
|
|
@@ -175,7 +288,6 @@ import {
|
|
|
175
288
|
assertProjectCallbacks,
|
|
176
289
|
BuildInfo as BuildInfo2,
|
|
177
290
|
DesignSystem as DesignSystem2,
|
|
178
|
-
getTokenCategoryValues,
|
|
179
291
|
inspectFile,
|
|
180
292
|
inspectFiles,
|
|
181
293
|
mergeCallbacks,
|
|
@@ -185,10 +297,10 @@ import {
|
|
|
185
297
|
|
|
186
298
|
// src/callbacks.ts
|
|
187
299
|
import {
|
|
188
|
-
|
|
189
|
-
createTransformArgs,
|
|
300
|
+
createTransformHelpers,
|
|
190
301
|
getPatternDefaultValueRefsByTransformId,
|
|
191
|
-
mergePatternDefaultValues
|
|
302
|
+
mergePatternDefaultValues,
|
|
303
|
+
PATTERN_HELPERS
|
|
192
304
|
} from "@pandacss/compiler-shared";
|
|
193
305
|
function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
194
306
|
const utilityTransforms = callbacks["utility.transform"];
|
|
@@ -198,6 +310,7 @@ function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
|
198
310
|
const config = project.config();
|
|
199
311
|
const patternDefaultValues = callbacks["pattern.defaultValues"];
|
|
200
312
|
const patternDefaultValueRefs = config && patternDefaultValues ? getPatternDefaultValueRefsByTransformId(config) : /* @__PURE__ */ new Map();
|
|
313
|
+
const { token, utils } = createTransformHelpers(tokenDictionary);
|
|
201
314
|
if (hasPatternTransforms && !project.registerPatternTransform) {
|
|
202
315
|
throw new Error("Native project does not support pattern.transform callbacks");
|
|
203
316
|
}
|
|
@@ -208,7 +321,7 @@ function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
|
208
321
|
project.registerPatternTransform(id, (props) => {
|
|
209
322
|
const input = props;
|
|
210
323
|
const nextProps = defaultValue ? mergePatternDefaultValues(defaultValue(input), input) : input;
|
|
211
|
-
return callback(nextProps,
|
|
324
|
+
return callback(nextProps, PATTERN_HELPERS);
|
|
212
325
|
});
|
|
213
326
|
}
|
|
214
327
|
}
|
|
@@ -218,7 +331,7 @@ function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
|
218
331
|
if (project.registerUtilityTransform && utilityTransforms) {
|
|
219
332
|
for (const [id, callback] of Object.entries(utilityTransforms)) {
|
|
220
333
|
project.registerUtilityTransform(id, (resolved, original) => {
|
|
221
|
-
return callback(resolved,
|
|
334
|
+
return callback(resolved, { raw: original, token, utils });
|
|
222
335
|
});
|
|
223
336
|
}
|
|
224
337
|
}
|
|
@@ -330,11 +443,17 @@ var FallbackCompiler = class _FallbackCompiler {
|
|
|
330
443
|
removeFile() {
|
|
331
444
|
return false;
|
|
332
445
|
}
|
|
446
|
+
affectedFiles() {
|
|
447
|
+
return [];
|
|
448
|
+
}
|
|
333
449
|
clear() {
|
|
334
450
|
}
|
|
335
451
|
scan() {
|
|
336
452
|
return [];
|
|
337
453
|
}
|
|
454
|
+
designSystemImportSelections() {
|
|
455
|
+
return [];
|
|
456
|
+
}
|
|
338
457
|
realpath(path) {
|
|
339
458
|
return path;
|
|
340
459
|
}
|
|
@@ -367,6 +486,9 @@ var FallbackCompiler = class _FallbackCompiler {
|
|
|
367
486
|
hasLayerDeclaration() {
|
|
368
487
|
return false;
|
|
369
488
|
}
|
|
489
|
+
stripLayerOrderStatements(css) {
|
|
490
|
+
return css;
|
|
491
|
+
}
|
|
370
492
|
spec() {
|
|
371
493
|
return {
|
|
372
494
|
conditions: { keys: [], breakpoints: [], containers: [] },
|
|
@@ -393,7 +515,7 @@ var FallbackCompiler = class _FallbackCompiler {
|
|
|
393
515
|
bailed: false,
|
|
394
516
|
diagnostics: [],
|
|
395
517
|
dependencies: [],
|
|
396
|
-
helper: { needsCx: false,
|
|
518
|
+
helper: { needsCx: false, needsAttachRecipe: false, needsMemoRecipe: false }
|
|
397
519
|
};
|
|
398
520
|
}
|
|
399
521
|
inspectFile(input) {
|
|
@@ -421,7 +543,7 @@ var FallbackCompiler = class _FallbackCompiler {
|
|
|
421
543
|
return emptyWriteCssResult(options.outfile);
|
|
422
544
|
}
|
|
423
545
|
writeSplitCss(options) {
|
|
424
|
-
return
|
|
546
|
+
return emptyWriteSplitCssResult(options.outdir ?? "");
|
|
425
547
|
}
|
|
426
548
|
isEmpty() {
|
|
427
549
|
return true;
|
|
@@ -456,8 +578,11 @@ var FallbackCompiler = class _FallbackCompiler {
|
|
|
456
578
|
getLayerCss(_options) {
|
|
457
579
|
return emptyCompileOutput();
|
|
458
580
|
}
|
|
581
|
+
getKeyframeCss(_options) {
|
|
582
|
+
return emptyCompileOutput();
|
|
583
|
+
}
|
|
459
584
|
getSplitCss(_options) {
|
|
460
|
-
return [];
|
|
585
|
+
return { files: [], diagnostics: [] };
|
|
461
586
|
}
|
|
462
587
|
buildInfo = fallbackBuildInfo;
|
|
463
588
|
designSystem = fallbackDesignSystem;
|
|
@@ -524,21 +649,20 @@ function emptyWriteCssResult(path) {
|
|
|
524
649
|
...emptyCompileOutput()
|
|
525
650
|
};
|
|
526
651
|
}
|
|
527
|
-
function
|
|
652
|
+
function emptyWriteSplitCssResult(root) {
|
|
528
653
|
return {
|
|
529
654
|
root,
|
|
530
655
|
paths: [],
|
|
531
|
-
files: []
|
|
656
|
+
files: [],
|
|
657
|
+
diagnostics: []
|
|
532
658
|
};
|
|
533
659
|
}
|
|
534
660
|
|
|
535
661
|
// src/load-binary.ts
|
|
536
|
-
import { execFileSync } from "child_process";
|
|
537
|
-
import { existsSync, mkdirSync, readFileSync, rmSync } from "fs";
|
|
538
|
-
import { createRequire } from "module";
|
|
539
|
-
import { dirname, join } from "path";
|
|
540
|
-
import { fileURLToPath } from "url";
|
|
541
|
-
var bindingUrl = new URL("../binding.cjs", import.meta.url);
|
|
662
|
+
import { execFileSync } from "node:child_process";
|
|
663
|
+
import { existsSync, mkdirSync, readFileSync, rmSync } from "node:fs";
|
|
664
|
+
import { createRequire } from "node:module";
|
|
665
|
+
import { dirname, join } from "node:path";
|
|
542
666
|
var webContainerWasiPackage = "@pandacss/compiler-wasm32-wasi";
|
|
543
667
|
function loadNativeBinding() {
|
|
544
668
|
const bindingPath = resolveBindingPath();
|
|
@@ -551,13 +675,21 @@ function loadNativeBinding() {
|
|
|
551
675
|
return loadWebContainerBinding(require2, bindingPath, error);
|
|
552
676
|
}
|
|
553
677
|
}
|
|
554
|
-
function resolveBindingPath() {
|
|
555
|
-
|
|
556
|
-
|
|
678
|
+
function resolveBindingPath(referrer = import.meta.url) {
|
|
679
|
+
const packageRoot = resolvePackageRoot(referrer);
|
|
680
|
+
if (packageRoot) {
|
|
681
|
+
const bindingPath = join(packageRoot, "binding.cjs");
|
|
557
682
|
if (existsSync(bindingPath)) return bindingPath;
|
|
558
683
|
}
|
|
559
684
|
return fallbackBindingPaths().find((path) => existsSync(path));
|
|
560
685
|
}
|
|
686
|
+
function resolvePackageRoot(referrer) {
|
|
687
|
+
try {
|
|
688
|
+
return dirname(createRequire(referrer).resolve("@pandacss/compiler/package.json"));
|
|
689
|
+
} catch {
|
|
690
|
+
return void 0;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
561
693
|
function fallbackBindingPaths() {
|
|
562
694
|
const cwd = process.cwd();
|
|
563
695
|
const paths = [join(cwd, "packages/compiler/binding.cjs")];
|
|
@@ -632,15 +764,27 @@ function createCompilerFromSnapshot(snapshot, options) {
|
|
|
632
764
|
const hooks = mergeHooks(snapshot.hooks, options?.hooks);
|
|
633
765
|
return build(snapshot.config, callbacks, { ...options, hooks });
|
|
634
766
|
}
|
|
767
|
+
function assertNativeBinding(callbacks, hooks) {
|
|
768
|
+
if (binding !== fallback) return;
|
|
769
|
+
const needed = ["pattern.transform", "utility.transform"].filter(
|
|
770
|
+
(key) => Object.keys(callbacks[key] ?? {}).length > 0
|
|
771
|
+
);
|
|
772
|
+
if (hooks?.["parser:before"]?.length) needed.push("parser:before");
|
|
773
|
+
if (needed.length === 0) return;
|
|
774
|
+
throw new Error(
|
|
775
|
+
`Could not load the native @pandacss/compiler binding for ${process.platform}-${process.arch}, which ${needed.join(", ")} callbacks require. Reinstall your dependencies to fetch the platform package, or open an issue if your platform is unsupported.`
|
|
776
|
+
);
|
|
777
|
+
}
|
|
635
778
|
function build(config, callbacks, options) {
|
|
636
779
|
assertProjectCallbacks(config, callbacks);
|
|
637
780
|
assertProjectHooks(options?.hooks, callbacks);
|
|
638
781
|
if (!nativeCompilerFromConfig) {
|
|
639
782
|
throw new Error("createCompiler is not available in this binding");
|
|
640
783
|
}
|
|
784
|
+
assertNativeBinding(callbacks, options?.hooks);
|
|
641
785
|
const prepared = prepareCompilerConfig(config);
|
|
642
786
|
const compiler = nativeCompilerFromConfig(prepared, toNativeOptions(options), createUtilityValuesCallbacks(callbacks));
|
|
643
|
-
registerCallbacks(compiler, callbacks, options?.hooks, compiler.
|
|
787
|
+
registerCallbacks(compiler, callbacks, options?.hooks, compiler.tokenDictionary?.());
|
|
644
788
|
attachFileSystem(compiler);
|
|
645
789
|
attachPathSystem(compiler);
|
|
646
790
|
attachBuildInfo(compiler);
|
|
@@ -725,32 +869,38 @@ function toNativeOptions(options) {
|
|
|
725
869
|
function createUtilityValuesCallbacks(callbacks) {
|
|
726
870
|
const utilityValues = callbacks["utility.values"];
|
|
727
871
|
if (!utilityValues || Object.keys(utilityValues).length === 0) return void 0;
|
|
728
|
-
return
|
|
729
|
-
Object.entries(utilityValues).map(([id, callback]) => [
|
|
730
|
-
id,
|
|
731
|
-
(tokenDictionary) => callback((category) => getTokenCategoryValues(category, tokenDictionary))
|
|
732
|
-
])
|
|
733
|
-
);
|
|
872
|
+
return utilityValues;
|
|
734
873
|
}
|
|
735
874
|
|
|
736
875
|
// src/tooling/create-project.ts
|
|
876
|
+
function treeshakeDesignSystemEnabled(config) {
|
|
877
|
+
const optimize = config.optimize;
|
|
878
|
+
return optimize?.treeshakeDesignSystem === true;
|
|
879
|
+
}
|
|
737
880
|
function createProjectFromLoadedConfig(loaded) {
|
|
738
881
|
const compiler = createCompilerFromSnapshot({
|
|
739
882
|
config: loaded.config,
|
|
740
883
|
callbacks: loaded.callbacks,
|
|
741
884
|
hooks: loaded.hooks
|
|
742
885
|
});
|
|
743
|
-
const
|
|
744
|
-
|
|
745
|
-
loaded.metadata?.
|
|
746
|
-
loaded.
|
|
747
|
-
);
|
|
886
|
+
const hydrated = hydrateDesignSystem(compiler, {
|
|
887
|
+
chain: loaded.metadata?.designSystem,
|
|
888
|
+
consumerTokenPaths: loaded.metadata?.userTokenPaths ?? [],
|
|
889
|
+
treeshake: treeshakeDesignSystemEnabled(loaded.config)
|
|
890
|
+
});
|
|
891
|
+
const designSystemDiagnostics = [
|
|
892
|
+
...hydrated.diagnostics,
|
|
893
|
+
...artifactConflictDiagnostics(loaded.metadata),
|
|
894
|
+
...collectExportMissingDiagnostics(loaded.metadata),
|
|
895
|
+
...collectNameCollisionDiagnostics(loaded.metadata)
|
|
896
|
+
];
|
|
748
897
|
return {
|
|
749
898
|
compiler,
|
|
750
899
|
configPath: loaded.path,
|
|
751
900
|
dependencies: loaded.dependencies,
|
|
752
901
|
outdir: loaded.config.outdir ?? defaultConfig.outdir,
|
|
753
|
-
designSystemDiagnostics
|
|
902
|
+
designSystemDiagnostics,
|
|
903
|
+
designSystemTreeshakeKey: hydrated.treeshakeKey
|
|
754
904
|
};
|
|
755
905
|
}
|
|
756
906
|
async function createProjectFromConfig(key) {
|
|
@@ -792,12 +942,16 @@ function sourceCacheKey(source) {
|
|
|
792
942
|
}
|
|
793
943
|
|
|
794
944
|
// src/tooling/registry.ts
|
|
795
|
-
import { watch } from "fs";
|
|
796
|
-
import { dirname as dirname2, join as join2 } from "path";
|
|
945
|
+
import { realpathSync, unwatchFile, watch, watchFile } from "node:fs";
|
|
946
|
+
import { dirname as dirname2, isAbsolute, join as join2, resolve } from "node:path";
|
|
797
947
|
import { findConfig } from "@pandacss/config";
|
|
948
|
+
var FILE_POLL_INTERVAL_MS = 1e3;
|
|
798
949
|
var ProjectRegistry = class {
|
|
799
950
|
#projects = /* @__PURE__ */ new Map();
|
|
800
951
|
#watchers = /* @__PURE__ */ new Map();
|
|
952
|
+
#watchedDirs = /* @__PURE__ */ new Map();
|
|
953
|
+
/** path → listener so `unwatchFile` doesn't clear other registries. */
|
|
954
|
+
#polledFiles = /* @__PURE__ */ new Map();
|
|
801
955
|
#createProject;
|
|
802
956
|
constructor(options = {}) {
|
|
803
957
|
this.#createProject = options.createProject ?? ((key) => createProjectFromConfig(key));
|
|
@@ -807,12 +961,12 @@ var ProjectRegistry = class {
|
|
|
807
961
|
const cacheKey = resolvedPath ?? syntheticKey(key);
|
|
808
962
|
const cached = this.#projects.get(cacheKey);
|
|
809
963
|
if (cached) return cached;
|
|
810
|
-
if (resolvedPath) this.#watch(cacheKey, [resolvedPath]);
|
|
964
|
+
if (resolvedPath) this.#watch(cacheKey, key.cwd, [resolvedPath]);
|
|
811
965
|
const project = this.#createProject(key);
|
|
812
966
|
project.then(
|
|
813
967
|
(resolved) => {
|
|
814
968
|
if (resolvedPath && this.#projects.get(cacheKey) === project) {
|
|
815
|
-
this.#watch(cacheKey, [resolvedPath, ...resolved.dependencies]);
|
|
969
|
+
this.#watch(cacheKey, key.cwd, [resolvedPath, ...resolved.dependencies]);
|
|
816
970
|
}
|
|
817
971
|
},
|
|
818
972
|
() => this.#evict(cacheKey)
|
|
@@ -820,49 +974,84 @@ var ProjectRegistry = class {
|
|
|
820
974
|
this.#projects.set(cacheKey, project);
|
|
821
975
|
return project;
|
|
822
976
|
}
|
|
823
|
-
// Coarse: wipes the whole cache regardless of which paths changed.
|
|
824
977
|
invalidate(_changedPaths = []) {
|
|
825
|
-
for (const
|
|
826
|
-
|
|
978
|
+
for (const cacheKey of [...this.#watchers.keys(), ...this.#polledFiles.keys()]) {
|
|
979
|
+
this.#closeWatchers(cacheKey);
|
|
827
980
|
}
|
|
828
981
|
this.#watchers.clear();
|
|
982
|
+
this.#watchedDirs.clear();
|
|
983
|
+
this.#polledFiles.clear();
|
|
829
984
|
this.#projects.clear();
|
|
830
985
|
}
|
|
831
|
-
//
|
|
832
|
-
|
|
833
|
-
#watch(cacheKey, paths) {
|
|
834
|
-
this.#closeWatchers(cacheKey);
|
|
986
|
+
// Dir watch + `watchFile` poll; deps are cwd-relative like the driver.
|
|
987
|
+
#watch(cacheKey, cwd, paths) {
|
|
835
988
|
const filesByDir = /* @__PURE__ */ new Map();
|
|
836
989
|
for (const path of new Set(paths)) {
|
|
837
|
-
const
|
|
990
|
+
const absolute = isAbsolute(path) ? path : resolve(cwd, path);
|
|
991
|
+
const normalized = canonicalPath(absolute);
|
|
992
|
+
const dir = dirname2(normalized);
|
|
838
993
|
if (!filesByDir.has(dir)) filesByDir.set(dir, /* @__PURE__ */ new Set());
|
|
839
|
-
filesByDir.get(dir)?.add(
|
|
994
|
+
filesByDir.get(dir)?.add(normalized);
|
|
840
995
|
}
|
|
841
|
-
const
|
|
996
|
+
const watched = this.#watchedDirs.get(cacheKey) ?? /* @__PURE__ */ new Map();
|
|
997
|
+
const watchers = this.#watchers.get(cacheKey) ?? [];
|
|
842
998
|
for (const [dir, filesInDir] of filesByDir) {
|
|
999
|
+
const existing = watched.get(dir);
|
|
1000
|
+
if (existing) {
|
|
1001
|
+
for (const file of filesInDir) {
|
|
1002
|
+
if (existing.has(file)) continue;
|
|
1003
|
+
existing.add(file);
|
|
1004
|
+
this.#pollFile(cacheKey, file);
|
|
1005
|
+
}
|
|
1006
|
+
continue;
|
|
1007
|
+
}
|
|
1008
|
+
const tracked = new Set(filesInDir);
|
|
843
1009
|
try {
|
|
844
1010
|
watchers.push(
|
|
845
1011
|
watch(dir, (_event, filename) => {
|
|
846
|
-
if (filename
|
|
1012
|
+
if (!filename || tracked.has(join2(dir, filename))) this.#evict(cacheKey);
|
|
847
1013
|
})
|
|
848
1014
|
);
|
|
1015
|
+
watched.set(dir, tracked);
|
|
849
1016
|
} catch {
|
|
850
1017
|
}
|
|
1018
|
+
for (const file of tracked) this.#pollFile(cacheKey, file);
|
|
851
1019
|
}
|
|
1020
|
+
this.#watchedDirs.set(cacheKey, watched);
|
|
852
1021
|
this.#watchers.set(cacheKey, watchers);
|
|
853
1022
|
}
|
|
1023
|
+
#pollFile(cacheKey, file) {
|
|
1024
|
+
const polled = this.#polledFiles.get(cacheKey) ?? /* @__PURE__ */ new Map();
|
|
1025
|
+
if (polled.has(file)) return;
|
|
1026
|
+
const listener = () => this.#evict(cacheKey);
|
|
1027
|
+
polled.set(file, listener);
|
|
1028
|
+
this.#polledFiles.set(cacheKey, polled);
|
|
1029
|
+
watchFile(file, { interval: FILE_POLL_INTERVAL_MS }, listener);
|
|
1030
|
+
}
|
|
854
1031
|
#closeWatchers(cacheKey) {
|
|
855
1032
|
for (const watcher of this.#watchers.get(cacheKey) ?? []) watcher.close();
|
|
1033
|
+
for (const [file, listener] of this.#polledFiles.get(cacheKey) ?? []) {
|
|
1034
|
+
unwatchFile(file, listener);
|
|
1035
|
+
}
|
|
1036
|
+
this.#polledFiles.delete(cacheKey);
|
|
856
1037
|
}
|
|
857
1038
|
#evict(cacheKey) {
|
|
858
1039
|
this.#closeWatchers(cacheKey);
|
|
859
1040
|
this.#watchers.delete(cacheKey);
|
|
1041
|
+
this.#watchedDirs.delete(cacheKey);
|
|
860
1042
|
this.#projects.delete(cacheKey);
|
|
861
1043
|
}
|
|
862
1044
|
};
|
|
1045
|
+
function canonicalPath(filepath) {
|
|
1046
|
+
try {
|
|
1047
|
+
return realpathSync(filepath);
|
|
1048
|
+
} catch {
|
|
1049
|
+
return filepath;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
863
1052
|
function resolveConfigPath(key) {
|
|
864
1053
|
try {
|
|
865
|
-
return findConfig({ cwd: key.cwd, file: key.configPath });
|
|
1054
|
+
return canonicalPath(findConfig({ cwd: key.cwd, file: key.configPath }));
|
|
866
1055
|
} catch {
|
|
867
1056
|
return void 0;
|
|
868
1057
|
}
|