quilt-wasm 0.4.0 → 0.6.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/quilt_wasm.js CHANGED
@@ -1,672 +1,6 @@
1
- /* @ts-self-types="./quilt_wasm.d.ts" */
2
-
3
- /**
4
- * A child placeholder (the `HOLE` constant in the Python runtime).
5
- * @returns {WasmCmdOrHole}
6
- */
7
- export function HOLE() {
8
- const ret = wasm.HOLE();
9
- return WasmCmdOrHole.__wrap(ret);
10
- }
11
-
12
- /**
13
- * The `NewLine` command (the `NL` constant in the Python runtime).
14
- * @returns {WasmStrCmd}
15
- */
16
- export function NL() {
17
- const ret = wasm.NL();
18
- return WasmStrCmd.__wrap(ret);
19
- }
20
-
21
- /**
22
- * The `Pop` command (the `POP` constant in the Python runtime).
23
- * @returns {WasmStrCmd}
24
- */
25
- export function POP() {
26
- const ret = wasm.POP();
27
- return WasmStrCmd.__wrap(ret);
28
- }
29
-
30
- /**
31
- * A fluent term builder, mirroring the Rust `QTermBuilder` (consuming form:
32
- * each method takes `self` and returns the next builder, so chaining works
33
- * from JS exactly as `tb("x").w("a").c(child).b()`).
34
- */
35
- export class WasmBuilder {
36
- static __wrap(ptr) {
37
- const obj = Object.create(WasmBuilder.prototype);
38
- obj.__wbg_ptr = ptr;
39
- WasmBuilderFinalization.register(obj, obj.__wbg_ptr, obj);
40
- return obj;
41
- }
42
- __destroy_into_raw() {
43
- const ptr = this.__wbg_ptr;
44
- this.__wbg_ptr = 0;
45
- WasmBuilderFinalization.unregister(this);
46
- return ptr;
47
- }
48
- free() {
49
- const ptr = this.__destroy_into_raw();
50
- wasm.__wbg_wasmbuilder_free(ptr, 0);
51
- }
52
- /**
53
- * Build the term. Consumes the builder.
54
- * @returns {WasmQTerm}
55
- */
56
- b() {
57
- const ptr = this.__destroy_into_raw();
58
- const ret = wasm.wasmbuilder_b(ptr);
59
- return WasmQTerm.__wrap(ret);
60
- }
61
- /**
62
- * Splice a child term.
63
- * @param {WasmQTerm} child
64
- * @returns {WasmBuilder}
65
- */
66
- c(child) {
67
- const ptr = this.__destroy_into_raw();
68
- _assertClass(child, WasmQTerm);
69
- const ret = wasm.wasmbuilder_c(ptr, child.__wbg_ptr);
70
- return WasmBuilder.__wrap(ret);
71
- }
72
- /**
73
- * Emit a child term (for an `Arc<QTerm>` this is the same as [`c`]).
74
- * @param {WasmQTerm} child
75
- * @returns {WasmBuilder}
76
- */
77
- e(child) {
78
- const ptr = this.__destroy_into_raw();
79
- _assertClass(child, WasmQTerm);
80
- const ret = wasm.wasmbuilder_e(ptr, child.__wbg_ptr);
81
- return WasmBuilder.__wrap(ret);
82
- }
83
- /**
84
- * Emit a newline (respecting the current prefix).
85
- * @returns {WasmBuilder}
86
- */
87
- n() {
88
- const ptr = this.__destroy_into_raw();
89
- const ret = wasm.wasmbuilder_n(ptr);
90
- return WasmBuilder.__wrap(ret);
91
- }
92
- /**
93
- * Push an indentation prefix.
94
- * @param {string} s
95
- * @returns {WasmBuilder}
96
- */
97
- p(s) {
98
- const ptr = this.__destroy_into_raw();
99
- const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
100
- const len0 = WASM_VECTOR_LEN;
101
- const ret = wasm.wasmbuilder_p(ptr, ptr0, len0);
102
- return WasmBuilder.__wrap(ret);
103
- }
104
- /**
105
- * Write literal source text.
106
- * @param {string} s
107
- * @returns {WasmBuilder}
108
- */
109
- w(s) {
110
- const ptr = this.__destroy_into_raw();
111
- const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
112
- const len0 = WASM_VECTOR_LEN;
113
- const ret = wasm.wasmbuilder_w(ptr, ptr0, len0);
114
- return WasmBuilder.__wrap(ret);
115
- }
116
- /**
117
- * Pop an indentation prefix.
118
- * @returns {WasmBuilder}
119
- */
120
- x() {
121
- const ptr = this.__destroy_into_raw();
122
- const ret = wasm.wasmbuilder_x(ptr);
123
- return WasmBuilder.__wrap(ret);
124
- }
125
- }
126
- if (Symbol.dispose) WasmBuilder.prototype[Symbol.dispose] = WasmBuilder.prototype.free;
127
-
128
- /**
129
- * A `StrCmd` or a child placeholder (`HOLE`), used in `quote`/`unquote` cmds.
130
- */
131
- export class WasmCmdOrHole {
132
- static __wrap(ptr) {
133
- const obj = Object.create(WasmCmdOrHole.prototype);
134
- obj.__wbg_ptr = ptr;
135
- WasmCmdOrHoleFinalization.register(obj, obj.__wbg_ptr, obj);
136
- return obj;
137
- }
138
- static __unwrap(jsValue) {
139
- if (!(jsValue instanceof WasmCmdOrHole)) {
140
- return 0;
141
- }
142
- return jsValue.__destroy_into_raw();
143
- }
144
- __destroy_into_raw() {
145
- const ptr = this.__wbg_ptr;
146
- this.__wbg_ptr = 0;
147
- WasmCmdOrHoleFinalization.unregister(this);
148
- return ptr;
149
- }
150
- free() {
151
- const ptr = this.__destroy_into_raw();
152
- wasm.__wbg_wasmcmdorhole_free(ptr, 0);
153
- }
154
- }
155
- if (Symbol.dispose) WasmCmdOrHole.prototype[Symbol.dispose] = WasmCmdOrHole.prototype.free;
156
-
157
- /**
158
- * A quilt term (`Arc<QTerm>`).
159
- */
160
- export class WasmQTerm {
161
- static __wrap(ptr) {
162
- const obj = Object.create(WasmQTerm.prototype);
163
- obj.__wbg_ptr = ptr;
164
- WasmQTermFinalization.register(obj, obj.__wbg_ptr, obj);
165
- return obj;
166
- }
167
- __destroy_into_raw() {
168
- const ptr = this.__wbg_ptr;
169
- this.__wbg_ptr = 0;
170
- WasmQTermFinalization.unregister(this);
171
- return ptr;
172
- }
173
- free() {
174
- const ptr = this.__destroy_into_raw();
175
- wasm.__wbg_wasmqterm_free(ptr, 0);
176
- }
177
- /**
178
- * Serialize the term back to source code.
179
- * @returns {string}
180
- */
181
- coparse() {
182
- let deferred1_0;
183
- let deferred1_1;
184
- try {
185
- const ret = wasm.wasmqterm_coparse(this.__wbg_ptr);
186
- deferred1_0 = ret[0];
187
- deferred1_1 = ret[1];
188
- return getStringFromWasm0(ret[0], ret[1]);
189
- } finally {
190
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
191
- }
192
- }
193
- /**
194
- * @returns {string}
195
- */
196
- toString() {
197
- let deferred1_0;
198
- let deferred1_1;
199
- try {
200
- const ret = wasm.wasmqterm_toString(this.__wbg_ptr);
201
- deferred1_0 = ret[0];
202
- deferred1_1 = ret[1];
203
- return getStringFromWasm0(ret[0], ret[1]);
204
- } finally {
205
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
206
- }
207
- }
208
- }
209
- if (Symbol.dispose) WasmQTerm.prototype[Symbol.dispose] = WasmQTerm.prototype.free;
210
-
211
- /**
212
- * A single string command (`write`/`NL`/`push`/`POP`).
213
- */
214
- export class WasmStrCmd {
215
- static __wrap(ptr) {
216
- const obj = Object.create(WasmStrCmd.prototype);
217
- obj.__wbg_ptr = ptr;
218
- WasmStrCmdFinalization.register(obj, obj.__wbg_ptr, obj);
219
- return obj;
220
- }
221
- __destroy_into_raw() {
222
- const ptr = this.__wbg_ptr;
223
- this.__wbg_ptr = 0;
224
- WasmStrCmdFinalization.unregister(this);
225
- return ptr;
226
- }
227
- free() {
228
- const ptr = this.__destroy_into_raw();
229
- wasm.__wbg_wasmstrcmd_free(ptr, 0);
230
- }
231
- }
232
- if (Symbol.dispose) WasmStrCmd.prototype[Symbol.dispose] = WasmStrCmd.prototype.free;
233
-
234
- /**
235
- * Wrap a `StrCmd` as a `CmdOrHole`.
236
- * @param {WasmStrCmd} c
237
- * @returns {WasmCmdOrHole}
238
- */
239
- export function cmd(c) {
240
- _assertClass(c, WasmStrCmd);
241
- const ret = wasm.cmd(c.__wbg_ptr);
242
- return WasmCmdOrHole.__wrap(ret);
243
- }
244
-
245
- /**
246
- * A leaf node: a tag whose only content is `code`.
247
- * @param {string} tag
248
- * @param {string} code
249
- * @returns {WasmQTerm}
250
- */
251
- export function leaf(tag, code) {
252
- const ptr0 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
253
- const len0 = WASM_VECTOR_LEN;
254
- const ptr1 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
255
- const len1 = WASM_VECTOR_LEN;
256
- const ret = wasm.leaf(ptr0, len0, ptr1, len1);
257
- return WasmQTerm.__wrap(ret);
258
- }
259
-
260
- /**
261
- * An identifier term (the `⟨N⟩` operator).
262
- * @param {string} s
263
- * @returns {WasmQTerm}
264
- */
265
- export function name(s) {
266
- const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
267
- const len0 = WASM_VECTOR_LEN;
268
- const ret = wasm.name(ptr0, len0);
269
- return WasmQTerm.__wrap(ret);
270
- }
271
-
272
- /**
273
- * A `Push` command.
274
- * @param {string} s
275
- * @returns {WasmStrCmd}
276
- */
277
- export function push(s) {
278
- const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
279
- const len0 = WASM_VECTOR_LEN;
280
- const ret = wasm.push(ptr0, len0);
281
- return WasmStrCmd.__wrap(ret);
282
- }
283
-
284
- /**
285
- * Lift a JS value to a term that reconstructs it (the homogeneous `↑`
286
- * operator, TypeScript into TypeScript). Supports `number`, `string`, and
287
- * `boolean`. Numbers with no fractional part lift to integer literals;
288
- * everything is coparse-only, so the tags are advisory.
289
- *
290
- * Unlike the Python runtime's `qlift`, this does *not* pass an already-built
291
- * `QTerm` through unchanged: recovering an exported wasm-bindgen type from a
292
- * polymorphic `JsValue` needs target-specific glue. The demos never lift a
293
- * term (terms splice via `↙…↘`), so this is sufficient; a JS shim can add
294
- * pass-through later if needed.
295
- * @param {any} value
296
- * @returns {WasmQTerm}
297
- */
298
- export function qlift(value) {
299
- const ret = wasm.qlift(value);
300
- if (ret[2]) {
301
- throw takeFromExternrefTable0(ret[1]);
302
- }
303
- return WasmQTerm.__wrap(ret[0]);
304
- }
305
-
306
- /**
307
- * Lift a JS value to an HTML term (the `↑` operator with an `html` splice
308
- * target). Strings become entity-escaped `text` leaves — inert as text content
309
- * or as a double-quoted attribute value — and terms pass through unchanged, so
310
- * already-built fragments can be lifted too. Mirrors `qlift_html` in the
311
- * Python runtime, minus the `QTerm` pass-through (see [`qlift`]).
312
- * @param {any} value
313
- * @returns {WasmQTerm}
314
- */
315
- export function qlift_html(value) {
316
- const ret = wasm.qlift_html(value);
317
- if (ret[2]) {
318
- throw takeFromExternrefTable0(ret[1]);
319
- }
320
- return WasmQTerm.__wrap(ret[0]);
321
- }
322
-
323
- /**
324
- * A quoted fragment.
325
- * @param {string} tag
326
- * @param {number} index
327
- * @param {string} lang
328
- * @param {WasmQTerm} term
329
- * @param {WasmCmdOrHole[]} cmds
330
- * @returns {WasmQTerm}
331
- */
332
- export function quote(tag, index, lang, term, cmds) {
333
- const ptr0 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
334
- const len0 = WASM_VECTOR_LEN;
335
- const ptr1 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
336
- const len1 = WASM_VECTOR_LEN;
337
- _assertClass(term, WasmQTerm);
338
- const ptr2 = passArrayJsValueToWasm0(cmds, wasm.__wbindgen_malloc);
339
- const len2 = WASM_VECTOR_LEN;
340
- const ret = wasm.quote(ptr0, len0, index, ptr1, len1, term.__wbg_ptr, ptr2, len2);
341
- return WasmQTerm.__wrap(ret);
342
- }
343
-
344
- /**
345
- * A symbol: a leaf whose tag and code are the same.
346
- * @param {string} s
347
- * @returns {WasmQTerm}
348
- */
349
- export function sym(s) {
350
- const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
351
- const len0 = WASM_VECTOR_LEN;
352
- const ret = wasm.sym(ptr0, len0);
353
- return WasmQTerm.__wrap(ret);
354
- }
355
-
356
- /**
357
- * Start building a tuple node with the given tag.
358
- * @param {string} tag
359
- * @returns {WasmBuilder}
360
- */
361
- export function tb(tag) {
362
- const ptr0 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
363
- const len0 = WASM_VECTOR_LEN;
364
- const ret = wasm.tb(ptr0, len0);
365
- return WasmBuilder.__wrap(ret);
366
- }
367
-
368
- /**
369
- * An unquoted splice.
370
- * @param {string} tag
371
- * @param {number} index
372
- * @param {string} lang
373
- * @param {WasmQTerm} term
374
- * @param {WasmCmdOrHole[]} cmds
375
- * @returns {WasmQTerm}
376
- */
377
- export function unquote(tag, index, lang, term, cmds) {
378
- const ptr0 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
379
- const len0 = WASM_VECTOR_LEN;
380
- const ptr1 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
381
- const len1 = WASM_VECTOR_LEN;
382
- _assertClass(term, WasmQTerm);
383
- const ptr2 = passArrayJsValueToWasm0(cmds, wasm.__wbindgen_malloc);
384
- const len2 = WASM_VECTOR_LEN;
385
- const ret = wasm.unquote(ptr0, len0, index, ptr1, len1, term.__wbg_ptr, ptr2, len2);
386
- return WasmQTerm.__wrap(ret);
387
- }
388
-
389
- /**
390
- * A `Write` command.
391
- * @param {string} s
392
- * @returns {WasmStrCmd}
393
- */
394
- export function write(s) {
395
- const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
396
- const len0 = WASM_VECTOR_LEN;
397
- const ret = wasm.write(ptr0, len0);
398
- return WasmStrCmd.__wrap(ret);
399
- }
400
- function __wbg_get_imports() {
401
- const import0 = {
402
- __proto__: null,
403
- __wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
404
- const ret = Error(getStringFromWasm0(arg0, arg1));
405
- return ret;
406
- },
407
- __wbg___wbindgen_boolean_get_edaed31a367ce1bd: function(arg0) {
408
- const v = arg0;
409
- const ret = typeof(v) === 'boolean' ? v : undefined;
410
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
411
- },
412
- __wbg___wbindgen_number_get_1cc01dd708740256: function(arg0, arg1) {
413
- const obj = arg1;
414
- const ret = typeof(obj) === 'number' ? obj : undefined;
415
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
416
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
417
- },
418
- __wbg___wbindgen_string_get_71bb4348194e31f0: function(arg0, arg1) {
419
- const obj = arg1;
420
- const ret = typeof(obj) === 'string' ? obj : undefined;
421
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
422
- var len1 = WASM_VECTOR_LEN;
423
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
424
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
425
- },
426
- __wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
427
- throw new Error(getStringFromWasm0(arg0, arg1));
428
- },
429
- __wbg_wasmcmdorhole_unwrap: function(arg0) {
430
- const ret = WasmCmdOrHole.__unwrap(arg0);
431
- return ret;
432
- },
433
- __wbindgen_init_externref_table: function() {
434
- const table = wasm.__wbindgen_externrefs;
435
- const offset = table.grow(4);
436
- table.set(0, undefined);
437
- table.set(offset + 0, undefined);
438
- table.set(offset + 1, null);
439
- table.set(offset + 2, true);
440
- table.set(offset + 3, false);
441
- },
442
- };
443
- return {
444
- __proto__: null,
445
- "./quilt_wasm_bg.js": import0,
446
- };
447
- }
448
-
449
- const WasmBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
450
- ? { register: () => {}, unregister: () => {} }
451
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmbuilder_free(ptr, 1));
452
- const WasmCmdOrHoleFinalization = (typeof FinalizationRegistry === 'undefined')
453
- ? { register: () => {}, unregister: () => {} }
454
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmcmdorhole_free(ptr, 1));
455
- const WasmQTermFinalization = (typeof FinalizationRegistry === 'undefined')
456
- ? { register: () => {}, unregister: () => {} }
457
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmqterm_free(ptr, 1));
458
- const WasmStrCmdFinalization = (typeof FinalizationRegistry === 'undefined')
459
- ? { register: () => {}, unregister: () => {} }
460
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmstrcmd_free(ptr, 1));
461
-
462
- function addToExternrefTable0(obj) {
463
- const idx = wasm.__externref_table_alloc();
464
- wasm.__wbindgen_externrefs.set(idx, obj);
465
- return idx;
466
- }
467
-
468
- function _assertClass(instance, klass) {
469
- if (!(instance instanceof klass)) {
470
- throw new Error(`expected instance of ${klass.name}`);
471
- }
472
- }
473
-
474
- let cachedDataViewMemory0 = null;
475
- function getDataViewMemory0() {
476
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
477
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
478
- }
479
- return cachedDataViewMemory0;
480
- }
481
-
482
- function getStringFromWasm0(ptr, len) {
483
- return decodeText(ptr >>> 0, len);
484
- }
485
-
486
- let cachedUint8ArrayMemory0 = null;
487
- function getUint8ArrayMemory0() {
488
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
489
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
490
- }
491
- return cachedUint8ArrayMemory0;
492
- }
493
-
494
- function isLikeNone(x) {
495
- return x === undefined || x === null;
496
- }
497
-
498
- function passArrayJsValueToWasm0(array, malloc) {
499
- const ptr = malloc(array.length * 4, 4) >>> 0;
500
- for (let i = 0; i < array.length; i++) {
501
- const add = addToExternrefTable0(array[i]);
502
- getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
503
- }
504
- WASM_VECTOR_LEN = array.length;
505
- return ptr;
506
- }
507
-
508
- function passStringToWasm0(arg, malloc, realloc) {
509
- if (realloc === undefined) {
510
- const buf = cachedTextEncoder.encode(arg);
511
- const ptr = malloc(buf.length, 1) >>> 0;
512
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
513
- WASM_VECTOR_LEN = buf.length;
514
- return ptr;
515
- }
516
-
517
- let len = arg.length;
518
- let ptr = malloc(len, 1) >>> 0;
519
-
520
- const mem = getUint8ArrayMemory0();
521
-
522
- let offset = 0;
523
-
524
- for (; offset < len; offset++) {
525
- const code = arg.charCodeAt(offset);
526
- if (code > 0x7F) break;
527
- mem[ptr + offset] = code;
528
- }
529
- if (offset !== len) {
530
- if (offset !== 0) {
531
- arg = arg.slice(offset);
532
- }
533
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
534
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
535
- const ret = cachedTextEncoder.encodeInto(arg, view);
536
-
537
- offset += ret.written;
538
- ptr = realloc(ptr, len, offset, 1) >>> 0;
539
- }
540
-
541
- WASM_VECTOR_LEN = offset;
542
- return ptr;
543
- }
544
-
545
- function takeFromExternrefTable0(idx) {
546
- const value = wasm.__wbindgen_externrefs.get(idx);
547
- wasm.__externref_table_dealloc(idx);
548
- return value;
549
- }
550
-
551
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
552
- cachedTextDecoder.decode();
553
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
554
- let numBytesDecoded = 0;
555
- function decodeText(ptr, len) {
556
- numBytesDecoded += len;
557
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
558
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
559
- cachedTextDecoder.decode();
560
- numBytesDecoded = len;
561
- }
562
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
563
- }
564
-
565
- const cachedTextEncoder = new TextEncoder();
566
-
567
- if (!('encodeInto' in cachedTextEncoder)) {
568
- cachedTextEncoder.encodeInto = function (arg, view) {
569
- const buf = cachedTextEncoder.encode(arg);
570
- view.set(buf);
571
- return {
572
- read: arg.length,
573
- written: buf.length
574
- };
575
- };
576
- }
577
-
578
- let WASM_VECTOR_LEN = 0;
579
-
580
- let wasmModule, wasmInstance, wasm;
581
- function __wbg_finalize_init(instance, module) {
582
- wasmInstance = instance;
583
- wasm = instance.exports;
584
- wasmModule = module;
585
- cachedDataViewMemory0 = null;
586
- cachedUint8ArrayMemory0 = null;
587
- wasm.__wbindgen_start();
588
- return wasm;
589
- }
590
-
591
- async function __wbg_load(module, imports) {
592
- if (typeof Response === 'function' && module instanceof Response) {
593
- if (typeof WebAssembly.instantiateStreaming === 'function') {
594
- try {
595
- return await WebAssembly.instantiateStreaming(module, imports);
596
- } catch (e) {
597
- const validResponse = module.ok && expectedResponseType(module.type);
598
-
599
- if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
600
- 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);
601
-
602
- } else { throw e; }
603
- }
604
- }
605
-
606
- const bytes = await module.arrayBuffer();
607
- return await WebAssembly.instantiate(bytes, imports);
608
- } else {
609
- const instance = await WebAssembly.instantiate(module, imports);
610
-
611
- if (instance instanceof WebAssembly.Instance) {
612
- return { instance, module };
613
- } else {
614
- return instance;
615
- }
616
- }
617
-
618
- function expectedResponseType(type) {
619
- switch (type) {
620
- case 'basic': case 'cors': case 'default': return true;
621
- }
622
- return false;
623
- }
624
- }
625
-
626
- function initSync(module) {
627
- if (wasm !== undefined) return wasm;
628
-
629
-
630
- if (module !== undefined) {
631
- if (Object.getPrototypeOf(module) === Object.prototype) {
632
- ({module} = module)
633
- } else {
634
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
635
- }
636
- }
637
-
638
- const imports = __wbg_get_imports();
639
- if (!(module instanceof WebAssembly.Module)) {
640
- module = new WebAssembly.Module(module);
641
- }
642
- const instance = new WebAssembly.Instance(module, imports);
643
- return __wbg_finalize_init(instance, module);
644
- }
645
-
646
- async function __wbg_init(module_or_path) {
647
- if (wasm !== undefined) return wasm;
648
-
649
-
650
- if (module_or_path !== undefined) {
651
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
652
- ({module_or_path} = module_or_path)
653
- } else {
654
- console.warn('using deprecated parameters for the initialization function; pass a single object instead')
655
- }
656
- }
657
-
658
- if (module_or_path === undefined) {
659
- module_or_path = new URL('quilt_wasm_bg.wasm', import.meta.url);
660
- }
661
- const imports = __wbg_get_imports();
662
-
663
- if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
664
- module_or_path = fetch(module_or_path);
665
- }
666
-
667
- const { instance, module } = await __wbg_load(await module_or_path, imports);
668
-
669
- return __wbg_finalize_init(instance, module);
670
- }
671
-
672
- export { initSync, __wbg_init as default };
1
+ // Generated by quilt-wasm/js/assemble.mjs. Do not edit.
2
+ import * as raw from "./quilt_wasm_raw.js";
3
+ import { __bindWasm } from "./quilt_runtime.js";
4
+ __bindWasm(raw);
5
+ export * from "./quilt_runtime.js";
6
+ export { default, initSync, __memoryBytes } from "./quilt_wasm_raw.js";