@structured-world/structured-zstd 0.2.5 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@structured-world/structured-zstd",
3
- "version": "0.2.5",
3
+ "version": "0.3.0",
4
4
  "description": "Pure-Rust Zstandard (zstd) codec compiled to WebAssembly — compress and decompress in the browser, Node.js and Deno, with automatic SIMD (simd128) acceleration and a scalar fallback. No native addons, no FFI.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -51,7 +51,7 @@ export class ZstdCompressStream {
51
51
  * Feed more plaintext; returns whatever compressed bytes are now complete
52
52
  * (possibly empty while the current block is still filling).
53
53
  */
54
- push(chunk: Uint8Array): Uint8Array;
54
+ push(chunk: Uint8Array | number[]): Uint8Array;
55
55
  /**
56
56
  * Open a streaming compressor at `level` seeded with a raw zstd dictionary
57
57
  * blob (e.g. from `zstd --train`), mirroring `ZSTD_CCtx_loadDictionary` on
@@ -61,7 +61,7 @@ export class ZstdCompressStream {
61
61
  * opened via its matching `withDictionary` constructor (or the one-shot
62
62
  * `decompressUsingDict`). Throws if the dictionary is invalid.
63
63
  */
64
- static withDictionary(level: number, dict: Uint8Array, checksum?: boolean | null): ZstdCompressStream;
64
+ static withDictionary(level: number, dict: Uint8Array | number[], checksum?: boolean | null): ZstdCompressStream;
65
65
  /**
66
66
  * Open a streaming compressor at `level` seeded from a [`ZstdDictionary`]
67
67
  * prepared once: per-stream setup copies the prepared tables instead of
@@ -104,7 +104,7 @@ export class ZstdDecompressStream {
104
104
  * Feed more compressed bytes; returns whatever decompressed output is now
105
105
  * available (possibly empty while a block is still incomplete).
106
106
  */
107
- push(chunk: Uint8Array): Uint8Array;
107
+ push(chunk: Uint8Array | number[]): Uint8Array;
108
108
  /**
109
109
  * The content checksum stored in the frame's 4-byte trailer, or
110
110
  * `undefined` if the frame carried none. Meaningful after [`Self::finish`].
@@ -117,7 +117,7 @@ export class ZstdDecompressStream {
117
117
  * `withDictionary`). `checksum` behaves as in [`Self::new`]. Throws if the
118
118
  * dictionary is malformed.
119
119
  */
120
- static withDictionary(dict: Uint8Array, checksum?: ContentChecksum | null): ZstdDecompressStream;
120
+ static withDictionary(dict: Uint8Array | number[], checksum?: ContentChecksum | null): ZstdDecompressStream;
121
121
  /**
122
122
  * Open a streaming decompressor against a [`ZstdDictionary`] prepared
123
123
  * once: per-stream setup is a reference-count bump, no dictionary
@@ -158,19 +158,19 @@ export class ZstdDictionary {
158
158
  *
159
159
  * `checksum` is optional (default `false`).
160
160
  */
161
- compress(data: Uint8Array, level: number, checksum?: boolean | null): Uint8Array;
161
+ compress(data: Uint8Array | number[], level: number, checksum?: boolean | null): Uint8Array;
162
162
  /**
163
163
  * Decompress a frame produced with this dictionary, reusing the
164
164
  * prepared tables and one decoder workspace across calls. `checksum`
165
165
  * behaves as in the module-level `decompress`.
166
166
  */
167
- decompress(data: Uint8Array, checksum?: ContentChecksum | null): Uint8Array;
167
+ decompress(data: Uint8Array | number[], checksum?: ContentChecksum | null): Uint8Array;
168
168
  /**
169
169
  * Parse `dict` once for repeated use. Magic-prefixed blobs (e.g. from
170
170
  * `zstd --train`) parse as full dictionaries; anything else is raw
171
171
  * content. Throws if a magic-prefixed blob is corrupt.
172
172
  */
173
- constructor(dict: Uint8Array);
173
+ constructor(dict: Uint8Array | number[]);
174
174
  /**
175
175
  * The dictionary ID (0 for raw content).
176
176
  */
@@ -188,7 +188,7 @@ export class ZstdDictionary {
188
188
  * `ZSTD_c_checksumFlag = 0`): pass `true` to append the trailing XXH64 content
189
189
  * checksum.
190
190
  */
191
- export function compress(data: Uint8Array, level: number, checksum?: boolean | null): Uint8Array;
191
+ export function compress(data: Uint8Array | number[], level: number, checksum?: boolean | null): Uint8Array;
192
192
 
193
193
  /**
194
194
  * Compress `data` against a raw Zstandard dictionary at compression `level`.
@@ -200,7 +200,7 @@ export function compress(data: Uint8Array, level: number, checksum?: boolean | n
200
200
  * `checksum` is optional (default `false`, matching libzstd's
201
201
  * `ZSTD_c_checksumFlag = 0`); pass `true` to append the XXH64 trailer.
202
202
  */
203
- export function compressUsingDict(data: Uint8Array, dict: Uint8Array, level: number, checksum?: boolean | null): Uint8Array;
203
+ export function compressUsingDict(data: Uint8Array | number[], dict: Uint8Array | number[], level: number, checksum?: boolean | null): Uint8Array;
204
204
 
205
205
  /**
206
206
  * Decompress a complete Zstandard frame back into its original bytes.
@@ -211,7 +211,7 @@ export function compressUsingDict(data: Uint8Array, dict: Uint8Array, level: num
211
211
  * pass `ContentChecksum.Verify` to validate, or `EmitOnly` to compute without
212
212
  * erroring on mismatch.
213
213
  */
214
- export function decompress(data: Uint8Array, checksum?: ContentChecksum | null): Uint8Array;
214
+ export function decompress(data: Uint8Array | number[], checksum?: ContentChecksum | null): Uint8Array;
215
215
 
216
216
  /**
217
217
  * Decompress a dictionary-encoded Zstandard frame.
@@ -220,7 +220,7 @@ export function decompress(data: Uint8Array, checksum?: ContentChecksum | null):
220
220
  * dictionary the frame was compressed with. Throws on a malformed frame or a
221
221
  * dictionary mismatch.
222
222
  */
223
- export function decompressUsingDict(data: Uint8Array, dict: Uint8Array, checksum?: ContentChecksum | null): Uint8Array;
223
+ export function decompressUsingDict(data: Uint8Array | number[], dict: Uint8Array | number[], checksum?: ContentChecksum | null): Uint8Array;
224
224
 
225
225
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
226
226
 
@@ -251,8 +251,8 @@ export interface InitOutput {
251
251
  readonly zstddictionary_new: (a: number, b: number) => [number, number, number];
252
252
  readonly __wbindgen_externrefs: WebAssembly.Table;
253
253
  readonly __wbindgen_malloc: (a: number, b: number) => number;
254
- readonly __externref_table_dealloc: (a: number) => void;
255
254
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
255
+ readonly __externref_table_dealloc: (a: number) => void;
256
256
  readonly __wbindgen_start: () => void;
257
257
  }
258
258
 
@@ -80,7 +80,7 @@ export class ZstdCompressStream {
80
80
  /**
81
81
  * Feed more plaintext; returns whatever compressed bytes are now complete
82
82
  * (possibly empty while the current block is still filling).
83
- * @param {Uint8Array} chunk
83
+ * @param {Uint8Array | number[]} chunk
84
84
  * @returns {Uint8Array}
85
85
  */
86
86
  push(chunk) {
@@ -103,14 +103,15 @@ export class ZstdCompressStream {
103
103
  * opened via its matching `withDictionary` constructor (or the one-shot
104
104
  * `decompressUsingDict`). Throws if the dictionary is invalid.
105
105
  * @param {number} level
106
- * @param {Uint8Array} dict
106
+ * @param {Uint8Array | number[]} dict
107
107
  * @param {boolean | null} [checksum]
108
108
  * @returns {ZstdCompressStream}
109
109
  */
110
110
  static withDictionary(level, dict, checksum) {
111
+ const val2 = +level;
111
112
  const ptr0 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
112
113
  const len0 = WASM_VECTOR_LEN;
113
- const ret = wasm.zstdcompressstream_withDictionary(level, ptr0, len0, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
114
+ const ret = wasm.zstdcompressstream_withDictionary(val2, ptr0, len0, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
114
115
  if (ret[2]) {
115
116
  throw takeFromExternrefTable0(ret[1]);
116
117
  }
@@ -202,7 +203,7 @@ export class ZstdDecompressStream {
202
203
  /**
203
204
  * Feed more compressed bytes; returns whatever decompressed output is now
204
205
  * available (possibly empty while a block is still incomplete).
205
- * @param {Uint8Array} chunk
206
+ * @param {Uint8Array | number[]} chunk
206
207
  * @returns {Uint8Array}
207
208
  */
208
209
  push(chunk) {
@@ -231,14 +232,15 @@ export class ZstdDecompressStream {
231
232
  * frame was compressed with (e.g. via [`ZstdCompressStream`]'s
232
233
  * `withDictionary`). `checksum` behaves as in [`Self::new`]. Throws if the
233
234
  * dictionary is malformed.
234
- * @param {Uint8Array} dict
235
+ * @param {Uint8Array | number[]} dict
235
236
  * @param {ContentChecksum | null} [checksum]
236
237
  * @returns {ZstdDecompressStream}
237
238
  */
238
239
  static withDictionary(dict, checksum) {
240
+ const val2 = +(isLikeNone(checksum) ? 3 : checksum);
239
241
  const ptr0 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
240
242
  const len0 = WASM_VECTOR_LEN;
241
- const ret = wasm.zstddecompressstream_withDictionary(ptr0, len0, isLikeNone(checksum) ? 3 : checksum);
243
+ const ret = wasm.zstddecompressstream_withDictionary(ptr0, len0, val2);
242
244
  if (ret[2]) {
243
245
  throw takeFromExternrefTable0(ret[1]);
244
246
  }
@@ -299,40 +301,42 @@ export class ZstdDictionary {
299
301
  * every following call reuses that primed snapshot.
300
302
  *
301
303
  * `checksum` is optional (default `false`).
302
- * @param {Uint8Array} data
304
+ * @param {Uint8Array | number[]} data
303
305
  * @param {number} level
304
306
  * @param {boolean | null} [checksum]
305
307
  * @returns {Uint8Array}
306
308
  */
307
309
  compress(data, level, checksum) {
310
+ const val2 = +level;
308
311
  const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
309
312
  const len0 = WASM_VECTOR_LEN;
310
- const ret = wasm.zstddictionary_compress(this.__wbg_ptr, ptr0, len0, level, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
313
+ const ret = wasm.zstddictionary_compress(this.__wbg_ptr, ptr0, len0, val2, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
311
314
  if (ret[3]) {
312
315
  throw takeFromExternrefTable0(ret[2]);
313
316
  }
314
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
317
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
315
318
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
316
- return v2;
319
+ return v3;
317
320
  }
318
321
  /**
319
322
  * Decompress a frame produced with this dictionary, reusing the
320
323
  * prepared tables and one decoder workspace across calls. `checksum`
321
324
  * behaves as in the module-level `decompress`.
322
- * @param {Uint8Array} data
325
+ * @param {Uint8Array | number[]} data
323
326
  * @param {ContentChecksum | null} [checksum]
324
327
  * @returns {Uint8Array}
325
328
  */
326
329
  decompress(data, checksum) {
330
+ const val2 = +(isLikeNone(checksum) ? 3 : checksum);
327
331
  const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
328
332
  const len0 = WASM_VECTOR_LEN;
329
- const ret = wasm.zstddictionary_decompress(this.__wbg_ptr, ptr0, len0, isLikeNone(checksum) ? 3 : checksum);
333
+ const ret = wasm.zstddictionary_decompress(this.__wbg_ptr, ptr0, len0, val2);
330
334
  if (ret[3]) {
331
335
  throw takeFromExternrefTable0(ret[2]);
332
336
  }
333
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
337
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
334
338
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
335
- return v2;
339
+ return v3;
336
340
  }
337
341
  /**
338
342
  * The dictionary ID (0 for raw content).
@@ -346,7 +350,7 @@ export class ZstdDictionary {
346
350
  * Parse `dict` once for repeated use. Magic-prefixed blobs (e.g. from
347
351
  * `zstd --train`) parse as full dictionaries; anything else is raw
348
352
  * content. Throws if a magic-prefixed blob is corrupt.
349
- * @param {Uint8Array} dict
353
+ * @param {Uint8Array | number[]} dict
350
354
  */
351
355
  constructor(dict) {
352
356
  const ptr0 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
@@ -372,18 +376,19 @@ if (Symbol.dispose) ZstdDictionary.prototype[Symbol.dispose] = ZstdDictionary.pr
372
376
  * `checksum` is optional (default `false`, matching libzstd's
373
377
  * `ZSTD_c_checksumFlag = 0`): pass `true` to append the trailing XXH64 content
374
378
  * checksum.
375
- * @param {Uint8Array} data
379
+ * @param {Uint8Array | number[]} data
376
380
  * @param {number} level
377
381
  * @param {boolean | null} [checksum]
378
382
  * @returns {Uint8Array}
379
383
  */
380
384
  export function compress(data, level, checksum) {
385
+ const val2 = +level;
381
386
  const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
382
387
  const len0 = WASM_VECTOR_LEN;
383
- const ret = wasm.compress(ptr0, len0, level, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
384
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
388
+ const ret = wasm.compress(ptr0, len0, val2, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
389
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
385
390
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
386
- return v2;
391
+ return v3;
387
392
  }
388
393
 
389
394
  /**
@@ -395,24 +400,32 @@ export function compress(data, level, checksum) {
395
400
  *
396
401
  * `checksum` is optional (default `false`, matching libzstd's
397
402
  * `ZSTD_c_checksumFlag = 0`); pass `true` to append the XXH64 trailer.
398
- * @param {Uint8Array} data
399
- * @param {Uint8Array} dict
403
+ * @param {Uint8Array | number[]} data
404
+ * @param {Uint8Array | number[]} dict
400
405
  * @param {number} level
401
406
  * @param {boolean | null} [checksum]
402
407
  * @returns {Uint8Array}
403
408
  */
404
409
  export function compressUsingDict(data, dict, level, checksum) {
405
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
406
- const len0 = WASM_VECTOR_LEN;
407
- const ptr1 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
408
- const len1 = WASM_VECTOR_LEN;
409
- const ret = wasm.compressUsingDict(ptr0, len0, ptr1, len1, level, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
410
+ const val3 = +level;
411
+ let ptr0, len0, ptr1, len1;
412
+ try {
413
+ ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
414
+ len0 = WASM_VECTOR_LEN;
415
+ ptr1 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
416
+ len1 = WASM_VECTOR_LEN;
417
+ } catch (e) {
418
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
419
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
420
+ throw e;
421
+ }
422
+ const ret = wasm.compressUsingDict(ptr0, len0, ptr1, len1, val3, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
410
423
  if (ret[3]) {
411
424
  throw takeFromExternrefTable0(ret[2]);
412
425
  }
413
- var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
426
+ var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
414
427
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
415
- return v3;
428
+ return v4;
416
429
  }
417
430
 
418
431
  /**
@@ -423,20 +436,21 @@ export function compressUsingDict(data, dict, level, checksum) {
423
436
  * `checksum` is optional (default `None` — skip the XXH64 pass for speed);
424
437
  * pass `ContentChecksum.Verify` to validate, or `EmitOnly` to compute without
425
438
  * erroring on mismatch.
426
- * @param {Uint8Array} data
439
+ * @param {Uint8Array | number[]} data
427
440
  * @param {ContentChecksum | null} [checksum]
428
441
  * @returns {Uint8Array}
429
442
  */
430
443
  export function decompress(data, checksum) {
444
+ const val2 = +(isLikeNone(checksum) ? 3 : checksum);
431
445
  const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
432
446
  const len0 = WASM_VECTOR_LEN;
433
- const ret = wasm.decompress(ptr0, len0, isLikeNone(checksum) ? 3 : checksum);
447
+ const ret = wasm.decompress(ptr0, len0, val2);
434
448
  if (ret[3]) {
435
449
  throw takeFromExternrefTable0(ret[2]);
436
450
  }
437
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
451
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
438
452
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
439
- return v2;
453
+ return v3;
440
454
  }
441
455
 
442
456
  /**
@@ -445,42 +459,49 @@ export function decompress(data, checksum) {
445
459
  * Mirrors C `ZSTD_decompress_usingDict`: `dict` must be the same raw
446
460
  * dictionary the frame was compressed with. Throws on a malformed frame or a
447
461
  * dictionary mismatch.
448
- * @param {Uint8Array} data
449
- * @param {Uint8Array} dict
462
+ * @param {Uint8Array | number[]} data
463
+ * @param {Uint8Array | number[]} dict
450
464
  * @param {ContentChecksum | null} [checksum]
451
465
  * @returns {Uint8Array}
452
466
  */
453
467
  export function decompressUsingDict(data, dict, checksum) {
454
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
455
- const len0 = WASM_VECTOR_LEN;
456
- const ptr1 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
457
- const len1 = WASM_VECTOR_LEN;
458
- const ret = wasm.decompressUsingDict(ptr0, len0, ptr1, len1, isLikeNone(checksum) ? 3 : checksum);
468
+ const val3 = +(isLikeNone(checksum) ? 3 : checksum);
469
+ let ptr0, len0, ptr1, len1;
470
+ try {
471
+ ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
472
+ len0 = WASM_VECTOR_LEN;
473
+ ptr1 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
474
+ len1 = WASM_VECTOR_LEN;
475
+ } catch (e) {
476
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
477
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
478
+ throw e;
479
+ }
480
+ const ret = wasm.decompressUsingDict(ptr0, len0, ptr1, len1, val3);
459
481
  if (ret[3]) {
460
482
  throw takeFromExternrefTable0(ret[2]);
461
483
  }
462
- var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
484
+ var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
463
485
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
464
- return v3;
486
+ return v4;
465
487
  }
466
488
  function __wbg_get_imports() {
467
489
  const import0 = {
468
490
  __proto__: null,
469
- __wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
491
+ __wbg_Error_208446807d0d1e30: function(arg0, arg1) {
470
492
  const ret = Error(getStringFromWasm0(arg0, arg1));
471
493
  return ret;
472
494
  },
473
- __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
495
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
474
496
  throw new Error(getStringFromWasm0(arg0, arg1));
475
497
  },
476
498
  __wbindgen_init_externref_table: function() {
477
499
  const table = wasm.__wbindgen_externrefs;
478
- const offset = table.grow(4);
479
500
  table.set(0, undefined);
480
- table.set(offset + 0, undefined);
481
- table.set(offset + 1, null);
482
- table.set(offset + 2, true);
483
- table.set(offset + 3, false);
501
+ table.set(1024, undefined);
502
+ table.set(1025, null);
503
+ table.set(1026, true);
504
+ table.set(1027, false);
484
505
  },
485
506
  };
486
507
  return {
@@ -511,7 +532,8 @@ function getArrayU8FromWasm0(ptr, len) {
511
532
  }
512
533
 
513
534
  function getStringFromWasm0(ptr, len) {
514
- return decodeText(ptr >>> 0, len);
535
+ ptr = ptr >>> 0;
536
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
515
537
  }
516
538
 
517
539
  let cachedUint8ArrayMemory0 = null;
@@ -539,18 +561,18 @@ function takeFromExternrefTable0(idx) {
539
561
  return value;
540
562
  }
541
563
 
542
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
564
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
543
565
  cachedTextDecoder.decode();
544
566
  const MAX_SAFARI_DECODE_BYTES = 2146435072;
545
567
  let numBytesDecoded = 0;
546
- function decodeText(ptr, len) {
547
- numBytesDecoded += len;
568
+ function decodeText(bytes) {
569
+ numBytesDecoded += bytes.length;
548
570
  if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
549
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
571
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
550
572
  cachedTextDecoder.decode();
551
- numBytesDecoded = len;
573
+ numBytesDecoded = bytes.length;
552
574
  }
553
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
575
+ return cachedTextDecoder.decode(bytes);
554
576
  }
555
577
 
556
578
  let WASM_VECTOR_LEN = 0;
@@ -624,9 +646,17 @@ function initSync(module) {
624
646
  return __wbg_finalize_init(instance, module);
625
647
  }
626
648
 
649
+ let __wbg_init_promise;
627
650
  async function __wbg_init(module_or_path) {
628
651
  if (wasm !== undefined) return wasm;
652
+ if (__wbg_init_promise === undefined) {
653
+ __wbg_init_promise = __wbg_init_once(module_or_path);
654
+ __wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
655
+ }
656
+ return __wbg_init_promise;
657
+ }
629
658
 
659
+ async function __wbg_init_once(module_or_path) {
630
660
 
631
661
  if (module_or_path !== undefined) {
632
662
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
Binary file
@@ -26,6 +26,6 @@ export const zstddictionary_id: (a: number) => number;
26
26
  export const zstddictionary_new: (a: number, b: number) => [number, number, number];
27
27
  export const __wbindgen_externrefs: WebAssembly.Table;
28
28
  export const __wbindgen_malloc: (a: number, b: number) => number;
29
- export const __externref_table_dealloc: (a: number) => void;
30
29
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
30
+ export const __externref_table_dealloc: (a: number) => void;
31
31
  export const __wbindgen_start: () => void;
@@ -51,7 +51,7 @@ export class ZstdCompressStream {
51
51
  * Feed more plaintext; returns whatever compressed bytes are now complete
52
52
  * (possibly empty while the current block is still filling).
53
53
  */
54
- push(chunk: Uint8Array): Uint8Array;
54
+ push(chunk: Uint8Array | number[]): Uint8Array;
55
55
  /**
56
56
  * Open a streaming compressor at `level` seeded with a raw zstd dictionary
57
57
  * blob (e.g. from `zstd --train`), mirroring `ZSTD_CCtx_loadDictionary` on
@@ -61,7 +61,7 @@ export class ZstdCompressStream {
61
61
  * opened via its matching `withDictionary` constructor (or the one-shot
62
62
  * `decompressUsingDict`). Throws if the dictionary is invalid.
63
63
  */
64
- static withDictionary(level: number, dict: Uint8Array, checksum?: boolean | null): ZstdCompressStream;
64
+ static withDictionary(level: number, dict: Uint8Array | number[], checksum?: boolean | null): ZstdCompressStream;
65
65
  /**
66
66
  * Open a streaming compressor at `level` seeded from a [`ZstdDictionary`]
67
67
  * prepared once: per-stream setup copies the prepared tables instead of
@@ -104,7 +104,7 @@ export class ZstdDecompressStream {
104
104
  * Feed more compressed bytes; returns whatever decompressed output is now
105
105
  * available (possibly empty while a block is still incomplete).
106
106
  */
107
- push(chunk: Uint8Array): Uint8Array;
107
+ push(chunk: Uint8Array | number[]): Uint8Array;
108
108
  /**
109
109
  * The content checksum stored in the frame's 4-byte trailer, or
110
110
  * `undefined` if the frame carried none. Meaningful after [`Self::finish`].
@@ -117,7 +117,7 @@ export class ZstdDecompressStream {
117
117
  * `withDictionary`). `checksum` behaves as in [`Self::new`]. Throws if the
118
118
  * dictionary is malformed.
119
119
  */
120
- static withDictionary(dict: Uint8Array, checksum?: ContentChecksum | null): ZstdDecompressStream;
120
+ static withDictionary(dict: Uint8Array | number[], checksum?: ContentChecksum | null): ZstdDecompressStream;
121
121
  /**
122
122
  * Open a streaming decompressor against a [`ZstdDictionary`] prepared
123
123
  * once: per-stream setup is a reference-count bump, no dictionary
@@ -158,19 +158,19 @@ export class ZstdDictionary {
158
158
  *
159
159
  * `checksum` is optional (default `false`).
160
160
  */
161
- compress(data: Uint8Array, level: number, checksum?: boolean | null): Uint8Array;
161
+ compress(data: Uint8Array | number[], level: number, checksum?: boolean | null): Uint8Array;
162
162
  /**
163
163
  * Decompress a frame produced with this dictionary, reusing the
164
164
  * prepared tables and one decoder workspace across calls. `checksum`
165
165
  * behaves as in the module-level `decompress`.
166
166
  */
167
- decompress(data: Uint8Array, checksum?: ContentChecksum | null): Uint8Array;
167
+ decompress(data: Uint8Array | number[], checksum?: ContentChecksum | null): Uint8Array;
168
168
  /**
169
169
  * Parse `dict` once for repeated use. Magic-prefixed blobs (e.g. from
170
170
  * `zstd --train`) parse as full dictionaries; anything else is raw
171
171
  * content. Throws if a magic-prefixed blob is corrupt.
172
172
  */
173
- constructor(dict: Uint8Array);
173
+ constructor(dict: Uint8Array | number[]);
174
174
  /**
175
175
  * The dictionary ID (0 for raw content).
176
176
  */
@@ -188,7 +188,7 @@ export class ZstdDictionary {
188
188
  * `ZSTD_c_checksumFlag = 0`): pass `true` to append the trailing XXH64 content
189
189
  * checksum.
190
190
  */
191
- export function compress(data: Uint8Array, level: number, checksum?: boolean | null): Uint8Array;
191
+ export function compress(data: Uint8Array | number[], level: number, checksum?: boolean | null): Uint8Array;
192
192
 
193
193
  /**
194
194
  * Compress `data` against a raw Zstandard dictionary at compression `level`.
@@ -200,7 +200,7 @@ export function compress(data: Uint8Array, level: number, checksum?: boolean | n
200
200
  * `checksum` is optional (default `false`, matching libzstd's
201
201
  * `ZSTD_c_checksumFlag = 0`); pass `true` to append the XXH64 trailer.
202
202
  */
203
- export function compressUsingDict(data: Uint8Array, dict: Uint8Array, level: number, checksum?: boolean | null): Uint8Array;
203
+ export function compressUsingDict(data: Uint8Array | number[], dict: Uint8Array | number[], level: number, checksum?: boolean | null): Uint8Array;
204
204
 
205
205
  /**
206
206
  * Decompress a complete Zstandard frame back into its original bytes.
@@ -211,7 +211,7 @@ export function compressUsingDict(data: Uint8Array, dict: Uint8Array, level: num
211
211
  * pass `ContentChecksum.Verify` to validate, or `EmitOnly` to compute without
212
212
  * erroring on mismatch.
213
213
  */
214
- export function decompress(data: Uint8Array, checksum?: ContentChecksum | null): Uint8Array;
214
+ export function decompress(data: Uint8Array | number[], checksum?: ContentChecksum | null): Uint8Array;
215
215
 
216
216
  /**
217
217
  * Decompress a dictionary-encoded Zstandard frame.
@@ -220,7 +220,7 @@ export function decompress(data: Uint8Array, checksum?: ContentChecksum | null):
220
220
  * dictionary the frame was compressed with. Throws on a malformed frame or a
221
221
  * dictionary mismatch.
222
222
  */
223
- export function decompressUsingDict(data: Uint8Array, dict: Uint8Array, checksum?: ContentChecksum | null): Uint8Array;
223
+ export function decompressUsingDict(data: Uint8Array | number[], dict: Uint8Array | number[], checksum?: ContentChecksum | null): Uint8Array;
224
224
 
225
225
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
226
226
 
@@ -251,8 +251,8 @@ export interface InitOutput {
251
251
  readonly zstddictionary_new: (a: number, b: number) => [number, number, number];
252
252
  readonly __wbindgen_externrefs: WebAssembly.Table;
253
253
  readonly __wbindgen_malloc: (a: number, b: number) => number;
254
- readonly __externref_table_dealloc: (a: number) => void;
255
254
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
255
+ readonly __externref_table_dealloc: (a: number) => void;
256
256
  readonly __wbindgen_start: () => void;
257
257
  }
258
258
 
@@ -80,7 +80,7 @@ export class ZstdCompressStream {
80
80
  /**
81
81
  * Feed more plaintext; returns whatever compressed bytes are now complete
82
82
  * (possibly empty while the current block is still filling).
83
- * @param {Uint8Array} chunk
83
+ * @param {Uint8Array | number[]} chunk
84
84
  * @returns {Uint8Array}
85
85
  */
86
86
  push(chunk) {
@@ -103,14 +103,15 @@ export class ZstdCompressStream {
103
103
  * opened via its matching `withDictionary` constructor (or the one-shot
104
104
  * `decompressUsingDict`). Throws if the dictionary is invalid.
105
105
  * @param {number} level
106
- * @param {Uint8Array} dict
106
+ * @param {Uint8Array | number[]} dict
107
107
  * @param {boolean | null} [checksum]
108
108
  * @returns {ZstdCompressStream}
109
109
  */
110
110
  static withDictionary(level, dict, checksum) {
111
+ const val2 = +level;
111
112
  const ptr0 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
112
113
  const len0 = WASM_VECTOR_LEN;
113
- const ret = wasm.zstdcompressstream_withDictionary(level, ptr0, len0, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
114
+ const ret = wasm.zstdcompressstream_withDictionary(val2, ptr0, len0, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
114
115
  if (ret[2]) {
115
116
  throw takeFromExternrefTable0(ret[1]);
116
117
  }
@@ -202,7 +203,7 @@ export class ZstdDecompressStream {
202
203
  /**
203
204
  * Feed more compressed bytes; returns whatever decompressed output is now
204
205
  * available (possibly empty while a block is still incomplete).
205
- * @param {Uint8Array} chunk
206
+ * @param {Uint8Array | number[]} chunk
206
207
  * @returns {Uint8Array}
207
208
  */
208
209
  push(chunk) {
@@ -231,14 +232,15 @@ export class ZstdDecompressStream {
231
232
  * frame was compressed with (e.g. via [`ZstdCompressStream`]'s
232
233
  * `withDictionary`). `checksum` behaves as in [`Self::new`]. Throws if the
233
234
  * dictionary is malformed.
234
- * @param {Uint8Array} dict
235
+ * @param {Uint8Array | number[]} dict
235
236
  * @param {ContentChecksum | null} [checksum]
236
237
  * @returns {ZstdDecompressStream}
237
238
  */
238
239
  static withDictionary(dict, checksum) {
240
+ const val2 = +(isLikeNone(checksum) ? 3 : checksum);
239
241
  const ptr0 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
240
242
  const len0 = WASM_VECTOR_LEN;
241
- const ret = wasm.zstddecompressstream_withDictionary(ptr0, len0, isLikeNone(checksum) ? 3 : checksum);
243
+ const ret = wasm.zstddecompressstream_withDictionary(ptr0, len0, val2);
242
244
  if (ret[2]) {
243
245
  throw takeFromExternrefTable0(ret[1]);
244
246
  }
@@ -299,40 +301,42 @@ export class ZstdDictionary {
299
301
  * every following call reuses that primed snapshot.
300
302
  *
301
303
  * `checksum` is optional (default `false`).
302
- * @param {Uint8Array} data
304
+ * @param {Uint8Array | number[]} data
303
305
  * @param {number} level
304
306
  * @param {boolean | null} [checksum]
305
307
  * @returns {Uint8Array}
306
308
  */
307
309
  compress(data, level, checksum) {
310
+ const val2 = +level;
308
311
  const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
309
312
  const len0 = WASM_VECTOR_LEN;
310
- const ret = wasm.zstddictionary_compress(this.__wbg_ptr, ptr0, len0, level, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
313
+ const ret = wasm.zstddictionary_compress(this.__wbg_ptr, ptr0, len0, val2, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
311
314
  if (ret[3]) {
312
315
  throw takeFromExternrefTable0(ret[2]);
313
316
  }
314
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
317
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
315
318
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
316
- return v2;
319
+ return v3;
317
320
  }
318
321
  /**
319
322
  * Decompress a frame produced with this dictionary, reusing the
320
323
  * prepared tables and one decoder workspace across calls. `checksum`
321
324
  * behaves as in the module-level `decompress`.
322
- * @param {Uint8Array} data
325
+ * @param {Uint8Array | number[]} data
323
326
  * @param {ContentChecksum | null} [checksum]
324
327
  * @returns {Uint8Array}
325
328
  */
326
329
  decompress(data, checksum) {
330
+ const val2 = +(isLikeNone(checksum) ? 3 : checksum);
327
331
  const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
328
332
  const len0 = WASM_VECTOR_LEN;
329
- const ret = wasm.zstddictionary_decompress(this.__wbg_ptr, ptr0, len0, isLikeNone(checksum) ? 3 : checksum);
333
+ const ret = wasm.zstddictionary_decompress(this.__wbg_ptr, ptr0, len0, val2);
330
334
  if (ret[3]) {
331
335
  throw takeFromExternrefTable0(ret[2]);
332
336
  }
333
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
337
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
334
338
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
335
- return v2;
339
+ return v3;
336
340
  }
337
341
  /**
338
342
  * The dictionary ID (0 for raw content).
@@ -346,7 +350,7 @@ export class ZstdDictionary {
346
350
  * Parse `dict` once for repeated use. Magic-prefixed blobs (e.g. from
347
351
  * `zstd --train`) parse as full dictionaries; anything else is raw
348
352
  * content. Throws if a magic-prefixed blob is corrupt.
349
- * @param {Uint8Array} dict
353
+ * @param {Uint8Array | number[]} dict
350
354
  */
351
355
  constructor(dict) {
352
356
  const ptr0 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
@@ -372,18 +376,19 @@ if (Symbol.dispose) ZstdDictionary.prototype[Symbol.dispose] = ZstdDictionary.pr
372
376
  * `checksum` is optional (default `false`, matching libzstd's
373
377
  * `ZSTD_c_checksumFlag = 0`): pass `true` to append the trailing XXH64 content
374
378
  * checksum.
375
- * @param {Uint8Array} data
379
+ * @param {Uint8Array | number[]} data
376
380
  * @param {number} level
377
381
  * @param {boolean | null} [checksum]
378
382
  * @returns {Uint8Array}
379
383
  */
380
384
  export function compress(data, level, checksum) {
385
+ const val2 = +level;
381
386
  const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
382
387
  const len0 = WASM_VECTOR_LEN;
383
- const ret = wasm.compress(ptr0, len0, level, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
384
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
388
+ const ret = wasm.compress(ptr0, len0, val2, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
389
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
385
390
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
386
- return v2;
391
+ return v3;
387
392
  }
388
393
 
389
394
  /**
@@ -395,24 +400,32 @@ export function compress(data, level, checksum) {
395
400
  *
396
401
  * `checksum` is optional (default `false`, matching libzstd's
397
402
  * `ZSTD_c_checksumFlag = 0`); pass `true` to append the XXH64 trailer.
398
- * @param {Uint8Array} data
399
- * @param {Uint8Array} dict
403
+ * @param {Uint8Array | number[]} data
404
+ * @param {Uint8Array | number[]} dict
400
405
  * @param {number} level
401
406
  * @param {boolean | null} [checksum]
402
407
  * @returns {Uint8Array}
403
408
  */
404
409
  export function compressUsingDict(data, dict, level, checksum) {
405
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
406
- const len0 = WASM_VECTOR_LEN;
407
- const ptr1 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
408
- const len1 = WASM_VECTOR_LEN;
409
- const ret = wasm.compressUsingDict(ptr0, len0, ptr1, len1, level, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
410
+ const val3 = +level;
411
+ let ptr0, len0, ptr1, len1;
412
+ try {
413
+ ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
414
+ len0 = WASM_VECTOR_LEN;
415
+ ptr1 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
416
+ len1 = WASM_VECTOR_LEN;
417
+ } catch (e) {
418
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
419
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
420
+ throw e;
421
+ }
422
+ const ret = wasm.compressUsingDict(ptr0, len0, ptr1, len1, val3, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
410
423
  if (ret[3]) {
411
424
  throw takeFromExternrefTable0(ret[2]);
412
425
  }
413
- var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
426
+ var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
414
427
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
415
- return v3;
428
+ return v4;
416
429
  }
417
430
 
418
431
  /**
@@ -423,20 +436,21 @@ export function compressUsingDict(data, dict, level, checksum) {
423
436
  * `checksum` is optional (default `None` — skip the XXH64 pass for speed);
424
437
  * pass `ContentChecksum.Verify` to validate, or `EmitOnly` to compute without
425
438
  * erroring on mismatch.
426
- * @param {Uint8Array} data
439
+ * @param {Uint8Array | number[]} data
427
440
  * @param {ContentChecksum | null} [checksum]
428
441
  * @returns {Uint8Array}
429
442
  */
430
443
  export function decompress(data, checksum) {
444
+ const val2 = +(isLikeNone(checksum) ? 3 : checksum);
431
445
  const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
432
446
  const len0 = WASM_VECTOR_LEN;
433
- const ret = wasm.decompress(ptr0, len0, isLikeNone(checksum) ? 3 : checksum);
447
+ const ret = wasm.decompress(ptr0, len0, val2);
434
448
  if (ret[3]) {
435
449
  throw takeFromExternrefTable0(ret[2]);
436
450
  }
437
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
451
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
438
452
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
439
- return v2;
453
+ return v3;
440
454
  }
441
455
 
442
456
  /**
@@ -445,42 +459,49 @@ export function decompress(data, checksum) {
445
459
  * Mirrors C `ZSTD_decompress_usingDict`: `dict` must be the same raw
446
460
  * dictionary the frame was compressed with. Throws on a malformed frame or a
447
461
  * dictionary mismatch.
448
- * @param {Uint8Array} data
449
- * @param {Uint8Array} dict
462
+ * @param {Uint8Array | number[]} data
463
+ * @param {Uint8Array | number[]} dict
450
464
  * @param {ContentChecksum | null} [checksum]
451
465
  * @returns {Uint8Array}
452
466
  */
453
467
  export function decompressUsingDict(data, dict, checksum) {
454
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
455
- const len0 = WASM_VECTOR_LEN;
456
- const ptr1 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
457
- const len1 = WASM_VECTOR_LEN;
458
- const ret = wasm.decompressUsingDict(ptr0, len0, ptr1, len1, isLikeNone(checksum) ? 3 : checksum);
468
+ const val3 = +(isLikeNone(checksum) ? 3 : checksum);
469
+ let ptr0, len0, ptr1, len1;
470
+ try {
471
+ ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
472
+ len0 = WASM_VECTOR_LEN;
473
+ ptr1 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
474
+ len1 = WASM_VECTOR_LEN;
475
+ } catch (e) {
476
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
477
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
478
+ throw e;
479
+ }
480
+ const ret = wasm.decompressUsingDict(ptr0, len0, ptr1, len1, val3);
459
481
  if (ret[3]) {
460
482
  throw takeFromExternrefTable0(ret[2]);
461
483
  }
462
- var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
484
+ var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
463
485
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
464
- return v3;
486
+ return v4;
465
487
  }
466
488
  function __wbg_get_imports() {
467
489
  const import0 = {
468
490
  __proto__: null,
469
- __wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
491
+ __wbg_Error_208446807d0d1e30: function(arg0, arg1) {
470
492
  const ret = Error(getStringFromWasm0(arg0, arg1));
471
493
  return ret;
472
494
  },
473
- __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
495
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
474
496
  throw new Error(getStringFromWasm0(arg0, arg1));
475
497
  },
476
498
  __wbindgen_init_externref_table: function() {
477
499
  const table = wasm.__wbindgen_externrefs;
478
- const offset = table.grow(4);
479
500
  table.set(0, undefined);
480
- table.set(offset + 0, undefined);
481
- table.set(offset + 1, null);
482
- table.set(offset + 2, true);
483
- table.set(offset + 3, false);
501
+ table.set(1024, undefined);
502
+ table.set(1025, null);
503
+ table.set(1026, true);
504
+ table.set(1027, false);
484
505
  },
485
506
  };
486
507
  return {
@@ -511,7 +532,8 @@ function getArrayU8FromWasm0(ptr, len) {
511
532
  }
512
533
 
513
534
  function getStringFromWasm0(ptr, len) {
514
- return decodeText(ptr >>> 0, len);
535
+ ptr = ptr >>> 0;
536
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
515
537
  }
516
538
 
517
539
  let cachedUint8ArrayMemory0 = null;
@@ -539,18 +561,18 @@ function takeFromExternrefTable0(idx) {
539
561
  return value;
540
562
  }
541
563
 
542
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
564
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
543
565
  cachedTextDecoder.decode();
544
566
  const MAX_SAFARI_DECODE_BYTES = 2146435072;
545
567
  let numBytesDecoded = 0;
546
- function decodeText(ptr, len) {
547
- numBytesDecoded += len;
568
+ function decodeText(bytes) {
569
+ numBytesDecoded += bytes.length;
548
570
  if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
549
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
571
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
550
572
  cachedTextDecoder.decode();
551
- numBytesDecoded = len;
573
+ numBytesDecoded = bytes.length;
552
574
  }
553
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
575
+ return cachedTextDecoder.decode(bytes);
554
576
  }
555
577
 
556
578
  let WASM_VECTOR_LEN = 0;
@@ -624,9 +646,17 @@ function initSync(module) {
624
646
  return __wbg_finalize_init(instance, module);
625
647
  }
626
648
 
649
+ let __wbg_init_promise;
627
650
  async function __wbg_init(module_or_path) {
628
651
  if (wasm !== undefined) return wasm;
652
+ if (__wbg_init_promise === undefined) {
653
+ __wbg_init_promise = __wbg_init_once(module_or_path);
654
+ __wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
655
+ }
656
+ return __wbg_init_promise;
657
+ }
629
658
 
659
+ async function __wbg_init_once(module_or_path) {
630
660
 
631
661
  if (module_or_path !== undefined) {
632
662
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
Binary file
@@ -26,6 +26,6 @@ export const zstddictionary_id: (a: number) => number;
26
26
  export const zstddictionary_new: (a: number, b: number) => [number, number, number];
27
27
  export const __wbindgen_externrefs: WebAssembly.Table;
28
28
  export const __wbindgen_malloc: (a: number, b: number) => number;
29
- export const __externref_table_dealloc: (a: number) => void;
30
29
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
30
+ export const __externref_table_dealloc: (a: number) => void;
31
31
  export const __wbindgen_start: () => void;