iso2x-wasm 0.1.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,1111 @@
1
+ /* @ts-self-types="./iso2x_wasm.d.ts" */
2
+
3
+ /**
4
+ * One format-agnostic session type exposed to JS. The worker drives this
5
+ * the same way regardless of format - `nextChunk`/`isDone`/`totalUnits`
6
+ * is the entire contract, with `hashNextPart` as an extra pre-streaming
7
+ * step that's a no-op where nothing needs precomputing.
8
+ */
9
+ export class ConversionSession {
10
+ static __wrap(ptr) {
11
+ const obj = Object.create(ConversionSession.prototype);
12
+ obj.__wbg_ptr = ptr;
13
+ ConversionSessionFinalization.register(obj, obj.__wbg_ptr, obj);
14
+ return obj;
15
+ }
16
+ __destroy_into_raw() {
17
+ const ptr = this.__wbg_ptr;
18
+ this.__wbg_ptr = 0;
19
+ ConversionSessionFinalization.unregister(this);
20
+ return ptr;
21
+ }
22
+ free() {
23
+ const ptr = this.__destroy_into_raw();
24
+ wasm.__wbg_conversionsession_free(ptr, 0);
25
+ }
26
+ /**
27
+ * @returns {string | undefined}
28
+ */
29
+ currentEntryName() {
30
+ try {
31
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
32
+ wasm.conversionsession_currentEntryName(retptr, this.__wbg_ptr);
33
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
34
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
35
+ let v1;
36
+ if (r0 !== 0) {
37
+ v1 = getStringFromWasm0(r0, r1).slice();
38
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
39
+ }
40
+ return v1;
41
+ } finally {
42
+ wasm.__wbindgen_add_to_stack_pointer(16);
43
+ }
44
+ }
45
+ /**
46
+ * Drives one bounded step of pre-streaming hashing/sizing (see
47
+ * `SessionInner::hash_next_part`). Call this in a loop from JS,
48
+ * yielding to the event loop between calls, until it returns `true`,
49
+ * *before* calling `nextChunk()`. Bounding each call's work is what
50
+ * makes hashing/sizing cancellable from JS.
51
+ * @returns {boolean}
52
+ */
53
+ hashNextPart() {
54
+ try {
55
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
56
+ wasm.conversionsession_hashNextPart(retptr, this.__wbg_ptr);
57
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
58
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
59
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
60
+ if (r2) {
61
+ throw takeObject(r1);
62
+ }
63
+ return r0 !== 0;
64
+ } finally {
65
+ wasm.__wbindgen_add_to_stack_pointer(16);
66
+ }
67
+ }
68
+ /**
69
+ * @returns {boolean}
70
+ */
71
+ isDone() {
72
+ const ret = wasm.conversionsession_isDone(this.__wbg_ptr);
73
+ return ret !== 0;
74
+ }
75
+ /**
76
+ * @param {number} max_bytes
77
+ * @returns {Uint8Array | undefined}
78
+ */
79
+ nextChunk(max_bytes) {
80
+ try {
81
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
82
+ wasm.conversionsession_nextChunk(retptr, this.__wbg_ptr, max_bytes);
83
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
84
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
85
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
86
+ if (r2) {
87
+ throw takeObject(r1);
88
+ }
89
+ return takeObject(r0);
90
+ } finally {
91
+ wasm.__wbindgen_add_to_stack_pointer(16);
92
+ }
93
+ }
94
+ /**
95
+ * Array of `{ name, size }` for formats that produce multiple output
96
+ * files. Safe to call right after `open()`, before streaming - though
97
+ * it may be empty until sizing/hashing finishes, or permanently empty
98
+ * for single-stream formats.
99
+ * @returns {any}
100
+ */
101
+ outputManifest() {
102
+ try {
103
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
104
+ wasm.conversionsession_outputManifest(retptr, this.__wbg_ptr);
105
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
106
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
107
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
108
+ if (r2) {
109
+ throw takeObject(r1);
110
+ }
111
+ return takeObject(r0);
112
+ } finally {
113
+ wasm.__wbindgen_add_to_stack_pointer(16);
114
+ }
115
+ }
116
+ /**
117
+ * @returns {number}
118
+ */
119
+ totalUnits() {
120
+ const ret = wasm.conversionsession_totalUnits(this.__wbg_ptr);
121
+ return ret;
122
+ }
123
+ /**
124
+ * See `ChunkSource::units_done` - `null` for every format except
125
+ * zar, where it's the authoritative "raw input bytes consumed" count
126
+ * to use instead of summing `nextChunk()`'s returned byte lengths.
127
+ * @returns {number | undefined}
128
+ */
129
+ unitsDone() {
130
+ try {
131
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
132
+ wasm.conversionsession_unitsDone(retptr, this.__wbg_ptr);
133
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
134
+ var r2 = getDataViewMemory0().getFloat64(retptr + 8 * 1, true);
135
+ return r0 === 0 ? undefined : r2;
136
+ } finally {
137
+ wasm.__wbindgen_add_to_stack_pointer(16);
138
+ }
139
+ }
140
+ }
141
+ if (Symbol.dispose) ConversionSession.prototype[Symbol.dispose] = ConversionSession.prototype.free;
142
+
143
+ export class SourceInfo {
144
+ static __wrap(ptr) {
145
+ const obj = Object.create(SourceInfo.prototype);
146
+ obj.__wbg_ptr = ptr;
147
+ SourceInfoFinalization.register(obj, obj.__wbg_ptr, obj);
148
+ return obj;
149
+ }
150
+ __destroy_into_raw() {
151
+ const ptr = this.__wbg_ptr;
152
+ this.__wbg_ptr = 0;
153
+ SourceInfoFinalization.unregister(this);
154
+ return ptr;
155
+ }
156
+ free() {
157
+ const ptr = this.__destroy_into_raw();
158
+ wasm.__wbg_sourceinfo_free(ptr, 0);
159
+ }
160
+ /**
161
+ * @returns {string}
162
+ */
163
+ contentType() {
164
+ let deferred1_0;
165
+ let deferred1_1;
166
+ try {
167
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
168
+ wasm.sourceinfo_contentType(retptr, this.__wbg_ptr);
169
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
170
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
171
+ deferred1_0 = r0;
172
+ deferred1_1 = r1;
173
+ return getStringFromWasm0(r0, r1);
174
+ } finally {
175
+ wasm.__wbindgen_add_to_stack_pointer(16);
176
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
177
+ }
178
+ }
179
+ /**
180
+ * @returns {string | undefined}
181
+ */
182
+ detectedTitle() {
183
+ try {
184
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
185
+ wasm.sourceinfo_detectedTitle(retptr, this.__wbg_ptr);
186
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
187
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
188
+ let v1;
189
+ if (r0 !== 0) {
190
+ v1 = getStringFromWasm0(r0, r1).slice();
191
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
192
+ }
193
+ return v1;
194
+ } finally {
195
+ wasm.__wbindgen_add_to_stack_pointer(16);
196
+ }
197
+ }
198
+ /**
199
+ * @returns {string}
200
+ */
201
+ titleId() {
202
+ let deferred1_0;
203
+ let deferred1_1;
204
+ try {
205
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
206
+ wasm.sourceinfo_titleId(retptr, this.__wbg_ptr);
207
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
208
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
209
+ deferred1_0 = r0;
210
+ deferred1_1 = r1;
211
+ return getStringFromWasm0(r0, r1);
212
+ } finally {
213
+ wasm.__wbindgen_add_to_stack_pointer(16);
214
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
215
+ }
216
+ }
217
+ }
218
+ if (Symbol.dispose) SourceInfo.prototype[Symbol.dispose] = SourceInfo.prototype.free;
219
+
220
+ /**
221
+ * @returns {number}
222
+ */
223
+ export function cciFileSplitPoint() {
224
+ const ret = wasm.cciFileSplitPoint();
225
+ return ret;
226
+ }
227
+
228
+ /**
229
+ * @returns {number}
230
+ */
231
+ export function cciSectorSize() {
232
+ const ret = wasm.cciSectorSize();
233
+ return ret >>> 0;
234
+ }
235
+
236
+ /**
237
+ * @returns {number}
238
+ */
239
+ export function cciSizingBatchSectors() {
240
+ const ret = wasm.cciSizingBatchSectors();
241
+ return ret >>> 0;
242
+ }
243
+
244
+ /**
245
+ * Chains `next_digest` onto the end of the hash list encoded in `mht_bytes`
246
+ * and returns the recomputed digest bytes.
247
+ *
248
+ * # Errors
249
+ *
250
+ * Returns an error if `mht_bytes` is not a valid hash list, or if
251
+ * `next_digest` is not exactly 20 bytes long.
252
+ * @param {Uint8Array} mht_bytes
253
+ * @param {Uint8Array} next_digest
254
+ * @returns {Uint8Array}
255
+ */
256
+ export function chainMhtDigest(mht_bytes, next_digest) {
257
+ try {
258
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
259
+ const ptr0 = passArray8ToWasm0(mht_bytes, wasm.__wbindgen_export);
260
+ const len0 = WASM_VECTOR_LEN;
261
+ const ptr1 = passArray8ToWasm0(next_digest, wasm.__wbindgen_export);
262
+ const len1 = WASM_VECTOR_LEN;
263
+ wasm.chainMhtDigest(retptr, ptr0, len0, ptr1, len1);
264
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
265
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
266
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
267
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
268
+ if (r3) {
269
+ throw takeObject(r2);
270
+ }
271
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
272
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
273
+ return v3;
274
+ } finally {
275
+ wasm.__wbindgen_add_to_stack_pointer(16);
276
+ }
277
+ }
278
+
279
+ /**
280
+ * @returns {number}
281
+ */
282
+ export function cisoFilePaddingModulus() {
283
+ const ret = wasm.cisoFilePaddingModulus();
284
+ return ret >>> 0;
285
+ }
286
+
287
+ /**
288
+ * @returns {number}
289
+ */
290
+ export function cisoFileSplitPoint() {
291
+ const ret = wasm.cisoFileSplitPoint();
292
+ return ret;
293
+ }
294
+
295
+ /**
296
+ * @returns {number}
297
+ */
298
+ export function cisoSectorSize() {
299
+ const ret = wasm.cisoSectorSize();
300
+ return ret >>> 0;
301
+ }
302
+
303
+ /**
304
+ * @returns {number}
305
+ */
306
+ export function cisoSizingBatchSectors() {
307
+ const ret = wasm.cisoSizingBatchSectors();
308
+ return ret >>> 0;
309
+ }
310
+
311
+ /**
312
+ * Wasm wrapper around `core::source::detect_dir` - the directory-shape
313
+ * path (God/Extracted). Takes the flat list of forward-slash-normalized
314
+ * relative paths for every regular file in the dropped folder.
315
+ *
316
+ * Returns `None` when the listing matches neither shape (e.g. a folder of
317
+ * loose split-XISO parts) - the caller should resolve each entry via
318
+ * `detectFormat` instead.
319
+ * @param {string[]} entries
320
+ * @returns {string | undefined}
321
+ */
322
+ export function detectDirFormat(entries) {
323
+ try {
324
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
325
+ const ptr0 = passArrayJsValueToWasm0(entries, wasm.__wbindgen_export);
326
+ const len0 = WASM_VECTOR_LEN;
327
+ wasm.detectDirFormat(retptr, ptr0, len0);
328
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
329
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
330
+ let v2;
331
+ if (r0 !== 0) {
332
+ v2 = getStringFromWasm0(r0, r1).slice();
333
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
334
+ }
335
+ return v2;
336
+ } finally {
337
+ wasm.__wbindgen_add_to_stack_pointer(16);
338
+ }
339
+ }
340
+
341
+ /**
342
+ * Wasm wrapper around `core::source::detect` - the single-file, magic-byte
343
+ * path (Xiso/Ciso/Cci). For a dropped folder use `detectDirFormat` instead.
344
+ *
345
+ * # Errors
346
+ *
347
+ * Returns an error if reading from `read_fn` fails or if the file's magic
348
+ * bytes don't match any known single-file format.
349
+ * @param {Function} read_fn
350
+ * @param {number} file_size
351
+ * @returns {string}
352
+ */
353
+ export function detectFormat(read_fn, file_size) {
354
+ let deferred2_0;
355
+ let deferred2_1;
356
+ try {
357
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
358
+ wasm.detectFormat(retptr, addHeapObject(read_fn), file_size);
359
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
360
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
361
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
362
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
363
+ var ptr1 = r0;
364
+ var len1 = r1;
365
+ if (r3) {
366
+ ptr1 = 0; len1 = 0;
367
+ throw takeObject(r2);
368
+ }
369
+ deferred2_0 = ptr1;
370
+ deferred2_1 = len1;
371
+ return getStringFromWasm0(ptr1, len1);
372
+ } finally {
373
+ wasm.__wbindgen_add_to_stack_pointer(16);
374
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
375
+ }
376
+ }
377
+
378
+ /**
379
+ * Generates a bootable "default.xbe" attach stub for an OGX (original
380
+ * Xbox) source, so an ISO/CCI/CISO conversion output can still be
381
+ * launched from a softmod dashboard. Rejects `GoD` (XEX) sources - this
382
+ * only makes sense for OGX, and this function enforces that
383
+ * unconditionally regardless of what the caller has already checked.
384
+ *
385
+ * # Errors
386
+ *
387
+ * Returns an error if `source` is unresolved or invalid, if reading
388
+ * `source_parts` fails, if the source is a `GoD` (XEX) source rather than
389
+ * OGX, if the XDVDFS root or `default.xbe` can't be located, or if
390
+ * building the attach stub fails.
391
+ * @param {Function} read_fn
392
+ * @param {number} file_size
393
+ * @param {any} source
394
+ * @param {any} source_parts
395
+ * @returns {Uint8Array}
396
+ */
397
+ export function generateAttachXbe(read_fn, file_size, source, source_parts) {
398
+ try {
399
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
400
+ wasm.generateAttachXbe(retptr, addBorrowedObject(read_fn), file_size, addBorrowedObject(source), addBorrowedObject(source_parts));
401
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
402
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
403
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
404
+ if (r2) {
405
+ throw takeObject(r1);
406
+ }
407
+ return takeObject(r0);
408
+ } finally {
409
+ wasm.__wbindgen_add_to_stack_pointer(16);
410
+ heap[stack_pointer++] = undefined;
411
+ heap[stack_pointer++] = undefined;
412
+ heap[stack_pointer++] = undefined;
413
+ }
414
+ }
415
+
416
+ /**
417
+ * Shows title/content-type for a source, before its conversion session is opened.
418
+ * Image-backed sources are inspected by locating and parsing the XDVDFS
419
+ * root; an extracted source has no such root, so it's inspected instead
420
+ * by locating and parsing `default.xbe`/`default.xex` directly off the
421
+ * directory.
422
+ *
423
+ * # Errors
424
+ *
425
+ * Returns an error if `source` is unresolved or invalid, if reading
426
+ * `source_parts` fails, or if the launch executable / XDVDFS root can't
427
+ * be located or parsed for the resolved source.
428
+ * @param {Function} read_fn
429
+ * @param {number} file_size
430
+ * @param {any} source
431
+ * @param {any} source_parts
432
+ * @returns {SourceInfo}
433
+ */
434
+ export function inspectSource(read_fn, file_size, source, source_parts) {
435
+ try {
436
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
437
+ wasm.inspectSource(retptr, addBorrowedObject(read_fn), file_size, addBorrowedObject(source), addBorrowedObject(source_parts));
438
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
439
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
440
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
441
+ if (r2) {
442
+ throw takeObject(r1);
443
+ }
444
+ return SourceInfo.__wrap(r0);
445
+ } finally {
446
+ wasm.__wbindgen_add_to_stack_pointer(16);
447
+ heap[stack_pointer++] = undefined;
448
+ heap[stack_pointer++] = undefined;
449
+ heap[stack_pointer++] = undefined;
450
+ }
451
+ }
452
+
453
+ /**
454
+ * Exposes the root-offset candidates `IsoType::read` actually probes -
455
+ * Xsf, Xgd2, Xgd1, Xgd3, in that order (iso2god-rs's `iso/iso_type.rs`) -
456
+ * so JS callers reference the real values instead of hardcoding magic
457
+ * numbers that could silently drift if iso2god-rs reorders or changes them.
458
+ * @returns {Array<any>}
459
+ */
460
+ export function isoRootOffsetCandidates() {
461
+ const ret = wasm.isoRootOffsetCandidates();
462
+ return takeObject(ret);
463
+ }
464
+
465
+ /**
466
+ * @returns {number}
467
+ */
468
+ export function mhtSize() {
469
+ const ret = wasm.mhtSize();
470
+ return ret >>> 0;
471
+ }
472
+
473
+ /**
474
+ * Opens a conversion session for the given source and the requested
475
+ * target-format `options`.
476
+ *
477
+ * # Errors
478
+ *
479
+ * Returns an error if `options` fails to deserialize into a known
480
+ * `FormatOptions` variant, if `source` is unresolved or invalid, if
481
+ * reading `source_parts` fails, or if the resolved source can't be
482
+ * opened as the requested target format (e.g. an extracted-only source
483
+ * requested as an image-only target).
484
+ * @param {Function} read_fn
485
+ * @param {number} file_size
486
+ * @param {any} options
487
+ * @param {any} source
488
+ * @param {any} source_parts
489
+ * @returns {ConversionSession}
490
+ */
491
+ export function openConversionSession(read_fn, file_size, options, source, source_parts) {
492
+ try {
493
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
494
+ wasm.openConversionSession(retptr, addBorrowedObject(read_fn), file_size, addHeapObject(options), addBorrowedObject(source), addBorrowedObject(source_parts));
495
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
496
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
497
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
498
+ if (r2) {
499
+ throw takeObject(r1);
500
+ }
501
+ return ConversionSession.__wrap(r0);
502
+ } finally {
503
+ wasm.__wbindgen_add_to_stack_pointer(16);
504
+ heap[stack_pointer++] = undefined;
505
+ heap[stack_pointer++] = undefined;
506
+ heap[stack_pointer++] = undefined;
507
+ }
508
+ }
509
+
510
+ /**
511
+ * @returns {number}
512
+ */
513
+ export function xisoSplitMargin() {
514
+ const ret = wasm.xisoSplitMargin();
515
+ return ret;
516
+ }
517
+
518
+ /**
519
+ * @returns {number}
520
+ */
521
+ export function zarBlockSize() {
522
+ const ret = wasm.zarBlockSize();
523
+ return ret >>> 0;
524
+ }
525
+ function __wbg_get_imports() {
526
+ const import0 = {
527
+ __proto__: null,
528
+ __wbg_Error_9dc85fe1bc224456: function(arg0, arg1) {
529
+ const ret = Error(getStringFromWasm0(arg0, arg1));
530
+ return addHeapObject(ret);
531
+ },
532
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
533
+ const ret = String(getObject(arg1));
534
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
535
+ const len1 = WASM_VECTOR_LEN;
536
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
537
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
538
+ },
539
+ __wbg___wbindgen_bigint_get_as_i64_8ea6736501f396b6: function(arg0, arg1) {
540
+ const v = getObject(arg1);
541
+ const ret = typeof(v) === 'bigint' ? v : undefined;
542
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
543
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
544
+ },
545
+ __wbg___wbindgen_boolean_get_b131b2f36d6b2f55: function(arg0) {
546
+ const v = getObject(arg0);
547
+ const ret = typeof(v) === 'boolean' ? v : undefined;
548
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
549
+ },
550
+ __wbg___wbindgen_debug_string_56c147eb1a51f0c4: function(arg0, arg1) {
551
+ const ret = debugString(getObject(arg1));
552
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
553
+ const len1 = WASM_VECTOR_LEN;
554
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
555
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
556
+ },
557
+ __wbg___wbindgen_in_ce8569b2fc6f5088: function(arg0, arg1) {
558
+ const ret = getObject(arg0) in getObject(arg1);
559
+ return ret;
560
+ },
561
+ __wbg___wbindgen_is_bigint_df272c65456269c2: function(arg0) {
562
+ const ret = typeof(getObject(arg0)) === 'bigint';
563
+ return ret;
564
+ },
565
+ __wbg___wbindgen_is_function_147961669f068cd4: function(arg0) {
566
+ const ret = typeof(getObject(arg0)) === 'function';
567
+ return ret;
568
+ },
569
+ __wbg___wbindgen_is_null_ced4761460071341: function(arg0) {
570
+ const ret = getObject(arg0) === null;
571
+ return ret;
572
+ },
573
+ __wbg___wbindgen_is_object_3a2c414391dbf751: function(arg0) {
574
+ const val = getObject(arg0);
575
+ const ret = typeof(val) === 'object' && val !== null;
576
+ return ret;
577
+ },
578
+ __wbg___wbindgen_is_undefined_4410e3c20a99fa97: function(arg0) {
579
+ const ret = getObject(arg0) === undefined;
580
+ return ret;
581
+ },
582
+ __wbg___wbindgen_jsval_eq_174c93ec61bab0c5: function(arg0, arg1) {
583
+ const ret = getObject(arg0) === getObject(arg1);
584
+ return ret;
585
+ },
586
+ __wbg___wbindgen_jsval_loose_eq_e07e3b1f5db6da6c: function(arg0, arg1) {
587
+ const ret = getObject(arg0) == getObject(arg1);
588
+ return ret;
589
+ },
590
+ __wbg___wbindgen_number_get_588ed6b97f0d7e14: function(arg0, arg1) {
591
+ const obj = getObject(arg1);
592
+ const ret = typeof(obj) === 'number' ? obj : undefined;
593
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
594
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
595
+ },
596
+ __wbg___wbindgen_string_get_fa2687d531ed17a5: function(arg0, arg1) {
597
+ const obj = getObject(arg1);
598
+ const ret = typeof(obj) === 'string' ? obj : undefined;
599
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
600
+ var len1 = WASM_VECTOR_LEN;
601
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
602
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
603
+ },
604
+ __wbg___wbindgen_throw_bbadd78c1bac3a77: function(arg0, arg1) {
605
+ throw new Error(getStringFromWasm0(arg0, arg1));
606
+ },
607
+ __wbg_byteLength_96807b1d9ab24a4c: function(arg0) {
608
+ const ret = getObject(arg0).byteLength;
609
+ return ret;
610
+ },
611
+ __wbg_call_91f00ddc43e01490: function() { return handleError(function (arg0, arg1) {
612
+ const ret = getObject(arg0).call(getObject(arg1));
613
+ return addHeapObject(ret);
614
+ }, arguments); },
615
+ __wbg_call_c00e41735f66c175: function() { return handleError(function (arg0, arg1, arg2, arg3) {
616
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3));
617
+ return addHeapObject(ret);
618
+ }, arguments); },
619
+ __wbg_done_6a8439e544ec6206: function(arg0) {
620
+ const ret = getObject(arg0).done;
621
+ return ret;
622
+ },
623
+ __wbg_entries_5a6a7e7e0df09fe5: function(arg0) {
624
+ const ret = Object.entries(getObject(arg0));
625
+ return addHeapObject(ret);
626
+ },
627
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
628
+ let deferred0_0;
629
+ let deferred0_1;
630
+ try {
631
+ deferred0_0 = arg0;
632
+ deferred0_1 = arg1;
633
+ console.error(getStringFromWasm0(arg0, arg1));
634
+ } finally {
635
+ wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
636
+ }
637
+ },
638
+ __wbg_get_44e98e27bda25b5b: function() { return handleError(function (arg0, arg1) {
639
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
640
+ return addHeapObject(ret);
641
+ }, arguments); },
642
+ __wbg_get_4b90d6d8c5deb5d5: function(arg0, arg1) {
643
+ const ret = getObject(arg0)[arg1 >>> 0];
644
+ return addHeapObject(ret);
645
+ },
646
+ __wbg_get_52a8a619f7b88df6: function() { return handleError(function (arg0, arg1) {
647
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
648
+ return addHeapObject(ret);
649
+ }, arguments); },
650
+ __wbg_get_unchecked_46e778e3cec74b5e: function(arg0, arg1) {
651
+ const ret = getObject(arg0)[arg1 >>> 0];
652
+ return addHeapObject(ret);
653
+ },
654
+ __wbg_instanceof_ArrayBuffer_a581da923203f29f: function(arg0) {
655
+ let result;
656
+ try {
657
+ result = getObject(arg0) instanceof ArrayBuffer;
658
+ } catch (_) {
659
+ result = false;
660
+ }
661
+ const ret = result;
662
+ return ret;
663
+ },
664
+ __wbg_instanceof_Map_7f94c740225003e2: function(arg0) {
665
+ let result;
666
+ try {
667
+ result = getObject(arg0) instanceof Map;
668
+ } catch (_) {
669
+ result = false;
670
+ }
671
+ const ret = result;
672
+ return ret;
673
+ },
674
+ __wbg_instanceof_Uint8Array_b6fe1ac89eba107e: function(arg0) {
675
+ let result;
676
+ try {
677
+ result = getObject(arg0) instanceof Uint8Array;
678
+ } catch (_) {
679
+ result = false;
680
+ }
681
+ const ret = result;
682
+ return ret;
683
+ },
684
+ __wbg_isArray_139f48e3c057ede8: function(arg0) {
685
+ const ret = Array.isArray(getObject(arg0));
686
+ return ret;
687
+ },
688
+ __wbg_isSafeInteger_c22ccb4af2201fe9: function(arg0) {
689
+ const ret = Number.isSafeInteger(getObject(arg0));
690
+ return ret;
691
+ },
692
+ __wbg_iterator_9b36cebf3be7b7cd: function() {
693
+ const ret = Symbol.iterator;
694
+ return addHeapObject(ret);
695
+ },
696
+ __wbg_length_68a9d5278d084f4f: function(arg0) {
697
+ const ret = getObject(arg0).length;
698
+ return ret;
699
+ },
700
+ __wbg_length_fb04d16d7bdf6d4c: function(arg0) {
701
+ const ret = getObject(arg0).length;
702
+ return ret;
703
+ },
704
+ __wbg_new_0b303268aa395a38: function() {
705
+ const ret = new Array();
706
+ return addHeapObject(ret);
707
+ },
708
+ __wbg_new_20b778a4c5c691c3: function() {
709
+ const ret = new Object();
710
+ return addHeapObject(ret);
711
+ },
712
+ __wbg_new_227d7c05414eb861: function() {
713
+ const ret = new Error();
714
+ return addHeapObject(ret);
715
+ },
716
+ __wbg_new_5fae30e6b23db8df: function(arg0, arg1) {
717
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
718
+ return addHeapObject(ret);
719
+ },
720
+ __wbg_new_b06772b280cc6e52: function(arg0) {
721
+ const ret = new Uint8Array(getObject(arg0));
722
+ return addHeapObject(ret);
723
+ },
724
+ __wbg_new_from_slice_bb2d1778c0b87eb1: function(arg0, arg1) {
725
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
726
+ return addHeapObject(ret);
727
+ },
728
+ __wbg_next_8cb028b6ba50743f: function() { return handleError(function (arg0) {
729
+ const ret = getObject(arg0).next();
730
+ return addHeapObject(ret);
731
+ }, arguments); },
732
+ __wbg_next_cfd0b146c9538df8: function(arg0) {
733
+ const ret = getObject(arg0).next;
734
+ return addHeapObject(ret);
735
+ },
736
+ __wbg_prototypesetcall_956c7493c68e29b4: function(arg0, arg1, arg2) {
737
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
738
+ },
739
+ __wbg_push_ceb8ef046afb2041: function(arg0, arg1) {
740
+ const ret = getObject(arg0).push(getObject(arg1));
741
+ return ret;
742
+ },
743
+ __wbg_set_a6ba3ac0e634b822: function() { return handleError(function (arg0, arg1, arg2) {
744
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
745
+ return ret;
746
+ }, arguments); },
747
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
748
+ const ret = getObject(arg1).stack;
749
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
750
+ const len1 = WASM_VECTOR_LEN;
751
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
752
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
753
+ },
754
+ __wbg_value_3d3defe09fb1ffca: function(arg0) {
755
+ const ret = getObject(arg0).value;
756
+ return addHeapObject(ret);
757
+ },
758
+ __wbindgen_cast_0000000000000001: function(arg0) {
759
+ // Cast intrinsic for `F64 -> Externref`.
760
+ const ret = arg0;
761
+ return addHeapObject(ret);
762
+ },
763
+ __wbindgen_cast_0000000000000002: function(arg0) {
764
+ // Cast intrinsic for `I64 -> Externref`.
765
+ const ret = arg0;
766
+ return addHeapObject(ret);
767
+ },
768
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
769
+ // Cast intrinsic for `Ref(String) -> Externref`.
770
+ const ret = getStringFromWasm0(arg0, arg1);
771
+ return addHeapObject(ret);
772
+ },
773
+ __wbindgen_cast_0000000000000004: function(arg0) {
774
+ // Cast intrinsic for `U64 -> Externref`.
775
+ const ret = BigInt.asUintN(64, arg0);
776
+ return addHeapObject(ret);
777
+ },
778
+ __wbindgen_object_clone_ref: function(arg0) {
779
+ const ret = getObject(arg0);
780
+ return addHeapObject(ret);
781
+ },
782
+ __wbindgen_object_drop_ref: function(arg0) {
783
+ takeObject(arg0);
784
+ },
785
+ };
786
+ return {
787
+ __proto__: null,
788
+ "./iso2x_wasm_bg.js": import0,
789
+ };
790
+ }
791
+
792
+ const ConversionSessionFinalization = (typeof FinalizationRegistry === 'undefined')
793
+ ? { register: () => {}, unregister: () => {} }
794
+ : new FinalizationRegistry(ptr => wasm.__wbg_conversionsession_free(ptr, 1));
795
+ const SourceInfoFinalization = (typeof FinalizationRegistry === 'undefined')
796
+ ? { register: () => {}, unregister: () => {} }
797
+ : new FinalizationRegistry(ptr => wasm.__wbg_sourceinfo_free(ptr, 1));
798
+
799
+ function addHeapObject(obj) {
800
+ if (heap_next === heap.length) heap.push(heap.length + 1);
801
+ const idx = heap_next;
802
+ heap_next = heap[idx];
803
+
804
+ heap[idx] = obj;
805
+ return idx;
806
+ }
807
+
808
+ function addBorrowedObject(obj) {
809
+ if (stack_pointer == 1) throw new Error('out of js stack');
810
+ heap[--stack_pointer] = obj;
811
+ return stack_pointer;
812
+ }
813
+
814
+ function debugString(val) {
815
+ // primitive types
816
+ const type = typeof val;
817
+ if (type == 'number' || type == 'boolean' || val == null) {
818
+ return `${val}`;
819
+ }
820
+ if (type == 'string') {
821
+ return `"${val}"`;
822
+ }
823
+ if (type == 'symbol') {
824
+ const description = val.description;
825
+ if (description == null) {
826
+ return 'Symbol';
827
+ } else {
828
+ return `Symbol(${description})`;
829
+ }
830
+ }
831
+ if (type == 'function') {
832
+ const name = val.name;
833
+ if (typeof name == 'string' && name.length > 0) {
834
+ return `Function(${name})`;
835
+ } else {
836
+ return 'Function';
837
+ }
838
+ }
839
+ // objects
840
+ if (Array.isArray(val)) {
841
+ const length = val.length;
842
+ let debug = '[';
843
+ if (length > 0) {
844
+ debug += debugString(val[0]);
845
+ }
846
+ for(let i = 1; i < length; i++) {
847
+ debug += ', ' + debugString(val[i]);
848
+ }
849
+ debug += ']';
850
+ return debug;
851
+ }
852
+ // Test for built-in
853
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
854
+ let className;
855
+ if (builtInMatches && builtInMatches.length > 1) {
856
+ className = builtInMatches[1];
857
+ } else {
858
+ // Failed to match the standard '[object ClassName]'
859
+ return toString.call(val);
860
+ }
861
+ if (className == 'Object') {
862
+ // we're a user defined class or Object
863
+ // JSON.stringify avoids problems with cycles, and is generally much
864
+ // easier than looping through ownProperties of `val`.
865
+ try {
866
+ return 'Object(' + JSON.stringify(val) + ')';
867
+ } catch (_) {
868
+ return 'Object';
869
+ }
870
+ }
871
+ // errors
872
+ if (val instanceof Error) {
873
+ return `${val.name}: ${val.message}\n${val.stack}`;
874
+ }
875
+ // TODO we could test for more things here, like `Set`s and `Map`s.
876
+ return className;
877
+ }
878
+
879
+ function dropObject(idx) {
880
+ if (idx < 1028) return;
881
+ heap[idx] = heap_next;
882
+ heap_next = idx;
883
+ }
884
+
885
+ function getArrayU8FromWasm0(ptr, len) {
886
+ ptr = ptr >>> 0;
887
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
888
+ }
889
+
890
+ let cachedDataViewMemory0 = null;
891
+ function getDataViewMemory0() {
892
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
893
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
894
+ }
895
+ return cachedDataViewMemory0;
896
+ }
897
+
898
+ function getStringFromWasm0(ptr, len) {
899
+ return decodeText(ptr >>> 0, len);
900
+ }
901
+
902
+ let cachedUint8ArrayMemory0 = null;
903
+ function getUint8ArrayMemory0() {
904
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
905
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
906
+ }
907
+ return cachedUint8ArrayMemory0;
908
+ }
909
+
910
+ function getObject(idx) { return heap[idx]; }
911
+
912
+ function handleError(f, args) {
913
+ try {
914
+ return f.apply(this, args);
915
+ } catch (e) {
916
+ wasm.__wbindgen_export3(addHeapObject(e));
917
+ }
918
+ }
919
+
920
+ let heap = new Array(1024).fill(undefined);
921
+ heap.push(undefined, null, true, false);
922
+
923
+ let heap_next = heap.length;
924
+
925
+ function isLikeNone(x) {
926
+ return x === undefined || x === null;
927
+ }
928
+
929
+ function passArray8ToWasm0(arg, malloc) {
930
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
931
+ getUint8ArrayMemory0().set(arg, ptr / 1);
932
+ WASM_VECTOR_LEN = arg.length;
933
+ return ptr;
934
+ }
935
+
936
+ function passArrayJsValueToWasm0(array, malloc) {
937
+ const ptr = malloc(array.length * 4, 4) >>> 0;
938
+ const mem = getDataViewMemory0();
939
+ for (let i = 0; i < array.length; i++) {
940
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
941
+ }
942
+ WASM_VECTOR_LEN = array.length;
943
+ return ptr;
944
+ }
945
+
946
+ function passStringToWasm0(arg, malloc, realloc) {
947
+ if (realloc === undefined) {
948
+ const buf = cachedTextEncoder.encode(arg);
949
+ const ptr = malloc(buf.length, 1) >>> 0;
950
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
951
+ WASM_VECTOR_LEN = buf.length;
952
+ return ptr;
953
+ }
954
+
955
+ let len = arg.length;
956
+ let ptr = malloc(len, 1) >>> 0;
957
+
958
+ const mem = getUint8ArrayMemory0();
959
+
960
+ let offset = 0;
961
+
962
+ for (; offset < len; offset++) {
963
+ const code = arg.charCodeAt(offset);
964
+ if (code > 0x7F) break;
965
+ mem[ptr + offset] = code;
966
+ }
967
+ if (offset !== len) {
968
+ if (offset !== 0) {
969
+ arg = arg.slice(offset);
970
+ }
971
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
972
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
973
+ const ret = cachedTextEncoder.encodeInto(arg, view);
974
+
975
+ offset += ret.written;
976
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
977
+ }
978
+
979
+ WASM_VECTOR_LEN = offset;
980
+ return ptr;
981
+ }
982
+
983
+ let stack_pointer = 1024;
984
+
985
+ function takeObject(idx) {
986
+ const ret = getObject(idx);
987
+ dropObject(idx);
988
+ return ret;
989
+ }
990
+
991
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
992
+ cachedTextDecoder.decode();
993
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
994
+ let numBytesDecoded = 0;
995
+ function decodeText(ptr, len) {
996
+ numBytesDecoded += len;
997
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
998
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
999
+ cachedTextDecoder.decode();
1000
+ numBytesDecoded = len;
1001
+ }
1002
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1003
+ }
1004
+
1005
+ const cachedTextEncoder = new TextEncoder();
1006
+
1007
+ if (!('encodeInto' in cachedTextEncoder)) {
1008
+ cachedTextEncoder.encodeInto = function (arg, view) {
1009
+ const buf = cachedTextEncoder.encode(arg);
1010
+ view.set(buf);
1011
+ return {
1012
+ read: arg.length,
1013
+ written: buf.length
1014
+ };
1015
+ };
1016
+ }
1017
+
1018
+ let WASM_VECTOR_LEN = 0;
1019
+
1020
+ let wasmModule, wasmInstance, wasm;
1021
+ function __wbg_finalize_init(instance, module) {
1022
+ wasmInstance = instance;
1023
+ wasm = instance.exports;
1024
+ wasmModule = module;
1025
+ cachedDataViewMemory0 = null;
1026
+ cachedUint8ArrayMemory0 = null;
1027
+ return wasm;
1028
+ }
1029
+
1030
+ async function __wbg_load(module, imports) {
1031
+ if (typeof Response === 'function' && module instanceof Response) {
1032
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1033
+ try {
1034
+ return await WebAssembly.instantiateStreaming(module, imports);
1035
+ } catch (e) {
1036
+ const validResponse = module.ok && expectedResponseType(module.type);
1037
+
1038
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1039
+ 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);
1040
+
1041
+ } else { throw e; }
1042
+ }
1043
+ }
1044
+
1045
+ const bytes = await module.arrayBuffer();
1046
+ return await WebAssembly.instantiate(bytes, imports);
1047
+ } else {
1048
+ const instance = await WebAssembly.instantiate(module, imports);
1049
+
1050
+ if (instance instanceof WebAssembly.Instance) {
1051
+ return { instance, module };
1052
+ } else {
1053
+ return instance;
1054
+ }
1055
+ }
1056
+
1057
+ function expectedResponseType(type) {
1058
+ switch (type) {
1059
+ case 'basic': case 'cors': case 'default': return true;
1060
+ }
1061
+ return false;
1062
+ }
1063
+ }
1064
+
1065
+ function initSync(module) {
1066
+ if (wasm !== undefined) return wasm;
1067
+
1068
+
1069
+ if (module !== undefined) {
1070
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1071
+ ({module} = module)
1072
+ } else {
1073
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1074
+ }
1075
+ }
1076
+
1077
+ const imports = __wbg_get_imports();
1078
+ if (!(module instanceof WebAssembly.Module)) {
1079
+ module = new WebAssembly.Module(module);
1080
+ }
1081
+ const instance = new WebAssembly.Instance(module, imports);
1082
+ return __wbg_finalize_init(instance, module);
1083
+ }
1084
+
1085
+ async function __wbg_init(module_or_path) {
1086
+ if (wasm !== undefined) return wasm;
1087
+
1088
+
1089
+ if (module_or_path !== undefined) {
1090
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1091
+ ({module_or_path} = module_or_path)
1092
+ } else {
1093
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1094
+ }
1095
+ }
1096
+
1097
+ if (module_or_path === undefined) {
1098
+ module_or_path = new URL('iso2x_wasm_bg.wasm', import.meta.url);
1099
+ }
1100
+ const imports = __wbg_get_imports();
1101
+
1102
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1103
+ module_or_path = fetch(module_or_path);
1104
+ }
1105
+
1106
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1107
+
1108
+ return __wbg_finalize_init(instance, module);
1109
+ }
1110
+
1111
+ export { initSync, __wbg_init as default };