@pandacss/compiler-wasm 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/{chunk-5E5JPQ3B.js → chunk-ZARW4JPN.js} +9 -15
- package/dist/index.d.ts +13 -13
- package/dist/index.js +10 -3
- package/dist/{web-2ZQDOLGS.js → web-JSAD2QZX.js} +1 -1
- package/dist/web.d.ts +13 -13
- package/dist/web.js +9 -15
- package/package.json +5 -3
- package/pkg-node/compiler_wasm.d.ts +33 -26
- package/pkg-node/compiler_wasm.js +180 -52
- package/pkg-node/compiler_wasm_bg.wasm +0 -0
- package/pkg-node/compiler_wasm_bg.wasm.d.ts +9 -3
- package/pkg-web/compiler_wasm.d.ts +42 -29
- package/pkg-web/compiler_wasm.js +180 -52
- package/pkg-web/compiler_wasm_bg.wasm +0 -0
- package/pkg-web/compiler_wasm_bg.wasm.d.ts +9 -3
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
BuildInfo,
|
|
6
6
|
DesignSystem,
|
|
7
7
|
createUsageReport,
|
|
8
|
-
getTokenCategoryValues,
|
|
9
8
|
inspectFile,
|
|
10
9
|
inspectFiles,
|
|
11
10
|
mergeCallbacks,
|
|
@@ -14,12 +13,13 @@ import {
|
|
|
14
13
|
|
|
15
14
|
// src/callbacks.ts
|
|
16
15
|
import {
|
|
17
|
-
|
|
18
|
-
createTransformArgs,
|
|
16
|
+
createTransformHelpers,
|
|
19
17
|
getPatternDefaultValueRefsByTransformId,
|
|
20
|
-
mergePatternDefaultValues
|
|
18
|
+
mergePatternDefaultValues,
|
|
19
|
+
PATTERN_HELPERS
|
|
21
20
|
} from "@pandacss/compiler-shared";
|
|
22
21
|
function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
22
|
+
const { token, utils } = createTransformHelpers(tokenDictionary);
|
|
23
23
|
const utilityTransforms = callbacks["utility.transform"];
|
|
24
24
|
if (utilityTransforms && Object.keys(utilityTransforms).length > 0 && !project.registerUtilityTransform) {
|
|
25
25
|
throw new Error("WASM project does not support utility.transform callbacks");
|
|
@@ -27,7 +27,7 @@ function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
|
27
27
|
if (project.registerUtilityTransform && utilityTransforms && Object.keys(utilityTransforms).length > 0) {
|
|
28
28
|
for (const [id, callback] of Object.entries(utilityTransforms)) {
|
|
29
29
|
project.registerUtilityTransform(id, (resolved, original) => {
|
|
30
|
-
return callback(resolved,
|
|
30
|
+
return callback(resolved, { raw: original, token, utils });
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -45,7 +45,7 @@ function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
|
45
45
|
project.registerPatternTransform(id, (props) => {
|
|
46
46
|
const input = props;
|
|
47
47
|
const nextProps = defaultValue ? mergePatternDefaultValues(defaultValue(input), input) : input;
|
|
48
|
-
return callback(nextProps,
|
|
48
|
+
return callback(nextProps, PATTERN_HELPERS);
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -81,7 +81,7 @@ function build(mod, config, callbacks, hooks) {
|
|
|
81
81
|
assertProjectHooks(hooks, callbacks);
|
|
82
82
|
const prepared = prepareCompilerConfig(config);
|
|
83
83
|
const compiler = mod.WasmCompiler.fromConfig(fs, prepared, buildFromConfigOptions(callbacks));
|
|
84
|
-
registerCallbacks(compiler, callbacks, hooks, compiler.
|
|
84
|
+
registerCallbacks(compiler, callbacks, hooks, compiler.tokenDictionary?.());
|
|
85
85
|
Object.defineProperty(compiler, "fs", { value: fs, enumerable: false });
|
|
86
86
|
Object.defineProperty(compiler, "path", { value: wasmPathSystem(compiler), enumerable: false });
|
|
87
87
|
const buildInfo = new BuildInfo(compiler);
|
|
@@ -112,8 +112,7 @@ function wasmPathSystem(compiler) {
|
|
|
112
112
|
function toDesignSystemBinding(compiler) {
|
|
113
113
|
return {
|
|
114
114
|
createManifest: (input) => compiler.createDesignSystemManifest(input),
|
|
115
|
-
manifestSchemaVersion: () => compiler.designSystemManifestSchemaVersion()
|
|
116
|
-
resolveChain: (manifests) => compiler.resolveDesignSystemChain(manifests)
|
|
115
|
+
manifestSchemaVersion: () => compiler.designSystemManifestSchemaVersion()
|
|
117
116
|
};
|
|
118
117
|
}
|
|
119
118
|
function buildFromConfigOptions(callbacks) {
|
|
@@ -121,12 +120,7 @@ function buildFromConfigOptions(callbacks) {
|
|
|
121
120
|
if (!utilityValues || Object.keys(utilityValues).length === 0) return void 0;
|
|
122
121
|
return {
|
|
123
122
|
configCallbacks: {
|
|
124
|
-
utilityValues
|
|
125
|
-
Object.entries(utilityValues).map(([id, callback]) => [
|
|
126
|
-
id,
|
|
127
|
-
(tokenDictionary) => callback((category) => getTokenCategoryValues(category, tokenDictionary))
|
|
128
|
-
])
|
|
129
|
-
)
|
|
123
|
+
utilityValues
|
|
130
124
|
}
|
|
131
125
|
};
|
|
132
126
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ParseFileReport, ScanOptions, LayerNames, Spec, SourceEntry, FileInspectionResult, ResolveUtilityValueInput, ResolvedUtilityValue, TokenSuggestion, WriteArtifactsOptions, WriteCssOptions, WriteCssResult, WriteLayerCssOptions, WriteSplitCssOptions,
|
|
1
|
+
import { ParseFileReport, ScanOptions, LayerNames, Spec, SourceEntry, FileInspectionResult, ResolveUtilityValueInput, ResolvedUtilityValue, TokenSuggestion, WriteArtifactsOptions, WriteCssOptions, WriteCssResult, WriteLayerCssOptions, WriteSplitCssOptions, WriteSplitCssResult, SerializedHookFilter, Atom, RecipeEntry, EncodedRecipeStyles, ProjectSummary, CompileOptions, CompileOutput, LayerCssOptions, SplitCssOptions, SplitCssResult, GenerateArtifactOptions, CodegenArtifact, CodegenArtifactId, CodegenDependency, Diagnostic, CompileFileManifest, ParsedFileView, StaticPatternResult, BuildInfoDesignSystemDependency, BuildInfoArtifact, DesignSystemManifestInput, DesignSystemManifest, SerializedConfig, UtilityValuesCallback, CompilerOptions, Compiler, ProjectCallbacks, ProjectHooks, ConfigSnapshot, Driver } from '@pandacss/compiler-shared';
|
|
2
2
|
export * from '@pandacss/compiler-shared';
|
|
3
|
-
export {
|
|
3
|
+
export { createUsageReport, mergeCallbacks } from '@pandacss/compiler-shared';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* TS-facing types that mirror the wasm-bindgen generated interfaces.
|
|
@@ -29,8 +29,7 @@ interface TokenDictionaryInput {
|
|
|
29
29
|
/** `path → CSS var form` (e.g. `colors.red.500 → var(--colors-red-500)`). */
|
|
30
30
|
vars: Record<string, string>;
|
|
31
31
|
}
|
|
32
|
-
type JsxFramework = 'react' | 'solid' | 'preact' | 'vue' |
|
|
33
|
-
type CssSyntax = 'template-literal' | 'object-literal';
|
|
32
|
+
type JsxFramework = 'react' | 'solid' | 'preact' | 'vue' | (string & {});
|
|
34
33
|
interface MatchersInput {
|
|
35
34
|
css?: MatcherInput;
|
|
36
35
|
recipe?: MatcherInput;
|
|
@@ -41,8 +40,6 @@ interface MatchersInput {
|
|
|
41
40
|
jsxFramework?: JsxFramework;
|
|
42
41
|
/** Defaults to `["styled"]` when omitted. */
|
|
43
42
|
jsxFactories?: string[];
|
|
44
|
-
/** CSS authoring syntax preference. Omit for object-literal mode. */
|
|
45
|
-
syntax?: CssSyntax;
|
|
46
43
|
/** Enable `token('…')` folding by passing a resolved dictionary. */
|
|
47
44
|
tokenDictionary?: TokenDictionaryInput;
|
|
48
45
|
}
|
|
@@ -74,6 +71,7 @@ declare class WasmCompiler {
|
|
|
74
71
|
refreshFile(path: string): boolean;
|
|
75
72
|
refreshFileSource(path: string, source: string): boolean;
|
|
76
73
|
removeFile(path: string): boolean;
|
|
74
|
+
affectedFiles(): string[];
|
|
77
75
|
clear(): void;
|
|
78
76
|
scan(options?: ScanOptions): string[];
|
|
79
77
|
realpath(path: string): string;
|
|
@@ -84,15 +82,17 @@ declare class WasmCompiler {
|
|
|
84
82
|
parseFiles(paths: string[]): ParseFileReport[];
|
|
85
83
|
layers(): LayerNames;
|
|
86
84
|
hasLayerDeclaration(css: string): boolean;
|
|
85
|
+
stripLayerOrderStatements(css: string): string;
|
|
87
86
|
spec(): Spec;
|
|
88
87
|
sources(): SourceEntry[];
|
|
89
88
|
inspectFileSource(path: string, source: string): Omit<FileInspectionResult, 'path'>;
|
|
90
89
|
resolveUtilityValue(input: ResolveUtilityValueInput): ResolvedUtilityValue | null;
|
|
91
90
|
suggestTokens(prop: string, value: string): TokenSuggestion[];
|
|
91
|
+
suggestSemanticTokens(path: string): TokenSuggestion[];
|
|
92
92
|
writeArtifacts(options: WriteArtifactsOptions): string[];
|
|
93
93
|
writeCss(options: WriteCssOptions): WriteCssResult;
|
|
94
94
|
writeLayerCss(options: WriteLayerCssOptions): WriteCssResult;
|
|
95
|
-
writeSplitCss(options: WriteSplitCssOptions):
|
|
95
|
+
writeSplitCss(options: WriteSplitCssOptions): WriteSplitCssResult;
|
|
96
96
|
isEmpty(): boolean;
|
|
97
97
|
registerUtilityTransform?(id: string, callback: (resolved: unknown, original: unknown) => unknown): void;
|
|
98
98
|
registerPatternTransform?(id: string, callback: (props: unknown, helpers: Record<string, unknown>) => unknown): void;
|
|
@@ -104,7 +104,8 @@ declare class WasmCompiler {
|
|
|
104
104
|
summary(): ProjectSummary;
|
|
105
105
|
compile(options?: CompileOptions): CompileOutput;
|
|
106
106
|
getLayerCss(options: LayerCssOptions): CompileOutput;
|
|
107
|
-
|
|
107
|
+
getKeyframeCss(options?: CompileOptions): CompileOutput;
|
|
108
|
+
getSplitCss(options?: SplitCssOptions): SplitCssResult;
|
|
108
109
|
generateArtifacts(options?: GenerateArtifactOptions): CodegenArtifact[];
|
|
109
110
|
generateArtifact(id: CodegenArtifactId, options?: GenerateArtifactOptions): CodegenArtifact | undefined;
|
|
110
111
|
generateAffectedArtifacts(dependencies: CodegenDependency[], options?: GenerateArtifactOptions): CodegenArtifact[];
|
|
@@ -113,13 +114,12 @@ declare class WasmCompiler {
|
|
|
113
114
|
/** Per-file view, or `null` when `path` isn't known. */
|
|
114
115
|
getFile(path: string): ParsedFileView | null;
|
|
115
116
|
staticPatternAtoms(): StaticPatternResult;
|
|
116
|
-
serializeBuildInfo(panda: string): BuildInfoArtifact;
|
|
117
|
+
serializeBuildInfo(panda: string, designSystemDependencies?: BuildInfoDesignSystemDependency[]): BuildInfoArtifact;
|
|
117
118
|
applyBuildInfo(name: string, buildInfo: BuildInfoArtifact, only?: string[]): boolean;
|
|
118
119
|
buildInfoSchemaVersion(): number;
|
|
119
120
|
configFingerprint(): string;
|
|
120
121
|
createDesignSystemManifest(input: DesignSystemManifestInput): DesignSystemManifest;
|
|
121
122
|
designSystemManifestSchemaVersion(): number;
|
|
122
|
-
resolveDesignSystemChain(manifests: DesignSystemManifest[]): DesignSystemChainPlan;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
/**
|
|
@@ -146,15 +146,15 @@ declare class WasmCompiler {
|
|
|
146
146
|
*/
|
|
147
147
|
interface WasmFromConfigOptions {
|
|
148
148
|
configCallbacks?: {
|
|
149
|
-
utilityValues?: Record<string,
|
|
149
|
+
utilityValues?: Record<string, UtilityValuesCallback>;
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* The raw wasm instance - superset of {@link Compiler} carrying the internal
|
|
154
|
-
* `
|
|
154
|
+
* `tokenDictionary` the facade hides.
|
|
155
155
|
*/
|
|
156
156
|
interface RawWasmCompiler extends WasmCompiler {
|
|
157
|
-
|
|
157
|
+
tokenDictionary?(): TokenDictionaryInput | undefined;
|
|
158
158
|
}
|
|
159
159
|
interface WasmModule {
|
|
160
160
|
WasmFileSystem: new () => WasmFileSystem;
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
createCompilerFromWasmModule,
|
|
5
5
|
createUsageReport,
|
|
6
6
|
mergeCallbacks
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZARW4JPN.js";
|
|
8
8
|
|
|
9
9
|
// src/index.ts
|
|
10
|
-
import { createRequire } from "module";
|
|
10
|
+
import { createRequire } from "node:module";
|
|
11
11
|
import { mergeCallbacks as mergeCallbacks2, mergeHooks } from "@pandacss/compiler-shared";
|
|
12
12
|
|
|
13
13
|
// src/driver.ts
|
|
@@ -47,12 +47,19 @@ var BrowserDriver = class extends BaseDriver {
|
|
|
47
47
|
return NO_CHANGE;
|
|
48
48
|
}
|
|
49
49
|
applyChange(change) {
|
|
50
|
+
const changed = this.trackSourceChange(change, this.#applySourceChange(change));
|
|
51
|
+
const refreshed = this.refreshAffectedFiles();
|
|
52
|
+
return changed || refreshed;
|
|
53
|
+
}
|
|
54
|
+
#applySourceChange(change) {
|
|
50
55
|
if (change.kind === "unlink") {
|
|
51
56
|
this.compiler.fs.removeFile?.(change.path);
|
|
52
57
|
return this.compiler.removeFile(change.path);
|
|
53
58
|
}
|
|
54
59
|
if (change.content == null) return false;
|
|
55
60
|
this.compiler.fs.addFile?.(change.path, change.content);
|
|
61
|
+
if (this.compiler.refreshFileSource(change.path, change.content)) return true;
|
|
62
|
+
if (!this.isSourceFile(change.path)) return false;
|
|
56
63
|
this.compiler.parseFileSource(change.path, change.content);
|
|
57
64
|
return true;
|
|
58
65
|
}
|
|
@@ -74,7 +81,7 @@ async function loadWasm() {
|
|
|
74
81
|
return mod;
|
|
75
82
|
}
|
|
76
83
|
async function createCompiler(config, options) {
|
|
77
|
-
const { createCompilerFromWasmModule: createCompilerFromWasmModule2 } = await import("./web-
|
|
84
|
+
const { createCompilerFromWasmModule: createCompilerFromWasmModule2 } = await import("./web-JSAD2QZX.js");
|
|
78
85
|
return createCompilerFromWasmModule2(await loadWasm(), config, options);
|
|
79
86
|
}
|
|
80
87
|
async function createCompilerFromSnapshot(snapshot, options) {
|
package/dist/web.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ParseFileReport, ScanOptions, LayerNames, Spec, SourceEntry, FileInspectionResult, ResolveUtilityValueInput, ResolvedUtilityValue, TokenSuggestion, WriteArtifactsOptions, WriteCssOptions, WriteCssResult, WriteLayerCssOptions, WriteSplitCssOptions,
|
|
1
|
+
import { ParseFileReport, ScanOptions, LayerNames, Spec, SourceEntry, FileInspectionResult, ResolveUtilityValueInput, ResolvedUtilityValue, TokenSuggestion, WriteArtifactsOptions, WriteCssOptions, WriteCssResult, WriteLayerCssOptions, WriteSplitCssOptions, WriteSplitCssResult, SerializedHookFilter, Atom, RecipeEntry, EncodedRecipeStyles, ProjectSummary, CompileOptions, CompileOutput, LayerCssOptions, SplitCssOptions, SplitCssResult, GenerateArtifactOptions, CodegenArtifact, CodegenArtifactId, CodegenDependency, Diagnostic, CompileFileManifest, ParsedFileView, StaticPatternResult, BuildInfoDesignSystemDependency, BuildInfoArtifact, DesignSystemManifestInput, DesignSystemManifest, SerializedConfig, UtilityValuesCallback, CompilerOptions, Compiler, ProjectCallbacks, ProjectHooks } from '@pandacss/compiler-shared';
|
|
2
2
|
export * from '@pandacss/compiler-shared';
|
|
3
|
-
export {
|
|
3
|
+
export { createUsageReport, mergeCallbacks } from '@pandacss/compiler-shared';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* TS-facing types that mirror the wasm-bindgen generated interfaces.
|
|
@@ -29,8 +29,7 @@ interface TokenDictionaryInput {
|
|
|
29
29
|
/** `path → CSS var form` (e.g. `colors.red.500 → var(--colors-red-500)`). */
|
|
30
30
|
vars: Record<string, string>;
|
|
31
31
|
}
|
|
32
|
-
type JsxFramework = 'react' | 'solid' | 'preact' | 'vue' |
|
|
33
|
-
type CssSyntax = 'template-literal' | 'object-literal';
|
|
32
|
+
type JsxFramework = 'react' | 'solid' | 'preact' | 'vue' | (string & {});
|
|
34
33
|
interface MatchersInput {
|
|
35
34
|
css?: MatcherInput;
|
|
36
35
|
recipe?: MatcherInput;
|
|
@@ -41,8 +40,6 @@ interface MatchersInput {
|
|
|
41
40
|
jsxFramework?: JsxFramework;
|
|
42
41
|
/** Defaults to `["styled"]` when omitted. */
|
|
43
42
|
jsxFactories?: string[];
|
|
44
|
-
/** CSS authoring syntax preference. Omit for object-literal mode. */
|
|
45
|
-
syntax?: CssSyntax;
|
|
46
43
|
/** Enable `token('…')` folding by passing a resolved dictionary. */
|
|
47
44
|
tokenDictionary?: TokenDictionaryInput;
|
|
48
45
|
}
|
|
@@ -74,6 +71,7 @@ declare class WasmCompiler {
|
|
|
74
71
|
refreshFile(path: string): boolean;
|
|
75
72
|
refreshFileSource(path: string, source: string): boolean;
|
|
76
73
|
removeFile(path: string): boolean;
|
|
74
|
+
affectedFiles(): string[];
|
|
77
75
|
clear(): void;
|
|
78
76
|
scan(options?: ScanOptions): string[];
|
|
79
77
|
realpath(path: string): string;
|
|
@@ -84,15 +82,17 @@ declare class WasmCompiler {
|
|
|
84
82
|
parseFiles(paths: string[]): ParseFileReport[];
|
|
85
83
|
layers(): LayerNames;
|
|
86
84
|
hasLayerDeclaration(css: string): boolean;
|
|
85
|
+
stripLayerOrderStatements(css: string): string;
|
|
87
86
|
spec(): Spec;
|
|
88
87
|
sources(): SourceEntry[];
|
|
89
88
|
inspectFileSource(path: string, source: string): Omit<FileInspectionResult, 'path'>;
|
|
90
89
|
resolveUtilityValue(input: ResolveUtilityValueInput): ResolvedUtilityValue | null;
|
|
91
90
|
suggestTokens(prop: string, value: string): TokenSuggestion[];
|
|
91
|
+
suggestSemanticTokens(path: string): TokenSuggestion[];
|
|
92
92
|
writeArtifacts(options: WriteArtifactsOptions): string[];
|
|
93
93
|
writeCss(options: WriteCssOptions): WriteCssResult;
|
|
94
94
|
writeLayerCss(options: WriteLayerCssOptions): WriteCssResult;
|
|
95
|
-
writeSplitCss(options: WriteSplitCssOptions):
|
|
95
|
+
writeSplitCss(options: WriteSplitCssOptions): WriteSplitCssResult;
|
|
96
96
|
isEmpty(): boolean;
|
|
97
97
|
registerUtilityTransform?(id: string, callback: (resolved: unknown, original: unknown) => unknown): void;
|
|
98
98
|
registerPatternTransform?(id: string, callback: (props: unknown, helpers: Record<string, unknown>) => unknown): void;
|
|
@@ -104,7 +104,8 @@ declare class WasmCompiler {
|
|
|
104
104
|
summary(): ProjectSummary;
|
|
105
105
|
compile(options?: CompileOptions): CompileOutput;
|
|
106
106
|
getLayerCss(options: LayerCssOptions): CompileOutput;
|
|
107
|
-
|
|
107
|
+
getKeyframeCss(options?: CompileOptions): CompileOutput;
|
|
108
|
+
getSplitCss(options?: SplitCssOptions): SplitCssResult;
|
|
108
109
|
generateArtifacts(options?: GenerateArtifactOptions): CodegenArtifact[];
|
|
109
110
|
generateArtifact(id: CodegenArtifactId, options?: GenerateArtifactOptions): CodegenArtifact | undefined;
|
|
110
111
|
generateAffectedArtifacts(dependencies: CodegenDependency[], options?: GenerateArtifactOptions): CodegenArtifact[];
|
|
@@ -113,13 +114,12 @@ declare class WasmCompiler {
|
|
|
113
114
|
/** Per-file view, or `null` when `path` isn't known. */
|
|
114
115
|
getFile(path: string): ParsedFileView | null;
|
|
115
116
|
staticPatternAtoms(): StaticPatternResult;
|
|
116
|
-
serializeBuildInfo(panda: string): BuildInfoArtifact;
|
|
117
|
+
serializeBuildInfo(panda: string, designSystemDependencies?: BuildInfoDesignSystemDependency[]): BuildInfoArtifact;
|
|
117
118
|
applyBuildInfo(name: string, buildInfo: BuildInfoArtifact, only?: string[]): boolean;
|
|
118
119
|
buildInfoSchemaVersion(): number;
|
|
119
120
|
configFingerprint(): string;
|
|
120
121
|
createDesignSystemManifest(input: DesignSystemManifestInput): DesignSystemManifest;
|
|
121
122
|
designSystemManifestSchemaVersion(): number;
|
|
122
|
-
resolveDesignSystemChain(manifests: DesignSystemManifest[]): DesignSystemChainPlan;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
/**
|
|
@@ -146,15 +146,15 @@ declare class WasmCompiler {
|
|
|
146
146
|
*/
|
|
147
147
|
interface WasmFromConfigOptions {
|
|
148
148
|
configCallbacks?: {
|
|
149
|
-
utilityValues?: Record<string,
|
|
149
|
+
utilityValues?: Record<string, UtilityValuesCallback>;
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* The raw wasm instance - superset of {@link Compiler} carrying the internal
|
|
154
|
-
* `
|
|
154
|
+
* `tokenDictionary` the facade hides.
|
|
155
155
|
*/
|
|
156
156
|
interface RawWasmCompiler extends WasmCompiler {
|
|
157
|
-
|
|
157
|
+
tokenDictionary?(): TokenDictionaryInput | undefined;
|
|
158
158
|
}
|
|
159
159
|
interface WasmModule {
|
|
160
160
|
WasmFileSystem: new () => WasmFileSystem;
|
package/dist/web.js
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
BuildInfo,
|
|
6
6
|
DesignSystem,
|
|
7
7
|
createUsageReport,
|
|
8
|
-
getTokenCategoryValues,
|
|
9
8
|
inspectFile,
|
|
10
9
|
inspectFiles,
|
|
11
10
|
mergeCallbacks,
|
|
@@ -14,12 +13,13 @@ import {
|
|
|
14
13
|
|
|
15
14
|
// src/callbacks.ts
|
|
16
15
|
import {
|
|
17
|
-
|
|
18
|
-
createTransformArgs,
|
|
16
|
+
createTransformHelpers,
|
|
19
17
|
getPatternDefaultValueRefsByTransformId,
|
|
20
|
-
mergePatternDefaultValues
|
|
18
|
+
mergePatternDefaultValues,
|
|
19
|
+
PATTERN_HELPERS
|
|
21
20
|
} from "@pandacss/compiler-shared";
|
|
22
21
|
function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
22
|
+
const { token, utils } = createTransformHelpers(tokenDictionary);
|
|
23
23
|
const utilityTransforms = callbacks["utility.transform"];
|
|
24
24
|
if (utilityTransforms && Object.keys(utilityTransforms).length > 0 && !project.registerUtilityTransform) {
|
|
25
25
|
throw new Error("WASM project does not support utility.transform callbacks");
|
|
@@ -27,7 +27,7 @@ function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
|
27
27
|
if (project.registerUtilityTransform && utilityTransforms && Object.keys(utilityTransforms).length > 0) {
|
|
28
28
|
for (const [id, callback] of Object.entries(utilityTransforms)) {
|
|
29
29
|
project.registerUtilityTransform(id, (resolved, original) => {
|
|
30
|
-
return callback(resolved,
|
|
30
|
+
return callback(resolved, { raw: original, token, utils });
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -45,7 +45,7 @@ function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
|
45
45
|
project.registerPatternTransform(id, (props) => {
|
|
46
46
|
const input = props;
|
|
47
47
|
const nextProps = defaultValue ? mergePatternDefaultValues(defaultValue(input), input) : input;
|
|
48
|
-
return callback(nextProps,
|
|
48
|
+
return callback(nextProps, PATTERN_HELPERS);
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -81,7 +81,7 @@ function build(mod, config, callbacks, hooks) {
|
|
|
81
81
|
assertProjectHooks(hooks, callbacks);
|
|
82
82
|
const prepared = prepareCompilerConfig(config);
|
|
83
83
|
const compiler = mod.WasmCompiler.fromConfig(fs, prepared, buildFromConfigOptions(callbacks));
|
|
84
|
-
registerCallbacks(compiler, callbacks, hooks, compiler.
|
|
84
|
+
registerCallbacks(compiler, callbacks, hooks, compiler.tokenDictionary?.());
|
|
85
85
|
Object.defineProperty(compiler, "fs", { value: fs, enumerable: false });
|
|
86
86
|
Object.defineProperty(compiler, "path", { value: wasmPathSystem(compiler), enumerable: false });
|
|
87
87
|
const buildInfo = new BuildInfo(compiler);
|
|
@@ -112,8 +112,7 @@ function wasmPathSystem(compiler) {
|
|
|
112
112
|
function toDesignSystemBinding(compiler) {
|
|
113
113
|
return {
|
|
114
114
|
createManifest: (input) => compiler.createDesignSystemManifest(input),
|
|
115
|
-
manifestSchemaVersion: () => compiler.designSystemManifestSchemaVersion()
|
|
116
|
-
resolveChain: (manifests) => compiler.resolveDesignSystemChain(manifests)
|
|
115
|
+
manifestSchemaVersion: () => compiler.designSystemManifestSchemaVersion()
|
|
117
116
|
};
|
|
118
117
|
}
|
|
119
118
|
function buildFromConfigOptions(callbacks) {
|
|
@@ -121,12 +120,7 @@ function buildFromConfigOptions(callbacks) {
|
|
|
121
120
|
if (!utilityValues || Object.keys(utilityValues).length === 0) return void 0;
|
|
122
121
|
return {
|
|
123
122
|
configCallbacks: {
|
|
124
|
-
utilityValues
|
|
125
|
-
Object.entries(utilityValues).map(([id, callback]) => [
|
|
126
|
-
id,
|
|
127
|
-
(tokenDictionary) => callback((category) => getTokenCategoryValues(category, tokenDictionary))
|
|
128
|
-
])
|
|
129
|
-
)
|
|
123
|
+
utilityValues
|
|
130
124
|
}
|
|
131
125
|
};
|
|
132
126
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/compiler-wasm",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "WebAssembly binding for the Panda compiler engine (browser/playground target)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,10 +38,11 @@
|
|
|
38
38
|
"pkg-web"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@pandacss/compiler-shared": "2.0.0
|
|
41
|
+
"@pandacss/compiler-shared": "2.0.0",
|
|
42
|
+
"@pandacss/types": "2.0.0"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@pandacss/config": "2.0.0
|
|
45
|
+
"@pandacss/config": "2.0.0"
|
|
45
46
|
},
|
|
46
47
|
"engines": {
|
|
47
48
|
"node": ">=22"
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
"build:js": "tsup",
|
|
52
53
|
"build:fast": "tsup --no-dts",
|
|
53
54
|
"build:wasm": "tsx build-wasm.ts",
|
|
55
|
+
"verify:package": "node verify-package.mjs",
|
|
54
56
|
"dev": "pnpm build:fast --watch",
|
|
55
57
|
"test": "vitest run"
|
|
56
58
|
}
|
|
@@ -19,6 +19,11 @@ export class WasmCompiler {
|
|
|
19
19
|
private constructor();
|
|
20
20
|
free(): void;
|
|
21
21
|
[Symbol.dispose](): void;
|
|
22
|
+
/**
|
|
23
|
+
* Files whose folded imports changed since the last call. Clears on read.
|
|
24
|
+
* Re-parse each via `refreshFile`, then call again until empty.
|
|
25
|
+
*/
|
|
26
|
+
affectedFiles(): string[];
|
|
22
27
|
/**
|
|
23
28
|
* Hydrate an external build info into this project (additive), optionally
|
|
24
29
|
* restricted to imported modules (tree-shaking). Returns `false` on a
|
|
@@ -66,13 +71,21 @@ export class WasmCompiler {
|
|
|
66
71
|
*/
|
|
67
72
|
configFingerprint(): string;
|
|
68
73
|
/**
|
|
69
|
-
* Build a `panda
|
|
74
|
+
* Build a `panda/lib.json` value from host-supplied fields, stamping the
|
|
70
75
|
* engine-owned schema version. Backs the `designSystem.create` JS namespace.
|
|
71
76
|
*
|
|
72
77
|
* # Errors
|
|
73
78
|
* Returns a JS error if `input` is invalid or the manifest fails to serialize.
|
|
74
79
|
*/
|
|
75
80
|
createDesignSystemManifest(input: any): any;
|
|
81
|
+
/**
|
|
82
|
+
* Per-package import selections from one scan. Each entry is `null` = all,
|
|
83
|
+
* or export names to narrow.
|
|
84
|
+
*
|
|
85
|
+
* # Errors
|
|
86
|
+
* Returns a JS error when the scan fails or serialization fails.
|
|
87
|
+
*/
|
|
88
|
+
designSystemImportSelections(packages: any): any;
|
|
76
89
|
/**
|
|
77
90
|
* The manifest wire-format version this binding reads/writes.
|
|
78
91
|
*/
|
|
@@ -117,23 +130,14 @@ export class WasmCompiler {
|
|
|
117
130
|
static fromConfig(fs: WasmFileSystem, config: any, options: any): WasmCompiler;
|
|
118
131
|
/**
|
|
119
132
|
* Generate artifacts affected by the provided config dependency names.
|
|
120
|
-
*
|
|
121
|
-
* # Errors
|
|
122
|
-
* Returns a JS error if dependencies/options are invalid or serializing fails.
|
|
123
133
|
*/
|
|
124
134
|
generateAffectedArtifacts(dependencies: any, options: any): any;
|
|
125
135
|
/**
|
|
126
136
|
* Generate one codegen artifact by id.
|
|
127
|
-
*
|
|
128
|
-
* # Errors
|
|
129
|
-
* Returns a JS error if the id/options are invalid or serializing fails.
|
|
130
137
|
*/
|
|
131
138
|
generateArtifact(id: string, options: any): any;
|
|
132
139
|
/**
|
|
133
140
|
* Generate every codegen artifact from the resolved project state.
|
|
134
|
-
*
|
|
135
|
-
* # Errors
|
|
136
|
-
* Returns a JS error if options are invalid or serializing fails.
|
|
137
141
|
*/
|
|
138
142
|
generateArtifacts(options: any): any;
|
|
139
143
|
/**
|
|
@@ -143,6 +147,10 @@ export class WasmCompiler {
|
|
|
143
147
|
* Returns a JS error if serializing fails.
|
|
144
148
|
*/
|
|
145
149
|
getFile(path: string): any;
|
|
150
|
+
/**
|
|
151
|
+
* Theme `@keyframes` CSS only (no token vars or other layers).
|
|
152
|
+
*/
|
|
153
|
+
getKeyframeCss(options?: any | null): any;
|
|
146
154
|
/**
|
|
147
155
|
* CSS for the named cascade layers, concatenated in order. Sliced in Rust
|
|
148
156
|
* (byte offsets stay valid); unknown layer names are skipped.
|
|
@@ -202,8 +210,8 @@ export class WasmCompiler {
|
|
|
202
210
|
*/
|
|
203
211
|
parseFileSource(path: string, source: string): any;
|
|
204
212
|
/**
|
|
205
|
-
* Read + parse source paths
|
|
206
|
-
*
|
|
213
|
+
* Read + parse source paths from `scan()`. One report per requested path;
|
|
214
|
+
* a read miss keeps last-good state and reports a warning diagnostic.
|
|
207
215
|
*
|
|
208
216
|
* # Errors
|
|
209
217
|
* Returns a JS error when `paths` is malformed or serializing the report fails.
|
|
@@ -247,15 +255,6 @@ export class WasmCompiler {
|
|
|
247
255
|
* Drop a file's contribution. Returns `true` if the path was known.
|
|
248
256
|
*/
|
|
249
257
|
removeFile(path: string): boolean;
|
|
250
|
-
/**
|
|
251
|
-
* Order already-read manifests by their `designSystem` parent links into a
|
|
252
|
-
* root-first hydrate/merge plan (or report a cycle). Backs the
|
|
253
|
-
* `designSystem.resolveChain` JS namespace. Pure — the host did the reads.
|
|
254
|
-
*
|
|
255
|
-
* # Errors
|
|
256
|
-
* Returns a JS error if `manifests` is invalid or the plan fails to serialize.
|
|
257
|
-
*/
|
|
258
|
-
resolveDesignSystemChain(manifests: any): any;
|
|
259
258
|
resolvePath(path: string, cwd?: string | null): string;
|
|
260
259
|
/**
|
|
261
260
|
* Resolve selector and CSS metadata for one utility value.
|
|
@@ -281,7 +280,7 @@ export class WasmCompiler {
|
|
|
281
280
|
* # Errors
|
|
282
281
|
* Returns a JS error if serializing the build info fails.
|
|
283
282
|
*/
|
|
284
|
-
serializeBuildInfo(panda: string): any;
|
|
283
|
+
serializeBuildInfo(panda: string, dependencies: any): any;
|
|
285
284
|
/**
|
|
286
285
|
* Every `sva()` slot-recipe entry.
|
|
287
286
|
*
|
|
@@ -310,6 +309,17 @@ export class WasmCompiler {
|
|
|
310
309
|
* Returns a JS error if serializing fails.
|
|
311
310
|
*/
|
|
312
311
|
staticPatternAtoms(): any;
|
|
312
|
+
/**
|
|
313
|
+
* Remove Panda `@layer a, b;` order statements; leave unrelated ones.
|
|
314
|
+
*/
|
|
315
|
+
stripLayerOrderStatements(css: string): string;
|
|
316
|
+
/**
|
|
317
|
+
* Semantic tokens that carry the same value as a token path.
|
|
318
|
+
*
|
|
319
|
+
* # Errors
|
|
320
|
+
* Returns a JS error if serialization fails.
|
|
321
|
+
*/
|
|
322
|
+
suggestSemanticTokens(path: string): any;
|
|
313
323
|
/**
|
|
314
324
|
* Tokens that carry a hardcoded value, ranked (safe equivalents first).
|
|
315
325
|
*
|
|
@@ -327,12 +337,9 @@ export class WasmCompiler {
|
|
|
327
337
|
/**
|
|
328
338
|
* Rust-built token dictionary projected into the small JS interop shape.
|
|
329
339
|
*/
|
|
330
|
-
|
|
340
|
+
tokenDictionary(): any;
|
|
331
341
|
/**
|
|
332
342
|
* Generate artifacts and write them under `outdir`.
|
|
333
|
-
*
|
|
334
|
-
* # Errors
|
|
335
|
-
* Returns a JS error if writing or serializing fails.
|
|
336
343
|
*/
|
|
337
344
|
writeArtifacts(options: any): any;
|
|
338
345
|
writeCss(options: any): any;
|