@pandacss/compiler-wasm 2.0.0-beta.1 → 2.0.0-beta.10
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-R2J25HLY.js → chunk-NJUVM3GY.js} +42 -16
- package/dist/index.d.ts +26 -14
- package/dist/index.js +8 -6
- package/dist/{web-Z44NGLTK.js → web-PCTKJFIY.js} +3 -1
- package/dist/web.d.ts +26 -14
- package/dist/web.js +42 -16
- package/package.json +7 -3
- package/pkg-node/compiler_wasm.d.ts +69 -23
- package/pkg-node/compiler_wasm.js +287 -79
- package/pkg-node/compiler_wasm_bg.wasm +0 -0
- package/pkg-node/compiler_wasm_bg.wasm.d.ts +16 -5
- package/pkg-web/compiler_wasm.d.ts +85 -28
- package/pkg-web/compiler_wasm.js +287 -79
- package/pkg-web/compiler_wasm_bg.wasm +0 -0
- package/pkg-web/compiler_wasm_bg.wasm.d.ts +16 -5
|
@@ -2,20 +2,24 @@
|
|
|
2
2
|
import {
|
|
3
3
|
assertProjectCallbacks,
|
|
4
4
|
assertProjectHooks,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
BuildInfo,
|
|
6
|
+
DesignSystem,
|
|
7
|
+
createUsageReport,
|
|
8
|
+
inspectFile,
|
|
9
|
+
inspectFiles,
|
|
7
10
|
mergeCallbacks,
|
|
8
11
|
prepareCompilerConfig
|
|
9
12
|
} from "@pandacss/compiler-shared";
|
|
10
13
|
|
|
11
14
|
// src/callbacks.ts
|
|
12
15
|
import {
|
|
13
|
-
|
|
14
|
-
createTransformArgs,
|
|
16
|
+
createTransformHelpers,
|
|
15
17
|
getPatternDefaultValueRefsByTransformId,
|
|
16
|
-
mergePatternDefaultValues
|
|
18
|
+
mergePatternDefaultValues,
|
|
19
|
+
PATTERN_HELPERS
|
|
17
20
|
} from "@pandacss/compiler-shared";
|
|
18
21
|
function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
22
|
+
const { token, utils } = createTransformHelpers(tokenDictionary);
|
|
19
23
|
const utilityTransforms = callbacks["utility.transform"];
|
|
20
24
|
if (utilityTransforms && Object.keys(utilityTransforms).length > 0 && !project.registerUtilityTransform) {
|
|
21
25
|
throw new Error("WASM project does not support utility.transform callbacks");
|
|
@@ -23,7 +27,7 @@ function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
|
23
27
|
if (project.registerUtilityTransform && utilityTransforms && Object.keys(utilityTransforms).length > 0) {
|
|
24
28
|
for (const [id, callback] of Object.entries(utilityTransforms)) {
|
|
25
29
|
project.registerUtilityTransform(id, (resolved, original) => {
|
|
26
|
-
return callback(resolved,
|
|
30
|
+
return callback(resolved, { raw: original, token, utils });
|
|
27
31
|
});
|
|
28
32
|
}
|
|
29
33
|
}
|
|
@@ -41,7 +45,7 @@ function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
|
41
45
|
project.registerPatternTransform(id, (props) => {
|
|
42
46
|
const input = props;
|
|
43
47
|
const nextProps = defaultValue ? mergePatternDefaultValues(defaultValue(input), input) : input;
|
|
44
|
-
return callback(nextProps,
|
|
48
|
+
return callback(nextProps, PATTERN_HELPERS);
|
|
45
49
|
});
|
|
46
50
|
}
|
|
47
51
|
}
|
|
@@ -78,29 +82,51 @@ function build(mod, config, callbacks, hooks) {
|
|
|
78
82
|
const prepared = prepareCompilerConfig(config);
|
|
79
83
|
const compiler = mod.WasmCompiler.fromConfig(fs, prepared, buildFromConfigOptions(callbacks));
|
|
80
84
|
registerCallbacks(compiler, callbacks, hooks, compiler.token_dictionary?.());
|
|
81
|
-
compiler
|
|
82
|
-
Object.defineProperty(compiler, "
|
|
83
|
-
|
|
85
|
+
Object.defineProperty(compiler, "fs", { value: fs, enumerable: false });
|
|
86
|
+
Object.defineProperty(compiler, "path", { value: wasmPathSystem(compiler), enumerable: false });
|
|
87
|
+
const buildInfo = new BuildInfo(compiler);
|
|
88
|
+
Object.defineProperty(compiler, "buildInfo", { value: buildInfo, enumerable: false });
|
|
89
|
+
Object.defineProperty(compiler, "designSystem", {
|
|
90
|
+
// `load` reuses the `buildInfo` namespace just wired above.
|
|
91
|
+
value: new DesignSystem(toDesignSystemBinding(compiler), buildInfo),
|
|
92
|
+
enumerable: false
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(compiler, "inspectFile", {
|
|
95
|
+
value: (input) => inspectFile(compiler, input),
|
|
96
|
+
enumerable: false
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(compiler, "inspectFiles", {
|
|
99
|
+
value: (files) => inspectFiles(compiler, files),
|
|
84
100
|
enumerable: false
|
|
85
101
|
});
|
|
86
102
|
return compiler;
|
|
87
103
|
}
|
|
104
|
+
function wasmPathSystem(compiler) {
|
|
105
|
+
return {
|
|
106
|
+
realpath: (path) => compiler.realpath(path),
|
|
107
|
+
resolve: (path, cwd) => compiler.resolvePath(path, cwd),
|
|
108
|
+
join: (parts) => compiler.joinPath(parts),
|
|
109
|
+
dirname: (path) => compiler.dirname(path)
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function toDesignSystemBinding(compiler) {
|
|
113
|
+
return {
|
|
114
|
+
createManifest: (input) => compiler.createDesignSystemManifest(input),
|
|
115
|
+
manifestSchemaVersion: () => compiler.designSystemManifestSchemaVersion()
|
|
116
|
+
};
|
|
117
|
+
}
|
|
88
118
|
function buildFromConfigOptions(callbacks) {
|
|
89
119
|
const utilityValues = callbacks["utility.values"];
|
|
90
120
|
if (!utilityValues || Object.keys(utilityValues).length === 0) return void 0;
|
|
91
121
|
return {
|
|
92
122
|
configCallbacks: {
|
|
93
|
-
utilityValues
|
|
94
|
-
Object.entries(utilityValues).map(([id, callback]) => [
|
|
95
|
-
id,
|
|
96
|
-
(tokenDictionary) => callback((category) => getTokenCategoryValues(category, tokenDictionary))
|
|
97
|
-
])
|
|
98
|
-
)
|
|
123
|
+
utilityValues
|
|
99
124
|
}
|
|
100
125
|
};
|
|
101
126
|
}
|
|
102
127
|
|
|
103
128
|
export {
|
|
129
|
+
createUsageReport,
|
|
104
130
|
mergeCallbacks,
|
|
105
131
|
createCompilerFromWasmModule,
|
|
106
132
|
build,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ParseFileReport, ScanOptions, LayerNames, Spec, SourceEntry, FileInspectionResult,
|
|
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, 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.
|
|
@@ -84,12 +84,17 @@ declare class WasmCompiler {
|
|
|
84
84
|
parseFiles(paths: string[]): ParseFileReport[];
|
|
85
85
|
layers(): LayerNames;
|
|
86
86
|
hasLayerDeclaration(css: string): boolean;
|
|
87
|
+
stripLayerOrderStatements(css: string): string;
|
|
87
88
|
spec(): Spec;
|
|
88
89
|
sources(): SourceEntry[];
|
|
89
|
-
inspectFileSource(path: string, source: string): FileInspectionResult
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
inspectFileSource(path: string, source: string): Omit<FileInspectionResult, 'path'>;
|
|
91
|
+
resolveUtilityValue(input: ResolveUtilityValueInput): ResolvedUtilityValue | null;
|
|
92
|
+
suggestTokens(prop: string, value: string): TokenSuggestion[];
|
|
93
|
+
suggestSemanticTokens(path: string): TokenSuggestion[];
|
|
94
|
+
writeArtifacts(options: WriteArtifactsOptions): string[];
|
|
95
|
+
writeCss(options: WriteCssOptions): WriteCssResult;
|
|
96
|
+
writeLayerCss(options: WriteLayerCssOptions): WriteCssResult;
|
|
97
|
+
writeSplitCss(options: WriteSplitCssOptions): WriteSplitCssResult;
|
|
93
98
|
isEmpty(): boolean;
|
|
94
99
|
registerUtilityTransform?(id: string, callback: (resolved: unknown, original: unknown) => unknown): void;
|
|
95
100
|
registerPatternTransform?(id: string, callback: (props: unknown, helpers: Record<string, unknown>) => unknown): void;
|
|
@@ -100,8 +105,9 @@ declare class WasmCompiler {
|
|
|
100
105
|
encodedRecipes(): EncodedRecipeStyles;
|
|
101
106
|
summary(): ProjectSummary;
|
|
102
107
|
compile(options?: CompileOptions): CompileOutput;
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
getLayerCss(options: LayerCssOptions): CompileOutput;
|
|
109
|
+
getKeyframeCss(options?: CompileOptions): CompileOutput;
|
|
110
|
+
getSplitCss(options?: SplitCssOptions): SplitCssResult;
|
|
105
111
|
generateArtifacts(options?: GenerateArtifactOptions): CodegenArtifact[];
|
|
106
112
|
generateArtifact(id: CodegenArtifactId, options?: GenerateArtifactOptions): CodegenArtifact | undefined;
|
|
107
113
|
generateAffectedArtifacts(dependencies: CodegenDependency[], options?: GenerateArtifactOptions): CodegenArtifact[];
|
|
@@ -110,10 +116,12 @@ declare class WasmCompiler {
|
|
|
110
116
|
/** Per-file view, or `null` when `path` isn't known. */
|
|
111
117
|
getFile(path: string): ParsedFileView | null;
|
|
112
118
|
staticPatternAtoms(): StaticPatternResult;
|
|
113
|
-
serializeBuildInfo(panda: string):
|
|
114
|
-
applyBuildInfo(name: string, buildInfo:
|
|
119
|
+
serializeBuildInfo(panda: string): BuildInfoArtifact;
|
|
120
|
+
applyBuildInfo(name: string, buildInfo: BuildInfoArtifact, only?: string[]): boolean;
|
|
115
121
|
buildInfoSchemaVersion(): number;
|
|
116
122
|
configFingerprint(): string;
|
|
123
|
+
createDesignSystemManifest(input: DesignSystemManifestInput): DesignSystemManifest;
|
|
124
|
+
designSystemManifestSchemaVersion(): number;
|
|
117
125
|
}
|
|
118
126
|
|
|
119
127
|
/**
|
|
@@ -135,14 +143,18 @@ declare class WasmCompiler {
|
|
|
135
143
|
* ```
|
|
136
144
|
*/
|
|
137
145
|
|
|
138
|
-
/**
|
|
146
|
+
/**
|
|
147
|
+
* `configCallbacks` carry construction-time `utility.values` resolvers.
|
|
148
|
+
*/
|
|
139
149
|
interface WasmFromConfigOptions {
|
|
140
150
|
configCallbacks?: {
|
|
141
|
-
utilityValues?: Record<string,
|
|
151
|
+
utilityValues?: Record<string, UtilityValuesCallback>;
|
|
142
152
|
};
|
|
143
153
|
}
|
|
144
|
-
/**
|
|
145
|
-
*
|
|
154
|
+
/**
|
|
155
|
+
* The raw wasm instance - superset of {@link Compiler} carrying the internal
|
|
156
|
+
* `token_dictionary` the facade hides.
|
|
157
|
+
*/
|
|
146
158
|
interface RawWasmCompiler extends WasmCompiler {
|
|
147
159
|
token_dictionary?(): TokenDictionaryInput | undefined;
|
|
148
160
|
}
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,9 @@ import {
|
|
|
2
2
|
build,
|
|
3
3
|
buildFromConfigOptions,
|
|
4
4
|
createCompilerFromWasmModule,
|
|
5
|
+
createUsageReport,
|
|
5
6
|
mergeCallbacks
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NJUVM3GY.js";
|
|
7
8
|
|
|
8
9
|
// src/index.ts
|
|
9
10
|
import { createRequire } from "module";
|
|
@@ -20,7 +21,7 @@ async function createBrowserDriver(options) {
|
|
|
20
21
|
}) : await createCompilerFromSnapshot(options.snapshot);
|
|
21
22
|
if (options.sources) {
|
|
22
23
|
for (const [path, content] of Object.entries(options.sources)) {
|
|
23
|
-
compiler.fs?.
|
|
24
|
+
compiler.fs.addFile?.(path, content);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
return new BrowserDriver(compiler, options.snapshot.config);
|
|
@@ -47,16 +48,16 @@ var BrowserDriver = class extends BaseDriver {
|
|
|
47
48
|
}
|
|
48
49
|
applyChange(change) {
|
|
49
50
|
if (change.kind === "unlink") {
|
|
50
|
-
this.compiler.fs?.
|
|
51
|
+
this.compiler.fs.removeFile?.(change.path);
|
|
51
52
|
return this.compiler.removeFile(change.path);
|
|
52
53
|
}
|
|
53
54
|
if (change.content == null) return false;
|
|
54
|
-
this.compiler.fs?.
|
|
55
|
+
this.compiler.fs.addFile?.(change.path, change.content);
|
|
55
56
|
this.compiler.parseFileSource(change.path, change.content);
|
|
56
57
|
return true;
|
|
57
58
|
}
|
|
58
59
|
getOutdir(outdir) {
|
|
59
|
-
return this.compiler.
|
|
60
|
+
return this.compiler.path.resolve(this.getConfiguredOutdir(outdir));
|
|
60
61
|
}
|
|
61
62
|
};
|
|
62
63
|
|
|
@@ -73,7 +74,7 @@ async function loadWasm() {
|
|
|
73
74
|
return mod;
|
|
74
75
|
}
|
|
75
76
|
async function createCompiler(config, options) {
|
|
76
|
-
const { createCompilerFromWasmModule: createCompilerFromWasmModule2 } = await import("./web-
|
|
77
|
+
const { createCompilerFromWasmModule: createCompilerFromWasmModule2 } = await import("./web-PCTKJFIY.js");
|
|
77
78
|
return createCompilerFromWasmModule2(await loadWasm(), config, options);
|
|
78
79
|
}
|
|
79
80
|
async function createCompilerFromSnapshot(snapshot, options) {
|
|
@@ -88,6 +89,7 @@ export {
|
|
|
88
89
|
createCompiler,
|
|
89
90
|
createCompilerFromSnapshot,
|
|
90
91
|
createCompilerFromWasmModule,
|
|
92
|
+
createUsageReport,
|
|
91
93
|
loadWasm,
|
|
92
94
|
mergeCallbacks
|
|
93
95
|
};
|
|
@@ -2,11 +2,13 @@ import {
|
|
|
2
2
|
build,
|
|
3
3
|
buildFromConfigOptions,
|
|
4
4
|
createCompilerFromWasmModule,
|
|
5
|
+
createUsageReport,
|
|
5
6
|
mergeCallbacks
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NJUVM3GY.js";
|
|
7
8
|
export {
|
|
8
9
|
build,
|
|
9
10
|
buildFromConfigOptions,
|
|
10
11
|
createCompilerFromWasmModule,
|
|
12
|
+
createUsageReport,
|
|
11
13
|
mergeCallbacks
|
|
12
14
|
};
|
package/dist/web.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ParseFileReport, ScanOptions, LayerNames, Spec, SourceEntry, FileInspectionResult,
|
|
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, 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.
|
|
@@ -84,12 +84,17 @@ declare class WasmCompiler {
|
|
|
84
84
|
parseFiles(paths: string[]): ParseFileReport[];
|
|
85
85
|
layers(): LayerNames;
|
|
86
86
|
hasLayerDeclaration(css: string): boolean;
|
|
87
|
+
stripLayerOrderStatements(css: string): string;
|
|
87
88
|
spec(): Spec;
|
|
88
89
|
sources(): SourceEntry[];
|
|
89
|
-
inspectFileSource(path: string, source: string): FileInspectionResult
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
inspectFileSource(path: string, source: string): Omit<FileInspectionResult, 'path'>;
|
|
91
|
+
resolveUtilityValue(input: ResolveUtilityValueInput): ResolvedUtilityValue | null;
|
|
92
|
+
suggestTokens(prop: string, value: string): TokenSuggestion[];
|
|
93
|
+
suggestSemanticTokens(path: string): TokenSuggestion[];
|
|
94
|
+
writeArtifacts(options: WriteArtifactsOptions): string[];
|
|
95
|
+
writeCss(options: WriteCssOptions): WriteCssResult;
|
|
96
|
+
writeLayerCss(options: WriteLayerCssOptions): WriteCssResult;
|
|
97
|
+
writeSplitCss(options: WriteSplitCssOptions): WriteSplitCssResult;
|
|
93
98
|
isEmpty(): boolean;
|
|
94
99
|
registerUtilityTransform?(id: string, callback: (resolved: unknown, original: unknown) => unknown): void;
|
|
95
100
|
registerPatternTransform?(id: string, callback: (props: unknown, helpers: Record<string, unknown>) => unknown): void;
|
|
@@ -100,8 +105,9 @@ declare class WasmCompiler {
|
|
|
100
105
|
encodedRecipes(): EncodedRecipeStyles;
|
|
101
106
|
summary(): ProjectSummary;
|
|
102
107
|
compile(options?: CompileOptions): CompileOutput;
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
getLayerCss(options: LayerCssOptions): CompileOutput;
|
|
109
|
+
getKeyframeCss(options?: CompileOptions): CompileOutput;
|
|
110
|
+
getSplitCss(options?: SplitCssOptions): SplitCssResult;
|
|
105
111
|
generateArtifacts(options?: GenerateArtifactOptions): CodegenArtifact[];
|
|
106
112
|
generateArtifact(id: CodegenArtifactId, options?: GenerateArtifactOptions): CodegenArtifact | undefined;
|
|
107
113
|
generateAffectedArtifacts(dependencies: CodegenDependency[], options?: GenerateArtifactOptions): CodegenArtifact[];
|
|
@@ -110,10 +116,12 @@ declare class WasmCompiler {
|
|
|
110
116
|
/** Per-file view, or `null` when `path` isn't known. */
|
|
111
117
|
getFile(path: string): ParsedFileView | null;
|
|
112
118
|
staticPatternAtoms(): StaticPatternResult;
|
|
113
|
-
serializeBuildInfo(panda: string):
|
|
114
|
-
applyBuildInfo(name: string, buildInfo:
|
|
119
|
+
serializeBuildInfo(panda: string): BuildInfoArtifact;
|
|
120
|
+
applyBuildInfo(name: string, buildInfo: BuildInfoArtifact, only?: string[]): boolean;
|
|
115
121
|
buildInfoSchemaVersion(): number;
|
|
116
122
|
configFingerprint(): string;
|
|
123
|
+
createDesignSystemManifest(input: DesignSystemManifestInput): DesignSystemManifest;
|
|
124
|
+
designSystemManifestSchemaVersion(): number;
|
|
117
125
|
}
|
|
118
126
|
|
|
119
127
|
/**
|
|
@@ -135,14 +143,18 @@ declare class WasmCompiler {
|
|
|
135
143
|
* ```
|
|
136
144
|
*/
|
|
137
145
|
|
|
138
|
-
/**
|
|
146
|
+
/**
|
|
147
|
+
* `configCallbacks` carry construction-time `utility.values` resolvers.
|
|
148
|
+
*/
|
|
139
149
|
interface WasmFromConfigOptions {
|
|
140
150
|
configCallbacks?: {
|
|
141
|
-
utilityValues?: Record<string,
|
|
151
|
+
utilityValues?: Record<string, UtilityValuesCallback>;
|
|
142
152
|
};
|
|
143
153
|
}
|
|
144
|
-
/**
|
|
145
|
-
*
|
|
154
|
+
/**
|
|
155
|
+
* The raw wasm instance - superset of {@link Compiler} carrying the internal
|
|
156
|
+
* `token_dictionary` the facade hides.
|
|
157
|
+
*/
|
|
146
158
|
interface RawWasmCompiler extends WasmCompiler {
|
|
147
159
|
token_dictionary?(): TokenDictionaryInput | undefined;
|
|
148
160
|
}
|
package/dist/web.js
CHANGED
|
@@ -2,20 +2,24 @@
|
|
|
2
2
|
import {
|
|
3
3
|
assertProjectCallbacks,
|
|
4
4
|
assertProjectHooks,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
BuildInfo,
|
|
6
|
+
DesignSystem,
|
|
7
|
+
createUsageReport,
|
|
8
|
+
inspectFile,
|
|
9
|
+
inspectFiles,
|
|
7
10
|
mergeCallbacks,
|
|
8
11
|
prepareCompilerConfig
|
|
9
12
|
} from "@pandacss/compiler-shared";
|
|
10
13
|
|
|
11
14
|
// src/callbacks.ts
|
|
12
15
|
import {
|
|
13
|
-
|
|
14
|
-
createTransformArgs,
|
|
16
|
+
createTransformHelpers,
|
|
15
17
|
getPatternDefaultValueRefsByTransformId,
|
|
16
|
-
mergePatternDefaultValues
|
|
18
|
+
mergePatternDefaultValues,
|
|
19
|
+
PATTERN_HELPERS
|
|
17
20
|
} from "@pandacss/compiler-shared";
|
|
18
21
|
function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
22
|
+
const { token, utils } = createTransformHelpers(tokenDictionary);
|
|
19
23
|
const utilityTransforms = callbacks["utility.transform"];
|
|
20
24
|
if (utilityTransforms && Object.keys(utilityTransforms).length > 0 && !project.registerUtilityTransform) {
|
|
21
25
|
throw new Error("WASM project does not support utility.transform callbacks");
|
|
@@ -23,7 +27,7 @@ function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
|
23
27
|
if (project.registerUtilityTransform && utilityTransforms && Object.keys(utilityTransforms).length > 0) {
|
|
24
28
|
for (const [id, callback] of Object.entries(utilityTransforms)) {
|
|
25
29
|
project.registerUtilityTransform(id, (resolved, original) => {
|
|
26
|
-
return callback(resolved,
|
|
30
|
+
return callback(resolved, { raw: original, token, utils });
|
|
27
31
|
});
|
|
28
32
|
}
|
|
29
33
|
}
|
|
@@ -41,7 +45,7 @@ function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
|
41
45
|
project.registerPatternTransform(id, (props) => {
|
|
42
46
|
const input = props;
|
|
43
47
|
const nextProps = defaultValue ? mergePatternDefaultValues(defaultValue(input), input) : input;
|
|
44
|
-
return callback(nextProps,
|
|
48
|
+
return callback(nextProps, PATTERN_HELPERS);
|
|
45
49
|
});
|
|
46
50
|
}
|
|
47
51
|
}
|
|
@@ -78,24 +82,45 @@ function build(mod, config, callbacks, hooks) {
|
|
|
78
82
|
const prepared = prepareCompilerConfig(config);
|
|
79
83
|
const compiler = mod.WasmCompiler.fromConfig(fs, prepared, buildFromConfigOptions(callbacks));
|
|
80
84
|
registerCallbacks(compiler, callbacks, hooks, compiler.token_dictionary?.());
|
|
81
|
-
compiler
|
|
82
|
-
Object.defineProperty(compiler, "
|
|
83
|
-
|
|
85
|
+
Object.defineProperty(compiler, "fs", { value: fs, enumerable: false });
|
|
86
|
+
Object.defineProperty(compiler, "path", { value: wasmPathSystem(compiler), enumerable: false });
|
|
87
|
+
const buildInfo = new BuildInfo(compiler);
|
|
88
|
+
Object.defineProperty(compiler, "buildInfo", { value: buildInfo, enumerable: false });
|
|
89
|
+
Object.defineProperty(compiler, "designSystem", {
|
|
90
|
+
// `load` reuses the `buildInfo` namespace just wired above.
|
|
91
|
+
value: new DesignSystem(toDesignSystemBinding(compiler), buildInfo),
|
|
92
|
+
enumerable: false
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(compiler, "inspectFile", {
|
|
95
|
+
value: (input) => inspectFile(compiler, input),
|
|
96
|
+
enumerable: false
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(compiler, "inspectFiles", {
|
|
99
|
+
value: (files) => inspectFiles(compiler, files),
|
|
84
100
|
enumerable: false
|
|
85
101
|
});
|
|
86
102
|
return compiler;
|
|
87
103
|
}
|
|
104
|
+
function wasmPathSystem(compiler) {
|
|
105
|
+
return {
|
|
106
|
+
realpath: (path) => compiler.realpath(path),
|
|
107
|
+
resolve: (path, cwd) => compiler.resolvePath(path, cwd),
|
|
108
|
+
join: (parts) => compiler.joinPath(parts),
|
|
109
|
+
dirname: (path) => compiler.dirname(path)
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function toDesignSystemBinding(compiler) {
|
|
113
|
+
return {
|
|
114
|
+
createManifest: (input) => compiler.createDesignSystemManifest(input),
|
|
115
|
+
manifestSchemaVersion: () => compiler.designSystemManifestSchemaVersion()
|
|
116
|
+
};
|
|
117
|
+
}
|
|
88
118
|
function buildFromConfigOptions(callbacks) {
|
|
89
119
|
const utilityValues = callbacks["utility.values"];
|
|
90
120
|
if (!utilityValues || Object.keys(utilityValues).length === 0) return void 0;
|
|
91
121
|
return {
|
|
92
122
|
configCallbacks: {
|
|
93
|
-
utilityValues
|
|
94
|
-
Object.entries(utilityValues).map(([id, callback]) => [
|
|
95
|
-
id,
|
|
96
|
-
(tokenDictionary) => callback((category) => getTokenCategoryValues(category, tokenDictionary))
|
|
97
|
-
])
|
|
98
|
-
)
|
|
123
|
+
utilityValues
|
|
99
124
|
}
|
|
100
125
|
};
|
|
101
126
|
}
|
|
@@ -103,5 +128,6 @@ export {
|
|
|
103
128
|
build,
|
|
104
129
|
buildFromConfigOptions,
|
|
105
130
|
createCompilerFromWasmModule,
|
|
131
|
+
createUsageReport,
|
|
106
132
|
mergeCallbacks
|
|
107
133
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/compiler-wasm",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.10",
|
|
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,14 @@
|
|
|
38
38
|
"pkg-web"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@pandacss/compiler-shared": "2.0.0-beta.
|
|
41
|
+
"@pandacss/compiler-shared": "2.0.0-beta.10",
|
|
42
|
+
"@pandacss/types": "2.0.0-beta.10"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@pandacss/config": "2.0.0-beta.
|
|
45
|
+
"@pandacss/config": "2.0.0-beta.10"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=22"
|
|
45
49
|
},
|
|
46
50
|
"scripts": {
|
|
47
51
|
"build": "pnpm build:wasm && pnpm build:js",
|
|
@@ -65,6 +65,26 @@ export class WasmCompiler {
|
|
|
65
65
|
* stamped into build info as `configFingerprint`.
|
|
66
66
|
*/
|
|
67
67
|
configFingerprint(): string;
|
|
68
|
+
/**
|
|
69
|
+
* Build a `panda/lib.json` value from host-supplied fields, stamping the
|
|
70
|
+
* engine-owned schema version. Backs the `designSystem.create` JS namespace.
|
|
71
|
+
*
|
|
72
|
+
* # Errors
|
|
73
|
+
* Returns a JS error if `input` is invalid or the manifest fails to serialize.
|
|
74
|
+
*/
|
|
75
|
+
createDesignSystemManifest(input: any): any;
|
|
76
|
+
/**
|
|
77
|
+
* Per-package import selections from one scan. Each entry is `null` = all,
|
|
78
|
+
* or export names to narrow.
|
|
79
|
+
*
|
|
80
|
+
* # Errors
|
|
81
|
+
* Returns a JS error when the scan fails or serialization fails.
|
|
82
|
+
*/
|
|
83
|
+
designSystemImportSelections(packages: any): any;
|
|
84
|
+
/**
|
|
85
|
+
* The manifest wire-format version this binding reads/writes.
|
|
86
|
+
*/
|
|
87
|
+
designSystemManifestSchemaVersion(): number;
|
|
68
88
|
/**
|
|
69
89
|
* Config validation diagnostics from construction.
|
|
70
90
|
*
|
|
@@ -131,6 +151,23 @@ export class WasmCompiler {
|
|
|
131
151
|
* Returns a JS error if serializing fails.
|
|
132
152
|
*/
|
|
133
153
|
getFile(path: string): any;
|
|
154
|
+
/**
|
|
155
|
+
* Theme `@keyframes` CSS only (no token vars or other layers).
|
|
156
|
+
*/
|
|
157
|
+
getKeyframeCss(options?: any | null): any;
|
|
158
|
+
/**
|
|
159
|
+
* CSS for the named cascade layers, concatenated in order. Sliced in Rust
|
|
160
|
+
* (byte offsets stay valid); unknown layer names are skipped.
|
|
161
|
+
*/
|
|
162
|
+
getLayerCss(options: any): any;
|
|
163
|
+
/**
|
|
164
|
+
* Split the stylesheet into per-file outputs (one per layer + per recipe,
|
|
165
|
+
* plus `recipes.css` / `styles.css` index files) for `--splitting`.
|
|
166
|
+
*
|
|
167
|
+
* # Errors
|
|
168
|
+
* Returns a JS error if serializing fails.
|
|
169
|
+
*/
|
|
170
|
+
getSplitCss(options?: any | null): any;
|
|
134
171
|
/**
|
|
135
172
|
* Whether `css` declares Panda's cascade layers (`@layer reset, base, …;`),
|
|
136
173
|
* marking it as the stylesheet root to inject the compiled CSS into.
|
|
@@ -154,11 +191,6 @@ export class WasmCompiler {
|
|
|
154
191
|
*/
|
|
155
192
|
isSourceFile(path: string): boolean;
|
|
156
193
|
joinPath(parts: any): string;
|
|
157
|
-
/**
|
|
158
|
-
* CSS for the named cascade layers, concatenated in order. Sliced in Rust
|
|
159
|
-
* (byte offsets stay valid); unknown layer names are skipped.
|
|
160
|
-
*/
|
|
161
|
-
layerCss(layers: string[]): string;
|
|
162
194
|
/**
|
|
163
195
|
* The resolved cascade-layer names (config overrides merged over defaults).
|
|
164
196
|
*
|
|
@@ -212,18 +244,15 @@ export class WasmCompiler {
|
|
|
212
244
|
*/
|
|
213
245
|
refreshFileSource(path: string, source: string): boolean;
|
|
214
246
|
/**
|
|
215
|
-
* Register a JS-backed pattern transform callback.
|
|
216
|
-
* installs callbacks referenced by the serialized config snapshot.
|
|
247
|
+
* Register a JS-backed pattern transform callback.
|
|
217
248
|
*/
|
|
218
249
|
registerPatternTransform(id: string, callback: Function): void;
|
|
219
250
|
/**
|
|
220
|
-
* Register a JS-backed `parser:before` source transform
|
|
221
|
-
* filter. The filter is evaluated before calling into JS.
|
|
251
|
+
* Register a JS-backed `parser:before` source transform.
|
|
222
252
|
*/
|
|
223
253
|
registerSourceTransform(id: string, filter: any, callback: Function): void;
|
|
224
254
|
/**
|
|
225
|
-
* Register a JS-backed utility transform callback.
|
|
226
|
-
* the user callback so Rust only has to pass the raw value.
|
|
255
|
+
* Register a JS-backed utility transform callback.
|
|
227
256
|
*/
|
|
228
257
|
registerUtilityTransform(id: string, callback: Function): void;
|
|
229
258
|
/**
|
|
@@ -231,6 +260,13 @@ export class WasmCompiler {
|
|
|
231
260
|
*/
|
|
232
261
|
removeFile(path: string): boolean;
|
|
233
262
|
resolvePath(path: string, cwd?: string | null): string;
|
|
263
|
+
/**
|
|
264
|
+
* Resolve selector and CSS metadata for one utility value.
|
|
265
|
+
*
|
|
266
|
+
* # Errors
|
|
267
|
+
* Returns a JS error if the input or result cannot be serialized.
|
|
268
|
+
*/
|
|
269
|
+
resolveUtilityValue(input: any): any;
|
|
234
270
|
/**
|
|
235
271
|
* Source paths matching the config's `include`/`exclude` (overridable via
|
|
236
272
|
* `options`) from the in-memory filesystem. For discovery and the host's
|
|
@@ -271,20 +307,30 @@ export class WasmCompiler {
|
|
|
271
307
|
*/
|
|
272
308
|
spec(): any;
|
|
273
309
|
/**
|
|
274
|
-
*
|
|
275
|
-
* plus `recipes.css` / `styles.css` index files) for `--splitting`.
|
|
310
|
+
* `staticCss.patterns` expansion as raw atoms, without compiling.
|
|
276
311
|
*
|
|
277
312
|
* # Errors
|
|
278
313
|
* Returns a JS error if serializing fails.
|
|
279
314
|
*/
|
|
280
|
-
|
|
315
|
+
staticPatternAtoms(): any;
|
|
281
316
|
/**
|
|
282
|
-
*
|
|
317
|
+
* Remove Panda `@layer a, b;` order statements; leave unrelated ones.
|
|
318
|
+
*/
|
|
319
|
+
stripLayerOrderStatements(css: string): string;
|
|
320
|
+
/**
|
|
321
|
+
* Semantic tokens that carry the same value as a token path.
|
|
283
322
|
*
|
|
284
323
|
* # Errors
|
|
285
|
-
* Returns a JS error if
|
|
324
|
+
* Returns a JS error if serialization fails.
|
|
286
325
|
*/
|
|
287
|
-
|
|
326
|
+
suggestSemanticTokens(path: string): any;
|
|
327
|
+
/**
|
|
328
|
+
* Tokens that carry a hardcoded value, ranked (safe equivalents first).
|
|
329
|
+
*
|
|
330
|
+
* # Errors
|
|
331
|
+
* Returns a JS error if serialization fails.
|
|
332
|
+
*/
|
|
333
|
+
suggestTokens(prop: string, value: string): any;
|
|
288
334
|
/**
|
|
289
335
|
* Aggregate counts.
|
|
290
336
|
*
|
|
@@ -297,15 +343,15 @@ export class WasmCompiler {
|
|
|
297
343
|
*/
|
|
298
344
|
token_dictionary(): any;
|
|
299
345
|
/**
|
|
300
|
-
* Generate artifacts and write them under `outdir
|
|
301
|
-
* Returns the written paths.
|
|
346
|
+
* Generate artifacts and write them under `outdir`.
|
|
302
347
|
*
|
|
303
348
|
* # Errors
|
|
304
|
-
* Returns a JS error if
|
|
349
|
+
* Returns a JS error if writing or serializing fails.
|
|
305
350
|
*/
|
|
306
|
-
writeArtifacts(
|
|
307
|
-
writeCss(
|
|
308
|
-
|
|
351
|
+
writeArtifacts(options: any): any;
|
|
352
|
+
writeCss(options: any): any;
|
|
353
|
+
writeLayerCss(options: any): any;
|
|
354
|
+
writeSplitCss(options: any): any;
|
|
309
355
|
}
|
|
310
356
|
|
|
311
357
|
/**
|