@omena/wasm 0.2.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/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # omena-wasm
2
+
3
+ `omena-wasm` exposes the first browser-side binding for the Omena CSS
4
+ workspace. The binding consumes `omena-query` as the public Rust facade and
5
+ keeps parser and transform crates behind that boundary.
6
+
7
+ The current API is intentionally in-memory:
8
+
9
+ - `checkStyleSource(source, path)` checks CSS-family source text and returns
10
+ query-owned parser facts.
11
+ - `buildStyleSource(source, path, passIds)` runs conservative transform passes
12
+ and returns the execution summary plus output CSS.
13
+ - `buildStyleSourceWithContext(source, path, passIds, context)` accepts
14
+ explicit evaluator/provenance context and returns the execution summary plus
15
+ output CSS.
16
+ - `buildStyleSourceForTargetQuery(source, path, targetQuery)` plans
17
+ conservative target-sensitive passes from a Browserslist query or named
18
+ target profile.
19
+ - `buildStyleSourceForTargetQueryWithOptions(source, path, targetQuery,
20
+ targetOptions)` accepts camelCase target transform options for explicit
21
+ lowering opt-ins.
22
+ - `buildStyleSourceForTargetQueryWithContext(source, path, targetQuery,
23
+ targetOptions, context)` combines target planning with explicit evaluator
24
+ context, including dart-sass-compatible SCSS output.
25
+ - `buildStyleSourcesWithContext(targetPath, sources, passIds, context,
26
+ packageManifests)` derives import/composes context from an in-memory workspace
27
+ source array, merges explicit evaluator/provenance context, and returns an
28
+ execution summary plus output CSS.
29
+ - `buildStyleSourcesForTargetQueryWithContext(targetPath, sources, targetQuery,
30
+ targetOptions, context, packageManifests)` combines target planning with
31
+ workspace-derived import/composes context.
32
+ - `readCascadeAtPosition(source, path, line, character, input)` reads cascade,
33
+ computed-value, and custom-property LFP information at a `var(...)` reference
34
+ position. Pass `null` or `undefined` for `input` when no EngineInputV2 context
35
+ is needed.
36
+ - `readStyleContextIndex(source, path, input)` reads query-owned `@layer`,
37
+ `@container`, and `@scope` context indexes. Pass `null` or `undefined` for
38
+ `input` when no EngineInputV2 context is needed.
39
+ - `readStyleDiagnostics(source, path)` reads query-owned style diagnostics for
40
+ a CSS-family file.
41
+ - `readStyleHoverCandidates(source, path)` reads query-owned style hover
42
+ candidates for a CSS-family file.
43
+ - `readStyleCompletionAtPosition(source, path, line, character)` reads
44
+ query-owned style completions at a source position.
45
+ - `readSourceDiagnostics(sourceUri, candidates)` reads query-owned source
46
+ diagnostics from precomputed missing-selector candidates.
47
+ - `expressionDomainIncrementalFlow(input)` runs one query-owned
48
+ expression-domain incremental-flow pass for simple browser clients.
49
+ - `new ExpressionDomainFlowRuntime().analyze(input)` keeps the query-owned
50
+ incremental-flow runtime alive across calls so browser clients can observe
51
+ graph reuse.
52
+ - `expressionDomainSelectorProjection(input)` projects expression-domain flow
53
+ values to target style selectors.
54
+ - `listTransformPasses()` lists transform pass ids accepted by
55
+ `buildStyleSource`.
56
+
57
+ This crate does not read from the filesystem and does not provide the Node or
58
+ LSP integration layer. Those stay in native consumer crates.
@@ -0,0 +1,51 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class ExpressionDomainFlowRuntime {
5
+ free(): void;
6
+ [Symbol.dispose](): void;
7
+ analyze(input: any): any;
8
+ constructor();
9
+ }
10
+
11
+ export function buildStyleSource(source: string, path: string, pass_ids: any): any;
12
+
13
+ export function buildStyleSourceForTargetQuery(source: string, path: string, target_query: string): any;
14
+
15
+ export function buildStyleSourceForTargetQueryWithContext(source: string, path: string, target_query: string, target_options: any, context: any): any;
16
+
17
+ export function buildStyleSourceForTargetQueryWithOptions(source: string, path: string, target_query: string, target_options: any): any;
18
+
19
+ export function buildStyleSourceWithContext(source: string, path: string, pass_ids: any, context: any): any;
20
+
21
+ export function buildStyleSourceWithEngineInputContext(source: string, path: string, pass_ids: any, input: any, closed_style_world: boolean): any;
22
+
23
+ export function buildStyleSourcesForTargetQueryWithContext(target_path: string, sources: any, target_query: string, target_options: any, context: any, package_manifests: any): any;
24
+
25
+ export function buildStyleSourcesWithContext(target_path: string, sources: any, pass_ids: any, context: any, package_manifests: any): any;
26
+
27
+ export function checkStyleSource(source: string, path: string): any;
28
+
29
+ export function expressionDomainIncrementalFlow(input: any): any;
30
+
31
+ export function expressionDomainSelectorProjection(input: any): any;
32
+
33
+ export function listTransformPasses(): any;
34
+
35
+ export function readCascadeAtPosition(source: string, path: string, line: number, character: number, input: any): any;
36
+
37
+ export function readSourceDiagnostics(source_uri: string, candidates: any): any;
38
+
39
+ export function readStyleCompletionAtPosition(source: string, path: string, line: number, character: number): any;
40
+
41
+ export function readStyleContextIndex(source: string, path: string, input: any): any;
42
+
43
+ export function readStyleDiagnostics(source: string, path: string): any;
44
+
45
+ export function readStyleHoverCandidates(source: string, path: string): any;
46
+
47
+ export function readWorkspaceSourceDiagnostics(source_uri: string, source: string, style_sources: any, package_manifests: any): any;
48
+
49
+ export function readWorkspaceStyleDiagnostics(target_path: string, sources: any, source_documents: any, package_manifests: any, external_sifs: any, external_mode?: string | null): any;
50
+
51
+ export function transformContextFromEngineInput(input: any, target_path: string, closed_style_world: boolean): any;
package/omena_wasm.js ADDED
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./omena_wasm.d.ts" */
2
+ import * as wasm from "./omena_wasm_bg.wasm";
3
+ import { __wbg_set_wasm } from "./omena_wasm_bg.js";
4
+
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ ExpressionDomainFlowRuntime, buildStyleSource, buildStyleSourceForTargetQuery, buildStyleSourceForTargetQueryWithContext, buildStyleSourceForTargetQueryWithOptions, buildStyleSourceWithContext, buildStyleSourceWithEngineInputContext, buildStyleSourcesForTargetQueryWithContext, buildStyleSourcesWithContext, checkStyleSource, expressionDomainIncrementalFlow, expressionDomainSelectorProjection, listTransformPasses, readCascadeAtPosition, readSourceDiagnostics, readStyleCompletionAtPosition, readStyleContextIndex, readStyleDiagnostics, readStyleHoverCandidates, readWorkspaceSourceDiagnostics, readWorkspaceStyleDiagnostics, transformContextFromEngineInput
9
+ } from "./omena_wasm_bg.js";
@@ -0,0 +1,862 @@
1
+ export class ExpressionDomainFlowRuntime {
2
+ __destroy_into_raw() {
3
+ const ptr = this.__wbg_ptr;
4
+ this.__wbg_ptr = 0;
5
+ ExpressionDomainFlowRuntimeFinalization.unregister(this);
6
+ return ptr;
7
+ }
8
+ free() {
9
+ const ptr = this.__destroy_into_raw();
10
+ wasm.__wbg_expressiondomainflowruntime_free(ptr, 0);
11
+ }
12
+ /**
13
+ * @param {any} input
14
+ * @returns {any}
15
+ */
16
+ analyze(input) {
17
+ const ret = wasm.expressiondomainflowruntime_analyze(this.__wbg_ptr, input);
18
+ if (ret[2]) {
19
+ throw takeFromExternrefTable0(ret[1]);
20
+ }
21
+ return takeFromExternrefTable0(ret[0]);
22
+ }
23
+ constructor() {
24
+ const ret = wasm.expressiondomainflowruntime_new();
25
+ this.__wbg_ptr = ret;
26
+ ExpressionDomainFlowRuntimeFinalization.register(this, this.__wbg_ptr, this);
27
+ return this;
28
+ }
29
+ }
30
+ if (Symbol.dispose) ExpressionDomainFlowRuntime.prototype[Symbol.dispose] = ExpressionDomainFlowRuntime.prototype.free;
31
+
32
+ /**
33
+ * @param {string} source
34
+ * @param {string} path
35
+ * @param {any} pass_ids
36
+ * @returns {any}
37
+ */
38
+ export function buildStyleSource(source, path, pass_ids) {
39
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
40
+ const len0 = WASM_VECTOR_LEN;
41
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
42
+ const len1 = WASM_VECTOR_LEN;
43
+ const ret = wasm.buildStyleSource(ptr0, len0, ptr1, len1, pass_ids);
44
+ if (ret[2]) {
45
+ throw takeFromExternrefTable0(ret[1]);
46
+ }
47
+ return takeFromExternrefTable0(ret[0]);
48
+ }
49
+
50
+ /**
51
+ * @param {string} source
52
+ * @param {string} path
53
+ * @param {string} target_query
54
+ * @returns {any}
55
+ */
56
+ export function buildStyleSourceForTargetQuery(source, path, target_query) {
57
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
58
+ const len0 = WASM_VECTOR_LEN;
59
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
60
+ const len1 = WASM_VECTOR_LEN;
61
+ const ptr2 = passStringToWasm0(target_query, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
62
+ const len2 = WASM_VECTOR_LEN;
63
+ const ret = wasm.buildStyleSourceForTargetQuery(ptr0, len0, ptr1, len1, ptr2, len2);
64
+ if (ret[2]) {
65
+ throw takeFromExternrefTable0(ret[1]);
66
+ }
67
+ return takeFromExternrefTable0(ret[0]);
68
+ }
69
+
70
+ /**
71
+ * @param {string} source
72
+ * @param {string} path
73
+ * @param {string} target_query
74
+ * @param {any} target_options
75
+ * @param {any} context
76
+ * @returns {any}
77
+ */
78
+ export function buildStyleSourceForTargetQueryWithContext(source, path, target_query, target_options, context) {
79
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
80
+ const len0 = WASM_VECTOR_LEN;
81
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
82
+ const len1 = WASM_VECTOR_LEN;
83
+ const ptr2 = passStringToWasm0(target_query, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
84
+ const len2 = WASM_VECTOR_LEN;
85
+ const ret = wasm.buildStyleSourceForTargetQueryWithContext(ptr0, len0, ptr1, len1, ptr2, len2, target_options, context);
86
+ if (ret[2]) {
87
+ throw takeFromExternrefTable0(ret[1]);
88
+ }
89
+ return takeFromExternrefTable0(ret[0]);
90
+ }
91
+
92
+ /**
93
+ * @param {string} source
94
+ * @param {string} path
95
+ * @param {string} target_query
96
+ * @param {any} target_options
97
+ * @returns {any}
98
+ */
99
+ export function buildStyleSourceForTargetQueryWithOptions(source, path, target_query, target_options) {
100
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
101
+ const len0 = WASM_VECTOR_LEN;
102
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
103
+ const len1 = WASM_VECTOR_LEN;
104
+ const ptr2 = passStringToWasm0(target_query, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
105
+ const len2 = WASM_VECTOR_LEN;
106
+ const ret = wasm.buildStyleSourceForTargetQueryWithOptions(ptr0, len0, ptr1, len1, ptr2, len2, target_options);
107
+ if (ret[2]) {
108
+ throw takeFromExternrefTable0(ret[1]);
109
+ }
110
+ return takeFromExternrefTable0(ret[0]);
111
+ }
112
+
113
+ /**
114
+ * @param {string} source
115
+ * @param {string} path
116
+ * @param {any} pass_ids
117
+ * @param {any} context
118
+ * @returns {any}
119
+ */
120
+ export function buildStyleSourceWithContext(source, path, pass_ids, context) {
121
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
122
+ const len0 = WASM_VECTOR_LEN;
123
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
124
+ const len1 = WASM_VECTOR_LEN;
125
+ const ret = wasm.buildStyleSourceWithContext(ptr0, len0, ptr1, len1, pass_ids, context);
126
+ if (ret[2]) {
127
+ throw takeFromExternrefTable0(ret[1]);
128
+ }
129
+ return takeFromExternrefTable0(ret[0]);
130
+ }
131
+
132
+ /**
133
+ * @param {string} source
134
+ * @param {string} path
135
+ * @param {any} pass_ids
136
+ * @param {any} input
137
+ * @param {boolean} closed_style_world
138
+ * @returns {any}
139
+ */
140
+ export function buildStyleSourceWithEngineInputContext(source, path, pass_ids, input, closed_style_world) {
141
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
142
+ const len0 = WASM_VECTOR_LEN;
143
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
144
+ const len1 = WASM_VECTOR_LEN;
145
+ const ret = wasm.buildStyleSourceWithEngineInputContext(ptr0, len0, ptr1, len1, pass_ids, input, closed_style_world);
146
+ if (ret[2]) {
147
+ throw takeFromExternrefTable0(ret[1]);
148
+ }
149
+ return takeFromExternrefTable0(ret[0]);
150
+ }
151
+
152
+ /**
153
+ * @param {string} target_path
154
+ * @param {any} sources
155
+ * @param {string} target_query
156
+ * @param {any} target_options
157
+ * @param {any} context
158
+ * @param {any} package_manifests
159
+ * @returns {any}
160
+ */
161
+ export function buildStyleSourcesForTargetQueryWithContext(target_path, sources, target_query, target_options, context, package_manifests) {
162
+ const ptr0 = passStringToWasm0(target_path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
163
+ const len0 = WASM_VECTOR_LEN;
164
+ const ptr1 = passStringToWasm0(target_query, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
165
+ const len1 = WASM_VECTOR_LEN;
166
+ const ret = wasm.buildStyleSourcesForTargetQueryWithContext(ptr0, len0, sources, ptr1, len1, target_options, context, package_manifests);
167
+ if (ret[2]) {
168
+ throw takeFromExternrefTable0(ret[1]);
169
+ }
170
+ return takeFromExternrefTable0(ret[0]);
171
+ }
172
+
173
+ /**
174
+ * @param {string} target_path
175
+ * @param {any} sources
176
+ * @param {any} pass_ids
177
+ * @param {any} context
178
+ * @param {any} package_manifests
179
+ * @returns {any}
180
+ */
181
+ export function buildStyleSourcesWithContext(target_path, sources, pass_ids, context, package_manifests) {
182
+ const ptr0 = passStringToWasm0(target_path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
183
+ const len0 = WASM_VECTOR_LEN;
184
+ const ret = wasm.buildStyleSourcesWithContext(ptr0, len0, sources, pass_ids, context, package_manifests);
185
+ if (ret[2]) {
186
+ throw takeFromExternrefTable0(ret[1]);
187
+ }
188
+ return takeFromExternrefTable0(ret[0]);
189
+ }
190
+
191
+ /**
192
+ * @param {string} source
193
+ * @param {string} path
194
+ * @returns {any}
195
+ */
196
+ export function checkStyleSource(source, path) {
197
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
198
+ const len0 = WASM_VECTOR_LEN;
199
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
200
+ const len1 = WASM_VECTOR_LEN;
201
+ const ret = wasm.checkStyleSource(ptr0, len0, ptr1, len1);
202
+ if (ret[2]) {
203
+ throw takeFromExternrefTable0(ret[1]);
204
+ }
205
+ return takeFromExternrefTable0(ret[0]);
206
+ }
207
+
208
+ /**
209
+ * @param {any} input
210
+ * @returns {any}
211
+ */
212
+ export function expressionDomainIncrementalFlow(input) {
213
+ const ret = wasm.expressionDomainIncrementalFlow(input);
214
+ if (ret[2]) {
215
+ throw takeFromExternrefTable0(ret[1]);
216
+ }
217
+ return takeFromExternrefTable0(ret[0]);
218
+ }
219
+
220
+ /**
221
+ * @param {any} input
222
+ * @returns {any}
223
+ */
224
+ export function expressionDomainSelectorProjection(input) {
225
+ const ret = wasm.expressionDomainSelectorProjection(input);
226
+ if (ret[2]) {
227
+ throw takeFromExternrefTable0(ret[1]);
228
+ }
229
+ return takeFromExternrefTable0(ret[0]);
230
+ }
231
+
232
+ /**
233
+ * @returns {any}
234
+ */
235
+ export function listTransformPasses() {
236
+ const ret = wasm.listTransformPasses();
237
+ if (ret[2]) {
238
+ throw takeFromExternrefTable0(ret[1]);
239
+ }
240
+ return takeFromExternrefTable0(ret[0]);
241
+ }
242
+
243
+ /**
244
+ * @param {string} source
245
+ * @param {string} path
246
+ * @param {number} line
247
+ * @param {number} character
248
+ * @param {any} input
249
+ * @returns {any}
250
+ */
251
+ export function readCascadeAtPosition(source, path, line, character, input) {
252
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
253
+ const len0 = WASM_VECTOR_LEN;
254
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
255
+ const len1 = WASM_VECTOR_LEN;
256
+ const ret = wasm.readCascadeAtPosition(ptr0, len0, ptr1, len1, line, character, input);
257
+ if (ret[2]) {
258
+ throw takeFromExternrefTable0(ret[1]);
259
+ }
260
+ return takeFromExternrefTable0(ret[0]);
261
+ }
262
+
263
+ /**
264
+ * @param {string} source_uri
265
+ * @param {any} candidates
266
+ * @returns {any}
267
+ */
268
+ export function readSourceDiagnostics(source_uri, candidates) {
269
+ const ptr0 = passStringToWasm0(source_uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
270
+ const len0 = WASM_VECTOR_LEN;
271
+ const ret = wasm.readSourceDiagnostics(ptr0, len0, candidates);
272
+ if (ret[2]) {
273
+ throw takeFromExternrefTable0(ret[1]);
274
+ }
275
+ return takeFromExternrefTable0(ret[0]);
276
+ }
277
+
278
+ /**
279
+ * @param {string} source
280
+ * @param {string} path
281
+ * @param {number} line
282
+ * @param {number} character
283
+ * @returns {any}
284
+ */
285
+ export function readStyleCompletionAtPosition(source, path, line, character) {
286
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
287
+ const len0 = WASM_VECTOR_LEN;
288
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
289
+ const len1 = WASM_VECTOR_LEN;
290
+ const ret = wasm.readStyleCompletionAtPosition(ptr0, len0, ptr1, len1, line, character);
291
+ if (ret[2]) {
292
+ throw takeFromExternrefTable0(ret[1]);
293
+ }
294
+ return takeFromExternrefTable0(ret[0]);
295
+ }
296
+
297
+ /**
298
+ * @param {string} source
299
+ * @param {string} path
300
+ * @param {any} input
301
+ * @returns {any}
302
+ */
303
+ export function readStyleContextIndex(source, path, input) {
304
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
305
+ const len0 = WASM_VECTOR_LEN;
306
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
307
+ const len1 = WASM_VECTOR_LEN;
308
+ const ret = wasm.readStyleContextIndex(ptr0, len0, ptr1, len1, input);
309
+ if (ret[2]) {
310
+ throw takeFromExternrefTable0(ret[1]);
311
+ }
312
+ return takeFromExternrefTable0(ret[0]);
313
+ }
314
+
315
+ /**
316
+ * @param {string} source
317
+ * @param {string} path
318
+ * @returns {any}
319
+ */
320
+ export function readStyleDiagnostics(source, path) {
321
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
322
+ const len0 = WASM_VECTOR_LEN;
323
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
324
+ const len1 = WASM_VECTOR_LEN;
325
+ const ret = wasm.readStyleDiagnostics(ptr0, len0, ptr1, len1);
326
+ if (ret[2]) {
327
+ throw takeFromExternrefTable0(ret[1]);
328
+ }
329
+ return takeFromExternrefTable0(ret[0]);
330
+ }
331
+
332
+ /**
333
+ * @param {string} source
334
+ * @param {string} path
335
+ * @returns {any}
336
+ */
337
+ export function readStyleHoverCandidates(source, path) {
338
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
339
+ const len0 = WASM_VECTOR_LEN;
340
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
341
+ const len1 = WASM_VECTOR_LEN;
342
+ const ret = wasm.readStyleHoverCandidates(ptr0, len0, ptr1, len1);
343
+ if (ret[2]) {
344
+ throw takeFromExternrefTable0(ret[1]);
345
+ }
346
+ return takeFromExternrefTable0(ret[0]);
347
+ }
348
+
349
+ /**
350
+ * @param {string} source_uri
351
+ * @param {string} source
352
+ * @param {any} style_sources
353
+ * @param {any} package_manifests
354
+ * @returns {any}
355
+ */
356
+ export function readWorkspaceSourceDiagnostics(source_uri, source, style_sources, package_manifests) {
357
+ const ptr0 = passStringToWasm0(source_uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
358
+ const len0 = WASM_VECTOR_LEN;
359
+ const ptr1 = passStringToWasm0(source, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
360
+ const len1 = WASM_VECTOR_LEN;
361
+ const ret = wasm.readWorkspaceSourceDiagnostics(ptr0, len0, ptr1, len1, style_sources, package_manifests);
362
+ if (ret[2]) {
363
+ throw takeFromExternrefTable0(ret[1]);
364
+ }
365
+ return takeFromExternrefTable0(ret[0]);
366
+ }
367
+
368
+ /**
369
+ * @param {string} target_path
370
+ * @param {any} sources
371
+ * @param {any} source_documents
372
+ * @param {any} package_manifests
373
+ * @param {any} external_sifs
374
+ * @param {string | null} [external_mode]
375
+ * @returns {any}
376
+ */
377
+ export function readWorkspaceStyleDiagnostics(target_path, sources, source_documents, package_manifests, external_sifs, external_mode) {
378
+ const ptr0 = passStringToWasm0(target_path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
379
+ const len0 = WASM_VECTOR_LEN;
380
+ var ptr1 = isLikeNone(external_mode) ? 0 : passStringToWasm0(external_mode, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
381
+ var len1 = WASM_VECTOR_LEN;
382
+ const ret = wasm.readWorkspaceStyleDiagnostics(ptr0, len0, sources, source_documents, package_manifests, external_sifs, ptr1, len1);
383
+ if (ret[2]) {
384
+ throw takeFromExternrefTable0(ret[1]);
385
+ }
386
+ return takeFromExternrefTable0(ret[0]);
387
+ }
388
+
389
+ /**
390
+ * @param {any} input
391
+ * @param {string} target_path
392
+ * @param {boolean} closed_style_world
393
+ * @returns {any}
394
+ */
395
+ export function transformContextFromEngineInput(input, target_path, closed_style_world) {
396
+ const ptr0 = passStringToWasm0(target_path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
397
+ const len0 = WASM_VECTOR_LEN;
398
+ const ret = wasm.transformContextFromEngineInput(input, ptr0, len0, closed_style_world);
399
+ if (ret[2]) {
400
+ throw takeFromExternrefTable0(ret[1]);
401
+ }
402
+ return takeFromExternrefTable0(ret[0]);
403
+ }
404
+ export function __wbg_Error_ef53bc310eb298a0(arg0, arg1) {
405
+ const ret = Error(getStringFromWasm0(arg0, arg1));
406
+ return ret;
407
+ }
408
+ export function __wbg_Number_6b506e6536831eaa(arg0) {
409
+ const ret = Number(arg0);
410
+ return ret;
411
+ }
412
+ export function __wbg_String_8564e559799eccda(arg0, arg1) {
413
+ const ret = String(arg1);
414
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
415
+ const len1 = WASM_VECTOR_LEN;
416
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
417
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
418
+ }
419
+ export function __wbg___wbindgen_bigint_get_as_i64_38130e98eecd467d(arg0, arg1) {
420
+ const v = arg1;
421
+ const ret = typeof(v) === 'bigint' ? v : undefined;
422
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
423
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
424
+ }
425
+ export function __wbg___wbindgen_boolean_get_1a45e2c38d4d41b9(arg0) {
426
+ const v = arg0;
427
+ const ret = typeof(v) === 'boolean' ? v : undefined;
428
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
429
+ }
430
+ export function __wbg___wbindgen_debug_string_0accd80f45e5faa2(arg0, arg1) {
431
+ const ret = debugString(arg1);
432
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
433
+ const len1 = WASM_VECTOR_LEN;
434
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
435
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
436
+ }
437
+ export function __wbg___wbindgen_in_70a403a56e771704(arg0, arg1) {
438
+ const ret = arg0 in arg1;
439
+ return ret;
440
+ }
441
+ export function __wbg___wbindgen_is_bigint_6ffd6468a9bc44b9(arg0) {
442
+ const ret = typeof(arg0) === 'bigint';
443
+ return ret;
444
+ }
445
+ export function __wbg___wbindgen_is_function_754e9f305ff6029e(arg0) {
446
+ const ret = typeof(arg0) === 'function';
447
+ return ret;
448
+ }
449
+ export function __wbg___wbindgen_is_null_87c3bfe968c6a5ad(arg0) {
450
+ const ret = arg0 === null;
451
+ return ret;
452
+ }
453
+ export function __wbg___wbindgen_is_object_56732c2bc353f41d(arg0) {
454
+ const val = arg0;
455
+ const ret = typeof(val) === 'object' && val !== null;
456
+ return ret;
457
+ }
458
+ export function __wbg___wbindgen_is_string_c236cabd84a4d769(arg0) {
459
+ const ret = typeof(arg0) === 'string';
460
+ return ret;
461
+ }
462
+ export function __wbg___wbindgen_is_undefined_67b456be8673d3d7(arg0) {
463
+ const ret = arg0 === undefined;
464
+ return ret;
465
+ }
466
+ export function __wbg___wbindgen_jsval_eq_1068e624fa87f6ab(arg0, arg1) {
467
+ const ret = arg0 === arg1;
468
+ return ret;
469
+ }
470
+ export function __wbg___wbindgen_jsval_loose_eq_2c56564c75129511(arg0, arg1) {
471
+ const ret = arg0 == arg1;
472
+ return ret;
473
+ }
474
+ export function __wbg___wbindgen_number_get_9bb1761122181af2(arg0, arg1) {
475
+ const obj = arg1;
476
+ const ret = typeof(obj) === 'number' ? obj : undefined;
477
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
478
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
479
+ }
480
+ export function __wbg___wbindgen_string_get_72bdf95d3ae505b1(arg0, arg1) {
481
+ const obj = arg1;
482
+ const ret = typeof(obj) === 'string' ? obj : undefined;
483
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
484
+ var len1 = WASM_VECTOR_LEN;
485
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
486
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
487
+ }
488
+ export function __wbg___wbindgen_throw_1506f2235d1bdba0(arg0, arg1) {
489
+ throw new Error(getStringFromWasm0(arg0, arg1));
490
+ }
491
+ export function __wbg_call_8a89609d89f6608a() { return handleError(function (arg0, arg1) {
492
+ const ret = arg0.call(arg1);
493
+ return ret;
494
+ }, arguments); }
495
+ export function __wbg_done_60cf307fcc680536(arg0) {
496
+ const ret = arg0.done;
497
+ return ret;
498
+ }
499
+ export function __wbg_entries_04b37a02507f1713(arg0) {
500
+ const ret = Object.entries(arg0);
501
+ return ret;
502
+ }
503
+ export function __wbg_get_1f8f054ddbaa7db2() { return handleError(function (arg0, arg1) {
504
+ const ret = Reflect.get(arg0, arg1);
505
+ return ret;
506
+ }, arguments); }
507
+ export function __wbg_get_2b48c7d0d006a781(arg0, arg1) {
508
+ const ret = arg0[arg1 >>> 0];
509
+ return ret;
510
+ }
511
+ export function __wbg_get_de6a0f7d4d18a304() { return handleError(function (arg0, arg1) {
512
+ const ret = Reflect.get(arg0, arg1);
513
+ return ret;
514
+ }, arguments); }
515
+ export function __wbg_get_unchecked_33f6e5c9e2f2d6b2(arg0, arg1) {
516
+ const ret = arg0[arg1 >>> 0];
517
+ return ret;
518
+ }
519
+ export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
520
+ const ret = arg0[arg1];
521
+ return ret;
522
+ }
523
+ export function __wbg_instanceof_ArrayBuffer_8f49811467741499(arg0) {
524
+ let result;
525
+ try {
526
+ result = arg0 instanceof ArrayBuffer;
527
+ } catch (_) {
528
+ result = false;
529
+ }
530
+ const ret = result;
531
+ return ret;
532
+ }
533
+ export function __wbg_instanceof_Map_9fc06d9a951bcee6(arg0) {
534
+ let result;
535
+ try {
536
+ result = arg0 instanceof Map;
537
+ } catch (_) {
538
+ result = false;
539
+ }
540
+ const ret = result;
541
+ return ret;
542
+ }
543
+ export function __wbg_instanceof_Performance_1a12386577a93f55(arg0) {
544
+ let result;
545
+ try {
546
+ result = arg0 instanceof Performance;
547
+ } catch (_) {
548
+ result = false;
549
+ }
550
+ const ret = result;
551
+ return ret;
552
+ }
553
+ export function __wbg_instanceof_Uint8Array_86f30649f63ef9c2(arg0) {
554
+ let result;
555
+ try {
556
+ result = arg0 instanceof Uint8Array;
557
+ } catch (_) {
558
+ result = false;
559
+ }
560
+ const ret = result;
561
+ return ret;
562
+ }
563
+ export function __wbg_isArray_67c2c9c4313f4448(arg0) {
564
+ const ret = Array.isArray(arg0);
565
+ return ret;
566
+ }
567
+ export function __wbg_isSafeInteger_66acec27e09e99a7(arg0) {
568
+ const ret = Number.isSafeInteger(arg0);
569
+ return ret;
570
+ }
571
+ export function __wbg_iterator_8732428d309e270e() {
572
+ const ret = Symbol.iterator;
573
+ return ret;
574
+ }
575
+ export function __wbg_length_4a591ecaa01354d9(arg0) {
576
+ const ret = arg0.length;
577
+ return ret;
578
+ }
579
+ export function __wbg_length_66f1a4b2e9026940(arg0) {
580
+ const ret = arg0.length;
581
+ return ret;
582
+ }
583
+ export function __wbg_new_578aeef4b6b94378(arg0) {
584
+ const ret = new Uint8Array(arg0);
585
+ return ret;
586
+ }
587
+ export function __wbg_new_622fc80556be2e26() {
588
+ const ret = new Map();
589
+ return ret;
590
+ }
591
+ export function __wbg_new_ce1ab61c1c2b300d() {
592
+ const ret = new Object();
593
+ return ret;
594
+ }
595
+ export function __wbg_new_d90091b82fdf5b91() {
596
+ const ret = new Array();
597
+ return ret;
598
+ }
599
+ export function __wbg_next_9e03acdf51c4960d(arg0) {
600
+ const ret = arg0.next;
601
+ return ret;
602
+ }
603
+ export function __wbg_next_eb8ca7351fa27906() { return handleError(function (arg0) {
604
+ const ret = arg0.next();
605
+ return ret;
606
+ }, arguments); }
607
+ export function __wbg_now_f565250295e2d180(arg0) {
608
+ const ret = arg0.now();
609
+ return ret;
610
+ }
611
+ export function __wbg_prototypesetcall_3249fc62a0fafa30(arg0, arg1, arg2) {
612
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
613
+ }
614
+ export function __wbg_set_52b1e1eb5bed906a(arg0, arg1, arg2) {
615
+ const ret = arg0.set(arg1, arg2);
616
+ return ret;
617
+ }
618
+ export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
619
+ arg0[arg1] = arg2;
620
+ }
621
+ export function __wbg_set_dca99999bba88a9a(arg0, arg1, arg2) {
622
+ arg0[arg1 >>> 0] = arg2;
623
+ }
624
+ export function __wbg_static_accessor_GLOBAL_9d53f2689e622ca1() {
625
+ const ret = typeof global === 'undefined' ? null : global;
626
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
627
+ }
628
+ export function __wbg_static_accessor_GLOBAL_THIS_a1a35cec07001a8a() {
629
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
630
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
631
+ }
632
+ export function __wbg_static_accessor_SELF_4c59f6c7ea29a144() {
633
+ const ret = typeof self === 'undefined' ? null : self;
634
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
635
+ }
636
+ export function __wbg_static_accessor_WINDOW_e70ae9f2eb052253() {
637
+ const ret = typeof window === 'undefined' ? null : window;
638
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
639
+ }
640
+ export function __wbg_value_f3625092ee4b37f4(arg0) {
641
+ const ret = arg0.value;
642
+ return ret;
643
+ }
644
+ export function __wbindgen_cast_0000000000000001(arg0) {
645
+ // Cast intrinsic for `F64 -> Externref`.
646
+ const ret = arg0;
647
+ return ret;
648
+ }
649
+ export function __wbindgen_cast_0000000000000002(arg0) {
650
+ // Cast intrinsic for `I64 -> Externref`.
651
+ const ret = arg0;
652
+ return ret;
653
+ }
654
+ export function __wbindgen_cast_0000000000000003(arg0, arg1) {
655
+ // Cast intrinsic for `Ref(String) -> Externref`.
656
+ const ret = getStringFromWasm0(arg0, arg1);
657
+ return ret;
658
+ }
659
+ export function __wbindgen_cast_0000000000000004(arg0) {
660
+ // Cast intrinsic for `U64 -> Externref`.
661
+ const ret = BigInt.asUintN(64, arg0);
662
+ return ret;
663
+ }
664
+ export function __wbindgen_init_externref_table() {
665
+ const table = wasm.__wbindgen_externrefs;
666
+ const offset = table.grow(4);
667
+ table.set(0, undefined);
668
+ table.set(offset + 0, undefined);
669
+ table.set(offset + 1, null);
670
+ table.set(offset + 2, true);
671
+ table.set(offset + 3, false);
672
+ }
673
+ const ExpressionDomainFlowRuntimeFinalization = (typeof FinalizationRegistry === 'undefined')
674
+ ? { register: () => {}, unregister: () => {} }
675
+ : new FinalizationRegistry(ptr => wasm.__wbg_expressiondomainflowruntime_free(ptr, 1));
676
+
677
+ function addToExternrefTable0(obj) {
678
+ const idx = wasm.__externref_table_alloc_command_export();
679
+ wasm.__wbindgen_externrefs.set(idx, obj);
680
+ return idx;
681
+ }
682
+
683
+ function debugString(val) {
684
+ // primitive types
685
+ const type = typeof val;
686
+ if (type == 'number' || type == 'boolean' || val == null) {
687
+ return `${val}`;
688
+ }
689
+ if (type == 'string') {
690
+ return `"${val}"`;
691
+ }
692
+ if (type == 'symbol') {
693
+ const description = val.description;
694
+ if (description == null) {
695
+ return 'Symbol';
696
+ } else {
697
+ return `Symbol(${description})`;
698
+ }
699
+ }
700
+ if (type == 'function') {
701
+ const name = val.name;
702
+ if (typeof name == 'string' && name.length > 0) {
703
+ return `Function(${name})`;
704
+ } else {
705
+ return 'Function';
706
+ }
707
+ }
708
+ // objects
709
+ if (Array.isArray(val)) {
710
+ const length = val.length;
711
+ let debug = '[';
712
+ if (length > 0) {
713
+ debug += debugString(val[0]);
714
+ }
715
+ for(let i = 1; i < length; i++) {
716
+ debug += ', ' + debugString(val[i]);
717
+ }
718
+ debug += ']';
719
+ return debug;
720
+ }
721
+ // Test for built-in
722
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
723
+ let className;
724
+ if (builtInMatches && builtInMatches.length > 1) {
725
+ className = builtInMatches[1];
726
+ } else {
727
+ // Failed to match the standard '[object ClassName]'
728
+ return toString.call(val);
729
+ }
730
+ if (className == 'Object') {
731
+ // we're a user defined class or Object
732
+ // JSON.stringify avoids problems with cycles, and is generally much
733
+ // easier than looping through ownProperties of `val`.
734
+ try {
735
+ return 'Object(' + JSON.stringify(val) + ')';
736
+ } catch (_) {
737
+ return 'Object';
738
+ }
739
+ }
740
+ // errors
741
+ if (val instanceof Error) {
742
+ return `${val.name}: ${val.message}\n${val.stack}`;
743
+ }
744
+ // TODO we could test for more things here, like `Set`s and `Map`s.
745
+ return className;
746
+ }
747
+
748
+ function getArrayU8FromWasm0(ptr, len) {
749
+ ptr = ptr >>> 0;
750
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
751
+ }
752
+
753
+ let cachedDataViewMemory0 = null;
754
+ function getDataViewMemory0() {
755
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
756
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
757
+ }
758
+ return cachedDataViewMemory0;
759
+ }
760
+
761
+ function getStringFromWasm0(ptr, len) {
762
+ return decodeText(ptr >>> 0, len);
763
+ }
764
+
765
+ let cachedUint8ArrayMemory0 = null;
766
+ function getUint8ArrayMemory0() {
767
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
768
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
769
+ }
770
+ return cachedUint8ArrayMemory0;
771
+ }
772
+
773
+ function handleError(f, args) {
774
+ try {
775
+ return f.apply(this, args);
776
+ } catch (e) {
777
+ const idx = addToExternrefTable0(e);
778
+ wasm.__wbindgen_exn_store_command_export(idx);
779
+ }
780
+ }
781
+
782
+ function isLikeNone(x) {
783
+ return x === undefined || x === null;
784
+ }
785
+
786
+ function passStringToWasm0(arg, malloc, realloc) {
787
+ if (realloc === undefined) {
788
+ const buf = cachedTextEncoder.encode(arg);
789
+ const ptr = malloc(buf.length, 1) >>> 0;
790
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
791
+ WASM_VECTOR_LEN = buf.length;
792
+ return ptr;
793
+ }
794
+
795
+ let len = arg.length;
796
+ let ptr = malloc(len, 1) >>> 0;
797
+
798
+ const mem = getUint8ArrayMemory0();
799
+
800
+ let offset = 0;
801
+
802
+ for (; offset < len; offset++) {
803
+ const code = arg.charCodeAt(offset);
804
+ if (code > 0x7F) break;
805
+ mem[ptr + offset] = code;
806
+ }
807
+ if (offset !== len) {
808
+ if (offset !== 0) {
809
+ arg = arg.slice(offset);
810
+ }
811
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
812
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
813
+ const ret = cachedTextEncoder.encodeInto(arg, view);
814
+
815
+ offset += ret.written;
816
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
817
+ }
818
+
819
+ WASM_VECTOR_LEN = offset;
820
+ return ptr;
821
+ }
822
+
823
+ function takeFromExternrefTable0(idx) {
824
+ const value = wasm.__wbindgen_externrefs.get(idx);
825
+ wasm.__externref_table_dealloc_command_export(idx);
826
+ return value;
827
+ }
828
+
829
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
830
+ cachedTextDecoder.decode();
831
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
832
+ let numBytesDecoded = 0;
833
+ function decodeText(ptr, len) {
834
+ numBytesDecoded += len;
835
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
836
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
837
+ cachedTextDecoder.decode();
838
+ numBytesDecoded = len;
839
+ }
840
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
841
+ }
842
+
843
+ const cachedTextEncoder = new TextEncoder();
844
+
845
+ if (!('encodeInto' in cachedTextEncoder)) {
846
+ cachedTextEncoder.encodeInto = function (arg, view) {
847
+ const buf = cachedTextEncoder.encode(arg);
848
+ view.set(buf);
849
+ return {
850
+ read: arg.length,
851
+ written: buf.length
852
+ };
853
+ };
854
+ }
855
+
856
+ let WASM_VECTOR_LEN = 0;
857
+
858
+
859
+ let wasm;
860
+ export function __wbg_set_wasm(val) {
861
+ wasm = val;
862
+ }
Binary file
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@omena/wasm",
3
+ "type": "module",
4
+ "description": "Wasm bindings for browser-side Omena CSS parser and transform checks",
5
+ "version": "0.2.0",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/omenien/omena-css"
10
+ },
11
+ "files": [
12
+ "omena_wasm_bg.wasm",
13
+ "omena_wasm.js",
14
+ "omena_wasm_bg.js",
15
+ "omena_wasm.d.ts"
16
+ ],
17
+ "main": "omena_wasm.js",
18
+ "types": "omena_wasm.d.ts",
19
+ "sideEffects": [
20
+ "./omena_wasm.js",
21
+ "./snippets/*"
22
+ ]
23
+ }