@seonbi/wasm 0.1.0-alpha.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,7 @@
1
+ # @seonbi/wasm
2
+
3
+ <p align="center">
4
+ <img src="../../assets/logo.svg" alt="seonbi logo" width="180">
5
+ </p>
6
+
7
+ WASM binding for `seonbi-rs` using `wasm-bindgen`.
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@seonbi/wasm",
3
+ "type": "module",
4
+ "version": "0.1.0-alpha.0",
5
+ "license": "LGPL-2.1",
6
+ "files": [
7
+ "wasm_bg.wasm",
8
+ "wasm.js",
9
+ "wasm.d.ts"
10
+ ],
11
+ "main": "wasm.js",
12
+ "types": "wasm.d.ts",
13
+ "sideEffects": [
14
+ "./snippets/*"
15
+ ]
16
+ }
package/wasm.d.ts ADDED
@@ -0,0 +1,80 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export interface ArrowOption {
4
+ bidirArrow: boolean;
5
+ doubleArrow: boolean;
6
+ }
7
+
8
+ export interface Configuration {
9
+ contentType: string | undefined;
10
+ preset: string | undefined;
11
+ quote: QuoteOption | undefined;
12
+ cite: CiteOption | undefined;
13
+ arrow: ArrowOption | undefined;
14
+ ellipsis: boolean | undefined;
15
+ emDash: boolean | undefined;
16
+ stop: StopOption | undefined;
17
+ hanja: HanjaOption | undefined;
18
+ }
19
+
20
+ export interface HanjaOption {
21
+ rendering: HanjaRenderingOption;
22
+ reading: HanjaReadingOption;
23
+ }
24
+
25
+ export interface HanjaReadingOption {
26
+ initialSoundLaw: boolean;
27
+ useDictionaries: string[];
28
+ dictionary?: Map<string, string>;
29
+ }
30
+
31
+ export type CiteOption = "AngleQuotes" | "CornerBrackets" | "AngleQuotesWithCite" | "CornerBracketsWithCite";
32
+
33
+ export type HanjaRenderingOption = "HangulOnly" | "HanjaInParentheses" | "DisambiguatingHanjaInParentheses" | "HanjaInRuby";
34
+
35
+ export type QuoteOption = "CurvedQuotes" | "VerticalCornerBrackets" | "HorizontalCornerBrackets" | "Guillemets" | "CurvedSingleQuotesWithQ" | "VerticalCornerBracketsWithQ" | "HorizontalCornerBracketsWithQ";
36
+
37
+ export type StopOption = "Horizontal" | "HorizontalWithSlashes" | "Vertical";
38
+
39
+
40
+ export function koKp(): Configuration;
41
+
42
+ export function koKr(): Configuration;
43
+
44
+ export function transform(config: Configuration, input: string): string;
45
+
46
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
47
+
48
+ export interface InitOutput {
49
+ readonly memory: WebAssembly.Memory;
50
+ readonly koKp: () => number;
51
+ readonly koKr: () => number;
52
+ readonly transform: (a: number, b: number, c: number, d: number) => void;
53
+ readonly __wbindgen_export: (a: number, b: number) => number;
54
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
55
+ readonly __wbindgen_export3: (a: number) => void;
56
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
57
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
58
+ }
59
+
60
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
61
+
62
+ /**
63
+ * Instantiates the given `module`, which can either be bytes or
64
+ * a precompiled `WebAssembly.Module`.
65
+ *
66
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
67
+ *
68
+ * @returns {InitOutput}
69
+ */
70
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
71
+
72
+ /**
73
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
74
+ * for everything else, calls `WebAssembly.instantiate` directly.
75
+ *
76
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
77
+ *
78
+ * @returns {Promise<InitOutput>}
79
+ */
80
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/wasm.js ADDED
@@ -0,0 +1,526 @@
1
+ /* @ts-self-types="./wasm.d.ts" */
2
+
3
+ /**
4
+ * @returns {Configuration}
5
+ */
6
+ export function koKp() {
7
+ const ret = wasm.koKp();
8
+ return takeObject(ret);
9
+ }
10
+
11
+ /**
12
+ * @returns {Configuration}
13
+ */
14
+ export function koKr() {
15
+ const ret = wasm.koKr();
16
+ return takeObject(ret);
17
+ }
18
+
19
+ /**
20
+ * @param {Configuration} config
21
+ * @param {string} input
22
+ * @returns {string}
23
+ */
24
+ export function transform(config, input) {
25
+ let deferred3_0;
26
+ let deferred3_1;
27
+ try {
28
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
29
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
30
+ const len0 = WASM_VECTOR_LEN;
31
+ wasm.transform(retptr, addHeapObject(config), ptr0, len0);
32
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
33
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
34
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
35
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
36
+ var ptr2 = r0;
37
+ var len2 = r1;
38
+ if (r3) {
39
+ ptr2 = 0; len2 = 0;
40
+ throw takeObject(r2);
41
+ }
42
+ deferred3_0 = ptr2;
43
+ deferred3_1 = len2;
44
+ return getStringFromWasm0(ptr2, len2);
45
+ } finally {
46
+ wasm.__wbindgen_add_to_stack_pointer(16);
47
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
48
+ }
49
+ }
50
+
51
+ function __wbg_get_imports() {
52
+ const import0 = {
53
+ __proto__: null,
54
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
55
+ const ret = Error(getStringFromWasm0(arg0, arg1));
56
+ return addHeapObject(ret);
57
+ },
58
+ __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
59
+ const ret = String(getObject(arg1));
60
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
61
+ const len1 = WASM_VECTOR_LEN;
62
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
63
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
64
+ },
65
+ __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
66
+ const v = getObject(arg0);
67
+ const ret = typeof(v) === 'boolean' ? v : undefined;
68
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
69
+ },
70
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
71
+ const ret = debugString(getObject(arg1));
72
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
73
+ const len1 = WASM_VECTOR_LEN;
74
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
75
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
76
+ },
77
+ __wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
78
+ const ret = getObject(arg0) in getObject(arg1);
79
+ return ret;
80
+ },
81
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
82
+ const ret = typeof(getObject(arg0)) === 'function';
83
+ return ret;
84
+ },
85
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
86
+ const val = getObject(arg0);
87
+ const ret = typeof(val) === 'object' && val !== null;
88
+ return ret;
89
+ },
90
+ __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
91
+ const ret = typeof(getObject(arg0)) === 'string';
92
+ return ret;
93
+ },
94
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
95
+ const ret = getObject(arg0) === undefined;
96
+ return ret;
97
+ },
98
+ __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
99
+ const ret = getObject(arg0) == getObject(arg1);
100
+ return ret;
101
+ },
102
+ __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
103
+ const obj = getObject(arg1);
104
+ const ret = typeof(obj) === 'number' ? obj : undefined;
105
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
106
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
107
+ },
108
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
109
+ const obj = getObject(arg1);
110
+ const ret = typeof(obj) === 'string' ? obj : undefined;
111
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
112
+ var len1 = WASM_VECTOR_LEN;
113
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
114
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
115
+ },
116
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
117
+ throw new Error(getStringFromWasm0(arg0, arg1));
118
+ },
119
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
120
+ const ret = getObject(arg0).call(getObject(arg1));
121
+ return addHeapObject(ret);
122
+ }, arguments); },
123
+ __wbg_done_57b39ecd9addfe81: function(arg0) {
124
+ const ret = getObject(arg0).done;
125
+ return ret;
126
+ },
127
+ __wbg_entries_58c7934c745daac7: function(arg0) {
128
+ const ret = Object.entries(getObject(arg0));
129
+ return addHeapObject(ret);
130
+ },
131
+ __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
132
+ const ret = getObject(arg0)[arg1 >>> 0];
133
+ return addHeapObject(ret);
134
+ },
135
+ __wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
136
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
137
+ return addHeapObject(ret);
138
+ }, arguments); },
139
+ __wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
140
+ const ret = getObject(arg0)[getObject(arg1)];
141
+ return addHeapObject(ret);
142
+ },
143
+ __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
144
+ let result;
145
+ try {
146
+ result = getObject(arg0) instanceof ArrayBuffer;
147
+ } catch (_) {
148
+ result = false;
149
+ }
150
+ const ret = result;
151
+ return ret;
152
+ },
153
+ __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
154
+ let result;
155
+ try {
156
+ result = getObject(arg0) instanceof Uint8Array;
157
+ } catch (_) {
158
+ result = false;
159
+ }
160
+ const ret = result;
161
+ return ret;
162
+ },
163
+ __wbg_isArray_d314bb98fcf08331: function(arg0) {
164
+ const ret = Array.isArray(getObject(arg0));
165
+ return ret;
166
+ },
167
+ __wbg_iterator_6ff6560ca1568e55: function() {
168
+ const ret = Symbol.iterator;
169
+ return addHeapObject(ret);
170
+ },
171
+ __wbg_length_32ed9a279acd054c: function(arg0) {
172
+ const ret = getObject(arg0).length;
173
+ return ret;
174
+ },
175
+ __wbg_length_35a7bace40f36eac: function(arg0) {
176
+ const ret = getObject(arg0).length;
177
+ return ret;
178
+ },
179
+ __wbg_new_361308b2356cecd0: function() {
180
+ const ret = new Object();
181
+ return addHeapObject(ret);
182
+ },
183
+ __wbg_new_3eb36ae241fe6f44: function() {
184
+ const ret = new Array();
185
+ return addHeapObject(ret);
186
+ },
187
+ __wbg_new_dca287b076112a51: function() {
188
+ const ret = new Map();
189
+ return addHeapObject(ret);
190
+ },
191
+ __wbg_new_dd2b680c8bf6ae29: function(arg0) {
192
+ const ret = new Uint8Array(getObject(arg0));
193
+ return addHeapObject(ret);
194
+ },
195
+ __wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
196
+ const ret = getObject(arg0).next();
197
+ return addHeapObject(ret);
198
+ }, arguments); },
199
+ __wbg_next_418f80d8f5303233: function(arg0) {
200
+ const ret = getObject(arg0).next;
201
+ return addHeapObject(ret);
202
+ },
203
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
204
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
205
+ },
206
+ __wbg_set_1eb0999cf5d27fc8: function(arg0, arg1, arg2) {
207
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
208
+ return addHeapObject(ret);
209
+ },
210
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
211
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
212
+ },
213
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
214
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
215
+ },
216
+ __wbg_value_0546255b415e96c1: function(arg0) {
217
+ const ret = getObject(arg0).value;
218
+ return addHeapObject(ret);
219
+ },
220
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
221
+ // Cast intrinsic for `Ref(String) -> Externref`.
222
+ const ret = getStringFromWasm0(arg0, arg1);
223
+ return addHeapObject(ret);
224
+ },
225
+ __wbindgen_object_clone_ref: function(arg0) {
226
+ const ret = getObject(arg0);
227
+ return addHeapObject(ret);
228
+ },
229
+ __wbindgen_object_drop_ref: function(arg0) {
230
+ takeObject(arg0);
231
+ },
232
+ };
233
+ return {
234
+ __proto__: null,
235
+ "./wasm_bg.js": import0,
236
+ };
237
+ }
238
+
239
+ function addHeapObject(obj) {
240
+ if (heap_next === heap.length) heap.push(heap.length + 1);
241
+ const idx = heap_next;
242
+ heap_next = heap[idx];
243
+
244
+ heap[idx] = obj;
245
+ return idx;
246
+ }
247
+
248
+ function debugString(val) {
249
+ // primitive types
250
+ const type = typeof val;
251
+ if (type == 'number' || type == 'boolean' || val == null) {
252
+ return `${val}`;
253
+ }
254
+ if (type == 'string') {
255
+ return `"${val}"`;
256
+ }
257
+ if (type == 'symbol') {
258
+ const description = val.description;
259
+ if (description == null) {
260
+ return 'Symbol';
261
+ } else {
262
+ return `Symbol(${description})`;
263
+ }
264
+ }
265
+ if (type == 'function') {
266
+ const name = val.name;
267
+ if (typeof name == 'string' && name.length > 0) {
268
+ return `Function(${name})`;
269
+ } else {
270
+ return 'Function';
271
+ }
272
+ }
273
+ // objects
274
+ if (Array.isArray(val)) {
275
+ const length = val.length;
276
+ let debug = '[';
277
+ if (length > 0) {
278
+ debug += debugString(val[0]);
279
+ }
280
+ for(let i = 1; i < length; i++) {
281
+ debug += ', ' + debugString(val[i]);
282
+ }
283
+ debug += ']';
284
+ return debug;
285
+ }
286
+ // Test for built-in
287
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
288
+ let className;
289
+ if (builtInMatches && builtInMatches.length > 1) {
290
+ className = builtInMatches[1];
291
+ } else {
292
+ // Failed to match the standard '[object ClassName]'
293
+ return toString.call(val);
294
+ }
295
+ if (className == 'Object') {
296
+ // we're a user defined class or Object
297
+ // JSON.stringify avoids problems with cycles, and is generally much
298
+ // easier than looping through ownProperties of `val`.
299
+ try {
300
+ return 'Object(' + JSON.stringify(val) + ')';
301
+ } catch (_) {
302
+ return 'Object';
303
+ }
304
+ }
305
+ // errors
306
+ if (val instanceof Error) {
307
+ return `${val.name}: ${val.message}\n${val.stack}`;
308
+ }
309
+ // TODO we could test for more things here, like `Set`s and `Map`s.
310
+ return className;
311
+ }
312
+
313
+ function dropObject(idx) {
314
+ if (idx < 132) return;
315
+ heap[idx] = heap_next;
316
+ heap_next = idx;
317
+ }
318
+
319
+ function getArrayU8FromWasm0(ptr, len) {
320
+ ptr = ptr >>> 0;
321
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
322
+ }
323
+
324
+ let cachedDataViewMemory0 = null;
325
+ function getDataViewMemory0() {
326
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
327
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
328
+ }
329
+ return cachedDataViewMemory0;
330
+ }
331
+
332
+ function getStringFromWasm0(ptr, len) {
333
+ ptr = ptr >>> 0;
334
+ return decodeText(ptr, len);
335
+ }
336
+
337
+ let cachedUint8ArrayMemory0 = null;
338
+ function getUint8ArrayMemory0() {
339
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
340
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
341
+ }
342
+ return cachedUint8ArrayMemory0;
343
+ }
344
+
345
+ function getObject(idx) { return heap[idx]; }
346
+
347
+ function handleError(f, args) {
348
+ try {
349
+ return f.apply(this, args);
350
+ } catch (e) {
351
+ wasm.__wbindgen_export3(addHeapObject(e));
352
+ }
353
+ }
354
+
355
+ let heap = new Array(128).fill(undefined);
356
+ heap.push(undefined, null, true, false);
357
+
358
+ let heap_next = heap.length;
359
+
360
+ function isLikeNone(x) {
361
+ return x === undefined || x === null;
362
+ }
363
+
364
+ function passStringToWasm0(arg, malloc, realloc) {
365
+ if (realloc === undefined) {
366
+ const buf = cachedTextEncoder.encode(arg);
367
+ const ptr = malloc(buf.length, 1) >>> 0;
368
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
369
+ WASM_VECTOR_LEN = buf.length;
370
+ return ptr;
371
+ }
372
+
373
+ let len = arg.length;
374
+ let ptr = malloc(len, 1) >>> 0;
375
+
376
+ const mem = getUint8ArrayMemory0();
377
+
378
+ let offset = 0;
379
+
380
+ for (; offset < len; offset++) {
381
+ const code = arg.charCodeAt(offset);
382
+ if (code > 0x7F) break;
383
+ mem[ptr + offset] = code;
384
+ }
385
+ if (offset !== len) {
386
+ if (offset !== 0) {
387
+ arg = arg.slice(offset);
388
+ }
389
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
390
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
391
+ const ret = cachedTextEncoder.encodeInto(arg, view);
392
+
393
+ offset += ret.written;
394
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
395
+ }
396
+
397
+ WASM_VECTOR_LEN = offset;
398
+ return ptr;
399
+ }
400
+
401
+ function takeObject(idx) {
402
+ const ret = getObject(idx);
403
+ dropObject(idx);
404
+ return ret;
405
+ }
406
+
407
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
408
+ cachedTextDecoder.decode();
409
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
410
+ let numBytesDecoded = 0;
411
+ function decodeText(ptr, len) {
412
+ numBytesDecoded += len;
413
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
414
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
415
+ cachedTextDecoder.decode();
416
+ numBytesDecoded = len;
417
+ }
418
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
419
+ }
420
+
421
+ const cachedTextEncoder = new TextEncoder();
422
+
423
+ if (!('encodeInto' in cachedTextEncoder)) {
424
+ cachedTextEncoder.encodeInto = function (arg, view) {
425
+ const buf = cachedTextEncoder.encode(arg);
426
+ view.set(buf);
427
+ return {
428
+ read: arg.length,
429
+ written: buf.length
430
+ };
431
+ };
432
+ }
433
+
434
+ let WASM_VECTOR_LEN = 0;
435
+
436
+ let wasmModule, wasm;
437
+ function __wbg_finalize_init(instance, module) {
438
+ wasm = instance.exports;
439
+ wasmModule = module;
440
+ cachedDataViewMemory0 = null;
441
+ cachedUint8ArrayMemory0 = null;
442
+ return wasm;
443
+ }
444
+
445
+ async function __wbg_load(module, imports) {
446
+ if (typeof Response === 'function' && module instanceof Response) {
447
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
448
+ try {
449
+ return await WebAssembly.instantiateStreaming(module, imports);
450
+ } catch (e) {
451
+ const validResponse = module.ok && expectedResponseType(module.type);
452
+
453
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
454
+ 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);
455
+
456
+ } else { throw e; }
457
+ }
458
+ }
459
+
460
+ const bytes = await module.arrayBuffer();
461
+ return await WebAssembly.instantiate(bytes, imports);
462
+ } else {
463
+ const instance = await WebAssembly.instantiate(module, imports);
464
+
465
+ if (instance instanceof WebAssembly.Instance) {
466
+ return { instance, module };
467
+ } else {
468
+ return instance;
469
+ }
470
+ }
471
+
472
+ function expectedResponseType(type) {
473
+ switch (type) {
474
+ case 'basic': case 'cors': case 'default': return true;
475
+ }
476
+ return false;
477
+ }
478
+ }
479
+
480
+ function initSync(module) {
481
+ if (wasm !== undefined) return wasm;
482
+
483
+
484
+ if (module !== undefined) {
485
+ if (Object.getPrototypeOf(module) === Object.prototype) {
486
+ ({module} = module)
487
+ } else {
488
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
489
+ }
490
+ }
491
+
492
+ const imports = __wbg_get_imports();
493
+ if (!(module instanceof WebAssembly.Module)) {
494
+ module = new WebAssembly.Module(module);
495
+ }
496
+ const instance = new WebAssembly.Instance(module, imports);
497
+ return __wbg_finalize_init(instance, module);
498
+ }
499
+
500
+ async function __wbg_init(module_or_path) {
501
+ if (wasm !== undefined) return wasm;
502
+
503
+
504
+ if (module_or_path !== undefined) {
505
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
506
+ ({module_or_path} = module_or_path)
507
+ } else {
508
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
509
+ }
510
+ }
511
+
512
+ if (module_or_path === undefined) {
513
+ module_or_path = new URL('wasm_bg.wasm', import.meta.url);
514
+ }
515
+ const imports = __wbg_get_imports();
516
+
517
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
518
+ module_or_path = fetch(module_or_path);
519
+ }
520
+
521
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
522
+
523
+ return __wbg_finalize_init(instance, module);
524
+ }
525
+
526
+ export { initSync, __wbg_init as default };
package/wasm_bg.wasm ADDED
Binary file