@zip.js/zip.js 2.8.53 → 2.8.54

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 (47) hide show
  1. package/README.md +1 -1
  2. package/deno.json +2 -1
  3. package/dist/zip-core-external.js +691 -482
  4. package/dist/zip-core-external.min.js +1 -1
  5. package/dist/zip-core.js +698 -481
  6. package/dist/zip-core.min.js +1 -1
  7. package/dist/zip-fs-core-external.js +729 -511
  8. package/dist/zip-fs-core-external.min.js +1 -1
  9. package/dist/zip-fs-core.js +691 -496
  10. package/dist/zip-fs-core.min.js +1 -1
  11. package/dist/zip-fs-external.js +729 -511
  12. package/dist/zip-fs-external.min.js +1 -1
  13. package/dist/zip-fs-native.js +743 -512
  14. package/dist/zip-fs-native.min.js +1 -1
  15. package/dist/zip-fs.js +742 -511
  16. package/dist/zip-fs.min.js +1 -1
  17. package/dist/zip-legacy.js +700 -483
  18. package/dist/zip-legacy.min.js +1 -1
  19. package/dist/zip-native.js +700 -483
  20. package/dist/zip-native.min.js +1 -1
  21. package/dist/zip-web-worker-native.js +1 -1
  22. package/dist/zip-web-worker.js +1 -1
  23. package/dist/zip.js +699 -482
  24. package/dist/zip.min.js +1 -1
  25. package/eslint.config.mjs +1 -0
  26. package/index-native.cjs +743 -512
  27. package/index-native.min.js +1 -1
  28. package/index.cjs +742 -511
  29. package/index.d.cts +398 -42
  30. package/index.d.ts +398 -42
  31. package/index.min.js +1 -1
  32. package/lib/core/configuration.js +62 -21
  33. package/lib/core/constants.js +11 -1
  34. package/lib/core/io.js +33 -27
  35. package/lib/core/options.js +44 -2
  36. package/lib/core/streams/aes-crypto-stream.js +12 -12
  37. package/lib/core/util/decode-text.js +11 -2
  38. package/lib/core/web-worker-base.js +3 -2
  39. package/lib/core/web-worker-inline-native.js +1 -1
  40. package/lib/core/web-worker-inline-wasm.js +1 -1
  41. package/lib/core/zip-fs.js +38 -27
  42. package/lib/core/zip-reader.js +58 -26
  43. package/lib/core/zip-writer.js +293 -177
  44. package/lib/zip-core-base.js +6 -1
  45. package/lib/zip-core-reader.js +1 -0
  46. package/lib/zip-core-writer.js +4 -0
  47. package/package.json +8 -2
@@ -36,6 +36,7 @@ const COMPRESSION_METHOD_AES = 0x63;
36
36
 
37
37
  const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50;
38
38
  const SPLIT_ZIP_FILE_SIGNATURE = 0x08074b50;
39
+ const TEMPORARY_SPLIT_ZIP_FILE_SIGNATURE = 0x30304b50;
39
40
  const DATA_DESCRIPTOR_RECORD_SIGNATURE = SPLIT_ZIP_FILE_SIGNATURE;
40
41
  const ARCHIVE_EXTRA_DATA_SIGNATURE = 0x08064b50;
41
42
  const DIGITAL_SIGNATURE_RECORD_SIGNATURE = 0x05054b50;
@@ -52,6 +53,7 @@ const ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH = END_OF_CENTRAL_DIR_LENGTH + ZIP64_
52
53
  const DATA_DESCRIPTOR_RECORD_LENGTH = 12;
53
54
  const DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH = 20;
54
55
  const DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH = 4;
56
+ const SPLIT_ZIP_FILE_SIGNATURE_LENGTH = 4;
55
57
 
56
58
  const EXTRAFIELD_TYPE_ZIP64 = 0x0001;
57
59
  const EXTRAFIELD_TYPE_AES = 0x9901;
@@ -103,6 +105,8 @@ const HEADER_OFFSET_VERSION = 0;
103
105
  const HEADER_OFFSET_SIGNATURE = 10;
104
106
  const HEADER_OFFSET_COMPRESSED_SIZE = 14;
105
107
  const HEADER_OFFSET_UNCOMPRESSED_SIZE = 18;
108
+ const HEADER_OFFSET_FILENAME_LENGTH = 22;
109
+ const HEADER_OFFSET_EXTRAFIELD_LENGTH = 24;
106
110
  const LOCAL_HEADER_COMMON_OFFSET = 4;
107
111
 
108
112
  const MAX_DATE = new Date(2107, 11, 31, 23, 59, 58);
@@ -115,9 +119,116 @@ const FUNCTION_TYPE = "function";
115
119
  const OBJECT_TYPE = "object";
116
120
  const STRING_TYPE = "string";
117
121
  const NUMBER_TYPE = "number";
122
+ const BOOLEAN_TYPE = "boolean";
118
123
 
119
124
  const EMPTY_UINT8_ARRAY = new Uint8Array();
120
125
 
126
+ /*
127
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
128
+
129
+ Redistribution and use in source and binary forms, with or without
130
+ modification, are permitted provided that the following conditions are met:
131
+
132
+ 1. Redistributions of source code must retain the above copyright notice,
133
+ this list of conditions and the following disclaimer.
134
+
135
+ 2. Redistributions in binary form must reproduce the above copyright
136
+ notice, this list of conditions and the following disclaimer in
137
+ the documentation and/or other materials provided with the distribution.
138
+
139
+ 3. The names of the authors may not be used to endorse or promote products
140
+ derived from this software without specific prior written permission.
141
+
142
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
143
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
144
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
145
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
146
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
147
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
148
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
149
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
150
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
151
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
152
+ */
153
+
154
+
155
+ const OPTION_FILENAME_ENCODING = "filenameEncoding";
156
+ const OPTION_COMMENT_ENCODING = "commentEncoding";
157
+ const OPTION_DECODE_TEXT = "decodeText";
158
+ const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
159
+ const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
160
+ const OPTION_PASSWORD = "password";
161
+ const OPTION_RAW_PASSWORD = "rawPassword";
162
+ const OPTION_PASS_THROUGH = "passThrough";
163
+ const OPTION_SIGNAL = "signal";
164
+ const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
165
+ const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
166
+ const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
167
+ const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
168
+ const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
169
+ const OPTION_CHECK_SIGNATURE = "checkSignature";
170
+ const OPTION_CHECK_CRC32 = "checkCrc32";
171
+ const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
172
+ const OPTION_USE_WEB_WORKERS = "useWebWorkers";
173
+ const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
174
+ const OPTION_TRANSFER_STREAMS = "transferStreams";
175
+ const OPTION_PREVENT_CLOSE = "preventClose";
176
+ const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
177
+ const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
178
+ const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
179
+ const OPTION_KEEP_ORDER = "keepOrder";
180
+ const OPTION_LEVEL = "level";
181
+ const OPTION_BUFFERED_WRITE = "bufferedWrite";
182
+ const OPTION_CREATE_TEMP_STREAM = "createTempStream";
183
+ const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
184
+ const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
185
+ const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
186
+ const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
187
+ const OPTION_ENCODE_TEXT = "encodeText";
188
+ const OPTION_OFFSET = "offset";
189
+ const OPTION_USDZ = "usdz";
190
+ const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
191
+ const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
192
+ const OPTION_STRICTNESS = "strictness";
193
+ const OPTION_FILENAME_VALIDATION = "filenameValidation";
194
+ const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
195
+ const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
196
+ const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
197
+ const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
198
+ const TEXT_TYPE_FILENAME = "filename";
199
+ const TEXT_TYPE_COMMENT = "comment";
200
+ const STRICTNESS_STRICT = "strict";
201
+ const STRICTNESS_BALANCED = "balanced";
202
+ const STRICTNESS_TOLERANT = "tolerant";
203
+
204
+ const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
205
+ const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
206
+ const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
207
+
208
+ function checkFunctionOption(value) {
209
+ if (value && typeof value != FUNCTION_TYPE) {
210
+ throw new Error(ERR_INVALID_FUNCTION_OPTION);
211
+ }
212
+ return value;
213
+ }
214
+
215
+ function checkSignalOption(signal) {
216
+ if (signal && (typeof signal.addEventListener != FUNCTION_TYPE || typeof signal.aborted != BOOLEAN_TYPE)) {
217
+ throw new Error(ERR_INVALID_SIGNAL);
218
+ }
219
+ return signal || UNDEFINED_VALUE;
220
+ }
221
+
222
+ function checkPasswordOption(password, rawPassword) {
223
+ if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
224
+ throw new Error(ERR_INVALID_PASSWORD_TYPE);
225
+ }
226
+ }
227
+
228
+ function toNumber(value) {
229
+ return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
230
+ }
231
+
121
232
  /*
122
233
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
123
234
 
@@ -147,7 +258,10 @@ const EMPTY_UINT8_ARRAY = new Uint8Array();
147
258
  */
148
259
 
149
260
 
261
+ const DEFAULT_CHUNK_SIZE$1 = 64 * 1024;
150
262
  const MINIMUM_CHUNK_SIZE = 64;
263
+ const MINIMUM_PROPERTY_VALUE = 1;
264
+ const ERR_INVALID_MAX_WORKERS = "Invalid maxWorkers (must be an integer greater than 0)";
151
265
  let maxWorkers = 2;
