@pandacss/compiler-wasm 2.0.0-beta.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/LICENSE.md +21 -0
- package/README.md +14 -0
- package/dist/chunk-R2J25HLY.js +108 -0
- package/dist/index.d.ts +222 -0
- package/dist/index.js +93 -0
- package/dist/web-Z44NGLTK.js +12 -0
- package/dist/web.d.ts +166 -0
- package/dist/web.js +107 -0
- package/package.json +54 -0
- package/pkg-node/compiler_wasm.d.ts +381 -0
- package/pkg-node/compiler_wasm.js +1788 -0
- package/pkg-node/compiler_wasm_bg.wasm +0 -0
- package/pkg-node/compiler_wasm_bg.wasm.d.ts +68 -0
- package/pkg-node/package.json +3 -0
- package/pkg-web/compiler_wasm.d.ts +474 -0
- package/pkg-web/compiler_wasm.js +1879 -0
- package/pkg-web/compiler_wasm_bg.wasm +0 -0
- package/pkg-web/compiler_wasm_bg.wasm.d.ts +68 -0
- package/pkg-web/package.json +3 -0
package/dist/web.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// src/web.ts
|
|
2
|
+
import {
|
|
3
|
+
assertProjectCallbacks,
|
|
4
|
+
assertProjectHooks,
|
|
5
|
+
getTokenCategoryValues,
|
|
6
|
+
makeBuildInfoApi,
|
|
7
|
+
mergeCallbacks,
|
|
8
|
+
prepareCompilerConfig
|
|
9
|
+
} from "@pandacss/compiler-shared";
|
|
10
|
+
|
|
11
|
+
// src/callbacks.ts
|
|
12
|
+
import {
|
|
13
|
+
createPatternHelpers,
|
|
14
|
+
createTransformArgs,
|
|
15
|
+
getPatternDefaultValueRefsByTransformId,
|
|
16
|
+
mergePatternDefaultValues
|
|
17
|
+
} from "@pandacss/compiler-shared";
|
|
18
|
+
function registerCallbacks(project, callbacks, hooks, tokenDictionary) {
|
|
19
|
+
const utilityTransforms = callbacks["utility.transform"];
|
|
20
|
+
if (utilityTransforms && Object.keys(utilityTransforms).length > 0 && !project.registerUtilityTransform) {
|
|
21
|
+
throw new Error("WASM project does not support utility.transform callbacks");
|
|
22
|
+
}
|
|
23
|
+
if (project.registerUtilityTransform && utilityTransforms && Object.keys(utilityTransforms).length > 0) {
|
|
24
|
+
for (const [id, callback] of Object.entries(utilityTransforms)) {
|
|
25
|
+
project.registerUtilityTransform(id, (resolved, original) => {
|
|
26
|
+
return callback(resolved, createTransformArgs(original, tokenDictionary));
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const patternTransforms = callbacks["pattern.transform"];
|
|
31
|
+
if (patternTransforms && Object.keys(patternTransforms).length > 0 && !project.registerPatternTransform) {
|
|
32
|
+
throw new Error("WASM project does not support pattern.transform callbacks");
|
|
33
|
+
}
|
|
34
|
+
const config = project.config();
|
|
35
|
+
const patternDefaultValues = callbacks["pattern.defaultValues"];
|
|
36
|
+
const patternDefaultValueRefs = config && patternDefaultValues ? getPatternDefaultValueRefsByTransformId(config) : /* @__PURE__ */ new Map();
|
|
37
|
+
if (project.registerPatternTransform && patternTransforms && Object.keys(patternTransforms).length > 0) {
|
|
38
|
+
for (const [id, callback] of Object.entries(patternTransforms)) {
|
|
39
|
+
const defaultValueId = patternDefaultValueRefs.get(id);
|
|
40
|
+
const defaultValue = defaultValueId ? patternDefaultValues?.[defaultValueId] : void 0;
|
|
41
|
+
project.registerPatternTransform(id, (props) => {
|
|
42
|
+
const input = props;
|
|
43
|
+
const nextProps = defaultValue ? mergePatternDefaultValues(defaultValue(input), input) : input;
|
|
44
|
+
return callback(nextProps, createPatternHelpers());
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const sourceTransforms = hooks?.["parser:before"];
|
|
49
|
+
if (sourceTransforms?.length && !project.registerSourceTransform) {
|
|
50
|
+
throw new Error("WASM project does not support parser:before callbacks");
|
|
51
|
+
}
|
|
52
|
+
if (project.registerSourceTransform && sourceTransforms) {
|
|
53
|
+
for (const hook of sourceTransforms) {
|
|
54
|
+
const callback = callbacks["parser:before"]?.[hook.id];
|
|
55
|
+
if (!callback) continue;
|
|
56
|
+
project.registerSourceTransform(hook.id, hook.filter, (filePath, content) => {
|
|
57
|
+
const result = callback({ filePath: String(filePath), content: String(content), original: String(content) });
|
|
58
|
+
if (isPromiseLike(result)) {
|
|
59
|
+
throw new Error(`parser:before callback \`${hook.id}\` must be synchronous`);
|
|
60
|
+
}
|
|
61
|
+
return typeof result === "string" ? result : void 0;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function isPromiseLike(value) {
|
|
67
|
+
return !!value && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/web.ts
|
|
71
|
+
function createCompilerFromWasmModule(mod, config, options) {
|
|
72
|
+
return build(mod, config, options?.callbacks ?? {}, options?.hooks);
|
|
73
|
+
}
|
|
74
|
+
function build(mod, config, callbacks, hooks) {
|
|
75
|
+
const fs = new mod.WasmFileSystem();
|
|
76
|
+
assertProjectCallbacks(config, callbacks);
|
|
77
|
+
assertProjectHooks(hooks, callbacks);
|
|
78
|
+
const prepared = prepareCompilerConfig(config);
|
|
79
|
+
const compiler = mod.WasmCompiler.fromConfig(fs, prepared, buildFromConfigOptions(callbacks));
|
|
80
|
+
registerCallbacks(compiler, callbacks, hooks, compiler.token_dictionary?.());
|
|
81
|
+
compiler.fs = fs;
|
|
82
|
+
Object.defineProperty(compiler, "buildInfo", {
|
|
83
|
+
value: makeBuildInfoApi(compiler),
|
|
84
|
+
enumerable: false
|
|
85
|
+
});
|
|
86
|
+
return compiler;
|
|
87
|
+
}
|
|
88
|
+
function buildFromConfigOptions(callbacks) {
|
|
89
|
+
const utilityValues = callbacks["utility.values"];
|
|
90
|
+
if (!utilityValues || Object.keys(utilityValues).length === 0) return void 0;
|
|
91
|
+
return {
|
|
92
|
+
configCallbacks: {
|
|
93
|
+
utilityValues: Object.fromEntries(
|
|
94
|
+
Object.entries(utilityValues).map(([id, callback]) => [
|
|
95
|
+
id,
|
|
96
|
+
(tokenDictionary) => callback((category) => getTokenCategoryValues(category, tokenDictionary))
|
|
97
|
+
])
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
build,
|
|
104
|
+
buildFromConfigOptions,
|
|
105
|
+
createCompilerFromWasmModule,
|
|
106
|
+
mergeCallbacks
|
|
107
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pandacss/compiler-wasm",
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
|
+
"description": "WebAssembly binding for the Panda compiler engine (browser/playground target)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"source": "./src/index.ts",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./web": {
|
|
15
|
+
"source": "./src/web.ts",
|
|
16
|
+
"types": "./dist/web.d.ts",
|
|
17
|
+
"default": "./dist/web.js"
|
|
18
|
+
},
|
|
19
|
+
"./pkg-node/*": "./pkg-node/*",
|
|
20
|
+
"./pkg-web/*": "./pkg-web/*",
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"author": "Segun Adebayo <joseshegs@gmail.com>",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"homepage": "https://panda-css.com",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/chakra-ui/panda.git",
|
|
30
|
+
"directory": "packages/compiler-wasm"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"pkg-node",
|
|
38
|
+
"pkg-web"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@pandacss/compiler-shared": "2.0.0-beta.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@pandacss/config": "2.0.0-beta.0"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "pnpm build:wasm && pnpm build:js",
|
|
48
|
+
"build:js": "tsup",
|
|
49
|
+
"build:fast": "tsup --no-dts",
|
|
50
|
+
"build:wasm": "tsx build-wasm.ts",
|
|
51
|
+
"dev": "pnpm build:fast --watch",
|
|
52
|
+
"test": "vitest run"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* JS-facing project handle. Constructed once per session with a
|
|
6
|
+
* [`WasmFileSystem`] (whose contents the cross-file resolver reads),
|
|
7
|
+
* plus a resolved Panda config snapshot.
|
|
8
|
+
*
|
|
9
|
+
* ```js
|
|
10
|
+
* const fs = new WasmFileSystem()
|
|
11
|
+
* fs.addFile('/proj/tokens.ts', "export const brand = '#ef4444';")
|
|
12
|
+
* fs.addFile('/proj/main.tsx', "import { brand } from './tokens'\ncss({ color: brand })")
|
|
13
|
+
* const compiler = WasmCompiler.fromConfig(fs, config)
|
|
14
|
+
* project.parseFile('/proj/main.tsx', fs.readFile('/proj/main.tsx'))
|
|
15
|
+
* const atoms = project.atoms()
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export class WasmCompiler {
|
|
19
|
+
private constructor();
|
|
20
|
+
free(): void;
|
|
21
|
+
[Symbol.dispose](): void;
|
|
22
|
+
/**
|
|
23
|
+
* Hydrate an external build info into this project (additive), optionally
|
|
24
|
+
* restricted to imported modules (tree-shaking). Returns `false` on a
|
|
25
|
+
* schema-version mismatch.
|
|
26
|
+
*
|
|
27
|
+
* # Errors
|
|
28
|
+
* Returns a JS error if `build_info` isn't a valid build-info document.
|
|
29
|
+
*/
|
|
30
|
+
applyBuildInfo(name: string, build_info: any, only: any): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Deduplicated atoms across every currently-known file, sorted by
|
|
33
|
+
* `(prop, conditions, value)` for stable iteration.
|
|
34
|
+
*
|
|
35
|
+
* # Errors
|
|
36
|
+
* Returns a JS error if serializing the atom array fails.
|
|
37
|
+
*/
|
|
38
|
+
atoms(): any;
|
|
39
|
+
/**
|
|
40
|
+
* The build-info wire-format version this binding reads/writes.
|
|
41
|
+
*/
|
|
42
|
+
buildInfoSchemaVersion(): number;
|
|
43
|
+
/**
|
|
44
|
+
* Drop every path's state. Keeps the config-derived extractor,
|
|
45
|
+
* token dictionary, and cross-file resolver intact.
|
|
46
|
+
*/
|
|
47
|
+
clear(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Compile to CSS. Mirrors the NAPI `Project.compile()`.
|
|
50
|
+
*
|
|
51
|
+
* # Errors
|
|
52
|
+
* Returns a JS error if serializing fails.
|
|
53
|
+
*/
|
|
54
|
+
compile(options?: any | null): any;
|
|
55
|
+
/**
|
|
56
|
+
* Return the serialized config snapshot this project was constructed
|
|
57
|
+
* with.
|
|
58
|
+
*
|
|
59
|
+
* # Errors
|
|
60
|
+
* Returns a JS error if serializing fails.
|
|
61
|
+
*/
|
|
62
|
+
config(): any;
|
|
63
|
+
/**
|
|
64
|
+
* Engine-owned fingerprint of the resolved config's output-affecting fields,
|
|
65
|
+
* stamped into build info as `configFingerprint`.
|
|
66
|
+
*/
|
|
67
|
+
configFingerprint(): string;
|
|
68
|
+
/**
|
|
69
|
+
* Config validation diagnostics from construction.
|
|
70
|
+
*
|
|
71
|
+
* # Errors
|
|
72
|
+
* Returns a JS error if serializing fails.
|
|
73
|
+
*/
|
|
74
|
+
diagnostics(): any;
|
|
75
|
+
dirname(path: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Encoded config recipe styles, separate from atomic utility atoms.
|
|
78
|
+
*
|
|
79
|
+
* # Errors
|
|
80
|
+
* Returns a JS error if serializing fails.
|
|
81
|
+
*/
|
|
82
|
+
encodedRecipes(): any;
|
|
83
|
+
/**
|
|
84
|
+
* Stateless single-file extraction — raw `{ calls, jsx, diagnostics }`,
|
|
85
|
+
* using the project's configured matchers + token dictionary. Unlike
|
|
86
|
+
* `parseFile`, it registers nothing; it's the read-only peek companion.
|
|
87
|
+
*
|
|
88
|
+
* # Errors
|
|
89
|
+
* Returns a JS error string when serializing the result fails.
|
|
90
|
+
*/
|
|
91
|
+
extractFileSource(path: string, source: string): any;
|
|
92
|
+
/**
|
|
93
|
+
* `(path, hex source_hash)` for every known file, sorted by path.
|
|
94
|
+
*
|
|
95
|
+
* # Errors
|
|
96
|
+
* Returns a JS error if serializing fails.
|
|
97
|
+
*/
|
|
98
|
+
fileManifest(): any;
|
|
99
|
+
/**
|
|
100
|
+
* Construct a compiler from the resolved, JSON-safe Panda config snapshot.
|
|
101
|
+
*
|
|
102
|
+
* # Errors
|
|
103
|
+
* Returns a JS error when `config` doesn't deserialize into JSON.
|
|
104
|
+
*/
|
|
105
|
+
static fromConfig(fs: WasmFileSystem, config: any, options: any): WasmCompiler;
|
|
106
|
+
/**
|
|
107
|
+
* Generate artifacts affected by the provided config dependency names.
|
|
108
|
+
*
|
|
109
|
+
* # Errors
|
|
110
|
+
* Returns a JS error if dependencies/options are invalid or serializing fails.
|
|
111
|
+
*/
|
|
112
|
+
generateAffectedArtifacts(dependencies: any, options: any): any;
|
|
113
|
+
/**
|
|
114
|
+
* Generate one codegen artifact by id.
|
|
115
|
+
*
|
|
116
|
+
* # Errors
|
|
117
|
+
* Returns a JS error if the id/options are invalid or serializing fails.
|
|
118
|
+
*/
|
|
119
|
+
generateArtifact(id: string, options: any): any;
|
|
120
|
+
/**
|
|
121
|
+
* Generate every codegen artifact from the resolved project state.
|
|
122
|
+
*
|
|
123
|
+
* # Errors
|
|
124
|
+
* Returns a JS error if options are invalid or serializing fails.
|
|
125
|
+
*/
|
|
126
|
+
generateArtifacts(options: any): any;
|
|
127
|
+
/**
|
|
128
|
+
* Per-file view; returns `null` when `path` isn't known.
|
|
129
|
+
*
|
|
130
|
+
* # Errors
|
|
131
|
+
* Returns a JS error if serializing fails.
|
|
132
|
+
*/
|
|
133
|
+
getFile(path: string): any;
|
|
134
|
+
/**
|
|
135
|
+
* Whether `css` declares Panda's cascade layers (`@layer reset, base, …;`),
|
|
136
|
+
* marking it as the stylesheet root to inject the compiled CSS into.
|
|
137
|
+
*/
|
|
138
|
+
hasLayerDeclaration(css: string): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Stateless source inspection for tooling (reporting, lint, IDE). Returns
|
|
141
|
+
* classified Panda usage sites plus file-local extraction diagnostics.
|
|
142
|
+
*
|
|
143
|
+
* # Errors
|
|
144
|
+
* Returns a JS error if serialization fails.
|
|
145
|
+
*/
|
|
146
|
+
inspectFileSource(path: string, source: string): any;
|
|
147
|
+
/**
|
|
148
|
+
* Returns `true` when the project has no files and no accumulated output.
|
|
149
|
+
*/
|
|
150
|
+
isEmpty(): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Whether `path` is a source file the project extracts from — its
|
|
153
|
+
* `cwd`-relative form matches the configured `include`/`exclude` globs.
|
|
154
|
+
*/
|
|
155
|
+
isSourceFile(path: string): boolean;
|
|
156
|
+
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
|
+
/**
|
|
163
|
+
* The resolved cascade-layer names (config overrides merged over defaults).
|
|
164
|
+
*
|
|
165
|
+
* # Errors
|
|
166
|
+
* Returns a JS error if serializing fails.
|
|
167
|
+
*/
|
|
168
|
+
layers(): any;
|
|
169
|
+
/**
|
|
170
|
+
* Read a source file from the in-memory filesystem and parse it.
|
|
171
|
+
*
|
|
172
|
+
* # Errors
|
|
173
|
+
* Returns a JS error if serializing the per-call report fails.
|
|
174
|
+
*/
|
|
175
|
+
parseFile(path: string): any;
|
|
176
|
+
/**
|
|
177
|
+
* Extract + encode provided source text. Replaces any prior contribution
|
|
178
|
+
* from `path`.
|
|
179
|
+
*
|
|
180
|
+
* # Errors
|
|
181
|
+
* Returns a JS error if serializing the per-call report fails.
|
|
182
|
+
*/
|
|
183
|
+
parseFileSource(path: string, source: string): any;
|
|
184
|
+
/**
|
|
185
|
+
* Read + parse source paths returned from `scan()`. Returns one report per
|
|
186
|
+
* successfully parsed path.
|
|
187
|
+
*
|
|
188
|
+
* # Errors
|
|
189
|
+
* Returns a JS error when `paths` is malformed or serializing the report fails.
|
|
190
|
+
*/
|
|
191
|
+
parseFiles(paths: any): any;
|
|
192
|
+
/**
|
|
193
|
+
* Real on-disk path (symlinks followed) from the in-memory filesystem, so two
|
|
194
|
+
* paths to the same file compare equal. Returns the input when unresolved.
|
|
195
|
+
*/
|
|
196
|
+
realpath(path: string): string;
|
|
197
|
+
/**
|
|
198
|
+
* Every `cva()` recipe entry in `(file, span_start)` order.
|
|
199
|
+
*
|
|
200
|
+
* # Errors
|
|
201
|
+
* Returns a JS error if serializing fails.
|
|
202
|
+
*/
|
|
203
|
+
recipes(): any;
|
|
204
|
+
/**
|
|
205
|
+
* Re-read `path` from the in-memory filesystem and re-parse it only if
|
|
206
|
+
* already known. Returns `true` when the file was present and got
|
|
207
|
+
* re-parsed.
|
|
208
|
+
*/
|
|
209
|
+
refreshFile(path: string): boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Re-parse provided source text only if `path` is already known.
|
|
212
|
+
*/
|
|
213
|
+
refreshFileSource(path: string, source: string): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Register a JS-backed pattern transform callback. The wrapper package
|
|
216
|
+
* installs callbacks referenced by the serialized config snapshot.
|
|
217
|
+
*/
|
|
218
|
+
registerPatternTransform(id: string, callback: Function): void;
|
|
219
|
+
/**
|
|
220
|
+
* Register a JS-backed `parser:before` source transform with a Rust-side
|
|
221
|
+
* filter. The filter is evaluated before calling into JS.
|
|
222
|
+
*/
|
|
223
|
+
registerSourceTransform(id: string, filter: any, callback: Function): void;
|
|
224
|
+
/**
|
|
225
|
+
* Register a JS-backed utility transform callback. The JS package wraps
|
|
226
|
+
* the user callback so Rust only has to pass the raw value.
|
|
227
|
+
*/
|
|
228
|
+
registerUtilityTransform(id: string, callback: Function): void;
|
|
229
|
+
/**
|
|
230
|
+
* Drop a file's contribution. Returns `true` if the path was known.
|
|
231
|
+
*/
|
|
232
|
+
removeFile(path: string): boolean;
|
|
233
|
+
resolvePath(path: string, cwd?: string | null): string;
|
|
234
|
+
/**
|
|
235
|
+
* Source paths matching the config's `include`/`exclude` (overridable via
|
|
236
|
+
* `options`) from the in-memory filesystem. For discovery and the host's
|
|
237
|
+
* watch list.
|
|
238
|
+
*
|
|
239
|
+
* # Errors
|
|
240
|
+
* Returns a JS error when `options` is malformed or the scan fails.
|
|
241
|
+
*/
|
|
242
|
+
scan(options: any): any;
|
|
243
|
+
/**
|
|
244
|
+
* Serialize the project's encoded atoms + recipes into a portable build info
|
|
245
|
+
* (the `panda buildinfo` producer). `configFingerprint` is engine-owned; the
|
|
246
|
+
* caller supplies only the published `panda` peer range.
|
|
247
|
+
*
|
|
248
|
+
* # Errors
|
|
249
|
+
* Returns a JS error if serializing the build info fails.
|
|
250
|
+
*/
|
|
251
|
+
serializeBuildInfo(panda: string): any;
|
|
252
|
+
/**
|
|
253
|
+
* Every `sva()` slot-recipe entry.
|
|
254
|
+
*
|
|
255
|
+
* # Errors
|
|
256
|
+
* Returns a JS error if serializing fails.
|
|
257
|
+
*/
|
|
258
|
+
slotRecipes(): any;
|
|
259
|
+
/**
|
|
260
|
+
* Source globs + their static base dirs (for the host watcher).
|
|
261
|
+
*
|
|
262
|
+
* # Errors
|
|
263
|
+
* Returns a JS error if serialization fails.
|
|
264
|
+
*/
|
|
265
|
+
sources(): any;
|
|
266
|
+
/**
|
|
267
|
+
* Tooling introspection snapshot (read once, index on the host).
|
|
268
|
+
*
|
|
269
|
+
* # Errors
|
|
270
|
+
* Returns a JS error if the snapshot fails to serialize.
|
|
271
|
+
*/
|
|
272
|
+
spec(): any;
|
|
273
|
+
/**
|
|
274
|
+
* Split the stylesheet into per-file outputs (one per layer + per recipe,
|
|
275
|
+
* plus `recipes.css` / `styles.css` index files) for `--splitting`.
|
|
276
|
+
*
|
|
277
|
+
* # Errors
|
|
278
|
+
* Returns a JS error if serializing fails.
|
|
279
|
+
*/
|
|
280
|
+
splitCss(): any;
|
|
281
|
+
/**
|
|
282
|
+
* `staticCss.patterns` expansion as raw atoms, without compiling.
|
|
283
|
+
*
|
|
284
|
+
* # Errors
|
|
285
|
+
* Returns a JS error if serializing fails.
|
|
286
|
+
*/
|
|
287
|
+
staticPatternAtoms(): any;
|
|
288
|
+
/**
|
|
289
|
+
* Aggregate counts.
|
|
290
|
+
*
|
|
291
|
+
* # Errors
|
|
292
|
+
* Returns a JS error if serializing fails.
|
|
293
|
+
*/
|
|
294
|
+
summary(): any;
|
|
295
|
+
/**
|
|
296
|
+
* Rust-built token dictionary projected into the small JS interop shape.
|
|
297
|
+
*/
|
|
298
|
+
token_dictionary(): any;
|
|
299
|
+
/**
|
|
300
|
+
* Generate artifacts and write them under `outdir` via the in-memory fs.
|
|
301
|
+
* Returns the written paths.
|
|
302
|
+
*
|
|
303
|
+
* # Errors
|
|
304
|
+
* Returns a JS error if a file fails to write or results fail to serialize.
|
|
305
|
+
*/
|
|
306
|
+
writeArtifacts(outdir: string, cwd: string | null | undefined, options: any): any;
|
|
307
|
+
writeCss(outfile: string, cwd?: string | null, options?: any | null): any;
|
|
308
|
+
writeSplitCss(outdir: string, cwd?: string | null): any;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* JS-facing extractor handle. Constructed once per session with a
|
|
313
|
+
* [`WasmFileSystem`] handle and a `MatchersInput`; the cross-file
|
|
314
|
+
* resolver is wired up automatically against the same FS.
|
|
315
|
+
*
|
|
316
|
+
* ```js
|
|
317
|
+
* const fs = new WasmFileSystem();
|
|
318
|
+
* fs.addFile('/src/code.tsx', '...');
|
|
319
|
+
* const ext = new WasmExtractor(fs, matchers);
|
|
320
|
+
* const result = ext.parseFile('/src/code.tsx', source);
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
export class WasmExtractor {
|
|
324
|
+
free(): void;
|
|
325
|
+
[Symbol.dispose](): void;
|
|
326
|
+
/**
|
|
327
|
+
* Construct from a JS matchers object (see `MatchersInput`).
|
|
328
|
+
*
|
|
329
|
+
* # Errors
|
|
330
|
+
* Returns a JS error string when `matchers` doesn't deserialize
|
|
331
|
+
* into a `MatchersInput` shape.
|
|
332
|
+
*/
|
|
333
|
+
constructor(fs: WasmFileSystem, matchers: any);
|
|
334
|
+
/**
|
|
335
|
+
* Single-file extract. Returns the lean `ExtractUsage` shape as a
|
|
336
|
+
* plain JS object (`{ calls, jsx, diagnostics }`).
|
|
337
|
+
*
|
|
338
|
+
* # Errors
|
|
339
|
+
* Returns a JS error string when serializing the result to `JsValue`
|
|
340
|
+
* fails (effectively never — the shape is bounded JSON).
|
|
341
|
+
*/
|
|
342
|
+
parseFile(path: string, source: string): any;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* JS-facing handle over [`MemoryFileSystem`]. Cheap to clone — shares
|
|
347
|
+
* state via `Arc<RwLock>` internally — so the JS host can pass the same
|
|
348
|
+
* handle into multiple `WasmExtractor` instances and edits flow through
|
|
349
|
+
* to all consumers.
|
|
350
|
+
*/
|
|
351
|
+
export class WasmFileSystem {
|
|
352
|
+
free(): void;
|
|
353
|
+
[Symbol.dispose](): void;
|
|
354
|
+
/**
|
|
355
|
+
* Write or overwrite a file. Parent dirs auto-register.
|
|
356
|
+
*/
|
|
357
|
+
addFile(path: string, content: string): void;
|
|
358
|
+
/**
|
|
359
|
+
* `true` when `path` exists as file or directory.
|
|
360
|
+
*/
|
|
361
|
+
exists(path: string): boolean;
|
|
362
|
+
/**
|
|
363
|
+
* Number of files stored. Convenience for diagnostics / tests.
|
|
364
|
+
*/
|
|
365
|
+
fileCount(): number;
|
|
366
|
+
constructor();
|
|
367
|
+
/**
|
|
368
|
+
* Read a file. Returns `undefined` when missing.
|
|
369
|
+
*/
|
|
370
|
+
readFile(path: string): string | undefined;
|
|
371
|
+
/**
|
|
372
|
+
* `true` when the file existed and was removed.
|
|
373
|
+
*/
|
|
374
|
+
removeFile(path: string): boolean;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Install a panic hook so Rust panics surface as readable stack traces in
|
|
379
|
+
* the browser console. Idempotent — safe to call multiple times.
|
|
380
|
+
*/
|
|
381
|
+
export function installPanicHook(): void;
|