quilt-wasm 0.5.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.
@@ -0,0 +1,66 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * The size of this module's linear memory, in bytes — for tests and
6
+ * benchmarks that check a workload runs in bounded memory (wasm memory only
7
+ * ever grows, so a leak shows up here as growth). Not API.
8
+ */
9
+ export function __memoryBytes(): number;
10
+
11
+ /**
12
+ * The Rust `coparse` of an encoded term.
13
+ */
14
+ export function coparse(ops: Uint32Array | number[], strings: string[]): string;
15
+
16
+ /**
17
+ * Format a JS number: drop the decimal point when it is integral (`42`, not
18
+ * `42.0`), so lifted whole numbers read as integer literals.
19
+ */
20
+ export function fmt_number(n: number): string;
21
+
22
+ /**
23
+ * `qlift` of an encoded term: the encoded term whose TypeScript rebuilds it,
24
+ * so `↓(↑(x)) == x` (issue #166). Returns `[ops, strings]`.
25
+ */
26
+ export function lift(ops: Uint32Array | number[], strings: string[]): Array<any>;
27
+
28
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
29
+
30
+ export interface InitOutput {
31
+ readonly memory: WebAssembly.Memory;
32
+ readonly __memoryBytes: () => number;
33
+ readonly coparse: (a: number, b: number, c: number, d: number) => [number, number, number, number];
34
+ readonly fmt_number: (a: number) => [number, number];
35
+ readonly lift: (a: number, b: number, c: number, d: number) => [number, number, number];
36
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
37
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
38
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
39
+ readonly __wbindgen_externrefs: WebAssembly.Table;
40
+ readonly __externref_table_alloc: () => number;
41
+ readonly __externref_drop_slice: (a: number, b: number) => void;
42
+ readonly __externref_table_dealloc: (a: number) => void;
43
+ readonly __wbindgen_start: () => void;
44
+ }
45
+
46
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
47
+
48
+ /**
49
+ * Instantiates the given `module`, which can either be bytes or
50
+ * a precompiled `WebAssembly.Module`.
51
+ *
52
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
53
+ *
54
+ * @returns {InitOutput}
55
+ */
56
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
57
+
58
+ /**
59
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
60
+ * for everything else, calls `WebAssembly.instantiate` directly.
61
+ *
62
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
63
+ *
64
+ * @returns {Promise<InitOutput>}
65
+ */
66
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,382 @@
1
+ /* @ts-self-types="./quilt_wasm_raw.d.ts" */
2
+
3
+ /**
4
+ * The size of this module's linear memory, in bytes — for tests and
5
+ * benchmarks that check a workload runs in bounded memory (wasm memory only
6
+ * ever grows, so a leak shows up here as growth). Not API.
7
+ * @returns {number}
8
+ */
9
+ export function __memoryBytes() {
10
+ const ret = wasm.__memoryBytes();
11
+ return ret;
12
+ }
13
+
14
+ /**
15
+ * The Rust `coparse` of an encoded term.
16
+ * @param {Uint32Array | number[]} ops
17
+ * @param {string[]} strings
18
+ * @returns {string}
19
+ */
20
+ export function coparse(ops, strings) {
21
+ let deferred4_0;
22
+ let deferred4_1;
23
+ try {
24
+ let ptr0, len0, ptr1, len1;
25
+ try {
26
+ ptr0 = passArray32ToWasm0(ops, wasm.__wbindgen_malloc);
27
+ len0 = WASM_VECTOR_LEN;
28
+ ptr1 = passArrayJsValueToWasm0(strings, wasm.__wbindgen_malloc);
29
+ len1 = WASM_VECTOR_LEN;
30
+ } catch (e) {
31
+ if (ptr1) { wasm.__externref_drop_slice(ptr1, len1); wasm.__wbindgen_free(ptr1, len1 * 4, 4); }
32
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 4, 4); }
33
+ throw e;
34
+ }
35
+ const ret = wasm.coparse(ptr0, len0, ptr1, len1);
36
+ var ptr3 = ret[0];
37
+ var len3 = ret[1];
38
+ if (ret[3]) {
39
+ ptr3 = 0; len3 = 0;
40
+ throw takeFromExternrefTable0(ret[2]);
41
+ }
42
+ deferred4_0 = ptr3;
43
+ deferred4_1 = len3;
44
+ return getStringFromWasm0(ptr3, len3);
45
+ } finally {
46
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Format a JS number: drop the decimal point when it is integral (`42`, not
52
+ * `42.0`), so lifted whole numbers read as integer literals.
53
+ * @param {number} n
54
+ * @returns {string}
55
+ */
56
+ export function fmt_number(n) {
57
+ let deferred1_0;
58
+ let deferred1_1;
59
+ try {
60
+ const ret = wasm.fmt_number(n);
61
+ deferred1_0 = ret[0];
62
+ deferred1_1 = ret[1];
63
+ return getStringFromWasm0(ret[0], ret[1]);
64
+ } finally {
65
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
66
+ }
67
+ }
68
+
69
+ /**
70
+ * `qlift` of an encoded term: the encoded term whose TypeScript rebuilds it,
71
+ * so `↓(↑(x)) == x` (issue #166). Returns `[ops, strings]`.
72
+ * @param {Uint32Array | number[]} ops
73
+ * @param {string[]} strings
74
+ * @returns {Array<any>}
75
+ */
76
+ export function lift(ops, strings) {
77
+ let ptr0, len0, ptr1, len1;
78
+ try {
79
+ ptr0 = passArray32ToWasm0(ops, wasm.__wbindgen_malloc);
80
+ len0 = WASM_VECTOR_LEN;
81
+ ptr1 = passArrayJsValueToWasm0(strings, wasm.__wbindgen_malloc);
82
+ len1 = WASM_VECTOR_LEN;
83
+ } catch (e) {
84
+ if (ptr1) { wasm.__externref_drop_slice(ptr1, len1); wasm.__wbindgen_free(ptr1, len1 * 4, 4); }
85
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 4, 4); }
86
+ throw e;
87
+ }
88
+ const ret = wasm.lift(ptr0, len0, ptr1, len1);
89
+ if (ret[2]) {
90
+ throw takeFromExternrefTable0(ret[1]);
91
+ }
92
+ return takeFromExternrefTable0(ret[0]);
93
+ }
94
+ function __wbg_get_imports() {
95
+ const import0 = {
96
+ __proto__: null,
97
+ __wbg_Error_208446807d0d1e30: function(arg0, arg1) {
98
+ const ret = Error(getStringFromWasm0(arg0, arg1));
99
+ return ret;
100
+ },
101
+ __wbg___wbindgen_string_get_7ce8eee7fd327545: function(arg0, arg1) {
102
+ const obj = arg1;
103
+ const ret = typeof(obj) === 'string' ? obj : undefined;
104
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
105
+ var len1 = WASM_VECTOR_LEN;
106
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
107
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
108
+ },
109
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
110
+ throw new Error(getStringFromWasm0(arg0, arg1));
111
+ },
112
+ __wbg_new_37eb45aaf5eeb820: function() {
113
+ const ret = new Array();
114
+ return ret;
115
+ },
116
+ __wbg_new_from_slice_3512352010266e02: function(arg0, arg1) {
117
+ const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
118
+ return ret;
119
+ },
120
+ __wbg_push_c9f4893fc209f768: function(arg0, arg1) {
121
+ const ret = arg0.push(arg1);
122
+ return ret;
123
+ },
124
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
125
+ // Cast intrinsic for `Ref(String) -> Externref`.
126
+ const ret = getStringFromWasm0(arg0, arg1);
127
+ return ret;
128
+ },
129
+ __wbindgen_init_externref_table: function() {
130
+ const table = wasm.__wbindgen_externrefs;
131
+ table.set(0, undefined);
132
+ table.set(1024, undefined);
133
+ table.set(1025, null);
134
+ table.set(1026, true);
135
+ table.set(1027, false);
136
+ },
137
+ };
138
+ return {
139
+ __proto__: null,
140
+ "./quilt_wasm_raw_bg.js": import0,
141
+ };
142
+ }
143
+
144
+ function addToExternrefTable0(obj) {
145
+ const idx = wasm.__externref_table_alloc();
146
+ wasm.__wbindgen_externrefs.set(idx, obj);
147
+ return idx;
148
+ }
149
+
150
+ function getArrayU32FromWasm0(ptr, len) {
151
+ ptr = ptr >>> 0;
152
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
153
+ }
154
+
155
+ let cachedDataViewMemory0 = null;
156
+ function getDataViewMemory0() {
157
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
158
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
159
+ }
160
+ return cachedDataViewMemory0;
161
+ }
162
+
163
+ function getStringFromWasm0(ptr, len) {
164
+ ptr = ptr >>> 0;
165
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
166
+ }
167
+
168
+ let cachedUint32ArrayMemory0 = null;
169
+ function getUint32ArrayMemory0() {
170
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
171
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
172
+ }
173
+ return cachedUint32ArrayMemory0;
174
+ }
175
+
176
+ let cachedUint8ArrayMemory0 = null;
177
+ function getUint8ArrayMemory0() {
178
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
179
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
180
+ }
181
+ return cachedUint8ArrayMemory0;
182
+ }
183
+
184
+ function isLikeNone(x) {
185
+ return x === undefined || x === null;
186
+ }
187
+
188
+ function passArray32ToWasm0(arg, malloc) {
189
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
190
+ getUint32ArrayMemory0().set(arg, ptr / 4);
191
+ WASM_VECTOR_LEN = arg.length;
192
+ return ptr;
193
+ }
194
+
195
+ function passArrayJsValueToWasm0(array, malloc) {
196
+ const ptr = malloc(array.length * 4, 4) >>> 0;
197
+ for (let i = 0; i < array.length; i++) {
198
+ const add = addToExternrefTable0(array[i]);
199
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
200
+ }
201
+ WASM_VECTOR_LEN = array.length;
202
+ return ptr;
203
+ }
204
+
205
+ function passStringToWasm0(arg, malloc, realloc) {
206
+ if (realloc === undefined) {
207
+ const buf = cachedTextEncoder.encode(arg);
208
+ const ptr = malloc(buf.length, 1) >>> 0;
209
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
210
+ WASM_VECTOR_LEN = buf.length;
211
+ return ptr;
212
+ }
213
+
214
+ let len = arg.length;
215
+ let ptr = malloc(len, 1) >>> 0;
216
+
217
+ const mem = getUint8ArrayMemory0();
218
+
219
+ let offset = 0;
220
+
221
+ for (; offset < len; offset++) {
222
+ const code = arg.charCodeAt(offset);
223
+ if (code > 0x7F) break;
224
+ mem[ptr + offset] = code;
225
+ }
226
+ if (offset !== len) {
227
+ if (offset !== 0) {
228
+ arg = arg.slice(offset);
229
+ }
230
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
231
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
232
+ const ret = cachedTextEncoder.encodeInto(arg, view);
233
+
234
+ offset += ret.written;
235
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
236
+ }
237
+
238
+ WASM_VECTOR_LEN = offset;
239
+ return ptr;
240
+ }
241
+
242
+ function takeFromExternrefTable0(idx) {
243
+ const value = wasm.__wbindgen_externrefs.get(idx);
244
+ wasm.__externref_table_dealloc(idx);
245
+ return value;
246
+ }
247
+
248
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
249
+ cachedTextDecoder.decode();
250
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
251
+ let numBytesDecoded = 0;
252
+ function decodeText(bytes) {
253
+ numBytesDecoded += bytes.length;
254
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
255
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
256
+ cachedTextDecoder.decode();
257
+ numBytesDecoded = bytes.length;
258
+ }
259
+ return cachedTextDecoder.decode(bytes);
260
+ }
261
+
262
+ const cachedTextEncoder = new TextEncoder();
263
+
264
+ if (!('encodeInto' in cachedTextEncoder)) {
265
+ cachedTextEncoder.encodeInto = function (arg, view) {
266
+ const buf = cachedTextEncoder.encode(arg);
267
+ view.set(buf);
268
+ return {
269
+ read: arg.length,
270
+ written: buf.length
271
+ };
272
+ };
273
+ }
274
+
275
+ let WASM_VECTOR_LEN = 0;
276
+
277
+ let wasmModule, wasmInstance, wasm;
278
+ function __wbg_finalize_init(instance, module) {
279
+ wasmInstance = instance;
280
+ wasm = instance.exports;
281
+ wasmModule = module;
282
+ cachedDataViewMemory0 = null;
283
+ cachedUint32ArrayMemory0 = null;
284
+ cachedUint8ArrayMemory0 = null;
285
+ wasm.__wbindgen_start();
286
+ return wasm;
287
+ }
288
+
289
+ async function __wbg_load(module, imports) {
290
+ if (typeof Response === 'function' && module instanceof Response) {
291
+ if (!module.ok) {
292
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
293
+ }
294
+
295
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
296
+ try {
297
+ return await WebAssembly.instantiateStreaming(module, imports);
298
+ } catch (e) {
299
+ const validResponse = expectedResponseType(module.type);
300
+
301
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
302
+ 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);
303
+
304
+ } else { throw e; }
305
+ }
306
+ }
307
+
308
+ const bytes = await module.arrayBuffer();
309
+ return await WebAssembly.instantiate(bytes, imports);
310
+ } else {
311
+ const instance = await WebAssembly.instantiate(module, imports);
312
+
313
+ if (instance instanceof WebAssembly.Instance) {
314
+ return { instance, module };
315
+ } else {
316
+ return instance;
317
+ }
318
+ }
319
+
320
+ function expectedResponseType(type) {
321
+ switch (type) {
322
+ case 'basic': case 'cors': case 'default': return true;
323
+ }
324
+ return false;
325
+ }
326
+ }
327
+
328
+ function initSync(module) {
329
+ if (wasm !== undefined) return wasm;
330
+
331
+
332
+ if (module !== undefined) {
333
+ if (Object.getPrototypeOf(module) === Object.prototype) {
334
+ ({module} = module)
335
+ } else {
336
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
337
+ }
338
+ }
339
+
340
+ const imports = __wbg_get_imports();
341
+ if (!(module instanceof WebAssembly.Module)) {
342
+ module = new WebAssembly.Module(module);
343
+ }
344
+ const instance = new WebAssembly.Instance(module, imports);
345
+ return __wbg_finalize_init(instance, module);
346
+ }
347
+
348
+ let __wbg_init_promise;
349
+ async function __wbg_init(module_or_path) {
350
+ if (wasm !== undefined) return wasm;
351
+ if (__wbg_init_promise === undefined) {
352
+ __wbg_init_promise = __wbg_init_once(module_or_path);
353
+ __wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
354
+ }
355
+ return __wbg_init_promise;
356
+ }
357
+
358
+ async function __wbg_init_once(module_or_path) {
359
+
360
+ if (module_or_path !== undefined) {
361
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
362
+ ({module_or_path} = module_or_path)
363
+ } else {
364
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
365
+ }
366
+ }
367
+
368
+ if (module_or_path === undefined) {
369
+ module_or_path = new URL('quilt_wasm_raw_bg.wasm', import.meta.url);
370
+ }
371
+ const imports = __wbg_get_imports();
372
+
373
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
374
+ module_or_path = fetch(module_or_path);
375
+ }
376
+
377
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
378
+
379
+ return __wbg_finalize_init(instance, module);
380
+ }
381
+
382
+ export { initSync, __wbg_init as default };
Binary file
Binary file