152
266
  try {
153
267
  if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
@@ -159,7 +273,7 @@ try {
159
273
  const DEFAULT_CONFIGURATION = {
160
274
  workerURI: "./core/web-worker-wasm.js",
161
275
  wasmURI: "./core/streams/zlib-wasm/zlib-streams.wasm",
162
- chunkSize: 64 * 1024,
276
+ chunkSize: DEFAULT_CHUNK_SIZE$1,
163
277
  maxWorkers,
164
278
  terminateWorkerTimeout: 5000,
165
279
  workerStarvationTimeout: 5000,
@@ -171,24 +285,38 @@ const DEFAULT_CONFIGURATION = {
171
285
  DecompressionStream: typeof DecompressionStream != UNDEFINED_TYPE && DecompressionStream
172
286
  };
173
287
 
174
- const CONFIGURABLE_PROPERTY_NAMES = [
288
+ const PROPERTY_NAME_MAX_WORKERS = "maxWorkers";
289
+
290
+ const STRING_PROPERTY_NAMES = [
175
291
  "baseURI",
176
292
  "wasmURI",
177
- "workerURI",
178
- "createWorker",
293
+ "workerURI"
294
+ ];
295
+ const BOOLEAN_PROPERTY_NAMES = [
296
+ "useCompressionStream",
297
+ "useWebWorkers",
298
+ "transferStreams"
299
+ ];
300
+ const NUMBER_PROPERTY_NAMES = [
179
301
  "chunkSize",
180
- "maxWorkers",
302
+ PROPERTY_NAME_MAX_WORKERS,
181
303
  "terminateWorkerTimeout",
182
304
  "workerStarvationTimeout",
183
- "workerStartupTimeout",
184
- "useCompressionStream",
185
- "useWebWorkers",
186
- "transferStreams",
305
+ "workerStartupTimeout"
306
+ ];
307
+ const FUNCTION_PROPERTY_NAMES = [
308
+ "createWorker",
187
309
  "CompressionStream",
188
310
  "DecompressionStream",
189
311
  "CompressionStreamFallback",
190
312
  "DecompressionStreamFallback"
191
313
  ];
314
+ const CONFIGURABLE_PROPERTY_NAMES = [
315
+ ...STRING_PROPERTY_NAMES,
316
+ ...BOOLEAN_PROPERTY_NAMES,
317
+ ...NUMBER_PROPERTY_NAMES,
318
+ ...FUNCTION_PROPERTY_NAMES
319
+ ];
192
320
 
193
321
  const config = { ...DEFAULT_CONFIGURATION };
194
322
 
@@ -197,20 +325,43 @@ function getConfiguration() {
197
325
  }
198
326
 
199
327
  function getChunkSize(config) {
200
- return Math.max(config.chunkSize, MINIMUM_CHUNK_SIZE);
328
+ return normalizeChunkSize(config.chunkSize);
329
+ }
330
+
331
+ function normalizeChunkSize(chunkSize) {
332
+ chunkSize = toNumber(chunkSize);
333
+ return Number.isInteger(chunkSize) && chunkSize >= MINIMUM_PROPERTY_VALUE ? Math.max(chunkSize, MINIMUM_CHUNK_SIZE) : DEFAULT_CHUNK_SIZE$1;
201
334
  }
202
335
 
203
336
  function configure(configuration) {
204
- configuration = normalizeConfiguration(configuration);
337
+ Object.assign(config, checkConfiguration(normalizeConfiguration(configuration)));
338
+ }
339
+
340
+ function checkConfiguration(configuration) {
341
+ const checkedConfiguration = {};
205
342
  for (const propertyName of CONFIGURABLE_PROPERTY_NAMES) {
206
343
  const propertyValue = configuration[propertyName];
207
344
  if (propertyValue !== UNDEFINED_VALUE) {
208
- config[propertyName] = propertyValue;
345
+ checkedConfiguration[propertyName] = checkPropertyValue(propertyName, propertyValue);
209
346
  }
210
347
  }
348
+ return checkedConfiguration;
349
+ }
350
+
351
+ function checkPropertyValue(propertyName, propertyValue) {
352
+ if (NUMBER_PROPERTY_NAMES.includes(propertyName)) {
353
+ propertyValue = toNumber(propertyValue);
354
+ if (propertyName == PROPERTY_NAME_MAX_WORKERS && (!Number.isInteger(propertyValue) || propertyValue < MINIMUM_PROPERTY_VALUE)) {
355
+ throw new Error(ERR_INVALID_MAX_WORKERS);
356
+ }
357
+ } else if (FUNCTION_PROPERTY_NAMES.includes(propertyName)) {
358
+ checkFunctionOption(propertyValue);
359
+ }
360
+ return propertyValue;
211
361
  }
212
362
 
213
363
  function normalizeConfiguration(configuration) {
364
+ configuration = configuration || {};
214
365
  const { CompressionStreamZlib, DecompressionStreamZlib } = configuration;
215
366
  if (CompressionStreamZlib === UNDEFINED_VALUE && DecompressionStreamZlib === UNDEFINED_VALUE) {
216
367
  return configuration;
@@ -226,14 +377,9 @@ function normalizeConfiguration(configuration) {
226
377
  }
227
378
 
228
379
  function setDefaultConfiguration(configuration) {
229
- configuration = normalizeConfiguration(configuration);
230
- for (const propertyName of CONFIGURABLE_PROPERTY_NAMES) {
231
- const propertyValue = configuration[propertyName];
232
- if (propertyValue !== UNDEFINED_VALUE) {
233
- DEFAULT_CONFIGURATION[propertyName] = propertyValue;
234
- }
235
- }
236
- configure(configuration);
380
+ const checkedConfiguration = checkConfiguration(normalizeConfiguration(configuration));
381
+ Object.assign(DEFAULT_CONFIGURATION, checkedConfiguration);
382
+ Object.assign(config, checkedConfiguration);
237
383
  }
238
384
 
239
385
  function resetConfiguration() {
@@ -1425,13 +1571,13 @@ class AESDecryptionStream extends TransformStream {
1425
1571
  const {
1426
1572
  ctr,
1427
1573
  hmac,
1428
- pending,
1574
+ pendingInput,
1429
1575
  ready
1430
1576
  } = this;
1431
1577
  if (hmac && ctr) {
1432
1578
  await ready;
1433
- const chunkToDecrypt = subarray(pending, 0, pending.length - AUTHENTICATION_CODE_LENGTH);
1434
- const originalAuthenticationCode = subarray(pending, pending.length - AUTHENTICATION_CODE_LENGTH);
1579
+ const chunkToDecrypt = subarray(pendingInput, 0, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
1580
+ const originalAuthenticationCode = subarray(pendingInput, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
1435
1581
  let decryptedChunkArray = EMPTY_UINT8_ARRAY;
1436
1582
  if (chunkToDecrypt.length) {
1437
1583
  const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
@@ -1440,7 +1586,7 @@ class AESDecryptionStream extends TransformStream {
1440
1586
  decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
1441
1587
  }
1442
1588
  const authenticationCode = subarray(fromBits(codecBytes, hmac.digest()), 0, AUTHENTICATION_CODE_LENGTH);
1443
- let invalidAuthenticationCode = pending.length < AUTHENTICATION_CODE_LENGTH ? 1 : 0;
1589
+ let invalidAuthenticationCode = pendingInput.length < AUTHENTICATION_CODE_LENGTH ? 1 : 0;
1444
1590
  for (let indexByte = 0; indexByte < AUTHENTICATION_CODE_LENGTH; indexByte++) {
1445
1591
  invalidAuthenticationCode |= authenticationCode[indexByte] ^ originalAuthenticationCode[indexByte];
1446
1592
  }
@@ -1484,14 +1630,14 @@ class AESEncryptionStream extends TransformStream {
1484
1630
  const {
1485
1631
  ctr,
1486
1632
  hmac,
1487
- pending,
1633
+ pendingInput,
1488
1634
  ready
1489
1635
  } = this;
1490
1636
  if (hmac && ctr) {
1491
1637
  await ready;
1492
1638
  let encryptedChunkArray = EMPTY_UINT8_ARRAY;
1493
- if (pending.length) {
1494
- const encryptedChunk = ctr.update(toBits(codecBytes, pending));
1639
+ if (pendingInput.length) {
1640
+ const encryptedChunk = ctr.update(toBits(codecBytes, pendingInput));
1495
1641
  hmac.update(encryptedChunk);
1496
1642
  encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
1497
1643
  }
@@ -1508,7 +1654,7 @@ function initAesCrypto(aesCrypto, password, rawPassword, encryptionStrength) {
1508
1654
  ready: new Promise(resolve => aesCrypto.resolveReady = resolve),
1509
1655
  password: encodePassword(password, rawPassword),
1510
1656
  strength: encryptionStrength - 1,
1511
- pending: EMPTY_UINT8_ARRAY
1657
+ pendingInput: EMPTY_UINT8_ARRAY
1512
1658
  });
1513
1659
  }
1514
1660
 
@@ -1516,10 +1662,10 @@ function append(aesCrypto, input, output, paddingStart, paddingEnd, verifyAuthen
1516
1662
  const {
1517
1663
  ctr,
1518
1664
  hmac,
1519
- pending
1665
+ pendingInput
1520
1666
  } = aesCrypto;
1521
- if (pending.length) {
1522
- input = concat(pending, input);
1667
+ if (pendingInput.length) {
1668
+ input = concat(pendingInput, input);
1523
1669
  }
1524
1670
  const inputLength = input.length - paddingEnd;
1525
1671
  output = expand(output, paddingStart + (inputLength - (inputLength % BLOCK_LENGTH)));
@@ -1535,7 +1681,7 @@ function append(aesCrypto, input, output, paddingStart, paddingEnd, verifyAuthen
1535
1681
  }
1536
1682
  output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
1537
1683
  }
1538
- aesCrypto.pending = subarray(input, offset);
1684
+ aesCrypto.pendingInput = subarray(input, offset);
1539
1685
  return output;
1540
1686
  }
1541
1687
 
@@ -3312,6 +3458,96 @@ async function terminateWorkers() {
3312
3458
  resetWebWorkerSupport();
3313
3459
  }
3314
3460
 
3461
+ /*
3462
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
3463
+
3464
+ Redistribution and use in source and binary forms, with or without
3465
+ modification, are permitted provided that the following conditions are met:
3466
+
3467
+ 1. Redistributions of source code must retain the above copyright notice,
3468
+ this list of conditions and the following disclaimer.
3469
+
3470
+ 2. Redistributions in binary form must reproduce the above copyright
3471
+ notice, this list of conditions and the following disclaimer in
3472
+ the documentation and/or other materials provided with the distribution.
3473
+
3474
+ 3. The names of the authors may not be used to endorse or promote products
3475
+ derived from this software without specific prior written permission.
3476
+
3477
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
3478
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
3479
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
3480
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
3481
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3482
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
3483
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
3484
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3485
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3486
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3487
+ */
3488
+
3489
+ /* global TextDecoder */
3490
+
3491
+ const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
3492
+ const VALID_CP437 = CP437.length == 256;
3493
+
3494
+ function decodeCP437(stringValue) {
3495
+ if (VALID_CP437) {
3496
+ let result = "";
3497
+ for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
3498
+ result += CP437[stringValue[indexCharacter]];
3499
+ }
3500
+ return result;
3501
+ } else {
3502
+ return new TextDecoder().decode(stringValue);
3503
+ }
3504
+ }
3505
+
3506
+ /*
3507
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
3508
+
3509
+ Redistribution and use in source and binary forms, with or without
3510
+ modification, are permitted provided that the following conditions are met:
3511
+
3512
+ 1. Redistributions of source code must retain the above copyright notice,
3513
+ this list of conditions and the following disclaimer.
3514
+
3515
+ 2. Redistributions in binary form must reproduce the above copyright
3516
+ notice, this list of conditions and the following disclaimer in
3517
+ the documentation and/or other materials provided with the distribution.
3518
+
3519
+ 3. The names of the authors may not be used to endorse or promote products
3520
+ derived from this software without specific prior written permission.
3521
+
3522
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
3523
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
3524
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
3525
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
3526
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3527
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
3528
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
3529
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3530
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3531
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3532
+ */
3533
+
3534
+
3535
+ function decodeText(value, encoding) {
3536
+ return decode(value, encoding, true);
3537
+ }
3538
+
3539
+ function decodeTextRemovingBOM(value, encoding) {
3540
+ return decode(value, encoding, false);
3541
+ }
3542
+
3543
+ function decode(value, encoding, ignoreBOM) {
3544
+ if (encoding && encoding.trim().toLowerCase() == "cp437") {
3545
+ return decodeCP437(value);
3546
+ } else {
3547
+ return new TextDecoder(encoding, { ignoreBOM }).decode(value);
3548
+ }
3549
+ }
3550
+
3315
3551
  /*
3316
3552
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
3317
3553
 
@@ -3384,6 +3620,7 @@ class Reader extends Stream {
3384
3620
  createReadable({ offset = 0, size, chunkSize = getChunkSize(getConfiguration()) } = {}) {
3385
3621
  const reader = this;
3386
3622
  let chunkOffset = 0;
3623
+ chunkSize = normalizeChunkSize(chunkSize);
3387
3624
  return new ReadableStream({
3388
3625
  async pull(controller) {
3389
3626
  const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
@@ -3391,7 +3628,7 @@ class Reader extends Stream {
3391
3628
  if (data.length) {
3392
3629
  controller.enqueue(data);
3393
3630
  }
3394
- if ((chunkOffset + chunkSize >= size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
3631
+ if ((chunkOffset + chunkSize >= size) || (!data.length && dataSize)) {
3395
3632
  controller.close();
3396
3633
  } else {
3397
3634
  chunkOffset += chunkSize;
@@ -3471,31 +3708,31 @@ class Data64URIWriter extends Writer {
3471
3708
  Object.assign(this, {
3472
3709
  contentType,
3473
3710
  data: "data:" + (contentType || "") + ";base64,",
3474
- pending: []
3711
+ pendingCharacters: ""
3475
3712
  });
3476
3713
  }
3477
3714
 
3478
3715
  writeUint8Array(array) {
3479
3716
  const writer = this;
3480
3717
  let indexArray;
3481
- let dataString = writer.pending;
3482
- const delta = writer.pending.length;
3483
- writer.pending = "";
3718
+ let dataString = writer.pendingCharacters;
3719
+ const delta = writer.pendingCharacters.length;
3720
+ writer.pendingCharacters = "";
3484
3721
  for (indexArray = 0; indexArray < (Math.floor((delta + array.length) / 3) * 3) - delta; indexArray++) {
3485
3722
  dataString += String.fromCharCode(array[indexArray]);
3486
3723
  }
3487
3724
  for (; indexArray < array.length; indexArray++) {
3488
- writer.pending += String.fromCharCode(array[indexArray]);
3725
+ writer.pendingCharacters += String.fromCharCode(array[indexArray]);
3489
3726
  }
3490
3727
  if (dataString.length > 2) {
3491
3728
  writer.data += btoa(dataString);
3492
3729
  } else {
3493
- writer.pending = dataString + writer.pending;
3730
+ writer.pendingCharacters = dataString + writer.pendingCharacters;
3494
3731
  }
3495
3732
  }
3496
3733
 
3497
3734
  getData() {
3498
- return this.data + btoa(this.pending);
3735
+ return this.data + btoa(this.pendingCharacters);
3499
3736
  }
3500
3737
  }
3501
3738
 
@@ -3525,7 +3762,7 @@ class BlobReader extends Reader {
3525
3762
  constructor(blob) {
3526
3763
  super();
3527
3764
  Object.assign(this, {
3528
- blob,
3765
+ sourceBlob: blob,
3529
3766
  size: blob.size
3530
3767
  });
3531
3768
  if (!blobSliceProbe) {
@@ -3535,13 +3772,13 @@ class BlobReader extends Reader {
3535
3772
 
3536
3773
  createReadable(options) {
3537
3774
  const reader = this;
3538
- const { blob, size } = reader;
3775
+ const { sourceBlob, size } = reader;
3539
3776
  const { offset = 0, size: readSize = size - offset } = options || {};
3540
3777
  if (!offset && readSize >= size) {
3541
- return toCompatibleReadable(blob.stream());
3778
+ return toCompatibleReadable(sourceBlob.stream());
3542
3779
  }
3543
3780
  if (blobSliceReliable) {
3544
- return toCompatibleReadable(blob.slice(offset, offset + readSize).stream());
3781
+ return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
3545
3782
  }
3546
3783
  return super.createReadable(options);
3547
3784
  }
@@ -3550,7 +3787,7 @@ class BlobReader extends Reader {
3550
3787
  const reader = this;
3551
3788
  const offsetEnd = offset + length;
3552
3789
  const readsWholeBlob = !offset && offsetEnd >= reader.size;
3553
- const blob = readsWholeBlob ? reader.blob : reader.blob.slice(offset, offsetEnd);
3790
+ const blob = readsWholeBlob ? reader.sourceBlob : reader.sourceBlob.slice(offset, offsetEnd);
3554
3791
  let arrayBuffer = await blob.arrayBuffer();
3555
3792
  const sliceIgnoredByBuggyImplementation = arrayBuffer.byteLength > length;
3556
3793
  if (sliceIgnoredByBuggyImplementation) {
@@ -3572,12 +3809,12 @@ class BlobWriter extends Stream {
3572
3809
  }
3573
3810
  });
3574
3811
  writer.contentType = contentType;
3575
- writer.blob = streamToBlob(transformStream.readable, contentType);
3576
- writer.blob.catch(() => { });
3812
+ writer.blobPromise = streamToBlob(transformStream.readable, contentType);
3813
+ writer.blobPromise.catch(() => { });
3577
3814
  }
3578
3815
 
3579
3816
  getData() {
3580
- return this.blob;
3817
+ return this.blobPromise;
3581
3818
  }
3582
3819
  }
3583
3820
 
@@ -3611,7 +3848,7 @@ function getTextSize(text) {
3611
3848
  class TextWriter extends BlobWriter {
3612
3849
 
3613
3850
  constructor(encoding) {
3614
- super(encoding);
3851
+ super();
3615
3852
  Object.assign(this, {
3616
3853
  encoding,
3617
3854
  utf8: !encoding || encoding.toLowerCase() == "utf-8"
@@ -3627,14 +3864,7 @@ class TextWriter extends BlobWriter {
3627
3864
  if (blob.text && utf8) {
3628
3865
  return blob.text();
3629
3866
  } else {
3630
- const reader = new FileReader();
3631
- return new Promise((resolve, reject) => {
3632
- Object.assign(reader, {
3633
- onload: ({ target }) => resolve(target.result),
3634
- onerror: () => reject(reader.error)
3635
- });
3636
- reader.readAsText(blob, encoding);
3637
- });
3867
+ return decodeTextRemovingBOM(new Uint8Array(await blob.arrayBuffer()), encoding);
3638
3868
  }
3639
3869
  }
3640
3870
  }
@@ -4302,85 +4532,13 @@ function readUint8Array(reader, offset, size) {
4302
4532
  return reader.readUint8Array(offset, size);
4303
4533
  }
4304
4534
 
4305
- /*
4306
- Copyright (c) 2022 Gildas Lormeau. All rights reserved.
4307
-
4308
- Redistribution and use in source and binary forms, with or without
4309
- modification, are permitted provided that the following conditions are met:
4310
-
4311
- 1. Redistributions of source code must retain the above copyright notice,
4312
- this list of conditions and the following disclaimer.
4313
-
4314
- 2. Redistributions in binary form must reproduce the above copyright
4315
- notice, this list of conditions and the following disclaimer in
4316
- the documentation and/or other materials provided with the distribution.
4317
-
4318
- 3. The names of the authors may not be used to endorse or promote products
4319
- derived from this software without specific prior written permission.
4320
-
4321
- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
4322
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
4323
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
4324
- INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
4325
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4326
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
4327
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4328
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4329
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4330
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4331
- */
4332
-
4333
- /* global TextDecoder */
4334
-
4335
- const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
4336
- const VALID_CP437 = CP437.length == 256;
4337
-
4338
- function decodeCP437(stringValue) {
4339
- if (VALID_CP437) {
4340
- let result = "";
4341
- for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
4342
- result += CP437[stringValue[indexCharacter]];
4343
- }
4344
- return result;
4345
- } else {
4346
- return new TextDecoder().decode(stringValue);
4347
- }
4348
- }
4349
-
4350
- /*
4351
- Copyright (c) 2022 Gildas Lormeau. All rights reserved.
4352
-
4353
- Redistribution and use in source and binary forms, with or without
4354
- modification, are permitted provided that the following conditions are met:
4355
-
4356
- 1. Redistributions of source code must retain the above copyright notice,
4357
- this list of conditions and the following disclaimer.
4358
-
4359
- 2. Redistributions in binary form must reproduce the above copyright
4360
- notice, this list of conditions and the following disclaimer in
4361
- the documentation and/or other materials provided with the distribution.
4362
-
4363
- 3. The names of the authors may not be used to endorse or promote products
4364
- derived from this software without specific prior written permission.
4365
-
4366
- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
4367
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
4368
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
4369
- INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
4370
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4371
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
4372
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4373
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4374
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4375
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4376
- */
4377
-
4378
-
4379
- function decodeText(value, encoding) {
4380
- if (encoding && encoding.trim().toLowerCase() == "cp437") {
4381
- return decodeCP437(value);
4535
+ function createReadable(reader, options) {
4536
+ if (reader.createReadable) {
4537
+ return reader.createReadable(options);
4538
+ } else if (reader.readUint8Array) {
4539
+ return Reader.prototype.createReadable.call(reader, options);
4382
4540
  } else {
4383
- return new TextDecoder(encoding, { ignoreBOM: true }).decode(value);
4541
+ return reader.readable;
4384
4542
  }
4385
4543
  }
4386
4544
 
@@ -4540,83 +4698,6 @@ class Entry {
4540
4698
 
4541
4699
  }
4542
4700
 
4543
- /*
4544
- Copyright (c) 2022 Gildas Lormeau. All rights reserved.
4545
-
4546
- Redistribution and use in source and binary forms, with or without
4547
- modification, are permitted provided that the following conditions are met:
4548
-
4549
- 1. Redistributions of source code must retain the above copyright notice,
4550
- this list of conditions and the following disclaimer.
4551
-
4552
- 2. Redistributions in binary form must reproduce the above copyright
4553
- notice, this list of conditions and the following disclaimer in
4554
- the documentation and/or other materials provided with the distribution.
4555
-
4556
- 3. The names of the authors may not be used to endorse or promote products
4557
- derived from this software without specific prior written permission.
4558
-
4559
- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
4560
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
4561
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
4562
- INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
4563
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4564
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
4565
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4566
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4567
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4568
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4569
- */
4570
-
4571
- const OPTION_FILENAME_ENCODING = "filenameEncoding";
4572
- const OPTION_COMMENT_ENCODING = "commentEncoding";
4573
- const OPTION_DECODE_TEXT = "decodeText";
4574
- const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
4575
- const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
4576
- const OPTION_PASSWORD = "password";
4577
- const OPTION_RAW_PASSWORD = "rawPassword";
4578
- const OPTION_PASS_THROUGH = "passThrough";
4579
- const OPTION_SIGNAL = "signal";
4580
- const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
4581
- const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
4582
- const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
4583
- const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
4584
- const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
4585
- const OPTION_CHECK_SIGNATURE = "checkSignature";
4586
- const OPTION_CHECK_CRC32 = "checkCrc32";
4587
- const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
4588
- const OPTION_USE_WEB_WORKERS = "useWebWorkers";
4589
- const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
4590
- const OPTION_TRANSFER_STREAMS = "transferStreams";
4591
- const OPTION_PREVENT_CLOSE = "preventClose";
4592
- const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
4593
- const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
4594
- const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
4595
- const OPTION_KEEP_ORDER = "keepOrder";
4596
- const OPTION_LEVEL = "level";
4597
- const OPTION_BUFFERED_WRITE = "bufferedWrite";
4598
- const OPTION_CREATE_TEMP_STREAM = "createTempStream";
4599
- const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
4600
- const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
4601
- const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
4602
- const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
4603
- const OPTION_ENCODE_TEXT = "encodeText";
4604
- const OPTION_OFFSET = "offset";
4605
- const OPTION_USDZ = "usdz";
4606
- const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
4607
- const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
4608
- const OPTION_STRICTNESS = "strictness";
4609
- const OPTION_FILENAME_VALIDATION = "filenameValidation";
4610
- const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
4611
- const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
4612
- const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
4613
- const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
4614
- const TEXT_TYPE_FILENAME = "filename";
4615
- const TEXT_TYPE_COMMENT = "comment";
4616
- const STRICTNESS_STRICT = "strict";
4617
- const STRICTNESS_BALANCED = "balanced";
4618
- const STRICTNESS_TOLERANT = "tolerant";
4619
-
4620
4701
  /*
4621
4702
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
4622
4703
 
@@ -4657,6 +4738,7 @@ const ERR_UNSUPPORTED_ENCRYPTION = "Encryption method not supported";
4657
4738
  const ERR_UNSUPPORTED_COMPRESSION$1 = "Compression method not supported";
4658
4739
  const ERR_SPLIT_ZIP_FILE = "Split zip file";
4659
4740
  const ERR_OVERLAPPING_ENTRY = "Overlapping entry found";
4741
+ const ERR_ENTRY_DATA_OUT_OF_BOUNDS = "Entry data out of bounds";
4660
4742
  const ERR_AMBIGUOUS_ARCHIVE = "Ambiguous archive";
4661
4743
  const ERR_ENCRYPTED_CENTRAL_DIRECTORY = "Encrypted central directory is not supported";
4662
4744
  const ERR_UNSAFE_FILENAME = "Unsafe filename";
@@ -4677,7 +4759,7 @@ const ZIP64_PROPERTIES = [
4677
4759
  ];
4678
4760
  const ZIP64_EXTRACTION = {
4679
4761
  [MAX_16_BITS]: {
4680
- getValue: getUint32,
4762
+ getValue: getUint32$1,
4681
4763
  bytes: 4
4682
4764
  },
4683
4765
  [MAX_32_BITS]: {
@@ -4686,6 +4768,7 @@ const ZIP64_EXTRACTION = {
4686
4768
  }
4687
4769
  };
4688
4770
  const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
4771
+ const MAX_DEFLATE_EXPANSION_RATIO = 1032;
4689
4772
  const CENTRAL_DIRECTORY_UNREACHABLE = 0;
4690
4773
  const CENTRAL_DIRECTORY_PLAUSIBLE = 1;
4691
4774
  const CENTRAL_DIRECTORY_REACHABLE = 2;
@@ -4696,7 +4779,6 @@ class ZipReader {
4696
4779
  Object.assign(this, {
4697
4780
  reader: new GenericReader(reader),
4698
4781
  options,
4699
- config: getConfiguration(),
4700
4782
  readRanges: new Map()
4701
4783
  });
4702
4784
  }
@@ -4704,7 +4786,6 @@ class ZipReader {
4704
4786
  async* getEntriesGenerator(options = {}) {
4705
4787
  const zipReader = this;
4706
4788
  let { reader } = zipReader;
4707
- const { config } = zipReader;
4708
4789
  await initStream(reader);
4709
4790
  if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
4710
4791
  reader = new BlobReader(await streamToBlob(reader.readable));
@@ -4721,9 +4802,7 @@ class ZipReader {
4721
4802
  const normalizeFilename = getOptionValue$1(zipReader, options, OPTION_NORMALIZE_FILENAME);
4722
4803
  const { endOfDirectoryInfo, endOfDirectoryReachingEndCount } = await findEndOfCentralDirectory(reader, rejectAmbiguousEndOfDirectory, maxAppendedDataSize);
4723
4804
  if (!endOfDirectoryInfo) {
4724
- const signatureArray = await readUint8Array(reader, 0, 4);
4725
- const signatureView = getDataView(signatureArray);
4726
- if (getUint32(signatureView) == SPLIT_ZIP_FILE_SIGNATURE) {
4805
+ if (await startsWithSplitZipSignature$1(reader)) {
4727
4806
  throw new Error(ERR_SPLIT_ZIP_FILE);
4728
4807
  } else {
4729
4808
  throw new Error(ERR_EOCDR_NOT_FOUND);
@@ -4733,18 +4812,18 @@ class ZipReader {
4733
4812
  throwAmbiguousArchive("multiple end of central directory records");
4734
4813
  }
4735
4814
  const endOfDirectoryView = getDataView(endOfDirectoryInfo);
4736
- let directoryDataLength = getUint32(endOfDirectoryView, 12);
4737
- let directoryDataOffset = getUint32(endOfDirectoryView, 16);
4815
+ let directoryDataLength = getUint32$1(endOfDirectoryView, 12);
4816
+ let directoryDataOffset = getUint32$1(endOfDirectoryView, 16);
4738
4817
  const commentOffset = endOfDirectoryInfo.offset;
4739
- const commentLength = getUint16(endOfDirectoryView, 20);
4818
+ const commentLength = getUint16$1(endOfDirectoryView, 20);
4740
4819
  const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
4741
4820
  if (reader.size - appendedDataOffset > maxAppendedDataSize) {
4742
4821
  throwAmbiguousArchive("appended data");
4743
4822
  }
4744
- let lastDiskNumber = getUint16(endOfDirectoryView, 4);
4823
+ let lastDiskNumber = getUint16$1(endOfDirectoryView, 4);
4745
4824
  const expectedLastDiskNumber = reader.lastDiskNumber || 0;
4746
- let diskNumber = getUint16(endOfDirectoryView, 6);
4747
- let filesLength = getUint16(endOfDirectoryView, 10);
4825
+ let diskNumber = getUint16$1(endOfDirectoryView, 6);
4826
+ let filesLength = getUint16$1(endOfDirectoryView, 10);
4748
4827
  let prependedDataLength = 0;
4749
4828
  let startOffset;
4750
4829
  let zip64EndOfDirectory;
@@ -4760,12 +4839,12 @@ class ZipReader {
4760
4839
  EMPTY_UINT8_ARRAY;
4761
4840
  const endOfDirectoryLocatorView = getDataView(endOfDirectoryLocatorArray);
4762
4841
  if (endOfDirectoryLocatorArray.length == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH &&
4763
- getUint32(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
4764
- directoryDataOffset = getDiskOffset$1(reader, getUint32(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
4842
+ getUint32$1(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
4843
+ directoryDataOffset = getDiskOffset$1(reader, getUint32$1(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
4765
4844
  let endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
4766
4845
  let endOfDirectoryView = getDataView(endOfDirectoryArray);
4767
4846
  const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH - ZIP64_END_OF_CENTRAL_DIR_LENGTH;
4768
- if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
4847
+ if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
4769
4848
  directoryDataOffset != expectedDirectoryDataOffset && expectedDirectoryDataOffset >= 0) {
4770
4849
  const originalDirectoryDataOffset = directoryDataOffset;
4771
4850
  directoryDataOffset = expectedDirectoryDataOffset;
@@ -4775,7 +4854,7 @@ class ZipReader {
4775
4854
  endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
4776
4855
  endOfDirectoryView = getDataView(endOfDirectoryArray);
4777
4856
  }
4778
- if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
4857
+ if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
4779
4858
  throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
4780
4859
  }
4781
4860
  zip64EndOfDirectory = true;
@@ -4790,13 +4869,13 @@ class ZipReader {
4790
4869
  }
4791
4870
  }
4792
4871
  if (lastDiskNumber == MAX_16_BITS) {
4793
- lastDiskNumber = getUint32(endOfDirectoryView, 16);
4794
- } else if (checkAmbiguity && lastDiskNumber != getUint32(endOfDirectoryView, 16)) {
4872
+ lastDiskNumber = getUint32$1(endOfDirectoryView, 16);
4873
+ } else if (checkAmbiguity && lastDiskNumber != getUint32$1(endOfDirectoryView, 16)) {
4795
4874
  throwAmbiguousArchive("mismatched zip64 end of central directory record");
4796
4875
  }
4797
4876
  if (diskNumber == MAX_16_BITS) {
4798
- diskNumber = getUint32(endOfDirectoryView, 20);
4799
- } else if (checkAmbiguity && diskNumber != getUint32(endOfDirectoryView, 20)) {
4877
+ diskNumber = getUint32$1(endOfDirectoryView, 20);
4878
+ } else if (checkAmbiguity && diskNumber != getUint32$1(endOfDirectoryView, 20)) {
4800
4879
  throwAmbiguousArchive("mismatched zip64 end of central directory record");
4801
4880
  }
4802
4881
  if (filesLength == MAX_16_BITS) {
@@ -4834,11 +4913,11 @@ class ZipReader {
4834
4913
  }
4835
4914
  const expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
4836
4915
  if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
4837
- const storedPointsAtDirectory = getUint32(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
4916
+ const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
4838
4917
  let reconcile = !storedPointsAtDirectory;
4839
4918
  if (!reconcile && expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
4840
4919
  const expectedSignatureArray = await readUint8Array(reader, expectedDirectoryDataOffset, 4);
4841
- reconcile = getUint32(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
4920
+ reconcile = getUint32$1(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
4842
4921
  }
4843
4922
  if (reconcile) {
4844
4923
  const originalDirectoryDataOffset = directoryDataOffset;
@@ -4862,10 +4941,10 @@ class ZipReader {
4862
4941
  }
4863
4942
  zipReader.directoryOffset = directoryDataOffset;
4864
4943
  zipReader.directoryLength = declaredDirectoryDataLength;
4865
- const decryptCentralDirectory = getOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
4944
+ const decryptCentralDirectory = getFunctionOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
4866
4945
  let decryptedDirectory;
4867
4946
  if (decryptCentralDirectory && filesLength && directoryArray.length >= 4 &&
4868
- getUint32(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
4947
+ getUint32$1(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
4869
4948
  (zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
4870
4949
  directoryArray = await decryptCentralDirectory(directoryArray, directoryEncryptionInfo);
4871
4950
  directoryView = getDataView(directoryArray);
@@ -4878,8 +4957,8 @@ class ZipReader {
4878
4957
  const filenames = checkAmbiguity ? new Set() : UNDEFINED_VALUE;
4879
4958
  let duplicateFilename;
4880
4959
  for (let indexFile = 0; indexFile < filesLength; indexFile++) {
4881
- const fileEntry = new ZipEntry$1(reader, config, zipReader.options);
4882
- if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
4960
+ const fileEntry = new ZipEntry$1(reader, zipReader.options);
4961
+ if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32$1(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
4883
4962
  if (indexFile == 0 && !decryptedDirectory && (zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
4884
4963
  throw new Error(ERR_ENCRYPTED_CENTRAL_DIRECTORY);
4885
4964
  }
@@ -4890,16 +4969,16 @@ class ZipReader {
4890
4969
  const filenameOffset = offset + CENTRAL_FILE_HEADER_LENGTH;
4891
4970
  const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
4892
4971
  const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
4893
- const versionMadeBy = getUint16(directoryView, offset + 4);
4972
+ const versionMadeBy = getUint16$1(directoryView, offset + 4);
4894
4973
  const msDosCompatible = versionMadeBy >> 8 == 0;
4895
4974
  const unixCompatible = versionMadeBy >> 8 == 3;
4896
4975
  const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
4897
- const commentLength = getUint16(directoryView, offset + 32);
4976
+ const commentLength = getUint16$1(directoryView, offset + 32);
4898
4977
  const endOffset = commentOffset + commentLength;
4899
4978
  const rawComment = directoryArray.subarray(commentOffset, endOffset);
4900
4979
  const filenameUTF8 = languageEncodingFlag;
4901
4980
  const commentUTF8 = languageEncodingFlag;
4902
- const externalFileAttributes = getUint32(directoryView, offset + 38);
4981
+ const externalFileAttributes = getUint32$1(directoryView, offset + 38);
4903
4982
  const msdosAttributesRaw = externalFileAttributes & MAX_8_BITS;
4904
4983
  const msdosAttributes = {
4905
4984
  readOnly: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_READONLY_MASK),
@@ -4908,8 +4987,8 @@ class ZipReader {
4908
4987
  directory: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_DIR_MASK),
4909
4988
  archive: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_ARCHIVE_MASK)
4910
4989
  };
4911
- const offsetFileEntry = getUint32(directoryView, offset + 42);
4912
- const decode = getOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
4990
+ const offsetFileEntry = getUint32$1(directoryView, offset + 42);
4991
+ const decode = getFunctionOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
4913
4992
  const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
4914
4993
  const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
4915
4994
  let filename = decode(rawFilename, rawFilenameEncoding, TEXT_TYPE_FILENAME);
@@ -4940,8 +5019,8 @@ class ZipReader {
4940
5019
  uncompressedSize: 0,
4941
5020
  commentLength,
4942
5021
  offset: offsetFileEntry,
4943
- diskNumberStart: getUint16(directoryView, offset + 34),
4944
- internalFileAttributes: getUint16(directoryView, offset + 36),
5022
+ diskNumberStart: getUint16$1(directoryView, offset + 34),
5023
+ internalFileAttributes: getUint16$1(directoryView, offset + 36),
4945
5024
  externalFileAttributes,
4946
5025
  msdosAttributesRaw,
4947
5026
  msdosAttributes,
@@ -5009,8 +5088,8 @@ class ZipReader {
5009
5088
  yield entry;
5010
5089
  }
5011
5090
  let offsetAfterSignature = offset;
5012
- if (offset + 6 <= directoryArray.length && getUint32(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
5013
- const signatureDataLength = getUint16(directoryView, offset + 4);
5091
+ if (offset + 6 <= directoryArray.length && getUint32$1(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
5092
+ const signatureDataLength = getUint16$1(directoryView, offset + 4);
5014
5093
  if (offset + 6 + signatureDataLength <= directoryArray.length) {
5015
5094
  zipReader.digitalSignature = directoryArray.subarray(offset + 6, offset + 6 + signatureDataLength);
5016
5095
  offsetAfterSignature = offset + 6 + signatureDataLength;
@@ -5022,13 +5101,17 @@ class ZipReader {
5022
5101
  if (duplicateFilename) {
5023
5102
  throwAmbiguousArchive("duplicate filename");
5024
5103
  }
5025
- if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > 0))) {
5026
- throwAmbiguousArchive("prepended data");
5027
- }
5028
5104
  const extractPrependedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_PREPENDED_DATA);
5029
5105
  const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
5106
+ const splitZipSignatureLength = (checkAmbiguity || extractPrependedData) && filesLength &&
5107
+ startOffset == SPLIT_ZIP_FILE_SIGNATURE_LENGTH && await startsWithSplitZipMarker(reader) ? SPLIT_ZIP_FILE_SIGNATURE_LENGTH : 0;
5108
+ if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > splitZipSignatureLength))) {
5109
+ throwAmbiguousArchive("prepended data");
5110
+ }
5030
5111
  if (extractPrependedData) {
5031
- zipReader.prependedData = startOffset > 0 ? await readUint8Array(reader, 0, startOffset) : EMPTY_UINT8_ARRAY;
5112
+ zipReader.prependedData = startOffset > splitZipSignatureLength ?
5113
+ await readUint8Array(reader, splitZipSignatureLength, startOffset - splitZipSignatureLength) :
5114
+ EMPTY_UINT8_ARRAY;
5032
5115
  }
5033
5116
  zipReader.comment = commentLength ? await readUint8Array(reader, commentOffset + END_OF_CENTRAL_DIR_LENGTH, commentLength) : EMPTY_UINT8_ARRAY;
5034
5117
  if (extractAppendedData) {
@@ -5095,16 +5178,16 @@ class ZipReaderStream {
5095
5178
 
5096
5179
  let ZipEntry$1 = class ZipEntry {
5097
5180
 
5098
- constructor(reader, config, options) {
5181
+ constructor(reader, options) {
5099
5182
  Object.assign(this, {
5100
5183
  reader,
5101
- config,
5102
5184
  options
5103
5185
  });
5104
5186
  }
5105
5187
 
5106
5188
  async getData(writer, fileEntry, readRanges, options = {}) {
5107
5189
  const zipEntry = this;
5190
+ const config = getConfiguration();
5108
5191
  const {
5109
5192
  reader,
5110
5193
  index,
@@ -5113,7 +5196,6 @@ let ZipEntry$1 = class ZipEntry {
5113
5196
  extraFieldAES,
5114
5197
  extraFieldZip64,
5115
5198
  compressionMethod,
5116
- config,
5117
5199
  bitFlag,
5118
5200
  rawBitFlag,
5119
5201
  crc32,
@@ -5131,6 +5213,7 @@ let ZipEntry$1 = class ZipEntry {
5131
5213
  let password = getOptionValue$1(zipEntry, options, OPTION_PASSWORD);
5132
5214
  let rawPassword = getOptionValue$1(zipEntry, options, OPTION_RAW_PASSWORD);
5133
5215
  const passThrough = getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH);
5216
+ checkPasswordOption(password, rawPassword);
5134
5217
  password = password && password.length && password;
5135
5218
  rawPassword = rawPassword && rawPassword.length && rawPassword;
5136
5219
  if (extraFieldAES) {
@@ -5138,7 +5221,7 @@ let ZipEntry$1 = class ZipEntry {
5138
5221
  throw new Error(ERR_UNSUPPORTED_COMPRESSION$1);
5139
5222
  }
5140
5223
  }
5141
- if (dataArray.length < HEADER_SIZE || getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
5224
+ if (dataArray.length < HEADER_SIZE || getUint32$1(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
5142
5225
  throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND);
5143
5226
  }
5144
5227
  readCommonHeader(localDirectory, dataView, 4);
@@ -5200,9 +5283,12 @@ let ZipEntry$1 = class ZipEntry {
5200
5283
  }
5201
5284
  }
5202
5285
  const dataOffset = localHeaderOffset + HEADER_SIZE + filenameLength + extraFieldLength;
5286
+ if (dataOffset + compressedSize > reader.size) {
5287
+ throw new Error(ERR_ENTRY_DATA_OUT_OF_BOUNDS);
5288
+ }
5203
5289
  const size = compressedSize;
5204
5290
  const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
5205
- const signal = getOptionValue$1(zipEntry, options, OPTION_SIGNAL);
5291
+ const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
5206
5292
  const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
5207
5293
  let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
5208
5294
  const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
@@ -5210,6 +5296,8 @@ let ZipEntry$1 = class ZipEntry {
5210
5296
  checkOverlappingEntry = true;
5211
5297
  }
5212
5298
  const { onstart, onprogress, onend } = options;
5299
+ const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !passThrough;
5300
+ const outputSize = passThrough ? compressedSize : uncompressedSize;
5213
5301
  const deflate64 = compressionMethod == COMPRESSION_METHOD_DEFLATE_64;
5214
5302
  let useCompressionStream = getOptionValue$1(zipEntry, options, OPTION_USE_COMPRESSION_STREAM);
5215
5303
  if (deflate64) {
@@ -5230,9 +5318,9 @@ let ZipEntry$1 = class ZipEntry {
5230
5318
  checkCrc32,
5231
5319
  checkAuthenticationCode: getOptionValue$1(zipEntry, options, OPTION_CHECK_AUTHENTICATION_CODE),
5232
5320
  passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((crc32 >>> 24) & MAX_8_BITS)),
5233
- outputSize: passThrough ? compressedSize : uncompressedSize,
5321
+ outputSize,
5234
5322
  crc32,
5235
- compressed: compressionMethod != 0 && !passThrough,
5323
+ compressed,
5236
5324
  encrypted,
5237
5325
  useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
5238
5326
  useCompressionStream,
@@ -5269,11 +5357,11 @@ let ZipEntry$1 = class ZipEntry {
5269
5357
  writer = new WritableStream();
5270
5358
  }
5271
5359
  writer = new GenericWriter(writer);
5272
- await initStream(writer, passThrough ? compressedSize : uncompressedSize);
5360
+ await initStream(writer, getDecodableOutputSize(outputSize, compressedSize, compressed));
5273
5361
  ({ writable } = writer);
5274
- const { outputSize } = await runWorker({ readable, writable }, workerOptions);
5275
- writer.size += outputSize;
5276
- if (outputSize != (passThrough ? compressedSize : uncompressedSize)) {
5362
+ const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
5363
+ writer.size += writtenSize;
5364
+ if (writtenSize != outputSize) {
5277
5365
  throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
5278
5366
  }
5279
5367
  }
@@ -5307,7 +5395,7 @@ let ZipEntry$1 = class ZipEntry {
5307
5395
  function detectEncryptedCentralDirectory(directoryView) {
5308
5396
  const maxOffset = Math.min(directoryView.byteLength, 1024) - 3;
5309
5397
  for (let offset = 0; offset < maxOffset; offset++) {
5310
- if (getUint32(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
5398
+ if (getUint32$1(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
5311
5399
  return true;
5312
5400
  }
5313
5401
  }
@@ -5318,15 +5406,15 @@ function getDirectoryEncryptionInfo(rawExtensibleData) {
5318
5406
  const directoryEncryptionInfo = { rawExtensibleData };
5319
5407
  if (rawExtensibleData.length >= 28) {
5320
5408
  const extensibleDataView = getDataView(rawExtensibleData);
5321
- const hashDataLength = getUint16(extensibleDataView, 26);
5409
+ const hashDataLength = getUint16$1(extensibleDataView, 26);
5322
5410
  Object.assign(directoryEncryptionInfo, {
5323
- compressionMethod: getUint16(extensibleDataView, 0),
5411
+ compressionMethod: getUint16$1(extensibleDataView, 0),
5324
5412
  compressedSize: Number(getBigUint64(extensibleDataView, 2)),
5325
5413
  uncompressedSize: Number(getBigUint64(extensibleDataView, 10)),
5326
- encryptionAlgorithm: getUint16(extensibleDataView, 18),
5327
- bitLength: getUint16(extensibleDataView, 20),
5328
- flags: getUint16(extensibleDataView, 22),
5329
- hashAlgorithm: getUint16(extensibleDataView, 24),
5414
+ encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
5415
+ bitLength: getUint16$1(extensibleDataView, 20),
5416
+ flags: getUint16$1(extensibleDataView, 22),
5417
+ hashAlgorithm: getUint16$1(extensibleDataView, 24),
5330
5418
  hashData: rawExtensibleData.subarray(28, 28 + hashDataLength)
5331
5419
  });
5332
5420
  }
@@ -5334,12 +5422,12 @@ function getDirectoryEncryptionInfo(rawExtensibleData) {
5334
5422
  }
5335
5423
 
5336
5424
  function readCommonHeader(directory, dataView, offset) {
5337
- const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2);
5425
+ const rawBitFlag = directory.rawBitFlag = getUint16$1(dataView, offset + 2);
5338
5426
  const encrypted = (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED;
5339
- const rawLastModDate = getUint32(dataView, offset + 6);
5427
+ const rawLastModDate = getUint32$1(dataView, offset + 6);
5340
5428
  Object.assign(directory, {
5341
5429
  encrypted,
5342
- version: getUint16(dataView, offset),
5430
+ version: getUint16$1(dataView, offset),
5343
5431
  bitFlag: {
5344
5432
  level: (rawBitFlag & BITFLAG_LEVEL) >> 1,
5345
5433
  dataDescriptor: (rawBitFlag & BITFLAG_DATA_DESCRIPTOR) == BITFLAG_DATA_DESCRIPTOR,
@@ -5347,8 +5435,8 @@ function readCommonHeader(directory, dataView, offset) {
5347
5435
  },
5348
5436
  rawLastModDate,
5349
5437
  lastModDate: getDate(rawLastModDate),
5350
- filenameLength: getUint16(dataView, offset + 22),
5351
- extraFieldLength: getUint16(dataView, offset + 24)
5438
+ filenameLength: getUint16$1(dataView, offset + 22),
5439
+ extraFieldLength: getUint16$1(dataView, offset + 24)
5352
5440
  });
5353
5441
  }
5354
5442
 
@@ -5359,8 +5447,8 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
5359
5447
  let offsetExtraField = 0;
5360
5448
  try {
5361
5449
  while (offsetExtraField < rawExtraField.length) {
5362
- const type = getUint16(rawExtraFieldView, offsetExtraField);
5363
- const size = getUint16(rawExtraFieldView, offsetExtraField + 2);
5450
+ const type = getUint16$1(rawExtraFieldView, offsetExtraField);
5451
+ const size = getUint16$1(rawExtraFieldView, offsetExtraField + 2);
5364
5452
  extraField.set(type, {
5365
5453
  type,
5366
5454
  data: rawExtraField.slice(offsetExtraField + 4, offsetExtraField + 4 + size)
@@ -5370,12 +5458,12 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
5370
5458
  } catch {
5371
5459
  // ignored
5372
5460
  }
5373
- const compressionMethod = getUint16(dataView, offset + 4);
5461
+ const compressionMethod = getUint16$1(dataView, offset + 4);
5374
5462
  Object.assign(directory, {
5375
- signature: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
5376
- crc32: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
5377
- compressedSize: getUint32(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
5378
- uncompressedSize: getUint32(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
5463
+ signature: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
5464
+ crc32: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
5465
+ compressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
5466
+ uncompressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
5379
5467
  });
5380
5468
  const extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64);
5381
5469
  if (extraFieldZip64) {
@@ -5464,11 +5552,11 @@ function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName,
5464
5552
  computedCrc32.append(fileEntry[rawPropertyName]);
5465
5553
  const computedCrc32View = getDataView(new Uint8Array(4));
5466
5554
  computedCrc32View.setUint32(0, computedCrc32.get(), true);
5467
- const nameCrc32 = getUint32(extraFieldView, 1);
5555
+ const nameCrc32 = getUint32$1(extraFieldView, 1);
5468
5556
  Object.assign(extraFieldUnicode, {
5469
5557
  version: getUint8(extraFieldView, 0),
5470
5558
  [propertyName]: decodeText(extraFieldUnicode.data.subarray(5)),
5471
- valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32(computedCrc32View, 0)
5559
+ valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32$1(computedCrc32View, 0)
5472
5560
  });
5473
5561
  if (extraFieldUnicode.valid) {
5474
5562
  directory[propertyName] = extraFieldUnicode[propertyName];
@@ -5484,7 +5572,7 @@ function readExtraFieldAES(extraFieldAES, directory, compressionMethod) {
5484
5572
  vendorId: getUint8(extraFieldView, 2),
5485
5573
  strength,
5486
5574
  originalCompressionMethod: compressionMethod,
5487
- compressionMethod: getUint16(extraFieldView, 5)
5575
+ compressionMethod: getUint16$1(extraFieldView, 5)
5488
5576
  });
5489
5577
  directory.compressionMethod = extraFieldAES.compressionMethod;
5490
5578
  if (extraFieldAES.vendorVersion != VENDOR_VERSION_AE_1$1) {
@@ -5498,8 +5586,8 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
5498
5586
  let tag1Data;
5499
5587
  try {
5500
5588
  while (offsetExtraField < extraFieldNTFS.data.length && !tag1Data) {
5501
- const tagValue = getUint16(extraFieldView, offsetExtraField);
5502
- const attributeSize = getUint16(extraFieldView, offsetExtraField + 2);
5589
+ const tagValue = getUint16$1(extraFieldView, offsetExtraField);
5590
+ const attributeSize = getUint16$1(extraFieldView, offsetExtraField + 2);
5503
5591
  if (tagValue == EXTRAFIELD_TYPE_NTFS_TAG1) {
5504
5592
  tag1Data = extraFieldNTFS.data.slice(offsetExtraField + 4, offsetExtraField + 4 + attributeSize);
5505
5593
  }
@@ -5532,12 +5620,12 @@ function readExtraFieldUnixDates(extraField, directory) {
5532
5620
  return;
5533
5621
  }
5534
5622
  const extraFieldView = getDataView(extraField.data);
5535
- const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
5536
- const lastModDate = new Date((getUint32(extraFieldView, 4) | 0) * 1000);
5623
+ const lastAccessDate = new Date((getUint32$1(extraFieldView, 0) | 0) * 1000);
5624
+ const lastModDate = new Date((getUint32$1(extraFieldView, 4) | 0) * 1000);
5537
5625
  const extraFieldData = { lastAccessDate, lastModDate };
5538
5626
  if (extraField.data.length >= 12) {
5539
- extraFieldData.uid = getUint16(extraFieldView, 8);
5540
- extraFieldData.gid = getUint16(extraFieldView, 10);
5627
+ extraFieldData.uid = getUint16$1(extraFieldView, 8);
5628
+ extraFieldData.gid = getUint16$1(extraFieldView, 10);
5541
5629
  }
5542
5630
  Object.assign(extraField, extraFieldData);
5543
5631
  Object.assign(directory, extraFieldData);
@@ -5557,8 +5645,8 @@ function readExtraFieldUnix(extraField, directory, isInfoZip) {
5557
5645
  gid = unpackUnixId(extraField.data.subarray(offset, offset + gidSize));
5558
5646
  Object.assign(extraField, { version, uid, gid });
5559
5647
  } else if (extraField.data.length >= 4) {
5560
- uid = getUint16(view, 0);
5561
- gid = getUint16(view, 2);
5648
+ uid = getUint16$1(view, 0);
5649
+ gid = getUint16$1(view, 2);
5562
5650
  Object.assign(extraField, { uid, gid });
5563
5651
  }
5564
5652
  if (uid !== UNDEFINED_VALUE) {
@@ -5608,7 +5696,7 @@ function readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory,
5608
5696
  let offset = 1;
5609
5697
  timeProperties.forEach((propertyName, indexProperty) => {
5610
5698
  if (extraFieldExtendedTimestamp.data.length >= offset + 4) {
5611
- const time = getUint32(extraFieldView, offset);
5699
+ const time = getUint32$1(extraFieldView, offset);
5612
5700
  directory[propertyName] = extraFieldExtendedTimestamp[propertyName] = new Date((time | 0) * 1000);
5613
5701
  const rawPropertyName = timeRawProperties[indexProperty];
5614
5702
  extraFieldExtendedTimestamp[rawPropertyName] = time;
@@ -5642,7 +5730,7 @@ async function detectOverlappingEntry({
5642
5730
  const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
5643
5731
  const dataDescriptorView = getDataView(dataDescriptorArray);
5644
5732
  let signature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
5645
- getUint32(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
5733
+ getUint32$1(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
5646
5734
  if (signature) {
5647
5735
  const signedDataDescriptor = readDataDescriptor(dataDescriptorView, DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, extraFieldZip64);
5648
5736
  const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || signedDataDescriptor.crc32 == crc32;
@@ -5676,15 +5764,15 @@ async function detectOverlappingEntry({
5676
5764
  }
5677
5765
 
5678
5766
  function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
5679
- const crc32 = getUint32(dataDescriptorView, offset);
5767
+ const crc32 = getUint32$1(dataDescriptorView, offset);
5680
5768
  let compressedSize;
5681
5769
  let uncompressedSize;
5682
5770
  if (extraFieldZip64) {
5683
5771
  compressedSize = getBigUint64(dataDescriptorView, offset + 4);
5684
5772
  uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
5685
5773
  } else {
5686
- compressedSize = getUint32(dataDescriptorView, offset + 4);
5687
- uncompressedSize = getUint32(dataDescriptorView, offset + 8);
5774
+ compressedSize = getUint32$1(dataDescriptorView, offset + 4);
5775
+ uncompressedSize = getUint32$1(dataDescriptorView, offset + 8);
5688
5776
  }
5689
5777
  return { crc32, compressedSize, uncompressedSize };
5690
5778
  }
@@ -5693,10 +5781,28 @@ function getDiskOffset$1(reader, diskNumber) {
5693
5781
  return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
5694
5782
  }
5695
5783
 
5784
+ async function startsWithSplitZipSignature$1(reader) {
5785
+ return await getFirstSignature(reader) == SPLIT_ZIP_FILE_SIGNATURE;
5786
+ }
5787
+
5788
+ async function startsWithSplitZipMarker(reader) {
5789
+ const signature = await getFirstSignature(reader);
5790
+ return signature == SPLIT_ZIP_FILE_SIGNATURE || signature == TEMPORARY_SPLIT_ZIP_FILE_SIGNATURE;
5791
+ }
5792
+
5793
+ async function getFirstSignature(reader) {
5794
+ const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
5795
+ return getUint32$1(getDataView(signatureArray));
5796
+ }
5797
+
5696
5798
  function isStrictnessValue(value) {
5697
5799
  return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
5698
5800
  }
5699
5801
 
5802
+ function getDecodableOutputSize(outputSize, compressedSize, compressed) {
5803
+ return Math.min(outputSize, compressed ? compressedSize * MAX_DEFLATE_EXPANSION_RATIO : compressedSize);
5804
+ }
5805
+
5700
5806
  function getStrictness(options, inheritedOptions) {
5701
5807
  return resolveStrictness(options, resolveStrictness(inheritedOptions, STRICTNESS_BALANCED));
5702
5808
  }
@@ -5759,7 +5865,7 @@ function isUnsafeFilename(filename, filenameValidation) {
5759
5865
 
5760
5866
  function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
5761
5867
  if (maxAppendedDataSize !== UNDEFINED_VALUE) {
5762
- const size = toNumber$1(maxAppendedDataSize);
5868
+ const size = toNumber(maxAppendedDataSize);
5763
5869
  if (typeof size != NUMBER_TYPE || Number.isNaN(size) || size < 0) {
5764
5870
  throw new Error(ERR_INVALID_MAX_APPENDED_DATA_SIZE);
5765
5871
  }
@@ -5782,7 +5888,7 @@ async function findEndOfCentralDirectory(reader, rejectAmbiguous, maxAppendedDat
5782
5888
  let plausibleEndOfDirectoryInfo;
5783
5889
  let endOfDirectoryReachingEndCount = 0;
5784
5890
  for await (const [anchoredView, anchoredOffset, anchoredArray, indexByte, offset] of scanEndOfCentralDirectory(reader, anchoredLength)) {
5785
- const commentLength = getUint16(anchoredView, indexByte + 20);
5891
+ const commentLength = getUint16$1(anchoredView, indexByte + 20);
5786
5892
  if (offset + END_OF_CENTRAL_DIR_LENGTH + commentLength == size) {
5787
5893
  const reachability = await getCentralDirectoryReachability(reader, anchoredView, anchoredOffset, indexByte, offset, size, remoteProbeBudget);
5788
5894
  if (reachability == CENTRAL_DIRECTORY_REACHABLE) {
@@ -5833,7 +5939,7 @@ async function* scanEndOfCentralDirectory(reader, scanLength) {
5833
5939
  const scanArray = await readUint8Array(reader, scanOffset, scanLength);
5834
5940
  const scanView = getDataView(scanArray);
5835
5941
  for (let indexByte = scanArray.length - END_OF_CENTRAL_DIR_LENGTH; indexByte >= 0; indexByte--) {
5836
- if (getUint32(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
5942
+ if (getUint32$1(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
5837
5943
  yield [scanView, scanOffset, scanArray, indexByte, scanOffset + indexByte];
5838
5944
  }
5839
5945
  }
@@ -5844,9 +5950,9 @@ function getEndOfCentralDirectoryInfo(scanArray, indexByte, offset) {
5844
5950
  }
5845
5951
 
5846
5952
  async function getCentralDirectoryReachability(reader, view, anchoredOffset, indexByte, offset, size, remoteProbeBudget) {
5847
- const filesLength = getUint16(view, indexByte + 10);
5848
- const directoryDataLength = getUint32(view, indexByte + 12);
5849
- const directoryDataOffset = getUint32(view, indexByte + 16);
5953
+ const filesLength = getUint16$1(view, indexByte + 10);
5954
+ const directoryDataLength = getUint32$1(view, indexByte + 12);
5955
+ const directoryDataOffset = getUint32$1(view, indexByte + 16);
5850
5956
  if (filesLength == MAX_16_BITS || directoryDataLength == MAX_32_BITS || directoryDataOffset == MAX_32_BITS) {
5851
5957
  const locatorSignature = await readSignature(reader, view, anchoredOffset, offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, size, remoteProbeBudget);
5852
5958
  return locatorSignature == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE ? CENTRAL_DIRECTORY_REACHABLE : CENTRAL_DIRECTORY_UNREACHABLE;
@@ -5854,7 +5960,7 @@ async function getCentralDirectoryReachability(reader, view, anchoredOffset, ind
5854
5960
  if (!filesLength && !directoryDataLength) {
5855
5961
  return CENTRAL_DIRECTORY_PLAUSIBLE;
5856
5962
  }
5857
- const directoryDiskNumber = getUint16(view, indexByte + 6);
5963
+ const directoryDiskNumber = getUint16$1(view, indexByte + 6);
5858
5964
  for (const centralDirectoryOffset of [offset - directoryDataLength, getDiskOffset$1(reader, directoryDiskNumber) + directoryDataOffset]) {
5859
5965
  if (await readSignature(reader, view, anchoredOffset, centralDirectoryOffset, size, remoteProbeBudget) == CENTRAL_FILE_HEADER_SIGNATURE) {
5860
5966
  return CENTRAL_DIRECTORY_REACHABLE;
@@ -5868,12 +5974,12 @@ async function readSignature(reader, view, anchoredOffset, signatureOffset, size
5868
5974
  return UNDEFINED_VALUE;
5869
5975
  }
5870
5976
  if (signatureOffset >= anchoredOffset) {
5871
- return getUint32(view, signatureOffset - anchoredOffset);
5977
+ return getUint32$1(view, signatureOffset - anchoredOffset);
5872
5978
  }
5873
5979
  if (remoteProbeBudget.count > 0) {
5874
5980
  remoteProbeBudget.count--;
5875
5981
  const signatureArray = await readUint8Array(reader, signatureOffset, 4);
5876
- return getUint32(getDataView(signatureArray), 0);
5982
+ return getUint32$1(getDataView(signatureArray), 0);
5877
5983
  }
5878
5984
  return UNDEFINED_VALUE;
5879
5985
  }
@@ -5910,10 +6016,11 @@ function getOptionValue$1(zipReader, options, name) {
5910
6016
  return options[name] === UNDEFINED_VALUE ? zipReader.options[name] : options[name];
5911
6017
  }
5912
6018
 
5913
- function toNumber$1(value) {
5914
- return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
6019
+ function getFunctionOptionValue$1(zipReader, options, name) {
6020
+ return checkFunctionOption(getOptionValue$1(zipReader, options, name));
5915
6021
  }
5916
6022
 
6023
+
5917
6024
  function getDate(timeRaw) {
5918
6025
  const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS;
5919
6026
  return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
@@ -5927,11 +6034,11 @@ function getUint8(view, offset) {
5927
6034
  return view.getUint8(offset);
5928
6035
  }
5929
6036
 
5930
- function getUint16(view, offset) {
6037
+ function getUint16$1(view, offset) {
5931
6038
  return view.getUint16(offset, true);
5932
6039
  }
5933
6040
 
5934
- function getUint32(view, offset) {
6041
+ function getUint32$1(view, offset) {
5935
6042
  return view.getUint32(offset, true);
5936
6043
  }
5937
6044
 
@@ -5946,6 +6053,7 @@ var zipReader = /*#__PURE__*/Object.freeze({
5946
6053
  ERR_CENTRAL_DIRECTORY_NOT_FOUND: ERR_CENTRAL_DIRECTORY_NOT_FOUND,
5947
6054
  ERR_ENCRYPTED: ERR_ENCRYPTED,
5948
6055
  ERR_ENCRYPTED_CENTRAL_DIRECTORY: ERR_ENCRYPTED_CENTRAL_DIRECTORY,
6056
+ ERR_ENTRY_DATA_OUT_OF_BOUNDS: ERR_ENTRY_DATA_OUT_OF_BOUNDS,
5949
6057
  ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND,
5950
6058
  ERR_EOCDR_NOT_FOUND: ERR_EOCDR_NOT_FOUND,
5951
6059
  ERR_EXTRAFIELD_ZIP64_NOT_FOUND: ERR_EXTRAFIELD_ZIP64_NOT_FOUND,
@@ -6002,12 +6110,16 @@ const ERR_DUPLICATED_NAME = "File already exists";
6002
6110
  const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
6003
6111
  const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
6004
6112
  const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
6113
+ const ERR_INVALID_ENTRY_COMMENT_TYPE = "Invalid file entry comment (must be a string)";
6114
+ const ERR_INVALID_DATE = "Invalid date (must be a valid Date instance)";
6005
6115
  const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
6006
6116
  const ERR_INVALID_VERSION = "Version exceeds 65535";
6007
6117
  const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
6008
6118
  const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
6009
6119
  const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
6010
- const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
6120
+ const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
6121
+ const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
6122
+ const ERR_INVALID_EXTRAFIELD_DATA_TYPE = "Invalid extra field data (must be a Uint8Array)";
6011
6123
  const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
6012
6124
  const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
6013
6125
  const MIN_UNIX_TIME = -2147483648;
@@ -6027,7 +6139,6 @@ const ERR_INVALID_UNIX_ID_SIZE = "uid/gid must be 0..65535 for unixExtraFieldTyp
6027
6139
  const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be integer 0..255)";
6028
6140
  const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
6029
6141
  const ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
6030
- const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
6031
6142
  const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
6032
6143
 
6033
6144
  const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
@@ -6052,8 +6163,7 @@ class ZipWriter {
6052
6163
  writer,
6053
6164
  addSplitZipSignature,
6054
6165
  options,
6055
- config: getConfiguration(),
6056
- files: new Map(),
6166
+ fileEntries: new Map(),
6057
6167
  filenames: new Set(),
6058
6168
  offset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? writer.size || writer.writable.size || 0 : options[OPTION_OFFSET],
6059
6169
  initialOffset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : options[OPTION_OFFSET] - (writer.size || writer.writable.size || 0),
@@ -6074,14 +6184,23 @@ class ZipWriter {
6074
6184
  await initStream(reader);
6075
6185
  }
6076
6186
  const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
6077
- const zipReader$1 = new ZipReader(reader.readable);
6187
+ const zipReader$1 = new ZipReader(reader);
6078
6188
  const entries = await zipReader$1.getEntries();
6079
6189
  await zipReader$1.close();
6080
6190
  await initStream(this.writer);
6081
- await reader.readable.pipeTo(this.writer.writable, { preventClose: true, preventAbort: true });
6082
- this.writer.size = this.offset = reader.size;
6191
+ const { directoryOffset } = zipReader$1;
6192
+ let splitZipSignatureLength = 0;
6193
+ if (this.addSplitZipSignature) {
6194
+ delete this.addSplitZipSignature;
6195
+ if (!await startsWithSplitZipSignature(reader)) {
6196
+ await writeData(this.writer, getSplitZipSignatureArray());
6197
+ splitZipSignatureLength = SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
6198
+ this.offset += splitZipSignatureLength;
6199
+ }
6200
+ }
6201
+ const entryPositions = await copyZipData(this, reader, entries, directoryOffset, splitZipSignatureLength);
6083
6202
  this.filenames = new Set(entries.map(entry => entry.filename));
6084
- this.files = new Map(entries.map(entry => {
6203
+ this.fileEntries = new Map(entries.map(entry => {
6085
6204
  const {
6086
6205
  version,
6087
6206
  rawLastModDate,
@@ -6136,11 +6255,12 @@ class ZipWriter {
6136
6255
  if (crc32 !== UNDEFINED_VALUE) {
6137
6256
  setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
6138
6257
  }
6258
+ const { offset, diskNumberStart } = entryPositions.get(entry);
6139
6259
  Object.assign(entry, {
6140
6260
  zip64UncompressedSize,
6141
6261
  zip64CompressedSize,
6142
- zip64Offset: zip64 && entry.offset >= MAX_32_BITS,
6143
- diskNumberStart: 0,
6262
+ offset,
6263
+ diskNumberStart,
6144
6264
  zip64DiskNumberStart: false,
6145
6265
  rawExtraFieldZip64,
6146
6266
  rawExtraFieldAES,
@@ -6160,11 +6280,8 @@ class ZipWriter {
6160
6280
  async add(name = "", reader, options = {}) {
6161
6281
  const zipWriter = this;
6162
6282
  options = Object.assign({}, options);
6163
- const {
6164
- pendingAddFileCalls,
6165
- config
6166
- } = zipWriter;
6167
- if (workers < config.maxWorkers) {
6283
+ const { pendingAddFileCalls } = zipWriter;
6284
+ if (workers < getConfiguration().maxWorkers) {
6168
6285
  workers++;
6169
6286
  } else {
6170
6287
  await new Promise(resolve => pendingEntries.push(resolve));
@@ -6201,16 +6318,16 @@ class ZipWriter {
6201
6318
  }
6202
6319
 
6203
6320
  remove(entry) {
6204
- const { filenames, files } = this;
6321
+ const { filenames, fileEntries } = this;
6205
6322
  // deno-lint-ignore valid-typeof
6206
6323
  if (typeof entry == STRING_TYPE) {
6207
- entry = files.get(entry);
6324
+ entry = fileEntries.get(entry);
6208
6325
  }
6209
6326
  if (entry && entry.filename !== UNDEFINED_VALUE) {
6210
6327
  const { filename } = entry;
6211
- if (filenames.has(filename) && files.has(filename)) {
6328
+ if (filenames.has(filename) && fileEntries.has(filename)) {
6212
6329
  filenames.delete(filename);
6213
- files.delete(filename);
6330
+ fileEntries.delete(filename);
6214
6331
  return true;
6215
6332
  }
6216
6333
  }
@@ -6307,12 +6424,12 @@ async function addFile(zipWriter, name, reader, options) {
6307
6424
  const metadataInfo = resolveMetadata(zipWriter, name, options);
6308
6425
  const { comment } = metadataInfo;
6309
6426
  const extraField = options[PROPERTY_NAME_EXTRA_FIELD];
6310
- zipWriter.files.set(name, UNDEFINED_VALUE);
6427
+ zipWriter.fileEntries.set(name, UNDEFINED_VALUE);
6311
6428
  let fileEntry;
6312
6429
  try {
6313
6430
  const { resolvedOptions } = metadataInfo;
6314
6431
  if (resolvedOptions.level != 0 && resolvedOptions.compressionMethod === UNDEFINED_VALUE &&
6315
- !resolvedOptions.passThrough && !(await supportsDeflate(zipWriter.config))) {
6432
+ !resolvedOptions.passThrough && !(await supportsDeflate(getConfiguration()))) {
6316
6433
  resolvedOptions.level = 0;
6317
6434
  }
6318
6435
  const sizesInfo = await resolveSizes(zipWriter, reader, metadataInfo, options);
@@ -6330,7 +6447,7 @@ async function addFile(zipWriter, name, reader, options) {
6330
6447
  const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
6331
6448
  fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo, metadataSize }, options);
6332
6449
  } catch (error) {
6333
- zipWriter.files.delete(name);
6450
+ zipWriter.fileEntries.delete(name);
6334
6451
  throw error;
6335
6452
  }
6336
6453
  Object.assign(fileEntry, {
@@ -6374,9 +6491,9 @@ function resolveAttributes(zipWriter, name, options) {
6374
6491
  if (unixExtraFieldType === UNDEFINED_VALUE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
6375
6492
  unixExtraFieldType = INFOZIP_EXTRA_FIELD_TYPE$1;
6376
6493
  }
6377
- let msdosAttributesRaw = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
6494
+ let msdosAttributesRaw = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
6378
6495
  let msdosAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES);
6379
- const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType;
6496
+ const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType || executable;
6380
6497
  const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
6381
6498
  if (hasUnixMetadata) {
6382
6499
  msDosCompatible = false;
@@ -6385,10 +6502,10 @@ function resolveAttributes(zipWriter, name, options) {
6385
6502
  msDosCompatible = true;
6386
6503
  versionMadeBy = (versionMadeBy & MAX_8_BITS);
6387
6504
  }
6388
- if (msdosAttributesRaw !== UNDEFINED_VALUE && (msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
6505
+ if (msdosAttributesRaw !== UNDEFINED_VALUE && (!Number.isInteger(msdosAttributesRaw) || msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
6389
6506
  throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
6390
6507
  }
6391
- if (msdosAttributes && typeof msdosAttributes !== OBJECT_TYPE) {
6508
+ if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
6392
6509
  throw new Error(ERR_INVALID_MSDOS_DATA);
6393
6510
  }
6394
6511
  if (versionMadeBy > MAX_16_BITS) {
@@ -6476,7 +6593,7 @@ function resolveAttributes(zipWriter, name, options) {
6476
6593
  }
6477
6594
 
6478
6595
  function resolveMetadata(zipWriter, name, options) {
6479
- const encode = getOptionValue(zipWriter, options, OPTION_ENCODE_TEXT, encodeText);
6596
+ const encode = getFunctionOptionValue(zipWriter, options, OPTION_ENCODE_TEXT) || encodeText;
6480
6597
  let rawFilename = encode(name, TEXT_TYPE_FILENAME);
6481
6598
  if (rawFilename === UNDEFINED_VALUE) {
6482
6599
  rawFilename = encodeText(name);
@@ -6485,6 +6602,10 @@ function resolveMetadata(zipWriter, name, options) {
6485
6602
  throw new Error(ERR_INVALID_ENTRY_NAME);
6486
6603
  }
6487
6604
  const comment = options[PROPERTY_NAME_COMMENT] || "";
6605
+ // deno-lint-ignore valid-typeof
6606
+ if (typeof comment != STRING_TYPE) {
6607
+ throw new Error(ERR_INVALID_ENTRY_COMMENT_TYPE);
6608
+ }
6488
6609
  let rawComment = encode(comment, TEXT_TYPE_COMMENT);
6489
6610
  if (rawComment === UNDEFINED_VALUE) {
6490
6611
  rawComment = encodeText(comment);
@@ -6496,16 +6617,14 @@ function resolveMetadata(zipWriter, name, options) {
6496
6617
  if (version > MAX_16_BITS) {
6497
6618
  throw new Error(ERR_INVALID_VERSION);
6498
6619
  }
6499
- const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
6500
- const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
6501
- const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
6620
+ const lastModDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
6621
+ const lastAccessDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
6622
+ const creationDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
6502
6623
  const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
6503
6624
  const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
6504
6625
  const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
6505
6626
  const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
6506
- if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
6507
- throw new Error(ERR_INVALID_PASSWORD_TYPE);
6508
- }
6627
+ checkPasswordOption(password, rawPassword);
6509
6628
  const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
6510
6629
  const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
6511
6630
  const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
@@ -6514,9 +6633,9 @@ function resolveMetadata(zipWriter, name, options) {
6514
6633
  const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
6515
6634
  const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS);
6516
6635
  const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
6517
- const createTempStream = getOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
6636
+ const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
6518
6637
  const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
6519
- const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
6638
+ const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
6520
6639
  const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
6521
6640
  const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
6522
6641
  const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
@@ -6596,18 +6715,26 @@ function serializeExtraField(extraField) {
6596
6715
  if (!extraField) {
6597
6716
  return EMPTY_UINT8_ARRAY;
6598
6717
  }
6718
+ if (!(extraField instanceof Map)) {
6719
+ throw new Error(ERR_INVALID_EXTRAFIELD);
6720
+ }
6599
6721
  let extraFieldSize = 0;
6600
6722
  let offset = 0;
6601
- extraField.forEach(data => extraFieldSize += 4 + getLength(data));
6602
- const rawExtraField = new Uint8Array(extraFieldSize);
6603
- const rawExtraFieldView = getDataView(rawExtraField);
6604
6723
  extraField.forEach((data, type) => {
6605
- if (type > MAX_16_BITS) {
6724
+ if (!Number.isInteger(type) || type < 0 || type > MAX_16_BITS) {
6606
6725
  throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
6607
6726
  }
6727
+ if (!(data instanceof Uint8Array)) {
6728
+ throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
6729
+ }
6608
6730
  if (getLength(data) > MAX_16_BITS) {
6609
6731
  throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
6610
6732
  }
6733
+ extraFieldSize += 4 + getLength(data);
6734
+ });
6735
+ const rawExtraField = new Uint8Array(extraFieldSize);
6736
+ const rawExtraFieldView = getDataView(rawExtraField);
6737
+ extraField.forEach((data, type) => {
6611
6738
  setUint16(rawExtraFieldView, offset, type);
6612
6739
  setUint16(rawExtraFieldView, offset + 2, getLength(data));
6613
6740
  arraySet(rawExtraField, data, offset + 4);
@@ -6694,8 +6821,8 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
6694
6821
  }
6695
6822
 
6696
6823
  async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comment) {
6697
- const zipWriter = { options: writerOptions, config: getConfiguration() };
6698
- if (writerOptions[OPTION_SIGN_CENTRAL_DIRECTORY]) {
6824
+ const zipWriter = { options: writerOptions };
6825
+ if (checkFunctionOption(writerOptions[OPTION_SIGN_CENTRAL_DIRECTORY])) {
6699
6826
  throw new Error(ERR_UNDETERMINED_SIZE);
6700
6827
  }
6701
6828
  if (comment !== UNDEFINED_VALUE && !(comment instanceof Uint8Array)) {
@@ -6721,7 +6848,7 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
6721
6848
  ({ name } = attributesInfo);
6722
6849
  const { resolvedOptions: metadata } = resolveMetadata(zipWriter, name, options);
6723
6850
  if (metadata.level != 0 && metadata.compressionMethod === UNDEFINED_VALUE &&
6724
- !metadata.passThrough && !(await supportsDeflate(zipWriter.config))) {
6851
+ !metadata.passThrough && !(await supportsDeflate(getConfiguration()))) {
6725
6852
  metadata.level = 0;
6726
6853
  }
6727
6854
  const hasContent = !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY);
@@ -6770,7 +6897,7 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
6770
6897
 
6771
6898
  async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6772
6899
  const {
6773
- files,
6900
+ fileEntries,
6774
6901
  writer
6775
6902
  } = zipWriter;
6776
6903
  const {
@@ -6792,12 +6919,12 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6792
6919
  let writerSizeBeforeEntry;
6793
6920
  let flushedBufferedSize = 0;
6794
6921
  let fileWriter;
6795
- files.set(name, fileEntry);
6922
+ fileEntries.set(name, fileEntry);
6796
6923
  zipWriter.lastFileEntry = fileEntry;
6797
6924
  try {
6798
6925
  let lockPreviousFileEntry;
6799
6926
  if (keepOrder) {
6800
- lockPreviousFileEntry = previousFileEntry && previousFileEntry.lock;
6927
+ lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
6801
6928
  requestLockCurrentFileEntry();
6802
6929
  }
6803
6930
  if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
@@ -6818,11 +6945,8 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6818
6945
  const diskOffset = getDiskOffset(writer);
6819
6946
  if (zipWriter.addSplitZipSignature) {
6820
6947
  delete zipWriter.addSplitZipSignature;
6821
- const signatureArray = new Uint8Array(4);
6822
- const signatureArrayView = getDataView(signatureArray);
6823
- setUint32(signatureArrayView, 0, SPLIT_ZIP_FILE_SIGNATURE);
6824
- await writeData(writer, signatureArray);
6825
- zipWriter.offset += 4;
6948
+ await writeData(writer, getSplitZipSignatureArray());
6949
+ zipWriter.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
6826
6950
  }
6827
6951
  if (usdz && !bufferedWrite) {
6828
6952
  appendExtraFieldUSDZ(entryInfo, zipWriter.offset - diskOffset);
@@ -6840,11 +6964,11 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6840
6964
  writerSizeBeforeEntry = writer.size;
6841
6965
  await writeData(fileWriter, localHeaderArray);
6842
6966
  }
6843
- fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, zipWriter.config, options);
6967
+ fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, getConfiguration(), options);
6844
6968
  if (!bufferedWrite) {
6845
6969
  writingEntryData = false;
6846
6970
  }
6847
- files.set(name, fileEntry);
6971
+ fileEntries.set(name, fileEntry);
6848
6972
  fileEntry.filename = name;
6849
6973
  if (bufferedWrite) {
6850
6974
  await Promise.all([fileWriter.writable.getWriter().close(), lockPreviousFileEntry]);
@@ -6885,7 +7009,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6885
7009
  zipWriter.offset += flushedBufferedSize;
6886
7010
  }
6887
7011
  }
6888
- files.delete(name);
7012
+ fileEntries.delete(name);
6889
7013
  throw error;
6890
7014
  } finally {
6891
7015
  if (bufferedWrite) {
@@ -6907,7 +7031,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6907
7031
  }
6908
7032
 
6909
7033
  function requestLockCurrentFileEntry() {
6910
- fileEntry.lock = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
7034
+ fileEntry.lockFileEntry = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
6911
7035
  }
6912
7036
 
6913
7037
  async function requestLockWriter() {
@@ -6927,7 +7051,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6927
7051
  }
6928
7052
  }
6929
7053
 
6930
- async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryInfo, config, options) {
7054
+ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry }, entryInfo, config, options) {
6931
7055
  const {
6932
7056
  headerInfo,
6933
7057
  dataDescriptorInfo,
@@ -6995,7 +7119,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
6995
7119
  codecURI
6996
7120
  } = options;
6997
7121
  const fileEntry = {
6998
- lock,
7122
+ lockFileEntry,
6999
7123
  versionMadeBy,
7000
7124
  zip64,
7001
7125
  directory: Boolean(directory),
@@ -7037,7 +7161,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
7037
7161
  }
7038
7162
  const { writable } = writer;
7039
7163
  if (reader) {
7040
- const readable = toCompatibleReadable(reader.createReadable ? reader.createReadable() : reader.readable);
7164
+ const readable = toCompatibleReadable(createReadable(reader));
7041
7165
  const size = reader.size;
7042
7166
  const workerOptions = {
7043
7167
  options: {
@@ -7149,14 +7273,14 @@ function getHeaderInfo(options) {
7149
7273
  if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
7150
7274
  const length = 4 + 16;
7151
7275
  const extraFieldZip64 = createRecordWriter(length);
7152
- extraFieldZip64.uint16(EXTRAFIELD_TYPE_ZIP64);
7153
- extraFieldZip64.uint16(length - 4);
7276
+ extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
7277
+ extraFieldZip64.writeUint16(length - 4);
7154
7278
  rawLocalExtraFieldZip64 = extraFieldZip64.array;
7155
7279
  if (zip64ExtraFieldComplete) {
7156
- extraFieldZip64.uint64(uncompressedSize);
7280
+ extraFieldZip64.writeUint64(uncompressedSize);
7157
7281
  if (uncompressedFile) {
7158
7282
  const encryptionOverhead = encrypted ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
7159
- extraFieldZip64.uint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
7283
+ extraFieldZip64.writeUint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
7160
7284
  }
7161
7285
  }
7162
7286
  } else {
@@ -7165,8 +7289,8 @@ function getHeaderInfo(options) {
7165
7289
  let rawExtraFieldAES;
7166
7290
  if (encrypted && !zipCrypto) {
7167
7291
  const extraFieldAES = createRecordWriter(getLength(EXTRAFIELD_DATA_AES) + 2);
7168
- extraFieldAES.uint16(EXTRAFIELD_TYPE_AES);
7169
- extraFieldAES.bytes(EXTRAFIELD_DATA_AES);
7292
+ extraFieldAES.writeUint16(EXTRAFIELD_TYPE_AES);
7293
+ extraFieldAES.writeBytes(EXTRAFIELD_DATA_AES);
7170
7294
  rawExtraFieldAES = extraFieldAES.array;
7171
7295
  rawExtraFieldAES[8] = encryptionStrength;
7172
7296
  } else {
@@ -7182,15 +7306,15 @@ function getHeaderInfo(options) {
7182
7306
  const extraFieldTimestampLength = 9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0);
7183
7307
  const extraFieldTimestamp = createRecordWriter(extraFieldTimestampLength);
7184
7308
  extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
7185
- extraFieldTimestamp.uint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7186
- extraFieldTimestamp.uint16(extraFieldTimestampLength - 4);
7187
- extraFieldTimestamp.uint8(extraFieldExtendedTimestampFlag);
7188
- extraFieldTimestamp.uint32(lastModTimeUnix);
7309
+ extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7310
+ extraFieldTimestamp.writeUint16(extraFieldTimestampLength - 4);
7311
+ extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
7312
+ extraFieldTimestamp.writeUint32(lastModTimeUnix);
7189
7313
  if (lastAccessDate) {
7190
- extraFieldTimestamp.uint32(clampUnixTime(getTimeUnix(lastAccessDate)));
7314
+ extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(lastAccessDate)));
7191
7315
  }
7192
7316
  if (creationDate) {
7193
- extraFieldTimestamp.uint32(clampUnixTime(getTimeUnix(creationDate)));
7317
+ extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(creationDate)));
7194
7318
  }
7195
7319
  rawExtraFieldExtendedTimestamp = extraFieldTimestamp.array;
7196
7320
  } else {
@@ -7203,14 +7327,14 @@ function getHeaderInfo(options) {
7203
7327
  try {
7204
7328
  const lastModTimeNTFS = getTimeNTFS(lastModDate);
7205
7329
  const extraFieldNTFS = createRecordWriter(36);
7206
- extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS);
7207
- extraFieldNTFS.uint16(32);
7330
+ extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS);
7331
+ extraFieldNTFS.writeUint16(32);
7208
7332
  extraFieldNTFS.skip(4);
7209
- extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS_TAG1);
7210
- extraFieldNTFS.uint16(24);
7211
- extraFieldNTFS.uint64(lastModTimeNTFS);
7212
- extraFieldNTFS.uint64(lastAccessDate ? getTimeNTFS(lastAccessDate) : lastModTimeNTFS);
7213
- extraFieldNTFS.uint64(creationDate ? getTimeNTFS(creationDate) : lastModTimeNTFS);
7333
+ extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS_TAG1);
7334
+ extraFieldNTFS.writeUint16(24);
7335
+ extraFieldNTFS.writeUint64(lastModTimeNTFS);
7336
+ extraFieldNTFS.writeUint64(lastAccessDate ? getTimeNTFS(lastAccessDate) : lastModTimeNTFS);
7337
+ extraFieldNTFS.writeUint64(creationDate ? getTimeNTFS(creationDate) : lastModTimeNTFS);
7214
7338
  rawExtraFieldNTFS = extraFieldNTFS.array;
7215
7339
  } catch {
7216
7340
  rawExtraFieldNTFS = EMPTY_UINT8_ARRAY;
@@ -7229,20 +7353,20 @@ function getHeaderInfo(options) {
7229
7353
  const gidBytes = packUnixId(gid);
7230
7354
  const payloadLength = 3 + uidBytes.length + gidBytes.length;
7231
7355
  const extraFieldUnix = createRecordWriter(4 + payloadLength);
7232
- extraFieldUnix.uint16(EXTRAFIELD_TYPE_INFOZIP);
7233
- extraFieldUnix.uint16(payloadLength);
7234
- extraFieldUnix.uint8(1);
7235
- extraFieldUnix.uint8(uidBytes.length);
7236
- extraFieldUnix.bytes(uidBytes);
7237
- extraFieldUnix.uint8(gidBytes.length);
7238
- extraFieldUnix.bytes(gidBytes);
7356
+ extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
7357
+ extraFieldUnix.writeUint16(payloadLength);
7358
+ extraFieldUnix.writeUint8(1);
7359
+ extraFieldUnix.writeUint8(uidBytes.length);
7360
+ extraFieldUnix.writeBytes(uidBytes);
7361
+ extraFieldUnix.writeUint8(gidBytes.length);
7362
+ extraFieldUnix.writeBytes(gidBytes);
7239
7363
  rawExtraFieldUnix = extraFieldUnix.array;
7240
7364
  } else if (unixExtraFieldType == UNIX_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
7241
7365
  const extraFieldUnix = createRecordWriter(8);
7242
- extraFieldUnix.uint16(EXTRAFIELD_TYPE_UNIX);
7243
- extraFieldUnix.uint16(4);
7244
- extraFieldUnix.uint16((uid === UNDEFINED_VALUE ? 0 : uid) & MAX_16_BITS);
7245
- extraFieldUnix.uint16((gid === UNDEFINED_VALUE ? 0 : gid) & MAX_16_BITS);
7366
+ extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_UNIX);
7367
+ extraFieldUnix.writeUint16(4);
7368
+ extraFieldUnix.writeUint16((uid === UNDEFINED_VALUE ? 0 : uid) & MAX_16_BITS);
7369
+ extraFieldUnix.writeUint16((gid === UNDEFINED_VALUE ? 0 : gid) & MAX_16_BITS);
7246
7370
  rawExtraFieldUnix = extraFieldUnix.array;
7247
7371
  } else {
7248
7372
  rawExtraFieldUnix = EMPTY_UINT8_ARRAY;
@@ -7292,18 +7416,18 @@ function getHeaderInfo(options) {
7292
7416
  const localHeader = createRecordWriter(HEADER_SIZE + getLength(rawFilename) + extraFieldLength);
7293
7417
  const localHeaderArray = localHeader.array;
7294
7418
  const localHeaderView = getDataView(localHeaderArray);
7295
- localHeader.uint32(LOCAL_FILE_HEADER_SIGNATURE);
7296
- localHeader.bytes(headerArray);
7297
- localHeader.bytes(rawFilename);
7419
+ localHeader.writeUint32(LOCAL_FILE_HEADER_SIGNATURE);
7420
+ localHeader.writeBytes(headerArray);
7421
+ localHeader.writeBytes(rawFilename);
7298
7422
  if (writeLocalExtraFieldZip64) {
7299
- localHeader.bytes(rawLocalExtraFieldZip64);
7300
- }
7301
- localHeader.bytes(rawExtraFieldAES);
7302
- localHeader.bytes(rawExtraFieldExtendedTimestamp);
7303
- localHeader.bytes(rawExtraFieldNTFS);
7304
- localHeader.bytes(rawExtraFieldUnix);
7305
- localHeader.bytes(rawExtraField);
7306
- localHeader.bytes(rawLocalExtraField);
7423
+ localHeader.writeBytes(rawLocalExtraFieldZip64);
7424
+ }
7425
+ localHeader.writeBytes(rawExtraFieldAES);
7426
+ localHeader.writeBytes(rawExtraFieldExtendedTimestamp);
7427
+ localHeader.writeBytes(rawExtraFieldNTFS);
7428
+ localHeader.writeBytes(rawExtraFieldUnix);
7429
+ localHeader.writeBytes(rawExtraField);
7430
+ localHeader.writeBytes(rawLocalExtraField);
7307
7431
  if (dataDescriptor) {
7308
7432
  if (!zip64CompressedSize) {
7309
7433
  setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + LOCAL_HEADER_COMMON_OFFSET, 0);
@@ -7493,7 +7617,7 @@ function updateLocalHeader({
7493
7617
 
7494
7618
 
7495
7619
  async function closeFile(zipWriter, comment, options) {
7496
- const directoryDataLength = createDirectoryRecords(zipWriter.files);
7620
+ const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
7497
7621
  const { directoryStart, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
7498
7622
  const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
7499
7623
  await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryDataLength, signatureLength });
@@ -7523,19 +7647,19 @@ function createDirectoryRecords(files) {
7523
7647
  if (zip64Offset || zip64DiskNumberStart || zip64UncompressedSize || zip64CompressedSize) {
7524
7648
  const length = 4 + (zip64UncompressedSize ? 8 : 0) + (zip64CompressedSize ? 8 : 0) + (zip64Offset ? 8 : 0) + (zip64DiskNumberStart ? 4 : 0);
7525
7649
  const extraFieldZip64 = createRecordWriter(length);
7526
- extraFieldZip64.uint16(EXTRAFIELD_TYPE_ZIP64);
7527
- extraFieldZip64.uint16(length - 4);
7650
+ extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
7651
+ extraFieldZip64.writeUint16(length - 4);
7528
7652
  if (zip64UncompressedSize) {
7529
- extraFieldZip64.uint64(uncompressedSize);
7653
+ extraFieldZip64.writeUint64(uncompressedSize);
7530
7654
  }
7531
7655
  if (zip64CompressedSize) {
7532
- extraFieldZip64.uint64(compressedSize);
7656
+ extraFieldZip64.writeUint64(compressedSize);
7533
7657
  }
7534
7658
  if (zip64Offset) {
7535
- extraFieldZip64.uint64(fileEntry.offset);
7659
+ extraFieldZip64.writeUint64(fileEntry.offset);
7536
7660
  }
7537
7661
  if (zip64DiskNumberStart) {
7538
- extraFieldZip64.uint32(fileEntry.diskNumberStart);
7662
+ extraFieldZip64.writeUint32(fileEntry.diskNumberStart);
7539
7663
  }
7540
7664
  rawExtraFieldZip64 = extraFieldZip64.array;
7541
7665
  } else {
@@ -7548,10 +7672,10 @@ function createDirectoryRecords(files) {
7548
7672
  const lastModTimeUnix = getTimeUnix(lastModDate);
7549
7673
  if (extendedTimestamp && inUnixTimeRange(lastModTimeUnix)) {
7550
7674
  const extraFieldTimestamp = createRecordWriter(9);
7551
- extraFieldTimestamp.uint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7552
- extraFieldTimestamp.uint16(5);
7553
- extraFieldTimestamp.uint8(extraFieldExtendedTimestampFlag);
7554
- extraFieldTimestamp.uint32(lastModTimeUnix);
7675
+ extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7676
+ extraFieldTimestamp.writeUint16(5);
7677
+ extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
7678
+ extraFieldTimestamp.writeUint32(lastModTimeUnix);
7555
7679
  rawExtraFieldTimestamp = extraFieldTimestamp.array;
7556
7680
  } else {
7557
7681
  rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
@@ -7573,14 +7697,14 @@ function createDirectoryRecords(files) {
7573
7697
  }
7574
7698
 
7575
7699
  async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
7576
- const { files, writer } = zipWriter;
7700
+ const { fileEntries, writer } = zipWriter;
7577
7701
  const directoryArray = new Uint8Array(directoryDataLength);
7578
7702
  await initStream(writer);
7579
7703
  let offset = 0;
7580
7704
  let directoryDiskOffset = 0;
7581
7705
  let directoryStartDiskNumber = getDiskNumber(writer);
7582
7706
  let directoryStartDiskOffset = getDiskOffset(writer);
7583
- for (const [indexFileEntry, fileEntry] of Array.from(files.values()).entries()) {
7707
+ for (const [indexFileEntry, fileEntry] of Array.from(fileEntries.values()).entries()) {
7584
7708
  const {
7585
7709
  offset: fileEntryOffset,
7586
7710
  rawFilename,
@@ -7625,28 +7749,28 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
7625
7749
  setUint16(headerView, HEADER_OFFSET_VERSION, VERSION_ZIP64);
7626
7750
  }
7627
7751
  const directoryRecord = createRecordWriter(directoryRecordLength);
7628
- directoryRecord.uint32(CENTRAL_FILE_HEADER_SIGNATURE);
7629
- directoryRecord.uint16(versionMadeBy);
7630
- directoryRecord.bytes(headerArray.subarray(0, HEADER_SIZE - 4 - 2));
7631
- directoryRecord.uint16(extraFieldLength);
7632
- directoryRecord.uint16(getLength(rawComment));
7633
- directoryRecord.uint16(zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
7634
- directoryRecord.uint16(internalFileAttributes);
7635
- directoryRecord.uint32(externalFileAttributes);
7636
- directoryRecord.uint32(zip64Offset ? MAX_32_BITS : fileEntryOffset);
7637
- directoryRecord.bytes(rawFilename);
7638
- directoryRecord.bytes(rawExtraFieldZip64);
7639
- directoryRecord.bytes(rawExtraFieldAES);
7640
- directoryRecord.bytes(rawExtraFieldExtendedTimestamp);
7641
- directoryRecord.bytes(rawExtraFieldNTFS);
7642
- directoryRecord.bytes(rawExtraFieldUnix);
7643
- directoryRecord.bytes(rawExtraField);
7644
- directoryRecord.bytes(rawComment);
7752
+ directoryRecord.writeUint32(CENTRAL_FILE_HEADER_SIGNATURE);
7753
+ directoryRecord.writeUint16(versionMadeBy);
7754
+ directoryRecord.writeBytes(headerArray.subarray(0, HEADER_SIZE - 4 - 2));
7755
+ directoryRecord.writeUint16(extraFieldLength);
7756
+ directoryRecord.writeUint16(getLength(rawComment));
7757
+ directoryRecord.writeUint16(zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
7758
+ directoryRecord.writeUint16(internalFileAttributes);
7759
+ directoryRecord.writeUint32(externalFileAttributes);
7760
+ directoryRecord.writeUint32(zip64Offset ? MAX_32_BITS : fileEntryOffset);
7761
+ directoryRecord.writeBytes(rawFilename);
7762
+ directoryRecord.writeBytes(rawExtraFieldZip64);
7763
+ directoryRecord.writeBytes(rawExtraFieldAES);
7764
+ directoryRecord.writeBytes(rawExtraFieldExtendedTimestamp);
7765
+ directoryRecord.writeBytes(rawExtraFieldNTFS);
7766
+ directoryRecord.writeBytes(rawExtraFieldUnix);
7767
+ directoryRecord.writeBytes(rawExtraField);
7768
+ directoryRecord.writeBytes(rawComment);
7645
7769
  arraySet(directoryArray, directoryRecord.array, offset);
7646
7770
  offset += directoryRecordLength;
7647
7771
  if (options.onprogress) {
7648
7772
  try {
7649
- await options.onprogress(indexFileEntry + 1, files.size, new Entry(fileEntry));
7773
+ await options.onprogress(indexFileEntry + 1, fileEntries.size, new Entry(fileEntry));
7650
7774
  } catch {
7651
7775
  // ignored
7652
7776
  }
@@ -7660,7 +7784,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
7660
7784
  }
7661
7785
 
7662
7786
  async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
7663
- const signCentralDirectory = getOptionValue(zipWriter, options, OPTION_SIGN_CENTRAL_DIRECTORY);
7787
+ const signCentralDirectory = getFunctionOptionValue(zipWriter, options, OPTION_SIGN_CENTRAL_DIRECTORY);
7664
7788
  if (signCentralDirectory) {
7665
7789
  const signatureData = await signCentralDirectory(directoryArray);
7666
7790
  const signatureDataLength = getLength(signatureData);
@@ -7668,9 +7792,9 @@ async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
7668
7792
  throw new Error(ERR_INVALID_SIGNATURE_DATA);
7669
7793
  }
7670
7794
  const signatureRecord = createRecordWriter(6 + signatureDataLength);
7671
- signatureRecord.uint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
7672
- signatureRecord.uint16(signatureDataLength);
7673
- signatureRecord.bytes(signatureData);
7795
+ signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
7796
+ signatureRecord.writeUint16(signatureDataLength);
7797
+ signatureRecord.writeBytes(signatureData);
7674
7798
  await writeData(zipWriter.writer, signatureRecord.array);
7675
7799
  return 6 + signatureDataLength;
7676
7800
  }
@@ -7681,7 +7805,7 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
7681
7805
  const { writer } = zipWriter;
7682
7806
  const { directoryStart, signatureLength } = cdInfo;
7683
7807
  let { directoryDataLength } = cdInfo;
7684
- let filesLength = zipWriter.files.size;
7808
+ let fileEntriesLength = zipWriter.fileEntries.size;
7685
7809
  let diskNumber = directoryStart.diskNumber;
7686
7810
  let directoryOffset = getSegmentOffset(zipWriter, directoryStart);
7687
7811
  let lastDiskNumber = getDiskNumber(writer);
@@ -7689,7 +7813,7 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
7689
7813
  lastDiskNumber++;
7690
7814
  }
7691
7815
  let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
7692
- if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS || lastDiskNumber >= MAX_16_BITS) {
7816
+ if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || fileEntriesLength >= MAX_16_BITS || lastDiskNumber >= MAX_16_BITS) {
7693
7817
  if (zip64 === false) {
7694
7818
  throw new Error(ERR_UNSUPPORTED_FORMAT);
7695
7819
  } else {
@@ -7706,37 +7830,37 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
7706
7830
  }
7707
7831
  lastDiskNumber = getDiskNumber(writer);
7708
7832
  if (zip64) {
7709
- endOfdirectoryRecord.uint32(ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
7710
- endOfdirectoryRecord.uint64(44);
7711
- endOfdirectoryRecord.uint16(45);
7712
- endOfdirectoryRecord.uint16(45);
7713
- endOfdirectoryRecord.uint32(lastDiskNumber);
7714
- endOfdirectoryRecord.uint32(diskNumber);
7715
- endOfdirectoryRecord.uint64(filesLength);
7716
- endOfdirectoryRecord.uint64(filesLength);
7717
- endOfdirectoryRecord.uint64(directoryDataLength);
7718
- endOfdirectoryRecord.uint64(directoryOffset);
7719
- endOfdirectoryRecord.uint32(ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
7720
- endOfdirectoryRecord.uint32(lastDiskNumber);
7721
- endOfdirectoryRecord.uint64(BigInt(getSegmentOffset(zipWriter, writer)) + BigInt(directoryDataLength) + BigInt(signatureLength));
7722
- endOfdirectoryRecord.uint32(lastDiskNumber + 1);
7833
+ endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
7834
+ endOfdirectoryRecord.writeUint64(44);
7835
+ endOfdirectoryRecord.writeUint16(45);
7836
+ endOfdirectoryRecord.writeUint16(45);
7837
+ endOfdirectoryRecord.writeUint32(lastDiskNumber);
7838
+ endOfdirectoryRecord.writeUint32(diskNumber);
7839
+ endOfdirectoryRecord.writeUint64(fileEntriesLength);
7840
+ endOfdirectoryRecord.writeUint64(fileEntriesLength);
7841
+ endOfdirectoryRecord.writeUint64(directoryDataLength);
7842
+ endOfdirectoryRecord.writeUint64(directoryOffset);
7843
+ endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
7844
+ endOfdirectoryRecord.writeUint32(lastDiskNumber);
7845
+ endOfdirectoryRecord.writeUint64(BigInt(getSegmentOffset(zipWriter, writer)) + BigInt(directoryDataLength) + BigInt(signatureLength));
7846
+ endOfdirectoryRecord.writeUint32(lastDiskNumber + 1);
7723
7847
  const supportZip64SplitFile = getOptionValue(zipWriter, options, OPTION_SUPPORT_ZIP64_SPLIT_FILE, true);
7724
7848
  if (supportZip64SplitFile) {
7725
7849
  lastDiskNumber = MAX_16_BITS;
7726
7850
  diskNumber = MAX_16_BITS;
7727
7851
  }
7728
- filesLength = MAX_16_BITS;
7852
+ fileEntriesLength = MAX_16_BITS;
7729
7853
  directoryOffset = MAX_32_BITS;
7730
7854
  directoryDataLength = MAX_32_BITS;
7731
7855
  }
7732
- endOfdirectoryRecord.uint32(END_OF_CENTRAL_DIR_SIGNATURE);
7733
- endOfdirectoryRecord.uint16(lastDiskNumber);
7734
- endOfdirectoryRecord.uint16(diskNumber);
7735
- endOfdirectoryRecord.uint16(filesLength);
7736
- endOfdirectoryRecord.uint16(filesLength);
7737
- endOfdirectoryRecord.uint32(directoryDataLength);
7738
- endOfdirectoryRecord.uint32(directoryOffset);
7739
- endOfdirectoryRecord.uint16(commentLength);
7856
+ endOfdirectoryRecord.writeUint32(END_OF_CENTRAL_DIR_SIGNATURE);
7857
+ endOfdirectoryRecord.writeUint16(lastDiskNumber);
7858
+ endOfdirectoryRecord.writeUint16(diskNumber);
7859
+ endOfdirectoryRecord.writeUint16(fileEntriesLength);
7860
+ endOfdirectoryRecord.writeUint16(fileEntriesLength);
7861
+ endOfdirectoryRecord.writeUint32(directoryDataLength);
7862
+ endOfdirectoryRecord.writeUint32(directoryOffset);
7863
+ endOfdirectoryRecord.writeUint16(commentLength);
7740
7864
  await writeData(writer, endOfdirectoryRecord.array);
7741
7865
  if (commentLength) {
7742
7866
  await writeData(writer, comment);
@@ -7749,11 +7873,11 @@ function createRecordWriter(length) {
7749
7873
  let offset = 0;
7750
7874
  return {
7751
7875
  array,
7752
- uint8: value => { setUint8(view, offset, value); offset += 1; },
7753
- uint16: value => { setUint16(view, offset, value); offset += 2; },
7754
- uint32: value => { setUint32(view, offset, value); offset += 4; },
7755
- uint64: value => { setBigUint64(view, offset, BigInt(value)); offset += 8; },
7756
- bytes: value => { arraySet(array, value, offset); offset += getLength(value); },
7876
+ writeUint8: value => { setUint8(view, offset, value); offset += 1; },
7877
+ writeUint16: value => { setUint16(view, offset, value); offset += 2; },
7878
+ writeUint32: value => { setUint32(view, offset, value); offset += 4; },
7879
+ writeUint64: value => { setBigUint64(view, offset, BigInt(value)); offset += 8; },
7880
+ writeBytes: value => { arraySet(array, value, offset); offset += getLength(value); },
7757
7881
  skip: count => offset += count
7758
7882
  };
7759
7883
  }
@@ -7777,6 +7901,71 @@ function getSegmentOffset(zipWriter, { diskNumber = 0, diskOffset = 0 }) {
7777
7901
  return zipWriter.offset - diskOffset - (diskNumber ? zipWriter.initialOffset : 0);
7778
7902
  }
7779
7903
 
7904
+ async function startsWithSplitZipSignature(reader) {
7905
+ const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
7906
+ return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
7907
+ }
7908
+
7909
+ async function copyZipData(zipWriter, reader, entries, directoryOffset, splitZipSignatureLength) {
7910
+ const { writer } = zipWriter;
7911
+ const entryPositions = new Map();
7912
+ if (writer.closeDisk) {
7913
+ const sortedEntries = Array.from(entries).sort((firstEntry, secondEntry) =>
7914
+ getSourceOffset(reader, firstEntry) - getSourceOffset(reader, secondEntry));
7915
+ let copiedLength = 0;
7916
+ for (const entry of sortedEntries) {
7917
+ const sourceOffset = getSourceOffset(reader, entry);
7918
+ await copyData(zipWriter, reader, copiedLength, sourceOffset - copiedLength);
7919
+ if (exceedsAvailableSize(writer, await getLocalHeaderLength(reader, sourceOffset))) {
7920
+ await writer.closeDisk();
7921
+ }
7922
+ entryPositions.set(entry, {
7923
+ offset: getSegmentOffset(zipWriter, writer),
7924
+ diskNumberStart: getDiskNumber(writer)
7925
+ });
7926
+ copiedLength = sourceOffset;
7927
+ }
7928
+ await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
7929
+ } else {
7930
+ await copyData(zipWriter, reader, 0, directoryOffset);
7931
+ entries.forEach(entry => entryPositions.set(entry, {
7932
+ offset: splitZipSignatureLength + getSourceOffset(reader, entry),
7933
+ diskNumberStart: 0
7934
+ }));
7935
+ }
7936
+ return entryPositions;
7937
+ }
7938
+
7939
+ async function copyData(zipWriter, reader, offset, size) {
7940
+ if (size > 0) {
7941
+ const { writer } = zipWriter;
7942
+ await createReadable(reader, { offset, size }).pipeTo(writer.writable, { preventClose: true, preventAbort: true });
7943
+ writer.size += size;
7944
+ zipWriter.offset += size;
7945
+ }
7946
+ }
7947
+
7948
+ async function getLocalHeaderLength(reader, offset) {
7949
+ const headerArray = await readUint8Array(reader, offset, HEADER_SIZE);
7950
+ if (getLength(headerArray) < HEADER_SIZE) {
7951
+ return HEADER_SIZE;
7952
+ }
7953
+ const headerView = getDataView(headerArray);
7954
+ return HEADER_SIZE +
7955
+ getUint16(headerView, HEADER_OFFSET_FILENAME_LENGTH + LOCAL_HEADER_COMMON_OFFSET) +
7956
+ getUint16(headerView, HEADER_OFFSET_EXTRAFIELD_LENGTH + LOCAL_HEADER_COMMON_OFFSET);
7957
+ }
7958
+
7959
+ function getSourceOffset(reader, { offset, diskNumberStart }) {
7960
+ return offset + (reader.getDiskOffset ? reader.getDiskOffset(diskNumberStart) : 0);
7961
+ }
7962
+
7963
+ function getSplitZipSignatureArray() {
7964
+ const signatureArray = new Uint8Array(SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
7965
+ setUint32(getDataView(signatureArray), 0, SPLIT_ZIP_FILE_SIGNATURE);
7966
+ return signatureArray;
7967
+ }
7968
+
7780
7969
  async function writeData(writer, array) {
7781
7970
  const { writable } = writer;
7782
7971
  const streamWriter = writable.getWriter();
@@ -7828,6 +8017,21 @@ function getOptionValue(zipWriter, options, name, defaultValue) {
7828
8017
  return result === UNDEFINED_VALUE ? defaultValue : result;
7829
8018
  }
7830
8019
 
8020
+ function getDateOptionValue(zipWriter, options, name, defaultValue) {
8021
+ const date = getOptionValue(zipWriter, options, name, defaultValue);
8022
+ if (date === null) {
8023
+ return defaultValue;
8024
+ }
8025
+ if (date !== UNDEFINED_VALUE && (typeof date.getTime != FUNCTION_TYPE || Number.isNaN(date.getTime()))) {
8026
+ throw new Error(ERR_INVALID_DATE);
8027
+ }
8028
+ return date;
8029
+ }
8030
+
8031
+ function getFunctionOptionValue(zipWriter, options, name) {
8032
+ return checkFunctionOption(getOptionValue(zipWriter, options, name));
8033
+ }
8034
+
7831
8035
  function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
7832
8036
  const value = getAliasedValue(options, name, deprecatedName);
7833
8037
  const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
@@ -7842,9 +8046,6 @@ function getNumberOptionValue(zipWriter, options, name, defaultValue) {
7842
8046
  return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
7843
8047
  }
7844
8048
 
7845
- function toNumber(value) {
7846
- return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
7847
- }
7848
8049
 
7849
8050
  function getMaximumCompressedSize(uncompressedSize) {
7850
8051
  return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
@@ -7856,6 +8057,14 @@ function isCompressed(compressionMethod, level) {
7856
8057
  : compressionMethod !== COMPRESSION_METHOD_STORE;
7857
8058
  }
7858
8059
 
8060
+ function getUint16(view, offset) {
8061
+ return view.getUint16(offset, true);
8062
+ }
8063
+
8064
+ function getUint32(view, offset) {
8065
+ return view.getUint32(offset, true);
8066
+ }
8067
+
7859
8068
  function setUint8(view, offset, value) {
7860
8069
  view.setUint8(offset, value);
7861
8070
  }
@@ -7899,9 +8108,9 @@ function getHeaderArrayData({
7899
8108
  const headerRecord = createRecordWriter(HEADER_SIZE - 4);
7900
8109
  const headerArray = headerRecord.array;
7901
8110
  const headerView = getDataView(headerArray);
7902
- headerRecord.uint16(version);
7903
- headerRecord.uint16(bitFlag);
7904
- headerRecord.uint16(compressionMethod);
8111
+ headerRecord.writeUint16(version);
8112
+ headerRecord.writeUint16(bitFlag);
8113
+ headerRecord.writeUint16(compressionMethod);
7905
8114
  if (rawLastModDate === UNDEFINED_VALUE) {
7906
8115
  const dateArray = new Uint32Array(1);
7907
8116
  const dateView = getDataView(dateArray);
@@ -7909,20 +8118,20 @@ function getHeaderArrayData({
7909
8118
  setUint16(dateView, 2, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate());
7910
8119
  rawLastModDate = dateArray[0];
7911
8120
  }
7912
- headerRecord.uint32(rawLastModDate);
8121
+ headerRecord.writeUint32(rawLastModDate);
7913
8122
  headerRecord.skip(4);
7914
8123
  if (zip64CompressedSize || compressedSize !== UNDEFINED_VALUE) {
7915
- headerRecord.uint32(zip64CompressedSize ? MAX_32_BITS : compressedSize);
8124
+ headerRecord.writeUint32(zip64CompressedSize ? MAX_32_BITS : compressedSize);
7916
8125
  } else {
7917
8126
  headerRecord.skip(4);
7918
8127
  }
7919
8128
  if (zip64UncompressedSize || uncompressedSize !== UNDEFINED_VALUE) {
7920
- headerRecord.uint32(zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
8129
+ headerRecord.writeUint32(zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
7921
8130
  } else {
7922
8131
  headerRecord.skip(4);
7923
8132
  }
7924
- headerRecord.uint16(getLength(rawFilename));
7925
- headerRecord.uint16(extraFieldLength);
8133
+ headerRecord.writeUint16(getLength(rawFilename));
8134
+ headerRecord.writeUint16(extraFieldLength);
7926
8135
  return {
7927
8136
  headerArray,
7928
8137
  headerView,
@@ -8842,6 +9051,7 @@ configureExternalAssets();
8842
9051
  const ERR_ENTRY_EXISTS = "Entry filename already exists";
8843
9052
  const ERR_READABLE_CONSUMED = "Readable stream already consumed";
8844
9053
  const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.passThrough or set uncompressedSize for each entry)";
9054
+ const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
8845
9055
  const ERR_ABORT_EXPORT = "zipjs-abort-export";
8846
9056
  const ERR_ABORTED = "The operation was aborted";
8847
9057
  const ABORT_ERROR_NAME = "AbortError";
@@ -8874,13 +9084,14 @@ class ZipEntry {
8874
9084
  fs,
8875
9085
  name,
8876
9086
  data: params.data,
8877
- options: params.options,
9087
+ options: params.options && Object.assign({}, params.options),
8878
9088
  id: fs.entryIdCounter++,
8879
9089
  parent,
8880
9090
  children: [],
8881
9091
  uncompressedSize: params.uncompressedSize || 0,
8882
9092
  undeterminedSize: params.undeterminedSize || params.uncompressedSize === UNDEFINED_VALUE,
8883
- passThrough: params.passThrough
9093
+ passThrough: params.passThrough,
9094
+ defaultLastModDate: params.defaultLastModDate || new Date()
8884
9095
  });
8885
9096
  if (parent || !fs.root) {
8886
9097
  fs.entries[zipEntry.id] = zipEntry;
@@ -8890,12 +9101,6 @@ class ZipEntry {
8890
9101
  }
8891
9102
  }
8892
9103
 
8893
- moveTo(target) {
8894
- // deprecated
8895
- const zipEntry = this;
8896
- zipEntry.fs.move(zipEntry, target);
8897
- }
8898
-
8899
9104
  getFullname() {
8900
9105
  return this.getRelativeName();
8901
9106
  }
@@ -8927,6 +9132,11 @@ class ZipEntry {
8927
9132
  this.name = name;
8928
9133
  }
8929
9134
  }
9135
+
9136
+ setOptions(options) {
9137
+ const entryOptions = Object.assign({}, this.options, options);
9138
+ this.options = Object.fromEntries(Object.entries(entryOptions).filter(([, value]) => value !== UNDEFINED_VALUE));
9139
+ }
8930
9140
  }
8931
9141
 
8932
9142
  class ZipFileEntry extends ZipEntry {
@@ -8953,7 +9163,7 @@ class ZipFileEntry extends ZipEntry {
8953
9163
  const reader = zipEntry.reader = createReader(zipEntry.Reader, zipEntry.data, options);
8954
9164
  const dataSize = zipEntry.uncompressedSize || reader.size;
8955
9165
  await Promise.all([initStream(reader), initStream(writer, dataSize)]);
8956
- const { signal } = options;
9166
+ const signal = checkSignalOption(options.signal);
8957
9167
  const readable = createProgressReadable(zipEntry, reader, options, signal);
8958
9168
  const preventClose = !ownsWritable(writer) && Boolean(options.preventClose);
8959
9169
  zipEntry.uncompressedSize = reader.size;
@@ -9171,10 +9381,6 @@ class ZipDirectoryEntry extends ZipEntry {
9171
9381
  });
9172
9382
  }
9173
9383
 
9174
- addData(name, params) {
9175
- return addChild(this, name, params);
9176
- }
9177
-
9178
9384
  importBlob(blob, options) {
9179
9385
  return this.importZip(new BlobReader(blob), options);
9180
9386
  }
@@ -9288,7 +9494,7 @@ class ZipDirectoryEntry extends ZipEntry {
9288
9494
  if (options.bufferedWrite === UNDEFINED_VALUE) {
9289
9495
  options.bufferedWrite = true;
9290
9496
  }
9291
- const [readers] = await Promise.all([initReaders(zipEntry, options.readerOptions), initStream(writer)]);
9497
+ const [readers] = await Promise.all([initReaders(zipEntry, checkReaderOptions(options.readerOptions)), initStream(writer)]);
9292
9498
  const zipWriter = new ZipWriter(writer, options);
9293
9499
  await exportZip(zipWriter, zipEntry, getTotalSize([zipEntry], getUncompressedSize), options, readers);
9294
9500
  await zipWriter.close(options.globalComment);
@@ -9298,12 +9504,13 @@ class ZipDirectoryEntry extends ZipEntry {
9298
9504
  getExportedSize(options = {}) {
9299
9505
  const zipEntry = this;
9300
9506
  options = Object.assign({}, options);
9507
+ checkReaderOptions(options.readerOptions);
9301
9508
  if (options.bufferedWrite === UNDEFINED_VALUE) {
9302
9509
  options.bufferedWrite = true;
9303
9510
  }
9304
9511
  const writeOrderGuaranteed = !options.bufferedWrite ||
9305
9512
  (options.keepOrder !== false && zipEntry.children.every(child => !child.children.length));
9306
- return getEntriesSize(options, Array.from(zipEntry.getChildren({ recursive: true }), child => {
9513
+ return getEntriesSize(options, zipEntry.getChildren({ recursive: true }).filter(child => !isImplicitDirectory(child)).map(child => {
9307
9514
  const { name, entryOptions } = getChildEntryOptions(child, zipEntry, options);
9308
9515
  return { name, size: child.directory ? 0 : getDeterminedSize(child, isPassThrough(child, options)), options: entryOptions };
9309
9516
  }), writeOrderGuaranteed, options.globalComment);
@@ -9342,7 +9549,7 @@ class ZipDirectoryEntry extends ZipEntry {
9342
9549
  }
9343
9550
 
9344
9551
 
9345
- class FS {
9552
+ class ZipFS {
9346
9553
 
9347
9554
  constructor() {
9348
9555
  resetFS(this);
@@ -9458,10 +9665,6 @@ class FS {
9458
9665
  return this.root.addFile(file, options);
9459
9666
  }
9460
9667
 
9461
- addData(name, params) {
9462
- return this.root.addData(name, params);
9463
- }
9464
-
9465
9668
  importBlob(blob, options) {
9466
9669
  resetFS(this);
9467
9670
  return this.root.importBlob(blob, options);
@@ -9529,7 +9732,7 @@ class FS {
9529
9732
  }
9530
9733
  }
9531
9734
 
9532
- const fs = { FS, ZipDirectoryEntry, ZipFileEntry };
9735
+ const fs = { FS: ZipFS, ZipDirectoryEntry, ZipFileEntry };
9533
9736
 
9534
9737
  function getTotalSize(entries, getEntrySize) {
9535
9738
  let size = 0;
@@ -9673,7 +9876,7 @@ function detach(entry) {
9673
9876
  }
9674
9877
 
9675
9878
  function forwardAbort(signal, abortController) {
9676
- if (!signal) {
9879
+ if (!checkSignalOption(signal)) {
9677
9880
  return () => { };
9678
9881
  }
9679
9882
  if (signal.aborted) {
@@ -9769,7 +9972,7 @@ function getChildEntryOptions(child, selectedEntry, options) {
9769
9972
  };
9770
9973
  }
9771
9974
  }
9772
- const entryOptions = Object.assign({}, zipEntryMetadata, options, passThroughOptions, childOptions, { directory: child.directory });
9975
+ const entryOptions = Object.assign({ lastModDate: child.defaultLastModDate }, zipEntryMetadata, options, childOptions, passThroughOptions, { directory: child.directory });
9773
9976
  if (!child.directory && entryOptions.passThrough && entryOptions.uncompressedSize === UNDEFINED_VALUE) {
9774
9977
  throw new Error(ERR_INVALID_PASS_THROUGH);
9775
9978
  }
@@ -9784,11 +9987,22 @@ function getDeterminedSize(child, passThrough) {
9784
9987
  return child.undeterminedSize ? UNDEFINED_VALUE : getExtractedSize(child, passThrough);
9785
9988
  }
9786
9989
 
9990
+ function checkReaderOptions(readerOptions) {
9991
+ if (readerOptions && (typeof readerOptions != OBJECT_TYPE || Array.isArray(readerOptions))) {
9992
+ throw new Error(ERR_INVALID_READER_OPTIONS);
9993
+ }
9994
+ return readerOptions;
9995
+ }
9996
+
9787
9997
  function isPassThrough(child, options) {
9788
9998
  const { readerOptions } = options;
9789
9999
  return Boolean(!child.directory && (child.passThrough || (readerOptions && readerOptions.passThrough)));
9790
10000
  }
9791
10001
 
10002
+ function isImplicitDirectory(child) {
10003
+ return child.directory && child.data === null;
10004
+ }
10005
+
9792
10006
  function getUserExtraField(extraField) {
9793
10007
  if (extraField) {
9794
10008
  const userExtraField = new Map();
@@ -9806,7 +10020,7 @@ function getUserExtraField(extraField) {
9806
10020
  async function exportZip(zipWriter, entry, totalSize, options, readers) {
9807
10021
  const { onstart, onprogress, onend, onentryprogress } = options;
9808
10022
  const selectedEntry = entry;
9809
- const totalEntries = getTotalSize(entry.children, () => 1);
10023
+ const totalEntries = getTotalSize(entry.children, child => isImplicitDirectory(child) ? 0 : 1);
9810
10024
  let writtenSize = 0;
9811
10025
  let writtenEntries = 0;
9812
10026
  if (onstart) {
@@ -9835,6 +10049,9 @@ async function exportZip(zipWriter, entry, totalSize, options, readers) {
9835
10049
  }
9836
10050
 
9837
10051
  async function addChild(child) {
10052
+ if (isImplicitDirectory(child)) {
10053
+ return;
10054
+ }
9838
10055
  const { name, entryOptions } = getChildEntryOptions(child, selectedEntry, options);
9839
10056
  let entryWrittenSize = 0;
9840
10057
  const entryMetadata = await zipWriter.add(name, readers.get(child), Object.assign(entryOptions, {
@@ -9868,7 +10085,7 @@ function addFileSystemHandle(zipEntry, handle, options) {
9868
10085
  if (handle.kind == "file") {
9869
10086
  const file = await handle.getFile();
9870
10087
  addedEntries.push(
9871
- parentEntry.addData(file.name, {
10088
+ addChild(parentEntry, file.name, {
9872
10089
  Reader: function () {
9873
10090
  const readable = file.stream();
9874
10091
  const size = file.size;
@@ -9902,10 +10119,11 @@ function addFileSystemHandle(zipEntry, handle, options) {
9902
10119
 
9903
10120
  async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
9904
10121
  const { onstart, onprogress, onend } = options;
10122
+ const readerOptions = checkReaderOptions(options.readerOptions);
9905
10123
  const abortController = new AbortController();
9906
10124
  const { signal } = abortController;
9907
10125
  const releaseSignal = forwardAbort(options.signal, abortController);
9908
- const getDataOptions = Object.assign({}, options, options.readerOptions, {
10126
+ const getDataOptions = Object.assign({}, options, readerOptions, {
9909
10127
  signal,
9910
10128
  onstart: UNDEFINED_VALUE,
9911
10129
  onprogress: UNDEFINED_VALUE,
@@ -10099,4 +10317,4 @@ function addChild(parent, name, params, directory) {
10099
10317
  }
10100
10318
  }
10101
10319
 
10102
- export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_EXISTS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMMENT_TYPE, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_PASS_THROUGH, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_READABLE_CONSUMED, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
10320
+ 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_ENTRY_EXISTS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_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_PASS_THROUGH, ERR_INVALID_READER_OPTIONS, ERR_INVALID_SIGNAL, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_READABLE_CONSUMED, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipDirectoryEntry, ZipEntry, ZipFS, ZipFileEntry, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };