@zip.js/zip.js 2.11.3 → 2.12.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 (50) hide show
  1. package/deno.json +1 -1
  2. package/dist/zip-core-external.js +444 -114
  3. package/dist/zip-core-external.min.js +1 -1
  4. package/dist/zip-core.js +454 -111
  5. package/dist/zip-core.min.js +1 -1
  6. package/dist/zip-fs-core-external.js +509 -236
  7. package/dist/zip-fs-core-external.min.js +1 -1
  8. package/dist/zip-fs-core.js +522 -233
  9. package/dist/zip-fs-core.min.js +1 -1
  10. package/dist/zip-fs-external.js +509 -236
  11. package/dist/zip-fs-external.min.js +1 -1
  12. package/dist/zip-fs-native.js +524 -235
  13. package/dist/zip-fs-native.min.js +1 -1
  14. package/dist/zip-fs.js +525 -236
  15. package/dist/zip-fs.min.js +1 -1
  16. package/dist/zip-legacy.js +456 -113
  17. package/dist/zip-legacy.min.js +1 -1
  18. package/dist/zip-native.js +456 -113
  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 +457 -114
  23. package/dist/zip.min.js +1 -1
  24. package/index-native.cjs +524 -235
  25. package/index-native.min.js +1 -1
  26. package/index.cjs +525 -236
  27. package/index.d.cts +480 -59
  28. package/index.d.ts +480 -59
  29. package/index.min.js +1 -1
  30. package/lib/core/codec-worker-web.js +10 -2
  31. package/lib/core/codec-worker.js +4 -3
  32. package/lib/core/configuration.js +20 -5
  33. package/lib/core/constants.js +2 -0
  34. package/lib/core/io.js +20 -10
  35. package/lib/core/options.js +29 -0
  36. package/lib/core/streams/codec-stream.js +6 -0
  37. package/lib/core/util/warnings.js +42 -0
  38. package/lib/core/version.js +1 -1
  39. package/lib/core/web-worker-base.js +4 -3
  40. package/lib/core/web-worker-inline-native.js +1 -1
  41. package/lib/core/web-worker-inline-wasm.js +1 -1
  42. package/lib/core/zip-entry.js +49 -1
  43. package/lib/core/zip-fs.js +43 -134
  44. package/lib/core/zip-reader.js +108 -47
  45. package/lib/core/zip-writer.js +238 -54
  46. package/lib/zip-core-base.js +9 -3
  47. package/lib/zip-core-reader.js +2 -0
  48. package/lib/zip-core-writer.js +6 -1
  49. package/lib/zip-module-wasm-base.js +2 -2
  50. package/package.json +5 -3
@@ -134,6 +134,7 @@
134
134
  const BOOLEAN_TYPE = "boolean";
135
135
 
136
136
  const EMPTY_UINT8_ARRAY = new Uint8Array();
137
+ const SYMBOL_ASYNC_DISPOSE = Symbol.asyncDispose || Symbol();
137
138
 
138
139
  /*
139
140
  Copyright (c) 2022 Gildas Lormeau. All rights reserved.
@@ -178,6 +179,7 @@
178
179
  const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
179
180
  const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
180
181
  const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
182
+ const OPTION_CHECK_LOCAL_FILENAME = "checkLocalFilename";
181
183
  const OPTION_CHECK_SIGNATURE = "checkSignature";
182
184
  const OPTION_CHECK_CRC32 = "checkCrc32";
183
185
  const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
@@ -208,15 +210,20 @@
208
210
  const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
209
211
  const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
210
212
  const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
213
+ const OPTION_ENTRY = "entry";
211
214
  const TEXT_TYPE_FILENAME = "filename";
212
215
  const TEXT_TYPE_COMMENT = "comment";
213
216
  const STRICTNESS_STRICT = "strict";
214
217
  const STRICTNESS_BALANCED = "balanced";
215
218
  const STRICTNESS_TOLERANT = "tolerant";
219
+ const PASS_THROUGH_COMPRESSED = "compressed";
216
220
 
217
221
  const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
218
222
  const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
219
223
  const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
224
+ const ERR_INVALID_PASS_THROUGH_VALUE = "Invalid passThrough option (must be a boolean or 'compressed')";
225
+ const ERR_ABORTED = "The operation was aborted";
226
+ const ABORT_ERROR_NAME = "AbortError";
220
227
 
221
228
  function checkFunctionOption(value) {
222
229
  if (value && typeof value != FUNCTION_TYPE) {
@@ -232,12 +239,25 @@
232
239
  return signal || UNDEFINED_VALUE;
233
240
  }
234
241
 
242
+ function throwIfAborted(signal) {
243
+ if (signal && signal.aborted) {
244
+ throw signal.reason === UNDEFINED_VALUE ? new DOMException(ERR_ABORTED, ABORT_ERROR_NAME) : signal.reason;
245
+ }
246
+ }
247
+
235
248
  function checkPasswordOption(password, rawPassword) {
236
249
  if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
237
250
  throw new Error(ERR_INVALID_PASSWORD_TYPE);
238
251
  }
239
252
  }
240
253
 
254
+ function checkPassThroughOption(passThrough) {
255
+ if (passThrough !== UNDEFINED_VALUE && typeof passThrough != BOOLEAN_TYPE && passThrough !== PASS_THROUGH_COMPRESSED) {
256
+ throw new Error(ERR_INVALID_PASS_THROUGH_VALUE);
257
+ }
258
+ return passThrough;
259
+ }
260
+
241
261
  function checkInteger(value, maxValue, errorMessage) {
242
262
  if (!Number.isInteger(value) || value < 0 || value > maxValue) {
243
263
  throw new Error(errorMessage);
@@ -287,6 +307,8 @@
287
307
  const MINIMUM_CHUNK_SIZE = 64;
288
308
  const MINIMUM_PROPERTY_VALUE = 1;
289
309
  const ERR_INVALID_MAX_WORKERS = "Invalid maxWorkers (must be an integer greater than 0)";
310
+ const ERR_INVALID_BASE_URI = "Invalid baseURI (must be a string)";
311
+ const ERR_INVALID_URI = "Invalid URI (must be a string or a function returning a string)";
290
312
  let maxWorkers = 2;
291
313
  try {
292
314
  if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
@@ -311,9 +333,9 @@
311
333
  };
312
334
 
313
335
  const PROPERTY_NAME_MAX_WORKERS = "maxWorkers";
336
+ const PROPERTY_NAME_BASE_URI = "baseURI";
314
337
 
315
- const STRING_PROPERTY_NAMES = [
316
- "baseURI",
338
+ const URI_PROPERTY_NAMES = [
317
339
  "wasmURI",
318
340
  "workerURI"
319
341
  ];
@@ -337,7 +359,8 @@
337
359
  "DecompressionStreamFallback"
338
360
  ];
339
361
  const CONFIGURABLE_PROPERTY_NAMES = [
340
- ...STRING_PROPERTY_NAMES,
362
+ PROPERTY_NAME_BASE_URI,
363
+ ...URI_PROPERTY_NAMES,
341
364
  ...BOOLEAN_PROPERTY_NAMES,
342
365
  ...NUMBER_PROPERTY_NAMES,
343
366
  ...FUNCTION_PROPERTY_NAMES
@@ -381,6 +404,14 @@
381
404
  }
382
405
  } else if (FUNCTION_PROPERTY_NAMES.includes(propertyName)) {
383
406
  checkFunctionOption(propertyValue);
407
+ } else if (propertyName == PROPERTY_NAME_BASE_URI) {
408
+ if (propertyValue && typeof propertyValue != STRING_TYPE) {
409
+ throw new Error(ERR_INVALID_BASE_URI);
410
+ }
411
+ } else if (URI_PROPERTY_NAMES.includes(propertyName)) {
412
+ if (propertyValue && typeof propertyValue != STRING_TYPE && typeof propertyValue != FUNCTION_TYPE) {
413
+ throw new Error(ERR_INVALID_URI);
414
+ }
384
415
  }
385
416
  return propertyValue;
386
417
  }
@@ -2597,6 +2628,7 @@
2597
2628
  constructor(chunkSize) {
2598
2629
  const pendingChunks = [];
2599
2630
  let pendingLength = 0;
2631
+ let outputSize = 0;
2600
2632
  if (!Number.isFinite(chunkSize) || chunkSize < 1) {
2601
2633
  chunkSize = DEFAULT_CHUNK_SIZE;
2602
2634
  }
@@ -2605,15 +2637,20 @@
2605
2637
  pendingChunks.push(chunk);
2606
2638
  pendingLength += chunk.length;
2607
2639
  while (pendingLength > chunkSize) {
2640
+ outputSize += chunkSize;
2608
2641
  controller.enqueue(shiftChunk());
2609
2642
  }
2610
2643
  },
2611
2644
  flush(controller) {
2612
2645
  if (pendingLength) {
2646
+ outputSize += pendingLength;
2613
2647
  controller.enqueue(concatChunks(pendingChunks, pendingLength));
2614
2648
  }
2615
2649
  }
2616
2650
  });
2651
+ Object.defineProperty(this, "outputSize", {
2652
+ get: () => outputSize
2653
+ });
2617
2654
 
2618
2655
  function shiftChunk() {
2619
2656
  const result = new Uint8Array(chunkSize);
@@ -2814,7 +2851,7 @@
2814
2851
  }
2815
2852
 
2816
2853
  async function runWorker$1({ options, readable, writable, onTaskFinished }, config) {
2817
- let codecStream;
2854
+ let codecStream, chunkStream;
2818
2855
  try {
2819
2856
  if (options.compressed && !options.format) {
2820
2857
  const deflate = options.codecType.startsWith(CODEC_DEFLATE);
@@ -2837,9 +2874,10 @@
2837
2874
  }
2838
2875
  }
2839
2876
  codecStream = new CodecStream(options, config);
2877
+ chunkStream = new ChunkStream(getChunkSize(config));
2840
2878
  await readable
2841
2879
  .pipeThrough(codecStream)
2842
- .pipeThrough(new ChunkStream(getChunkSize(config)))
2880
+ .pipeThrough(chunkStream)
2843
2881
  .pipeTo(writable, { preventClose: true, preventAbort: true });
2844
2882
  const {
2845
2883
  crc32,
@@ -2853,7 +2891,7 @@
2853
2891
  };
2854
2892
  } catch (error) {
2855
2893
  if (codecStream) {
2856
- error.outputSize = codecStream.outputSize;
2894
+ error.outputSize = chunkStream ? chunkStream.outputSize : 0;
2857
2895
  }
2858
2896
  throw error;
2859
2897
  } finally {
@@ -2962,11 +3000,17 @@
2962
3000
  let resolveResult, rejectResult;
2963
3001
  const result = new Promise((resolve, reject) => {
2964
3002
  resolveResult = resolve;
2965
- rejectResult = reject;
3003
+ rejectResult = error => {
3004
+ if (error && error.outputSize === UNDEFINED_VALUE) {
3005
+ error.outputSize = workerData.outputSize;
3006
+ }
3007
+ reject(error);
3008
+ };
2966
3009
  });
2967
3010
  Object.assign(workerData, {
2968
3011
  reader: null,
2969
3012
  writer: null,
3013
+ outputSize: 0,
2970
3014
  resolveResult,
2971
3015
  rejectResult,
2972
3016
  result
@@ -3250,8 +3294,10 @@
3250
3294
  }
3251
3295
  }
3252
3296
  if (type == MESSAGE_DATA) {
3297
+ const chunk = new Uint8Array(value);
3253
3298
  await writer.ready;
3254
- await writer.write(new Uint8Array(value));
3299
+ await writer.write(chunk);
3300
+ workerData.outputSize += chunk.length;
3255
3301
  if (!stale()) {
3256
3302
  sendMessage({ type: MESSAGE_ACK_DATA, messageId }, workerData);
3257
3303
  }
@@ -3559,10 +3605,13 @@
3559
3605
 
3560
3606
 
3561
3607
  const ERR_HTTP_STATUS = "HTTP error ";
3608
+ const MIN_SUCCESS_HTTP_STATUS = 200;
3609
+ const MAX_SUCCESS_HTTP_STATUS = 299;
3562
3610
  const ERR_HTTP_RANGE = "HTTP Range not supported";
3563
3611
  const ERR_HTTP_RESOURCE_CHANGED = "HTTP resource changed";
3564
3612
  const ERR_ITERATOR_COMPLETED_TOO_SOON = "Writer iterator completed too soon";
3565
3613
  const ERR_WRITER_NOT_INITIALIZED = "Writer not initialized";
3614
+ const ERR_WRITER_SIZE_NOT_WRITABLE = "Invalid writer (size must be writable)";
3566
3615
 
3567
3616
  const CONTENT_TYPE_TEXT_PLAIN = "text/plain";
3568
3617
  const HTTP_HEADER_CONTENT_LENGTH = "Content-Length";
@@ -3754,11 +3803,14 @@
3754
3803
  const reader = this;
3755
3804
  const { sourceBlob, size } = reader;
3756
3805
  const { offset = 0, size: readSize = size - offset } = options || {};
3757
- if (!offset && readSize >= size) {
3758
- return toCompatibleReadable(sourceBlob.stream());
3759
- }
3760
- if (blobSliceReliable) {
3761
- return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
3806
+ // deno-lint-ignore valid-typeof
3807
+ if (typeof sourceBlob.stream == FUNCTION_TYPE) {
3808
+ if (!offset && readSize >= size) {
3809
+ return toCompatibleReadable(sourceBlob.stream());
3810
+ }
3811
+ if (blobSliceReliable) {
3812
+ return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
3813
+ }
3762
3814
  }
3763
3815
  return super.createReadable(options);
3764
3816
  }
@@ -4158,7 +4210,7 @@
4158
4210
 
4159
4211
  async function sendFetchRequest(method, { fetch: fetchFunction = fetch, options, url }, headers) {
4160
4212
  const response = await fetchFunction(url, Object.assign({}, options, { method, headers }));
4161
- if (response.status < 400) {
4213
+ if (response.status >= MIN_SUCCESS_HTTP_STATUS && response.status <= MAX_SUCCESS_HTTP_STATUS) {
4162
4214
  return response;
4163
4215
  } else {
4164
4216
  throw response.status == 416 ? new Error(ERR_HTTP_RANGE) : new Error(ERR_HTTP_STATUS + (response.statusText || response.status));
@@ -4169,7 +4221,7 @@
4169
4221
  return new Promise((resolve, reject) => {
4170
4222
  const request = new XMLHttpRequest();
4171
4223
  request.addEventListener("load", () => {
4172
- if (request.status < 400) {
4224
+ if (request.status >= MIN_SUCCESS_HTTP_STATUS && request.status <= MAX_SUCCESS_HTTP_STATUS) {
4173
4225
  const headers = [];
4174
4226
  request.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(header => {
4175
4227
  const splitHeader = header.trim().split(/\s*:\s*/);
@@ -4473,8 +4525,10 @@
4473
4525
  writable: toCompatibleWritable(writer)
4474
4526
  };
4475
4527
  }
4476
- if (writer.size === UNDEFINED_VALUE) {
4477
- writer.size = 0;
4528
+ try {
4529
+ writer.size = writer.size === UNDEFINED_VALUE ? 0 : writer.size;
4530
+ } catch {
4531
+ throw new Error(ERR_WRITER_SIZE_NOT_WRITABLE);
4478
4532
  }
4479
4533
  return writer;
4480
4534
  }
@@ -4522,6 +4576,45 @@
4522
4576
  }
4523
4577
  }
4524
4578
 
4579
+ /*
4580
+ Copyright (c) 2026 Gildas Lormeau. All rights reserved.
4581
+
4582
+ Redistribution and use in source and binary forms, with or without
4583
+ modification, are permitted provided that the following conditions are met:
4584
+
4585
+ 1. Redistributions of source code must retain the above copyright notice,
4586
+ this list of conditions and the following disclaimer.
4587
+
4588
+ 2. Redistributions in binary form must reproduce the above copyright
4589
+ notice, this list of conditions and the following disclaimer in
4590
+ the documentation and/or other materials provided with the distribution.
4591
+
4592
+ 3. The names of the authors may not be used to endorse or promote products
4593
+ derived from this software without specific prior written permission.
4594
+
4595
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
4596
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
4597
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
4598
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
4599
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4600
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
4601
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4602
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4603
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4604
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4605
+ */
4606
+
4607
+
4608
+ function addWarning(warnings, reason, filename) {
4609
+ if (!warnings.some(warning => warning.reason == reason)) {
4610
+ const warning = { reason };
4611
+ if (filename !== UNDEFINED_VALUE) {
4612
+ warning.filename = filename;
4613
+ }
4614
+ warnings.push(warning);
4615
+ }
4616
+ }
4617
+
4525
4618
  /*
4526
4619
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
4527
4620
 
@@ -4550,6 +4643,7 @@
4550
4643
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4551
4644
  */
4552
4645
 
4646
+
4553
4647
  const PROPERTY_NAME_FILENAME = "filename";
4554
4648
  const PROPERTY_NAME_RAW_FILENAME = "rawFilename";
4555
4649
  const PROPERTY_NAME_COMMENT = "comment";
@@ -4674,6 +4768,38 @@
4674
4768
 
4675
4769
  }
4676
4770
 
4771
+ const INTERPRETED_EXTRA_FIELD_TYPES = new Set([
4772
+ EXTRAFIELD_TYPE_ZIP64,
4773
+ EXTRAFIELD_TYPE_AES,
4774
+ EXTRAFIELD_TYPE_NTFS,
4775
+ EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP,
4776
+ EXTRAFIELD_TYPE_UNICODE_PATH,
4777
+ EXTRAFIELD_TYPE_UNICODE_COMMENT,
4778
+ EXTRAFIELD_TYPE_USDZ,
4779
+ EXTRAFIELD_TYPE_INFOZIP,
4780
+ EXTRAFIELD_TYPE_UNIX,
4781
+ EXTRAFIELD_TYPE_UNIX_TYPE1,
4782
+ EXTRAFIELD_TYPE_PKWARE_UNIX
4783
+ ]);
4784
+
4785
+ function getUserExtraField(extraField) {
4786
+ if (extraField) {
4787
+ const userExtraField = new Map();
4788
+ extraField.forEach((field, type) => {
4789
+ if (!INTERPRETED_EXTRA_FIELD_TYPES.has(type)) {
4790
+ userExtraField.set(type, field.data);
4791
+ }
4792
+ });
4793
+ if (userExtraField.size) {
4794
+ return userExtraField;
4795
+ }
4796
+ }
4797
+ }
4798
+
4799
+ function getEncryptionOverhead(encrypted, zipCrypto, encryptionStrength) {
4800
+ return encrypted ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
4801
+ }
4802
+
4677
4803
  /*
4678
4804
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
4679
4805
 
@@ -4733,6 +4859,8 @@
4733
4859
  const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA = "trailing central directory data";
4734
4860
  const WARNING_DUPLICATE_FILENAME = "duplicate filename";
4735
4861
  const WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY = "mismatched zip64 end of central directory record";
4862
+ const WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY = "multiple end of central directory records";
4863
+ const WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME = "mismatched local file header (filename)";
4736
4864
  const WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG = "mismatched local file header (general purpose bit flag)";
4737
4865
  const WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD = "mismatched local file header (compression method)";
4738
4866
  const WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES = "mismatched local file header (crc32 or sizes)";
@@ -4803,7 +4931,7 @@
4803
4931
  }
4804
4932
  }
4805
4933
  if (rejectAmbiguousEndOfDirectory && endOfDirectoryReachingEndCount > 1) {
4806
- throwAmbiguousArchive("multiple end of central directory records");
4934
+ throwAmbiguousArchive(WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY);
4807
4935
  }
4808
4936
  const endOfDirectoryView = getDataView(endOfDirectoryInfo);
4809
4937
  let directoryDataLength = getUint32$1(endOfDirectoryView, 12);
@@ -5101,7 +5229,8 @@
5101
5229
  const writer = new TransformStream();
5102
5230
  const arrayBufferPromise = streamToBlob(writer.readable).then(blob => blob.arrayBuffer());
5103
5231
  arrayBufferPromise.catch(() => { });
5104
- await fileEntry.getData(writer, entry, zipReader.readRanges, options);
5232
+ await fileEntry.getData(writer, entry, zipReader.readRanges,
5233
+ Object.assign({}, options, { preventClose: false }));
5105
5234
  return arrayBufferPromise;
5106
5235
  };
5107
5236
  offset = endOffset;
@@ -5182,48 +5311,101 @@
5182
5311
  await reader.readable.cancel();
5183
5312
  }
5184
5313
  }
5314
+
5315
+ [SYMBOL_ASYNC_DISPOSE]() {
5316
+ return this.close();
5317
+ }
5185
5318
  }
5186
5319
 
5187
5320
  class ZipReaderStream {
5188
5321
 
5189
5322
  constructor(options = {}) {
5190
- const { readable, writable } = new TransformStream();
5191
- const gen = new ZipReader(readable, options).getEntriesGenerator();
5323
+ let sourceController;
5324
+ const { readable, writable } = new TransformStream({
5325
+ start(controller) {
5326
+ sourceController = controller;
5327
+ }
5328
+ });
5329
+ const zipReader = new ZipReader(readable, options);
5330
+ const gen = zipReader.getEntriesGenerator();
5331
+ const pendingEntries = new Set();
5192
5332
  this.readable = new ReadableStream({
5193
5333
  async pull(controller) {
5194
5334
  const { done, value } = await gen.next();
5195
5335
  if (done)
5196
5336
  return controller.close();
5337
+ const entryStream = createEntryStream(value, pendingEntries);
5197
5338
  const chunk = {
5198
5339
  ...value,
5199
- readable: (function () {
5200
- const { readable, writable } = new TransformStream();
5201
- if (value.getData) {
5202
- getData();
5203
- return readable;
5204
- }
5205
-
5206
- async function getData() {
5207
- try {
5208
- await value.getData(writable);
5209
- } catch (error) {
5210
- try {
5211
- await writable.abort(error);
5212
- } catch {
5213
- // ignored
5214
- }
5215
- }
5216
- }
5217
- })()
5340
+ readable: entryStream.readable
5218
5341
  };
5219
5342
  delete chunk.getData;
5343
+ Object.defineProperties(chunk, {
5344
+ localDirectory: {
5345
+ get: () => value.localDirectory,
5346
+ enumerable: true
5347
+ },
5348
+ warnings: {
5349
+ get: () => value.warnings,
5350
+ enumerable: true
5351
+ }
5352
+ });
5220
5353
  controller.enqueue(chunk);
5354
+ },
5355
+ async cancel(reason) {
5356
+ const entryStreams = Array.from(pendingEntries);
5357
+ pendingEntries.clear();
5358
+ sourceController.error(reason);
5359
+ await Promise.allSettled(entryStreams.map(entryStream => entryStream.cancel(reason)));
5360
+ await Promise.allSettled([gen.return(), zipReader.close()]);
5221
5361
  }
5222
5362
  });
5223
5363
  this.writable = writable;
5224
5364
  }
5225
5365
  }
5226
5366
 
5367
+ function createEntryStream(entry, pendingEntries) {
5368
+ const { readable, writable } = new TransformStream();
5369
+ let dataReader;
5370
+ const entryStream = {
5371
+ cancel: async reason => {
5372
+ pendingEntries.delete(entryStream);
5373
+ await (dataReader ? dataReader.cancel(reason) : readable.cancel(reason));
5374
+ }
5375
+ };
5376
+ entryStream.readable = new ReadableStream({
5377
+ async pull(controller) {
5378
+ if (!dataReader) {
5379
+ dataReader = readable.getReader();
5380
+ pendingEntries.add(entryStream);
5381
+ getData();
5382
+ }
5383
+ const { done, value } = await dataReader.read();
5384
+ if (done) {
5385
+ controller.close();
5386
+ } else {
5387
+ controller.enqueue(value);
5388
+ }
5389
+ },
5390
+ cancel: reason => entryStream.cancel(reason)
5391
+ }, { highWaterMark: 0 });
5392
+ return entryStream;
5393
+
5394
+ async function getData() {
5395
+ try {
5396
+ await entry.getData(writable, { preventClose: false });
5397
+ } catch (error) {
5398
+ try {
5399
+ await writable.abort(error);
5400
+ } catch {
5401
+ // ignored
5402
+ }
5403
+ } finally {
5404
+ pendingEntries.delete(entryStream);
5405
+ }
5406
+ }
5407
+ }
5408
+
5227
5409
  async function isZipFile(reader, options = {}) {
5228
5410
  reader = new GenericReader(reader);
5229
5411
  await initStream(reader);
@@ -5283,7 +5465,9 @@
5283
5465
  const dataView = getDataView(dataArray);
5284
5466
  let password = getOptionValue$1(zipEntry, options, OPTION_PASSWORD);
5285
5467
  let rawPassword = getOptionValue$1(zipEntry, options, OPTION_RAW_PASSWORD);
5286
- const passThrough = getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH);
5468
+ const passThrough = checkPassThroughOption(getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH));
5469
+ const passThroughCompression = Boolean(passThrough);
5470
+ const passThroughEncryption = passThrough === true;
5287
5471
  checkPasswordOption(password, rawPassword);
5288
5472
  password = password && password.length && password;
5289
5473
  rawPassword = rawPassword && rawPassword.length && rawPassword;
@@ -5304,7 +5488,9 @@
5304
5488
  const checkLocalDirectoryOption = getOptionValue$1(zipEntry, options, OPTION_CHECK_LOCAL_DIRECTORY);
5305
5489
  const entryStrictness = getStrictness(options, zipEntry.options);
5306
5490
  const checkLocalDirectory = getCheckLocalDirectory(checkLocalDirectoryOption, entryStrictness);
5307
- const checkLocalFilename = getCheckLocalFilename(checkLocalDirectoryOption, entryStrictness);
5491
+ const checkLocalFilenameOption = getOptionValue$1(zipEntry, options, OPTION_CHECK_LOCAL_FILENAME);
5492
+ const checkLocalFilename = getCheckLocalFilename(
5493
+ checkLocalFilenameOption === UNDEFINED_VALUE ? checkLocalDirectoryOption : checkLocalFilenameOption, entryStrictness);
5308
5494
  let rawLocalFilename = EMPTY_UINT8_ARRAY;
5309
5495
  if (checkLocalFilename && (filenameLength || extraFieldLength)) {
5310
5496
  const trailingDataArray = await readUint8Array(reader, localHeaderOffset + HEADER_SIZE, filenameLength + extraFieldLength);
@@ -5335,16 +5521,17 @@
5335
5521
  if (gid !== UNDEFINED_VALUE && fileEntry.gid === UNDEFINED_VALUE) {
5336
5522
  fileEntry.gid = gid;
5337
5523
  }
5338
- const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
5524
+ const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
5525
+ const encrypted = zipEntry.encrypted && localDirectory.encrypted && (!passThroughEncryption || checkPasswordOnly);
5339
5526
  const zipCrypto = encrypted && !extraFieldAES;
5340
- if (!passThrough) {
5527
+ if (!passThroughEncryption) {
5341
5528
  fileEntry.zipCrypto = zipCrypto;
5342
5529
  }
5343
5530
  if (encrypted && (localDirectory.rawBitFlag & BITFLAG_STRONG_ENCRYPTION) == BITFLAG_STRONG_ENCRYPTION) {
5344
5531
  throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
5345
5532
  }
5346
- const registeredCodec = passThrough ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
5347
- if (compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE && compressionMethod != COMPRESSION_METHOD_DEFLATE_64 && !registeredCodec && !passThrough) {
5533
+ const registeredCodec = passThroughCompression ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
5534
+ if (compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE && compressionMethod != COMPRESSION_METHOD_DEFLATE_64 && !registeredCodec && !passThroughCompression) {
5348
5535
  throw new Error(ERR_UNSUPPORTED_COMPRESSION);
5349
5536
  }
5350
5537
  if (encrypted) {
@@ -5360,15 +5547,17 @@
5360
5547
  const size = compressedSize;
5361
5548
  const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
5362
5549
  const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
5363
- const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
5550
+ throwIfAborted(signal);
5364
5551
  let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
5365
5552
  const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
5366
5553
  if (checkOverlappingEntryOnly) {
5367
5554
  checkOverlappingEntry = true;
5368
5555
  }
5369
5556
  const { onstart, onprogress, onend } = options;
5370
- const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !passThrough;
5371
- const outputSize = passThrough ? compressedSize : uncompressedSize;
5557
+ const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !passThroughCompression;
5558
+ const outputSize = passThroughCompression ?
5559
+ compressedSize - getEncryptionOverhead(encrypted, zipCrypto, extraFieldAES && extraFieldAES.strength) :
5560
+ uncompressedSize;
5372
5561
  const deflate64 = compressionMethod == COMPRESSION_METHOD_DEFLATE_64;
5373
5562
  let useCompressionStream = getOptionValue$1(zipEntry, options, OPTION_USE_COMPRESSION_STREAM);
5374
5563
  if (deflate64) {
@@ -5377,7 +5566,7 @@
5377
5566
  const checkCrc32Option = getOptionValue$1(zipEntry, options, OPTION_CHECK_CRC32);
5378
5567
  const checkCrc32 = (checkCrc32Option === UNDEFINED_VALUE ?
5379
5568
  getOptionValue$1(zipEntry, options, OPTION_CHECK_SIGNATURE) :
5380
- checkCrc32Option) && !passThrough &&
5569
+ checkCrc32Option) && !passThroughCompression &&
5381
5570
  (!encrypted || zipCrypto || (extraFieldAES && extraFieldAES.vendorVersion == VENDOR_VERSION_AE_1$1));
5382
5571
  const workerOptions = {
5383
5572
  options: {
@@ -5431,10 +5620,10 @@
5431
5620
  await initStream(writer, getDecodableOutputSize(outputSize, compressedSize, compressed));
5432
5621
  ({ writable } = writer);
5433
5622
  const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
5434
- writer.size += writtenSize;
5435
5623
  if (writtenSize != outputSize) {
5436
- throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
5624
+ throw Object.assign(new Error(ERR_INVALID_UNCOMPRESSED_SIZE), { outputSize: writtenSize });
5437
5625
  }
5626
+ writer.size += writtenSize;
5438
5627
  }
5439
5628
  } catch (error) {
5440
5629
  if (error.outputSize !== UNDEFINED_VALUE) {
@@ -6100,7 +6289,7 @@
6100
6289
  if (checkLocalFilename && !maskedLocalDirectory &&
6101
6290
  (rawLocalFilename.length != rawFilename.length ||
6102
6291
  rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
6103
- reportAmbiguity(reject, warnings, "mismatched local file header (filename)");
6292
+ reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME);
6104
6293
  }
6105
6294
  if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
6106
6295
  reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG);
@@ -6125,16 +6314,6 @@
6125
6314
  }
6126
6315
  }
6127
6316
 
6128
- function addWarning(warnings, reason, filename) {
6129
- if (!warnings.some(warning => warning.reason == reason)) {
6130
- const warning = { reason };
6131
- if (filename !== UNDEFINED_VALUE) {
6132
- warning.filename = filename;
6133
- }
6134
- warnings.push(warning);
6135
- }
6136
- }
6137
-
6138
6317
  function throwAmbiguousArchive(reason) {
6139
6318
  const error = new Error(ERR_AMBIGUOUS_ARCHIVE);
6140
6319
  error.reason = reason;
@@ -6214,7 +6393,9 @@
6214
6393
  WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG: WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG,
6215
6394
  WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD: WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD,
6216
6395
  WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES: WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES,
6396
+ WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME: WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME,
6217
6397
  WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY: WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY,
6398
+ WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY: WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY,
6218
6399
  WARNING_PREPENDED_CENTRAL_DIRECTORY: WARNING_PREPENDED_CENTRAL_DIRECTORY,
6219
6400
  WARNING_PREPENDED_DATA: WARNING_PREPENDED_DATA,
6220
6401
  WARNING_TRAILING_CENTRAL_DIRECTORY_DATA: WARNING_TRAILING_CENTRAL_DIRECTORY_DATA,
@@ -6267,7 +6448,7 @@
6267
6448
  const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
6268
6449
  const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
6269
6450
  const ERR_UNSUPPORTED_SPLIT_USDZ = "Split zip files are not supported in USDZ files";
6270
- const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
6451
+ const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set to true (use 'compressed' instead)";
6271
6452
  const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
6272
6453
  const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
6273
6454
  const ERR_INVALID_EXTRAFIELD_DATA_TYPE = "Invalid extra field data (must be a Uint8Array)";
@@ -6279,6 +6460,7 @@
6279
6460
  const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
6280
6461
  const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
6281
6462
  const ERR_UNDEFINED_COMPRESSION_METHOD = "Undefined compression method";
6463
+ const ERR_UNDEFINED_CRC32 = "Undefined CRC32";
6282
6464
  const ERR_UNDETERMINED_SIZE = "Undetermined size";
6283
6465
  const ERR_UNDEFINED_READER = "Undefined reader";
6284
6466
  const ERR_INVALID_READER = "Invalid reader (must be a Reader instance, a ReadableStream instance, or an object with a 'readable' property)";
@@ -6292,14 +6474,21 @@
6292
6474
  const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
6293
6475
  const ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
6294
6476
  const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
6477
+ const ERR_INVALID_ENTRY = "Invalid entry option (must be an entry returned by ZipReader#getEntries())";
6478
+ const ERR_ZIP_CRYPTO_LAST_MOD_DATE = "The last modification date of an entry encrypted with ZipCrypto cannot be changed when passThrough is set";
6479
+ const WARNING_COMPRESSION_UNAVAILABLE = "compression unavailable";
6480
+ const WARNING_CLAMPED_LAST_MODIFICATION_DATE = "clamped last modification date";
6295
6481
 
6296
6482
  const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
6297
6483
  const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
6298
6484
  const EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD = 9;
6299
6485
  const EXTRAFIELD_USDZ_MAX_LENGTH = 67;
6486
+ const MIN_PRINTABLE_ASCII_CHARACTER_CODE = 0x20;
6487
+ const MAX_PRINTABLE_ASCII_CHARACTER_CODE = 0x7e;
6300
6488
  const VENDOR_VERSION_AE_1 = 1;
6301
- const INFOZIP_EXTRA_FIELD_TYPE$1 = "infozip";
6489
+ const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
6302
6490
  const UNIX_EXTRA_FIELD_TYPE = "unix";
6491
+ const LEVEL_BY_BITFLAG_LEVEL = [8, 9, 5, 3];
6303
6492
  const MAX_LEVEL = 9;
6304
6493
 
6305
6494
  let workers = 0;
@@ -6326,9 +6515,11 @@
6326
6515
  initialOffset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : options[OPTION_OFFSET] - (writer.size || writer.writable.size || 0),
6327
6516
  pendingAddFileCalls: new Set(),
6328
6517
  pendingErrors: [],
6518
+ warnings: [],
6329
6519
  bufferedWrites: 0,
6330
6520
  directWrites: 0,
6331
- lastFileEntry: UNDEFINED_VALUE
6521
+ lastFileEntry: UNDEFINED_VALUE,
6522
+ archiveClosed: false
6332
6523
  });
6333
6524
  }
6334
6525
 
@@ -6493,6 +6684,9 @@
6493
6684
  const zipWriter = this;
6494
6685
  const { pendingAddFileCalls, writer } = this;
6495
6686
  const { writable } = writer;
6687
+ if (zipWriter.archiveClosed) {
6688
+ return getWriterData(writer);
6689
+ }
6496
6690
  if (!(comment instanceof Uint8Array)) {
6497
6691
  throw new Error(ERR_INVALID_COMMENT_TYPE);
6498
6692
  }
@@ -6516,11 +6710,16 @@
6516
6710
  throw error;
6517
6711
  }
6518
6712
  await closeFile(zipWriter, comment, options);
6713
+ zipWriter.archiveClosed = true;
6519
6714
  const preventClose = !ownsWritable(writer) && getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
6520
6715
  if (!preventClose) {
6521
6716
  await writable.getWriter().close();
6522
6717
  }
6523
- return writer.getData ? writer.getData() : writable;
6718
+ return getWriterData(writer);
6719
+ }
6720
+
6721
+ [SYMBOL_ASYNC_DISPOSE]() {
6722
+ return this.close();
6524
6723
  }
6525
6724
  }
6526
6725
 
@@ -6599,6 +6798,10 @@
6599
6798
  }
6600
6799
  }
6601
6800
 
6801
+ function getWriterData(writer) {
6802
+ return writer.getData ? writer.getData() : writer.writable;
6803
+ }
6804
+
6602
6805
  function watchPromiseError(zipWriter, promise) {
6603
6806
  const watchedPromise = new WatchedPromise((resolve, reject) => Promise.prototype.then.call(promise, resolve, reject));
6604
6807
  const watcher = {};
@@ -6617,6 +6820,14 @@
6617
6820
 
6618
6821
  async function addFileEntry(zipWriter, name, reader, options) {
6619
6822
  options = Object.assign({}, options);
6823
+ const entry = options[OPTION_ENTRY];
6824
+ if (entry !== UNDEFINED_VALUE) {
6825
+ const { entryOptions, passThroughOptions } = getSourceEntryOptions(entry,
6826
+ checkPassThroughOption(getOptionValue(zipWriter, options, OPTION_PASS_THROUGH)),
6827
+ getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE));
6828
+ delete options[OPTION_ENTRY];
6829
+ options = Object.assign(entryOptions, passThroughOptions, options);
6830
+ }
6620
6831
  if (getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY) && !name.endsWith(DIRECTORY_SIGNATURE)) {
6621
6832
  name += DIRECTORY_SIGNATURE;
6622
6833
  }
@@ -6681,21 +6892,33 @@
6681
6892
  try {
6682
6893
  const { resolvedOptions } = metadataInfo;
6683
6894
  if (resolvedOptions.level != 0 && resolvedOptions.compressionMethod === UNDEFINED_VALUE &&
6684
- !resolvedOptions.passThrough && !(await supportsDeflate(getConfiguration()))) {
6895
+ !resolvedOptions.passThroughCompression && !(await supportsDeflate(getConfiguration()))) {
6685
6896
  resolvedOptions.level = 0;
6897
+ addWarning(zipWriter.warnings, WARNING_COMPRESSION_UNAVAILABLE, name);
6686
6898
  }
6687
6899
  const sizesInfo = await resolveSizes(zipWriter, reader, metadataInfo, options);
6688
6900
  ({ reader } = sizesInfo);
6689
6901
  const diskOffset = getDiskOffset(zipWriter.writer);
6690
6902
  const diskNumber = getDiskNumber(zipWriter.writer);
6903
+ let crc32 = options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32;
6904
+ const storesAE2 = sizesInfo.resolvedOptions.encrypted && !resolvedOptions.zipCrypto;
6905
+ if (resolvedOptions.passThroughCompression && !resolvedOptions.passThroughEncryption && storesAE2) {
6906
+ crc32 = UNDEFINED_VALUE;
6907
+ }
6908
+ if (resolvedOptions.passThroughCompression && reader && !storesAE2 && crc32 === UNDEFINED_VALUE) {
6909
+ throw new Error(ERR_UNDEFINED_CRC32);
6910
+ }
6691
6911
  options = Object.assign({}, options, attributesInfo.resolvedOptions, metadataInfo.resolvedOptions, sizesInfo.resolvedOptions, {
6692
6912
  signature: options[PROPERTY_NAME_SIGNATURE],
6693
- crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
6913
+ crc32,
6694
6914
  offset: zipWriter.offset - diskOffset,
6695
6915
  diskNumberStart: diskNumber,
6696
6916
  [OPTION_USDZ]: zipWriter.options[OPTION_USDZ]
6697
6917
  });
6698
6918
  const headerInfo = getHeaderInfo(options);
6919
+ if (headerInfo.lastModDateClamped) {
6920
+ addWarning(zipWriter.warnings, WARNING_CLAMPED_LAST_MODIFICATION_DATE, name);
6921
+ }
6699
6922
  const dataDescriptorInfo = getDataDescriptorInfo(options);
6700
6923
  const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
6701
6924
  fileEntry = await getFileEntry(zipWriter, name, reader, {
@@ -6722,6 +6945,95 @@
6722
6945
  return new Entry(fileEntry);
6723
6946
  }
6724
6947
 
6948
+ function getSourceEntryOptions(entry, passThrough, lastModDateOverride) {
6949
+ if (entry === null || typeof entry != OBJECT_TYPE || Array.isArray(entry)) {
6950
+ throw new Error(ERR_INVALID_ENTRY);
6951
+ }
6952
+ const {
6953
+ externalFileAttributes,
6954
+ versionMadeBy,
6955
+ comment,
6956
+ lastModDate,
6957
+ rawLastModDate,
6958
+ creationDate,
6959
+ lastAccessDate,
6960
+ uncompressedSize,
6961
+ encrypted,
6962
+ zipCrypto,
6963
+ crc32,
6964
+ compressionMethod,
6965
+ extraFieldAES,
6966
+ extraFieldUnix,
6967
+ internalFileAttributes,
6968
+ extraField,
6969
+ bitFlag,
6970
+ directory,
6971
+ uid,
6972
+ gid
6973
+ } = entry;
6974
+ const entryOptions = {
6975
+ externalFileAttributes,
6976
+ versionMadeBy,
6977
+ comment,
6978
+ lastModDate,
6979
+ creationDate,
6980
+ lastAccessDate,
6981
+ internalFileAttributes,
6982
+ directory
6983
+ };
6984
+ if (bitFlag && bitFlag.languageEncodingFlag) {
6985
+ entryOptions[OPTION_USE_UNICODE_FILE_NAMES] = true;
6986
+ }
6987
+ const userExtraField = getUserExtraField(extraField);
6988
+ if (userExtraField) {
6989
+ entryOptions[PROPERTY_NAME_EXTRA_FIELD] = userExtraField;
6990
+ }
6991
+ if (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE) {
6992
+ Object.assign(entryOptions, {
6993
+ uid,
6994
+ gid,
6995
+ unixExtraFieldType: extraFieldUnix ? UNIX_EXTRA_FIELD_TYPE : INFOZIP_EXTRA_FIELD_TYPE
6996
+ });
6997
+ }
6998
+ const passThroughOptions = {};
6999
+ if (passThrough && !directory) {
7000
+ Object.assign(passThroughOptions, {
7001
+ uncompressedSize,
7002
+ crc32,
7003
+ compressionMethod
7004
+ });
7005
+ if (passThrough !== PASS_THROUGH_COMPRESSED) {
7006
+ Object.assign(passThroughOptions, {
7007
+ encrypted,
7008
+ zipCrypto,
7009
+ encryptionStrength: extraFieldAES ? extraFieldAES.strength : UNDEFINED_VALUE
7010
+ });
7011
+ }
7012
+ if (bitFlag) {
7013
+ passThroughOptions.dataDescriptor = bitFlag.dataDescriptor;
7014
+ passThroughOptions[OPTION_LEVEL] = LEVEL_BY_BITFLAG_LEVEL[bitFlag.level];
7015
+ }
7016
+ if (lastModDateOverride === UNDEFINED_VALUE) {
7017
+ passThroughOptions.rawLastModDate = rawLastModDate;
7018
+ } else if (passThrough !== PASS_THROUGH_COMPRESSED && zipCrypto && (!bitFlag || bitFlag.dataDescriptor) &&
7019
+ lastModDateOverride instanceof Date &&
7020
+ getDosTimeHighByte(lastModDateOverride) != ((rawLastModDate >>> 8) & MAX_8_BITS)) {
7021
+ throw new Error(ERR_ZIP_CRYPTO_LAST_MOD_DATE);
7022
+ }
7023
+ }
7024
+ return { entryOptions, passThroughOptions };
7025
+ }
7026
+
7027
+ function getDosTimeHighByte(lastModDate) {
7028
+ let dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
7029
+ if (dosLastModDate < MIN_DATE) {
7030
+ dosLastModDate = MIN_DATE;
7031
+ } else if (dosLastModDate > MAX_DATE) {
7032
+ dosLastModDate = MAX_DATE;
7033
+ }
7034
+ return ((dosLastModDate.getHours() << 3) | (dosLastModDate.getMinutes() >> 3)) & MAX_8_BITS;
7035
+ }
7036
+
6725
7037
  function resolveAttributes(zipWriter, name, options) {
6726
7038
  let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
6727
7039
  let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? VERSION_MADE_BY_MSDOS : VERSION_MADE_BY_UNIX);
@@ -6736,7 +7048,7 @@
6736
7048
  checkIntegerOption(uid, MAX_32_BITS, ERR_INVALID_UID);
6737
7049
  checkIntegerOption(gid, MAX_32_BITS, ERR_INVALID_GID);
6738
7050
  checkIntegerOption(unixMode, MAX_16_BITS, ERR_INVALID_UNIX_MODE);
6739
- if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE$1 && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
7051
+ if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
6740
7052
  throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
6741
7053
  }
6742
7054
  if (unixExtraFieldType === UNIX_EXTRA_FIELD_TYPE &&
@@ -6744,7 +7056,7 @@
6744
7056
  throw new Error(ERR_INVALID_UNIX_ID_SIZE);
6745
7057
  }
6746
7058
  if (unixExtraFieldType === UNDEFINED_VALUE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
6747
- unixExtraFieldType = INFOZIP_EXTRA_FIELD_TYPE$1;
7059
+ unixExtraFieldType = INFOZIP_EXTRA_FIELD_TYPE;
6748
7060
  }
6749
7061
  let msdosAttributesRaw = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
6750
7062
  let msdosAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES);
@@ -6875,7 +7187,9 @@
6875
7187
  const lastAccessDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
6876
7188
  const creationDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
6877
7189
  const internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, 0);
6878
- const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
7190
+ const passThrough = checkPassThroughOption(getOptionValue(zipWriter, options, OPTION_PASS_THROUGH));
7191
+ const passThroughCompression = Boolean(passThrough);
7192
+ const passThroughEncryption = passThrough === true;
6879
7193
  const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
6880
7194
  const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
6881
7195
  checkPasswordOption(password, rawPassword);
@@ -6890,10 +7204,12 @@
6890
7204
  const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
6891
7205
  const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
6892
7206
  const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
6893
- const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
7207
+ throwIfAborted(signal);
7208
+ const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES,
7209
+ !isPrintableASCIIText(rawFilename) || !isPrintableASCIIText(rawComment));
6894
7210
  const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
6895
- const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
6896
- if (!passThrough && compressionMethod !== UNDEFINED_VALUE &&
7211
+ const registeredCodec = passThroughCompression || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
7212
+ if (!passThroughCompression && compressionMethod !== UNDEFINED_VALUE &&
6897
7213
  compressionMethod !== COMPRESSION_METHOD_STORE && compressionMethod !== COMPRESSION_METHOD_DEFLATE && !registeredCodec) {
6898
7214
  throw new Error(ERR_UNSUPPORTED_COMPRESSION);
6899
7215
  }
@@ -6907,15 +7223,15 @@
6907
7223
  level = 0;
6908
7224
  }
6909
7225
  }
6910
- if (passThrough) {
6911
- level = UNDEFINED_VALUE;
7226
+ if (passThroughCompression) {
7227
+ level = toNumber(options[OPTION_LEVEL]);
6912
7228
  }
6913
7229
  let useCompressionStream = getOptionValue(zipWriter, options, OPTION_USE_COMPRESSION_STREAM);
6914
7230
  let dataDescriptor = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR);
6915
7231
  if (bufferedWrite && dataDescriptor === UNDEFINED_VALUE) {
6916
7232
  dataDescriptor = false;
6917
7233
  }
6918
- if (dataDescriptor === UNDEFINED_VALUE || (zipCrypto && !passThrough)) {
7234
+ if (dataDescriptor === UNDEFINED_VALUE || (zipCrypto && !passThroughEncryption)) {
6919
7235
  dataDescriptor = true;
6920
7236
  }
6921
7237
  if (level !== UNDEFINED_VALUE && level != 6) {
@@ -6939,7 +7255,8 @@
6939
7255
  lastAccessDate,
6940
7256
  creationDate,
6941
7257
  internalFileAttributes,
6942
- passThrough,
7258
+ passThroughCompression,
7259
+ passThroughEncryption,
6943
7260
  password,
6944
7261
  rawPassword,
6945
7262
  encryptionStrength,
@@ -7000,7 +7317,7 @@
7000
7317
  }
7001
7318
 
7002
7319
  async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, options) {
7003
- if (metadata.passThrough && !reader && !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY)) {
7320
+ if (metadata.passThroughCompression && !reader && !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY)) {
7004
7321
  throw new Error(ERR_UNDEFINED_READER);
7005
7322
  }
7006
7323
  let contentSize;
@@ -7016,12 +7333,12 @@
7016
7333
  }
7017
7334
 
7018
7335
  function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options) {
7019
- const { passThrough, zipCrypto, password, rawPassword, encryptionStrength } = metadata;
7336
+ const { passThroughCompression, passThroughEncryption, zipCrypto, password, rawPassword, encryptionStrength } = metadata;
7020
7337
  let { dataDescriptor, zip64, level, compressionMethod } = metadata;
7021
7338
  let maximumCompressedSize = 0;
7022
7339
  let uncompressedSize = 0;
7023
7340
  let unknownSize = false;
7024
- if (passThrough && hasContent) {
7341
+ if (passThroughCompression && hasContent) {
7025
7342
  uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
7026
7343
  if (uncompressedSize === UNDEFINED_VALUE) {
7027
7344
  throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
@@ -7032,17 +7349,17 @@
7032
7349
  }
7033
7350
  const zip64Enabled = zip64 === true;
7034
7351
  const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
7035
- if (hasContent && passThrough && !encrypted && getLength(password, rawPassword)) {
7352
+ if (hasContent && passThroughEncryption && !encrypted && getLength(password, rawPassword)) {
7036
7353
  throw new Error(ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH);
7037
7354
  }
7038
- const encryptedEntry = hasContent && (Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted));
7355
+ const encryptedEntry = hasContent && (Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThroughEncryption && encrypted));
7039
7356
  if (!hasContent) {
7040
7357
  level = 0;
7041
7358
  compressionMethod = COMPRESSION_METHOD_STORE;
7042
7359
  }
7043
- const encryptionOverhead = encryptedEntry ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
7360
+ const encryptionOverhead = getEncryptionOverhead(encryptedEntry, zipCrypto, encryptionStrength);
7044
7361
  if (hasContent) {
7045
- if (!passThrough) {
7362
+ if (!passThroughCompression) {
7046
7363
  if (contentSize === UNDEFINED_VALUE) {
7047
7364
  dataDescriptor = true;
7048
7365
  if (zip64 || zip64 === UNDEFINED_VALUE) {
@@ -7055,10 +7372,12 @@
7055
7372
  }
7056
7373
  } else {
7057
7374
  options.uncompressedSize = uncompressedSize;
7058
- maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
7375
+ maximumCompressedSize = contentSize === UNDEFINED_VALUE ?
7376
+ getMaximumCompressedSize(uncompressedSize) + encryptionOverhead :
7377
+ contentSize + (passThroughEncryption ? 0 : encryptionOverhead);
7059
7378
  }
7060
7379
  }
7061
- const emptyEntry = !encryptedEntry && (!hasContent || (contentSize === 0 && !passThrough)) && !isCompressed(compressionMethod, level);
7380
+ const emptyEntry = !encryptedEntry && (!hasContent || (contentSize === 0 && !passThroughCompression)) && !isCompressed(compressionMethod, level);
7062
7381
  if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
7063
7382
  dataDescriptor = false;
7064
7383
  }
@@ -7107,6 +7426,8 @@
7107
7426
  const initialOffset = writerOptions[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : writerOptions[OPTION_OFFSET];
7108
7427
  let offset = initialOffset;
7109
7428
  let minimumEntrySize = INFINITY_VALUE;
7429
+ const entrySizes = [];
7430
+ const entriesAlreadyZip64 = new Set();
7110
7431
  for (const entry of entries) {
7111
7432
  let { name } = entry;
7112
7433
  const { size } = entry;
@@ -7118,7 +7439,7 @@
7118
7439
  ({ name } = attributesInfo);
7119
7440
  const { resolvedOptions: metadata } = resolveMetadata(zipWriter, name, options);
7120
7441
  if (metadata.level != 0 && metadata.compressionMethod === UNDEFINED_VALUE &&
7121
- !metadata.passThrough && !(await supportsDeflate(getConfiguration()))) {
7442
+ !metadata.passThroughCompression && !(await supportsDeflate(getConfiguration()))) {
7122
7443
  metadata.level = 0;
7123
7444
  }
7124
7445
  const hasContent = !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY);
@@ -7126,7 +7447,7 @@
7126
7447
  throw new Error(ERR_UNDETERMINED_SIZE);
7127
7448
  }
7128
7449
  const { maximumCompressedSize, resolvedOptions: sizes } = resolveEntrySizes(zipWriter, hasContent, size, metadata, options);
7129
- if (hasContent && !metadata.passThrough && isCompressed(sizes.compressionMethod, sizes.level)) {
7450
+ if (hasContent && !metadata.passThroughCompression && isCompressed(sizes.compressionMethod, sizes.level)) {
7130
7451
  throw new Error(ERR_UNDETERMINED_SIZE);
7131
7452
  }
7132
7453
  const entryOptions = Object.assign({}, options, attributesInfo.resolvedOptions, metadata, sizes, { [OPTION_USDZ]: usdz });
@@ -7146,10 +7467,15 @@
7146
7467
  compressedSize
7147
7468
  }));
7148
7469
  const entrySize = entryInfo.metadataSize + compressedSize;
7470
+ entrySizes.push(entrySize);
7471
+ entriesAlreadyZip64.add(Boolean(entryOptions.zip64Enabled ||
7472
+ entryOptions.uncompressedSize >= MAX_32_BITS || compressedSize >= MAX_32_BITS));
7149
7473
  minimumEntrySize = Math.min(minimumEntrySize, entrySize);
7150
7474
  offset += entrySize;
7151
7475
  }
7152
- const layoutDependsOnWriteOrder = files.size > 1 && (usdz || offset - minimumEntrySize >= MAX_32_BITS);
7476
+ const layoutDependsOnWriteOrder = files.size > 1 && (usdz ||
7477
+ (offset - minimumEntrySize >= MAX_32_BITS &&
7478
+ (entriesAlreadyZip64.size > 1 || countEntriesBefore4GB(entrySizes, initialOffset, true) != countEntriesBefore4GB(entrySizes, initialOffset, false))));
7153
7479
  if (layoutDependsOnWriteOrder && !writeOrderGuaranteed) {
7154
7480
  throw new Error(ERR_UNDETERMINED_SIZE);
7155
7481
  }
@@ -7167,6 +7493,20 @@
7167
7493
  return offset - initialOffset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
7168
7494
  }
7169
7495
 
7496
+ function countEntriesBefore4GB(entrySizes, initialOffset, largestFirst) {
7497
+ const ordered = entrySizes.slice().sort((first, second) => largestFirst ? second - first : first - second);
7498
+ let position = initialOffset;
7499
+ let count = 0;
7500
+ for (const entrySize of ordered) {
7501
+ if (position >= MAX_32_BITS) {
7502
+ break;
7503
+ }
7504
+ position += entrySize;
7505
+ count++;
7506
+ }
7507
+ return count;
7508
+ }
7509
+
7170
7510
  async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
7171
7511
  const {
7172
7512
  fileEntries,
@@ -7342,6 +7682,7 @@
7342
7682
  localExtraFieldZip64Length,
7343
7683
  rawExtraFieldExtendedTimestamp,
7344
7684
  extraFieldExtendedTimestampFlag,
7685
+ extraFieldExtendedTimestampTime,
7345
7686
  rawExtraFieldNTFS,
7346
7687
  rawExtraFieldUnix,
7347
7688
  rawExtraFieldAES,
@@ -7354,6 +7695,7 @@
7354
7695
  password,
7355
7696
  rawPassword,
7356
7697
  level,
7698
+ useUnicodeFileNames,
7357
7699
  zip64,
7358
7700
  zip64Enabled,
7359
7701
  zip64UncompressedSize,
@@ -7388,7 +7730,8 @@
7388
7730
  msdosAttributesRaw,
7389
7731
  msdosAttributes,
7390
7732
  useCompressionStream,
7391
- passThrough,
7733
+ passThroughCompression,
7734
+ passThroughEncryption,
7392
7735
  format,
7393
7736
  codecURI
7394
7737
  } = options;
@@ -7399,9 +7742,9 @@
7399
7742
  zip64Enabled,
7400
7743
  directory: Boolean(directory),
7401
7744
  executable: Boolean(executable),
7402
- filenameUTF8: true,
7745
+ filenameUTF8: Boolean(useUnicodeFileNames),
7403
7746
  rawFilename,
7404
- commentUTF8: true,
7747
+ commentUTF8: Boolean(useUnicodeFileNames),
7405
7748
  rawComment,
7406
7749
  rawExtraFieldZip64,
7407
7750
  localExtraFieldZip64Length,
@@ -7432,7 +7775,7 @@
7432
7775
  uncompressedSize
7433
7776
  } = options;
7434
7777
  let compressedSize = 0;
7435
- if (!passThrough) {
7778
+ if (!passThroughCompression) {
7436
7779
  uncompressedSize = 0;
7437
7780
  }
7438
7781
  const { writable } = writer;
@@ -7449,9 +7792,9 @@
7449
7792
  encryptionStrength,
7450
7793
  zipCrypto: encrypted && zipCrypto,
7451
7794
  passwordVerification: encrypted && zipCrypto && (rawLastModDate >> 8) & MAX_8_BITS,
7452
- computeCrc32: !passThrough,
7453
- compressed: compressed && !passThrough,
7454
- encrypted: encrypted && !passThrough,
7795
+ computeCrc32: !passThroughCompression,
7796
+ compressed: compressed && !passThroughCompression,
7797
+ encrypted: encrypted && !passThroughEncryption,
7455
7798
  useWebWorkers,
7456
7799
  useCompressionStream,
7457
7800
  transferStreams,
@@ -7466,7 +7809,7 @@
7466
7809
  const result = await runWorker({ readable, writable }, workerOptions);
7467
7810
  compressedSize = result.outputSize;
7468
7811
  writer.size += compressedSize;
7469
- if (!passThrough) {
7812
+ if (!passThroughCompression) {
7470
7813
  uncompressedSize = result.inputSize;
7471
7814
  if (!encrypted || zipCrypto) {
7472
7815
  crc32 = result.crc32;
@@ -7509,8 +7852,9 @@
7509
7852
  headerArray,
7510
7853
  headerView,
7511
7854
  signature: crc32,
7512
- crc32: encrypted && !zipCrypto && !passThrough ? UNDEFINED_VALUE : crc32,
7855
+ crc32: encrypted && !zipCrypto && !passThroughCompression ? UNDEFINED_VALUE : crc32,
7513
7856
  extraFieldExtendedTimestampFlag,
7857
+ extraFieldExtendedTimestampTime,
7514
7858
  zip64UncompressedSize,
7515
7859
  zip64CompressedSize
7516
7860
  });
@@ -7535,7 +7879,7 @@
7535
7879
  encryptionStrength,
7536
7880
  extendedTimestamp,
7537
7881
  ntfsTimestamp,
7538
- passThrough,
7882
+ passThroughCompression,
7539
7883
  encrypted,
7540
7884
  zip64UncompressedSize,
7541
7885
  zip64CompressedSize,
@@ -7546,7 +7890,7 @@
7546
7890
  let { version, compressionMethod } = options;
7547
7891
  const compressed = !directory && isCompressed(compressionMethod, level);
7548
7892
  let rawLocalExtraFieldZip64;
7549
- const uncompressedFile = passThrough || !compressed;
7893
+ const uncompressedFile = passThroughCompression || !compressed;
7550
7894
  const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || (uncompressedFile && !unknownSize)));
7551
7895
  const writeLocalExtraFieldZip64 = zip64ExtraFieldComplete || (zip64 && dataDescriptor && (zip64UncompressedSize || zip64CompressedSize));
7552
7896
  if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
@@ -7558,8 +7902,8 @@
7558
7902
  if (zip64ExtraFieldComplete) {
7559
7903
  extraFieldZip64.writeUint64(uncompressedSize);
7560
7904
  if (uncompressedFile) {
7561
- const encryptionOverhead = encrypted ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
7562
- extraFieldZip64.writeUint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
7905
+ const encryptionOverhead = getEncryptionOverhead(encrypted, zipCrypto, encryptionStrength);
7906
+ extraFieldZip64.writeUint64(passThroughCompression ? 0 : uncompressedSize + encryptionOverhead);
7563
7907
  }
7564
7908
  }
7565
7909
  } else {
@@ -7578,6 +7922,7 @@
7578
7922
  let rawExtraFieldNTFS;
7579
7923
  let rawExtraFieldExtendedTimestamp;
7580
7924
  let extraFieldExtendedTimestampFlag;
7925
+ let extraFieldExtendedTimestampTime;
7581
7926
  if (extendedTimestamp) {
7582
7927
  const lastModTimeUnix = getTimeUnix(lastModDate);
7583
7928
  const lastModTimeUnixInRange = inUnixTimeRange(lastModTimeUnix);
@@ -7585,6 +7930,7 @@
7585
7930
  const extraFieldTimestampLength = 9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0);
7586
7931
  const extraFieldTimestamp = createRecordWriter(extraFieldTimestampLength);
7587
7932
  extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
7933
+ extraFieldExtendedTimestampTime = lastModTimeUnix;
7588
7934
  extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7589
7935
  extraFieldTimestamp.writeUint16(extraFieldTimestampLength - 4);
7590
7936
  extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
@@ -7627,7 +7973,7 @@
7627
7973
  let rawExtraFieldUnix;
7628
7974
  try {
7629
7975
  const { uid, gid, unixExtraFieldType } = options;
7630
- if (unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE$1 && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
7976
+ if (unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
7631
7977
  const uidBytes = packUnixId(uid === UNDEFINED_VALUE ? 0 : uid);
7632
7978
  const gidBytes = packUnixId(gid === UNDEFINED_VALUE ? 0 : gid);
7633
7979
  const payloadLength = 3 + uidBytes.length + gidBytes.length;
@@ -7668,7 +8014,7 @@
7668
8014
  }
7669
8015
  if (encrypted && !zipCrypto) {
7670
8016
  version = version > VERSION_AES ? version : VERSION_AES;
7671
- if (passThrough && crc32 !== UNDEFINED_VALUE) {
8017
+ if (passThroughCompression && crc32 !== UNDEFINED_VALUE) {
7672
8018
  rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
7673
8019
  }
7674
8020
  setUint16(getDataView(rawExtraFieldAES), EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD, compressionMethod);
@@ -7730,12 +8076,14 @@
7730
8076
  headerArray,
7731
8077
  headerView,
7732
8078
  lastModDate: storedLastModDate,
8079
+ lastModDateClamped: storedLastModDate === clampedLastModDate && dosLastModDate.getTime() != clampedLastModDate.getTime(),
7733
8080
  rawLastModDate,
7734
8081
  encrypted,
7735
8082
  compressed,
7736
8083
  version,
7737
8084
  compressionMethod,
7738
8085
  extraFieldExtendedTimestampFlag,
8086
+ extraFieldExtendedTimestampTime,
7739
8087
  rawExtraFieldZip64: EMPTY_UINT8_ARRAY,
7740
8088
  localExtraFieldZip64Length,
7741
8089
  rawExtraFieldExtendedTimestamp,
@@ -7838,7 +8186,7 @@
7838
8186
  }, {
7839
8187
  zip64,
7840
8188
  zipCrypto,
7841
- passThrough,
8189
+ passThroughCompression,
7842
8190
  dataDescriptor
7843
8191
  }) {
7844
8192
  const {
@@ -7849,7 +8197,7 @@
7849
8197
  dataDescriptorView,
7850
8198
  dataDescriptorOffset
7851
8199
  } = dataDescriptorInfo;
7852
- if ((!encrypted || zipCrypto || passThrough) && crc32 !== UNDEFINED_VALUE) {
8200
+ if ((!encrypted || zipCrypto || passThroughCompression) && crc32 !== UNDEFINED_VALUE) {
7853
8201
  setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
7854
8202
  if (dataDescriptor) {
7855
8203
  setUint32(dataDescriptorView, dataDescriptorOffset, crc32);
@@ -7880,9 +8228,9 @@
7880
8228
  uncompressedSize,
7881
8229
  zip64UncompressedSize,
7882
8230
  zip64CompressedSize
7883
- }, localHeaderView, { dataDescriptor, passThrough }) {
8231
+ }, localHeaderView, { dataDescriptor, passThroughCompression }) {
7884
8232
  if (!dataDescriptor) {
7885
- if (!encrypted || (passThrough && crc32 !== UNDEFINED_VALUE)) {
8233
+ if (!encrypted || (passThroughCompression && crc32 !== UNDEFINED_VALUE)) {
7886
8234
  setUint32(localHeaderView, HEADER_OFFSET_SIGNATURE + LOCAL_HEADER_COMMON_OFFSET, crc32);
7887
8235
  }
7888
8236
  if (!zip64CompressedSize) {
@@ -7919,9 +8267,8 @@
7919
8267
  rawExtraFieldUnix,
7920
8268
  rawExtraField,
7921
8269
  rawCentralExtraField,
7922
- extendedTimestamp,
7923
8270
  extraFieldExtendedTimestampFlag,
7924
- lastModDate,
8271
+ extraFieldExtendedTimestampTime,
7925
8272
  zip64Enabled,
7926
8273
  uncompressedSize,
7927
8274
  compressedSize
@@ -7964,16 +8311,15 @@
7964
8311
  fileEntry.zip64Offset = zip64Offset;
7965
8312
  fileEntry.zip64DiskNumberStart = zip64DiskNumberStart;
7966
8313
  let rawExtraFieldTimestamp;
7967
- const lastModTimeUnix = getTimeUnix(lastModDate);
7968
- if (extendedTimestamp && inUnixTimeRange(lastModTimeUnix)) {
8314
+ if (extraFieldExtendedTimestampTime === UNDEFINED_VALUE) {
8315
+ rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
8316
+ } else {
7969
8317
  const extraFieldTimestamp = createRecordWriter(9);
7970
8318
  extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7971
8319
  extraFieldTimestamp.writeUint16(5);
7972
8320
  extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
7973
- extraFieldTimestamp.writeUint32(lastModTimeUnix);
8321
+ extraFieldTimestamp.writeUint32(extraFieldExtendedTimestampTime);
7974
8322
  rawExtraFieldTimestamp = extraFieldTimestamp.array;
7975
- } else {
7976
- rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
7977
8323
  }
7978
8324
  fileEntry.rawExtraFieldExtendedTimestamp = rawExtraFieldTimestamp;
7979
8325
  const extraFieldLength = getLength(
@@ -8473,6 +8819,11 @@
8473
8819
  };
8474
8820
  }
8475
8821
 
8822
+ function isPrintableASCIIText(rawText) {
8823
+ return rawText.every(characterCode =>
8824
+ characterCode >= MIN_PRINTABLE_ASCII_CHARACTER_CODE && characterCode <= MAX_PRINTABLE_ASCII_CHARACTER_CODE);
8825
+ }
8826
+
8476
8827
  function getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod) {
8477
8828
  let bitFlag = 0;
8478
8829
  if (useUnicodeFileNames) {
@@ -8634,7 +8985,7 @@
8634
8985
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8635
8986
  */
8636
8987
 
8637
- const VERSION = "2.11.3";
8988
+ const VERSION = "2.12.0";
8638
8989
 
8639
8990
  /*
8640
8991
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
@@ -9115,7 +9466,10 @@
9115
9466
  const ERR_ENTRY_EXISTS = "Entry filename already exists";
9116
9467
  const ERR_DUPLICATE_IMPORTED_ENTRY = "Duplicate entry filename in the imported zip file";
9117
9468
  const ERR_INVALID_DUPLICATES = "Invalid duplicates option (must be \"throw\", \"keep-first\" or \"keep-last\")";
9118
- const ERR_ANCESTOR_ENTRY = "Entry is a ancestor of target entry";
9469
+ const ERR_ANCESTOR_ENTRY = "Entry is an ancestor of target entry";
9470
+ const ERR_ROOT_DIRECTORY_NOT_MOVABLE = "Root directory cannot be moved";
9471
+ const ERR_TARGET_NOT_DIRECTORY = "Target entry is not a directory";
9472
+ const ERR_PARENT_NOT_DIRECTORY = "Parent entry is not a directory";
9119
9473
  const ERR_READABLE_CONSUMED = "Readable stream already consumed";
9120
9474
  const DUPLICATES_THROW = "throw";
9121
9475
  const DUPLICATES_KEEP_FIRST = "keep-first";
@@ -9123,24 +9477,8 @@
9123
9477
  const DUPLICATES_VALUES = new Set([DUPLICATES_THROW, DUPLICATES_KEEP_FIRST, DUPLICATES_KEEP_LAST]);
9124
9478
  const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.passThrough or set uncompressedSize for each entry)";
9125
9479
  const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
9126
- const ERR_ZIP_CRYPTO_LAST_MOD_DATE = "The last modification date of an entry encrypted with ZipCrypto cannot be changed when passThrough is set";
9480
+ const ERR_UNSUPPORTED_PASS_THROUGH_VALUE = "The 'compressed' passThrough option is only supported by Entry#getData() and ZipWriter#add()";
9127
9481
  const ERR_ABORT_EXPORT = "zipjs-abort-export";
9128
- const ERR_ABORTED = "The operation was aborted";
9129
- const ABORT_ERROR_NAME = "AbortError";
9130
- const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
9131
- const INTERPRETED_EXTRA_FIELD_TYPES = new Set([
9132
- EXTRAFIELD_TYPE_ZIP64,
9133
- EXTRAFIELD_TYPE_AES,
9134
- EXTRAFIELD_TYPE_NTFS,
9135
- EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP,
9136
- EXTRAFIELD_TYPE_UNICODE_PATH,
9137
- EXTRAFIELD_TYPE_UNICODE_COMMENT,
9138
- EXTRAFIELD_TYPE_USDZ,
9139
- EXTRAFIELD_TYPE_INFOZIP,
9140
- EXTRAFIELD_TYPE_UNIX,
9141
- EXTRAFIELD_TYPE_UNIX_TYPE1,
9142
- EXTRAFIELD_TYPE_PKWARE_UNIX
9143
- ]);
9144
9482
 
9145
9483
  class ZipEntry {
9146
9484
 
@@ -9512,6 +9850,7 @@
9512
9850
  await initStream(reader);
9513
9851
  zipReader = new ZipReader(reader, options);
9514
9852
  }
9853
+ checkPassThroughValue(options.passThrough);
9515
9854
  const duplicates = checkDuplicatesOption(options.duplicates);
9516
9855
  const importedEntries = [];
9517
9856
  const entries = await zipReader.getEntries(options);
@@ -9602,18 +9941,25 @@
9602
9941
 
9603
9942
  async exportZip(writer, options = {}) {
9604
9943
  const zipEntry = this;
9944
+ const zipWriterProvided = Boolean(writer) && typeof writer.add == FUNCTION_TYPE;
9605
9945
  options = Object.assign({}, options);
9606
- if (options.bufferedWrite === UNDEFINED_VALUE) {
9946
+ if (!zipWriterProvided && options.bufferedWrite === UNDEFINED_VALUE) {
9607
9947
  options.bufferedWrite = true;
9608
9948
  }
9609
- const [readers] = await Promise.all([initReaders(zipEntry, checkReaderOptions(options.readerOptions)), initStream(writer)]);
9610
- const zipWriter = new ZipWriter(writer, options);
9949
+ const [readers] = await Promise.all([
9950
+ initReaders(zipEntry, checkReaderOptions(options.readerOptions)),
9951
+ zipWriterProvided ? UNDEFINED_VALUE : initStream(writer)
9952
+ ]);
9953
+ const zipWriter = zipWriterProvided ? writer : new ZipWriter(writer, options);
9611
9954
  await exportZip(zipWriter, zipEntry, getTotalSize([zipEntry], getUncompressedSize), options, readers);
9955
+ if (zipWriterProvided) {
9956
+ return zipWriter;
9957
+ }
9612
9958
  await zipWriter.close(options.globalComment);
9613
9959
  return writer.getData ? writer.getData() : writer.writable;
9614
9960
  }
9615
9961
 
9616
- getExportedSize(options = {}) {
9962
+ async getExportedSize(options = {}) {
9617
9963
  const zipEntry = this;
9618
9964
  options = Object.assign({}, options);
9619
9965
  checkReaderOptions(options.readerOptions);
@@ -9628,7 +9974,7 @@
9628
9974
  const writeOrderGuaranteed = !options.bufferedWrite ||
9629
9975
  (entries.every(entry => entry.options.keepOrder !== false) &&
9630
9976
  children.every(child => isImplicitDirectory(child) || !child.children.length));
9631
- return getEntriesSize(options, entries, writeOrderGuaranteed, options.globalComment);
9977
+ return await getEntriesSize(options, entries, writeOrderGuaranteed, options.globalComment);
9632
9978
  }
9633
9979
 
9634
9980
  getChildByName(name) {
@@ -9689,7 +10035,7 @@
9689
10035
 
9690
10036
  move(entry, destination) {
9691
10037
  if (entry == this.root) {
9692
- throw new Error("Root directory cannot be moved");
10038
+ throw new Error(ERR_ROOT_DIRECTORY_NOT_MOVABLE);
9693
10039
  } else {
9694
10040
  if (destination.directory) {
9695
10041
  if (!destination.isDescendantOf(entry)) {
@@ -9710,7 +10056,7 @@
9710
10056
  throw new Error(ERR_ANCESTOR_ENTRY);
9711
10057
  }
9712
10058
  } else {
9713
- throw new Error("Target entry is not a directory");
10059
+ throw new Error(ERR_TARGET_NOT_DIRECTORY);
9714
10060
  }
9715
10061
  }
9716
10062
  }
@@ -10023,70 +10369,11 @@
10023
10369
  let zipEntryMetadata = {};
10024
10370
  let passThroughOptions = {};
10025
10371
  if (child.data instanceof Entry) {
10026
- const {
10027
- externalFileAttributes,
10028
- versionMadeBy,
10029
- comment,
10030
- lastModDate,
10031
- rawLastModDate,
10032
- creationDate,
10033
- lastAccessDate,
10034
- uncompressedSize,
10035
- encrypted,
10036
- zipCrypto,
10037
- crc32,
10038
- compressionMethod,
10039
- extraFieldAES,
10040
- internalFileAttributes,
10041
- extraField,
10042
- bitFlag,
10043
- uid,
10044
- gid
10045
- } = child.data;
10046
- zipEntryMetadata = {
10047
- externalFileAttributes,
10048
- versionMadeBy,
10049
- comment,
10050
- lastModDate,
10051
- creationDate,
10052
- lastAccessDate,
10053
- internalFileAttributes
10054
- };
10055
- const userExtraField = getUserExtraField(extraField);
10056
- if (userExtraField) {
10057
- zipEntryMetadata.extraField = userExtraField;
10058
- }
10059
- if (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE) {
10060
- Object.assign(zipEntryMetadata, {
10061
- uid,
10062
- gid,
10063
- unixExtraFieldType: INFOZIP_EXTRA_FIELD_TYPE
10064
- });
10065
- }
10066
- if (isPassThrough(child, options)) {
10067
- let encryptionStrength;
10068
- if (extraFieldAES) {
10069
- encryptionStrength = extraFieldAES.strength;
10070
- }
10071
- passThroughOptions = {
10072
- passThrough: true,
10073
- encrypted,
10074
- zipCrypto,
10075
- crc32,
10076
- uncompressedSize,
10077
- encryptionStrength,
10078
- compressionMethod
10079
- };
10080
- if (bitFlag) {
10081
- passThroughOptions.dataDescriptor = bitFlag.dataDescriptor;
10082
- }
10083
- const lastModDateOverride = childOptions.lastModDate === UNDEFINED_VALUE ? options.lastModDate : childOptions.lastModDate;
10084
- if (lastModDateOverride === UNDEFINED_VALUE) {
10085
- passThroughOptions.rawLastModDate = rawLastModDate;
10086
- } else if (zipCrypto && (!bitFlag || bitFlag.dataDescriptor) && lastModDateOverride instanceof Date &&
10087
- getDosTimeHighByte(lastModDateOverride) != ((rawLastModDate >>> 8) & MAX_8_BITS)) {
10088
- throw new Error(ERR_ZIP_CRYPTO_LAST_MOD_DATE);
10089
- }
10372
+ const passThrough = isPassThrough(child, options);
10373
+ const lastModDateOverride = childOptions.lastModDate === UNDEFINED_VALUE ? options.lastModDate : childOptions.lastModDate;
10374
+ ({ entryOptions: zipEntryMetadata, passThroughOptions } = getSourceEntryOptions(child.data, passThrough, lastModDateOverride));
10375
+ if (passThrough) {
10376
+ passThroughOptions.passThrough = true;
10090
10377
  }
10091
10378
  }
10092
10379
  const entryOptions = Object.assign({ lastModDate: child.defaultLastModDate }, zipEntryMetadata, options, childOptions, passThroughOptions, { directory: child.directory });
@@ -10096,16 +10383,6 @@
10096
10383
  return { name, entryOptions };
10097
10384
  }
10098
10385
 
10099
- function getDosTimeHighByte(lastModDate) {
10100
- let dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
10101
- if (dosLastModDate < MIN_DATE) {
10102
- dosLastModDate = MIN_DATE;
10103
- } else if (dosLastModDate > MAX_DATE) {
10104
- dosLastModDate = MAX_DATE;
10105
- }
10106
- return ((dosLastModDate.getHours() << 3) | (dosLastModDate.getMinutes() >> 3)) & MAX_8_BITS;
10107
- }
10108
-
10109
10386
  function getDeterminedSize(child, passThrough) {
10110
10387
  const { reader } = child;
10111
10388
  if (reader && reader.size !== UNDEFINED_VALUE) {
@@ -10118,9 +10395,18 @@
10118
10395
  if (readerOptions && (typeof readerOptions != OBJECT_TYPE || Array.isArray(readerOptions))) {
10119
10396
  throw new Error(ERR_INVALID_READER_OPTIONS);
10120
10397
  }
10398
+ if (readerOptions) {
10399
+ checkPassThroughValue(readerOptions.passThrough);
10400
+ }
10121
10401
  return readerOptions;
10122
10402
  }
10123
10403
 
10404
+ function checkPassThroughValue(passThrough) {
10405
+ if (checkPassThroughOption(passThrough) === PASS_THROUGH_COMPRESSED) {
10406
+ throw new Error(ERR_UNSUPPORTED_PASS_THROUGH_VALUE);
10407
+ }
10408
+ }
10409
+
10124
10410
  function replaceContent(zipEntry, params) {
10125
10411
  const { uncompressedSize } = params;
10126
10412
  Object.assign(zipEntry, params, {
@@ -10149,20 +10435,6 @@
10149
10435
  return child.directory && child.data === null;
10150
10436
  }
10151
10437
 
10152
- function getUserExtraField(extraField) {
10153
- if (extraField) {
10154
- const userExtraField = new Map();
10155
- extraField.forEach((field, type) => {
10156
- if (!INTERPRETED_EXTRA_FIELD_TYPES.has(type)) {
10157
- userExtraField.set(type, field.data);
10158
- }
10159
- });
10160
- if (userExtraField.size) {
10161
- return userExtraField;
10162
- }
10163
- }
10164
- }
10165
-
10166
10438
  async function exportZip(zipWriter, entry, totalSize, options, readers) {
10167
10439
  const { onstart, onprogress, onend, onentryprogress } = options;
10168
10440
  const selectedEntry = entry;
@@ -10265,6 +10537,7 @@
10265
10537
 
10266
10538
  async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
10267
10539
  const { onstart, onprogress, onend } = options;
10540
+ checkPassThroughValue(options.passThrough);
10268
10541
  const readerOptions = checkReaderOptions(options.readerOptions);
10269
10542
  const abortController = new AbortController();
10270
10543
  const { signal } = abortController;
@@ -10340,7 +10613,7 @@
10340
10613
  if (exportAborted || isExportAborted(signal.reason)) {
10341
10614
  return;
10342
10615
  }
10343
- throw signal.reason === UNDEFINED_VALUE ? new DOMException(ERR_ABORTED, ABORT_ERROR_NAME) : signal.reason;
10616
+ throwIfAborted(signal);
10344
10617
  }
10345
10618
  try {
10346
10619
  if (child.directory) {
@@ -10473,7 +10746,7 @@
10473
10746
  }
10474
10747
  return directory ? new ZipDirectoryEntry(parent.fs, name, params, parent) : new ZipFileEntry(parent.fs, name, params, parent);
10475
10748
  } else {
10476
- throw new Error("Parent entry is not a directory");
10749
+ throw new Error(ERR_PARENT_NOT_DIRECTORY);
10477
10750
  }
10478
10751
  }
10479
10752
 
@@ -10520,6 +10793,7 @@
10520
10793
  exports.Data64URIWriter = Data64URIWriter;
10521
10794
  exports.ERR_ABORTED = ERR_ABORTED;
10522
10795
  exports.ERR_AMBIGUOUS_ARCHIVE = ERR_AMBIGUOUS_ARCHIVE;
10796
+ exports.ERR_ANCESTOR_ENTRY = ERR_ANCESTOR_ENTRY;
10523
10797
  exports.ERR_BAD_FORMAT = ERR_BAD_FORMAT;
10524
10798
  exports.ERR_CENTRAL_DIRECTORY_NOT_FOUND = ERR_CENTRAL_DIRECTORY_NOT_FOUND;
10525
10799
  exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
@@ -10533,7 +10807,9 @@
10533
10807
  exports.ERR_EXTRAFIELD_ZIP64_NOT_FOUND = ERR_EXTRAFIELD_ZIP64_NOT_FOUND;
10534
10808
  exports.ERR_HTTP_RANGE = ERR_HTTP_RANGE;
10535
10809
  exports.ERR_HTTP_RESOURCE_CHANGED = ERR_HTTP_RESOURCE_CHANGED;
10810
+ exports.ERR_HTTP_STATUS = ERR_HTTP_STATUS;
10536
10811
  exports.ERR_INVALID_AUTHENTICATION_CODE = ERR_INVALID_AUTHENTICATION_CODE;
10812
+ exports.ERR_INVALID_BASE_URI = ERR_INVALID_BASE_URI;
10537
10813
  exports.ERR_INVALID_CODEC_DEFINITION = ERR_INVALID_CODEC_DEFINITION;
10538
10814
  exports.ERR_INVALID_CODEC_MODULE = ERR_INVALID_CODEC_MODULE;
10539
10815
  exports.ERR_INVALID_COMMENT = ERR_INVALID_COMMENT;
@@ -10543,6 +10819,7 @@
10543
10819
  exports.ERR_INVALID_DATE = ERR_INVALID_DATE;
10544
10820
  exports.ERR_INVALID_DUPLICATES = ERR_INVALID_DUPLICATES;
10545
10821
  exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
10822
+ exports.ERR_INVALID_ENTRY = ERR_INVALID_ENTRY;
10546
10823
  exports.ERR_INVALID_ENTRY_COMMENT = ERR_INVALID_ENTRY_COMMENT;
10547
10824
  exports.ERR_INVALID_ENTRY_COMMENT_TYPE = ERR_INVALID_ENTRY_COMMENT_TYPE;
10548
10825
  exports.ERR_INVALID_ENTRY_NAME = ERR_INVALID_ENTRY_NAME;
@@ -10561,6 +10838,7 @@
10561
10838
  exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
10562
10839
  exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
10563
10840
  exports.ERR_INVALID_PASS_THROUGH = ERR_INVALID_PASS_THROUGH;
10841
+ exports.ERR_INVALID_PASS_THROUGH_VALUE = ERR_INVALID_PASS_THROUGH_VALUE;
10564
10842
  exports.ERR_INVALID_READER = ERR_INVALID_READER;
10565
10843
  exports.ERR_INVALID_READER_OPTIONS = ERR_INVALID_READER_OPTIONS;
10566
10844
  exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
@@ -10571,14 +10849,19 @@
10571
10849
  exports.ERR_INVALID_UNIX_EXTRA_FIELD_TYPE = ERR_INVALID_UNIX_EXTRA_FIELD_TYPE;
10572
10850
  exports.ERR_INVALID_UNIX_ID_SIZE = ERR_INVALID_UNIX_ID_SIZE;
10573
10851
  exports.ERR_INVALID_UNIX_MODE = ERR_INVALID_UNIX_MODE;
10852
+ exports.ERR_INVALID_URI = ERR_INVALID_URI;
10574
10853
  exports.ERR_INVALID_VERSION = ERR_INVALID_VERSION;
10575
10854
  exports.ERR_ITERATOR_COMPLETED_TOO_SOON = ERR_ITERATOR_COMPLETED_TOO_SOON;
10576
10855
  exports.ERR_LOCAL_FILE_HEADER_NOT_FOUND = ERR_LOCAL_FILE_HEADER_NOT_FOUND;
10577
10856
  exports.ERR_OVERLAPPING_ENTRY = ERR_OVERLAPPING_ENTRY;
10857
+ exports.ERR_PARENT_NOT_DIRECTORY = ERR_PARENT_NOT_DIRECTORY;
10578
10858
  exports.ERR_READABLE_CONSUMED = ERR_READABLE_CONSUMED;
10579
10859
  exports.ERR_RESERVED_COMPRESSION_METHOD = ERR_RESERVED_COMPRESSION_METHOD;
10860
+ exports.ERR_ROOT_DIRECTORY_NOT_MOVABLE = ERR_ROOT_DIRECTORY_NOT_MOVABLE;
10580
10861
  exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
10862
+ exports.ERR_TARGET_NOT_DIRECTORY = ERR_TARGET_NOT_DIRECTORY;
10581
10863
  exports.ERR_UNDEFINED_COMPRESSION_METHOD = ERR_UNDEFINED_COMPRESSION_METHOD;
10864
+ exports.ERR_UNDEFINED_CRC32 = ERR_UNDEFINED_CRC32;
10582
10865
  exports.ERR_UNDEFINED_READER = ERR_UNDEFINED_READER;
10583
10866
  exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
10584
10867
  exports.ERR_UNDETERMINED_SIZE = ERR_UNDETERMINED_SIZE;
@@ -10590,10 +10873,12 @@
10590
10873
  exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
10591
10874
  exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
10592
10875
  exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
10876
+ exports.ERR_UNSUPPORTED_PASS_THROUGH_VALUE = ERR_UNSUPPORTED_PASS_THROUGH_VALUE;
10593
10877
  exports.ERR_UNSUPPORTED_SPLIT_USDZ = ERR_UNSUPPORTED_SPLIT_USDZ;
10594
10878
  exports.ERR_UNSUPPORTED_UINT64 = ERR_UNSUPPORTED_UINT64;
10595
10879
  exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
10596
10880
  exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
10881
+ exports.ERR_WRITER_SIZE_NOT_WRITABLE = ERR_WRITER_SIZE_NOT_WRITABLE;
10597
10882
  exports.ERR_ZIP_CRYPTO_LAST_MOD_DATE = ERR_ZIP_CRYPTO_LAST_MOD_DATE;
10598
10883
  exports.ERR_ZIP_NOT_EMPTY = ERR_ZIP_NOT_EMPTY;
10599
10884
  exports.HttpRangeReader = HttpRangeReader;
@@ -10607,13 +10892,17 @@
10607
10892
  exports.Uint8ArrayWriter = Uint8ArrayWriter;
10608
10893
  exports.VERSION = VERSION;
10609
10894
  exports.WARNING_APPENDED_DATA = WARNING_APPENDED_DATA;
10895
+ exports.WARNING_CLAMPED_LAST_MODIFICATION_DATE = WARNING_CLAMPED_LAST_MODIFICATION_DATE;
10610
10896
  exports.WARNING_COMPRESSED_PATCHED_DATA = WARNING_COMPRESSED_PATCHED_DATA;
10897
+ exports.WARNING_COMPRESSION_UNAVAILABLE = WARNING_COMPRESSION_UNAVAILABLE;
10611
10898
  exports.WARNING_DUPLICATE_FILENAME = WARNING_DUPLICATE_FILENAME;
10612
10899
  exports.WARNING_MALFORMED_EXTRA_FIELD = WARNING_MALFORMED_EXTRA_FIELD;
10613
10900
  exports.WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG = WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG;
10614
10901
  exports.WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD = WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD;
10615
10902
  exports.WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES = WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES;
10903
+ exports.WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME = WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME;
10616
10904
  exports.WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY = WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY;
10905
+ exports.WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY = WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY;
10617
10906
  exports.WARNING_PREPENDED_CENTRAL_DIRECTORY = WARNING_PREPENDED_CENTRAL_DIRECTORY;
10618
10907
  exports.WARNING_PREPENDED_DATA = WARNING_PREPENDED_DATA;
10619
10908
  exports.WARNING_TRAILING_CENTRAL_DIRECTORY_DATA = WARNING_TRAILING_CENTRAL_DIRECTORY_DATA;