@frontierrnd/translation-consistency 0.0.0-stage → 2.0.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,771 @@
1
+ /* @ts-self-types="./fast_iso_wasm.d.ts" */
2
+
3
+ export class WasmFastIso {
4
+ static __wrap(ptr) {
5
+ const obj = Object.create(WasmFastIso.prototype);
6
+ obj.__wbg_ptr = ptr;
7
+ WasmFastIsoFinalization.register(obj, obj.__wbg_ptr, obj);
8
+ return obj;
9
+ }
10
+ __destroy_into_raw() {
11
+ const ptr = this.__wbg_ptr;
12
+ this.__wbg_ptr = 0;
13
+ WasmFastIsoFinalization.unregister(this);
14
+ return ptr;
15
+ }
16
+ free() {
17
+ const ptr = this.__destroy_into_raw();
18
+ wasm.__wbg_wasmfastiso_free(ptr, 0);
19
+ }
20
+ /**
21
+ * @returns {number}
22
+ */
23
+ get corpusSize() {
24
+ const ret = wasm.wasmfastiso_corpusSize(this.__wbg_ptr);
25
+ return ret >>> 0;
26
+ }
27
+ /**
28
+ * @param {Uint8Array | number[]} bytes
29
+ * @param {string | null} [version]
30
+ * @returns {WasmFastIso}
31
+ */
32
+ static deserialize(bytes, version) {
33
+ let ptr0, len0, ptr1, len1;
34
+ try {
35
+ ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
36
+ len0 = WASM_VECTOR_LEN;
37
+ ptr1 = isLikeNone(version) ? 0 : passStringToWasm0(version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
38
+ len1 = WASM_VECTOR_LEN;
39
+ } catch (e) {
40
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
41
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
42
+ throw e;
43
+ }
44
+ const ret = wasm.wasmfastiso_deserialize(ptr0, len0, ptr1, len1);
45
+ if (ret[2]) {
46
+ throw takeFromExternrefTable0(ret[1]);
47
+ }
48
+ return WasmFastIso.__wrap(ret[0]);
49
+ }
50
+ /**
51
+ * @returns {string}
52
+ */
53
+ get engineVersion() {
54
+ let deferred1_0;
55
+ let deferred1_1;
56
+ try {
57
+ const ret = wasm.wasmfastiso_engineVersion(this.__wbg_ptr);
58
+ deferred1_0 = ret[0];
59
+ deferred1_1 = ret[1];
60
+ return getStringFromWasm0(ret[0], ret[1]);
61
+ } finally {
62
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
63
+ }
64
+ }
65
+ /**
66
+ * @param {string} source
67
+ * @param {any} options_js
68
+ * @returns {any}
69
+ */
70
+ extractGlossary(source, options_js) {
71
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
72
+ const len0 = WASM_VECTOR_LEN;
73
+ const ret = wasm.wasmfastiso_extractGlossary(this.__wbg_ptr, ptr0, len0, options_js);
74
+ if (ret[2]) {
75
+ throw takeFromExternrefTable0(ret[1]);
76
+ }
77
+ return takeFromExternrefTable0(ret[0]);
78
+ }
79
+ /**
80
+ * @param {any} pairs_js
81
+ * @param {any} options_js
82
+ */
83
+ constructor(pairs_js, options_js) {
84
+ const ret = wasm.wasmfastiso_fit(pairs_js, options_js);
85
+ if (ret[2]) {
86
+ throw takeFromExternrefTable0(ret[1]);
87
+ }
88
+ this.__wbg_ptr = ret[0];
89
+ WasmFastIsoFinalization.register(this, this.__wbg_ptr, this);
90
+ return this;
91
+ }
92
+ /**
93
+ * @returns {number}
94
+ */
95
+ get lexicalSize() {
96
+ const ret = wasm.wasmfastiso_lexicalSize(this.__wbg_ptr);
97
+ return ret >>> 0;
98
+ }
99
+ /**
100
+ * @param {string} source
101
+ * @param {string} candidate
102
+ * @param {number | null} [max_window]
103
+ * @returns {any}
104
+ */
105
+ localizeSpans(source, candidate, max_window) {
106
+ const val3 = +(isLikeNone(max_window) ? Number.MAX_SAFE_INTEGER : (max_window) >>> 0);
107
+ let ptr0, len0, ptr1, len1;
108
+ try {
109
+ ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
110
+ len0 = WASM_VECTOR_LEN;
111
+ ptr1 = passStringToWasm0(candidate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
112
+ len1 = WASM_VECTOR_LEN;
113
+ } catch (e) {
114
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
115
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
116
+ throw e;
117
+ }
118
+ const ret = wasm.wasmfastiso_localizeSpans(this.__wbg_ptr, ptr0, len0, ptr1, len1, val3);
119
+ if (ret[2]) {
120
+ throw takeFromExternrefTable0(ret[1]);
121
+ }
122
+ return takeFromExternrefTable0(ret[0]);
123
+ }
124
+ /**
125
+ * @param {string} source
126
+ * @param {any} candidates_js
127
+ * @param {any} options_js
128
+ * @returns {any}
129
+ */
130
+ pickBest(source, candidates_js, options_js) {
131
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
132
+ const len0 = WASM_VECTOR_LEN;
133
+ const ret = wasm.wasmfastiso_pickBest(this.__wbg_ptr, ptr0, len0, candidates_js, options_js);
134
+ if (ret[2]) {
135
+ throw takeFromExternrefTable0(ret[1]);
136
+ }
137
+ return takeFromExternrefTable0(ret[0]);
138
+ }
139
+ /**
140
+ * @param {any} sources_js
141
+ * @param {any} targets_js
142
+ * @returns {any}
143
+ */
144
+ scanPassageDrift(sources_js, targets_js) {
145
+ const ret = wasm.wasmfastiso_scanPassageDrift(this.__wbg_ptr, sources_js, targets_js);
146
+ if (ret[2]) {
147
+ throw takeFromExternrefTable0(ret[1]);
148
+ }
149
+ return takeFromExternrefTable0(ret[0]);
150
+ }
151
+ /**
152
+ * @param {string} source
153
+ * @param {any} candidates_js
154
+ * @returns {any}
155
+ */
156
+ scoreBatch(source, candidates_js) {
157
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
158
+ const len0 = WASM_VECTOR_LEN;
159
+ const ret = wasm.wasmfastiso_scoreBatch(this.__wbg_ptr, ptr0, len0, candidates_js);
160
+ if (ret[2]) {
161
+ throw takeFromExternrefTable0(ret[1]);
162
+ }
163
+ return takeFromExternrefTable0(ret[0]);
164
+ }
165
+ /**
166
+ * @returns {Uint8Array}
167
+ */
168
+ serialize() {
169
+ const ret = wasm.wasmfastiso_serialize(this.__wbg_ptr);
170
+ if (ret[3]) {
171
+ throw takeFromExternrefTable0(ret[2]);
172
+ }
173
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
174
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
175
+ return v1;
176
+ }
177
+ }
178
+ if (Symbol.dispose) WasmFastIso.prototype[Symbol.dispose] = WasmFastIso.prototype.free;
179
+
180
+ /**
181
+ * @param {string} hyp
182
+ * @param {string} reference
183
+ * @returns {number}
184
+ */
185
+ export function chrfPP(hyp, reference) {
186
+ let ptr0, len0, ptr1, len1;
187
+ try {
188
+ ptr0 = passStringToWasm0(hyp, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
189
+ len0 = WASM_VECTOR_LEN;
190
+ ptr1 = passStringToWasm0(reference, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
191
+ len1 = WASM_VECTOR_LEN;
192
+ } catch (e) {
193
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
194
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
195
+ throw e;
196
+ }
197
+ const ret = wasm.chrfPP(ptr0, len0, ptr1, len1);
198
+ return ret;
199
+ }
200
+
201
+ /**
202
+ * @returns {string}
203
+ */
204
+ export function latestVersion() {
205
+ let deferred1_0;
206
+ let deferred1_1;
207
+ try {
208
+ const ret = wasm.latestVersion();
209
+ deferred1_0 = ret[0];
210
+ deferred1_1 = ret[1];
211
+ return getStringFromWasm0(ret[0], ret[1]);
212
+ } finally {
213
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
214
+ }
215
+ }
216
+
217
+ /**
218
+ * @param {Uint8Array | number[]} bytes
219
+ * @returns {string}
220
+ */
221
+ export function peekSerializedVersion(bytes) {
222
+ let deferred3_0;
223
+ let deferred3_1;
224
+ try {
225
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
226
+ const len0 = WASM_VECTOR_LEN;
227
+ const ret = wasm.peekSerializedVersion(ptr0, len0);
228
+ var ptr2 = ret[0];
229
+ var len2 = ret[1];
230
+ if (ret[3]) {
231
+ ptr2 = 0; len2 = 0;
232
+ throw takeFromExternrefTable0(ret[2]);
233
+ }
234
+ deferred3_0 = ptr2;
235
+ deferred3_1 = len2;
236
+ return getStringFromWasm0(ptr2, len2);
237
+ } finally {
238
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
239
+ }
240
+ }
241
+
242
+ /**
243
+ * @returns {any}
244
+ */
245
+ export function supportedVersions() {
246
+ const ret = wasm.supportedVersions();
247
+ return ret;
248
+ }
249
+ function __wbg_get_imports() {
250
+ const import0 = {
251
+ __proto__: null,
252
+ __wbg_Error_208446807d0d1e30: function(arg0, arg1) {
253
+ const ret = Error(getStringFromWasm0(arg0, arg1));
254
+ return ret;
255
+ },
256
+ __wbg_Number_ff192a72a0dcdf6d: function(arg0) {
257
+ const ret = Number(arg0);
258
+ return ret;
259
+ },
260
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
261
+ const ret = String(arg1);
262
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
263
+ const len1 = WASM_VECTOR_LEN;
264
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
265
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
266
+ },
267
+ __wbg___wbindgen_bigint_get_as_i64_11da4b52cd0aedef: function(arg0, arg1) {
268
+ const v = arg1;
269
+ const ret = typeof(v) === 'bigint' ? v : undefined;
270
+ getDataViewMemory0().setBigInt64((arg0 >>> 0) + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
271
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, !isLikeNone(ret), true);
272
+ },
273
+ __wbg___wbindgen_boolean_get_4f1baf9a00be3c74: function(arg0) {
274
+ const v = arg0;
275
+ const ret = typeof(v) === 'boolean' ? v : undefined;
276
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
277
+ },
278
+ __wbg___wbindgen_debug_string_f249a2a76caa9a55: function(arg0, arg1) {
279
+ const ret = debugString(arg1);
280
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
281
+ const len1 = WASM_VECTOR_LEN;
282
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
283
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
284
+ },
285
+ __wbg___wbindgen_in_3f58a9d3b3a7eed2: function(arg0, arg1) {
286
+ const ret = arg0 in arg1;
287
+ return ret;
288
+ },
289
+ __wbg___wbindgen_is_bigint_5fa10641e039d3ef: function(arg0) {
290
+ const ret = typeof(arg0) === 'bigint';
291
+ return ret;
292
+ },
293
+ __wbg___wbindgen_is_function_741ff2bb612836f5: function(arg0) {
294
+ const ret = typeof(arg0) === 'function';
295
+ return ret;
296
+ },
297
+ __wbg___wbindgen_is_null_c22311b1cc228e3a: function(arg0) {
298
+ const ret = arg0 === null;
299
+ return ret;
300
+ },
301
+ __wbg___wbindgen_is_object_8b968c3ab8e96595: function(arg0) {
302
+ const val = arg0;
303
+ const ret = typeof(val) === 'object' && val !== null;
304
+ return ret;
305
+ },
306
+ __wbg___wbindgen_is_string_fc456fee5d3317de: function(arg0) {
307
+ const ret = typeof(arg0) === 'string';
308
+ return ret;
309
+ },
310
+ __wbg___wbindgen_is_undefined_be5b34249ff1fc15: function(arg0) {
311
+ const ret = arg0 === undefined;
312
+ return ret;
313
+ },
314
+ __wbg___wbindgen_jsval_eq_38d7bfbe4cc84039: function(arg0, arg1) {
315
+ const ret = arg0 === arg1;
316
+ return ret;
317
+ },
318
+ __wbg___wbindgen_jsval_loose_eq_b2f214e2e4b30e36: function(arg0, arg1) {
319
+ const ret = arg0 == arg1;
320
+ return ret;
321
+ },
322
+ __wbg___wbindgen_number_get_934b640d0889af78: function(arg0, arg1) {
323
+ const obj = arg1;
324
+ const ret = typeof(obj) === 'number' ? obj : undefined;
325
+ getDataViewMemory0().setFloat64((arg0 >>> 0) + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
326
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, !isLikeNone(ret), true);
327
+ },
328
+ __wbg___wbindgen_string_get_7ce8eee7fd327545: function(arg0, arg1) {
329
+ const obj = arg1;
330
+ const ret = typeof(obj) === 'string' ? obj : undefined;
331
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
332
+ var len1 = WASM_VECTOR_LEN;
333
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
334
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
335
+ },
336
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
337
+ throw new Error(getStringFromWasm0(arg0, arg1));
338
+ },
339
+ __wbg_call_40b008ba32f73991: function() { return handleError(function (arg0, arg1) {
340
+ const ret = arg0.call(arg1);
341
+ return ret;
342
+ }, arguments); },
343
+ __wbg_done_57e08d0be6e30c02: function(arg0) {
344
+ const ret = arg0.done;
345
+ return ret;
346
+ },
347
+ __wbg_entries_7bb1459bd9b5c2b9: function(arg0) {
348
+ const ret = Object.entries(arg0);
349
+ return ret;
350
+ },
351
+ __wbg_getRandomValues_8b6f1f663e6f188d: function() { return handleError(function (arg0, arg1) {
352
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
353
+ }, arguments); },
354
+ __wbg_get_635eea311fa1a291: function() { return handleError(function (arg0, arg1) {
355
+ const ret = Reflect.get(arg0, arg1);
356
+ return ret;
357
+ }, arguments); },
358
+ __wbg_get_d7176cfb76d71114: function(arg0, arg1) {
359
+ const ret = arg0[arg1 >>> 0];
360
+ return ret;
361
+ },
362
+ __wbg_get_unchecked_e6325ad374eff861: function(arg0, arg1) {
363
+ const ret = arg0[arg1 >>> 0];
364
+ return ret;
365
+ },
366
+ __wbg_get_with_ref_key_fc601247060b7204: function(arg0, arg1) {
367
+ const ret = arg0[arg1];
368
+ return ret;
369
+ },
370
+ __wbg_instanceof_ArrayBuffer_12cdaa4161423e6b: function(arg0) {
371
+ let result;
372
+ try {
373
+ result = arg0 instanceof ArrayBuffer;
374
+ } catch (_) {
375
+ result = false;
376
+ }
377
+ const ret = result;
378
+ return ret;
379
+ },
380
+ __wbg_instanceof_Uint8Array_d7aeb0dcb3108fea: function(arg0) {
381
+ let result;
382
+ try {
383
+ result = arg0 instanceof Uint8Array;
384
+ } catch (_) {
385
+ result = false;
386
+ }
387
+ const ret = result;
388
+ return ret;
389
+ },
390
+ __wbg_isArray_bcf1376d0d732d08: function(arg0) {
391
+ const ret = Array.isArray(arg0);
392
+ return ret;
393
+ },
394
+ __wbg_isSafeInteger_1a35ba4d31e71d38: function(arg0) {
395
+ const ret = Number.isSafeInteger(arg0);
396
+ return ret;
397
+ },
398
+ __wbg_iterator_e4c5e8f68ada7b58: function() {
399
+ const ret = Symbol.iterator;
400
+ return ret;
401
+ },
402
+ __wbg_length_186163212ffe79c3: function(arg0) {
403
+ const ret = arg0.length;
404
+ return ret;
405
+ },
406
+ __wbg_length_b03a0fabb109b1e9: function(arg0) {
407
+ const ret = arg0.length;
408
+ return ret;
409
+ },
410
+ __wbg_new_13de428334042d26: function(arg0) {
411
+ const ret = new Uint8Array(arg0);
412
+ return ret;
413
+ },
414
+ __wbg_new_37eb45aaf5eeb820: function() {
415
+ const ret = new Array();
416
+ return ret;
417
+ },
418
+ __wbg_new_7075786089b89c5e: function() {
419
+ const ret = new Map();
420
+ return ret;
421
+ },
422
+ __wbg_new_cd4348290afae586: function() {
423
+ const ret = new Object();
424
+ return ret;
425
+ },
426
+ __wbg_next_178c1651c11432b3: function(arg0) {
427
+ const ret = arg0.next;
428
+ return ret;
429
+ },
430
+ __wbg_next_af5ac6a08bb0a717: function() { return handleError(function (arg0) {
431
+ const ret = arg0.next();
432
+ return ret;
433
+ }, arguments); },
434
+ __wbg_prototypesetcall_13162965d1fe7aa3: function(arg0, arg1, arg2) {
435
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
436
+ },
437
+ __wbg_set_8282f7e0d2d01336: function(arg0, arg1, arg2) {
438
+ const ret = arg0.set(arg1, arg2);
439
+ return ret;
440
+ },
441
+ __wbg_set_d2d33b52458e984a: function(arg0, arg1, arg2) {
442
+ arg0[arg1 >>> 0] = arg2;
443
+ },
444
+ __wbg_set_e4b9a833d288759a: function(arg0, arg1, arg2) {
445
+ arg0[arg1] = arg2;
446
+ },
447
+ __wbg_value_e0f328965e184931: function(arg0) {
448
+ const ret = arg0.value;
449
+ return ret;
450
+ },
451
+ __wbindgen_generic_0000000000000001: function(arg0) {
452
+ // Cast intrinsic for `F64 -> Externref`.
453
+ const ret = arg0;
454
+ return ret;
455
+ },
456
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
457
+ // Cast intrinsic for `Ref(String) -> Externref`.
458
+ const ret = getStringFromWasm0(arg0, arg1);
459
+ return ret;
460
+ },
461
+ __wbindgen_generic_0000000000000003: function(arg0) {
462
+ // Cast intrinsic for `U64 -> Externref`.
463
+ const ret = BigInt.asUintN(64, arg0);
464
+ return ret;
465
+ },
466
+ __wbindgen_init_externref_table: function() {
467
+ const table = wasm.__wbindgen_externrefs;
468
+ table.set(0, undefined);
469
+ table.set(1024, undefined);
470
+ table.set(1025, null);
471
+ table.set(1026, true);
472
+ table.set(1027, false);
473
+ },
474
+ };
475
+ return {
476
+ __proto__: null,
477
+ "./fast_iso_wasm_bg.js": import0,
478
+ };
479
+ }
480
+
481
+ const WasmFastIsoFinalization = (typeof FinalizationRegistry === 'undefined')
482
+ ? { register: () => {}, unregister: () => {} }
483
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmfastiso_free(ptr, 1));
484
+
485
+ function addToExternrefTable0(obj) {
486
+ const idx = wasm.__externref_table_alloc();
487
+ wasm.__wbindgen_externrefs.set(idx, obj);
488
+ return idx;
489
+ }
490
+
491
+ function debugString(val) {
492
+ switch (typeof val) {
493
+ // primitive types
494
+ case 'number':
495
+ case 'boolean':
496
+ case 'undefined':
497
+ return `${val}`;
498
+ case 'string':
499
+ return JSON.stringify(val);
500
+ case 'bigint':
501
+ return `${val}n`;
502
+ case 'symbol':
503
+ return val.description !== undefined
504
+ ? `Symbol(${val.description})`
505
+ : 'Symbol';
506
+ case 'function':
507
+ return typeof val.name === 'string' && val.name !== ''
508
+ ? `Function(${val.name})`
509
+ : 'Function';
510
+ case 'object': {
511
+ if (val === null) {
512
+ return 'null';
513
+ }
514
+ // objects
515
+ if (Array.isArray(val)) {
516
+ return '[' + Array.from(val, debugString).join(', ') + ']';
517
+ }
518
+ // errors
519
+ if (val instanceof Error) {
520
+ return `${val.name}: ${val.message}\n${val.stack}`;
521
+ }
522
+
523
+ const toStringOutput = toString.call(val);
524
+ // Test for built-in
525
+ const className = /\[object ([^\]]+)\]/.exec(toStringOutput)?.[1];
526
+
527
+ // Failed to match the standard '[object ClassName]'
528
+ if (className === undefined) {
529
+ return toStringOutput;
530
+ }
531
+ if (className === 'Object') {
532
+ // we're a user defined class or Object
533
+ // JSON.stringify avoids problems with cycles, and is generally much
534
+ // easier than looping through ownProperties of `val`.
535
+ try {
536
+ return 'Object(' + JSON.stringify(val) + ')';
537
+ } catch (_) {
538
+ return 'Object';
539
+ }
540
+ }
541
+ // TODO we could test for more things here, like `Set`s and `Map`s.
542
+ return className;
543
+ }
544
+ // Per MDN: 'This list of values is exhaustive.'
545
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#description
546
+ }
547
+ }
548
+
549
+ function getArrayU8FromWasm0(ptr, len) {
550
+ ptr = ptr >>> 0;
551
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
552
+ }
553
+
554
+ let cachedDataViewMemory0 = null;
555
+ function getDataViewMemory0() {
556
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
557
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
558
+ }
559
+ return cachedDataViewMemory0;
560
+ }
561
+
562
+ function getStringFromWasm0(ptr, len) {
563
+ ptr = ptr >>> 0;
564
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
565
+ }
566
+
567
+ let cachedUint8ArrayMemory0 = null;
568
+ function getUint8ArrayMemory0() {
569
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
570
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
571
+ }
572
+ return cachedUint8ArrayMemory0;
573
+ }
574
+
575
+ function handleError(f, args) {
576
+ try {
577
+ return f.apply(this, args);
578
+ } catch (e) {
579
+ const idx = addToExternrefTable0(e);
580
+ wasm.__wbindgen_exn_store(idx);
581
+ }
582
+ }
583
+
584
+ function isLikeNone(x) {
585
+ return x === undefined || x === null;
586
+ }
587
+
588
+ function passArray8ToWasm0(arg, malloc) {
589
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
590
+ getUint8ArrayMemory0().set(arg, ptr / 1);
591
+ WASM_VECTOR_LEN = arg.length;
592
+ return ptr;
593
+ }
594
+
595
+ function passStringToWasm0(arg, malloc, realloc) {
596
+ if (realloc === undefined) {
597
+ const buf = cachedTextEncoder.encode(arg);
598
+ const ptr = malloc(buf.length, 1) >>> 0;
599
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
600
+ WASM_VECTOR_LEN = buf.length;
601
+ return ptr;
602
+ }
603
+
604
+ let len = arg.length;
605
+ let ptr = malloc(len, 1) >>> 0;
606
+
607
+ const mem = getUint8ArrayMemory0();
608
+
609
+ let offset = 0;
610
+
611
+ for (; offset < len; offset++) {
612
+ const code = arg.charCodeAt(offset);
613
+ if (code > 0x7F) break;
614
+ mem[ptr + offset] = code;
615
+ }
616
+ if (offset !== len) {
617
+ if (offset !== 0) {
618
+ arg = arg.slice(offset);
619
+ }
620
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
621
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
622
+ const ret = cachedTextEncoder.encodeInto(arg, view);
623
+
624
+ offset += ret.written;
625
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
626
+ }
627
+
628
+ WASM_VECTOR_LEN = offset;
629
+ return ptr;
630
+ }
631
+
632
+ function takeFromExternrefTable0(idx) {
633
+ const value = wasm.__wbindgen_externrefs.get(idx);
634
+ wasm.__externref_table_dealloc(idx);
635
+ return value;
636
+ }
637
+
638
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
639
+ cachedTextDecoder.decode();
640
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
641
+ let numBytesDecoded = 0;
642
+ function decodeText(bytes) {
643
+ numBytesDecoded += bytes.length;
644
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
645
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
646
+ cachedTextDecoder.decode();
647
+ numBytesDecoded = bytes.length;
648
+ }
649
+ return cachedTextDecoder.decode(bytes);
650
+ }
651
+
652
+ const cachedTextEncoder = new TextEncoder();
653
+
654
+ if (!('encodeInto' in cachedTextEncoder)) {
655
+ cachedTextEncoder.encodeInto = function (arg, view) {
656
+ const buf = cachedTextEncoder.encode(arg);
657
+ view.set(buf);
658
+ return {
659
+ read: arg.length,
660
+ written: buf.length
661
+ };
662
+ };
663
+ }
664
+
665
+ let WASM_VECTOR_LEN = 0;
666
+
667
+ let wasmModule, wasmInstance, wasm;
668
+ function __wbg_finalize_init(instance, module) {
669
+ wasmInstance = instance;
670
+ wasm = instance.exports;
671
+ wasmModule = module;
672
+ cachedDataViewMemory0 = null;
673
+ cachedUint8ArrayMemory0 = null;
674
+ wasm.__wbindgen_start();
675
+ return wasm;
676
+ }
677
+
678
+ async function __wbg_load(module, imports) {
679
+ if (typeof Response === 'function' && module instanceof Response) {
680
+ if (!module.ok) {
681
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
682
+ }
683
+
684
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
685
+ try {
686
+ return await WebAssembly.instantiateStreaming(module, imports);
687
+ } catch (e) {
688
+ const validResponse = expectedResponseType(module.type);
689
+
690
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
691
+ 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);
692
+
693
+ } else { throw e; }
694
+ }
695
+ }
696
+
697
+ const bytes = await module.arrayBuffer();
698
+ return await WebAssembly.instantiate(bytes, imports);
699
+ } else {
700
+ const instance = await WebAssembly.instantiate(module, imports);
701
+
702
+ if (instance instanceof WebAssembly.Instance) {
703
+ return { instance, module };
704
+ } else {
705
+ return instance;
706
+ }
707
+ }
708
+
709
+ function expectedResponseType(type) {
710
+ switch (type) {
711
+ case 'basic': case 'cors': case 'default': return true;
712
+ }
713
+ return false;
714
+ }
715
+ }
716
+
717
+ function initSync(module) {
718
+ if (wasm !== undefined) return wasm;
719
+
720
+
721
+ if (module !== undefined) {
722
+ if (Object.getPrototypeOf(module) === Object.prototype) {
723
+ ({module} = module)
724
+ } else {
725
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
726
+ }
727
+ }
728
+
729
+ const imports = __wbg_get_imports();
730
+ if (!(module instanceof WebAssembly.Module)) {
731
+ module = new WebAssembly.Module(module);
732
+ }
733
+ const instance = new WebAssembly.Instance(module, imports);
734
+ return __wbg_finalize_init(instance, module);
735
+ }
736
+
737
+ let __wbg_init_promise;
738
+ async function __wbg_init(module_or_path) {
739
+ if (wasm !== undefined) return wasm;
740
+ if (__wbg_init_promise === undefined) {
741
+ __wbg_init_promise = __wbg_init_once(module_or_path);
742
+ __wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
743
+ }
744
+ return __wbg_init_promise;
745
+ }
746
+
747
+ async function __wbg_init_once(module_or_path) {
748
+
749
+ if (module_or_path !== undefined) {
750
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
751
+ ({module_or_path} = module_or_path)
752
+ } else {
753
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
754
+ }
755
+ }
756
+
757
+ if (module_or_path === undefined) {
758
+ module_or_path = new URL('fast_iso_wasm_bg.wasm', import.meta.url);
759
+ }
760
+ const imports = __wbg_get_imports();
761
+
762
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
763
+ module_or_path = fetch(module_or_path);
764
+ }
765
+
766
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
767
+
768
+ return __wbg_finalize_init(instance, module);
769
+ }
770
+
771
+ export { initSync, __wbg_init as default };