@zip.js/zip.js 2.11.4 → 2.13.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.
Files changed (52) hide show
  1. package/deno.json +1 -1
  2. package/dist/zip-core-external.js +549 -139
  3. package/dist/zip-core-external.min.js +1 -1
  4. package/dist/zip-core.js +559 -136
  5. package/dist/zip-core.min.js +1 -1
  6. package/dist/zip-fs-core-external.js +615 -260
  7. package/dist/zip-fs-core-external.min.js +1 -1
  8. package/dist/zip-fs-core.js +628 -257
  9. package/dist/zip-fs-core.min.js +1 -1
  10. package/dist/zip-fs-external.js +615 -260
  11. package/dist/zip-fs-external.min.js +1 -1
  12. package/dist/zip-fs-native.js +630 -259
  13. package/dist/zip-fs-native.min.js +1 -1
  14. package/dist/zip-fs.js +631 -260
  15. package/dist/zip-fs.min.js +1 -1
  16. package/dist/zip-legacy.js +561 -138
  17. package/dist/zip-legacy.min.js +1 -1
  18. package/dist/zip-native.js +561 -138
  19. package/dist/zip-native.min.js +1 -1
  20. package/dist/zip-web-worker-native.js +1 -1
  21. package/dist/zip-web-worker.js +1 -1
  22. package/dist/zip.js +562 -139
  23. package/dist/zip.min.js +1 -1
  24. package/index-native.cjs +630 -259
  25. package/index-native.min.js +1 -1
  26. package/index.cjs +631 -260
  27. package/index.d.cts +474 -59
  28. package/index.d.ts +474 -59
  29. package/index.min.js +1 -1
  30. package/lib/core/codec-worker-web.js +72 -22
  31. package/lib/core/codec-worker.js +18 -5
  32. package/lib/core/configuration.js +20 -5
  33. package/lib/core/constants.js +2 -0
  34. package/lib/core/io.js +13 -5
  35. package/lib/core/options.js +16 -0
  36. package/lib/core/streams/codec-stream.js +6 -0
  37. package/lib/core/util/error.js +35 -0
  38. package/lib/core/util/warnings.js +42 -0
  39. package/lib/core/version.js +1 -1
  40. package/lib/core/web-worker-base.js +46 -9
  41. package/lib/core/web-worker-inline-native.js +1 -1
  42. package/lib/core/web-worker-inline-wasm.js +1 -1
  43. package/lib/core/zip-entry.js +49 -1
  44. package/lib/core/zip-fs.js +45 -133
  45. package/lib/core/zip-reader.js +115 -52
  46. package/lib/core/zip-writer.js +244 -57
  47. package/lib/zip-core-base.js +9 -3
  48. package/lib/zip-core-reader.js +2 -0
  49. package/lib/zip-core-writer.js +6 -1
  50. package/lib/zip-module-wasm-base.js +2 -2
  51. package/package.json +5 -3
  52. package/worker-message-property-names.js +1 -1
@@ -125,6 +125,7 @@ const NUMBER_TYPE = "number";
125
125
  const BOOLEAN_TYPE = "boolean";
126
126
 
127
127
  const EMPTY_UINT8_ARRAY = new Uint8Array();
128
+ const SYMBOL_ASYNC_DISPOSE = Symbol.asyncDispose || Symbol();
128
129
 
129
130
  /*
130
131
  Copyright (c) 2022 Gildas Lormeau. All rights reserved.
@@ -169,6 +170,7 @@ const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
169
170
  const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
170
171
  const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
171
172
  const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
173
+ const OPTION_CHECK_LOCAL_FILENAME = "checkLocalFilename";
172
174
  const OPTION_CHECK_SIGNATURE = "checkSignature";
173
175
  const OPTION_CHECK_CRC32 = "checkCrc32";
174
176
  const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
@@ -199,15 +201,18 @@ const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
199
201
  const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
200
202
  const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
201
203
  const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
204
+ const OPTION_ENTRY = "entry";
202
205
  const TEXT_TYPE_FILENAME = "filename";
203
206
  const TEXT_TYPE_COMMENT = "comment";
204
207
  const STRICTNESS_STRICT = "strict";
205
208
  const STRICTNESS_BALANCED = "balanced";
206
209
  const STRICTNESS_TOLERANT = "tolerant";
210
+ const PASS_THROUGH_COMPRESSED = "compressed";
207
211
 
208
212
  const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
209
213
  const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
210
214
  const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
215
+ const ERR_INVALID_PASS_THROUGH_VALUE = "Invalid passThrough option (must be a boolean or 'compressed')";
211
216
  const ERR_ABORTED = "The operation was aborted";
212
217
  const ABORT_ERROR_NAME = "AbortError";
213
218
 
@@ -237,6 +242,13 @@ function checkPasswordOption(password, rawPassword) {
237
242
  }
238
243
  }
239
244
 
245
+ function checkPassThroughOption(passThrough) {
246
+ if (passThrough !== UNDEFINED_VALUE && typeof passThrough != BOOLEAN_TYPE && passThrough !== PASS_THROUGH_COMPRESSED) {
247
+ throw new Error(ERR_INVALID_PASS_THROUGH_VALUE);
248
+ }
249
+ return passThrough;
250
+ }
251
+
240
252
  function checkInteger(value, maxValue, errorMessage) {
241
253
  if (!Number.isInteger(value) || value < 0 || value > maxValue) {
242
254
  throw new Error(errorMessage);
@@ -286,6 +298,8 @@ const DEFAULT_CHUNK_SIZE$1 = 64 * 1024;
286
298
  const MINIMUM_CHUNK_SIZE = 64;
287
299
  const MINIMUM_PROPERTY_VALUE = 1;
288
300
  const ERR_INVALID_MAX_WORKERS = "Invalid maxWorkers (must be an integer greater than 0)";
301
+ const ERR_INVALID_BASE_URI = "Invalid baseURI (must be a string)";
302
+ const ERR_INVALID_URI = "Invalid URI (must be a string or a function returning a string)";
289
303
  let maxWorkers = 2;
290
304
  try {
291
305
  if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
@@ -310,9 +324,9 @@ const DEFAULT_CONFIGURATION = {
310
324
  };
311
325
 
312
326
  const PROPERTY_NAME_MAX_WORKERS = "maxWorkers";
327
+ const PROPERTY_NAME_BASE_URI = "baseURI";
313
328
 
314
- const STRING_PROPERTY_NAMES = [
315
- "baseURI",
329
+ const URI_PROPERTY_NAMES = [
316
330
  "wasmURI",
317
331
  "workerURI"
318
332
  ];
@@ -336,7 +350,8 @@ const FUNCTION_PROPERTY_NAMES = [
336
350
  "DecompressionStreamFallback"
337
351
  ];
338
352
  const CONFIGURABLE_PROPERTY_NAMES = [
339
- ...STRING_PROPERTY_NAMES,
353
+ PROPERTY_NAME_BASE_URI,
354
+ ...URI_PROPERTY_NAMES,
340
355
  ...BOOLEAN_PROPERTY_NAMES,
341
356
  ...NUMBER_PROPERTY_NAMES,
342
357
  ...FUNCTION_PROPERTY_NAMES
@@ -380,6 +395,14 @@ function checkPropertyValue(propertyName, propertyValue) {
380
395
  }
381
396
  } else if (FUNCTION_PROPERTY_NAMES.includes(propertyName)) {
382
397
  checkFunctionOption(propertyValue);
398
+ } else if (propertyName == PROPERTY_NAME_BASE_URI) {
399
+ if (propertyValue && typeof propertyValue != STRING_TYPE) {
400
+ throw new Error(ERR_INVALID_BASE_URI);
401
+ }
402
+ } else if (URI_PROPERTY_NAMES.includes(propertyName)) {
403
+ if (propertyValue && typeof propertyValue != STRING_TYPE && typeof propertyValue != FUNCTION_TYPE) {
404
+ throw new Error(ERR_INVALID_URI);
405
+ }
383
406
  }
384
407
  return propertyValue;
385
408
  }
@@ -493,6 +516,39 @@ function getDataView(array) {
493
516
  return new DataView(array.buffer, array.byteOffset, array.byteLength);
494
517
  }
495
518
 
519
+ /*
520
+ Copyright (c) 2026 Gildas Lormeau. All rights reserved.
521
+
522
+ Redistribution and use in source and binary forms, with or without
523
+ modification, are permitted provided that the following conditions are met:
524
+
525
+ 1. Redistributions of source code must retain the above copyright notice,
526
+ this list of conditions and the following disclaimer.
527
+
528
+ 2. Redistributions in binary form must reproduce the above copyright
529
+ notice, this list of conditions and the following disclaimer in
530
+ the documentation and/or other materials provided with the distribution.
531
+
532
+ 3. The names of the authors may not be used to endorse or promote products
533
+ derived from this software without specific prior written permission.
534
+
535
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
536
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
537
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
538
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
539
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
540
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
541
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
542
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
543
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
544
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
545
+ */
546
+
547
+
548
+ function isErrorObject(error) {
549
+ return Boolean(error) && typeof error == "object";
550
+ }
551
+
496
552
  /*
497
553
  Copyright (c) 2022 Gildas Lormeau. All rights reserved.
498
554
 
@@ -2632,6 +2688,7 @@ class ChunkStream extends TransformStream {
2632
2688
  constructor(chunkSize) {
2633
2689
  const pendingChunks = [];
2634
2690
  let pendingLength = 0;
2691
+ let outputSize = 0;
2635
2692
  if (!Number.isFinite(chunkSize) || chunkSize < 1) {
2636
2693
  chunkSize = DEFAULT_CHUNK_SIZE;
2637
2694
  }
@@ -2640,15 +2697,20 @@ class ChunkStream extends TransformStream {
2640
2697
  pendingChunks.push(chunk);
2641
2698
  pendingLength += chunk.length;
2642
2699
  while (pendingLength > chunkSize) {
2700
+ outputSize += chunkSize;
2643
2701
  controller.enqueue(shiftChunk());
2644
2702
  }
2645
2703
  },
2646
2704
  flush(controller) {
2647
2705
  if (pendingLength) {
2706
+ outputSize += pendingLength;
2648
2707
  controller.enqueue(concatChunks(pendingChunks, pendingLength));
2649
2708
  }
2650
2709
  }
2651
2710
  });
2711
+ Object.defineProperty(this, "outputSize", {
2712
+ get: () => outputSize
2713
+ });
2652
2714
 
2653
2715
  function shiftChunk() {
2654
2716
  const result = new Uint8Array(chunkSize);
@@ -2758,7 +2820,9 @@ function disableWebWorker(workerData) {
2758
2820
 
2759
2821
  class CodecWorker {
2760
2822
 
2761
- constructor(workerData, { readable, writable }, { options, config, streamOptions, useWebWorkers, transferStreams, workerURI, createWorker }, onTaskFinished) {
2823
+ constructor(workerData, { readable, writable }, workerOptions, onTaskFinished) {
2824
+ const { options, config, streamOptions, useWebWorkers, transferStreams, workerURI } = workerOptions;
2825
+ let { createWorker } = workerOptions;
2762
2826
  const { signal } = streamOptions;
2763
2827
  if (createWorkerFailed) {
2764
2828
  createWorker = UNDEFINED_VALUE;
@@ -2771,6 +2835,7 @@ class CodecWorker {
2771
2835
  .pipeThrough(new ProgressWatcherStream(streamOptions), { signal }),
2772
2836
  writable,
2773
2837
  options: Object.assign({}, options),
2838
+ workerOptions,
2774
2839
  workerURI,
2775
2840
  createWorker,
2776
2841
  transferStreams,
@@ -2852,8 +2917,8 @@ function createWorkerInterface(workerData, config) {
2852
2917
  };
2853
2918
  }
2854
2919
 
2855
- async function runWorker$1({ options, readable, writable, onTaskFinished }, config) {
2856
- let codecStream;
2920
+ async function runWorker$1({ options, readable, writable, onTaskFinished, workerOptions }, config) {
2921
+ let codecStream, chunkStream;
2857
2922
  try {
2858
2923
  if (options.compressed && !options.format) {
2859
2924
  const deflate = options.codecType.startsWith(CODEC_DEFLATE);
@@ -2876,9 +2941,10 @@ async function runWorker$1({ options, readable, writable, onTaskFinished }, conf
2876
2941
  }
2877
2942
  }
2878
2943
  codecStream = new CodecStream(options, config);
2944
+ chunkStream = new ChunkStream(getChunkSize(config));
2879
2945
  await readable
2880
2946
  .pipeThrough(codecStream)
2881
- .pipeThrough(new ChunkStream(getChunkSize(config)))
2947
+ .pipeThrough(chunkStream)
2882
2948
  .pipeTo(writable, { preventClose: true, preventAbort: true });
2883
2949
  const {
2884
2950
  crc32,
@@ -2892,7 +2958,15 @@ async function runWorker$1({ options, readable, writable, onTaskFinished }, conf
2892
2958
  };
2893
2959
  } catch (error) {
2894
2960
  if (codecStream) {
2895
- error.outputSize = codecStream.outputSize;
2961
+ const outputSize = chunkStream ? chunkStream.outputSize : 0;
2962
+ workerOptions.outputSize = outputSize;
2963
+ if (isErrorObject(error)) {
2964
+ try {
2965
+ error.outputSize = outputSize;
2966
+ } catch {
2967
+ // ignored
2968
+ }
2969
+ }
2896
2970
  }
2897
2971
  throw error;
2898
2972
  } finally {
@@ -3001,11 +3075,23 @@ async function runWebWorker(workerData, config) {
3001
3075
  let resolveResult, rejectResult;
3002
3076
  const result = new Promise((resolve, reject) => {
3003
3077
  resolveResult = resolve;
3004
- rejectResult = reject;
3078
+ rejectResult = error => {
3079
+ const { outputSize, workerOptions } = workerData;
3080
+ workerOptions.outputSize = outputSize;
3081
+ if (isErrorObject(error) && error.outputSize === UNDEFINED_VALUE) {
3082
+ try {
3083
+ error.outputSize = outputSize;
3084
+ } catch {
3085
+ // ignored
3086
+ }
3087
+ }
3088
+ reject(error);
3089
+ };
3005
3090
  });
3006
3091
  Object.assign(workerData, {
3007
3092
  reader: null,
3008
3093
  writer: null,
3094
+ outputSize: 0,
3009
3095
  resolveResult,
3010
3096
  rejectResult,
3011
3097
  result
@@ -3266,21 +3352,15 @@ function sendMessage(message, { worker, writer, transferStreams, workerAlive })
3266
3352
  }
3267
3353
 
3268
3354
  async function onMessage({ data }, workerData) {
3269
- const { type, value, messageId, result, error } = data;
3355
+ const { type, value, messageId, result, error, errorValue } = data;
3270
3356
  const { reader, writer, resolveResult, rejectResult, onTaskFinished, generation } = workerData;
3271
3357
  const stale = () => workerData.generation != generation;
3272
3358
  try {
3273
3359
  if (error) {
3274
- const { message, stack, code, name, outputSize, cause, codecImportFailed } = error;
3275
- const responseError = new Error(message);
3276
- Object.assign(responseError, { stack, code, name, outputSize });
3277
- if (cause) {
3278
- responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
3279
- }
3280
- if (codecImportFailed) {
3281
- responseError.codecImportFailed = true;
3360
+ if (error.outputSize !== UNDEFINED_VALUE) {
3361
+ workerData.outputSize = error.outputSize;
3282
3362
  }
3283
- close(responseError);
3363
+ fail(getResponseError(error, errorValue));
3284
3364
  } else {
3285
3365
  if (type == MESSAGE_PULL) {
3286
3366
  const { value, done } = await reader.read();
@@ -3289,39 +3369,82 @@ async function onMessage({ data }, workerData) {
3289
3369
  }
3290
3370
  }
3291
3371
  if (type == MESSAGE_DATA) {
3372
+ const chunk = new Uint8Array(value);
3292
3373
  await writer.ready;
3293
- await writer.write(new Uint8Array(value));
3374
+ await writer.write(chunk);
3375
+ workerData.outputSize += chunk.length;
3294
3376
  if (!stale()) {
3295
3377
  sendMessage({ type: MESSAGE_ACK_DATA, messageId }, workerData);
3296
3378
  }
3297
3379
  }
3298
3380
  if (type == MESSAGE_CLOSE) {
3299
- close(null, result);
3381
+ succeed(result);
3300
3382
  }
3301
3383
  }
3302
3384
  } catch (error) {
3303
3385
  if (!stale()) {
3304
3386
  terminateWorker$1(workerData);
3305
- close(error);
3387
+ fail(error);
3306
3388
  }
3307
3389
  }
3308
3390
 
3309
- function close(error, result) {
3310
- if (stale()) {
3311
- return;
3312
- }
3313
- if (error) {
3391
+ function fail(error) {
3392
+ if (!stale()) {
3314
3393
  rejectResult(error);
3315
- } else {
3394
+ releaseWriter();
3395
+ if (!(isErrorObject(error) && error.codecImportFailed)) {
3396
+ onTaskFinished();
3397
+ }
3398
+ }
3399
+ }
3400
+
3401
+ function succeed(result) {
3402
+ if (!stale()) {
3316
3403
  resolveResult(result);
3404
+ releaseWriter();
3405
+ onTaskFinished();
3317
3406
  }
3407
+ }
3408
+
3409
+ function releaseWriter() {
3318
3410
  if (writer) {
3319
3411
  writer.releaseLock();
3320
3412
  }
3321
- if (!(error && error.codecImportFailed)) {
3322
- onTaskFinished();
3413
+ }
3414
+ }
3415
+
3416
+ function getResponseError(errorData, errorValue) {
3417
+ const { message, stack, code, name, outputSize, cause, codecImportFailed } = errorData;
3418
+ let responseError;
3419
+ if (errorValue) {
3420
+ responseError = errorValue.value;
3421
+ } else {
3422
+ responseError = Object.assign(new Error(message), { stack, code, name });
3423
+ if (cause) {
3424
+ responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
3425
+ }
3426
+ }
3427
+ if (isErrorObject(responseError)) {
3428
+ try {
3429
+ if (outputSize !== UNDEFINED_VALUE) {
3430
+ responseError.outputSize = outputSize;
3431
+ }
3432
+ if (codecImportFailed) {
3433
+ responseError.codecImportFailed = true;
3434
+ }
3435
+ if (errorValue) {
3436
+ if (responseError.name !== name) {
3437
+ responseError.name = name;
3438
+ }
3439
+ if (responseError.code !== code) {
3440
+ responseError.code = code;
3441
+ }
3442
+ }
3443
+ } catch {
3444
+ // ignored
3323
3445
  }
3324
3446
  }
3447
+ return responseError;
3325
3448
  }
3326
3449
 
3327
3450
  /*
@@ -3598,10 +3721,13 @@ function decode(value, encoding, ignoreBOM) {
3598
3721
 
3599
3722
 
3600
3723
  const ERR_HTTP_STATUS = "HTTP error ";
3724
+ const MIN_SUCCESS_HTTP_STATUS = 200;
3725
+ const MAX_SUCCESS_HTTP_STATUS = 299;
3601
3726
  const ERR_HTTP_RANGE = "HTTP Range not supported";
3602
3727
  const ERR_HTTP_RESOURCE_CHANGED = "HTTP resource changed";
3603
3728
  const ERR_ITERATOR_COMPLETED_TOO_SOON = "Writer iterator completed too soon";
3604
3729
  const ERR_WRITER_NOT_INITIALIZED = "Writer not initialized";
3730
+ const ERR_WRITER_SIZE_NOT_WRITABLE = "Invalid writer (size must be writable)";
3605
3731
 
3606
3732
  const CONTENT_TYPE_TEXT_PLAIN = "text/plain";
3607
3733
  const HTTP_HEADER_CONTENT_LENGTH = "Content-Length";
@@ -3793,6 +3919,7 @@ class BlobReader extends Reader {
3793
3919
  const reader = this;
3794
3920
  const { sourceBlob, size } = reader;
3795
3921
  const { offset = 0, size: readSize = size - offset } = options || {};
3922
+ // deno-lint-ignore valid-typeof
3796
3923
  if (typeof sourceBlob.stream == FUNCTION_TYPE) {
3797
3924
  if (!offset && readSize >= size) {
3798
3925
  return toCompatibleReadable(sourceBlob.stream());
@@ -4179,7 +4306,7 @@ async function getContentLength(httpReader, sendRequest, getRequestData) {
4179
4306
 
4180
4307
  async function sendFetchRequest(method, { fetch: fetchFunction = fetch, options, url }, headers) {
4181
4308
  const response = await fetchFunction(url, Object.assign({}, options, { method, headers }));
4182
- if (response.status < 400) {
4309
+ if (response.status >= MIN_SUCCESS_HTTP_STATUS && response.status <= MAX_SUCCESS_HTTP_STATUS) {
4183
4310
  return response;
4184
4311
  } else {
4185
4312
  throw response.status == 416 ? new Error(ERR_HTTP_RANGE) : new Error(ERR_HTTP_STATUS + (response.statusText || response.status));
@@ -4190,7 +4317,7 @@ function sendXMLHttpRequest(method, { url }, headers) {
4190
4317
  return new Promise((resolve, reject) => {
4191
4318
  const request = new XMLHttpRequest();
4192
4319
  request.addEventListener("load", () => {
4193
- if (request.status < 400) {
4320
+ if (request.status >= MIN_SUCCESS_HTTP_STATUS && request.status <= MAX_SUCCESS_HTTP_STATUS) {
4194
4321
  const headers = [];
4195
4322
  request.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(header => {
4196
4323
  const splitHeader = header.trim().split(/\s*:\s*/);
@@ -4494,8 +4621,10 @@ class GenericWriter {
4494
4621
  writable: toCompatibleWritable(writer)
4495
4622
  };
4496
4623
  }
4497
- if (writer.size === UNDEFINED_VALUE) {
4498
- writer.size = 0;
4624
+ try {
4625
+ writer.size = writer.size === UNDEFINED_VALUE ? 0 : writer.size;
4626
+ } catch {
4627
+ throw new Error(ERR_WRITER_SIZE_NOT_WRITABLE);
4499
4628
  }
4500
4629
  return writer;
4501
4630
  }
@@ -4543,6 +4672,45 @@ function createReadable(reader, options) {
4543
4672
  }
4544
4673
  }
4545
4674
 
4675
+ /*
4676
+ Copyright (c) 2026 Gildas Lormeau. All rights reserved.
4677
+
4678
+ Redistribution and use in source and binary forms, with or without
4679
+ modification, are permitted provided that the following conditions are met:
4680
+
4681
+ 1. Redistributions of source code must retain the above copyright notice,
4682
+ this list of conditions and the following disclaimer.
4683
+
4684
+ 2. Redistributions in binary form must reproduce the above copyright
4685
+ notice, this list of conditions and the following disclaimer in
4686
+ the documentation and/or other materials provided with the distribution.
4687
+
4688
+ 3. The names of the authors may not be used to endorse or promote products
4689
+ derived from this software without specific prior written permission.
4690
+
4691
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
4692
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
4693
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
4694
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
4695
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4696
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
4697
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4698
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4699
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4700
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4701
+ */
4702
+
4703
+
4704
+ function addWarning(warnings, reason, filename) {
4705
+ if (!warnings.some(warning => warning.reason == reason)) {
4706
+ const warning = { reason };
4707
+ if (filename !== UNDEFINED_VALUE) {
4708
+ warning.filename = filename;
4709
+ }
4710
+ warnings.push(warning);
4711
+ }
4712
+ }
4713
+
4546
4714
  /*
4547
4715
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
4548
4716
 
@@ -4571,6 +4739,7 @@ function createReadable(reader, options) {
4571
4739
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4572
4740
  */
4573
4741
 
4742
+
4574
4743
  const PROPERTY_NAME_FILENAME = "filename";
4575
4744
  const PROPERTY_NAME_RAW_FILENAME = "rawFilename";
4576
4745
  const PROPERTY_NAME_COMMENT = "comment";
@@ -4695,6 +4864,38 @@ class Entry {
4695
4864
 
4696
4865
  }
4697
4866
 
