@imferno/wasm 0.1.3

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,709 @@
1
+ /* @ts-self-types="./imferno_wasm.d.ts" */
2
+
3
+ /**
4
+ * Compare a SourceAsset against a delivery spec
5
+ * @param {any} sourceAssetJson
6
+ * @param {any} deliverySpecJson
7
+ * @returns {any}
8
+ */
9
+ export function compareDelivery(sourceAssetJson, deliverySpecJson) {
10
+ const ret = wasm.compareDelivery(sourceAssetJson, deliverySpecJson);
11
+ if (ret[2]) {
12
+ throw takeFromExternrefTable0(ret[1]);
13
+ }
14
+ return takeFromExternrefTable0(ret[0]);
15
+ }
16
+
17
+ /**
18
+ * Extract a SourceAsset from CPL XML
19
+ * @param {string} cplXml
20
+ * @returns {any}
21
+ */
22
+ export function extractSourceAsset(cplXml) {
23
+ const ptr0 = passStringToWasm0(cplXml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
24
+ const len0 = WASM_VECTOR_LEN;
25
+ const ret = wasm.extractSourceAsset(ptr0, len0);
26
+ if (ret[2]) {
27
+ throw takeFromExternrefTable0(ret[1]);
28
+ }
29
+ return takeFromExternrefTable0(ret[0]);
30
+ }
31
+
32
+ /**
33
+ * Get library version
34
+ * @returns {string}
35
+ */
36
+ export function getVersion() {
37
+ let deferred1_0;
38
+ let deferred1_1;
39
+ try {
40
+ const ret = wasm.getVersion();
41
+ deferred1_0 = ret[0];
42
+ deferred1_1 = ret[1];
43
+ return getStringFromWasm0(ret[0], ret[1]);
44
+ } finally {
45
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Initialize the WASM module
51
+ */
52
+ export function init() {
53
+ wasm.init();
54
+ }
55
+
56
+ /**
57
+ * Inspect an IMF package and return structural metadata including unreferenced assets.
58
+ *
59
+ * Returns `{ cplCount, scmCount, declaredSidecars, unreferencedAssets }` where
60
+ * `unreferencedAssets` are assets in the AssetMap with no CPL Virtual Track reference
61
+ * and no SCM declaration — likely sidecar essences delivered without an SCM.
62
+ * @param {any} files
63
+ * @returns {any}
64
+ */
65
+ export function inspectPackage(files) {
66
+ const ret = wasm.inspectPackage(files);
67
+ if (ret[2]) {
68
+ throw takeFromExternrefTable0(ret[1]);
69
+ }
70
+ return takeFromExternrefTable0(ret[0]);
71
+ }
72
+
73
+ /**
74
+ * Parse ASSETMAP.xml and return a typed AssetMap object
75
+ * @param {string} xmlContent
76
+ * @returns {any}
77
+ */
78
+ export function parseAssetmapTyped(xmlContent) {
79
+ const ptr0 = passStringToWasm0(xmlContent, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
80
+ const len0 = WASM_VECTOR_LEN;
81
+ const ret = wasm.parseAssetmapTyped(ptr0, len0);
82
+ if (ret[2]) {
83
+ throw takeFromExternrefTable0(ret[1]);
84
+ }
85
+ return takeFromExternrefTable0(ret[0]);
86
+ }
87
+
88
+ /**
89
+ * Parse CPL XML and return a typed CompositionPlaylist object
90
+ * @param {string} xmlContent
91
+ * @returns {CompositionPlaylist}
92
+ */
93
+ export function parseCplTyped(xmlContent) {
94
+ const ptr0 = passStringToWasm0(xmlContent, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
95
+ const len0 = WASM_VECTOR_LEN;
96
+ const ret = wasm.parseCplTyped(ptr0, len0);
97
+ if (ret[2]) {
98
+ throw takeFromExternrefTable0(ret[1]);
99
+ }
100
+ return takeFromExternrefTable0(ret[0]);
101
+ }
102
+
103
+ /**
104
+ * Parse PKL XML and return a typed PackingList object
105
+ * @param {string} xmlContent
106
+ * @returns {any}
107
+ */
108
+ export function parsePklTyped(xmlContent) {
109
+ const ptr0 = passStringToWasm0(xmlContent, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
110
+ const len0 = WASM_VECTOR_LEN;
111
+ const ret = wasm.parsePklTyped(ptr0, len0);
112
+ if (ret[2]) {
113
+ throw takeFromExternrefTable0(ret[1]);
114
+ }
115
+ return takeFromExternrefTable0(ret[0]);
116
+ }
117
+
118
+ /**
119
+ * Parse VOLINDEX.xml and return a typed VolumeIndex object
120
+ * @param {string} xmlContent
121
+ * @returns {VolumeIndex}
122
+ */
123
+ export function parseVolindexTyped(xmlContent) {
124
+ const ptr0 = passStringToWasm0(xmlContent, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
125
+ const len0 = WASM_VECTOR_LEN;
126
+ const ret = wasm.parseVolindexTyped(ptr0, len0);
127
+ if (ret[2]) {
128
+ throw takeFromExternrefTable0(ret[1]);
129
+ }
130
+ return takeFromExternrefTable0(ret[0]);
131
+ }
132
+
133
+ /**
134
+ * Validate a CPL with configurable built-in spec selection (ST 2067-2/App2E).
135
+ *
136
+ * `coreSpec`: "auto" | "v2013" | "v2016" | "v2020"
137
+ * `app2eSpec`: "auto" | "none" | "v2020" | "v2021" | "v2023"
138
+ * @param {string} cplXml
139
+ * @param {string | null} [coreSpec]
140
+ * @param {string | null} [app2eSpec]
141
+ * @returns {any}
142
+ */
143
+ export function validateCplWithSpecSelection(cplXml, coreSpec, app2eSpec) {
144
+ const ptr0 = passStringToWasm0(cplXml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
145
+ const len0 = WASM_VECTOR_LEN;
146
+ var ptr1 = isLikeNone(coreSpec) ? 0 : passStringToWasm0(coreSpec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
147
+ var len1 = WASM_VECTOR_LEN;
148
+ var ptr2 = isLikeNone(app2eSpec) ? 0 : passStringToWasm0(app2eSpec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
149
+ var len2 = WASM_VECTOR_LEN;
150
+ const ret = wasm.validateCplWithSpecSelection(ptr0, len0, ptr1, len1, ptr2, len2);
151
+ if (ret[2]) {
152
+ throw takeFromExternrefTable0(ret[1]);
153
+ }
154
+ return takeFromExternrefTable0(ret[0]);
155
+ }
156
+
157
+ /**
158
+ * Validate a full IMF package from an in-memory map of filename → XML string.
159
+ *
160
+ * Pass all XML files from the package as a plain JS object where each key is
161
+ * the filename and each value is the file's text content. ASSETMAP.xml is
162
+ * required; VOLINDEX.xml, PKL files, and CPL files are resolved automatically
163
+ * from the AssetMap.
164
+ *
165
+ * Returns a `ValidationReport` serialized to JS.
166
+ * @param {any} files
167
+ * @param {any} rules
168
+ * @returns {any}
169
+ */
170
+ export function validatePackage(files, rules) {
171
+ const ret = wasm.validatePackage(files, rules);
172
+ if (ret[2]) {
173
+ throw takeFromExternrefTable0(ret[1]);
174
+ }
175
+ return takeFromExternrefTable0(ret[0]);
176
+ }
177
+
178
+ function __wbg_get_imports() {
179
+ const import0 = {
180
+ __proto__: null,
181
+ __wbg_Error_4577686b3a6d9b3a: function(arg0, arg1) {
182
+ const ret = Error(getStringFromWasm0(arg0, arg1));
183
+ return ret;
184
+ },
185
+ __wbg_Number_e89e48a2fe1a6355: function(arg0) {
186
+ const ret = Number(arg0);
187
+ return ret;
188
+ },
189
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
190
+ const ret = String(arg1);
191
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
192
+ const len1 = WASM_VECTOR_LEN;
193
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
194
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
195
+ },
196
+ __wbg___wbindgen_bigint_get_as_i64_578010f8442e0319: function(arg0, arg1) {
197
+ const v = arg1;
198
+ const ret = typeof(v) === 'bigint' ? v : undefined;
199
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
200
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
201
+ },
202
+ __wbg___wbindgen_boolean_get_18c4ed9422296fff: function(arg0) {
203
+ const v = arg0;
204
+ const ret = typeof(v) === 'boolean' ? v : undefined;
205
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
206
+ },
207
+ __wbg___wbindgen_debug_string_ddde1867f49c2442: function(arg0, arg1) {
208
+ const ret = debugString(arg1);
209
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
210
+ const len1 = WASM_VECTOR_LEN;
211
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
212
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
213
+ },
214
+ __wbg___wbindgen_in_1064a108f4d18b9e: function(arg0, arg1) {
215
+ const ret = arg0 in arg1;
216
+ return ret;
217
+ },
218
+ __wbg___wbindgen_is_bigint_a157f0734ca85901: function(arg0) {
219
+ const ret = typeof(arg0) === 'bigint';
220
+ return ret;
221
+ },
222
+ __wbg___wbindgen_is_function_d633e708baf0d146: function(arg0) {
223
+ const ret = typeof(arg0) === 'function';
224
+ return ret;
225
+ },
226
+ __wbg___wbindgen_is_null_a2a19127c13e7126: function(arg0) {
227
+ const ret = arg0 === null;
228
+ return ret;
229
+ },
230
+ __wbg___wbindgen_is_object_4b3de556756ee8a8: function(arg0) {
231
+ const val = arg0;
232
+ const ret = typeof(val) === 'object' && val !== null;
233
+ return ret;
234
+ },
235
+ __wbg___wbindgen_is_string_7debe47dc1e045c2: function(arg0) {
236
+ const ret = typeof(arg0) === 'string';
237
+ return ret;
238
+ },
239
+ __wbg___wbindgen_is_undefined_c18285b9fc34cb7d: function(arg0) {
240
+ const ret = arg0 === undefined;
241
+ return ret;
242
+ },
243
+ __wbg___wbindgen_jsval_eq_a6afb59d8c5e78d6: function(arg0, arg1) {
244
+ const ret = arg0 === arg1;
245
+ return ret;
246
+ },
247
+ __wbg___wbindgen_jsval_loose_eq_1562ceb9af84e990: function(arg0, arg1) {
248
+ const ret = arg0 == arg1;
249
+ return ret;
250
+ },
251
+ __wbg___wbindgen_number_get_5854912275df1894: function(arg0, arg1) {
252
+ const obj = arg1;
253
+ const ret = typeof(obj) === 'number' ? obj : undefined;
254
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
255
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
256
+ },
257
+ __wbg___wbindgen_string_get_3e5751597f39a112: function(arg0, arg1) {
258
+ const obj = arg1;
259
+ const ret = typeof(obj) === 'string' ? obj : undefined;
260
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
261
+ var len1 = WASM_VECTOR_LEN;
262
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
263
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
264
+ },
265
+ __wbg___wbindgen_throw_39bc967c0e5a9b58: function(arg0, arg1) {
266
+ throw new Error(getStringFromWasm0(arg0, arg1));
267
+ },
268
+ __wbg_call_73af281463ec8b58: function() { return handleError(function (arg0, arg1) {
269
+ const ret = arg0.call(arg1);
270
+ return ret;
271
+ }, arguments); },
272
+ __wbg_done_5aad55ec6b1954b1: function(arg0) {
273
+ const ret = arg0.done;
274
+ return ret;
275
+ },
276
+ __wbg_entries_28d32ba4cd93f5fc: function(arg0) {
277
+ const ret = Object.entries(arg0);
278
+ return ret;
279
+ },
280
+ __wbg_getTime_9429d05129287418: function(arg0) {
281
+ const ret = arg0.getTime();
282
+ return ret;
283
+ },
284
+ __wbg_get_4920fefd3451364b: function() { return handleError(function (arg0, arg1) {
285
+ const ret = Reflect.get(arg0, arg1);
286
+ return ret;
287
+ }, arguments); },
288
+ __wbg_get_f09c3a16f8848381: function(arg0, arg1) {
289
+ const ret = arg0[arg1 >>> 0];
290
+ return ret;
291
+ },
292
+ __wbg_get_unchecked_3d0f4b91c8eca4f0: function(arg0, arg1) {
293
+ const ret = arg0[arg1 >>> 0];
294
+ return ret;
295
+ },
296
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
297
+ const ret = arg0[arg1];
298
+ return ret;
299
+ },
300
+ __wbg_instanceof_ArrayBuffer_15859862b80b732d: function(arg0) {
301
+ let result;
302
+ try {
303
+ result = arg0 instanceof ArrayBuffer;
304
+ } catch (_) {
305
+ result = false;
306
+ }
307
+ const ret = result;
308
+ return ret;
309
+ },
310
+ __wbg_instanceof_Uint8Array_2240b7046ac16f05: function(arg0) {
311
+ let result;
312
+ try {
313
+ result = arg0 instanceof Uint8Array;
314
+ } catch (_) {
315
+ result = false;
316
+ }
317
+ const ret = result;
318
+ return ret;
319
+ },
320
+ __wbg_isArray_fad08a0d12828686: function(arg0) {
321
+ const ret = Array.isArray(arg0);
322
+ return ret;
323
+ },
324
+ __wbg_isSafeInteger_10e4151eb694e42a: function(arg0) {
325
+ const ret = Number.isSafeInteger(arg0);
326
+ return ret;
327
+ },
328
+ __wbg_iterator_fc7ad8d33bab9e26: function() {
329
+ const ret = Symbol.iterator;
330
+ return ret;
331
+ },
332
+ __wbg_length_5855c1f289dfffc1: function(arg0) {
333
+ const ret = arg0.length;
334
+ return ret;
335
+ },
336
+ __wbg_length_a31e05262e09b7f8: function(arg0) {
337
+ const ret = arg0.length;
338
+ return ret;
339
+ },
340
+ __wbg_log_b6373503dce9c42b: function(arg0, arg1) {
341
+ console.log(getStringFromWasm0(arg0, arg1));
342
+ },
343
+ __wbg_new_09959f7b4c92c246: function(arg0) {
344
+ const ret = new Uint8Array(arg0);
345
+ return ret;
346
+ },
347
+ __wbg_new_0_a719938e6f92ddf4: function() {
348
+ const ret = new Date();
349
+ return ret;
350
+ },
351
+ __wbg_new_92df58a8ec3bfb6b: function() {
352
+ const ret = new Map();
353
+ return ret;
354
+ },
355
+ __wbg_new_cbee8c0d5c479eac: function() {
356
+ const ret = new Array();
357
+ return ret;
358
+ },
359
+ __wbg_new_ed69e637b553a997: function() {
360
+ const ret = new Object();
361
+ return ret;
362
+ },
363
+ __wbg_next_a5fe6f328f7affc2: function(arg0) {
364
+ const ret = arg0.next;
365
+ return ret;
366
+ },
367
+ __wbg_next_e592122bb4ed4c67: function() { return handleError(function (arg0) {
368
+ const ret = arg0.next();
369
+ return ret;
370
+ }, arguments); },
371
+ __wbg_parse_59ff569636b34ff5: function(arg0, arg1) {
372
+ let deferred0_0;
373
+ let deferred0_1;
374
+ try {
375
+ deferred0_0 = arg0;
376
+ deferred0_1 = arg1;
377
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
378
+ return ret;
379
+ } finally {
380
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
381
+ }
382
+ },
383
+ __wbg_prototypesetcall_f034d444741426c3: function(arg0, arg1, arg2) {
384
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
385
+ },
386
+ __wbg_set_4c81cfb5dc3a333c: function(arg0, arg1, arg2) {
387
+ arg0[arg1 >>> 0] = arg2;
388
+ },
389
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
390
+ arg0[arg1] = arg2;
391
+ },
392
+ __wbg_set_cfc6de03f990decf: function(arg0, arg1, arg2) {
393
+ const ret = arg0.set(arg1, arg2);
394
+ return ret;
395
+ },
396
+ __wbg_value_667dcb90597486a6: function(arg0) {
397
+ const ret = arg0.value;
398
+ return ret;
399
+ },
400
+ __wbindgen_cast_0000000000000001: function(arg0) {
401
+ // Cast intrinsic for `F64 -> Externref`.
402
+ const ret = arg0;
403
+ return ret;
404
+ },
405
+ __wbindgen_cast_0000000000000002: function(arg0) {
406
+ // Cast intrinsic for `I64 -> Externref`.
407
+ const ret = arg0;
408
+ return ret;
409
+ },
410
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
411
+ // Cast intrinsic for `Ref(String) -> Externref`.
412
+ const ret = getStringFromWasm0(arg0, arg1);
413
+ return ret;
414
+ },
415
+ __wbindgen_cast_0000000000000004: function(arg0) {
416
+ // Cast intrinsic for `U64 -> Externref`.
417
+ const ret = BigInt.asUintN(64, arg0);
418
+ return ret;
419
+ },
420
+ __wbindgen_init_externref_table: function() {
421
+ const table = wasm.__wbindgen_externrefs;
422
+ const offset = table.grow(4);
423
+ table.set(0, undefined);
424
+ table.set(offset + 0, undefined);
425
+ table.set(offset + 1, null);
426
+ table.set(offset + 2, true);
427
+ table.set(offset + 3, false);
428
+ },
429
+ };
430
+ return {
431
+ __proto__: null,
432
+ "./imferno_wasm_bg.js": import0,
433
+ };
434
+ }
435
+
436
+ function addToExternrefTable0(obj) {
437
+ const idx = wasm.__externref_table_alloc();
438
+ wasm.__wbindgen_externrefs.set(idx, obj);
439
+ return idx;
440
+ }
441
+
442
+ function debugString(val) {
443
+ // primitive types
444
+ const type = typeof val;
445
+ if (type == 'number' || type == 'boolean' || val == null) {
446
+ return `${val}`;
447
+ }
448
+ if (type == 'string') {
449
+ return `"${val}"`;
450
+ }
451
+ if (type == 'symbol') {
452
+ const description = val.description;
453
+ if (description == null) {
454
+ return 'Symbol';
455
+ } else {
456
+ return `Symbol(${description})`;
457
+ }
458
+ }
459
+ if (type == 'function') {
460
+ const name = val.name;
461
+ if (typeof name == 'string' && name.length > 0) {
462
+ return `Function(${name})`;
463
+ } else {
464
+ return 'Function';
465
+ }
466
+ }
467
+ // objects
468
+ if (Array.isArray(val)) {
469
+ const length = val.length;
470
+ let debug = '[';
471
+ if (length > 0) {
472
+ debug += debugString(val[0]);
473
+ }
474
+ for(let i = 1; i < length; i++) {
475
+ debug += ', ' + debugString(val[i]);
476
+ }
477
+ debug += ']';
478
+ return debug;
479
+ }
480
+ // Test for built-in
481
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
482
+ let className;
483
+ if (builtInMatches && builtInMatches.length > 1) {
484
+ className = builtInMatches[1];
485
+ } else {
486
+ // Failed to match the standard '[object ClassName]'
487
+ return toString.call(val);
488
+ }
489
+ if (className == 'Object') {
490
+ // we're a user defined class or Object
491
+ // JSON.stringify avoids problems with cycles, and is generally much
492
+ // easier than looping through ownProperties of `val`.
493
+ try {
494
+ return 'Object(' + JSON.stringify(val) + ')';
495
+ } catch (_) {
496
+ return 'Object';
497
+ }
498
+ }
499
+ // errors
500
+ if (val instanceof Error) {
501
+ return `${val.name}: ${val.message}\n${val.stack}`;
502
+ }
503
+ // TODO we could test for more things here, like `Set`s and `Map`s.
504
+ return className;
505
+ }
506
+
507
+ function getArrayU8FromWasm0(ptr, len) {
508
+ ptr = ptr >>> 0;
509
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
510
+ }
511
+
512
+ let cachedDataViewMemory0 = null;
513
+ function getDataViewMemory0() {
514
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
515
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
516
+ }
517
+ return cachedDataViewMemory0;
518
+ }
519
+
520
+ function getStringFromWasm0(ptr, len) {
521
+ ptr = ptr >>> 0;
522
+ return decodeText(ptr, len);
523
+ }
524
+
525
+ let cachedUint8ArrayMemory0 = null;
526
+ function getUint8ArrayMemory0() {
527
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
528
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
529
+ }
530
+ return cachedUint8ArrayMemory0;
531
+ }
532
+
533
+ function handleError(f, args) {
534
+ try {
535
+ return f.apply(this, args);
536
+ } catch (e) {
537
+ const idx = addToExternrefTable0(e);
538
+ wasm.__wbindgen_exn_store(idx);
539
+ }
540
+ }
541
+
542
+ function isLikeNone(x) {
543
+ return x === undefined || x === null;
544
+ }
545
+
546
+ function passStringToWasm0(arg, malloc, realloc) {
547
+ if (realloc === undefined) {
548
+ const buf = cachedTextEncoder.encode(arg);
549
+ const ptr = malloc(buf.length, 1) >>> 0;
550
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
551
+ WASM_VECTOR_LEN = buf.length;
552
+ return ptr;
553
+ }
554
+
555
+ let len = arg.length;
556
+ let ptr = malloc(len, 1) >>> 0;
557
+
558
+ const mem = getUint8ArrayMemory0();
559
+
560
+ let offset = 0;
561
+
562
+ for (; offset < len; offset++) {
563
+ const code = arg.charCodeAt(offset);
564
+ if (code > 0x7F) break;
565
+ mem[ptr + offset] = code;
566
+ }
567
+ if (offset !== len) {
568
+ if (offset !== 0) {
569
+ arg = arg.slice(offset);
570
+ }
571
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
572
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
573
+ const ret = cachedTextEncoder.encodeInto(arg, view);
574
+
575
+ offset += ret.written;
576
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
577
+ }
578
+
579
+ WASM_VECTOR_LEN = offset;
580
+ return ptr;
581
+ }
582
+
583
+ function takeFromExternrefTable0(idx) {
584
+ const value = wasm.__wbindgen_externrefs.get(idx);
585
+ wasm.__externref_table_dealloc(idx);
586
+ return value;
587
+ }
588
+
589
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
590
+ cachedTextDecoder.decode();
591
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
592
+ let numBytesDecoded = 0;
593
+ function decodeText(ptr, len) {
594
+ numBytesDecoded += len;
595
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
596
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
597
+ cachedTextDecoder.decode();
598
+ numBytesDecoded = len;
599
+ }
600
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
601
+ }
602
+
603
+ const cachedTextEncoder = new TextEncoder();
604
+
605
+ if (!('encodeInto' in cachedTextEncoder)) {
606
+ cachedTextEncoder.encodeInto = function (arg, view) {
607
+ const buf = cachedTextEncoder.encode(arg);
608
+ view.set(buf);
609
+ return {
610
+ read: arg.length,
611
+ written: buf.length
612
+ };
613
+ };
614
+ }
615
+
616
+ let WASM_VECTOR_LEN = 0;
617
+
618
+ let wasmModule, wasm;
619
+ function __wbg_finalize_init(instance, module) {
620
+ wasm = instance.exports;
621
+ wasmModule = module;
622
+ cachedDataViewMemory0 = null;
623
+ cachedUint8ArrayMemory0 = null;
624
+ wasm.__wbindgen_start();
625
+ return wasm;
626
+ }
627
+
628
+ async function __wbg_load(module, imports) {
629
+ if (typeof Response === 'function' && module instanceof Response) {
630
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
631
+ try {
632
+ return await WebAssembly.instantiateStreaming(module, imports);
633
+ } catch (e) {
634
+ const validResponse = module.ok && expectedResponseType(module.type);
635
+
636
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
637
+ 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);
638
+
639
+ } else { throw e; }
640
+ }
641
+ }
642
+
643
+ const bytes = await module.arrayBuffer();
644
+ return await WebAssembly.instantiate(bytes, imports);
645
+ } else {
646
+ const instance = await WebAssembly.instantiate(module, imports);
647
+
648
+ if (instance instanceof WebAssembly.Instance) {
649
+ return { instance, module };
650
+ } else {
651
+ return instance;
652
+ }
653
+ }
654
+
655
+ function expectedResponseType(type) {
656
+ switch (type) {
657
+ case 'basic': case 'cors': case 'default': return true;
658
+ }
659
+ return false;
660
+ }
661
+ }
662
+
663
+ function initSync(module) {
664
+ if (wasm !== undefined) return wasm;
665
+
666
+
667
+ if (module !== undefined) {
668
+ if (Object.getPrototypeOf(module) === Object.prototype) {
669
+ ({module} = module)
670
+ } else {
671
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
672
+ }
673
+ }
674
+
675
+ const imports = __wbg_get_imports();
676
+ if (!(module instanceof WebAssembly.Module)) {
677
+ module = new WebAssembly.Module(module);
678
+ }
679
+ const instance = new WebAssembly.Instance(module, imports);
680
+ return __wbg_finalize_init(instance, module);
681
+ }
682
+
683
+ async function __wbg_init(module_or_path) {
684
+ if (wasm !== undefined) return wasm;
685
+
686
+
687
+ if (module_or_path !== undefined) {
688
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
689
+ ({module_or_path} = module_or_path)
690
+ } else {
691
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
692
+ }
693
+ }
694
+
695
+ if (module_or_path === undefined) {
696
+ module_or_path = new URL('imferno_wasm_bg.wasm', import.meta.url);
697
+ }
698
+ const imports = __wbg_get_imports();
699
+
700
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
701
+ module_or_path = fetch(module_or_path);
702
+ }
703
+
704
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
705
+
706
+ return __wbg_finalize_init(instance, module);
707
+ }
708
+
709
+ export { initSync, __wbg_init as default };
Binary file