@pandacss/compiler-wasm 2.0.0-beta.2 → 2.0.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-R2J25HLY.js → chunk-ZARW4JPN.js} +43 -17
- package/dist/index.d.ts +26 -17
- package/dist/index.js +16 -7
- package/dist/{web-Z44NGLTK.js → web-JSAD2QZX.js} +3 -1
- package/dist/web.d.ts +26 -17
- package/dist/web.js +43 -17
- package/package.json +5 -3
- package/pkg-node/compiler_wasm.d.ts +67 -35
- package/pkg-node/compiler_wasm.js +290 -74
- package/pkg-node/compiler_wasm_bg.wasm +0 -0
- package/pkg-node/compiler_wasm_bg.wasm.d.ts +15 -4
- package/pkg-web/compiler_wasm.d.ts +82 -39
- package/pkg-web/compiler_wasm.js +290 -74
- package/pkg-web/compiler_wasm_bg.wasm +0 -0
- package/pkg-web/compiler_wasm_bg.wasm.d.ts +15 -4
|
@@ -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
|
}
|
|
@@ -77,30 +81,52 @@ function build(mod, config, callbacks, hooks) {
|
|
|
77
81
|
assertProjectHooks(hooks, callbacks);
|
|
78
82
|
const prepared = prepareCompilerConfig(config);
|
|
79
83
|
const compiler = mod.WasmCompiler.fromConfig(fs, prepared, buildFromConfigOptions(callbacks));
|
|
80
|
-
registerCallbacks(compiler, callbacks, hooks, compiler.
|
|
81
|
-
compiler
|
|
82
|
-
Object.defineProperty(compiler, "
|
|
83
|
-
|
|
84
|
+
registerCallbacks(compiler, callbacks, hooks, compiler.tokenDictionary?.());
|
|
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, ResolveUtilityValueInput, ResolvedUtilityValue, WriteArtifactsOptions, WriteCssOptions, WriteCssResult, 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,13 +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
|
-
inspectFileSource(path: string, source: string): FileInspectionResult
|
|
88
|
+
inspectFileSource(path: string, source: string): Omit<FileInspectionResult, 'path'>;
|
|
90
89
|
resolveUtilityValue(input: ResolveUtilityValueInput): ResolvedUtilityValue | null;
|
|
90
|
+
suggestTokens(prop: string, value: string): TokenSuggestion[];
|
|
91
|
+
suggestSemanticTokens(path: string): TokenSuggestion[];
|
|
91
92
|
writeArtifacts(options: WriteArtifactsOptions): string[];
|
|
92
93
|
writeCss(options: WriteCssOptions): WriteCssResult;
|
|
93
|
-
|
|
94
|
+
writeLayerCss(options: WriteLayerCssOptions): WriteCssResult;
|
|
95
|
+
writeSplitCss(options: WriteSplitCssOptions): WriteSplitCssResult;
|
|
94
96
|
isEmpty(): boolean;
|
|
95
97
|
registerUtilityTransform?(id: string, callback: (resolved: unknown, original: unknown) => unknown): void;
|
|
96
98
|
registerPatternTransform?(id: string, callback: (props: unknown, helpers: Record<string, unknown>) => unknown): void;
|
|
@@ -101,8 +103,9 @@ declare class WasmCompiler {
|
|
|
101
103
|
encodedRecipes(): EncodedRecipeStyles;
|
|
102
104
|
summary(): ProjectSummary;
|
|
103
105
|
compile(options?: CompileOptions): CompileOutput;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
getLayerCss(options: LayerCssOptions): CompileOutput;
|
|
107
|
+
getKeyframeCss(options?: CompileOptions): CompileOutput;
|
|
108
|
+
getSplitCss(options?: SplitCssOptions): SplitCssResult;
|
|
106
109
|
generateArtifacts(options?: GenerateArtifactOptions): CodegenArtifact[];
|
|
107
110
|
generateArtifact(id: CodegenArtifactId, options?: GenerateArtifactOptions): CodegenArtifact | undefined;
|
|
108
111
|
generateAffectedArtifacts(dependencies: CodegenDependency[], options?: GenerateArtifactOptions): CodegenArtifact[];
|
|
@@ -111,10 +114,12 @@ declare class WasmCompiler {
|
|
|
111
114
|
/** Per-file view, or `null` when `path` isn't known. */
|
|
112
115
|
getFile(path: string): ParsedFileView | null;
|
|
113
116
|
staticPatternAtoms(): StaticPatternResult;
|
|
114
|
-
serializeBuildInfo(panda: string):
|
|
115
|
-
applyBuildInfo(name: string, buildInfo:
|
|
117
|
+
serializeBuildInfo(panda: string, designSystemDependencies?: BuildInfoDesignSystemDependency[]): BuildInfoArtifact;
|
|
118
|
+
applyBuildInfo(name: string, buildInfo: BuildInfoArtifact, only?: string[]): boolean;
|
|
116
119
|
buildInfoSchemaVersion(): number;
|
|
117
120
|
configFingerprint(): string;
|
|
121
|
+
createDesignSystemManifest(input: DesignSystemManifestInput): DesignSystemManifest;
|
|
122
|
+
designSystemManifestSchemaVersion(): number;
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
/**
|
|
@@ -136,16 +141,20 @@ declare class WasmCompiler {
|
|
|
136
141
|
* ```
|
|
137
142
|
*/
|
|
138
143
|
|
|
139
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* `configCallbacks` carry construction-time `utility.values` resolvers.
|
|
146
|
+
*/
|
|
140
147
|
interface WasmFromConfigOptions {
|
|
141
148
|
configCallbacks?: {
|
|
142
|
-
utilityValues?: Record<string,
|
|
149
|
+
utilityValues?: Record<string, UtilityValuesCallback>;
|
|
143
150
|
};
|
|
144
151
|
}
|
|
145
|
-
/**
|
|
146
|
-
*
|
|
152
|
+
/**
|
|
153
|
+
* The raw wasm instance - superset of {@link Compiler} carrying the internal
|
|
154
|
+
* `tokenDictionary` the facade hides.
|
|
155
|
+
*/
|
|
147
156
|
interface RawWasmCompiler extends WasmCompiler {
|
|
148
|
-
|
|
157
|
+
tokenDictionary?(): TokenDictionaryInput | undefined;
|
|
149
158
|
}
|
|
150
159
|
interface WasmModule {
|
|
151
160
|
WasmFileSystem: new () => WasmFileSystem;
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,12 @@ import {
|
|
|
2
2
|
build,
|
|
3
3
|
buildFromConfigOptions,
|
|
4
4
|
createCompilerFromWasmModule,
|
|
5
|
+
createUsageReport,
|
|
5
6
|
mergeCallbacks
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZARW4JPN.js";
|
|
7
8
|
|
|
8
9
|
// src/index.ts
|
|
9
|
-
import { createRequire } from "module";
|
|
10
|
+
import { createRequire } from "node:module";
|
|
10
11
|
import { mergeCallbacks as mergeCallbacks2, mergeHooks } from "@pandacss/compiler-shared";
|
|
11
12
|
|
|
12
13
|
// src/driver.ts
|
|
@@ -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);
|
|
@@ -46,17 +47,24 @@ var BrowserDriver = class extends BaseDriver {
|
|
|
46
47
|
return NO_CHANGE;
|
|
47
48
|
}
|
|
48
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) {
|
|
49
55
|
if (change.kind === "unlink") {
|
|
50
|
-
this.compiler.fs?.
|
|
56
|
+
this.compiler.fs.removeFile?.(change.path);
|
|
51
57
|
return this.compiler.removeFile(change.path);
|
|
52
58
|
}
|
|
53
59
|
if (change.content == null) return false;
|
|
54
|
-
this.compiler.fs?.
|
|
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;
|
|
55
63
|
this.compiler.parseFileSource(change.path, change.content);
|
|
56
64
|
return true;
|
|
57
65
|
}
|
|
58
66
|
getOutdir(outdir) {
|
|
59
|
-
return this.compiler.
|
|
67
|
+
return this.compiler.path.resolve(this.getConfiguredOutdir(outdir));
|
|
60
68
|
}
|
|
61
69
|
};
|
|
62
70
|
|
|
@@ -73,7 +81,7 @@ async function loadWasm() {
|
|
|
73
81
|
return mod;
|
|
74
82
|
}
|
|
75
83
|
async function createCompiler(config, options) {
|
|
76
|
-
const { createCompilerFromWasmModule: createCompilerFromWasmModule2 } = await import("./web-
|
|
84
|
+
const { createCompilerFromWasmModule: createCompilerFromWasmModule2 } = await import("./web-JSAD2QZX.js");
|
|
77
85
|
return createCompilerFromWasmModule2(await loadWasm(), config, options);
|
|
78
86
|
}
|
|
79
87
|
async function createCompilerFromSnapshot(snapshot, options) {
|
|
@@ -88,6 +96,7 @@ export {
|
|
|
88
96
|
createCompiler,
|
|
89
97
|
createCompilerFromSnapshot,
|
|
90
98
|
createCompilerFromWasmModule,
|
|
99
|
+
createUsageReport,
|
|
91
100
|
loadWasm,
|
|
92
101
|
mergeCallbacks
|
|
93
102
|
};
|
|
@@ -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-ZARW4JPN.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, ResolveUtilityValueInput, ResolvedUtilityValue, WriteArtifactsOptions, WriteCssOptions, WriteCssResult, 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,13 +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
|
-
inspectFileSource(path: string, source: string): FileInspectionResult
|
|
88
|
+
inspectFileSource(path: string, source: string): Omit<FileInspectionResult, 'path'>;
|
|
90
89
|
resolveUtilityValue(input: ResolveUtilityValueInput): ResolvedUtilityValue | null;
|
|
90
|
+
suggestTokens(prop: string, value: string): TokenSuggestion[];
|
|
91
|
+
suggestSemanticTokens(path: string): TokenSuggestion[];
|
|
91
92
|
writeArtifacts(options: WriteArtifactsOptions): string[];
|
|
92
93
|
writeCss(options: WriteCssOptions): WriteCssResult;
|
|
93
|
-
|
|
94
|
+
writeLayerCss(options: WriteLayerCssOptions): WriteCssResult;
|
|
95
|
+
writeSplitCss(options: WriteSplitCssOptions): WriteSplitCssResult;
|
|
94
96
|
isEmpty(): boolean;
|
|
95
97
|
registerUtilityTransform?(id: string, callback: (resolved: unknown, original: unknown) => unknown): void;
|
|
96
98
|
registerPatternTransform?(id: string, callback: (props: unknown, helpers: Record<string, unknown>) => unknown): void;
|
|
@@ -101,8 +103,9 @@ declare class WasmCompiler {
|
|
|
101
103
|
encodedRecipes(): EncodedRecipeStyles;
|
|
102
104
|
summary(): ProjectSummary;
|
|
103
105
|
compile(options?: CompileOptions): CompileOutput;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
getLayerCss(options: LayerCssOptions): CompileOutput;
|
|
107
|
+
getKeyframeCss(options?: CompileOptions): CompileOutput;
|
|
108
|
+
getSplitCss(options?: SplitCssOptions): SplitCssResult;
|
|
106
109
|
generateArtifacts(options?: GenerateArtifactOptions): CodegenArtifact[];
|
|
107
110
|
generateArtifact(id: CodegenArtifactId, options?: GenerateArtifactOptions): CodegenArtifact | undefined;
|
|
108
111
|
generateAffectedArtifacts(dependencies: CodegenDependency[], options?: GenerateArtifactOptions): CodegenArtifact[];
|
|
@@ -111,10 +114,12 @@ declare class WasmCompiler {
|
|
|
111
114
|
/** Per-file view, or `null` when `path` isn't known. */
|
|
112
115
|
getFile(path: string): ParsedFileView | null;
|
|
113
116
|
staticPatternAtoms(): StaticPatternResult;
|
|
114
|
-
serializeBuildInfo(panda: string):
|
|
115
|
-
applyBuildInfo(name: string, buildInfo:
|
|
117
|
+
serializeBuildInfo(panda: string, designSystemDependencies?: BuildInfoDesignSystemDependency[]): BuildInfoArtifact;
|
|
118
|
+
applyBuildInfo(name: string, buildInfo: BuildInfoArtifact, only?: string[]): boolean;
|
|
116
119
|
buildInfoSchemaVersion(): number;
|
|
117
120
|
configFingerprint(): string;
|
|
121
|
+
createDesignSystemManifest(input: DesignSystemManifestInput): DesignSystemManifest;
|
|
122
|
+
designSystemManifestSchemaVersion(): number;
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
/**
|
|
@@ -136,16 +141,20 @@ declare class WasmCompiler {
|
|
|
136
141
|
* ```
|
|
137
142
|
*/
|
|
138
143
|
|
|
139
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* `configCallbacks` carry construction-time `utility.values` resolvers.
|
|
146
|
+
*/
|
|
140
147
|
interface WasmFromConfigOptions {
|
|
141
148
|
configCallbacks?: {
|
|
142
|
-
utilityValues?: Record<string,
|
|
149
|
+
utilityValues?: Record<string, UtilityValuesCallback>;
|
|
143
150
|
};
|
|
144
151
|
}
|
|
145
|
-
/**
|
|
146
|
-
*
|
|
152
|
+
/**
|
|
153
|
+
* The raw wasm instance - superset of {@link Compiler} carrying the internal
|
|
154
|
+
* `tokenDictionary` the facade hides.
|
|
155
|
+
*/
|
|
147
156
|
interface RawWasmCompiler extends WasmCompiler {
|
|
148
|
-
|
|
157
|
+
tokenDictionary?(): TokenDictionaryInput | undefined;
|
|
149
158
|
}
|
|
150
159
|
interface WasmModule {
|
|
151
160
|
WasmFileSystem: new () => WasmFileSystem;
|
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
|
}
|
|
@@ -77,25 +81,46 @@ function build(mod, config, callbacks, hooks) {
|
|
|
77
81
|
assertProjectHooks(hooks, callbacks);
|
|
78
82
|
const prepared = prepareCompilerConfig(config);
|
|
79
83
|
const compiler = mod.WasmCompiler.fromConfig(fs, prepared, buildFromConfigOptions(callbacks));
|
|
80
|
-
registerCallbacks(compiler, callbacks, hooks, compiler.
|
|
81
|
-
compiler
|
|
82
|
-
Object.defineProperty(compiler, "
|
|
83
|
-
|
|
84
|
+
registerCallbacks(compiler, callbacks, hooks, compiler.tokenDictionary?.());
|
|
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.20",
|
|
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-beta.
|
|
41
|
+
"@pandacss/compiler-shared": "2.0.0-beta.20",
|
|
42
|
+
"@pandacss/types": "2.0.0-beta.20"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@pandacss/config": "2.0.0-beta.
|
|
45
|
+
"@pandacss/config": "2.0.0-beta.20"
|
|
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
|
}
|