lini-wasm 1.0.2

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Abbas Monfared
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # lini-wasm
2
+
3
+ [Lini](https://lini.rs) compiles plain text to clean, themeable SVG — one small
4
+ language for flowcharts, mindmaps, org charts, tables, ER schemas, sequences,
5
+ charts, engineering drawings, floor plans, and circuit schematics.
6
+
7
+ This package is the compiler itself, as a WebAssembly module: the same engine as
8
+ the `lini` binary, byte for byte, with no network calls and nothing to stand up
9
+ beside it.
10
+
11
+ ```sh
12
+ npm install lini-wasm
13
+ ```
14
+
15
+ ## Node, Bun, Deno
16
+
17
+ The module is read off disk as it loads, so there is nothing to await.
18
+
19
+ ```js
20
+ import { compile } from "lini-wasm";
21
+
22
+ const svg = compile(`
23
+ { direction: row; gap: 40; }
24
+ |box#write| "write"
25
+ |box#compile| "compile"
26
+ |box#svg| "SVG"
27
+ write -> compile -> svg
28
+ `);
29
+ ```
30
+
31
+ ## Browsers and bundlers
32
+
33
+ Vite, Astro, webpack, or a plain `<script type="module">` — the WebAssembly is
34
+ fetched on first use, so `init()` is awaited once:
35
+
36
+ ```js
37
+ import init, { compile } from "lini-wasm";
38
+
39
+ await init();
40
+ document.querySelector("#figure").innerHTML = compile('|box| "hello"');
41
+ ```
42
+
43
+ Bundlers pick this build up automatically. A page loading the file directly
44
+ imports `lini-wasm/web` and passes the module's URL:
45
+
46
+ ```js
47
+ import init, { compile } from "https://esm.sh/lini-wasm/web";
48
+ await init("https://esm.sh/lini-wasm/lini_wasm_bg.wasm");
49
+ ```
50
+
51
+ ## What it exports
52
+
53
+ | | |
54
+ |---|---|
55
+ | `compile(src)` | SVG — the default output, live `var()` colours and real `<text>` |
56
+ | `compile_html(src)` | a self-contained HTML page around that SVG |
57
+ | `compile_static(src)` | SVG with variables inlined and text outlined, for a rasteriser |
58
+ | `diagnostics(src)` | every error and warning as JSON — codes, spans, fixes. Never throws |
59
+ | `desugar(src)` | the source with all sugar lowered to primitives |
60
+ | `format(src)` | canonical formatting, what `lini fmt` writes |
61
+ | `highlight(src)` | the source as `<span class="lini-tok-…">` HTML |
62
+ | `highlight_css()` | the palette those spans wear, ready to ship beside them |
63
+ | `version()` | the engine's version |
64
+
65
+ Everything but `diagnostics`, `highlight` and `highlight_css` throws on an error-level
66
+ diagnostic, with the compiler's own `play.lini:3:5: error: …` message as the
67
+ thrown value. TypeScript declarations ship with both builds.
68
+
69
+ ## More
70
+
71
+ [**lini.rs**](https://lini.rs) — the tour, the full reference, the gallery, and
72
+ this compiler running in your browser.
73
+ [github.com/monfa-red/lini](https://github.com/monfa-red/lini) — the source, the
74
+ CLI, and `SKILL.md`, the whole language as a working brief.
75
+
76
+ MIT.
@@ -0,0 +1,65 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Compile Lini source to SVG.
6
+ *
7
+ * Throws on any error-level diagnostic, with the compiler's own LSP-shaped
8
+ * message (`play.lini:3:5: error: …`) as the thrown value.
9
+ */
10
+ export function compile(src: string): string;
11
+
12
+ /**
13
+ * Compile to a full HTML page rather than a bare SVG — the `--format html`
14
+ * output, for a preview pane that wants a self-contained document.
15
+ */
16
+ export function compile_html(src: string): string;
17
+
18
+ /**
19
+ * Compile with `var()` references inlined and text outlined to paths — the
20
+ * `--static` output. Self-contained for download, or for a canvas rasteriser.
21
+ */
22
+ export function compile_static(src: string): string;
23
+
24
+ /**
25
+ * The source with every bit of sugar lowered to primitives — what `lini
26
+ * desugar` prints. The teaching view.
27
+ */
28
+ export function desugar(src: string): string;
29
+
30
+ /**
31
+ * Every diagnostic as the JSON document `--json` emits — stable codes, spans,
32
+ * severities, and machine-applicable fixes. Never throws: a file that cannot
33
+ * compile still reports why, which is what an editor's gutter wants.
34
+ */
35
+ export function diagnostics(src: string): string;
36
+
37
+ /**
38
+ * Canonical formatting — what `lini fmt` writes.
39
+ */
40
+ export function format(src: string): string;
41
+
42
+ /**
43
+ * The source as `<span class="lini-tok-…">` HTML — what `lini highlight`
44
+ * prints, from the same scanner the VS Code and Zed grammars take their words
45
+ * from [SPEC 22]. Never throws: highlighting is lexical, so a file
46
+ * mid-keystroke still colours, which is exactly what a live editor wants.
47
+ */
48
+ export function highlight(src: string): string;
49
+
50
+ /**
51
+ * The stylesheet [`highlight`]'s markup wears — what `lini highlight --css`
52
+ * prints [SPEC 18/20].
53
+ *
54
+ * A host with no `lini` binary beside it — a bundler plugin, an Astro or
55
+ * Docusaurus integration — has no other way to reach the palette, and a copy
56
+ * kept in its own tree goes monochrome the day the scanner names a class this
57
+ * sheet does not paint. Shipping it from the module ties the two to one
58
+ * engine, exactly as [`highlight`] and the grammars already are.
59
+ */
60
+ export function highlight_css(): string;
61
+
62
+ /**
63
+ * The compiler's version, so a page can show which engine it is running.
64
+ */
65
+ export function version(): string;
@@ -0,0 +1,403 @@
1
+ /* @ts-self-types="./lini_wasm.d.ts" */
2
+
3
+ /**
4
+ * Compile Lini source to SVG.
5
+ *
6
+ * Throws on any error-level diagnostic, with the compiler's own LSP-shaped
7
+ * message (`play.lini:3:5: error: …`) as the thrown value.
8
+ * @param {string} src
9
+ * @returns {string}
10
+ */
11
+ function compile(src) {
12
+ let deferred3_0;
13
+ let deferred3_1;
14
+ try {
15
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
16
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
17
+ const len0 = WASM_VECTOR_LEN;
18
+ wasm.compile(retptr, ptr0, len0);
19
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
20
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
21
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
22
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
23
+ var ptr2 = r0;
24
+ var len2 = r1;
25
+ if (r3) {
26
+ ptr2 = 0; len2 = 0;
27
+ throw takeObject(r2);
28
+ }
29
+ deferred3_0 = ptr2;
30
+ deferred3_1 = len2;
31
+ return getStringFromWasm0(ptr2, len2);
32
+ } finally {
33
+ wasm.__wbindgen_add_to_stack_pointer(16);
34
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
35
+ }
36
+ }
37
+ exports.compile = compile;
38
+
39
+ /**
40
+ * Compile to a full HTML page rather than a bare SVG — the `--format html`
41
+ * output, for a preview pane that wants a self-contained document.
42
+ * @param {string} src
43
+ * @returns {string}
44
+ */
45
+ function compile_html(src) {
46
+ let deferred3_0;
47
+ let deferred3_1;
48
+ try {
49
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
50
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
51
+ const len0 = WASM_VECTOR_LEN;
52
+ wasm.compile_html(retptr, ptr0, len0);
53
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
54
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
55
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
56
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
57
+ var ptr2 = r0;
58
+ var len2 = r1;
59
+ if (r3) {
60
+ ptr2 = 0; len2 = 0;
61
+ throw takeObject(r2);
62
+ }
63
+ deferred3_0 = ptr2;
64
+ deferred3_1 = len2;
65
+ return getStringFromWasm0(ptr2, len2);
66
+ } finally {
67
+ wasm.__wbindgen_add_to_stack_pointer(16);
68
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
69
+ }
70
+ }
71
+ exports.compile_html = compile_html;
72
+
73
+ /**
74
+ * Compile with `var()` references inlined and text outlined to paths — the
75
+ * `--static` output. Self-contained for download, or for a canvas rasteriser.
76
+ * @param {string} src
77
+ * @returns {string}
78
+ */
79
+ function compile_static(src) {
80
+ let deferred3_0;
81
+ let deferred3_1;
82
+ try {
83
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
84
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
85
+ const len0 = WASM_VECTOR_LEN;
86
+ wasm.compile_static(retptr, ptr0, len0);
87
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
88
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
89
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
90
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
91
+ var ptr2 = r0;
92
+ var len2 = r1;
93
+ if (r3) {
94
+ ptr2 = 0; len2 = 0;
95
+ throw takeObject(r2);
96
+ }
97
+ deferred3_0 = ptr2;
98
+ deferred3_1 = len2;
99
+ return getStringFromWasm0(ptr2, len2);
100
+ } finally {
101
+ wasm.__wbindgen_add_to_stack_pointer(16);
102
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
103
+ }
104
+ }
105
+ exports.compile_static = compile_static;
106
+
107
+ /**
108
+ * The source with every bit of sugar lowered to primitives — what `lini
109
+ * desugar` prints. The teaching view.
110
+ * @param {string} src
111
+ * @returns {string}
112
+ */
113
+ function desugar(src) {
114
+ let deferred3_0;
115
+ let deferred3_1;
116
+ try {
117
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
118
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
119
+ const len0 = WASM_VECTOR_LEN;
120
+ wasm.desugar(retptr, ptr0, len0);
121
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
122
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
123
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
124
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
125
+ var ptr2 = r0;
126
+ var len2 = r1;
127
+ if (r3) {
128
+ ptr2 = 0; len2 = 0;
129
+ throw takeObject(r2);
130
+ }
131
+ deferred3_0 = ptr2;
132
+ deferred3_1 = len2;
133
+ return getStringFromWasm0(ptr2, len2);
134
+ } finally {
135
+ wasm.__wbindgen_add_to_stack_pointer(16);
136
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
137
+ }
138
+ }
139
+ exports.desugar = desugar;
140
+
141
+ /**
142
+ * Every diagnostic as the JSON document `--json` emits — stable codes, spans,
143
+ * severities, and machine-applicable fixes. Never throws: a file that cannot
144
+ * compile still reports why, which is what an editor's gutter wants.
145
+ * @param {string} src
146
+ * @returns {string}
147
+ */
148
+ function diagnostics(src) {
149
+ let deferred2_0;
150
+ let deferred2_1;
151
+ try {
152
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
153
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
154
+ const len0 = WASM_VECTOR_LEN;
155
+ wasm.diagnostics(retptr, ptr0, len0);
156
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
157
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
158
+ deferred2_0 = r0;
159
+ deferred2_1 = r1;
160
+ return getStringFromWasm0(r0, r1);
161
+ } finally {
162
+ wasm.__wbindgen_add_to_stack_pointer(16);
163
+ wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
164
+ }
165
+ }
166
+ exports.diagnostics = diagnostics;
167
+
168
+ /**
169
+ * Canonical formatting — what `lini fmt` writes.
170
+ * @param {string} src
171
+ * @returns {string}
172
+ */
173
+ function format(src) {
174
+ let deferred3_0;
175
+ let deferred3_1;
176
+ try {
177
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
178
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
179
+ const len0 = WASM_VECTOR_LEN;
180
+ wasm.format(retptr, ptr0, len0);
181
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
182
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
183
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
184
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
185
+ var ptr2 = r0;
186
+ var len2 = r1;
187
+ if (r3) {
188
+ ptr2 = 0; len2 = 0;
189
+ throw takeObject(r2);
190
+ }
191
+ deferred3_0 = ptr2;
192
+ deferred3_1 = len2;
193
+ return getStringFromWasm0(ptr2, len2);
194
+ } finally {
195
+ wasm.__wbindgen_add_to_stack_pointer(16);
196
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
197
+ }
198
+ }
199
+ exports.format = format;
200
+
201
+ /**
202
+ * The source as `<span class="lini-tok-…">` HTML — what `lini highlight`
203
+ * prints, from the same scanner the VS Code and Zed grammars take their words
204
+ * from [SPEC 22]. Never throws: highlighting is lexical, so a file
205
+ * mid-keystroke still colours, which is exactly what a live editor wants.
206
+ * @param {string} src
207
+ * @returns {string}
208
+ */
209
+ function highlight(src) {
210
+ let deferred2_0;
211
+ let deferred2_1;
212
+ try {
213
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
214
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
215
+ const len0 = WASM_VECTOR_LEN;
216
+ wasm.highlight(retptr, ptr0, len0);
217
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
218
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
219
+ deferred2_0 = r0;
220
+ deferred2_1 = r1;
221
+ return getStringFromWasm0(r0, r1);
222
+ } finally {
223
+ wasm.__wbindgen_add_to_stack_pointer(16);
224
+ wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
225
+ }
226
+ }
227
+ exports.highlight = highlight;
228
+
229
+ /**
230
+ * The stylesheet [`highlight`]'s markup wears — what `lini highlight --css`
231
+ * prints [SPEC 18/20].
232
+ *
233
+ * A host with no `lini` binary beside it — a bundler plugin, an Astro or
234
+ * Docusaurus integration — has no other way to reach the palette, and a copy
235
+ * kept in its own tree goes monochrome the day the scanner names a class this
236
+ * sheet does not paint. Shipping it from the module ties the two to one
237
+ * engine, exactly as [`highlight`] and the grammars already are.
238
+ * @returns {string}
239
+ */
240
+ function highlight_css() {
241
+ let deferred1_0;
242
+ let deferred1_1;
243
+ try {
244
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
245
+ wasm.highlight_css(retptr);
246
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
247
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
248
+ deferred1_0 = r0;
249
+ deferred1_1 = r1;
250
+ return getStringFromWasm0(r0, r1);
251
+ } finally {
252
+ wasm.__wbindgen_add_to_stack_pointer(16);
253
+ wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
254
+ }
255
+ }
256
+ exports.highlight_css = highlight_css;
257
+
258
+ /**
259
+ * The compiler's version, so a page can show which engine it is running.
260
+ * @returns {string}
261
+ */
262
+ function version() {
263
+ let deferred1_0;
264
+ let deferred1_1;
265
+ try {
266
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
267
+ wasm.version(retptr);
268
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
269
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
270
+ deferred1_0 = r0;
271
+ deferred1_1 = r1;
272
+ return getStringFromWasm0(r0, r1);
273
+ } finally {
274
+ wasm.__wbindgen_add_to_stack_pointer(16);
275
+ wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
276
+ }
277
+ }
278
+ exports.version = version;
279
+ function __wbg_get_imports() {
280
+ const import0 = {
281
+ __proto__: null,
282
+ __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
283
+ const ret = Error(getStringFromWasm0(arg0, arg1));
284
+ return addHeapObject(ret);
285
+ },
286
+ };
287
+ return {
288
+ __proto__: null,
289
+ "./lini_wasm_bg.js": import0,
290
+ };
291
+ }
292
+
293
+ function addHeapObject(obj) {
294
+ if (heap_next === heap.length) heap.push(heap.length + 1);
295
+ const idx = heap_next;
296
+ heap_next = heap[idx];
297
+
298
+ heap[idx] = obj;
299
+ return idx;
300
+ }
301
+
302
+ function dropObject(idx) {
303
+ if (idx < 1028) return;
304
+ heap[idx] = heap_next;
305
+ heap_next = idx;
306
+ }
307
+
308
+ let cachedDataViewMemory0 = null;
309
+ function getDataViewMemory0() {
310
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
311
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
312
+ }
313
+ return cachedDataViewMemory0;
314
+ }
315
+
316
+ function getStringFromWasm0(ptr, len) {
317
+ return decodeText(ptr >>> 0, len);
318
+ }
319
+
320
+ let cachedUint8ArrayMemory0 = null;
321
+ function getUint8ArrayMemory0() {
322
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
323
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
324
+ }
325
+ return cachedUint8ArrayMemory0;
326
+ }
327
+
328
+ function getObject(idx) { return heap[idx]; }
329
+
330
+ let heap = new Array(1024).fill(undefined);
331
+ heap.push(undefined, null, true, false);
332
+
333
+ let heap_next = heap.length;
334
+
335
+ function passStringToWasm0(arg, malloc, realloc) {
336
+ if (realloc === undefined) {
337
+ const buf = cachedTextEncoder.encode(arg);
338
+ const ptr = malloc(buf.length, 1) >>> 0;
339
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
340
+ WASM_VECTOR_LEN = buf.length;
341
+ return ptr;
342
+ }
343
+
344
+ let len = arg.length;
345
+ let ptr = malloc(len, 1) >>> 0;
346
+
347
+ const mem = getUint8ArrayMemory0();
348
+
349
+ let offset = 0;
350
+
351
+ for (; offset < len; offset++) {
352
+ const code = arg.charCodeAt(offset);
353
+ if (code > 0x7F) break;
354
+ mem[ptr + offset] = code;
355
+ }
356
+ if (offset !== len) {
357
+ if (offset !== 0) {
358
+ arg = arg.slice(offset);
359
+ }
360
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
361
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
362
+ const ret = cachedTextEncoder.encodeInto(arg, view);
363
+
364
+ offset += ret.written;
365
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
366
+ }
367
+
368
+ WASM_VECTOR_LEN = offset;
369
+ return ptr;
370
+ }
371
+
372
+ function takeObject(idx) {
373
+ const ret = getObject(idx);
374
+ dropObject(idx);
375
+ return ret;
376
+ }
377
+
378
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
379
+ cachedTextDecoder.decode();
380
+ function decodeText(ptr, len) {
381
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
382
+ }
383
+
384
+ const cachedTextEncoder = new TextEncoder();
385
+
386
+ if (!('encodeInto' in cachedTextEncoder)) {
387
+ cachedTextEncoder.encodeInto = function (arg, view) {
388
+ const buf = cachedTextEncoder.encode(arg);
389
+ view.set(buf);
390
+ return {
391
+ read: arg.length,
392
+ written: buf.length
393
+ };
394
+ };
395
+ }
396
+
397
+ let WASM_VECTOR_LEN = 0;
398
+
399
+ const wasmPath = `${__dirname}/lini_wasm_bg.wasm`;
400
+ const wasmBytes = require('fs').readFileSync(wasmPath);
401
+ const wasmModule = new WebAssembly.Module(wasmBytes);
402
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
403
+ let wasm = wasmInstance.exports;
Binary file
@@ -0,0 +1,16 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const compile: (a: number, b: number, c: number) => void;
5
+ export const compile_html: (a: number, b: number, c: number) => void;
6
+ export const compile_static: (a: number, b: number, c: number) => void;
7
+ export const desugar: (a: number, b: number, c: number) => void;
8
+ export const diagnostics: (a: number, b: number, c: number) => void;
9
+ export const format: (a: number, b: number, c: number) => void;
10
+ export const highlight: (a: number, b: number, c: number) => void;
11
+ export const highlight_css: (a: number) => void;
12
+ export const version: (a: number) => void;
13
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
14
+ export const __wbindgen_export: (a: number, b: number) => number;
15
+ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
16
+ export const __wbindgen_export3: (a: number, b: number, c: number) => void;
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "lini-wasm",
3
+ "version": "1.0.2",
4
+ "description": "Lini's compiler as a WebAssembly module — one small language for diagrams, compiled to clean, themeable SVG.",
5
+ "license": "MIT",
6
+ "homepage": "https://lini.rs",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/monfa-red/lini.git",
10
+ "directory": "crates/lini-wasm"
11
+ },
12
+ "bugs": "https://github.com/monfa-red/lini/issues",
13
+ "keywords": [
14
+ "diagram",
15
+ "diagrams-as-code",
16
+ "svg",
17
+ "dsl",
18
+ "wasm",
19
+ "webassembly",
20
+ "lini"
21
+ ],
22
+ "type": "module",
23
+ "types": "./web/lini_wasm.d.ts",
24
+ "main": "./node/lini_wasm.js",
25
+ "module": "./web/lini_wasm.js",
26
+ "browser": "./web/lini_wasm.js",
27
+ "exports": {
28
+ ".": {
29
+ "node": {
30
+ "types": "./node/lini_wasm.d.ts",
31
+ "default": "./node/lini_wasm.js"
32
+ },
33
+ "types": "./web/lini_wasm.d.ts",
34
+ "default": "./web/lini_wasm.js"
35
+ },
36
+ "./web": {
37
+ "types": "./web/lini_wasm.d.ts",
38
+ "default": "./web/lini_wasm.js"
39
+ },
40
+ "./node": {
41
+ "types": "./node/lini_wasm.d.ts",
42
+ "default": "./node/lini_wasm.js"
43
+ },
44
+ "./lini_wasm_bg.wasm": "./web/lini_wasm_bg.wasm",
45
+ "./package.json": "./package.json"
46
+ },
47
+ "files": [
48
+ "web",
49
+ "node",
50
+ "README.md",
51
+ "LICENSE"
52
+ ],
53
+ "engines": {
54
+ "node": ">=18"
55
+ }
56
+ }
@@ -0,0 +1,106 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Compile Lini source to SVG.
6
+ *
7
+ * Throws on any error-level diagnostic, with the compiler's own LSP-shaped
8
+ * message (`play.lini:3:5: error: …`) as the thrown value.
9
+ */
10
+ export function compile(src: string): string;
11
+
12
+ /**
13
+ * Compile to a full HTML page rather than a bare SVG — the `--format html`
14
+ * output, for a preview pane that wants a self-contained document.
15
+ */
16
+ export function compile_html(src: string): string;
17
+
18
+ /**
19
+ * Compile with `var()` references inlined and text outlined to paths — the
20
+ * `--static` output. Self-contained for download, or for a canvas rasteriser.
21
+ */
22
+ export function compile_static(src: string): string;
23
+
24
+ /**
25
+ * The source with every bit of sugar lowered to primitives — what `lini
26
+ * desugar` prints. The teaching view.
27
+ */
28
+ export function desugar(src: string): string;
29
+
30
+ /**
31
+ * Every diagnostic as the JSON document `--json` emits — stable codes, spans,
32
+ * severities, and machine-applicable fixes. Never throws: a file that cannot
33
+ * compile still reports why, which is what an editor's gutter wants.
34
+ */
35
+ export function diagnostics(src: string): string;
36
+
37
+ /**
38
+ * Canonical formatting — what `lini fmt` writes.
39
+ */
40
+ export function format(src: string): string;
41
+
42
+ /**
43
+ * The source as `<span class="lini-tok-…">` HTML — what `lini highlight`
44
+ * prints, from the same scanner the VS Code and Zed grammars take their words
45
+ * from [SPEC 22]. Never throws: highlighting is lexical, so a file
46
+ * mid-keystroke still colours, which is exactly what a live editor wants.
47
+ */
48
+ export function highlight(src: string): string;
49
+
50
+ /**
51
+ * The stylesheet [`highlight`]'s markup wears — what `lini highlight --css`
52
+ * prints [SPEC 18/20].
53
+ *
54
+ * A host with no `lini` binary beside it — a bundler plugin, an Astro or
55
+ * Docusaurus integration — has no other way to reach the palette, and a copy
56
+ * kept in its own tree goes monochrome the day the scanner names a class this
57
+ * sheet does not paint. Shipping it from the module ties the two to one
58
+ * engine, exactly as [`highlight`] and the grammars already are.
59
+ */
60
+ export function highlight_css(): string;
61
+
62
+ /**
63
+ * The compiler's version, so a page can show which engine it is running.
64
+ */
65
+ export function version(): string;
66
+
67
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
68
+
69
+ export interface InitOutput {
70
+ readonly memory: WebAssembly.Memory;
71
+ readonly compile: (a: number, b: number, c: number) => void;
72
+ readonly compile_html: (a: number, b: number, c: number) => void;
73
+ readonly compile_static: (a: number, b: number, c: number) => void;
74
+ readonly desugar: (a: number, b: number, c: number) => void;
75
+ readonly diagnostics: (a: number, b: number, c: number) => void;
76
+ readonly format: (a: number, b: number, c: number) => void;
77
+ readonly highlight: (a: number, b: number, c: number) => void;
78
+ readonly highlight_css: (a: number) => void;
79
+ readonly version: (a: number) => void;
80
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
81
+ readonly __wbindgen_export: (a: number, b: number) => number;
82
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
83
+ readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
84
+ }
85
+
86
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
87
+
88
+ /**
89
+ * Instantiates the given `module`, which can either be bytes or
90
+ * a precompiled `WebAssembly.Module`.
91
+ *
92
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
93
+ *
94
+ * @returns {InitOutput}
95
+ */
96
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
97
+
98
+ /**
99
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
100
+ * for everything else, calls `WebAssembly.instantiate` directly.
101
+ *
102
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
103
+ *
104
+ * @returns {Promise<InitOutput>}
105
+ */
106
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,493 @@
1
+ /* @ts-self-types="./lini_wasm.d.ts" */
2
+
3
+ /**
4
+ * Compile Lini source to SVG.
5
+ *
6
+ * Throws on any error-level diagnostic, with the compiler's own LSP-shaped
7
+ * message (`play.lini:3:5: error: …`) as the thrown value.
8
+ * @param {string} src
9
+ * @returns {string}
10
+ */
11
+ export function compile(src) {
12
+ let deferred3_0;
13
+ let deferred3_1;
14
+ try {
15
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
16
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
17
+ const len0 = WASM_VECTOR_LEN;
18
+ wasm.compile(retptr, ptr0, len0);
19
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
20
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
21
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
22
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
23
+ var ptr2 = r0;
24
+ var len2 = r1;
25
+ if (r3) {
26
+ ptr2 = 0; len2 = 0;
27
+ throw takeObject(r2);
28
+ }
29
+ deferred3_0 = ptr2;
30
+ deferred3_1 = len2;
31
+ return getStringFromWasm0(ptr2, len2);
32
+ } finally {
33
+ wasm.__wbindgen_add_to_stack_pointer(16);
34
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Compile to a full HTML page rather than a bare SVG — the `--format html`
40
+ * output, for a preview pane that wants a self-contained document.
41
+ * @param {string} src
42
+ * @returns {string}
43
+ */
44
+ export function compile_html(src) {
45
+ let deferred3_0;
46
+ let deferred3_1;
47
+ try {
48
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
49
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
50
+ const len0 = WASM_VECTOR_LEN;
51
+ wasm.compile_html(retptr, ptr0, len0);
52
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
53
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
54
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
55
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
56
+ var ptr2 = r0;
57
+ var len2 = r1;
58
+ if (r3) {
59
+ ptr2 = 0; len2 = 0;
60
+ throw takeObject(r2);
61
+ }
62
+ deferred3_0 = ptr2;
63
+ deferred3_1 = len2;
64
+ return getStringFromWasm0(ptr2, len2);
65
+ } finally {
66
+ wasm.__wbindgen_add_to_stack_pointer(16);
67
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Compile with `var()` references inlined and text outlined to paths — the
73
+ * `--static` output. Self-contained for download, or for a canvas rasteriser.
74
+ * @param {string} src
75
+ * @returns {string}
76
+ */
77
+ export function compile_static(src) {
78
+ let deferred3_0;
79
+ let deferred3_1;
80
+ try {
81
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
82
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
83
+ const len0 = WASM_VECTOR_LEN;
84
+ wasm.compile_static(retptr, ptr0, len0);
85
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
86
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
87
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
88
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
89
+ var ptr2 = r0;
90
+ var len2 = r1;
91
+ if (r3) {
92
+ ptr2 = 0; len2 = 0;
93
+ throw takeObject(r2);
94
+ }
95
+ deferred3_0 = ptr2;
96
+ deferred3_1 = len2;
97
+ return getStringFromWasm0(ptr2, len2);
98
+ } finally {
99
+ wasm.__wbindgen_add_to_stack_pointer(16);
100
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
101
+ }
102
+ }
103
+
104
+ /**
105
+ * The source with every bit of sugar lowered to primitives — what `lini
106
+ * desugar` prints. The teaching view.
107
+ * @param {string} src
108
+ * @returns {string}
109
+ */
110
+ export function desugar(src) {
111
+ let deferred3_0;
112
+ let deferred3_1;
113
+ try {
114
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
115
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
116
+ const len0 = WASM_VECTOR_LEN;
117
+ wasm.desugar(retptr, ptr0, len0);
118
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
119
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
120
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
121
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
122
+ var ptr2 = r0;
123
+ var len2 = r1;
124
+ if (r3) {
125
+ ptr2 = 0; len2 = 0;
126
+ throw takeObject(r2);
127
+ }
128
+ deferred3_0 = ptr2;
129
+ deferred3_1 = len2;
130
+ return getStringFromWasm0(ptr2, len2);
131
+ } finally {
132
+ wasm.__wbindgen_add_to_stack_pointer(16);
133
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
134
+ }
135
+ }
136
+
137
+ /**
138
+ * Every diagnostic as the JSON document `--json` emits — stable codes, spans,
139
+ * severities, and machine-applicable fixes. Never throws: a file that cannot
140
+ * compile still reports why, which is what an editor's gutter wants.
141
+ * @param {string} src
142
+ * @returns {string}
143
+ */
144
+ export function diagnostics(src) {
145
+ let deferred2_0;
146
+ let deferred2_1;
147
+ try {
148
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
149
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
150
+ const len0 = WASM_VECTOR_LEN;
151
+ wasm.diagnostics(retptr, ptr0, len0);
152
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
153
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
154
+ deferred2_0 = r0;
155
+ deferred2_1 = r1;
156
+ return getStringFromWasm0(r0, r1);
157
+ } finally {
158
+ wasm.__wbindgen_add_to_stack_pointer(16);
159
+ wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Canonical formatting — what `lini fmt` writes.
165
+ * @param {string} src
166
+ * @returns {string}
167
+ */
168
+ export function format(src) {
169
+ let deferred3_0;
170
+ let deferred3_1;
171
+ try {
172
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
173
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
174
+ const len0 = WASM_VECTOR_LEN;
175
+ wasm.format(retptr, ptr0, len0);
176
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
177
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
178
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
179
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
180
+ var ptr2 = r0;
181
+ var len2 = r1;
182
+ if (r3) {
183
+ ptr2 = 0; len2 = 0;
184
+ throw takeObject(r2);
185
+ }
186
+ deferred3_0 = ptr2;
187
+ deferred3_1 = len2;
188
+ return getStringFromWasm0(ptr2, len2);
189
+ } finally {
190
+ wasm.__wbindgen_add_to_stack_pointer(16);
191
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
192
+ }
193
+ }
194
+
195
+ /**
196
+ * The source as `<span class="lini-tok-…">` HTML — what `lini highlight`
197
+ * prints, from the same scanner the VS Code and Zed grammars take their words
198
+ * from [SPEC 22]. Never throws: highlighting is lexical, so a file
199
+ * mid-keystroke still colours, which is exactly what a live editor wants.
200
+ * @param {string} src
201
+ * @returns {string}
202
+ */
203
+ export function highlight(src) {
204
+ let deferred2_0;
205
+ let deferred2_1;
206
+ try {
207
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
208
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
209
+ const len0 = WASM_VECTOR_LEN;
210
+ wasm.highlight(retptr, ptr0, len0);
211
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
212
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
213
+ deferred2_0 = r0;
214
+ deferred2_1 = r1;
215
+ return getStringFromWasm0(r0, r1);
216
+ } finally {
217
+ wasm.__wbindgen_add_to_stack_pointer(16);
218
+ wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
219
+ }
220
+ }
221
+
222
+ /**
223
+ * The stylesheet [`highlight`]'s markup wears — what `lini highlight --css`
224
+ * prints [SPEC 18/20].
225
+ *
226
+ * A host with no `lini` binary beside it — a bundler plugin, an Astro or
227
+ * Docusaurus integration — has no other way to reach the palette, and a copy
228
+ * kept in its own tree goes monochrome the day the scanner names a class this
229
+ * sheet does not paint. Shipping it from the module ties the two to one
230
+ * engine, exactly as [`highlight`] and the grammars already are.
231
+ * @returns {string}
232
+ */
233
+ export function highlight_css() {
234
+ let deferred1_0;
235
+ let deferred1_1;
236
+ try {
237
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
238
+ wasm.highlight_css(retptr);
239
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
240
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
241
+ deferred1_0 = r0;
242
+ deferred1_1 = r1;
243
+ return getStringFromWasm0(r0, r1);
244
+ } finally {
245
+ wasm.__wbindgen_add_to_stack_pointer(16);
246
+ wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
247
+ }
248
+ }
249
+
250
+ /**
251
+ * The compiler's version, so a page can show which engine it is running.
252
+ * @returns {string}
253
+ */
254
+ export function version() {
255
+ let deferred1_0;
256
+ let deferred1_1;
257
+ try {
258
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
259
+ wasm.version(retptr);
260
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
261
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
262
+ deferred1_0 = r0;
263
+ deferred1_1 = r1;
264
+ return getStringFromWasm0(r0, r1);
265
+ } finally {
266
+ wasm.__wbindgen_add_to_stack_pointer(16);
267
+ wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
268
+ }
269
+ }
270
+ function __wbg_get_imports() {
271
+ const import0 = {
272
+ __proto__: null,
273
+ __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
274
+ const ret = Error(getStringFromWasm0(arg0, arg1));
275
+ return addHeapObject(ret);
276
+ },
277
+ };
278
+ return {
279
+ __proto__: null,
280
+ "./lini_wasm_bg.js": import0,
281
+ };
282
+ }
283
+
284
+ function addHeapObject(obj) {
285
+ if (heap_next === heap.length) heap.push(heap.length + 1);
286
+ const idx = heap_next;
287
+ heap_next = heap[idx];
288
+
289
+ heap[idx] = obj;
290
+ return idx;
291
+ }
292
+
293
+ function dropObject(idx) {
294
+ if (idx < 1028) return;
295
+ heap[idx] = heap_next;
296
+ heap_next = idx;
297
+ }
298
+
299
+ let cachedDataViewMemory0 = null;
300
+ function getDataViewMemory0() {
301
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
302
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
303
+ }
304
+ return cachedDataViewMemory0;
305
+ }
306
+
307
+ function getStringFromWasm0(ptr, len) {
308
+ return decodeText(ptr >>> 0, len);
309
+ }
310
+
311
+ let cachedUint8ArrayMemory0 = null;
312
+ function getUint8ArrayMemory0() {
313
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
314
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
315
+ }
316
+ return cachedUint8ArrayMemory0;
317
+ }
318
+
319
+ function getObject(idx) { return heap[idx]; }
320
+
321
+ let heap = new Array(1024).fill(undefined);
322
+ heap.push(undefined, null, true, false);
323
+
324
+ let heap_next = heap.length;
325
+
326
+ function passStringToWasm0(arg, malloc, realloc) {
327
+ if (realloc === undefined) {
328
+ const buf = cachedTextEncoder.encode(arg);
329
+ const ptr = malloc(buf.length, 1) >>> 0;
330
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
331
+ WASM_VECTOR_LEN = buf.length;
332
+ return ptr;
333
+ }
334
+
335
+ let len = arg.length;
336
+ let ptr = malloc(len, 1) >>> 0;
337
+
338
+ const mem = getUint8ArrayMemory0();
339
+
340
+ let offset = 0;
341
+
342
+ for (; offset < len; offset++) {
343
+ const code = arg.charCodeAt(offset);
344
+ if (code > 0x7F) break;
345
+ mem[ptr + offset] = code;
346
+ }
347
+ if (offset !== len) {
348
+ if (offset !== 0) {
349
+ arg = arg.slice(offset);
350
+ }
351
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
352
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
353
+ const ret = cachedTextEncoder.encodeInto(arg, view);
354
+
355
+ offset += ret.written;
356
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
357
+ }
358
+
359
+ WASM_VECTOR_LEN = offset;
360
+ return ptr;
361
+ }
362
+
363
+ function takeObject(idx) {
364
+ const ret = getObject(idx);
365
+ dropObject(idx);
366
+ return ret;
367
+ }
368
+
369
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
370
+ cachedTextDecoder.decode();
371
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
372
+ let numBytesDecoded = 0;
373
+ function decodeText(ptr, len) {
374
+ numBytesDecoded += len;
375
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
376
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
377
+ cachedTextDecoder.decode();
378
+ numBytesDecoded = len;
379
+ }
380
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
381
+ }
382
+
383
+ const cachedTextEncoder = new TextEncoder();
384
+
385
+ if (!('encodeInto' in cachedTextEncoder)) {
386
+ cachedTextEncoder.encodeInto = function (arg, view) {
387
+ const buf = cachedTextEncoder.encode(arg);
388
+ view.set(buf);
389
+ return {
390
+ read: arg.length,
391
+ written: buf.length
392
+ };
393
+ };
394
+ }
395
+
396
+ let WASM_VECTOR_LEN = 0;
397
+
398
+ let wasmModule, wasmInstance, wasm;
399
+ function __wbg_finalize_init(instance, module) {
400
+ wasmInstance = instance;
401
+ wasm = instance.exports;
402
+ wasmModule = module;
403
+ cachedDataViewMemory0 = null;
404
+ cachedUint8ArrayMemory0 = null;
405
+ return wasm;
406
+ }
407
+
408
+ async function __wbg_load(module, imports) {
409
+ if (typeof Response === 'function' && module instanceof Response) {
410
+ if (!module.ok) {
411
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
412
+ }
413
+
414
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
415
+ try {
416
+ return await WebAssembly.instantiateStreaming(module, imports);
417
+ } catch (e) {
418
+ const validResponse = expectedResponseType(module.type);
419
+
420
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
421
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
422
+
423
+ } else { throw e; }
424
+ }
425
+ }
426
+
427
+ const bytes = await module.arrayBuffer();
428
+ return await WebAssembly.instantiate(bytes, imports);
429
+ } else {
430
+ const instance = await WebAssembly.instantiate(module, imports);
431
+
432
+ if (instance instanceof WebAssembly.Instance) {
433
+ return { instance, module };
434
+ } else {
435
+ return instance;
436
+ }
437
+ }
438
+
439
+ function expectedResponseType(type) {
440
+ switch (type) {
441
+ case 'basic': case 'cors': case 'default': return true;
442
+ }
443
+ return false;
444
+ }
445
+ }
446
+
447
+ function initSync(module) {
448
+ if (wasm !== undefined) return wasm;
449
+
450
+
451
+ if (module !== undefined) {
452
+ if (Object.getPrototypeOf(module) === Object.prototype) {
453
+ ({module} = module)
454
+ } else {
455
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
456
+ }
457
+ }
458
+
459
+ const imports = __wbg_get_imports();
460
+ if (!(module instanceof WebAssembly.Module)) {
461
+ module = new WebAssembly.Module(module);
462
+ }
463
+ const instance = new WebAssembly.Instance(module, imports);
464
+ return __wbg_finalize_init(instance, module);
465
+ }
466
+
467
+ async function __wbg_init(module_or_path) {
468
+ if (wasm !== undefined) return wasm;
469
+
470
+
471
+ if (module_or_path !== undefined) {
472
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
473
+ ({module_or_path} = module_or_path)
474
+ } else {
475
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
476
+ }
477
+ }
478
+
479
+ if (module_or_path === undefined) {
480
+ module_or_path = new URL('lini_wasm_bg.wasm', import.meta.url);
481
+ }
482
+ const imports = __wbg_get_imports();
483
+
484
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
485
+ module_or_path = fetch(module_or_path);
486
+ }
487
+
488
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
489
+
490
+ return __wbg_finalize_init(instance, module);
491
+ }
492
+
493
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,16 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const compile: (a: number, b: number, c: number) => void;
5
+ export const compile_html: (a: number, b: number, c: number) => void;
6
+ export const compile_static: (a: number, b: number, c: number) => void;
7
+ export const desugar: (a: number, b: number, c: number) => void;
8
+ export const diagnostics: (a: number, b: number, c: number) => void;
9
+ export const format: (a: number, b: number, c: number) => void;
10
+ export const highlight: (a: number, b: number, c: number) => void;
11
+ export const highlight_css: (a: number) => void;
12
+ export const version: (a: number) => void;
13
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
14
+ export const __wbindgen_export: (a: number, b: number) => number;
15
+ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
16
+ export const __wbindgen_export3: (a: number, b: number, c: number) => void;