4867
+ const INTERPRETED_EXTRA_FIELD_TYPES = new Set([
4868
+ EXTRAFIELD_TYPE_ZIP64,
4869
+ EXTRAFIELD_TYPE_AES,
4870
+ EXTRAFIELD_TYPE_NTFS,
4871
+ EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP,
4872
+ EXTRAFIELD_TYPE_UNICODE_PATH,
4873
+ EXTRAFIELD_TYPE_UNICODE_COMMENT,
4874
+ EXTRAFIELD_TYPE_USDZ,
4875
+ EXTRAFIELD_TYPE_INFOZIP,
4876
+ EXTRAFIELD_TYPE_UNIX,
4877
+ EXTRAFIELD_TYPE_UNIX_TYPE1,
4878
+ EXTRAFIELD_TYPE_PKWARE_UNIX
4879
+ ]);
4880
+
4881
+ function getUserExtraField(extraField) {
4882
+ if (extraField) {
4883
+ const userExtraField = new Map();
4884
+ extraField.forEach((field, type) => {
4885
+ if (!INTERPRETED_EXTRA_FIELD_TYPES.has(type)) {
4886
+ userExtraField.set(type, field.data);
4887
+ }
4888
+ });
4889
+ if (userExtraField.size) {
4890
+ return userExtraField;
4891
+ }
4892
+ }
4893
+ }
4894
+
4895
+ function getEncryptionOverhead(encrypted, zipCrypto, encryptionStrength) {
4896
+ return encrypted ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
4897
+ }
4898
+
4698
4899
  /*
4699
4900
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
4700
4901
 
@@ -4754,6 +4955,8 @@ const WARNING_PREPENDED_CENTRAL_DIRECTORY = "prepended central directory";
4754
4955
  const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA = "trailing central directory data";
4755
4956
  const WARNING_DUPLICATE_FILENAME = "duplicate filename";
4756
4957
  const WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY = "mismatched zip64 end of central directory record";
4958
+ const WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY = "multiple end of central directory records";
4959
+ const WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME = "mismatched local file header (filename)";
4757
4960
  const WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG = "mismatched local file header (general purpose bit flag)";
4758
4961
  const WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD = "mismatched local file header (compression method)";
4759
4962
  const WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES = "mismatched local file header (crc32 or sizes)";
@@ -4824,7 +5027,7 @@ class ZipReader {
4824
5027
  }
4825
5028
  }
4826
5029
  if (rejectAmbiguousEndOfDirectory && endOfDirectoryReachingEndCount > 1) {
4827
- throwAmbiguousArchive("multiple end of central directory records");
5030
+ throwAmbiguousArchive(WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY);
4828
5031
  }
4829
5032
  const endOfDirectoryView = getDataView(endOfDirectoryInfo);
4830
5033
  let directoryDataLength = getUint32$1(endOfDirectoryView, 12);
@@ -5122,7 +5325,8 @@ class ZipReader {
5122
5325
  const writer = new TransformStream();
5123
5326
  const arrayBufferPromise = streamToBlob(writer.readable).then(blob => blob.arrayBuffer());
5124
5327
  arrayBufferPromise.catch(() => { });
5125
- await fileEntry.getData(writer, entry, zipReader.readRanges, options);
5328
+ await fileEntry.getData(writer, entry, zipReader.readRanges,
5329
+ Object.assign({}, options, { preventClose: false }));
5126
5330
  return arrayBufferPromise;
5127
5331
  };
5128
5332
  offset = endOffset;
@@ -5203,49 +5407,101 @@ class ZipReader {
5203
5407
  await reader.readable.cancel();
5204
5408
  }
5205
5409
  }
5410
+
5411
+ [SYMBOL_ASYNC_DISPOSE]() {
5412
+ return this.close();
5413
+ }
5206
5414
  }
5207
5415
 
5208
5416
  class ZipReaderStream {
5209
5417
 
5210
5418
  constructor(options = {}) {
5211
- const { readable, writable } = new TransformStream();
5212
- const gen = new ZipReader(readable, options).getEntriesGenerator();
5419
+ let sourceController;
5420
+ const { readable, writable } = new TransformStream({
5421
+ start(controller) {
5422
+ sourceController = controller;
5423
+ }
5424
+ });
5425
+ const zipReader = new ZipReader(readable, options);
5426
+ const gen = zipReader.getEntriesGenerator();
5427
+ const pendingEntries = new Set();
5213
5428
  this.readable = new ReadableStream({
5214
5429
  async pull(controller) {
5215
5430
  const { done, value } = await gen.next();
5216
5431
  if (done)
5217
5432
  return controller.close();
5218
- const entryReadable = (function () {
5219
- const { readable, writable } = new TransformStream();
5220
- if (value.getData) {
5221
- getData();
5222
- return readable;
5223
- }
5224
-
5225
- async function getData() {
5226
- try {
5227
- await value.getData(writable);
5228
- } catch (error) {
5229
- try {
5230
- await writable.abort(error);
5231
- } catch {
5232
- // ignored
5233
- }
5234
- }
5235
- }
5236
- })();
5433
+ const entryStream = createEntryStream(value, pendingEntries);
5237
5434
  const chunk = {
5238
5435
  ...value,
5239
- readable: entryReadable
5436
+ readable: entryStream.readable
5240
5437
  };
5241
5438
  delete chunk.getData;
5439
+ Object.defineProperties(chunk, {
5440
+ localDirectory: {
5441
+ get: () => value.localDirectory,
5442
+ enumerable: true
5443
+ },
5444
+ warnings: {
5445
+ get: () => value.warnings,
5446
+ enumerable: true
5447
+ }
5448
+ });
5242
5449
  controller.enqueue(chunk);
5450
+ },
5451
+ async cancel(reason) {
5452
+ const entryStreams = Array.from(pendingEntries);
5453
+ pendingEntries.clear();
5454
+ sourceController.error(reason);
5455
+ await Promise.allSettled(entryStreams.map(entryStream => entryStream.cancel(reason)));
5456
+ await Promise.allSettled([gen.return(), zipReader.close()]);
5243
5457
  }
5244
5458
  });
5245
5459
  this.writable = writable;
5246
5460
  }
5247
5461
  }
5248
5462
 
5463
+ function createEntryStream(entry, pendingEntries) {
5464
+ const { readable, writable } = new TransformStream();
5465
+ let dataReader;
5466
+ const entryStream = {
5467
+ cancel: async reason => {
5468
+ pendingEntries.delete(entryStream);
5469
+ await (dataReader ? dataReader.cancel(reason) : readable.cancel(reason));
5470
+ }
5471
+ };
5472
+ entryStream.readable = new ReadableStream({
5473
+ async pull(controller) {
5474
+ if (!dataReader) {
5475
+ dataReader = readable.getReader();
5476
+ pendingEntries.add(entryStream);
5477
+ getData();
5478
+ }
5479
+ const { done, value } = await dataReader.read();
5480
+ if (done) {
5481
+ controller.close();
5482
+ } else {
5483
+ controller.enqueue(value);
5484
+ }
5485
+ },
5486
+ cancel: reason => entryStream.cancel(reason)
5487
+ }, { highWaterMark: 0 });
5488
+ return entryStream;
5489
+
5490
+ async function getData() {
5491
+ try {
5492
+ await entry.getData(writable, { preventClose: false });
5493
+ } catch (error) {
5494
+ try {
5495
+ await writable.abort(error);
5496
+ } catch {
5497
+ // ignored
5498
+ }
5499
+ } finally {
5500
+ pendingEntries.delete(entryStream);
5501
+ }
5502
+ }
5503
+ }
5504
+
5249
5505
  async function isZipFile(reader, options = {}) {
5250
5506
  reader = new GenericReader(reader);
5251
5507
  await initStream(reader);
@@ -5305,7 +5561,9 @@ class ZipEntry {
5305
5561
  const dataView = getDataView(dataArray);
5306
5562
  let password = getOptionValue$1(zipEntry, options, OPTION_PASSWORD);
5307
5563
  let rawPassword = getOptionValue$1(zipEntry, options, OPTION_RAW_PASSWORD);
5308
- const passThrough = getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH);
5564
+ const passThrough = checkPassThroughOption(getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH));
5565
+ const passThroughCompression = Boolean(passThrough);
5566
+ const passThroughEncryption = passThrough === true;
5309
5567
  checkPasswordOption(password, rawPassword);
5310
5568
  password = password && password.length && password;
5311
5569
  rawPassword = rawPassword && rawPassword.length && rawPassword;
@@ -5326,7 +5584,9 @@ class ZipEntry {
5326
5584
  const checkLocalDirectoryOption = getOptionValue$1(zipEntry, options, OPTION_CHECK_LOCAL_DIRECTORY);
5327
5585
  const entryStrictness = getStrictness(options, zipEntry.options);
5328
5586
  const checkLocalDirectory = getCheckLocalDirectory(checkLocalDirectoryOption, entryStrictness);
5329
- const checkLocalFilename = getCheckLocalFilename(checkLocalDirectoryOption, entryStrictness);
5587
+ const checkLocalFilenameOption = getOptionValue$1(zipEntry, options, OPTION_CHECK_LOCAL_FILENAME);
5588
+ const checkLocalFilename = getCheckLocalFilename(
5589
+ checkLocalFilenameOption === UNDEFINED_VALUE ? checkLocalDirectoryOption : checkLocalFilenameOption, entryStrictness);
5330
5590
  let rawLocalFilename = EMPTY_UINT8_ARRAY;
5331
5591
  if (checkLocalFilename && (filenameLength || extraFieldLength)) {
5332
5592
  const trailingDataArray = await readUint8Array(reader, localHeaderOffset + HEADER_SIZE, filenameLength + extraFieldLength);
@@ -5357,16 +5617,17 @@ class ZipEntry {
5357
5617
  if (gid !== UNDEFINED_VALUE && fileEntry.gid === UNDEFINED_VALUE) {
5358
5618
  fileEntry.gid = gid;
5359
5619
  }
5360
- const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
5620
+ const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
5621
+ const encrypted = zipEntry.encrypted && localDirectory.encrypted && (!passThroughEncryption || checkPasswordOnly);
5361
5622
  const zipCrypto = encrypted && !extraFieldAES;
5362
- if (!passThrough) {
5623
+ if (!passThroughEncryption) {
5363
5624
  fileEntry.zipCrypto = zipCrypto;
5364
5625
  }
5365
5626
  if (encrypted && (localDirectory.rawBitFlag & BITFLAG_STRONG_ENCRYPTION) == BITFLAG_STRONG_ENCRYPTION) {
5366
5627
  throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
5367
5628
  }
5368
- const registeredCodec = passThrough ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
5369
- if (compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE && compressionMethod != COMPRESSION_METHOD_DEFLATE_64 && !registeredCodec && !passThrough) {
5629
+ const registeredCodec = passThroughCompression ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
5630
+ if (compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE && compressionMethod != COMPRESSION_METHOD_DEFLATE_64 && !registeredCodec && !passThroughCompression) {
5370
5631
  throw new Error(ERR_UNSUPPORTED_COMPRESSION);
5371
5632
  }
5372
5633
  if (encrypted) {
@@ -5383,15 +5644,16 @@ class ZipEntry {
5383
5644
  const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
5384
5645
  const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
5385
5646
  throwIfAborted(signal);
5386
- const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
5387
5647
  let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
5388
5648
  const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
5389
5649
  if (checkOverlappingEntryOnly) {
5390
5650
  checkOverlappingEntry = true;
5391
5651
  }
5392
5652
  const { onstart, onprogress, onend } = options;
5393
- const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !passThrough;
5394
- const outputSize = passThrough ? compressedSize : uncompressedSize;
5653
+ const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !passThroughCompression;
5654
+ const outputSize = passThroughCompression ?
5655
+ compressedSize - getEncryptionOverhead(encrypted, zipCrypto, extraFieldAES && extraFieldAES.strength) :
5656
+ uncompressedSize;
5395
5657
  const deflate64 = compressionMethod == COMPRESSION_METHOD_DEFLATE_64;
5396
5658
  let useCompressionStream = getOptionValue$1(zipEntry, options, OPTION_USE_COMPRESSION_STREAM);
5397
5659
  if (deflate64) {
@@ -5400,7 +5662,7 @@ class ZipEntry {
5400
5662
  const checkCrc32Option = getOptionValue$1(zipEntry, options, OPTION_CHECK_CRC32);
5401
5663
  const checkCrc32 = (checkCrc32Option === UNDEFINED_VALUE ?
5402
5664
  getOptionValue$1(zipEntry, options, OPTION_CHECK_SIGNATURE) :
5403
- checkCrc32Option) && !passThrough &&
5665
+ checkCrc32Option) && !passThroughCompression &&
5404
5666
  (!encrypted || zipCrypto || (extraFieldAES && extraFieldAES.vendorVersion == VENDOR_VERSION_AE_1$1));
5405
5667
  const workerOptions = {
5406
5668
  options: {
@@ -5444,7 +5706,7 @@ class ZipEntry {
5444
5706
  readRanges
5445
5707
  });
5446
5708
  }
5447
- let writable, abortError;
5709
+ let writable, abortError, aborted;
5448
5710
  try {
5449
5711
  if (!checkOverlappingEntryOnly) {
5450
5712
  if (checkPasswordOnly) {
@@ -5454,24 +5716,28 @@ class ZipEntry {
5454
5716
  await initStream(writer, getDecodableOutputSize(outputSize, compressedSize, compressed));
5455
5717
  ({ writable } = writer);
5456
5718
  const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
5457
- writer.size += writtenSize;
5458
5719
  if (writtenSize != outputSize) {
5459
- throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
5720
+ throw Object.assign(new Error(ERR_INVALID_UNCOMPRESSED_SIZE), { outputSize: writtenSize });
5460
5721
  }
5722
+ writer.size += writtenSize;
5461
5723
  }
5462
5724
  } catch (error) {
5463
- if (error.outputSize !== UNDEFINED_VALUE) {
5725
+ const { outputSize: failedOutputSize } = workerOptions;
5726
+ if (failedOutputSize !== UNDEFINED_VALUE) {
5727
+ writer.size += failedOutputSize;
5728
+ } else if (isErrorObject(error) && error.outputSize !== UNDEFINED_VALUE) {
5464
5729
  writer.size += error.outputSize;
5465
5730
  }
5466
- if (!checkPasswordOnly || error.message != ERR_ABORT_CHECK_PASSWORD) {
5731
+ if (!checkPasswordOnly || !isErrorObject(error) || error.message != ERR_ABORT_CHECK_PASSWORD) {
5467
5732
  abortError = error;
5733
+ aborted = true;
5468
5734
  throw error;
5469
5735
  }
5470
5736
  } finally {
5471
5737
  const preventClose = !ownsWritable(writer) && getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
5472
5738
  if (!preventClose && writable && !writable.locked) {
5473
5739
  const writableWriter = writable.getWriter();
5474
- if (abortError) {
5740
+ if (aborted) {
5475
5741
  try {
5476
5742
  await writableWriter.abort(abortError);
5477
5743
  } catch {
@@ -6123,7 +6389,7 @@ function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, chec
6123
6389
  if (checkLocalFilename && !maskedLocalDirectory &&
6124
6390
  (rawLocalFilename.length != rawFilename.length ||
6125
6391
  rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
6126
- reportAmbiguity(reject, warnings, "mismatched local file header (filename)");
6392
+ reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME);
6127
6393
  }
6128
6394
  if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
6129
6395
  reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG);
@@ -6148,16 +6414,6 @@ function reportAmbiguity(reject, warnings, reason) {
6148
6414
  }
6149
6415
  }
6150
6416
 
6151
- function addWarning(warnings, reason, filename) {
6152
- if (!warnings.some(warning => warning.reason == reason)) {
6153
- const warning = { reason };
6154
- if (filename !== UNDEFINED_VALUE) {
6155
- warning.filename = filename;
6156
- }
6157
- warnings.push(warning);
6158
- }
6159
- }
6160
-
6161
6417
  function throwAmbiguousArchive(reason) {
6162
6418
  const error = new Error(ERR_AMBIGUOUS_ARCHIVE);
6163
6419
  error.reason = reason;
@@ -6237,7 +6493,9 @@ var zipReader = /*#__PURE__*/Object.freeze({
6237
6493
  WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG: WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG,
6238
6494
  WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD: WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD,
6239
6495
  WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES: WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES,
6496
+ WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME: WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME,
6240
6497
  WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY: WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY,
6498
+ WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY: WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY,
6241
6499
  WARNING_PREPENDED_CENTRAL_DIRECTORY: WARNING_PREPENDED_CENTRAL_DIRECTORY,
6242
6500
  WARNING_PREPENDED_DATA: WARNING_PREPENDED_DATA,
6243
6501
  WARNING_TRAILING_CENTRAL_DIRECTORY_DATA: WARNING_TRAILING_CENTRAL_DIRECTORY_DATA,
@@ -6290,7 +6548,7 @@ const ERR_INVALID_VERSION = "Version exceeds 65535";
6290
6548
  const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
6291
6549
  const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
6292
6550
  const ERR_UNSUPPORTED_SPLIT_USDZ = "Split zip files are not supported in USDZ files";
6293
- const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
6551
+ const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set to true (use 'compressed' instead)";
6294
6552
  const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
6295
6553
  const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
6296
6554
  const ERR_INVALID_EXTRAFIELD_DATA_TYPE = "Invalid extra field data (must be a Uint8Array)";
@@ -6302,6 +6560,7 @@ const MAX_NTFS_TIME = BigInt("0x7fffffffffffffff");
6302
6560
  const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
6303
6561
  const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
6304
6562
  const ERR_UNDEFINED_COMPRESSION_METHOD = "Undefined compression method";
6563
+ const ERR_UNDEFINED_CRC32 = "Undefined CRC32";
6305
6564
  const ERR_UNDETERMINED_SIZE = "Undetermined size";
6306
6565
  const ERR_UNDEFINED_READER = "Undefined reader";
6307
6566
  const ERR_INVALID_READER = "Invalid reader (must be a Reader instance, a ReadableStream instance, or an object with a 'readable' property)";
@@ -6315,14 +6574,21 @@ const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be intege
6315
6574
  const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
6316
6575
  const ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
6317
6576
  const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
6577
+ const ERR_INVALID_ENTRY = "Invalid entry option (must be an entry returned by ZipReader#getEntries())";
6578
+ const ERR_ZIP_CRYPTO_LAST_MOD_DATE = "The last modification date of an entry encrypted with ZipCrypto cannot be changed when passThrough is set";
6579
+ const WARNING_COMPRESSION_UNAVAILABLE = "compression unavailable";
6580
+ const WARNING_CLAMPED_LAST_MODIFICATION_DATE = "clamped last modification date";
6318
6581
 
6319
6582
  const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
6320
6583
  const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
6321
6584
  const EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD = 9;
6322
6585
  const EXTRAFIELD_USDZ_MAX_LENGTH = 67;
6586
+ const MIN_PRINTABLE_ASCII_CHARACTER_CODE = 0x20;
6587
+ const MAX_PRINTABLE_ASCII_CHARACTER_CODE = 0x7e;
6323
6588
  const VENDOR_VERSION_AE_1 = 1;
6324
6589
  const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
6325
6590
  const UNIX_EXTRA_FIELD_TYPE = "unix";
6591
+ const LEVEL_BY_BITFLAG_LEVEL = [8, 9, 5, 3];
6326
6592
  const MAX_LEVEL = 9;
6327
6593
 
6328
6594
  let workers = 0;
@@ -6349,9 +6615,11 @@ class ZipWriter {
6349
6615
  initialOffset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : options[OPTION_OFFSET] - (writer.size || writer.writable.size || 0),
6350
6616
  pendingAddFileCalls: new Set(),
6351
6617
  pendingErrors: [],
6618
+ warnings: [],
6352
6619
  bufferedWrites: 0,
6353
6620
  directWrites: 0,
6354
- lastFileEntry: UNDEFINED_VALUE
6621
+ lastFileEntry: UNDEFINED_VALUE,
6622
+ archiveClosed: false
6355
6623
  });
6356
6624
  }
6357
6625
 
@@ -6516,6 +6784,9 @@ class ZipWriter {
6516
6784
  const zipWriter = this;
6517
6785
  const { pendingAddFileCalls, writer } = this;
6518
6786
  const { writable } = writer;
6787
+ if (zipWriter.archiveClosed) {
6788
+ return getWriterData(writer);
6789
+ }
6519
6790
  if (!(comment instanceof Uint8Array)) {
6520
6791
  throw new Error(ERR_INVALID_COMMENT_TYPE);
6521
6792
  }
@@ -6526,7 +6797,7 @@ class ZipWriter {
6526
6797
  await Promise.allSettled(Array.from(pendingAddFileCalls));
6527
6798
  }
6528
6799
  await Promise.allSettled(zipWriter.pendingErrors.map(watcher => watcher.recorded));
6529
- const unobservedWatchers = zipWriter.pendingErrors.filter(watcher => watcher.error && !watcher.observed);
6800
+ const unobservedWatchers = zipWriter.pendingErrors.filter(watcher => watcher.failed && !watcher.observed);
6530
6801
  if (unobservedWatchers.length) {
6531
6802
  const unobservedErrors = unobservedWatchers.map(watcher => watcher.error);
6532
6803
  unobservedWatchers.forEach(watcher => watcher.observed = true);
@@ -6539,11 +6810,16 @@ class ZipWriter {
6539
6810
  throw error;
6540
6811
  }
6541
6812
  await closeFile(zipWriter, comment, options);
6813
+ zipWriter.archiveClosed = true;
6542
6814
  const preventClose = !ownsWritable(writer) && getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
6543
6815
  if (!preventClose) {
6544
6816
  await writable.getWriter().close();
6545
6817
  }
6546
- return writer.getData ? writer.getData() : writable;
6818
+ return getWriterData(writer);
6819
+ }
6820
+
6821
+ [SYMBOL_ASYNC_DISPOSE]() {
6822
+ return this.close();
6547
6823
  }
6548
6824
  }
6549
6825
 
@@ -6622,11 +6898,16 @@ class WatchedPromise extends Promise {
6622
6898
  }
6623
6899
  }
6624
6900
 
6901
+ function getWriterData(writer) {
6902
+ return writer.getData ? writer.getData() : writer.writable;
6903
+ }
6904
+
6625
6905
  function watchPromiseError(zipWriter, promise) {
6626
6906
  const watchedPromise = new WatchedPromise((resolve, reject) => Promise.prototype.then.call(promise, resolve, reject));
6627
6907
  const watcher = {};
6628
6908
  watchedPromise.watcher = watcher;
6629
- watcher.recorded = Promise.prototype.then.call(watchedPromise, UNDEFINED_VALUE, error => watcher.error = error);
6909
+ watcher.recorded = Promise.prototype.then.call(watchedPromise, UNDEFINED_VALUE,
6910
+ error => Object.assign(watcher, { failed: true, error }));
6630
6911
  zipWriter.pendingErrors.push(watcher);
6631
6912
  return watchedPromise;
6632
6913
  }
@@ -6640,6 +6921,14 @@ async function prependZipEntries(zipWriter, reader) {
6640
6921
 
6641
6922
  async function addFileEntry(zipWriter, name, reader, options) {
6642
6923
  options = Object.assign({}, options);
6924
+ const entry = options[OPTION_ENTRY];
6925
+ if (entry !== UNDEFINED_VALUE) {
6926
+ const { entryOptions, passThroughOptions } = getSourceEntryOptions(entry,
6927
+ checkPassThroughOption(getOptionValue(zipWriter, options, OPTION_PASS_THROUGH)),
6928
+ getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE));
6929
+ delete options[OPTION_ENTRY];
6930
+ options = Object.assign(entryOptions, passThroughOptions, options);
6931
+ }
6643
6932
  if (getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY) && !name.endsWith(DIRECTORY_SIGNATURE)) {
6644
6933
  name += DIRECTORY_SIGNATURE;
6645
6934
  }
@@ -6704,21 +6993,33 @@ async function addFile(zipWriter, name, reader, options) {
6704
6993
  try {
6705
6994
  const { resolvedOptions } = metadataInfo;
6706
6995
  if (resolvedOptions.level != 0 && resolvedOptions.compressionMethod === UNDEFINED_VALUE &&
6707
- !resolvedOptions.passThrough && !(await supportsDeflate(getConfiguration()))) {
6996
+ !resolvedOptions.passThroughCompression && !(await supportsDeflate(getConfiguration()))) {
6708
6997
  resolvedOptions.level = 0;
6998
+ addWarning(zipWriter.warnings, WARNING_COMPRESSION_UNAVAILABLE, name);
6709
6999
  }
6710
7000
  const sizesInfo = await resolveSizes(zipWriter, reader, metadataInfo, options);
6711
7001
  ({ reader } = sizesInfo);
6712
7002
  const diskOffset = getDiskOffset(zipWriter.writer);
6713
7003
  const diskNumber = getDiskNumber(zipWriter.writer);
7004
+ let crc32 = options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32;
7005
+ const storesAE2 = sizesInfo.resolvedOptions.encrypted && !resolvedOptions.zipCrypto;
7006
+ if (resolvedOptions.passThroughCompression && !resolvedOptions.passThroughEncryption && storesAE2) {
7007
+ crc32 = UNDEFINED_VALUE;
7008
+ }
7009
+ if (resolvedOptions.passThroughCompression && reader && !storesAE2 && crc32 === UNDEFINED_VALUE) {
7010
+ throw new Error(ERR_UNDEFINED_CRC32);
7011
+ }
6714
7012
  options = Object.assign({}, options, attributesInfo.resolvedOptions, metadataInfo.resolvedOptions, sizesInfo.resolvedOptions, {
6715
7013
  signature: options[PROPERTY_NAME_SIGNATURE],
6716
- crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
7014
+ crc32,
6717
7015
  offset: zipWriter.offset - diskOffset,
6718
7016
  diskNumberStart: diskNumber,
6719
7017
  [OPTION_USDZ]: zipWriter.options[OPTION_USDZ]
6720
7018
  });
6721
7019
  const headerInfo = getHeaderInfo(options);
7020
+ if (headerInfo.lastModDateClamped) {
7021
+ addWarning(zipWriter.warnings, WARNING_CLAMPED_LAST_MODIFICATION_DATE, name);
7022
+ }
6722
7023
  const dataDescriptorInfo = getDataDescriptorInfo(options);
6723
7024
  const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
6724
7025
  fileEntry = await getFileEntry(zipWriter, name, reader, {
@@ -6745,6 +7046,95 @@ async function addFile(zipWriter, name, reader, options) {
6745
7046
  return new Entry(fileEntry);
6746
7047
  }
6747
7048
 
7049
+ function getSourceEntryOptions(entry, passThrough, lastModDateOverride) {
7050
+ if (entry === null || typeof entry != OBJECT_TYPE || Array.isArray(entry)) {
7051
+ throw new Error(ERR_INVALID_ENTRY);
7052
+ }
7053
+ const {
7054
+ externalFileAttributes,
7055
+ versionMadeBy,
7056
+ comment,
7057
+ lastModDate,
7058
+ rawLastModDate,
7059
+ creationDate,
7060
+ lastAccessDate,
7061
+ uncompressedSize,
7062
+ encrypted,
7063
+ zipCrypto,
7064
+ crc32,
7065
+ compressionMethod,
7066
+ extraFieldAES,
7067
+ extraFieldUnix,
7068
+ internalFileAttributes,
7069
+ extraField,
7070
+ bitFlag,
7071
+ directory,
7072
+ uid,
7073
+ gid
7074
+ } = entry;
7075
+ const entryOptions = {
7076
+ externalFileAttributes,
7077
+ versionMadeBy,
7078
+ comment,
7079
+ lastModDate,
7080
+ creationDate,
7081
+ lastAccessDate,
7082
+ internalFileAttributes,
7083
+ directory
7084
+ };
7085
+ if (bitFlag && bitFlag.languageEncodingFlag) {
7086
+ entryOptions[OPTION_USE_UNICODE_FILE_NAMES] = true;
7087
+ }
7088
+ const userExtraField = getUserExtraField(extraField);
7089
+ if (userExtraField) {
7090
+ entryOptions[PROPERTY_NAME_EXTRA_FIELD] = userExtraField;
7091
+ }
7092
+ if (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE) {
7093
+ Object.assign(entryOptions, {
7094
+ uid,
7095
+ gid,
7096
+ unixExtraFieldType: extraFieldUnix ? UNIX_EXTRA_FIELD_TYPE : INFOZIP_EXTRA_FIELD_TYPE
7097
+ });
7098
+ }
7099
+ const passThroughOptions = {};
7100
+ if (passThrough && !directory) {
7101
+ Object.assign(passThroughOptions, {
7102
+ uncompressedSize,
7103
+ crc32,
7104
+ compressionMethod
7105
+ });
7106
+ if (passThrough !== PASS_THROUGH_COMPRESSED) {
7107
+ Object.assign(passThroughOptions, {
7108
+ encrypted,
7109
+ zipCrypto,
7110
+ encryptionStrength: extraFieldAES ? extraFieldAES.strength : UNDEFINED_VALUE
7111
+ });
7112
+ }
7113
+ if (bitFlag) {
7114
+ passThroughOptions.dataDescriptor = bitFlag.dataDescriptor;
7115
+ passThroughOptions[OPTION_LEVEL] = LEVEL_BY_BITFLAG_LEVEL[bitFlag.level];
7116
+ }
7117
+ if (lastModDateOverride === UNDEFINED_VALUE) {
7118
+ passThroughOptions.rawLastModDate = rawLastModDate;
7119
+ } else if (passThrough !== PASS_THROUGH_COMPRESSED && zipCrypto && (!bitFlag || bitFlag.dataDescriptor) &&
7120
+ lastModDateOverride instanceof Date &&
7121
+ getDosTimeHighByte(lastModDateOverride) != ((rawLastModDate >>> 8) & MAX_8_BITS)) {
7122
+ throw new Error(ERR_ZIP_CRYPTO_LAST_MOD_DATE);
7123
+ }
7124
+ }
7125
+ return { entryOptions, passThroughOptions };
7126
+ }
7127
+
7128
+ function getDosTimeHighByte(lastModDate) {
7129
+ let dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
7130
+ if (dosLastModDate < MIN_DATE) {
7131
+ dosLastModDate = MIN_DATE;
7132
+ } else if (dosLastModDate > MAX_DATE) {
7133
+ dosLastModDate = MAX_DATE;
7134
+ }
7135
+ return ((dosLastModDate.getHours() << 3) | (dosLastModDate.getMinutes() >> 3)) & MAX_8_BITS;
7136
+ }
7137
+
6748
7138
  function resolveAttributes(zipWriter, name, options) {
6749
7139
  let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
6750
7140
  let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? VERSION_MADE_BY_MSDOS : VERSION_MADE_BY_UNIX);
@@ -6898,7 +7288,9 @@ function resolveMetadata(zipWriter, name, options) {
6898
7288
  const lastAccessDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
6899
7289
  const creationDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
6900
7290
  const internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, 0);
6901
- const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
7291
+ const passThrough = checkPassThroughOption(getOptionValue(zipWriter, options, OPTION_PASS_THROUGH));
7292
+ const passThroughCompression = Boolean(passThrough);
7293
+ const passThroughEncryption = passThrough === true;
6902
7294
  const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
6903
7295
  const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
6904
7296
  checkPasswordOption(password, rawPassword);
@@ -6914,10 +7306,11 @@ function resolveMetadata(zipWriter, name, options) {
6914
7306
  const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
6915
7307
  const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
6916
7308
  throwIfAborted(signal);
6917
- const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
7309
+ const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES,
7310
+ !isPrintableASCIIText(rawFilename) || !isPrintableASCIIText(rawComment));
6918
7311
  const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
6919
- const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
6920
- if (!passThrough && compressionMethod !== UNDEFINED_VALUE &&
7312
+ const registeredCodec = passThroughCompression || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
7313
+ if (!passThroughCompression && compressionMethod !== UNDEFINED_VALUE &&
6921
7314
  compressionMethod !== COMPRESSION_METHOD_STORE && compressionMethod !== COMPRESSION_METHOD_DEFLATE && !registeredCodec) {
6922
7315
  throw new Error(ERR_UNSUPPORTED_COMPRESSION);
6923
7316
  }
@@ -6931,15 +7324,15 @@ function resolveMetadata(zipWriter, name, options) {
6931
7324
  level = 0;
6932
7325
  }
6933
7326
  }
6934
- if (passThrough) {
6935
- level = UNDEFINED_VALUE;
7327
+ if (passThroughCompression) {
7328
+ level = toNumber(options[OPTION_LEVEL]);
6936
7329
  }
6937
7330
  let useCompressionStream = getOptionValue(zipWriter, options, OPTION_USE_COMPRESSION_STREAM);
6938
7331
  let dataDescriptor = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR);
6939
7332
  if (bufferedWrite && dataDescriptor === UNDEFINED_VALUE) {
6940
7333
  dataDescriptor = false;
6941
7334
  }
6942
- if (dataDescriptor === UNDEFINED_VALUE || (zipCrypto && !passThrough)) {
7335
+ if (dataDescriptor === UNDEFINED_VALUE || (zipCrypto && !passThroughEncryption)) {
6943
7336
  dataDescriptor = true;
6944
7337
  }
6945
7338
  if (level !== UNDEFINED_VALUE && level != 6) {
@@ -6963,7 +7356,8 @@ function resolveMetadata(zipWriter, name, options) {
6963
7356
  lastAccessDate,
6964
7357
  creationDate,
6965
7358
  internalFileAttributes,
6966
- passThrough,
7359
+ passThroughCompression,
7360
+ passThroughEncryption,
6967
7361
  password,
6968
7362
  rawPassword,
6969
7363
  encryptionStrength,
@@ -7024,7 +7418,7 @@ function serializeExtraField(extraField) {
7024
7418
  }
7025
7419
 
7026
7420
  async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, options) {
7027
- if (metadata.passThrough && !reader && !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY)) {
7421
+ if (metadata.passThroughCompression && !reader && !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY)) {
7028
7422
  throw new Error(ERR_UNDEFINED_READER);
7029
7423
  }
7030
7424
  let contentSize;
@@ -7040,12 +7434,12 @@ async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, op
7040
7434
  }
7041
7435
 
7042
7436
  function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options) {
7043
- const { passThrough, zipCrypto, password, rawPassword, encryptionStrength } = metadata;
7437
+ const { passThroughCompression, passThroughEncryption, zipCrypto, password, rawPassword, encryptionStrength } = metadata;
7044
7438
  let { dataDescriptor, zip64, level, compressionMethod } = metadata;
7045
7439
  let maximumCompressedSize = 0;
7046
7440
  let uncompressedSize = 0;
7047
7441
  let unknownSize = false;
7048
- if (passThrough && hasContent) {
7442
+ if (passThroughCompression && hasContent) {
7049
7443
  uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
7050
7444
  if (uncompressedSize === UNDEFINED_VALUE) {
7051
7445
  throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
@@ -7056,17 +7450,17 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
7056
7450
  }
7057
7451
  const zip64Enabled = zip64 === true;
7058
7452
  const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
7059
- if (hasContent && passThrough && !encrypted && getLength(password, rawPassword)) {
7453
+ if (hasContent && passThroughEncryption && !encrypted && getLength(password, rawPassword)) {
7060
7454
  throw new Error(ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH);
7061
7455
  }
7062
- const encryptedEntry = hasContent && (Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted));
7456
+ const encryptedEntry = hasContent && (Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThroughEncryption && encrypted));
7063
7457
  if (!hasContent) {
7064
7458
  level = 0;
7065
7459
  compressionMethod = COMPRESSION_METHOD_STORE;
7066
7460
  }
7067
- const encryptionOverhead = encryptedEntry ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
7461
+ const encryptionOverhead = getEncryptionOverhead(encryptedEntry, zipCrypto, encryptionStrength);
7068
7462
  if (hasContent) {
7069
- if (!passThrough) {
7463
+ if (!passThroughCompression) {
7070
7464
  if (contentSize === UNDEFINED_VALUE) {
7071
7465
  dataDescriptor = true;
7072
7466
  if (zip64 || zip64 === UNDEFINED_VALUE) {
@@ -7079,10 +7473,12 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
7079
7473
  }
7080
7474
  } else {
7081
7475
  options.uncompressedSize = uncompressedSize;
7082
- maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
7476
+ maximumCompressedSize = contentSize === UNDEFINED_VALUE ?
7477
+ getMaximumCompressedSize(uncompressedSize) + encryptionOverhead :
7478
+ contentSize + (passThroughEncryption ? 0 : encryptionOverhead);
7083
7479
  }
7084
7480
  }
7085
- const emptyEntry = !encryptedEntry && (!hasContent || (contentSize === 0 && !passThrough)) && !isCompressed(compressionMethod, level);
7481
+ const emptyEntry = !encryptedEntry && (!hasContent || (contentSize === 0 && !passThroughCompression)) && !isCompressed(compressionMethod, level);
7086
7482
  if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
7087
7483
  dataDescriptor = false;
7088
7484
  }
@@ -7289,6 +7685,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
7289
7685
  localExtraFieldZip64Length,
7290
7686
  rawExtraFieldExtendedTimestamp,
7291
7687
  extraFieldExtendedTimestampFlag,
7688
+ extraFieldExtendedTimestampTime,
7292
7689
  rawExtraFieldNTFS,
7293
7690
  rawExtraFieldUnix,
7294
7691
  rawExtraFieldAES,
@@ -7301,6 +7698,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
7301
7698
  password,
7302
7699
  rawPassword,
7303
7700
  level,
7701
+ useUnicodeFileNames,
7304
7702
  zip64,
7305
7703
  zip64Enabled,
7306
7704
  zip64UncompressedSize,
@@ -7335,7 +7733,8 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
7335
7733
  msdosAttributesRaw,
7336
7734
  msdosAttributes,
7337
7735
  useCompressionStream,
7338
- passThrough,
7736
+ passThroughCompression,
7737
+ passThroughEncryption,
7339
7738
  format,
7340
7739
  codecURI
7341
7740
  } = options;
@@ -7346,9 +7745,9 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
7346
7745
  zip64Enabled,
7347
7746
  directory: Boolean(directory),
7348
7747
  executable: Boolean(executable),
7349
- filenameUTF8: true,
7748
+ filenameUTF8: Boolean(useUnicodeFileNames),
7350
7749
  rawFilename,
7351
- commentUTF8: true,
7750
+ commentUTF8: Boolean(useUnicodeFileNames),
7352
7751
  rawComment,
7353
7752
  rawExtraFieldZip64,
7354
7753
  localExtraFieldZip64Length,
@@ -7379,7 +7778,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
7379
7778
  uncompressedSize
7380
7779
  } = options;
7381
7780
  let compressedSize = 0;
7382
- if (!passThrough) {
7781
+ if (!passThroughCompression) {
7383
7782
  uncompressedSize = 0;
7384
7783
  }
7385
7784
  const { writable } = writer;
@@ -7396,9 +7795,9 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
7396
7795
  encryptionStrength,
7397
7796
  zipCrypto: encrypted && zipCrypto,
7398
7797
  passwordVerification: encrypted && zipCrypto && (rawLastModDate >> 8) & MAX_8_BITS,
7399
- computeCrc32: !passThrough,
7400
- compressed: compressed && !passThrough,
7401
- encrypted: encrypted && !passThrough,
7798
+ computeCrc32: !passThroughCompression,
7799
+ compressed: compressed && !passThroughCompression,
7800
+ encrypted: encrypted && !passThroughEncryption,
7402
7801
  useWebWorkers,
7403
7802
  useCompressionStream,
7404
7803
  transferStreams,
@@ -7413,7 +7812,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
7413
7812
  const result = await runWorker({ readable, writable }, workerOptions);
7414
7813
  compressedSize = result.outputSize;
7415
7814
  writer.size += compressedSize;
7416
- if (!passThrough) {
7815
+ if (!passThroughCompression) {
7417
7816
  uncompressedSize = result.inputSize;
7418
7817
  if (!encrypted || zipCrypto) {
7419
7818
  crc32 = result.crc32;
@@ -7424,7 +7823,10 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
7424
7823
  throw new Error(ERR_UNSUPPORTED_FORMAT);
7425
7824
  }
7426
7825
  } catch (error) {
7427
- if (error.outputSize !== UNDEFINED_VALUE) {
7826
+ const { outputSize: failedOutputSize } = workerOptions;
7827
+ if (failedOutputSize !== UNDEFINED_VALUE) {
7828
+ writer.size += failedOutputSize;
7829
+ } else if (isErrorObject(error) && error.outputSize !== UNDEFINED_VALUE) {
7428
7830
  writer.size += error.outputSize;
7429
7831
  }
7430
7832
  throw error;
@@ -7456,8 +7858,9 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
7456
7858
  headerArray,
7457
7859
  headerView,
7458
7860
  signature: crc32,
7459
- crc32: encrypted && !zipCrypto && !passThrough ? UNDEFINED_VALUE : crc32,
7861
+ crc32: encrypted && !zipCrypto && !passThroughCompression ? UNDEFINED_VALUE : crc32,
7460
7862
  extraFieldExtendedTimestampFlag,
7863
+ extraFieldExtendedTimestampTime,
7461
7864
  zip64UncompressedSize,
7462
7865
  zip64CompressedSize
7463
7866
  });
@@ -7482,7 +7885,7 @@ function getHeaderInfo(options) {
7482
7885
  encryptionStrength,
7483
7886
  extendedTimestamp,
7484
7887
  ntfsTimestamp,
7485
- passThrough,
7888
+ passThroughCompression,
7486
7889
  encrypted,
7487
7890
  zip64UncompressedSize,
7488
7891
  zip64CompressedSize,
@@ -7493,7 +7896,7 @@ function getHeaderInfo(options) {
7493
7896
  let { version, compressionMethod } = options;
7494
7897
  const compressed = !directory && isCompressed(compressionMethod, level);
7495
7898
  let rawLocalExtraFieldZip64;
7496
- const uncompressedFile = passThrough || !compressed;
7899
+ const uncompressedFile = passThroughCompression || !compressed;
7497
7900
  const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || (uncompressedFile && !unknownSize)));
7498
7901
  const writeLocalExtraFieldZip64 = zip64ExtraFieldComplete || (zip64 && dataDescriptor && (zip64UncompressedSize || zip64CompressedSize));
7499
7902
  if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
@@ -7505,8 +7908,8 @@ function getHeaderInfo(options) {
7505
7908
  if (zip64ExtraFieldComplete) {
7506
7909
  extraFieldZip64.writeUint64(uncompressedSize);
7507
7910
  if (uncompressedFile) {
7508
- const encryptionOverhead = encrypted ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
7509
- extraFieldZip64.writeUint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
7911
+ const encryptionOverhead = getEncryptionOverhead(encrypted, zipCrypto, encryptionStrength);
7912
+ extraFieldZip64.writeUint64(passThroughCompression ? 0 : uncompressedSize + encryptionOverhead);
7510
7913
  }
7511
7914
  }
7512
7915
  } else {
@@ -7525,6 +7928,7 @@ function getHeaderInfo(options) {
7525
7928
  let rawExtraFieldNTFS;
7526
7929
  let rawExtraFieldExtendedTimestamp;
7527
7930
  let extraFieldExtendedTimestampFlag;
7931
+ let extraFieldExtendedTimestampTime;
7528
7932
  if (extendedTimestamp) {
7529
7933
  const lastModTimeUnix = getTimeUnix(lastModDate);
7530
7934
  const lastModTimeUnixInRange = inUnixTimeRange(lastModTimeUnix);
@@ -7532,6 +7936,7 @@ function getHeaderInfo(options) {
7532
7936
  const extraFieldTimestampLength = 9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0);
7533
7937
  const extraFieldTimestamp = createRecordWriter(extraFieldTimestampLength);
7534
7938
  extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
7939
+ extraFieldExtendedTimestampTime = lastModTimeUnix;
7535
7940
  extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7536
7941
  extraFieldTimestamp.writeUint16(extraFieldTimestampLength - 4);
7537
7942
  extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
@@ -7615,7 +8020,7 @@ function getHeaderInfo(options) {
7615
8020
  }
7616
8021
  if (encrypted && !zipCrypto) {
7617
8022
  version = version > VERSION_AES ? version : VERSION_AES;
7618
- if (passThrough && crc32 !== UNDEFINED_VALUE) {
8023
+ if (passThroughCompression && crc32 !== UNDEFINED_VALUE) {
7619
8024
  rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
7620
8025
  }
7621
8026
  setUint16(getDataView(rawExtraFieldAES), EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD, compressionMethod);
@@ -7677,12 +8082,14 @@ function getHeaderInfo(options) {
7677
8082
  headerArray,
7678
8083
  headerView,
7679
8084
  lastModDate: storedLastModDate,
8085
+ lastModDateClamped: storedLastModDate === clampedLastModDate && dosLastModDate.getTime() != clampedLastModDate.getTime(),
7680
8086
  rawLastModDate,
7681
8087
  encrypted,
7682
8088
  compressed,
7683
8089
  version,
7684
8090
  compressionMethod,
7685
8091
  extraFieldExtendedTimestampFlag,
8092
+ extraFieldExtendedTimestampTime,
7686
8093
  rawExtraFieldZip64: EMPTY_UINT8_ARRAY,
7687
8094
  localExtraFieldZip64Length,
7688
8095
  rawExtraFieldExtendedTimestamp,
@@ -7785,7 +8192,7 @@ function setEntryInfo({
7785
8192
  }, {
7786
8193
  zip64,
7787
8194
  zipCrypto,
7788
- passThrough,
8195
+ passThroughCompression,
7789
8196
  dataDescriptor
7790
8197
  }) {
7791
8198
  const {
@@ -7796,7 +8203,7 @@ function setEntryInfo({
7796
8203
  dataDescriptorView,
7797
8204
  dataDescriptorOffset
7798
8205
  } = dataDescriptorInfo;
7799
- if ((!encrypted || zipCrypto || passThrough) && crc32 !== UNDEFINED_VALUE) {
8206
+ if ((!encrypted || zipCrypto || passThroughCompression) && crc32 !== UNDEFINED_VALUE) {
7800
8207
  setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
7801
8208
  if (dataDescriptor) {
7802
8209
  setUint32(dataDescriptorView, dataDescriptorOffset, crc32);
@@ -7827,9 +8234,9 @@ function updateLocalHeader({
7827
8234
  uncompressedSize,
7828
8235
  zip64UncompressedSize,
7829
8236
  zip64CompressedSize
7830
- }, localHeaderView, { dataDescriptor, passThrough }) {
8237
+ }, localHeaderView, { dataDescriptor, passThroughCompression }) {
7831
8238
  if (!dataDescriptor) {
7832
- if (!encrypted || (passThrough && crc32 !== UNDEFINED_VALUE)) {
8239
+ if (!encrypted || (passThroughCompression && crc32 !== UNDEFINED_VALUE)) {
7833
8240
  setUint32(localHeaderView, HEADER_OFFSET_SIGNATURE + LOCAL_HEADER_COMMON_OFFSET, crc32);
7834
8241
  }
7835
8242
  if (!zip64CompressedSize) {
@@ -7866,9 +8273,8 @@ function createDirectoryRecords(files) {
7866
8273
  rawExtraFieldUnix,
7867
8274
  rawExtraField,
7868
8275
  rawCentralExtraField,
7869
- extendedTimestamp,
7870
8276
  extraFieldExtendedTimestampFlag,
7871
- lastModDate,
8277
+ extraFieldExtendedTimestampTime,
7872
8278
  zip64Enabled,
7873
8279
  uncompressedSize,
7874
8280
  compressedSize
@@ -7911,16 +8317,15 @@ function createDirectoryRecords(files) {
7911
8317
  fileEntry.zip64Offset = zip64Offset;
7912
8318
  fileEntry.zip64DiskNumberStart = zip64DiskNumberStart;
7913
8319
  let rawExtraFieldTimestamp;
7914
- const lastModTimeUnix = getTimeUnix(lastModDate);
7915
- if (extendedTimestamp && inUnixTimeRange(lastModTimeUnix)) {
8320
+ if (extraFieldExtendedTimestampTime === UNDEFINED_VALUE) {
8321
+ rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
8322
+ } else {
7916
8323
  const extraFieldTimestamp = createRecordWriter(9);
7917
8324
  extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7918
8325
  extraFieldTimestamp.writeUint16(5);
7919
8326
  extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
7920
- extraFieldTimestamp.writeUint32(lastModTimeUnix);
8327
+ extraFieldTimestamp.writeUint32(extraFieldExtendedTimestampTime);
7921
8328
  rawExtraFieldTimestamp = extraFieldTimestamp.array;
7922
- } else {
7923
- rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
7924
8329
  }
7925
8330
  fileEntry.rawExtraFieldExtendedTimestamp = rawExtraFieldTimestamp;
7926
8331
  const extraFieldLength = getLength(
@@ -8420,6 +8825,11 @@ function getHeaderArrayData({
8420
8825
  };
8421
8826
  }
8422
8827
 
8828
+ function isPrintableASCIIText(rawText) {
8829
+ return rawText.every(characterCode =>
8830
+ characterCode >= MIN_PRINTABLE_ASCII_CHARACTER_CODE && characterCode <= MAX_PRINTABLE_ASCII_CHARACTER_CODE);
8831
+ }
8832
+
8423
8833
  function getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod) {
8424
8834
  let bitFlag = 0;
8425
8835
  if (useUnicodeFileNames) {
@@ -8581,7 +8991,7 @@ function formatSupported(StreamClass, format) {
8581
8991
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8582
8992
  */
8583
8993
 
8584
- const VERSION = "2.11.4";
8994
+ const VERSION = "2.13.0";
8585
8995
 
8586
8996
  /*
8587
8997
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
@@ -9401,9 +9811,9 @@ setDefaultConfiguration({
9401
9811
  DecompressionStreamFallback: DecompressionStreamZlib
9402
9812
  });
9403
9813
 
9404
- function terminateWorkersAndModule() {
9814
+ async function terminateWorkersAndModule() {
9815
+ await terminateWorkers();
9405
9816
  modulePromise = null;
9406
- terminateWorkers();
9407
9817
  resetWasmModule();
9408
9818
  }
9409
9819
 
@@ -9412,4 +9822,4 @@ function terminateWorkersAndModule() {
9412
9822
 
9413
9823
  configureExternalAssets();
9414
9824
 
9415
- 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_DATA_OUT_OF_BOUNDS, 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_COMMENT_TYPE, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_DATE, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_COMMENT_TYPE, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_DATA_TYPE, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_FUNCTION_OPTION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MAX_WORKERS, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_READER, ERR_INVALID_SIGNAL, 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_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_COMPRESSION_METHOD, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_UNSUPPORTED_SPLIT_USDZ, ERR_UNSUPPORTED_UINT64, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, VERSION, WARNING_APPENDED_DATA, WARNING_COMPRESSED_PATCHED_DATA, WARNING_DUPLICATE_FILENAME, WARNING_MALFORMED_EXTRA_FIELD, WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG, WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD, WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY, WARNING_PREPENDED_CENTRAL_DIRECTORY, WARNING_PREPENDED_DATA, WARNING_TRAILING_CENTRAL_DIRECTORY_DATA, WARNING_UNKNOWN_VERSION, WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA, WARNING_UNSORTED_CENTRAL_DIRECTORY, WARNING_WRAPPED_ENTRIES_COUNT, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, getMimeType, getRegisteredCodecs, getSupportedCompressionMethods, isZipFile, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
9825
+ 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_DATA_OUT_OF_BOUNDS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_HTTP_STATUS, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_BASE_URI, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMMENT_TYPE, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_DATE, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_COMMENT_TYPE, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_DATA_TYPE, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_FUNCTION_OPTION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MAX_WORKERS, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_PASS_THROUGH_VALUE, ERR_INVALID_READER, ERR_INVALID_SIGNAL, 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_URI, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_COMPRESSION_METHOD, ERR_UNDEFINED_CRC32, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_UNSUPPORTED_SPLIT_USDZ, ERR_UNSUPPORTED_UINT64, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_WRITER_SIZE_NOT_WRITABLE, ERR_ZIP_CRYPTO_LAST_MOD_DATE, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, VERSION, WARNING_APPENDED_DATA, WARNING_CLAMPED_LAST_MODIFICATION_DATE, WARNING_COMPRESSED_PATCHED_DATA, WARNING_COMPRESSION_UNAVAILABLE, WARNING_DUPLICATE_FILENAME, WARNING_MALFORMED_EXTRA_FIELD, WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG, WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD, WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES, WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY, WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY, WARNING_PREPENDED_CENTRAL_DIRECTORY, WARNING_PREPENDED_DATA, WARNING_TRAILING_CENTRAL_DIRECTORY_DATA, WARNING_UNKNOWN_VERSION, WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA, WARNING_UNSORTED_CENTRAL_DIRECTORY, WARNING_WRAPPED_ENTRIES_COUNT, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, getMimeType, getRegisteredCodecs, getSupportedCompressionMethods, isZipFile, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };