@zip.js/zip.js 2.8.49 → 2.8.51

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.
@@ -108,6 +108,8 @@ const INFINITY_VALUE = Infinity;
108
108
  const UNDEFINED_TYPE = "undefined";
109
109
  const FUNCTION_TYPE = "function";
110
110
  const OBJECT_TYPE = "object";
111
+ const STRING_TYPE = "string";
112
+ const NUMBER_TYPE = "number";
111
113
 
112
114
  const EMPTY_UINT8_ARRAY = new Uint8Array();
113
115
 
@@ -273,7 +275,7 @@ function configureExternalAssets() {
273
275
  }
274
276
 
275
277
  /*
276
- Copyright (c) 2025 Gildas Lormeau. All rights reserved.
278
+ Copyright (c) 2026 Gildas Lormeau. All rights reserved.
277
279
 
278
280
  Redistribution and use in source and binary forms, with or without
279
281
  modification, are permitted provided that the following conditions are met:
@@ -301,72 +303,19 @@ function configureExternalAssets() {
301
303
  */
302
304
 
303
305
 
304
- const ERR_INVALID_CODEC_DEFINITION = "Invalid codec definition";
305
- const ERR_RESERVED_COMPRESSION_METHOD = "Reserved compression method";
306
- const ERR_INVALID_CODEC_MODULE = "Invalid codec module";
307
-
308
- const STRING_TYPE = "string";
309
- const RESERVED_COMPRESSION_METHODS = [
310
- COMPRESSION_METHOD_STORE,
311
- COMPRESSION_METHOD_DEFLATE,
312
- COMPRESSION_METHOD_DEFLATE_64,
313
- COMPRESSION_METHOD_AES
314
- ];
315
-
316
- const registeredCodecs = new Map();
317
- const codecStreams = new Map();
318
-
319
- function registerCodec(codec = {}) {
320
- const { compressionMethod, format, codecURI, CompressionStream, DecompressionStream, versionNeeded } = codec;
321
- if (!Number.isInteger(compressionMethod) || compressionMethod < 0 || compressionMethod > MAX_16_BITS ||
322
- typeof format != STRING_TYPE || !format.length) {
323
- throw new Error(ERR_INVALID_CODEC_DEFINITION);
324
- }
325
- if (RESERVED_COMPRESSION_METHODS.includes(compressionMethod)) {
326
- throw new Error(ERR_RESERVED_COMPRESSION_METHOD);
327
- }
328
- const hasStreams = typeof CompressionStream == FUNCTION_TYPE || typeof DecompressionStream == FUNCTION_TYPE;
329
- if (!hasStreams && (typeof codecURI != STRING_TYPE || !codecURI.length)) {
330
- throw new Error(ERR_INVALID_CODEC_DEFINITION);
331
- }
332
- registeredCodecs.set(compressionMethod, { compressionMethod, format, codecURI, versionNeeded });
333
- if (hasStreams) {
334
- setCodecStreams(format, { CompressionStream, DecompressionStream });
335
- }
336
- }
337
-
338
- function unregisterCodec(compressionMethod) {
339
- const codec = registeredCodecs.get(compressionMethod);
340
- if (codec) {
341
- registeredCodecs.delete(compressionMethod);
342
- let formatUsed;
343
- registeredCodecs.forEach(otherCodec => formatUsed = formatUsed || otherCodec.format == codec.format);
344
- if (!formatUsed) {
345
- codecStreams.delete(codec.format);
346
- }
347
- }
348
- }
349
-
350
- function getRegisteredCodec(compressionMethod) {
351
- return registeredCodecs.get(compressionMethod);
352
- }
353
-
354
- function getCodecStreams(format) {
355
- return codecStreams.get(format);
306
+ function concat(first, second) {
307
+ const result = new Uint8Array(first.length + second.length);
308
+ result.set(first);
309
+ result.set(second, first.length);
310
+ return result;
356
311
  }
357
312
 
358
- function setCodecStreams(format, streams) {
359
- const { CompressionStream, DecompressionStream } = streams;
360
- if (typeof CompressionStream != FUNCTION_TYPE && typeof DecompressionStream != FUNCTION_TYPE) {
361
- throw new Error(ERR_INVALID_CODEC_MODULE);
362
- }
363
- codecStreams.set(format, { CompressionStream, DecompressionStream });
313
+ function toExactUint8Array(array) {
314
+ return array.byteOffset || array.byteLength != array.buffer.byteLength ? new Uint8Array(array) : array;
364
315
  }
365
316
 
366
- async function ensureCodecStreams(format, codecURI) {
367
- if (!codecStreams.has(format) && codecURI) {
368
- setCodecStreams(format, await import(/* webpackIgnore: true */ /* @vite-ignore */ codecURI));
369
- }
317
+ function getDataView(array) {
318
+ return new DataView(array.buffer, array.byteOffset, array.byteLength);
370
319
  }
371
320
 
372
321
  /*
@@ -551,50 +500,6 @@ function encodeText(value) {
551
500
  }
552
501
  }
553
502
 
554
- /*
555
- Copyright (c) 2026 Gildas Lormeau. All rights reserved.
556
-
557
- Redistribution and use in source and binary forms, with or without
558
- modification, are permitted provided that the following conditions are met:
559
-
560
- 1. Redistributions of source code must retain the above copyright notice,
561
- this list of conditions and the following disclaimer.
562
-
563
- 2. Redistributions in binary form must reproduce the above copyright
564
- notice, this list of conditions and the following disclaimer in
565
- the documentation and/or other materials provided with the distribution.
566
-
567
- 3. The names of the authors may not be used to endorse or promote products
568
- derived from this software without specific prior written permission.
569
-
570
- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
571
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
572
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
573
- INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
574
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
575
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
576
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
577
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
578
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
579
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
580
- */
581
-
582
-
583
- function concat(first, second) {
584
- const result = new Uint8Array(first.length + second.length);
585
- result.set(first);
586
- result.set(second, first.length);
587
- return result;
588
- }
589
-
590
- function toExactUint8Array(array) {
591
- return array.byteOffset || array.byteLength != array.buffer.byteLength ? new Uint8Array(array) : array;
592
- }
593
-
594
- function getDataView(array) {
595
- return new DataView(array.buffer, array.byteOffset, array.byteLength);
596
- }
597
-
598
503
  // Derived from https://github.com/xqdoo00o/jszip/blob/master/lib/sjcl.js and https://github.com/bitwiseshiftleft/sjcl
599
504
 
600
505
  // deno-lint-ignore-file no-this-alias
@@ -1964,6 +1869,102 @@ function toCompatibleWritable(writable) {
1964
1869
  });
1965
1870
  }
1966
1871
 
1872
+ /*
1873
+ Copyright (c) 2025 Gildas Lormeau. All rights reserved.
1874
+
1875
+ Redistribution and use in source and binary forms, with or without
1876
+ modification, are permitted provided that the following conditions are met:
1877
+
1878
+ 1. Redistributions of source code must retain the above copyright notice,
1879
+ this list of conditions and the following disclaimer.
1880
+
1881
+ 2. Redistributions in binary form must reproduce the above copyright
1882
+ notice, this list of conditions and the following disclaimer in
1883
+ the documentation and/or other materials provided with the distribution.
1884
+
1885
+ 3. The names of the authors may not be used to endorse or promote products
1886
+ derived from this software without specific prior written permission.
1887
+
1888
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
1889
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
1890
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
1891
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
1892
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1893
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
1894
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
1895
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
1896
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
1897
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1898
+ */
1899
+
1900
+
1901
+ const ERR_INVALID_CODEC_DEFINITION = "Invalid codec definition";
1902
+ const ERR_RESERVED_COMPRESSION_METHOD = "Reserved compression method";
1903
+ const ERR_INVALID_CODEC_MODULE = "Invalid codec module";
1904
+
1905
+ const RESERVED_COMPRESSION_METHODS = [
1906
+ COMPRESSION_METHOD_STORE,
1907
+ COMPRESSION_METHOD_DEFLATE,
1908
+ COMPRESSION_METHOD_DEFLATE_64,
1909
+ COMPRESSION_METHOD_AES
1910
+ ];
1911
+
1912
+ const registeredCodecs = new Map();
1913
+ const codecStreams = new Map();
1914
+
1915
+ function registerCodec(codec = {}) {
1916
+ const { compressionMethod, format, codecURI, CompressionStream, DecompressionStream, versionNeeded } = codec;
1917
+ if (!Number.isInteger(compressionMethod) || compressionMethod < 0 || compressionMethod > MAX_16_BITS ||
1918
+ typeof format != STRING_TYPE || !format.length) {
1919
+ throw new Error(ERR_INVALID_CODEC_DEFINITION);
1920
+ }
1921
+ if (RESERVED_COMPRESSION_METHODS.includes(compressionMethod)) {
1922
+ throw new Error(ERR_RESERVED_COMPRESSION_METHOD);
1923
+ }
1924
+ const hasStreams = typeof CompressionStream == FUNCTION_TYPE || typeof DecompressionStream == FUNCTION_TYPE;
1925
+ if (!hasStreams && (typeof codecURI != STRING_TYPE || !codecURI.length)) {
1926
+ throw new Error(ERR_INVALID_CODEC_DEFINITION);
1927
+ }
1928
+ registeredCodecs.set(compressionMethod, { compressionMethod, format, codecURI, versionNeeded });
1929
+ if (hasStreams) {
1930
+ setCodecStreams(format, { CompressionStream, DecompressionStream });
1931
+ }
1932
+ }
1933
+
1934
+ function unregisterCodec(compressionMethod) {
1935
+ const codec = registeredCodecs.get(compressionMethod);
1936
+ if (codec) {
1937
+ registeredCodecs.delete(compressionMethod);
1938
+ let formatUsed;
1939
+ registeredCodecs.forEach(otherCodec => formatUsed = formatUsed || otherCodec.format == codec.format);
1940
+ if (!formatUsed) {
1941
+ codecStreams.delete(codec.format);
1942
+ }
1943
+ }
1944
+ }
1945
+
1946
+ function getRegisteredCodec(compressionMethod) {
1947
+ return registeredCodecs.get(compressionMethod);
1948
+ }
1949
+
1950
+ function getCodecStreams(format) {
1951
+ return codecStreams.get(format);
1952
+ }
1953
+
1954
+ function setCodecStreams(format, streams) {
1955
+ const { CompressionStream, DecompressionStream } = streams;
1956
+ if (typeof CompressionStream != FUNCTION_TYPE && typeof DecompressionStream != FUNCTION_TYPE) {
1957
+ throw new Error(ERR_INVALID_CODEC_MODULE);
1958
+ }
1959
+ codecStreams.set(format, { CompressionStream, DecompressionStream });
1960
+ }
1961
+
1962
+ async function ensureCodecStreams(format, codecURI) {
1963
+ if (!codecStreams.has(format) && codecURI) {
1964
+ setCodecStreams(format, await import(/* webpackIgnore: true */ /* @vite-ignore */ codecURI));
1965
+ }
1966
+ }
1967
+
1967
1968
  /*
1968
1969
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
1969
1970
 
@@ -2517,8 +2518,8 @@ class ChunkStream extends TransformStream {
2517
2518
  1. Redistributions of source code must retain the above copyright notice,
2518
2519
  this list of conditions and the following disclaimer.
2519
2520
 
2520
- 2. Redistributions in binary form must reproduce the above copyright
2521
- notice, this list of conditions and the following disclaimer in
2521
+ 2. Redistributions in binary form must reproduce the above copyright
2522
+ notice, this list of conditions and the following disclaimer in
2522
2523
  the documentation and/or other materials provided with the distribution.
2523
2524
 
2524
2525
  3. The names of the authors may not be used to endorse or promote products
@@ -2537,24 +2538,19 @@ class ChunkStream extends TransformStream {
2537
2538
  */
2538
2539
 
2539
2540
 
2540
- const MODULE_WORKER_OPTIONS = { type: "module" };
2541
- const ERROR_EVENT_TYPE = "error";
2542
- const MESSAGE_ERROR_EVENT_TYPE = "messageerror";
2543
2541
  const ERR_WORKER_STARTUP_TIMEOUT = "Worker startup timeout";
2544
2542
 
2545
- let webWorkerSupported, webWorkerSource, webWorkerURI, webWorkerOptions, createWorkerFailed;
2546
- let transferStreamsSupported = true;
2547
- try {
2548
- transferStreamsSupported = typeof structuredClone == FUNCTION_TYPE && structuredClone(new DOMException("", "AbortError")).code !== UNDEFINED_VALUE;
2549
- } catch {
2550
- // ignored
2551
- }
2543
+ let webWorkerSupported, createWorkerFailed, webWorkerBackend;
2552
2544
  let initModule$1 = () => { };
2553
2545
 
2554
2546
  function configureWorker({ initModule: initModuleFunction }) {
2555
2547
  initModule$1 = initModuleFunction;
2556
2548
  }
2557
2549
 
2550
+ function setWebWorkerBackend(backend) {
2551
+ webWorkerBackend = backend;
2552
+ }
2553
+
2558
2554
  async function supportsDeflate(config) {
2559
2555
  const { CompressionStream: NativeStream, CompressionStreamFallback: FallbackStream } = config;
2560
2556
  if (FallbackStream && !FallbackStream.requiresModule) {
@@ -2579,6 +2575,14 @@ function resetWebWorkerSupport() {
2579
2575
  createWorkerFailed = false;
2580
2576
  }
2581
2577
 
2578
+ function disableWebWorker(workerData) {
2579
+ if (workerData.createWorker) {
2580
+ createWorkerFailed = true;
2581
+ } else {
2582
+ webWorkerSupported = false;
2583
+ }
2584
+ }
2585
+
2582
2586
  class CodecWorker {
2583
2587
 
2584
2588
  constructor(workerData, { readable, writable }, { options, config, streamOptions, useWebWorkers, transferStreams, workerURI, createWorker }, onTaskFinished) {
@@ -2631,7 +2635,7 @@ class CodecWorker {
2631
2635
  // deno-lint-ignore valid-typeof
2632
2636
  webWorkerSupported = typeof Worker != UNDEFINED_TYPE;
2633
2637
  }
2634
- return (useWebWorkers && ((webWorkerSupported && workerURI) || createWorker) ? createWebWorkerInterface : createWorkerInterface)(workerData, config);
2638
+ return (useWebWorkers && webWorkerBackend && ((webWorkerSupported && workerURI) || createWorker) ? webWorkerBackend : createWorkerInterface)(workerData, config);
2635
2639
  }
2636
2640
  }
2637
2641
 
@@ -2648,85 +2652,31 @@ class ProgressWatcherStream extends TransformStream {
2648
2652
  async transform(chunk, controller) {
2649
2653
  chunkOffset += chunk.length;
2650
2654
  if (onprogress) {
2651
- await callHandler(onprogress, chunkOffset, size);
2652
- }
2653
- controller.enqueue(chunk);
2654
- },
2655
- async flush() {
2656
- if (onend) {
2657
- await callHandler(onend, chunkOffset);
2658
- }
2659
- }
2660
- });
2661
- }
2662
- }
2663
-
2664
- async function callHandler(handler, ...parameters) {
2665
- try {
2666
- await handler(...parameters);
2667
- } catch {
2668
- // ignored
2669
- }
2670
- }
2671
-
2672
- function createWorkerInterface(workerData, config) {
2673
- return {
2674
- run: () => runWorker$1(workerData, config)
2675
- };
2676
- }
2677
-
2678
- function createWebWorkerInterface(workerData, config) {
2679
- const { baseURI, chunkSize, workerStartupTimeout } = config;
2680
- let { wasmURI } = config;
2681
-
2682
- if (!workerData.interface) {
2683
- // deno-lint-ignore valid-typeof
2684
- if (typeof wasmURI == FUNCTION_TYPE) {
2685
- wasmURI = wasmURI();
2686
- }
2687
- let worker;
2688
- try {
2689
- worker = getWebWorker(workerData.workerURI, baseURI, workerData);
2690
- } catch {
2691
- if (workerData.createWorker) {
2692
- createWorkerFailed = true;
2693
- } else {
2694
- webWorkerSupported = false;
2695
- }
2696
- return createWorkerInterface(workerData, config);
2697
- }
2698
- Object.assign(workerData, {
2699
- worker,
2700
- workerAlive: false,
2701
- terminated: false,
2702
- interface: {
2703
- run: async () => {
2704
- try {
2705
- return await runWebWorker(workerData, { chunkSize, wasmURI, baseURI, workerStartupTimeout });
2706
- } catch (error) {
2707
- if (error && error.workerStartupFailed) {
2708
- if (workerData.createWorker) {
2709
- createWorkerFailed = true;
2710
- } else {
2711
- webWorkerSupported = false;
2712
- }
2713
- releaseWorkerStreams(workerData);
2714
- return runWorker$1(workerData, config);
2715
- }
2716
- if (error && error.codecImportFailed) {
2717
- if (workerData.reader) {
2718
- releaseWorkerStreams(workerData);
2719
- return runWorker$1(workerData, config);
2720
- }
2721
- workerData.onTaskFinished();
2722
- }
2723
- throw error;
2724
- }
2655
+ await callHandler(onprogress, chunkOffset, size);
2656
+ }
2657
+ controller.enqueue(chunk);
2658
+ },
2659
+ async flush() {
2660
+ if (onend) {
2661
+ await callHandler(onend, chunkOffset);
2725
2662
  }
2726
2663
  }
2727
2664
  });
2728
2665
  }
2729
- return workerData.interface;
2666
+ }
2667
+
2668
+ async function callHandler(handler, ...parameters) {
2669
+ try {
2670
+ await handler(...parameters);
2671
+ } catch {
2672
+ // ignored
2673
+ }
2674
+ }
2675
+
2676
+ function createWorkerInterface(workerData, config) {
2677
+ return {
2678
+ run: () => runWorker$1(workerData, config)
2679
+ };
2730
2680
  }
2731
2681
 
2732
2682
  async function runWorker$1({ options, readable, writable, onTaskFinished }, config) {
@@ -2777,6 +2727,95 @@ async function runWorker$1({ options, readable, writable, onTaskFinished }, conf
2777
2727
  }
2778
2728
  }
2779
2729
 
2730
+ /*
2731
+ Copyright (c) 2025 Gildas Lormeau. All rights reserved.
2732
+
2733
+ Redistribution and use in source and binary forms, with or without
2734
+ modification, are permitted provided that the following conditions are met:
2735
+
2736
+ 1. Redistributions of source code must retain the above copyright notice,
2737
+ this list of conditions and the following disclaimer.
2738
+
2739
+ 2. Redistributions in binary form must reproduce the above copyright
2740
+ notice, this list of conditions and the following disclaimer in
2741
+ the documentation and/or other materials provided with the distribution.
2742
+
2743
+ 3. The names of the authors may not be used to endorse or promote products
2744
+ derived from this software without specific prior written permission.
2745
+
2746
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
2747
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
2748
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
2749
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
2750
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2751
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
2752
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
2753
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2754
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
2755
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2756
+ */
2757
+
2758
+
2759
+ const MODULE_WORKER_OPTIONS = { type: "module" };
2760
+ const ERROR_EVENT_TYPE = "error";
2761
+ const MESSAGE_ERROR_EVENT_TYPE = "messageerror";
2762
+
2763
+ let webWorkerSource, webWorkerURI, webWorkerOptions;
2764
+ let transferStreamsSupported = true;
2765
+ try {
2766
+ transferStreamsSupported = typeof structuredClone == FUNCTION_TYPE && structuredClone(new DOMException("", "AbortError")).code !== UNDEFINED_VALUE;
2767
+ } catch {
2768
+ // ignored
2769
+ }
2770
+
2771
+ setWebWorkerBackend(createWebWorkerInterface);
2772
+
2773
+ function createWebWorkerInterface(workerData, config) {
2774
+ const { baseURI, chunkSize, workerStartupTimeout } = config;
2775
+ let { wasmURI } = config;
2776
+
2777
+ if (!workerData.interface) {
2778
+ // deno-lint-ignore valid-typeof
2779
+ if (typeof wasmURI == FUNCTION_TYPE) {
2780
+ wasmURI = wasmURI();
2781
+ }
2782
+ let worker;
2783
+ try {
2784
+ worker = getWebWorker(workerData.workerURI, baseURI, workerData);
2785
+ } catch {
2786
+ disableWebWorker(workerData);
2787
+ return createWorkerInterface(workerData, config);
2788
+ }
2789
+ Object.assign(workerData, {
2790
+ worker,
2791
+ workerAlive: false,
2792
+ terminated: false,
2793
+ interface: {
2794
+ run: async () => {
2795
+ try {
2796
+ return await runWebWorker(workerData, { chunkSize, wasmURI, baseURI, workerStartupTimeout });
2797
+ } catch (error) {
2798
+ if (error && error.workerStartupFailed) {
2799
+ disableWebWorker(workerData);
2800
+ releaseWorkerStreams(workerData);
2801
+ return runWorker$1(workerData, config);
2802
+ }
2803
+ if (error && error.codecImportFailed) {
2804
+ if (workerData.reader) {
2805
+ releaseWorkerStreams(workerData);
2806
+ return runWorker$1(workerData, config);
2807
+ }
2808
+ workerData.onTaskFinished();
2809
+ }
2810
+ throw error;
2811
+ }
2812
+ }
2813
+ }
2814
+ });
2815
+ }
2816
+ return workerData.interface;
2817
+ }
2818
+
2780
2819
  async function runWebWorker(workerData, config) {
2781
2820
  let resolveResult, rejectResult;
2782
2821
  const result = new Promise((resolve, reject) => {
@@ -3653,7 +3692,7 @@ async function initHttpReader(httpReader, sendRequest, getRequestData) {
3653
3692
  forceRangeRequests,
3654
3693
  combineSizeEocd
3655
3694
  } = httpReader;
3656
- if (isHttpFamily(url) && (useRangeHeader || forceRangeRequests) && (typeof preventHeadRequest == "undefined" || preventHeadRequest)) {
3695
+ if (isHttpFamily(url) && (useRangeHeader || forceRangeRequests) && (typeof preventHeadRequest == UNDEFINED_TYPE || preventHeadRequest)) {
3657
3696
  const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, combineSizeEocd ? -END_OF_CENTRAL_DIR_LENGTH : undefined));
3658
3697
  const acceptRanges = response.headers.get(HTTP_HEADER_ACCEPT_RANGES);
3659
3698
  if (!forceRangeRequests && (!acceptRanges || acceptRanges.toLowerCase() != HTTP_RANGE_UNIT)) {
@@ -4506,9 +4545,13 @@ const OPTION_USDZ = "usdz";
4506
4545
  const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
4507
4546
  const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
4508
4547
  const OPTION_STRICTNESS = "strictness";
4548
+ const OPTION_FILENAME_VALIDATION = "filenameValidation";
4549
+ const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
4509
4550
  const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
4510
4551
  const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
4511
4552
  const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
4553
+ const TEXT_TYPE_FILENAME = "filename";
4554
+ const TEXT_TYPE_COMMENT = "comment";
4512
4555
  const STRICTNESS_STRICT = "strict";
4513
4556
  const STRICTNESS_BALANCED = "balanced";
4514
4557
  const STRICTNESS_TOLERANT = "tolerant";
@@ -4555,6 +4598,11 @@ const ERR_SPLIT_ZIP_FILE = "Split zip file";
4555
4598
  const ERR_OVERLAPPING_ENTRY = "Overlapping entry found";
4556
4599
  const ERR_AMBIGUOUS_ARCHIVE = "Ambiguous archive";
4557
4600
  const ERR_ENCRYPTED_CENTRAL_DIRECTORY = "Encrypted central directory is not supported";
4601
+ const ERR_UNSAFE_FILENAME = "Unsafe filename";
4602
+ const ERR_INVALID_STRICTNESS = "Invalid strictness (must be 'strict', 'balanced' or 'tolerant')";
4603
+ const ERR_INVALID_FILENAME_VALIDATION = "Invalid filenameValidation (must be 'strict', 'balanced' or 'tolerant')";
4604
+ const ERR_INVALID_MAX_APPENDED_DATA_SIZE = "Invalid maxAppendedDataSize (must be a number greater than or equal to 0)";
4605
+ const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
4558
4606
  const CHARSET_UTF8 = "utf-8";
4559
4607
  const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
4560
4608
  const CHARSET_CP437 = "cp437";
@@ -4576,6 +4624,10 @@ const ZIP64_EXTRACTION = {
4576
4624
  bytes: 8
4577
4625
  }
4578
4626
  };
4627
+ const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
4628
+ const CENTRAL_DIRECTORY_UNREACHABLE = 0;
4629
+ const CENTRAL_DIRECTORY_PLAUSIBLE = 1;
4630
+ const CENTRAL_DIRECTORY_REACHABLE = 2;
4579
4631
 
4580
4632
  class ZipReader {
4581
4633
 
@@ -4604,6 +4656,8 @@ class ZipReader {
4604
4656
  const checkAmbiguity = strictness == STRICTNESS_STRICT;
4605
4657
  const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
4606
4658
  const maxAppendedDataSize = getMaxAppendedDataSize(getOptionValue$1(zipReader, options, OPTION_MAX_APPENDED_DATA_SIZE), strictness);
4659
+ const filenameValidation = getFilenameValidation(getOptionValue$1(zipReader, options, OPTION_FILENAME_VALIDATION), strictness);
4660
+ const normalizeFilename = getOptionValue$1(zipReader, options, OPTION_NORMALIZE_FILENAME);
4607
4661
  const { endOfDirectoryInfo, endOfDirectoryReachingEndCount } = await findEndOfCentralDirectory(reader, rejectAmbiguousEndOfDirectory, maxAppendedDataSize);
4608
4662
  if (!endOfDirectoryInfo) {
4609
4663
  const signatureArray = await readUint8Array(reader, 0, 4);
@@ -4797,11 +4851,22 @@ class ZipReader {
4797
4851
  const decode = getOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
4798
4852
  const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
4799
4853
  const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
4800
- let filename = decode(rawFilename, rawFilenameEncoding);
4854
+ let filename = decode(rawFilename, rawFilenameEncoding, TEXT_TYPE_FILENAME);
4801
4855
  if (filename === UNDEFINED_VALUE) {
4802
4856
  filename = decodeText(rawFilename, rawFilenameEncoding);
4803
4857
  }
4804
- let comment = decode(rawComment, rawCommentEncoding);
4858
+ if (normalizeFilename) {
4859
+ const normalizedFilename = normalizeFilename(filename);
4860
+ if (normalizedFilename !== UNDEFINED_VALUE) {
4861
+ filename = normalizedFilename;
4862
+ }
4863
+ }
4864
+ if (isUnsafeFilename(filename, filenameValidation)) {
4865
+ const error = new Error(ERR_UNSAFE_FILENAME);
4866
+ error.filename = filename;
4867
+ throw error;
4868
+ }
4869
+ let comment = decode(rawComment, rawCommentEncoding, TEXT_TYPE_COMMENT);
4805
4870
  if (comment === UNDEFINED_VALUE) {
4806
4871
  comment = decodeText(rawComment, rawCommentEncoding);
4807
4872
  }
@@ -4862,10 +4927,10 @@ class ZipReader {
4862
4927
  entry.getData = (writer, options) => fileEntry.getData(writer, entry, zipReader.readRanges, options);
4863
4928
  entry.arrayBuffer = async options => {
4864
4929
  const writer = new TransformStream();
4865
- const [arrayBuffer] = await Promise.all([
4866
- streamToBlob(writer.readable).then(blob => blob.arrayBuffer()),
4867
- fileEntry.getData(writer, entry, zipReader.readRanges, options)]);
4868
- return arrayBuffer;
4930
+ const arrayBufferPromise = streamToBlob(writer.readable).then(blob => blob.arrayBuffer());
4931
+ arrayBufferPromise.catch(() => { });
4932
+ await fileEntry.getData(writer, entry, zipReader.readRanges, options);
4933
+ return arrayBufferPromise;
4869
4934
  };
4870
4935
  offset = endOffset;
4871
4936
  const { onprogress } = options;
@@ -5116,7 +5181,7 @@ let ZipEntry$1 = class ZipEntry {
5116
5181
  readRanges
5117
5182
  });
5118
5183
  }
5119
- let writable;
5184
+ let writable, abortError;
5120
5185
  try {
5121
5186
  if (!checkOverlappingEntryOnly) {
5122
5187
  if (checkPasswordOnly) {
@@ -5136,12 +5201,22 @@ let ZipEntry$1 = class ZipEntry {
5136
5201
  writer.size += error.outputSize;
5137
5202
  }
5138
5203
  if (!checkPasswordOnly || error.message != ERR_ABORT_CHECK_PASSWORD) {
5204
+ abortError = error;
5139
5205
  throw error;
5140
5206
  }
5141
5207
  } finally {
5142
5208
  const preventClose = getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
5143
5209
  if (!preventClose && writable && !writable.locked) {
5144
- await writable.getWriter().close();
5210
+ const writableWriter = writable.getWriter();
5211
+ if (abortError) {
5212
+ try {
5213
+ await writableWriter.abort(abortError);
5214
+ } catch {
5215
+ // the error being propagated is more relevant; ignored
5216
+ }
5217
+ } else {
5218
+ await writableWriter.close();
5219
+ }
5145
5220
  }
5146
5221
  }
5147
5222
  return checkPasswordOnly || checkOverlappingEntryOnly ? UNDEFINED_VALUE : writer.getData ? writer.getData() : writable;
@@ -5521,16 +5596,51 @@ function getDiskOffset$1(reader, diskNumber) {
5521
5596
  return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
5522
5597
  }
5523
5598
 
5599
+ function isStrictnessValue(value) {
5600
+ return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
5601
+ }
5602
+
5524
5603
  function getStrictness(strictness, checkAmbiguity) {
5525
5604
  if (strictness === UNDEFINED_VALUE) {
5526
5605
  return checkAmbiguity ? STRICTNESS_STRICT : STRICTNESS_BALANCED;
5527
5606
  }
5607
+ if (!isStrictnessValue(strictness)) {
5608
+ throw new Error(ERR_INVALID_STRICTNESS);
5609
+ }
5528
5610
  return strictness;
5529
5611
  }
5530
5612
 
5613
+ function getFilenameValidation(filenameValidation, strictness) {
5614
+ if (filenameValidation === UNDEFINED_VALUE) {
5615
+ return strictness;
5616
+ }
5617
+ if (!isStrictnessValue(filenameValidation)) {
5618
+ throw new Error(ERR_INVALID_FILENAME_VALIDATION);
5619
+ }
5620
+ return filenameValidation;
5621
+ }
5622
+
5623
+ function isUnsafeFilename(filename, filenameValidation) {
5624
+ if (filenameValidation == STRICTNESS_TOLERANT) {
5625
+ return false;
5626
+ }
5627
+ const pathParts = filename.split("/");
5628
+ if (pathParts.length > 1 && pathParts[pathParts.length - 1] === "") {
5629
+ pathParts.pop();
5630
+ }
5631
+ if (pathParts.includes("..") || filename.startsWith("/") || filename.startsWith("\\\\") || DRIVE_LETTER_REGEXP.test(filename)) {
5632
+ return true;
5633
+ }
5634
+ return filenameValidation == STRICTNESS_STRICT && (pathParts.includes(".") || pathParts.includes(""));
5635
+ }
5636
+
5531
5637
  function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
5532
5638
  if (maxAppendedDataSize !== UNDEFINED_VALUE) {
5533
- return maxAppendedDataSize;
5639
+ const size = toNumber$1(maxAppendedDataSize);
5640
+ if (typeof size != NUMBER_TYPE || Number.isNaN(size) || size < 0) {
5641
+ throw new Error(ERR_INVALID_MAX_APPENDED_DATA_SIZE);
5642
+ }
5643
+ return size;
5534
5644
  }
5535
5645
  if (strictness == STRICTNESS_STRICT) {
5536
5646
  return 0;
@@ -5541,12 +5651,6 @@ function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
5541
5651
  return MAX_16_BITS;
5542
5652
  }
5543
5653
 
5544
- const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
5545
-
5546
- const CENTRAL_DIRECTORY_UNREACHABLE = 0;
5547
- const CENTRAL_DIRECTORY_PLAUSIBLE = 1;
5548
- const CENTRAL_DIRECTORY_REACHABLE = 2;
5549
-
5550
5654
  async function findEndOfCentralDirectory(reader, rejectAmbiguous, maxAppendedDataSize) {
5551
5655
  const { size } = reader;
5552
5656
  const anchoredLength = Math.min(size, END_OF_CENTRAL_DIR_LENGTH + MAX_16_BITS);
@@ -5682,6 +5786,10 @@ function getOptionValue$1(zipReader, options, name) {
5682
5786
  return options[name] === UNDEFINED_VALUE ? zipReader.options[name] : options[name];
5683
5787
  }
5684
5788
 
5789
+ function toNumber$1(value) {
5790
+ return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
5791
+ }
5792
+
5685
5793
  function getDate(timeRaw) {
5686
5794
  const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS;
5687
5795
  return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
@@ -5720,12 +5828,16 @@ var zipReader = /*#__PURE__*/Object.freeze({
5720
5828
  ERR_INVALID_AUTHENTICATION_CODE: ERR_INVALID_AUTHENTICATION_CODE,
5721
5829
  ERR_INVALID_COMPRESSED_DATA: ERR_INVALID_COMPRESSED_DATA,
5722
5830
  ERR_INVALID_CRC32: ERR_INVALID_CRC32,
5831
+ ERR_INVALID_FILENAME_VALIDATION: ERR_INVALID_FILENAME_VALIDATION,
5832
+ ERR_INVALID_MAX_APPENDED_DATA_SIZE: ERR_INVALID_MAX_APPENDED_DATA_SIZE,
5723
5833
  ERR_INVALID_PASSWORD: ERR_INVALID_PASSWORD,
5724
5834
  ERR_INVALID_SIGNATURE: ERR_INVALID_SIGNATURE,
5835
+ ERR_INVALID_STRICTNESS: ERR_INVALID_STRICTNESS,
5725
5836
  ERR_INVALID_UNCOMPRESSED_SIZE: ERR_INVALID_UNCOMPRESSED_SIZE,
5726
5837
  ERR_LOCAL_FILE_HEADER_NOT_FOUND: ERR_LOCAL_FILE_HEADER_NOT_FOUND,
5727
5838
  ERR_OVERLAPPING_ENTRY: ERR_OVERLAPPING_ENTRY,
5728
5839
  ERR_SPLIT_ZIP_FILE: ERR_SPLIT_ZIP_FILE,
5840
+ ERR_UNSAFE_FILENAME: ERR_UNSAFE_FILENAME,
5729
5841
  ERR_UNSUPPORTED_COMPRESSION: ERR_UNSUPPORTED_COMPRESSION$1,
5730
5842
  ERR_UNSUPPORTED_ENCRYPTION: ERR_UNSUPPORTED_ENCRYPTION,
5731
5843
  ERR_WORKER_STARTUP_TIMEOUT: ERR_WORKER_STARTUP_TIMEOUT,
@@ -5787,6 +5899,8 @@ const ERR_INVALID_UNIX_EXTRA_FIELD_TYPE = "Invalid unixExtraFieldType (must be '
5787
5899
  const ERR_INVALID_UNIX_ID_SIZE = "uid/gid must be 0..65535 for unixExtraFieldType 'unix' (use 'infozip' for larger ids)";
5788
5900
  const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be integer 0..255)";
5789
5901
  const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
5902
+ const ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
5903
+ const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
5790
5904
  const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
5791
5905
 
5792
5906
  const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
@@ -5794,6 +5908,7 @@ const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
5794
5908
  const VENDOR_VERSION_AE_1 = 1;
5795
5909
  const INFOZIP_EXTRA_FIELD_TYPE$1 = "infozip";
5796
5910
  const UNIX_EXTRA_FIELD_TYPE = "unix";
5911
+ const MAX_LEVEL = 9;
5797
5912
 
5798
5913
  let workers = 0;
5799
5914
  const pendingEntries = [];
@@ -5956,7 +6071,8 @@ class ZipWriter {
5956
6071
 
5957
6072
  remove(entry) {
5958
6073
  const { filenames, files } = this;
5959
- if (typeof entry == "string") {
6074
+ // deno-lint-ignore valid-typeof
6075
+ if (typeof entry == STRING_TYPE) {
5960
6076
  entry = files.get(entry);
5961
6077
  }
5962
6078
  if (entry && entry.filename !== UNDEFINED_VALUE) {
@@ -6094,20 +6210,20 @@ function resolveAttributes(zipWriter, name, options) {
6094
6210
  let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
6095
6211
  let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? 20 : 768);
6096
6212
  const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
6097
- const uid = getOptionValue(zipWriter, options, PROPERTY_NAME_UID);
6098
- const gid = getOptionValue(zipWriter, options, PROPERTY_NAME_GID);
6099
- let unixMode = getOptionValue(zipWriter, options, PROPERTY_NAME_UNIX_MODE);
6213
+ const uid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_UID);
6214
+ const gid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_GID);
6215
+ let unixMode = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_UNIX_MODE);
6100
6216
  let unixExtraFieldType = getOptionValue(zipWriter, options, OPTION_UNIX_EXTRA_FIELD_TYPE);
6101
6217
  let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
6102
6218
  let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
6103
6219
  let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
6104
- if (uid !== UNDEFINED_VALUE && (uid < 0 || uid > MAX_32_BITS)) {
6220
+ if (uid !== UNDEFINED_VALUE && (!Number.isInteger(uid) || uid < 0 || uid > MAX_32_BITS)) {
6105
6221
  throw new Error(ERR_INVALID_UID);
6106
6222
  }
6107
- if (gid !== UNDEFINED_VALUE && (gid < 0 || gid > MAX_32_BITS)) {
6223
+ if (gid !== UNDEFINED_VALUE && (!Number.isInteger(gid) || gid < 0 || gid > MAX_32_BITS)) {
6108
6224
  throw new Error(ERR_INVALID_GID);
6109
6225
  }
6110
- if (unixMode !== UNDEFINED_VALUE && (unixMode < 0 || unixMode > MAX_16_BITS)) {
6226
+ if (unixMode !== UNDEFINED_VALUE && (!Number.isInteger(unixMode) || unixMode < 0 || unixMode > MAX_16_BITS)) {
6111
6227
  throw new Error(ERR_INVALID_UNIX_MODE);
6112
6228
  }
6113
6229
  if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE$1 && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
@@ -6219,7 +6335,7 @@ function resolveAttributes(zipWriter, name, options) {
6219
6335
 
6220
6336
  function resolveMetadata(zipWriter, name, options) {
6221
6337
  const encode = getOptionValue(zipWriter, options, OPTION_ENCODE_TEXT, encodeText);
6222
- let rawFilename = encode(name);
6338
+ let rawFilename = encode(name, TEXT_TYPE_FILENAME);
6223
6339
  if (rawFilename === UNDEFINED_VALUE) {
6224
6340
  rawFilename = encodeText(name);
6225
6341
  }
@@ -6227,7 +6343,7 @@ function resolveMetadata(zipWriter, name, options) {
6227
6343
  throw new Error(ERR_INVALID_ENTRY_NAME);
6228
6344
  }
6229
6345
  const comment = options[PROPERTY_NAME_COMMENT] || "";
6230
- let rawComment = encode(comment);
6346
+ let rawComment = encode(comment, TEXT_TYPE_COMMENT);
6231
6347
  if (rawComment === UNDEFINED_VALUE) {
6232
6348
  rawComment = encodeText(comment);
6233
6349
  }
@@ -6247,8 +6363,11 @@ function resolveMetadata(zipWriter, name, options) {
6247
6363
  if (!passThrough) {
6248
6364
  password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
6249
6365
  rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
6366
+ if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
6367
+ throw new Error(ERR_INVALID_PASSWORD_TYPE);
6368
+ }
6250
6369
  }
6251
- const encryptionStrength = getOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
6370
+ const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
6252
6371
  const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
6253
6372
  const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
6254
6373
  const ntfsTimestamp = getOptionValue(zipWriter, options, OPTION_NTFS_TIMESTAMP);
@@ -6266,7 +6385,10 @@ function resolveMetadata(zipWriter, name, options) {
6266
6385
  compressionMethod !== COMPRESSION_METHOD_STORE && compressionMethod !== COMPRESSION_METHOD_DEFLATE && !registeredCodec) {
6267
6386
  throw new Error(ERR_UNSUPPORTED_COMPRESSION);
6268
6387
  }
6269
- let level = getOptionValue(zipWriter, options, OPTION_LEVEL);
6388
+ let level = getNumberOptionValue(zipWriter, options, OPTION_LEVEL);
6389
+ if (level !== UNDEFINED_VALUE && (!Number.isInteger(level) || level < 0 || level > MAX_LEVEL)) {
6390
+ throw new Error(ERR_INVALID_LEVEL);
6391
+ }
6270
6392
  if (zipWriter.options[OPTION_USDZ]) {
6271
6393
  if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
6272
6394
  throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
@@ -6287,7 +6409,7 @@ function resolveMetadata(zipWriter, name, options) {
6287
6409
  useCompressionStream = false;
6288
6410
  }
6289
6411
  const zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
6290
- if (!zipCrypto && (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && !(encryptionStrength >= 1 && encryptionStrength <= 3)) {
6412
+ if (!zipCrypto && (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && !(Number.isInteger(encryptionStrength) && encryptionStrength >= 1 && encryptionStrength <= 3)) {
6291
6413
  throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
6292
6414
  }
6293
6415
  const rawExtraField = serializeExtraField(options[PROPERTY_NAME_EXTRA_FIELD]);
@@ -7481,6 +7603,14 @@ function getOptionValue(zipWriter, options, name, defaultValue) {
7481
7603
  return result === UNDEFINED_VALUE ? defaultValue : result;
7482
7604
  }
7483
7605
 
7606
+ function getNumberOptionValue(zipWriter, options, name, defaultValue) {
7607
+ return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
7608
+ }
7609
+
7610
+ function toNumber(value) {
7611
+ return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
7612
+ }
7613
+
7484
7614
  function getMaximumCompressedSize(uncompressedSize) {
7485
7615
  return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
7486
7616
  }
@@ -8470,6 +8600,9 @@ configureExternalAssets();
8470
8600
 
8471
8601
  const ERR_ENTRY_EXISTS = "Entry filename already exists";
8472
8602
  const ERR_READABLE_CONSUMED = "Readable stream already consumed";
8603
+ const ERR_ABORT_EXPORT = "zipjs-abort-export";
8604
+ const ERR_ABORTED = "The operation was aborted";
8605
+ const ABORT_ERROR_NAME = "AbortError";
8473
8606
  const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
8474
8607
  const INTERPRETED_EXTRA_FIELD_TYPES = new Set([
8475
8608
  EXTRAFIELD_TYPE_ZIP64,
@@ -8578,8 +8711,9 @@ class ZipFileEntry extends ZipEntry {
8578
8711
  const uncompressedSize = zipEntry.data ? zipEntry.data.uncompressedSize : reader.size;
8579
8712
  await Promise.all([initStream(reader), initStream(writer, uncompressedSize)]);
8580
8713
  const { readable } = reader;
8714
+ const { signal } = options;
8581
8715
  zipEntry.uncompressedSize = reader.size;
8582
- await toCompatibleReadable(readable).pipeTo(toCompatibleWritable(writer.writable));
8716
+ await toCompatibleReadable(readable).pipeTo(toCompatibleWritable(writer.writable), { signal });
8583
8717
  return writer.getData ? writer.getData() : writer.writable;
8584
8718
  }
8585
8719
  }
@@ -8846,7 +8980,7 @@ class ZipDirectoryEntry extends ZipEntry {
8846
8980
  for (const entry of entries) {
8847
8981
  let parent = this;
8848
8982
  try {
8849
- const path = entry.filename.split("/");
8983
+ const path = entry.filename.split("/").filter(pathPart => pathPart != "" && pathPart != ".");
8850
8984
  const name = path.pop();
8851
8985
  path.forEach(pathPart => {
8852
8986
  const previousParent = parent;
@@ -8921,6 +9055,10 @@ class ZipDirectoryEntry extends ZipEntry {
8921
9055
  }
8922
9056
  }
8923
9057
 
9058
+ getChildren(options = {}) {
9059
+ return collectChildren(this, options.recursive);
9060
+ }
9061
+
8924
9062
  isPasswordProtected() {
8925
9063
  const children = this.children;
8926
9064
  for (let childIndex = 0; childIndex < children.length; childIndex++) {
@@ -9012,6 +9150,10 @@ class FS {
9012
9150
  return this.root.getChildByName(name);
9013
9151
  }
9014
9152
 
9153
+ getChildren(options) {
9154
+ return this.root.getChildren(options);
9155
+ }
9156
+
9015
9157
  addDirectory(name, options) {
9016
9158
  return this.root.addDirectory(name, options);
9017
9159
  }
@@ -9221,6 +9363,39 @@ function detach(entry) {
9221
9363
  }
9222
9364
  }
9223
9365
 
9366
+ function forwardAbort(signal, abortController) {
9367
+ if (!signal) {
9368
+ return () => { };
9369
+ }
9370
+ if (signal.aborted) {
9371
+ abortController.abort(signal.reason);
9372
+ return () => { };
9373
+ }
9374
+ const abort = () => abortController.abort(signal.reason);
9375
+ signal.addEventListener("abort", abort, { once: true });
9376
+ return () => signal.removeEventListener("abort", abort);
9377
+ }
9378
+
9379
+ function isExportAborted(error) {
9380
+ return Boolean(error) && error.message == ERR_ABORT_EXPORT;
9381
+ }
9382
+
9383
+ function aggregateEntryErrors(errors) {
9384
+ const [error] = errors;
9385
+ const otherErrors = errors
9386
+ .slice(1)
9387
+ .flatMap(otherError => [otherError, ...(otherError && otherError.entryErrors || [])])
9388
+ .filter(otherError => otherError !== error);
9389
+ if (otherErrors.length) {
9390
+ try {
9391
+ error.entryErrors = [...(error.entryErrors || []), ...otherErrors];
9392
+ } catch {
9393
+ // ignored
9394
+ }
9395
+ }
9396
+ return error;
9397
+ }
9398
+
9224
9399
  function getUserExtraField(extraField) {
9225
9400
  if (extraField) {
9226
9401
  const userExtraField = new Map();
@@ -9238,111 +9413,110 @@ function getUserExtraField(extraField) {
9238
9413
  async function exportZip(zipWriter, entry, totalSize, options, readers) {
9239
9414
  const selectedEntry = entry;
9240
9415
  const entryOffsets = new Map();
9241
- await process(zipWriter, entry);
9416
+ if (options.bufferedWrite) {
9417
+ await processChildren(entry);
9418
+ } else {
9419
+ for (const child of entry.getChildren({ recursive: true })) {
9420
+ await addChild(child);
9421
+ }
9422
+ }
9242
9423
 
9243
- async function process(zipWriter, entry) {
9244
- await exportChild();
9424
+ async function processChildren(entry) {
9425
+ const results = await Promise.allSettled(entry.children.map(async child => {
9426
+ await addChild(child);
9427
+ await processChildren(child);
9428
+ }));
9429
+ const errorResult = results.find(result => result.status == "rejected");
9430
+ if (errorResult) {
9431
+ throw errorResult.reason;
9432
+ }
9433
+ }
9245
9434
 
9246
- async function exportChild() {
9247
- if (options.bufferedWrite) {
9248
- const results = await Promise.allSettled(entry.children.map(processChild));
9249
- const errorResult = results.find(result => result.status == "rejected");
9250
- if (errorResult) {
9251
- throw errorResult.reason;
9435
+ async function addChild(child) {
9436
+ const name = options.relativePath ? child.getRelativeName(selectedEntry) : child.getFullname();
9437
+ const childOptions = child.options || {};
9438
+ let zipEntryOptions = {};
9439
+ if (child.data instanceof Entry) {
9440
+ const {
9441
+ externalFileAttributes,
9442
+ versionMadeBy,
9443
+ comment,
9444
+ lastModDate,
9445
+ creationDate,
9446
+ lastAccessDate,
9447
+ uncompressedSize,
9448
+ encrypted,
9449
+ zipCrypto,
9450
+ crc32,
9451
+ compressionMethod,
9452
+ extraFieldAES,
9453
+ internalFileAttributes,
9454
+ extraField,
9455
+ uid,
9456
+ gid
9457
+ } = child.data;
9458
+ zipEntryOptions = {
9459
+ externalFileAttributes,
9460
+ versionMadeBy,
9461
+ comment,
9462
+ lastModDate,
9463
+ creationDate,
9464
+ lastAccessDate,
9465
+ internalFileAttributes
9466
+ };
9467
+ const userExtraField = getUserExtraField(extraField);
9468
+ if (userExtraField) {
9469
+ zipEntryOptions.extraField = userExtraField;
9470
+ }
9471
+ if (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE) {
9472
+ Object.assign(zipEntryOptions, {
9473
+ uid,
9474
+ gid,
9475
+ unixExtraFieldType: options.unixExtraFieldType || INFOZIP_EXTRA_FIELD_TYPE
9476
+ });
9477
+ }
9478
+ if (child.passThrough) {
9479
+ let level, encryptionStrength;
9480
+ if (compressionMethod === 0) {
9481
+ level = 0;
9252
9482
  }
9253
- } else {
9254
- for (const child of entry.children) {
9255
- await processChild(child);
9483
+ if (extraFieldAES) {
9484
+ encryptionStrength = extraFieldAES.strength;
9256
9485
  }
9257
- }
9258
- }
9259
-
9260
- async function processChild(child) {
9261
- const name = options.relativePath ? child.getRelativeName(selectedEntry) : child.getFullname();
9262
- const childOptions = child.options || {};
9263
- let zipEntryOptions = {};
9264
- if (child.data instanceof Entry) {
9265
- const {
9266
- externalFileAttributes,
9267
- versionMadeBy,
9268
- comment,
9269
- lastModDate,
9270
- creationDate,
9271
- lastAccessDate,
9272
- uncompressedSize,
9486
+ zipEntryOptions = Object.assign(zipEntryOptions, {
9487
+ passThrough: true,
9273
9488
  encrypted,
9274
9489
  zipCrypto,
9275
9490
  crc32,
9276
- compressionMethod,
9277
- extraFieldAES,
9278
- internalFileAttributes,
9279
- extraField,
9280
- uid,
9281
- gid
9282
- } = child.data;
9283
- zipEntryOptions = {
9284
- externalFileAttributes,
9285
- versionMadeBy,
9286
- comment,
9287
- lastModDate,
9288
- creationDate,
9289
- lastAccessDate,
9290
- internalFileAttributes
9291
- };
9292
- const userExtraField = getUserExtraField(extraField);
9293
- if (userExtraField) {
9294
- zipEntryOptions.extraField = userExtraField;
9295
- }
9296
- if (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE) {
9297
- Object.assign(zipEntryOptions, {
9298
- uid,
9299
- gid,
9300
- unixExtraFieldType: options.unixExtraFieldType || INFOZIP_EXTRA_FIELD_TYPE
9301
- });
9302
- }
9303
- if (child.passThrough) {
9304
- let level, encryptionStrength;
9305
- if (compressionMethod === 0) {
9306
- level = 0;
9307
- }
9308
- if (extraFieldAES) {
9309
- encryptionStrength = extraFieldAES.strength;
9310
- }
9311
- zipEntryOptions = Object.assign(zipEntryOptions, {
9312
- passThrough: true,
9313
- encrypted,
9314
- zipCrypto,
9315
- crc32,
9316
- uncompressedSize,
9317
- level,
9318
- encryptionStrength,
9319
- compressionMethod
9320
- });
9321
- }
9491
+ uncompressedSize,
9492
+ level,
9493
+ encryptionStrength,
9494
+ compressionMethod
9495
+ });
9322
9496
  }
9323
- await zipWriter.add(name, readers.get(child), Object.assign({}, options, zipEntryOptions, childOptions, {
9324
- directory: child.directory,
9325
- onprogress: async indexProgress => {
9326
- if (options.onprogress) {
9327
- entryOffsets.set(name, indexProgress);
9328
- try {
9329
- await options.onprogress(Array.from(entryOffsets.values()).reduce((previousValue, currentValue) => previousValue + currentValue), totalSize);
9330
- } catch {
9331
- // ignored
9332
- }
9497
+ }
9498
+ await zipWriter.add(name, readers.get(child), Object.assign({}, options, zipEntryOptions, childOptions, {
9499
+ directory: child.directory,
9500
+ onprogress: async indexProgress => {
9501
+ if (options.onprogress) {
9502
+ entryOffsets.set(name, indexProgress);
9503
+ try {
9504
+ await options.onprogress(Array.from(entryOffsets.values()).reduce((previousValue, currentValue) => previousValue + currentValue), totalSize);
9505
+ } catch {
9506
+ // ignored
9333
9507
  }
9334
9508
  }
9335
- }));
9336
- await process(zipWriter, child);
9337
- }
9509
+ }
9510
+ }));
9338
9511
  }
9339
9512
  }
9340
9513
 
9341
9514
  function addFileSystemHandle(zipEntry, handle, options) {
9342
9515
  return addFile(zipEntry, handle, []);
9343
9516
 
9344
- async function addFile(parentEntry, handle, addedEntries) {
9517
+ async function addFile(parentEntry, handle, addedEntries, parentName = "") {
9345
9518
  if (handle) {
9519
+ const entryName = parentName ? parentName + "/" + handle.name : handle.name;
9346
9520
  try {
9347
9521
  if (handle.isFile || handle.isDirectory) {
9348
9522
  handle = await transformToFileSystemhandle(handle);
@@ -9364,12 +9538,18 @@ function addFileSystemHandle(zipEntry, handle, options) {
9364
9538
  const directoryEntry = parentEntry.addDirectory(handle.name);
9365
9539
  addedEntries.push(directoryEntry);
9366
9540
  for await (const childHandle of handle.values()) {
9367
- await addFile(directoryEntry, childHandle, addedEntries);
9541
+ await addFile(directoryEntry, childHandle, addedEntries, entryName);
9368
9542
  }
9369
9543
  }
9370
9544
  } catch (error) {
9371
- const message = error.message + (handle ? " (" + handle.name + ")" : "");
9372
- throw new Error(message, { cause: error });
9545
+ try {
9546
+ if (error.entryName === UNDEFINED_VALUE) {
9547
+ error.entryName = entryName;
9548
+ }
9549
+ } catch {
9550
+ // ignored
9551
+ }
9552
+ throw error;
9373
9553
  }
9374
9554
  }
9375
9555
  return addedEntries;
@@ -9379,15 +9559,33 @@ function addFileSystemHandle(zipEntry, handle, options) {
9379
9559
  async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
9380
9560
  const totalSize = getTotalSize([zipEntry], "uncompressedSize");
9381
9561
  const writtenSizes = new Map();
9382
- await exportChildren(zipEntry, directoryHandle);
9562
+ const abortController = new AbortController();
9563
+ const { signal } = abortController;
9564
+ const releaseSignal = forwardAbort(options.signal, abortController);
9565
+ const exportedEntryNames = [];
9566
+ let exportAborted = false;
9567
+ try {
9568
+ await exportChildren(zipEntry, directoryHandle);
9569
+ } catch (error) {
9570
+ try {
9571
+ error.exportedEntryNames = exportedEntryNames;
9572
+ } catch {
9573
+ // ignored
9574
+ }
9575
+ throw error;
9576
+ } finally {
9577
+ releaseSignal();
9578
+ }
9383
9579
  return directoryHandle;
9384
9580
 
9385
9581
  async function exportChildren(entry, parentHandle) {
9386
9582
  if (options.concurrent) {
9387
9583
  const results = await Promise.allSettled(entry.children.map(child => exportChild(child, parentHandle)));
9388
- const failedResult = results.find(result => result.status == "rejected");
9389
- if (failedResult) {
9390
- throw failedResult.reason;
9584
+ const rejectedResults = results.filter(result => result.status == "rejected");
9585
+ if (rejectedResults.length) {
9586
+ const failedResults = rejectedResults.filter(result => !isExportAborted(result.reason));
9587
+ const reportedResults = failedResults.length ? failedResults : rejectedResults;
9588
+ throw aggregateEntryErrors(reportedResults.map(result => result.reason));
9391
9589
  }
9392
9590
  } else {
9393
9591
  for (const child of entry.children) {
@@ -9397,6 +9595,12 @@ async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
9397
9595
  }
9398
9596
 
9399
9597
  async function exportChild(child, parentHandle) {
9598
+ if (signal.aborted) {
9599
+ if (exportAborted || isExportAborted(signal.reason)) {
9600
+ return;
9601
+ }
9602
+ throw signal.reason === UNDEFINED_VALUE ? new DOMException(ERR_ABORTED, ABORT_ERROR_NAME) : signal.reason;
9603
+ }
9400
9604
  try {
9401
9605
  if (child.directory) {
9402
9606
  const childDirectoryHandle = await parentHandle.getDirectoryHandle(child.name, { create: true });
@@ -9404,21 +9608,37 @@ async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
9404
9608
  } else {
9405
9609
  const fileHandle = await parentHandle.getFileHandle(child.name, { create: true });
9406
9610
  const writable = await fileHandle.createWritable();
9407
- await child.getData({ writable }, Object.assign({}, options, {
9408
- onprogress: async progress => {
9409
- if (options.onprogress) {
9410
- writtenSizes.set(child.id, progress);
9411
- try {
9412
- await options.onprogress(Array.from(writtenSizes.values()).reduce((previousValue, currentValue) => previousValue + currentValue, 0), totalSize);
9413
- } catch {
9414
- // ignored
9611
+ try {
9612
+ await child.getData({ writable }, Object.assign({}, options, {
9613
+ signal,
9614
+ onprogress: async progress => {
9615
+ if (options.onprogress) {
9616
+ writtenSizes.set(child.id, progress);
9617
+ try {
9618
+ await options.onprogress(Array.from(writtenSizes.values()).reduce((previousValue, currentValue) => previousValue + currentValue, 0), totalSize);
9619
+ } catch {
9620
+ // ignored
9621
+ }
9415
9622
  }
9416
9623
  }
9417
- }
9418
- }));
9624
+ }));
9625
+ } catch (error) {
9626
+ throw exportAborted ? new Error(ERR_ABORT_EXPORT) : error;
9627
+ }
9628
+ exportedEntryNames.push(child.getRelativeName(zipEntry));
9419
9629
  }
9420
9630
  } catch (error) {
9421
- throw new Error(error.message + (child ? " (" + child.name + ")" : ""), { cause: error });
9631
+ exportAborted = true;
9632
+ abortController.abort(new Error(ERR_ABORT_EXPORT));
9633
+ try {
9634
+ if (error.entryName === UNDEFINED_VALUE) {
9635
+ error.entryName = child.getRelativeName(zipEntry);
9636
+ error.entryId = child.id;
9637
+ }
9638
+ } catch {
9639
+ // ignored
9640
+ }
9641
+ throw error;
9422
9642
  }
9423
9643
  }
9424
9644
  }
@@ -9480,6 +9700,21 @@ function resetFS(fs) {
9480
9700
  fs.root = new ZipDirectoryEntry(fs);
9481
9701
  }
9482
9702
 
9703
+ function collectChildren(directory, recursive) {
9704
+ const children = [];
9705
+ const pendingDirectories = [directory];
9706
+ let directoryIndex = 0;
9707
+ while (directoryIndex < pendingDirectories.length) {
9708
+ for (const child of pendingDirectories[directoryIndex++].children) {
9709
+ children.push(child);
9710
+ if (recursive) {
9711
+ pendingDirectories.push(child);
9712
+ }
9713
+ }
9714
+ }
9715
+ return children;
9716
+ }
9717
+
9483
9718
  function registerEntries(fs, entry) {
9484
9719
  const pendingEntries = [entry];
9485
9720
  while (pendingEntries.length) {
@@ -9499,4 +9734,4 @@ function addChild(parent, name, params, directory) {
9499
9734
  }
9500
9735
  }
9501
9736
 
9502
- export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_EXISTS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_GID, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_READABLE_CONSUMED, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
9737
+ export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_EXISTS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_READABLE_CONSUMED, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };