@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
package/dist/zip-core.js CHANGED
@@ -45,6 +45,7 @@
45
45
 
46
46
  const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50;
47
47
  const SPLIT_ZIP_FILE_SIGNATURE = 0x08074b50;
48
+ const TEMPORARY_SPLIT_ZIP_FILE_SIGNATURE = 0x30304b50;
48
49
  const DATA_DESCRIPTOR_RECORD_SIGNATURE = SPLIT_ZIP_FILE_SIGNATURE;
49
50
  const ARCHIVE_EXTRA_DATA_SIGNATURE = 0x08064b50;
50
51
  const DIGITAL_SIGNATURE_RECORD_SIGNATURE = 0x05054b50;
@@ -61,6 +62,7 @@
61
62
  const DATA_DESCRIPTOR_RECORD_LENGTH = 12;
62
63
  const DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH = 20;
63
64
  const DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH = 4;
65
+ const SPLIT_ZIP_FILE_SIGNATURE_LENGTH = 4;
64
66
 
65
67
  const EXTRAFIELD_TYPE_ZIP64 = 0x0001;
66
68
  const EXTRAFIELD_TYPE_AES = 0x9901;
@@ -112,6 +114,8 @@
112
114
  const HEADER_OFFSET_SIGNATURE = 10;
113
115
  const HEADER_OFFSET_COMPRESSED_SIZE = 14;
114
116
  const HEADER_OFFSET_UNCOMPRESSED_SIZE = 18;
117
+ const HEADER_OFFSET_FILENAME_LENGTH = 22;
118
+ const HEADER_OFFSET_EXTRAFIELD_LENGTH = 24;
115
119
  const LOCAL_HEADER_COMMON_OFFSET = 4;
116
120
 
117
121
  const MAX_DATE = new Date(2107, 11, 31, 23, 59, 58);
@@ -124,9 +128,116 @@
124
128
  const OBJECT_TYPE = "object";
125
129
  const STRING_TYPE = "string";
126
130
  const NUMBER_TYPE = "number";
131
+ const BOOLEAN_TYPE = "boolean";
127
132
 
128
133
  const EMPTY_UINT8_ARRAY = new Uint8Array();
129
134
 
135
+ /*
136
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
137
+
138
+ Redistribution and use in source and binary forms, with or without
139
+ modification, are permitted provided that the following conditions are met:
140
+
141
+ 1. Redistributions of source code must retain the above copyright notice,
142
+ this list of conditions and the following disclaimer.
143
+
144
+ 2. Redistributions in binary form must reproduce the above copyright
145
+ notice, this list of conditions and the following disclaimer in
146
+ the documentation and/or other materials provided with the distribution.
147
+
148
+ 3. The names of the authors may not be used to endorse or promote products
149
+ derived from this software without specific prior written permission.
150
+
151
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
152
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
153
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
154
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
155
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
156
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
157
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
158
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
159
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
160
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
161
+ */
162
+
163
+
164
+ const OPTION_FILENAME_ENCODING = "filenameEncoding";
165
+ const OPTION_COMMENT_ENCODING = "commentEncoding";
166
+ const OPTION_DECODE_TEXT = "decodeText";
167
+ const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
168
+ const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
169
+ const OPTION_PASSWORD = "password";
170
+ const OPTION_RAW_PASSWORD = "rawPassword";
171
+ const OPTION_PASS_THROUGH = "passThrough";
172
+ const OPTION_SIGNAL = "signal";
173
+ const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
174
+ const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
175
+ const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
176
+ const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
177
+ const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
178
+ const OPTION_CHECK_SIGNATURE = "checkSignature";
179
+ const OPTION_CHECK_CRC32 = "checkCrc32";
180
+ const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
181
+ const OPTION_USE_WEB_WORKERS = "useWebWorkers";
182
+ const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
183
+ const OPTION_TRANSFER_STREAMS = "transferStreams";
184
+ const OPTION_PREVENT_CLOSE = "preventClose";
185
+ const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
186
+ const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
187
+ const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
188
+ const OPTION_KEEP_ORDER = "keepOrder";
189
+ const OPTION_LEVEL = "level";
190
+ const OPTION_BUFFERED_WRITE = "bufferedWrite";
191
+ const OPTION_CREATE_TEMP_STREAM = "createTempStream";
192
+ const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
193
+ const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
194
+ const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
195
+ const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
196
+ const OPTION_ENCODE_TEXT = "encodeText";
197
+ const OPTION_OFFSET = "offset";
198
+ const OPTION_USDZ = "usdz";
199
+ const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
200
+ const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
201
+ const OPTION_STRICTNESS = "strictness";
202
+ const OPTION_FILENAME_VALIDATION = "filenameValidation";
203
+ const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
204
+ const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
205
+ const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
206
+ const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
207
+ const TEXT_TYPE_FILENAME = "filename";
208
+ const TEXT_TYPE_COMMENT = "comment";
209
+ const STRICTNESS_STRICT = "strict";
210
+ const STRICTNESS_BALANCED = "balanced";
211
+ const STRICTNESS_TOLERANT = "tolerant";
212
+
213
+ const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
214
+ const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
215
+ const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
216
+
217
+ function checkFunctionOption(value) {
218
+ if (value && typeof value != FUNCTION_TYPE) {
219
+ throw new Error(ERR_INVALID_FUNCTION_OPTION);
220
+ }
221
+ return value;
222
+ }
223
+
224
+ function checkSignalOption(signal) {
225
+ if (signal && (typeof signal.addEventListener != FUNCTION_TYPE || typeof signal.aborted != BOOLEAN_TYPE)) {
226
+ throw new Error(ERR_INVALID_SIGNAL);
227
+ }
228
+ return signal || UNDEFINED_VALUE;
229
+ }
230
+
231
+ function checkPasswordOption(password, rawPassword) {
232
+ if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
233
+ throw new Error(ERR_INVALID_PASSWORD_TYPE);
234
+ }
235
+ }
236
+
237
+ function toNumber(value) {
238
+ return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
239
+ }
240
+
130
241
  /*
131
242
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
132
243
 
@@ -156,7 +267,10 @@
156
267
  */
157
268
 
158
269
 
270
+ const DEFAULT_CHUNK_SIZE$1 = 64 * 1024;
159
271
  const MINIMUM_CHUNK_SIZE = 64;
272
+ const MINIMUM_PROPERTY_VALUE = 1;
273
+ const ERR_INVALID_MAX_WORKERS = "Invalid maxWorkers (must be an integer greater than 0)";
160
274
  let maxWorkers = 2;
161
275
  try {
162
276
  if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
@@ -168,7 +282,7 @@
168
282
  const DEFAULT_CONFIGURATION = {
169
283
  workerURI: "./core/web-worker-wasm.js",
170
284
  wasmURI: "./core/streams/zlib-wasm/zlib-streams.wasm",
171
- chunkSize: 64 * 1024,
285
+ chunkSize: DEFAULT_CHUNK_SIZE$1,
172
286
  maxWorkers,
173
287
  terminateWorkerTimeout: 5000,
174
288
  workerStarvationTimeout: 5000,
@@ -180,24 +294,38 @@
180
294
  DecompressionStream: typeof DecompressionStream != UNDEFINED_TYPE && DecompressionStream
181
295
  };
182
296
 
183
- const CONFIGURABLE_PROPERTY_NAMES = [
297
+ const PROPERTY_NAME_MAX_WORKERS = "maxWorkers";
298
+
299
+ const STRING_PROPERTY_NAMES = [
184
300
  "baseURI",
185
301
  "wasmURI",
186
- "workerURI",
187
- "createWorker",
302
+ "workerURI"
303
+ ];
304
+ const BOOLEAN_PROPERTY_NAMES = [
305
+ "useCompressionStream",
306
+ "useWebWorkers",
307
+ "transferStreams"
308
+ ];
309
+ const NUMBER_PROPERTY_NAMES = [
188
310
  "chunkSize",
189
- "maxWorkers",
311
+ PROPERTY_NAME_MAX_WORKERS,
190
312
  "terminateWorkerTimeout",
191
313
  "workerStarvationTimeout",
192
- "workerStartupTimeout",
193
- "useCompressionStream",
194
- "useWebWorkers",
195
- "transferStreams",
314
+ "workerStartupTimeout"
315
+ ];
316
+ const FUNCTION_PROPERTY_NAMES = [
317
+ "createWorker",
196
318
  "CompressionStream",
197
319
  "DecompressionStream",
198
320
  "CompressionStreamFallback",
199
321
  "DecompressionStreamFallback"
200
322
  ];
323
+ const CONFIGURABLE_PROPERTY_NAMES = [
324
+ ...STRING_PROPERTY_NAMES,
325
+ ...BOOLEAN_PROPERTY_NAMES,
326
+ ...NUMBER_PROPERTY_NAMES,
327
+ ...FUNCTION_PROPERTY_NAMES
328
+ ];
201
329
 
202
330
  const config = { ...DEFAULT_CONFIGURATION };
203
331
 
@@ -206,20 +334,43 @@
206
334
  }
207
335
 
208
336
  function getChunkSize(config) {
209
- return Math.max(config.chunkSize, MINIMUM_CHUNK_SIZE);
337
+ return normalizeChunkSize(config.chunkSize);
338
+ }
339
+
340
+ function normalizeChunkSize(chunkSize) {
341
+ chunkSize = toNumber(chunkSize);
342
+ return Number.isInteger(chunkSize) && chunkSize >= MINIMUM_PROPERTY_VALUE ? Math.max(chunkSize, MINIMUM_CHUNK_SIZE) : DEFAULT_CHUNK_SIZE$1;
210
343
  }
211
344
 
212
345
  function configure(configuration) {
213
- configuration = normalizeConfiguration(configuration);
346
+ Object.assign(config, checkConfiguration(normalizeConfiguration(configuration)));
347
+ }
348
+
349
+ function checkConfiguration(configuration) {
350
+ const checkedConfiguration = {};
214
351
  for (const propertyName of CONFIGURABLE_PROPERTY_NAMES) {
215
352
  const propertyValue = configuration[propertyName];
216
353
  if (propertyValue !== UNDEFINED_VALUE) {
217
- config[propertyName] = propertyValue;
354
+ checkedConfiguration[propertyName] = checkPropertyValue(propertyName, propertyValue);
218
355
  }
219
356
  }
357
+ return checkedConfiguration;
358
+ }
359
+
360
+ function checkPropertyValue(propertyName, propertyValue) {
361
+ if (NUMBER_PROPERTY_NAMES.includes(propertyName)) {
362
+ propertyValue = toNumber(propertyValue);
363
+ if (propertyName == PROPERTY_NAME_MAX_WORKERS && (!Number.isInteger(propertyValue) || propertyValue < MINIMUM_PROPERTY_VALUE)) {
364
+ throw new Error(ERR_INVALID_MAX_WORKERS);
365
+ }
366
+ } else if (FUNCTION_PROPERTY_NAMES.includes(propertyName)) {
367
+ checkFunctionOption(propertyValue);
368
+ }
369
+ return propertyValue;
220
370
  }
221
371
 
222
372
  function normalizeConfiguration(configuration) {
373
+ configuration = configuration || {};
223
374
  const { CompressionStreamZlib, DecompressionStreamZlib } = configuration;
224
375
  if (CompressionStreamZlib === UNDEFINED_VALUE && DecompressionStreamZlib === UNDEFINED_VALUE) {
225
376
  return configuration;
@@ -235,14 +386,9 @@
235
386
  }
236
387
 
237
388
  function setDefaultConfiguration(configuration) {
238
- configuration = normalizeConfiguration(configuration);
239
- for (const propertyName of CONFIGURABLE_PROPERTY_NAMES) {
240
- const propertyValue = configuration[propertyName];
241
- if (propertyValue !== UNDEFINED_VALUE) {
242
- DEFAULT_CONFIGURATION[propertyName] = propertyValue;
243
- }
244
- }
245
- configure(configuration);
389
+ const checkedConfiguration = checkConfiguration(normalizeConfiguration(configuration));
390
+ Object.assign(DEFAULT_CONFIGURATION, checkedConfiguration);
391
+ Object.assign(config, checkedConfiguration);
246
392
  }
247
393
 
248
394
  function resetConfiguration() {
@@ -1398,13 +1544,13 @@
1398
1544
  const {
1399
1545
  ctr,
1400
1546
  hmac,
1401
- pending,
1547
+ pendingInput,
1402
1548
  ready
1403
1549
  } = this;
1404
1550
  if (hmac && ctr) {
1405
1551
  await ready;
1406
- const chunkToDecrypt = subarray(pending, 0, pending.length - AUTHENTICATION_CODE_LENGTH);
1407
- const originalAuthenticationCode = subarray(pending, pending.length - AUTHENTICATION_CODE_LENGTH);
1552
+ const chunkToDecrypt = subarray(pendingInput, 0, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
1553
+ const originalAuthenticationCode = subarray(pendingInput, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
1408
1554
  let decryptedChunkArray = EMPTY_UINT8_ARRAY;
1409
1555
  if (chunkToDecrypt.length) {
1410
1556
  const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
@@ -1413,7 +1559,7 @@
1413
1559
  decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
1414
1560
  }
1415
1561
  const authenticationCode = subarray(fromBits(codecBytes, hmac.digest()), 0, AUTHENTICATION_CODE_LENGTH);
1416
- let invalidAuthenticationCode = pending.length < AUTHENTICATION_CODE_LENGTH ? 1 : 0;
1562
+ let invalidAuthenticationCode = pendingInput.length < AUTHENTICATION_CODE_LENGTH ? 1 : 0;
1417
1563
  for (let indexByte = 0; indexByte < AUTHENTICATION_CODE_LENGTH; indexByte++) {
1418
1564
  invalidAuthenticationCode |= authenticationCode[indexByte] ^ originalAuthenticationCode[indexByte];
1419
1565
  }
@@ -1457,14 +1603,14 @@
1457
1603
  const {
1458
1604
  ctr,
1459
1605
  hmac,
1460
- pending,
1606
+ pendingInput,
1461
1607
  ready
1462
1608
  } = this;
1463
1609
  if (hmac && ctr) {
1464
1610
  await ready;
1465
1611
  let encryptedChunkArray = EMPTY_UINT8_ARRAY;
1466
- if (pending.length) {
1467
- const encryptedChunk = ctr.update(toBits(codecBytes, pending));
1612
+ if (pendingInput.length) {
1613
+ const encryptedChunk = ctr.update(toBits(codecBytes, pendingInput));
1468
1614
  hmac.update(encryptedChunk);
1469
1615
  encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
1470
1616
  }
@@ -1481,7 +1627,7 @@
1481
1627
  ready: new Promise(resolve => aesCrypto.resolveReady = resolve),
1482
1628
  password: encodePassword(password, rawPassword),
1483
1629
  strength: encryptionStrength - 1,
1484
- pending: EMPTY_UINT8_ARRAY
1630
+ pendingInput: EMPTY_UINT8_ARRAY
1485
1631
  });
1486
1632
  }
1487
1633
 
@@ -1489,10 +1635,10 @@
1489
1635
  const {
1490
1636
  ctr,
1491
1637
  hmac,
1492
- pending
1638
+ pendingInput
1493
1639
  } = aesCrypto;
1494
- if (pending.length) {
1495
- input = concat(pending, input);
1640
+ if (pendingInput.length) {
1641
+ input = concat(pendingInput, input);
1496
1642
  }
1497
1643
  const inputLength = input.length - paddingEnd;
1498
1644
  output = expand(output, paddingStart + (inputLength - (inputLength % BLOCK_LENGTH)));
@@ -1508,7 +1654,7 @@
1508
1654
  }
1509
1655
  output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
1510
1656
  }
1511
- aesCrypto.pending = subarray(input, offset);
1657
+ aesCrypto.pendingInput = subarray(input, offset);
1512
1658
  return output;
1513
1659
  }
1514
1660
 
@@ -3281,6 +3427,96 @@
3281
3427
  resetWebWorkerSupport();
3282
3428
  }
3283
3429
 
3430
+ /*
3431
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
3432
+
3433
+ Redistribution and use in source and binary forms, with or without
3434
+ modification, are permitted provided that the following conditions are met:
3435
+
3436
+ 1. Redistributions of source code must retain the above copyright notice,
3437
+ this list of conditions and the following disclaimer.
3438
+
3439
+ 2. Redistributions in binary form must reproduce the above copyright
3440
+ notice, this list of conditions and the following disclaimer in
3441
+ the documentation and/or other materials provided with the distribution.
3442
+
3443
+ 3. The names of the authors may not be used to endorse or promote products
3444
+ derived from this software without specific prior written permission.
3445
+
3446
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
3447
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
3448
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
3449
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
3450
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3451
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
3452
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
3453
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3454
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3455
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3456
+ */
3457
+
3458
+ /* global TextDecoder */
3459
+
3460
+ const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
3461
+ const VALID_CP437 = CP437.length == 256;
3462
+
3463
+ function decodeCP437(stringValue) {
3464
+ if (VALID_CP437) {
3465
+ let result = "";
3466
+ for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
3467
+ result += CP437[stringValue[indexCharacter]];
3468
+ }
3469
+ return result;
3470
+ } else {
3471
+ return new TextDecoder().decode(stringValue);
3472
+ }
3473
+ }
3474
+
3475
+ /*
3476
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
3477
+
3478
+ Redistribution and use in source and binary forms, with or without
3479
+ modification, are permitted provided that the following conditions are met:
3480
+
3481
+ 1. Redistributions of source code must retain the above copyright notice,
3482
+ this list of conditions and the following disclaimer.
3483
+
3484
+ 2. Redistributions in binary form must reproduce the above copyright
3485
+ notice, this list of conditions and the following disclaimer in
3486
+ the documentation and/or other materials provided with the distribution.
3487
+
3488
+ 3. The names of the authors may not be used to endorse or promote products
3489
+ derived from this software without specific prior written permission.
3490
+
3491
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
3492
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
3493
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
3494
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
3495
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3496
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
3497
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
3498
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3499
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3500
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3501
+ */
3502
+
3503
+
3504
+ function decodeText(value, encoding) {
3505
+ return decode(value, encoding, true);
3506
+ }
3507
+
3508
+ function decodeTextRemovingBOM(value, encoding) {
3509
+ return decode(value, encoding, false);
3510
+ }
3511
+
3512
+ function decode(value, encoding, ignoreBOM) {
3513
+ if (encoding && encoding.trim().toLowerCase() == "cp437") {
3514
+ return decodeCP437(value);
3515
+ } else {
3516
+ return new TextDecoder(encoding, { ignoreBOM }).decode(value);
3517
+ }
3518
+ }
3519
+
3284
3520
  /*
3285
3521
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
3286
3522
 
@@ -3353,6 +3589,7 @@
3353
3589
  createReadable({ offset = 0, size, chunkSize = getChunkSize(getConfiguration()) } = {}) {
3354
3590
  const reader = this;
3355
3591
  let chunkOffset = 0;
3592
+ chunkSize = normalizeChunkSize(chunkSize);
3356
3593
  return new ReadableStream({
3357
3594
  async pull(controller) {
3358
3595
  const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
@@ -3360,7 +3597,7 @@
3360
3597
  if (data.length) {
3361
3598
  controller.enqueue(data);
3362
3599
  }
3363
- if ((chunkOffset + chunkSize >= size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
3600
+ if ((chunkOffset + chunkSize >= size) || (!data.length && dataSize)) {
3364
3601
  controller.close();
3365
3602
  } else {
3366
3603
  chunkOffset += chunkSize;
@@ -3440,31 +3677,31 @@
3440
3677
  Object.assign(this, {
3441
3678
  contentType,
3442
3679
  data: "data:" + (contentType || "") + ";base64,",
3443
- pending: []
3680
+ pendingCharacters: ""
3444
3681
  });
3445
3682
  }
3446
3683
 
3447
3684
  writeUint8Array(array) {
3448
3685
  const writer = this;
3449
3686
  let indexArray;
3450
- let dataString = writer.pending;
3451
- const delta = writer.pending.length;
3452
- writer.pending = "";
3687
+ let dataString = writer.pendingCharacters;
3688
+ const delta = writer.pendingCharacters.length;
3689
+ writer.pendingCharacters = "";
3453
3690
  for (indexArray = 0; indexArray < (Math.floor((delta + array.length) / 3) * 3) - delta; indexArray++) {
3454
3691
  dataString += String.fromCharCode(array[indexArray]);
3455
3692
  }
3456
3693
  for (; indexArray < array.length; indexArray++) {
3457
- writer.pending += String.fromCharCode(array[indexArray]);
3694
+ writer.pendingCharacters += String.fromCharCode(array[indexArray]);
3458
3695
  }
3459
3696
  if (dataString.length > 2) {
3460
3697
  writer.data += btoa(dataString);
3461
3698
  } else {
3462
- writer.pending = dataString + writer.pending;
3699
+ writer.pendingCharacters = dataString + writer.pendingCharacters;
3463
3700
  }
3464
3701
  }
3465
3702
 
3466
3703
  getData() {
3467
- return this.data + btoa(this.pending);
3704
+ return this.data + btoa(this.pendingCharacters);
3468
3705
  }
3469
3706
  }
3470
3707
 
@@ -3494,7 +3731,7 @@
3494
3731
  constructor(blob) {
3495
3732
  super();
3496
3733
  Object.assign(this, {
3497
- blob,
3734
+ sourceBlob: blob,
3498
3735
  size: blob.size
3499
3736
  });
3500
3737
  if (!blobSliceProbe) {
@@ -3504,13 +3741,13 @@
3504
3741
 
3505
3742
  createReadable(options) {
3506
3743
  const reader = this;
3507
- const { blob, size } = reader;
3744
+ const { sourceBlob, size } = reader;
3508
3745
  const { offset = 0, size: readSize = size - offset } = options || {};
3509
3746
  if (!offset && readSize >= size) {
3510
- return toCompatibleReadable(blob.stream());
3747
+ return toCompatibleReadable(sourceBlob.stream());
3511
3748
  }
3512
3749
  if (blobSliceReliable) {
3513
- return toCompatibleReadable(blob.slice(offset, offset + readSize).stream());
3750
+ return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
3514
3751
  }
3515
3752
  return super.createReadable(options);
3516
3753
  }
@@ -3519,7 +3756,7 @@
3519
3756
  const reader = this;
3520
3757
  const offsetEnd = offset + length;
3521
3758
  const readsWholeBlob = !offset && offsetEnd >= reader.size;
3522
- const blob = readsWholeBlob ? reader.blob : reader.blob.slice(offset, offsetEnd);
3759
+ const blob = readsWholeBlob ? reader.sourceBlob : reader.sourceBlob.slice(offset, offsetEnd);
3523
3760
  let arrayBuffer = await blob.arrayBuffer();
3524
3761
  const sliceIgnoredByBuggyImplementation = arrayBuffer.byteLength > length;
3525
3762
  if (sliceIgnoredByBuggyImplementation) {
@@ -3541,12 +3778,12 @@
3541
3778
  }
3542
3779
  });
3543
3780
  writer.contentType = contentType;
3544
- writer.blob = streamToBlob(transformStream.readable, contentType);
3545
- writer.blob.catch(() => { });
3781
+ writer.blobPromise = streamToBlob(transformStream.readable, contentType);
3782
+ writer.blobPromise.catch(() => { });
3546
3783
  }
3547
3784
 
3548
3785
  getData() {
3549
- return this.blob;
3786
+ return this.blobPromise;
3550
3787
  }
3551
3788
  }
3552
3789
 
@@ -3560,7 +3797,7 @@
3560
3797
  class TextWriter extends BlobWriter {
3561
3798
 
3562
3799
  constructor(encoding) {
3563
- super(encoding);
3800
+ super();
3564
3801
  Object.assign(this, {
3565
3802
  encoding,
3566
3803
  utf8: !encoding || encoding.toLowerCase() == "utf-8"
@@ -3576,14 +3813,7 @@
3576
3813
  if (blob.text && utf8) {
3577
3814
  return blob.text();
3578
3815
  } else {
3579
- const reader = new FileReader();
3580
- return new Promise((resolve, reject) => {
3581
- Object.assign(reader, {
3582
- onload: ({ target }) => resolve(target.result),
3583
- onerror: () => reject(reader.error)
3584
- });
3585
- reader.readAsText(blob, encoding);
3586
- });
3816
+ return decodeTextRemovingBOM(new Uint8Array(await blob.arrayBuffer()), encoding);
3587
3817
  }
3588
3818
  }
3589
3819
  }
@@ -4251,85 +4481,13 @@
4251
4481
  return reader.readUint8Array(offset, size);
4252
4482
  }
4253
4483
 
4254
- /*
4255
- Copyright (c) 2022 Gildas Lormeau. All rights reserved.
4256
-
4257
- Redistribution and use in source and binary forms, with or without
4258
- modification, are permitted provided that the following conditions are met:
4259
-
4260
- 1. Redistributions of source code must retain the above copyright notice,
4261
- this list of conditions and the following disclaimer.
4262
-
4263
- 2. Redistributions in binary form must reproduce the above copyright
4264
- notice, this list of conditions and the following disclaimer in
4265
- the documentation and/or other materials provided with the distribution.
4266
-
4267
- 3. The names of the authors may not be used to endorse or promote products
4268
- derived from this software without specific prior written permission.
4269
-
4270
- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
4271
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
4272
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
4273
- INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
4274
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4275
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
4276
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4277
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4278
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4279
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4280
- */
4281
-
4282
- /* global TextDecoder */
4283
-
4284
- const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
4285
- const VALID_CP437 = CP437.length == 256;
4286
-
4287
- function decodeCP437(stringValue) {
4288
- if (VALID_CP437) {
4289
- let result = "";
4290
- for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
4291
- result += CP437[stringValue[indexCharacter]];
4292
- }
4293
- return result;
4294
- } else {
4295
- return new TextDecoder().decode(stringValue);
4296
- }
4297
- }
4298
-
4299
- /*
4300
- Copyright (c) 2022 Gildas Lormeau. All rights reserved.
4301
-
4302
- Redistribution and use in source and binary forms, with or without
4303
- modification, are permitted provided that the following conditions are met:
4304
-
4305
- 1. Redistributions of source code must retain the above copyright notice,
4306
- this list of conditions and the following disclaimer.
4307
-
4308
- 2. Redistributions in binary form must reproduce the above copyright
4309
- notice, this list of conditions and the following disclaimer in
4310
- the documentation and/or other materials provided with the distribution.
4311
-
4312
- 3. The names of the authors may not be used to endorse or promote products
4313
- derived from this software without specific prior written permission.
4314
-
4315
- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
4316
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
4317
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
4318
- INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
4319
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4320
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
4321
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4322
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4323
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4324
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4325
- */
4326
-
4327
-
4328
- function decodeText(value, encoding) {
4329
- if (encoding && encoding.trim().toLowerCase() == "cp437") {
4330
- return decodeCP437(value);
4484
+ function createReadable(reader, options) {
4485
+ if (reader.createReadable) {
4486
+ return reader.createReadable(options);
4487
+ } else if (reader.readUint8Array) {
4488
+ return Reader.prototype.createReadable.call(reader, options);
4331
4489
  } else {
4332
- return new TextDecoder(encoding, { ignoreBOM: true }).decode(value);
4490
+ return reader.readable;
4333
4491
  }
4334
4492
  }
4335
4493
 
@@ -4489,83 +4647,6 @@
4489
4647
 
4490
4648
  }
4491
4649
 
4492
- /*
4493
- Copyright (c) 2022 Gildas Lormeau. All rights reserved.
4494
-
4495
- Redistribution and use in source and binary forms, with or without
4496
- modification, are permitted provided that the following conditions are met:
4497
-
4498
- 1. Redistributions of source code must retain the above copyright notice,
4499
- this list of conditions and the following disclaimer.
4500
-
4501
- 2. Redistributions in binary form must reproduce the above copyright
4502
- notice, this list of conditions and the following disclaimer in
4503
- the documentation and/or other materials provided with the distribution.
4504
-
4505
- 3. The names of the authors may not be used to endorse or promote products
4506
- derived from this software without specific prior written permission.
4507
-
4508
- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
4509
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
4510
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
4511
- INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
4512
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4513
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
4514
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4515
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4516
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4517
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4518
- */
4519
-
4520
- const OPTION_FILENAME_ENCODING = "filenameEncoding";
4521
- const OPTION_COMMENT_ENCODING = "commentEncoding";
4522
- const OPTION_DECODE_TEXT = "decodeText";
4523
- const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
4524
- const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
4525
- const OPTION_PASSWORD = "password";
4526
- const OPTION_RAW_PASSWORD = "rawPassword";
4527
- const OPTION_PASS_THROUGH = "passThrough";
4528
- const OPTION_SIGNAL = "signal";
4529
- const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
4530
- const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
4531
- const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
4532
- const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
4533
- const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
4534
- const OPTION_CHECK_SIGNATURE = "checkSignature";
4535
- const OPTION_CHECK_CRC32 = "checkCrc32";
4536
- const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
4537
- const OPTION_USE_WEB_WORKERS = "useWebWorkers";
4538
- const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
4539
- const OPTION_TRANSFER_STREAMS = "transferStreams";
4540
- const OPTION_PREVENT_CLOSE = "preventClose";
4541
- const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
4542
- const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
4543
- const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
4544
- const OPTION_KEEP_ORDER = "keepOrder";
4545
- const OPTION_LEVEL = "level";
4546
- const OPTION_BUFFERED_WRITE = "bufferedWrite";
4547
- const OPTION_CREATE_TEMP_STREAM = "createTempStream";
4548
- const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
4549
- const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
4550
- const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
4551
- const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
4552
- const OPTION_ENCODE_TEXT = "encodeText";
4553
- const OPTION_OFFSET = "offset";
4554
- const OPTION_USDZ = "usdz";
4555
- const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
4556
- const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
4557
- const OPTION_STRICTNESS = "strictness";
4558
- const OPTION_FILENAME_VALIDATION = "filenameValidation";
4559
- const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
4560
- const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
4561
- const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
4562
- const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
4563
- const TEXT_TYPE_FILENAME = "filename";
4564
- const TEXT_TYPE_COMMENT = "comment";
4565
- const STRICTNESS_STRICT = "strict";
4566
- const STRICTNESS_BALANCED = "balanced";
4567
- const STRICTNESS_TOLERANT = "tolerant";
4568
-
4569
4650
  /*
4570
4651
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
4571
4652
 
@@ -4606,6 +4687,7 @@
4606
4687
  const ERR_UNSUPPORTED_COMPRESSION$1 = "Compression method not supported";
4607
4688
  const ERR_SPLIT_ZIP_FILE = "Split zip file";
4608
4689
  const ERR_OVERLAPPING_ENTRY = "Overlapping entry found";
4690
+ const ERR_ENTRY_DATA_OUT_OF_BOUNDS = "Entry data out of bounds";
4609
4691
  const ERR_AMBIGUOUS_ARCHIVE = "Ambiguous archive";
4610
4692
  const ERR_ENCRYPTED_CENTRAL_DIRECTORY = "Encrypted central directory is not supported";
4611
4693
  const ERR_UNSAFE_FILENAME = "Unsafe filename";
@@ -4626,7 +4708,7 @@
4626
4708
  ];
4627
4709
  const ZIP64_EXTRACTION = {
4628
4710
  [MAX_16_BITS]: {
4629
- getValue: getUint32,
4711
+ getValue: getUint32$1,
4630
4712
  bytes: 4
4631
4713
  },
4632
4714
  [MAX_32_BITS]: {
@@ -4635,6 +4717,7 @@
4635
4717
  }
4636
4718
  };
4637
4719
  const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
4720
+ const MAX_DEFLATE_EXPANSION_RATIO = 1032;
4638
4721
  const CENTRAL_DIRECTORY_UNREACHABLE = 0;
4639
4722
  const CENTRAL_DIRECTORY_PLAUSIBLE = 1;
4640
4723
  const CENTRAL_DIRECTORY_REACHABLE = 2;
@@ -4645,7 +4728,6 @@
4645
4728
  Object.assign(this, {
4646
4729
  reader: new GenericReader(reader),
4647
4730
  options,
4648
- config: getConfiguration(),
4649
4731
  readRanges: new Map()
4650
4732
  });
4651
4733
  }
@@ -4653,7 +4735,6 @@
4653
4735
  async* getEntriesGenerator(options = {}) {
4654
4736
  const zipReader = this;
4655
4737
  let { reader } = zipReader;
4656
- const { config } = zipReader;
4657
4738
  await initStream(reader);
4658
4739
  if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
4659
4740
  reader = new BlobReader(await streamToBlob(reader.readable));
@@ -4670,9 +4751,7 @@
4670
4751
  const normalizeFilename = getOptionValue$1(zipReader, options, OPTION_NORMALIZE_FILENAME);
4671
4752
  const { endOfDirectoryInfo, endOfDirectoryReachingEndCount } = await findEndOfCentralDirectory(reader, rejectAmbiguousEndOfDirectory, maxAppendedDataSize);
4672
4753
  if (!endOfDirectoryInfo) {
4673
- const signatureArray = await readUint8Array(reader, 0, 4);
4674
- const signatureView = getDataView(signatureArray);
4675
- if (getUint32(signatureView) == SPLIT_ZIP_FILE_SIGNATURE) {
4754
+ if (await startsWithSplitZipSignature$1(reader)) {
4676
4755
  throw new Error(ERR_SPLIT_ZIP_FILE);
4677
4756
  } else {
4678
4757
  throw new Error(ERR_EOCDR_NOT_FOUND);
@@ -4682,18 +4761,18 @@
4682
4761
  throwAmbiguousArchive("multiple end of central directory records");
4683
4762
  }
4684
4763
  const endOfDirectoryView = getDataView(endOfDirectoryInfo);
4685
- let directoryDataLength = getUint32(endOfDirectoryView, 12);
4686
- let directoryDataOffset = getUint32(endOfDirectoryView, 16);
4764
+ let directoryDataLength = getUint32$1(endOfDirectoryView, 12);
4765
+ let directoryDataOffset = getUint32$1(endOfDirectoryView, 16);
4687
4766
  const commentOffset = endOfDirectoryInfo.offset;
4688
- const commentLength = getUint16(endOfDirectoryView, 20);
4767
+ const commentLength = getUint16$1(endOfDirectoryView, 20);
4689
4768
  const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
4690
4769
  if (reader.size - appendedDataOffset > maxAppendedDataSize) {
4691
4770
  throwAmbiguousArchive("appended data");
4692
4771
  }
4693
- let lastDiskNumber = getUint16(endOfDirectoryView, 4);
4772
+ let lastDiskNumber = getUint16$1(endOfDirectoryView, 4);
4694
4773
  const expectedLastDiskNumber = reader.lastDiskNumber || 0;
4695
- let diskNumber = getUint16(endOfDirectoryView, 6);
4696
- let filesLength = getUint16(endOfDirectoryView, 10);
4774
+ let diskNumber = getUint16$1(endOfDirectoryView, 6);
4775
+ let filesLength = getUint16$1(endOfDirectoryView, 10);
4697
4776
  let prependedDataLength = 0;
4698
4777
  let startOffset;
4699
4778
  let zip64EndOfDirectory;
@@ -4709,12 +4788,12 @@
4709
4788
  EMPTY_UINT8_ARRAY;
4710
4789
  const endOfDirectoryLocatorView = getDataView(endOfDirectoryLocatorArray);
4711
4790
  if (endOfDirectoryLocatorArray.length == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH &&
4712
- getUint32(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
4713
- directoryDataOffset = getDiskOffset$1(reader, getUint32(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
4791
+ getUint32$1(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
4792
+ directoryDataOffset = getDiskOffset$1(reader, getUint32$1(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
4714
4793
  let endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
4715
4794
  let endOfDirectoryView = getDataView(endOfDirectoryArray);
4716
4795
  const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH - ZIP64_END_OF_CENTRAL_DIR_LENGTH;
4717
- if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
4796
+ if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
4718
4797
  directoryDataOffset != expectedDirectoryDataOffset && expectedDirectoryDataOffset >= 0) {
4719
4798
  const originalDirectoryDataOffset = directoryDataOffset;
4720
4799
  directoryDataOffset = expectedDirectoryDataOffset;
@@ -4724,7 +4803,7 @@
4724
4803
  endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
4725
4804
  endOfDirectoryView = getDataView(endOfDirectoryArray);
4726
4805
  }
4727
- if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
4806
+ if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
4728
4807
  throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
4729
4808
  }
4730
4809
  zip64EndOfDirectory = true;
@@ -4739,13 +4818,13 @@
4739
4818
  }
4740
4819
  }
4741
4820
  if (lastDiskNumber == MAX_16_BITS) {
4742
- lastDiskNumber = getUint32(endOfDirectoryView, 16);
4743
- } else if (checkAmbiguity && lastDiskNumber != getUint32(endOfDirectoryView, 16)) {
4821
+ lastDiskNumber = getUint32$1(endOfDirectoryView, 16);
4822
+ } else if (checkAmbiguity && lastDiskNumber != getUint32$1(endOfDirectoryView, 16)) {
4744
4823
  throwAmbiguousArchive("mismatched zip64 end of central directory record");
4745
4824
  }
4746
4825
  if (diskNumber == MAX_16_BITS) {
4747
- diskNumber = getUint32(endOfDirectoryView, 20);
4748
- } else if (checkAmbiguity && diskNumber != getUint32(endOfDirectoryView, 20)) {
4826
+ diskNumber = getUint32$1(endOfDirectoryView, 20);
4827
+ } else if (checkAmbiguity && diskNumber != getUint32$1(endOfDirectoryView, 20)) {
4749
4828
  throwAmbiguousArchive("mismatched zip64 end of central directory record");
4750
4829
  }
4751
4830
  if (filesLength == MAX_16_BITS) {
@@ -4783,11 +4862,11 @@
4783
4862
  }
4784
4863
  const expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
4785
4864
  if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
4786
- const storedPointsAtDirectory = getUint32(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
4865
+ const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
4787
4866
  let reconcile = !storedPointsAtDirectory;
4788
4867
  if (!reconcile && expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
4789
4868
  const expectedSignatureArray = await readUint8Array(reader, expectedDirectoryDataOffset, 4);
4790
- reconcile = getUint32(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
4869
+ reconcile = getUint32$1(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
4791
4870
  }
4792
4871
  if (reconcile) {
4793
4872
  const originalDirectoryDataOffset = directoryDataOffset;
@@ -4811,10 +4890,10 @@
4811
4890
  }
4812
4891
  zipReader.directoryOffset = directoryDataOffset;
4813
4892
  zipReader.directoryLength = declaredDirectoryDataLength;
4814
- const decryptCentralDirectory = getOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
4893
+ const decryptCentralDirectory = getFunctionOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
4815
4894
  let decryptedDirectory;
4816
4895
  if (decryptCentralDirectory && filesLength && directoryArray.length >= 4 &&
4817
- getUint32(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
4896
+ getUint32$1(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
4818
4897
  (zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
4819
4898
  directoryArray = await decryptCentralDirectory(directoryArray, directoryEncryptionInfo);
4820
4899
  directoryView = getDataView(directoryArray);
@@ -4827,8 +4906,8 @@
4827
4906
  const filenames = checkAmbiguity ? new Set() : UNDEFINED_VALUE;
4828
4907
  let duplicateFilename;
4829
4908
  for (let indexFile = 0; indexFile < filesLength; indexFile++) {
4830
- const fileEntry = new ZipEntry(reader, config, zipReader.options);
4831
- if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
4909
+ const fileEntry = new ZipEntry(reader, zipReader.options);
4910
+ if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32$1(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
4832
4911
  if (indexFile == 0 && !decryptedDirectory && (zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
4833
4912
  throw new Error(ERR_ENCRYPTED_CENTRAL_DIRECTORY);
4834
4913
  }
@@ -4839,16 +4918,16 @@
4839
4918
  const filenameOffset = offset + CENTRAL_FILE_HEADER_LENGTH;
4840
4919
  const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
4841
4920
  const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
4842
- const versionMadeBy = getUint16(directoryView, offset + 4);
4921
+ const versionMadeBy = getUint16$1(directoryView, offset + 4);
4843
4922
  const msDosCompatible = versionMadeBy >> 8 == 0;
4844
4923
  const unixCompatible = versionMadeBy >> 8 == 3;
4845
4924
  const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
4846
- const commentLength = getUint16(directoryView, offset + 32);
4925
+ const commentLength = getUint16$1(directoryView, offset + 32);
4847
4926
  const endOffset = commentOffset + commentLength;
4848
4927
  const rawComment = directoryArray.subarray(commentOffset, endOffset);
4849
4928
  const filenameUTF8 = languageEncodingFlag;
4850
4929
  const commentUTF8 = languageEncodingFlag;
4851
- const externalFileAttributes = getUint32(directoryView, offset + 38);
4930
+ const externalFileAttributes = getUint32$1(directoryView, offset + 38);
4852
4931
  const msdosAttributesRaw = externalFileAttributes & MAX_8_BITS;
4853
4932
  const msdosAttributes = {
4854
4933
  readOnly: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_READONLY_MASK),
@@ -4857,8 +4936,8 @@
4857
4936
  directory: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_DIR_MASK),
4858
4937
  archive: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_ARCHIVE_MASK)
4859
4938
  };
4860
- const offsetFileEntry = getUint32(directoryView, offset + 42);
4861
- const decode = getOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
4939
+ const offsetFileEntry = getUint32$1(directoryView, offset + 42);
4940
+ const decode = getFunctionOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
4862
4941
  const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
4863
4942
  const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
4864
4943
  let filename = decode(rawFilename, rawFilenameEncoding, TEXT_TYPE_FILENAME);
@@ -4889,8 +4968,8 @@
4889
4968
  uncompressedSize: 0,
4890
4969
  commentLength,
4891
4970
  offset: offsetFileEntry,
4892
- diskNumberStart: getUint16(directoryView, offset + 34),
4893
- internalFileAttributes: getUint16(directoryView, offset + 36),
4971
+ diskNumberStart: getUint16$1(directoryView, offset + 34),
4972
+ internalFileAttributes: getUint16$1(directoryView, offset + 36),
4894
4973
  externalFileAttributes,
4895
4974
  msdosAttributesRaw,
4896
4975
  msdosAttributes,
@@ -4958,8 +5037,8 @@
4958
5037
  yield entry;
4959
5038
  }
4960
5039
  let offsetAfterSignature = offset;
4961
- if (offset + 6 <= directoryArray.length && getUint32(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
4962
- const signatureDataLength = getUint16(directoryView, offset + 4);
5040
+ if (offset + 6 <= directoryArray.length && getUint32$1(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
5041
+ const signatureDataLength = getUint16$1(directoryView, offset + 4);
4963
5042
  if (offset + 6 + signatureDataLength <= directoryArray.length) {
4964
5043
  zipReader.digitalSignature = directoryArray.subarray(offset + 6, offset + 6 + signatureDataLength);
4965
5044
  offsetAfterSignature = offset + 6 + signatureDataLength;
@@ -4971,13 +5050,17 @@
4971
5050
  if (duplicateFilename) {
4972
5051
  throwAmbiguousArchive("duplicate filename");
4973
5052
  }
4974
- if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > 0))) {
4975
- throwAmbiguousArchive("prepended data");
4976
- }
4977
5053
  const extractPrependedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_PREPENDED_DATA);
4978
5054
  const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
5055
+ const splitZipSignatureLength = (checkAmbiguity || extractPrependedData) && filesLength &&
5056
+ startOffset == SPLIT_ZIP_FILE_SIGNATURE_LENGTH && await startsWithSplitZipMarker(reader) ? SPLIT_ZIP_FILE_SIGNATURE_LENGTH : 0;
5057
+ if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > splitZipSignatureLength))) {
5058
+ throwAmbiguousArchive("prepended data");
5059
+ }
4979
5060
  if (extractPrependedData) {
4980
- zipReader.prependedData = startOffset > 0 ? await readUint8Array(reader, 0, startOffset) : EMPTY_UINT8_ARRAY;
5061
+ zipReader.prependedData = startOffset > splitZipSignatureLength ?
5062
+ await readUint8Array(reader, splitZipSignatureLength, startOffset - splitZipSignatureLength) :
5063
+ EMPTY_UINT8_ARRAY;
4981
5064
  }
4982
5065
  zipReader.comment = commentLength ? await readUint8Array(reader, commentOffset + END_OF_CENTRAL_DIR_LENGTH, commentLength) : EMPTY_UINT8_ARRAY;
4983
5066
  if (extractAppendedData) {
@@ -5044,16 +5127,16 @@
5044
5127
 
5045
5128
  class ZipEntry {
5046
5129
 
5047
- constructor(reader, config, options) {
5130
+ constructor(reader, options) {
5048
5131
  Object.assign(this, {
5049
5132
  reader,
5050
- config,
5051
5133
  options
5052
5134
  });
5053
5135
  }
5054
5136
 
5055
5137
  async getData(writer, fileEntry, readRanges, options = {}) {
5056
5138
  const zipEntry = this;
5139
+ const config = getConfiguration();
5057
5140
  const {
5058
5141
  reader,
5059
5142
  index,
@@ -5062,7 +5145,6 @@
5062
5145
  extraFieldAES,
5063
5146
  extraFieldZip64,
5064
5147
  compressionMethod,
5065
- config,
5066
5148
  bitFlag,
5067
5149
  rawBitFlag,
5068
5150
  crc32,
@@ -5080,6 +5162,7 @@
5080
5162
  let password = getOptionValue$1(zipEntry, options, OPTION_PASSWORD);
5081
5163
  let rawPassword = getOptionValue$1(zipEntry, options, OPTION_RAW_PASSWORD);
5082
5164
  const passThrough = getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH);
5165
+ checkPasswordOption(password, rawPassword);
5083
5166
  password = password && password.length && password;
5084
5167
  rawPassword = rawPassword && rawPassword.length && rawPassword;
5085
5168
  if (extraFieldAES) {
@@ -5087,7 +5170,7 @@
5087
5170
  throw new Error(ERR_UNSUPPORTED_COMPRESSION$1);
5088
5171
  }
5089
5172
  }
5090
- if (dataArray.length < HEADER_SIZE || getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
5173
+ if (dataArray.length < HEADER_SIZE || getUint32$1(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
5091
5174
  throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND);
5092
5175
  }
5093
5176
  readCommonHeader(localDirectory, dataView, 4);
@@ -5149,9 +5232,12 @@
5149
5232
  }
5150
5233
  }
5151
5234
  const dataOffset = localHeaderOffset + HEADER_SIZE + filenameLength + extraFieldLength;
5235
+ if (dataOffset + compressedSize > reader.size) {
5236
+ throw new Error(ERR_ENTRY_DATA_OUT_OF_BOUNDS);
5237
+ }
5152
5238
  const size = compressedSize;
5153
5239
  const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
5154
- const signal = getOptionValue$1(zipEntry, options, OPTION_SIGNAL);
5240
+ const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
5155
5241
  const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
5156
5242
  let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
5157
5243
  const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
@@ -5159,6 +5245,8 @@
5159
5245
  checkOverlappingEntry = true;
5160
5246
  }
5161
5247
  const { onstart, onprogress, onend } = options;
5248
+ const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !passThrough;
5249
+ const outputSize = passThrough ? compressedSize : uncompressedSize;
5162
5250
  const deflate64 = compressionMethod == COMPRESSION_METHOD_DEFLATE_64;
5163
5251
  let useCompressionStream = getOptionValue$1(zipEntry, options, OPTION_USE_COMPRESSION_STREAM);
5164
5252
  if (deflate64) {
@@ -5179,9 +5267,9 @@
5179
5267
  checkCrc32,
5180
5268
  checkAuthenticationCode: getOptionValue$1(zipEntry, options, OPTION_CHECK_AUTHENTICATION_CODE),
5181
5269
  passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((crc32 >>> 24) & MAX_8_BITS)),
5182
- outputSize: passThrough ? compressedSize : uncompressedSize,
5270
+ outputSize,
5183
5271
  crc32,
5184
- compressed: compressionMethod != 0 && !passThrough,
5272
+ compressed,
5185
5273
  encrypted,
5186
5274
  useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
5187
5275
  useCompressionStream,
@@ -5218,11 +5306,11 @@
5218
5306
  writer = new WritableStream();
5219
5307
  }
5220
5308
  writer = new GenericWriter(writer);
5221
- await initStream(writer, passThrough ? compressedSize : uncompressedSize);
5309
+ await initStream(writer, getDecodableOutputSize(outputSize, compressedSize, compressed));
5222
5310
  ({ writable } = writer);
5223
- const { outputSize } = await runWorker({ readable, writable }, workerOptions);
5224
- writer.size += outputSize;
5225
- if (outputSize != (passThrough ? compressedSize : uncompressedSize)) {
5311
+ const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
5312
+ writer.size += writtenSize;
5313
+ if (writtenSize != outputSize) {
5226
5314
  throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
5227
5315
  }
5228
5316
  }
@@ -5256,7 +5344,7 @@
5256
5344
  function detectEncryptedCentralDirectory(directoryView) {
5257
5345
  const maxOffset = Math.min(directoryView.byteLength, 1024) - 3;
5258
5346
  for (let offset = 0; offset < maxOffset; offset++) {
5259
- if (getUint32(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
5347
+ if (getUint32$1(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
5260
5348
  return true;
5261
5349
  }
5262
5350
  }
@@ -5267,15 +5355,15 @@
5267
5355
  const directoryEncryptionInfo = { rawExtensibleData };
5268
5356
  if (rawExtensibleData.length >= 28) {
5269
5357
  const extensibleDataView = getDataView(rawExtensibleData);
5270
- const hashDataLength = getUint16(extensibleDataView, 26);
5358
+ const hashDataLength = getUint16$1(extensibleDataView, 26);
5271
5359
  Object.assign(directoryEncryptionInfo, {
5272
- compressionMethod: getUint16(extensibleDataView, 0),
5360
+ compressionMethod: getUint16$1(extensibleDataView, 0),
5273
5361
  compressedSize: Number(getBigUint64(extensibleDataView, 2)),
5274
5362
  uncompressedSize: Number(getBigUint64(extensibleDataView, 10)),
5275
- encryptionAlgorithm: getUint16(extensibleDataView, 18),
5276
- bitLength: getUint16(extensibleDataView, 20),
5277
- flags: getUint16(extensibleDataView, 22),
5278
- hashAlgorithm: getUint16(extensibleDataView, 24),
5363
+ encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
5364
+ bitLength: getUint16$1(extensibleDataView, 20),
5365
+ flags: getUint16$1(extensibleDataView, 22),
5366
+ hashAlgorithm: getUint16$1(extensibleDataView, 24),
5279
5367
  hashData: rawExtensibleData.subarray(28, 28 + hashDataLength)
5280
5368
  });
5281
5369
  }
@@ -5283,12 +5371,12 @@
5283
5371
  }
5284
5372
 
5285
5373
  function readCommonHeader(directory, dataView, offset) {
5286
- const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2);
5374
+ const rawBitFlag = directory.rawBitFlag = getUint16$1(dataView, offset + 2);
5287
5375
  const encrypted = (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED;
5288
- const rawLastModDate = getUint32(dataView, offset + 6);
5376
+ const rawLastModDate = getUint32$1(dataView, offset + 6);
5289
5377
  Object.assign(directory, {
5290
5378
  encrypted,
5291
- version: getUint16(dataView, offset),
5379
+ version: getUint16$1(dataView, offset),
5292
5380
  bitFlag: {
5293
5381
  level: (rawBitFlag & BITFLAG_LEVEL) >> 1,
5294
5382
  dataDescriptor: (rawBitFlag & BITFLAG_DATA_DESCRIPTOR) == BITFLAG_DATA_DESCRIPTOR,
@@ -5296,8 +5384,8 @@
5296
5384
  },
5297
5385
  rawLastModDate,
5298
5386
  lastModDate: getDate(rawLastModDate),
5299
- filenameLength: getUint16(dataView, offset + 22),
5300
- extraFieldLength: getUint16(dataView, offset + 24)
5387
+ filenameLength: getUint16$1(dataView, offset + 22),
5388
+ extraFieldLength: getUint16$1(dataView, offset + 24)
5301
5389
  });
5302
5390
  }
5303
5391
 
@@ -5308,8 +5396,8 @@
5308
5396
  let offsetExtraField = 0;
5309
5397
  try {
5310
5398
  while (offsetExtraField < rawExtraField.length) {
5311
- const type = getUint16(rawExtraFieldView, offsetExtraField);
5312
- const size = getUint16(rawExtraFieldView, offsetExtraField + 2);
5399
+ const type = getUint16$1(rawExtraFieldView, offsetExtraField);
5400
+ const size = getUint16$1(rawExtraFieldView, offsetExtraField + 2);
5313
5401
  extraField.set(type, {
5314
5402
  type,
5315
5403
  data: rawExtraField.slice(offsetExtraField + 4, offsetExtraField + 4 + size)
@@ -5319,12 +5407,12 @@
5319
5407
  } catch {
5320
5408
  // ignored
5321
5409
  }
5322
- const compressionMethod = getUint16(dataView, offset + 4);
5410
+ const compressionMethod = getUint16$1(dataView, offset + 4);
5323
5411
  Object.assign(directory, {
5324
- signature: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
5325
- crc32: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
5326
- compressedSize: getUint32(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
5327
- uncompressedSize: getUint32(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
5412
+ signature: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
5413
+ crc32: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
5414
+ compressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
5415
+ uncompressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
5328
5416
  });
5329
5417
  const extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64);
5330
5418
  if (extraFieldZip64) {
@@ -5413,11 +5501,11 @@
5413
5501
  computedCrc32.append(fileEntry[rawPropertyName]);
5414
5502
  const computedCrc32View = getDataView(new Uint8Array(4));
5415
5503
  computedCrc32View.setUint32(0, computedCrc32.get(), true);
5416
- const nameCrc32 = getUint32(extraFieldView, 1);
5504
+ const nameCrc32 = getUint32$1(extraFieldView, 1);
5417
5505
  Object.assign(extraFieldUnicode, {
5418
5506
  version: getUint8(extraFieldView, 0),
5419
5507
  [propertyName]: decodeText(extraFieldUnicode.data.subarray(5)),
5420
- valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32(computedCrc32View, 0)
5508
+ valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32$1(computedCrc32View, 0)
5421
5509
  });
5422
5510
  if (extraFieldUnicode.valid) {
5423
5511
  directory[propertyName] = extraFieldUnicode[propertyName];
@@ -5433,7 +5521,7 @@
5433
5521
  vendorId: getUint8(extraFieldView, 2),
5434
5522
  strength,
5435
5523
  originalCompressionMethod: compressionMethod,
5436
- compressionMethod: getUint16(extraFieldView, 5)
5524
+ compressionMethod: getUint16$1(extraFieldView, 5)
5437
5525
  });
5438
5526
  directory.compressionMethod = extraFieldAES.compressionMethod;
5439
5527
  if (extraFieldAES.vendorVersion != VENDOR_VERSION_AE_1$1) {
@@ -5447,8 +5535,8 @@
5447
5535
  let tag1Data;
5448
5536
  try {
5449
5537
  while (offsetExtraField < extraFieldNTFS.data.length && !tag1Data) {
5450
- const tagValue = getUint16(extraFieldView, offsetExtraField);
5451
- const attributeSize = getUint16(extraFieldView, offsetExtraField + 2);
5538
+ const tagValue = getUint16$1(extraFieldView, offsetExtraField);
5539
+ const attributeSize = getUint16$1(extraFieldView, offsetExtraField + 2);
5452
5540
  if (tagValue == EXTRAFIELD_TYPE_NTFS_TAG1) {
5453
5541
  tag1Data = extraFieldNTFS.data.slice(offsetExtraField + 4, offsetExtraField + 4 + attributeSize);
5454
5542
  }
@@ -5481,12 +5569,12 @@
5481
5569
  return;
5482
5570
  }
5483
5571
  const extraFieldView = getDataView(extraField.data);
5484
- const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
5485
- const lastModDate = new Date((getUint32(extraFieldView, 4) | 0) * 1000);
5572
+ const lastAccessDate = new Date((getUint32$1(extraFieldView, 0) | 0) * 1000);
5573
+ const lastModDate = new Date((getUint32$1(extraFieldView, 4) | 0) * 1000);
5486
5574
  const extraFieldData = { lastAccessDate, lastModDate };
5487
5575
  if (extraField.data.length >= 12) {
5488
- extraFieldData.uid = getUint16(extraFieldView, 8);
5489
- extraFieldData.gid = getUint16(extraFieldView, 10);
5576
+ extraFieldData.uid = getUint16$1(extraFieldView, 8);
5577
+ extraFieldData.gid = getUint16$1(extraFieldView, 10);
5490
5578
  }
5491
5579
  Object.assign(extraField, extraFieldData);
5492
5580
  Object.assign(directory, extraFieldData);
@@ -5506,8 +5594,8 @@
5506
5594
  gid = unpackUnixId(extraField.data.subarray(offset, offset + gidSize));
5507
5595
  Object.assign(extraField, { version, uid, gid });
5508
5596
  } else if (extraField.data.length >= 4) {
5509
- uid = getUint16(view, 0);
5510
- gid = getUint16(view, 2);
5597
+ uid = getUint16$1(view, 0);
5598
+ gid = getUint16$1(view, 2);
5511
5599
  Object.assign(extraField, { uid, gid });
5512
5600
  }
5513
5601
  if (uid !== UNDEFINED_VALUE) {
@@ -5557,7 +5645,7 @@
5557
5645
  let offset = 1;
5558
5646
  timeProperties.forEach((propertyName, indexProperty) => {
5559
5647
  if (extraFieldExtendedTimestamp.data.length >= offset + 4) {
5560
- const time = getUint32(extraFieldView, offset);
5648
+ const time = getUint32$1(extraFieldView, offset);
5561
5649
  directory[propertyName] = extraFieldExtendedTimestamp[propertyName] = new Date((time | 0) * 1000);
5562
5650
  const rawPropertyName = timeRawProperties[indexProperty];
5563
5651
  extraFieldExtendedTimestamp[rawPropertyName] = time;
@@ -5591,7 +5679,7 @@
5591
5679
  const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
5592
5680
  const dataDescriptorView = getDataView(dataDescriptorArray);
5593
5681
  let signature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
5594
- getUint32(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
5682
+ getUint32$1(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
5595
5683
  if (signature) {
5596
5684
  const signedDataDescriptor = readDataDescriptor(dataDescriptorView, DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, extraFieldZip64);
5597
5685
  const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || signedDataDescriptor.crc32 == crc32;
@@ -5625,15 +5713,15 @@
5625
5713
  }
5626
5714
 
5627
5715
  function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
5628
- const crc32 = getUint32(dataDescriptorView, offset);
5716
+ const crc32 = getUint32$1(dataDescriptorView, offset);
5629
5717
  let compressedSize;
5630
5718
  let uncompressedSize;
5631
5719
  if (extraFieldZip64) {
5632
5720
  compressedSize = getBigUint64(dataDescriptorView, offset + 4);
5633
5721
  uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
5634
5722
  } else {
5635
- compressedSize = getUint32(dataDescriptorView, offset + 4);
5636
- uncompressedSize = getUint32(dataDescriptorView, offset + 8);
5723
+ compressedSize = getUint32$1(dataDescriptorView, offset + 4);
5724
+ uncompressedSize = getUint32$1(dataDescriptorView, offset + 8);
5637
5725
  }
5638
5726
  return { crc32, compressedSize, uncompressedSize };
5639
5727
  }
@@ -5642,10 +5730,28 @@
5642
5730
  return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
5643
5731
  }
5644
5732
 
5733
+ async function startsWithSplitZipSignature$1(reader) {
5734
+ return await getFirstSignature(reader) == SPLIT_ZIP_FILE_SIGNATURE;
5735
+ }
5736
+
5737
+ async function startsWithSplitZipMarker(reader) {
5738
+ const signature = await getFirstSignature(reader);
5739
+ return signature == SPLIT_ZIP_FILE_SIGNATURE || signature == TEMPORARY_SPLIT_ZIP_FILE_SIGNATURE;
5740
+ }
5741
+
5742
+ async function getFirstSignature(reader) {
5743
+ const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
5744
+ return getUint32$1(getDataView(signatureArray));
5745
+ }
5746
+
5645
5747
  function isStrictnessValue(value) {
5646
5748
  return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
5647
5749
  }
5648
5750
 
5751
+ function getDecodableOutputSize(outputSize, compressedSize, compressed) {
5752
+ return Math.min(outputSize, compressed ? compressedSize * MAX_DEFLATE_EXPANSION_RATIO : compressedSize);
5753
+ }
5754
+
5649
5755
  function getStrictness(options, inheritedOptions) {
5650
5756
  return resolveStrictness(options, resolveStrictness(inheritedOptions, STRICTNESS_BALANCED));
5651
5757
  }
@@ -5708,7 +5814,7 @@
5708
5814
 
5709
5815
  function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
5710
5816
  if (maxAppendedDataSize !== UNDEFINED_VALUE) {
5711
- const size = toNumber$1(maxAppendedDataSize);
5817
+ const size = toNumber(maxAppendedDataSize);
5712
5818
  if (typeof size != NUMBER_TYPE || Number.isNaN(size) || size < 0) {
5713
5819
  throw new Error(ERR_INVALID_MAX_APPENDED_DATA_SIZE);
5714
5820
  }
@@ -5731,7 +5837,7 @@
5731
5837
  let plausibleEndOfDirectoryInfo;
5732
5838
  let endOfDirectoryReachingEndCount = 0;
5733
5839
  for await (const [anchoredView, anchoredOffset, anchoredArray, indexByte, offset] of scanEndOfCentralDirectory(reader, anchoredLength)) {
5734
- const commentLength = getUint16(anchoredView, indexByte + 20);
5840
+ const commentLength = getUint16$1(anchoredView, indexByte + 20);
5735
5841
  if (offset + END_OF_CENTRAL_DIR_LENGTH + commentLength == size) {
5736
5842
  const reachability = await getCentralDirectoryReachability(reader, anchoredView, anchoredOffset, indexByte, offset, size, remoteProbeBudget);
5737
5843
  if (reachability == CENTRAL_DIRECTORY_REACHABLE) {
@@ -5782,7 +5888,7 @@
5782
5888
  const scanArray = await readUint8Array(reader, scanOffset, scanLength);
5783
5889
  const scanView = getDataView(scanArray);
5784
5890
  for (let indexByte = scanArray.length - END_OF_CENTRAL_DIR_LENGTH; indexByte >= 0; indexByte--) {
5785
- if (getUint32(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
5891
+ if (getUint32$1(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
5786
5892
  yield [scanView, scanOffset, scanArray, indexByte, scanOffset + indexByte];
5787
5893
  }
5788
5894
  }
@@ -5793,9 +5899,9 @@
5793
5899
  }
5794
5900
 
5795
5901
  async function getCentralDirectoryReachability(reader, view, anchoredOffset, indexByte, offset, size, remoteProbeBudget) {
5796
- const filesLength = getUint16(view, indexByte + 10);
5797
- const directoryDataLength = getUint32(view, indexByte + 12);
5798
- const directoryDataOffset = getUint32(view, indexByte + 16);
5902
+ const filesLength = getUint16$1(view, indexByte + 10);
5903
+ const directoryDataLength = getUint32$1(view, indexByte + 12);
5904
+ const directoryDataOffset = getUint32$1(view, indexByte + 16);
5799
5905
  if (filesLength == MAX_16_BITS || directoryDataLength == MAX_32_BITS || directoryDataOffset == MAX_32_BITS) {
5800
5906
  const locatorSignature = await readSignature(reader, view, anchoredOffset, offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, size, remoteProbeBudget);
5801
5907
  return locatorSignature == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE ? CENTRAL_DIRECTORY_REACHABLE : CENTRAL_DIRECTORY_UNREACHABLE;
@@ -5803,7 +5909,7 @@
5803
5909
  if (!filesLength && !directoryDataLength) {
5804
5910
  return CENTRAL_DIRECTORY_PLAUSIBLE;
5805
5911
  }
5806
- const directoryDiskNumber = getUint16(view, indexByte + 6);
5912
+ const directoryDiskNumber = getUint16$1(view, indexByte + 6);
5807
5913
  for (const centralDirectoryOffset of [offset - directoryDataLength, getDiskOffset$1(reader, directoryDiskNumber) + directoryDataOffset]) {
5808
5914
  if (await readSignature(reader, view, anchoredOffset, centralDirectoryOffset, size, remoteProbeBudget) == CENTRAL_FILE_HEADER_SIGNATURE) {
5809
5915
  return CENTRAL_DIRECTORY_REACHABLE;
@@ -5817,12 +5923,12 @@
5817
5923
  return UNDEFINED_VALUE;
5818
5924
  }
5819
5925
  if (signatureOffset >= anchoredOffset) {
5820
- return getUint32(view, signatureOffset - anchoredOffset);
5926
+ return getUint32$1(view, signatureOffset - anchoredOffset);
5821
5927
  }
5822
5928
  if (remoteProbeBudget.count > 0) {
5823
5929
  remoteProbeBudget.count--;
5824
5930
  const signatureArray = await readUint8Array(reader, signatureOffset, 4);
5825
- return getUint32(getDataView(signatureArray), 0);
5931
+ return getUint32$1(getDataView(signatureArray), 0);
5826
5932
  }
5827
5933
  return UNDEFINED_VALUE;
5828
5934
  }
@@ -5859,10 +5965,11 @@
5859
5965
  return options[name] === UNDEFINED_VALUE ? zipReader.options[name] : options[name];
5860
5966
  }
5861
5967
 
5862
- function toNumber$1(value) {
5863
- return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
5968
+ function getFunctionOptionValue$1(zipReader, options, name) {
5969
+ return checkFunctionOption(getOptionValue$1(zipReader, options, name));
5864
5970
  }
5865
5971
 
5972
+
5866
5973
  function getDate(timeRaw) {
5867
5974
  const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS;
5868
5975
  return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
@@ -5876,11 +5983,11 @@
5876
5983
  return view.getUint8(offset);
5877
5984
  }
5878
5985
 
5879
- function getUint16(view, offset) {
5986
+ function getUint16$1(view, offset) {
5880
5987
  return view.getUint16(offset, true);
5881
5988
  }
5882
5989
 
5883
- function getUint32(view, offset) {
5990
+ function getUint32$1(view, offset) {
5884
5991
  return view.getUint32(offset, true);
5885
5992
  }
5886
5993
 
@@ -5895,6 +6002,7 @@
5895
6002
  ERR_CENTRAL_DIRECTORY_NOT_FOUND: ERR_CENTRAL_DIRECTORY_NOT_FOUND,
5896
6003
  ERR_ENCRYPTED: ERR_ENCRYPTED,
5897
6004
  ERR_ENCRYPTED_CENTRAL_DIRECTORY: ERR_ENCRYPTED_CENTRAL_DIRECTORY,
6005
+ ERR_ENTRY_DATA_OUT_OF_BOUNDS: ERR_ENTRY_DATA_OUT_OF_BOUNDS,
5898
6006
  ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND,
5899
6007
  ERR_EOCDR_NOT_FOUND: ERR_EOCDR_NOT_FOUND,
5900
6008
  ERR_EXTRAFIELD_ZIP64_NOT_FOUND: ERR_EXTRAFIELD_ZIP64_NOT_FOUND,
@@ -5951,12 +6059,16 @@
5951
6059
  const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
5952
6060
  const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
5953
6061
  const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
6062
+ const ERR_INVALID_ENTRY_COMMENT_TYPE = "Invalid file entry comment (must be a string)";
6063
+ const ERR_INVALID_DATE = "Invalid date (must be a valid Date instance)";
5954
6064
  const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
5955
6065
  const ERR_INVALID_VERSION = "Version exceeds 65535";
5956
6066
  const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
5957
6067
  const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
5958
6068
  const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
5959
- const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
6069
+ const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
6070
+ const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
6071
+ const ERR_INVALID_EXTRAFIELD_DATA_TYPE = "Invalid extra field data (must be a Uint8Array)";
5960
6072
  const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
5961
6073
  const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
5962
6074
  const MIN_UNIX_TIME = -2147483648;
@@ -5976,7 +6088,6 @@
5976
6088
  const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be integer 0..255)";
5977
6089
  const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
5978
6090
  const ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
5979
- const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
5980
6091
  const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
5981
6092
 
5982
6093
  const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
@@ -6001,8 +6112,7 @@
6001
6112
  writer,
6002
6113
  addSplitZipSignature,
6003
6114
  options,
6004
- config: getConfiguration(),
6005
- files: new Map(),
6115
+ fileEntries: new Map(),
6006
6116
  filenames: new Set(),
6007
6117
  offset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? writer.size || writer.writable.size || 0 : options[OPTION_OFFSET],
6008
6118
  initialOffset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : options[OPTION_OFFSET] - (writer.size || writer.writable.size || 0),
@@ -6023,14 +6133,23 @@
6023
6133
  await initStream(reader);
6024
6134
  }
6025
6135
  const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
6026
- const zipReader$1 = new ZipReader(reader.readable);
6136
+ const zipReader$1 = new ZipReader(reader);
6027
6137
  const entries = await zipReader$1.getEntries();
6028
6138
  await zipReader$1.close();
6029
6139
  await initStream(this.writer);
6030
- await reader.readable.pipeTo(this.writer.writable, { preventClose: true, preventAbort: true });
6031
- this.writer.size = this.offset = reader.size;
6140
+ const { directoryOffset } = zipReader$1;
6141
+ let splitZipSignatureLength = 0;
6142
+ if (this.addSplitZipSignature) {
6143
+ delete this.addSplitZipSignature;
6144
+ if (!await startsWithSplitZipSignature(reader)) {
6145
+ await writeData(this.writer, getSplitZipSignatureArray());
6146
+ splitZipSignatureLength = SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
6147
+ this.offset += splitZipSignatureLength;
6148
+ }
6149
+ }
6150
+ const entryPositions = await copyZipData(this, reader, entries, directoryOffset, splitZipSignatureLength);
6032
6151
  this.filenames = new Set(entries.map(entry => entry.filename));
6033
- this.files = new Map(entries.map(entry => {
6152
+ this.fileEntries = new Map(entries.map(entry => {
6034
6153
  const {
6035
6154
  version,
6036
6155
  rawLastModDate,
@@ -6085,11 +6204,12 @@
6085
6204
  if (crc32 !== UNDEFINED_VALUE) {
6086
6205
  setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
6087
6206
  }
6207
+ const { offset, diskNumberStart } = entryPositions.get(entry);
6088
6208
  Object.assign(entry, {
6089
6209
  zip64UncompressedSize,
6090
6210
  zip64CompressedSize,
6091
- zip64Offset: zip64 && entry.offset >= MAX_32_BITS,
6092
- diskNumberStart: 0,
6211
+ offset,
6212
+ diskNumberStart,
6093
6213
  zip64DiskNumberStart: false,
6094
6214
  rawExtraFieldZip64,
6095
6215
  rawExtraFieldAES,
@@ -6109,11 +6229,8 @@
6109
6229
  async add(name = "", reader, options = {}) {
6110
6230
  const zipWriter = this;
6111
6231
  options = Object.assign({}, options);
6112
- const {
6113
- pendingAddFileCalls,
6114
- config
6115
- } = zipWriter;
6116
- if (workers < config.maxWorkers) {
6232
+ const { pendingAddFileCalls } = zipWriter;
6233
+ if (workers < getConfiguration().maxWorkers) {
6117
6234
  workers++;
6118
6235
  } else {
6119
6236
  await new Promise(resolve => pendingEntries.push(resolve));
@@ -6150,16 +6267,16 @@
6150
6267
  }
6151
6268
 
6152
6269
  remove(entry) {
6153
- const { filenames, files } = this;
6270
+ const { filenames, fileEntries } = this;
6154
6271
  // deno-lint-ignore valid-typeof
6155
6272
  if (typeof entry == STRING_TYPE) {
6156
- entry = files.get(entry);
6273
+ entry = fileEntries.get(entry);
6157
6274
  }
6158
6275
  if (entry && entry.filename !== UNDEFINED_VALUE) {
6159
6276
  const { filename } = entry;
6160
- if (filenames.has(filename) && files.has(filename)) {
6277
+ if (filenames.has(filename) && fileEntries.has(filename)) {
6161
6278
  filenames.delete(filename);
6162
- files.delete(filename);
6279
+ fileEntries.delete(filename);
6163
6280
  return true;
6164
6281
  }
6165
6282
  }
@@ -6256,12 +6373,12 @@
6256
6373
  const metadataInfo = resolveMetadata(zipWriter, name, options);
6257
6374
  const { comment } = metadataInfo;
6258
6375
  const extraField = options[PROPERTY_NAME_EXTRA_FIELD];
6259
- zipWriter.files.set(name, UNDEFINED_VALUE);
6376
+ zipWriter.fileEntries.set(name, UNDEFINED_VALUE);
6260
6377
  let fileEntry;
6261
6378
  try {
6262
6379
  const { resolvedOptions } = metadataInfo;
6263
6380
  if (resolvedOptions.level != 0 && resolvedOptions.compressionMethod === UNDEFINED_VALUE &&
6264
- !resolvedOptions.passThrough && !(await supportsDeflate(zipWriter.config))) {
6381
+ !resolvedOptions.passThrough && !(await supportsDeflate(getConfiguration()))) {
6265
6382
  resolvedOptions.level = 0;
6266
6383
  }
6267
6384
  const sizesInfo = await resolveSizes(zipWriter, reader, metadataInfo, options);
@@ -6279,7 +6396,7 @@
6279
6396
  const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
6280
6397
  fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo, metadataSize }, options);
6281
6398
  } catch (error) {
6282
- zipWriter.files.delete(name);
6399
+ zipWriter.fileEntries.delete(name);
6283
6400
  throw error;
6284
6401
  }
6285
6402
  Object.assign(fileEntry, {
@@ -6323,9 +6440,9 @@
6323
6440
  if (unixExtraFieldType === UNDEFINED_VALUE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
6324
6441
  unixExtraFieldType = INFOZIP_EXTRA_FIELD_TYPE;
6325
6442
  }
6326
- let msdosAttributesRaw = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
6443
+ let msdosAttributesRaw = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
6327
6444
  let msdosAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES);
6328
- const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType;
6445
+ const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType || executable;
6329
6446
  const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
6330
6447
  if (hasUnixMetadata) {
6331
6448
  msDosCompatible = false;
@@ -6334,10 +6451,10 @@
6334
6451
  msDosCompatible = true;
6335
6452
  versionMadeBy = (versionMadeBy & MAX_8_BITS);
6336
6453
  }
6337
- if (msdosAttributesRaw !== UNDEFINED_VALUE && (msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
6454
+ if (msdosAttributesRaw !== UNDEFINED_VALUE && (!Number.isInteger(msdosAttributesRaw) || msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
6338
6455
  throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
6339
6456
  }
6340
- if (msdosAttributes && typeof msdosAttributes !== OBJECT_TYPE) {
6457
+ if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
6341
6458
  throw new Error(ERR_INVALID_MSDOS_DATA);
6342
6459
  }
6343
6460
  if (versionMadeBy > MAX_16_BITS) {
@@ -6425,7 +6542,7 @@
6425
6542
  }
6426
6543
 
6427
6544
  function resolveMetadata(zipWriter, name, options) {
6428
- const encode = getOptionValue(zipWriter, options, OPTION_ENCODE_TEXT, encodeText);
6545
+ const encode = getFunctionOptionValue(zipWriter, options, OPTION_ENCODE_TEXT) || encodeText;
6429
6546
  let rawFilename = encode(name, TEXT_TYPE_FILENAME);
6430
6547
  if (rawFilename === UNDEFINED_VALUE) {
6431
6548
  rawFilename = encodeText(name);
@@ -6434,6 +6551,10 @@
6434
6551
  throw new Error(ERR_INVALID_ENTRY_NAME);
6435
6552
  }
6436
6553
  const comment = options[PROPERTY_NAME_COMMENT] || "";
6554
+ // deno-lint-ignore valid-typeof
6555
+ if (typeof comment != STRING_TYPE) {
6556
+ throw new Error(ERR_INVALID_ENTRY_COMMENT_TYPE);
6557
+ }
6437
6558
  let rawComment = encode(comment, TEXT_TYPE_COMMENT);
6438
6559
  if (rawComment === UNDEFINED_VALUE) {
6439
6560
  rawComment = encodeText(comment);
@@ -6445,16 +6566,14 @@
6445
6566
  if (version > MAX_16_BITS) {
6446
6567
  throw new Error(ERR_INVALID_VERSION);
6447
6568
  }
6448
- const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
6449
- const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
6450
- const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
6569
+ const lastModDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
6570
+ const lastAccessDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
6571
+ const creationDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
6451
6572
  const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
6452
6573
  const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
6453
6574
  const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
6454
6575
  const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
6455
- if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
6456
- throw new Error(ERR_INVALID_PASSWORD_TYPE);
6457
- }
6576
+ checkPasswordOption(password, rawPassword);
6458
6577
  const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
6459
6578
  const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
6460
6579
  const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
@@ -6463,9 +6582,9 @@
6463
6582
  const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
6464
6583
  const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS);
6465
6584
  const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
6466
- const createTempStream = getOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
6585
+ const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
6467
6586
  const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
6468
- const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
6587
+ const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
6469
6588
  const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
6470
6589
  const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
6471
6590
  const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
@@ -6545,18 +6664,26 @@
6545
6664
  if (!extraField) {
6546
6665
  return EMPTY_UINT8_ARRAY;
6547
6666
  }
6667
+ if (!(extraField instanceof Map)) {
6668
+ throw new Error(ERR_INVALID_EXTRAFIELD);
6669
+ }
6548
6670
  let extraFieldSize = 0;
6549
6671
  let offset = 0;
6550
- extraField.forEach(data => extraFieldSize += 4 + getLength(data));
6551
- const rawExtraField = new Uint8Array(extraFieldSize);
6552
- const rawExtraFieldView = getDataView(rawExtraField);
6553
6672
  extraField.forEach((data, type) => {
6554
- if (type > MAX_16_BITS) {
6673
+ if (!Number.isInteger(type) || type < 0 || type > MAX_16_BITS) {
6555
6674
  throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
6556
6675
  }
6676
+ if (!(data instanceof Uint8Array)) {
6677
+ throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
6678
+ }
6557
6679
  if (getLength(data) > MAX_16_BITS) {
6558
6680
  throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
6559
6681
  }
6682
+ extraFieldSize += 4 + getLength(data);
6683
+ });
6684
+ const rawExtraField = new Uint8Array(extraFieldSize);
6685
+ const rawExtraFieldView = getDataView(rawExtraField);
6686
+ extraField.forEach((data, type) => {
6560
6687
  setUint16(rawExtraFieldView, offset, type);
6561
6688
  setUint16(rawExtraFieldView, offset + 2, getLength(data));
6562
6689
  arraySet(rawExtraField, data, offset + 4);
@@ -6644,7 +6771,7 @@
6644
6771
 
6645
6772
  async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6646
6773
  const {
6647
- files,
6774
+ fileEntries,
6648
6775
  writer
6649
6776
  } = zipWriter;
6650
6777
  const {
@@ -6666,12 +6793,12 @@
6666
6793
  let writerSizeBeforeEntry;
6667
6794
  let flushedBufferedSize = 0;
6668
6795
  let fileWriter;
6669
- files.set(name, fileEntry);
6796
+ fileEntries.set(name, fileEntry);
6670
6797
  zipWriter.lastFileEntry = fileEntry;
6671
6798
  try {
6672
6799
  let lockPreviousFileEntry;
6673
6800
  if (keepOrder) {
6674
- lockPreviousFileEntry = previousFileEntry && previousFileEntry.lock;
6801
+ lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
6675
6802
  requestLockCurrentFileEntry();
6676
6803
  }
6677
6804
  if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
@@ -6692,11 +6819,8 @@
6692
6819
  const diskOffset = getDiskOffset(writer);
6693
6820
  if (zipWriter.addSplitZipSignature) {
6694
6821
  delete zipWriter.addSplitZipSignature;
6695
- const signatureArray = new Uint8Array(4);
6696
- const signatureArrayView = getDataView(signatureArray);
6697
- setUint32(signatureArrayView, 0, SPLIT_ZIP_FILE_SIGNATURE);
6698
- await writeData(writer, signatureArray);
6699
- zipWriter.offset += 4;
6822
+ await writeData(writer, getSplitZipSignatureArray());
6823
+ zipWriter.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
6700
6824
  }
6701
6825
  if (usdz && !bufferedWrite) {
6702
6826
  appendExtraFieldUSDZ(entryInfo, zipWriter.offset - diskOffset);
@@ -6714,11 +6838,11 @@
6714
6838
  writerSizeBeforeEntry = writer.size;
6715
6839
  await writeData(fileWriter, localHeaderArray);
6716
6840
  }
6717
- fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, zipWriter.config, options);
6841
+ fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, getConfiguration(), options);
6718
6842
  if (!bufferedWrite) {
6719
6843
  writingEntryData = false;
6720
6844
  }
6721
- files.set(name, fileEntry);
6845
+ fileEntries.set(name, fileEntry);
6722
6846
  fileEntry.filename = name;
6723
6847
  if (bufferedWrite) {
6724
6848
  await Promise.all([fileWriter.writable.getWriter().close(), lockPreviousFileEntry]);
@@ -6759,7 +6883,7 @@
6759
6883
  zipWriter.offset += flushedBufferedSize;
6760
6884
  }
6761
6885
  }
6762
- files.delete(name);
6886
+ fileEntries.delete(name);
6763
6887
  throw error;
6764
6888
  } finally {
6765
6889
  if (bufferedWrite) {
@@ -6781,7 +6905,7 @@
6781
6905
  }
6782
6906
 
6783
6907
  function requestLockCurrentFileEntry() {
6784
- fileEntry.lock = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
6908
+ fileEntry.lockFileEntry = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
6785
6909
  }
6786
6910
 
6787
6911
  async function requestLockWriter() {
@@ -6801,7 +6925,7 @@
6801
6925
  }
6802
6926
  }
6803
6927
 
6804
- async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryInfo, config, options) {
6928
+ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry }, entryInfo, config, options) {
6805
6929
  const {
6806
6930
  headerInfo,
6807
6931
  dataDescriptorInfo,
@@ -6869,7 +6993,7 @@
6869
6993
  codecURI
6870
6994
  } = options;
6871
6995
  const fileEntry = {
6872
- lock,
6996
+ lockFileEntry,
6873
6997
  versionMadeBy,
6874
6998
  zip64,
6875
6999
  directory: Boolean(directory),
@@ -6911,7 +7035,7 @@
6911
7035
  }
6912
7036
  const { writable } = writer;
6913
7037
  if (reader) {
6914
- const readable = toCompatibleReadable(reader.createReadable ? reader.createReadable() : reader.readable);
7038
+ const readable = toCompatibleReadable(createReadable(reader));
6915
7039
  const size = reader.size;
6916
7040
  const workerOptions = {
6917
7041
  options: {
@@ -7023,14 +7147,14 @@
7023
7147
  if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
7024
7148
  const length = 4 + 16;
7025
7149
  const extraFieldZip64 = createRecordWriter(length);
7026
- extraFieldZip64.uint16(EXTRAFIELD_TYPE_ZIP64);
7027
- extraFieldZip64.uint16(length - 4);
7150
+ extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
7151
+ extraFieldZip64.writeUint16(length - 4);
7028
7152
  rawLocalExtraFieldZip64 = extraFieldZip64.array;
7029
7153
  if (zip64ExtraFieldComplete) {
7030
- extraFieldZip64.uint64(uncompressedSize);
7154
+ extraFieldZip64.writeUint64(uncompressedSize);
7031
7155
  if (uncompressedFile) {
7032
7156
  const encryptionOverhead = encrypted ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
7033
- extraFieldZip64.uint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
7157
+ extraFieldZip64.writeUint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
7034
7158
  }
7035
7159
  }
7036
7160
  } else {
@@ -7039,8 +7163,8 @@
7039
7163
  let rawExtraFieldAES;
7040
7164
  if (encrypted && !zipCrypto) {
7041
7165
  const extraFieldAES = createRecordWriter(getLength(EXTRAFIELD_DATA_AES) + 2);
7042
- extraFieldAES.uint16(EXTRAFIELD_TYPE_AES);
7043
- extraFieldAES.bytes(EXTRAFIELD_DATA_AES);
7166
+ extraFieldAES.writeUint16(EXTRAFIELD_TYPE_AES);
7167
+ extraFieldAES.writeBytes(EXTRAFIELD_DATA_AES);
7044
7168
  rawExtraFieldAES = extraFieldAES.array;
7045
7169
  rawExtraFieldAES[8] = encryptionStrength;
7046
7170
  } else {
@@ -7056,15 +7180,15 @@
7056
7180
  const extraFieldTimestampLength = 9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0);
7057
7181
  const extraFieldTimestamp = createRecordWriter(extraFieldTimestampLength);
7058
7182
  extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
7059
- extraFieldTimestamp.uint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7060
- extraFieldTimestamp.uint16(extraFieldTimestampLength - 4);
7061
- extraFieldTimestamp.uint8(extraFieldExtendedTimestampFlag);
7062
- extraFieldTimestamp.uint32(lastModTimeUnix);
7183
+ extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7184
+ extraFieldTimestamp.writeUint16(extraFieldTimestampLength - 4);
7185
+ extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
7186
+ extraFieldTimestamp.writeUint32(lastModTimeUnix);
7063
7187
  if (lastAccessDate) {
7064
- extraFieldTimestamp.uint32(clampUnixTime(getTimeUnix(lastAccessDate)));
7188
+ extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(lastAccessDate)));
7065
7189
  }
7066
7190
  if (creationDate) {
7067
- extraFieldTimestamp.uint32(clampUnixTime(getTimeUnix(creationDate)));
7191
+ extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(creationDate)));
7068
7192
  }
7069
7193
  rawExtraFieldExtendedTimestamp = extraFieldTimestamp.array;
7070
7194
  } else {
@@ -7077,14 +7201,14 @@
7077
7201
  try {
7078
7202
  const lastModTimeNTFS = getTimeNTFS(lastModDate);
7079
7203
  const extraFieldNTFS = createRecordWriter(36);
7080
- extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS);
7081
- extraFieldNTFS.uint16(32);
7204
+ extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS);
7205
+ extraFieldNTFS.writeUint16(32);
7082
7206
  extraFieldNTFS.skip(4);
7083
- extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS_TAG1);
7084
- extraFieldNTFS.uint16(24);
7085
- extraFieldNTFS.uint64(lastModTimeNTFS);
7086
- extraFieldNTFS.uint64(lastAccessDate ? getTimeNTFS(lastAccessDate) : lastModTimeNTFS);
7087
- extraFieldNTFS.uint64(creationDate ? getTimeNTFS(creationDate) : lastModTimeNTFS);
7207
+ extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS_TAG1);
7208
+ extraFieldNTFS.writeUint16(24);
7209
+ extraFieldNTFS.writeUint64(lastModTimeNTFS);
7210
+ extraFieldNTFS.writeUint64(lastAccessDate ? getTimeNTFS(lastAccessDate) : lastModTimeNTFS);
7211
+ extraFieldNTFS.writeUint64(creationDate ? getTimeNTFS(creationDate) : lastModTimeNTFS);
7088
7212
  rawExtraFieldNTFS = extraFieldNTFS.array;
7089
7213
  } catch {
7090
7214
  rawExtraFieldNTFS = EMPTY_UINT8_ARRAY;
@@ -7103,20 +7227,20 @@
7103
7227
  const gidBytes = packUnixId(gid);
7104
7228
  const payloadLength = 3 + uidBytes.length + gidBytes.length;
7105
7229
  const extraFieldUnix = createRecordWriter(4 + payloadLength);
7106
- extraFieldUnix.uint16(EXTRAFIELD_TYPE_INFOZIP);
7107
- extraFieldUnix.uint16(payloadLength);
7108
- extraFieldUnix.uint8(1);
7109
- extraFieldUnix.uint8(uidBytes.length);
7110
- extraFieldUnix.bytes(uidBytes);
7111
- extraFieldUnix.uint8(gidBytes.length);
7112
- extraFieldUnix.bytes(gidBytes);
7230
+ extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
7231
+ extraFieldUnix.writeUint16(payloadLength);
7232
+ extraFieldUnix.writeUint8(1);
7233
+ extraFieldUnix.writeUint8(uidBytes.length);
7234
+ extraFieldUnix.writeBytes(uidBytes);
7235
+ extraFieldUnix.writeUint8(gidBytes.length);
7236
+ extraFieldUnix.writeBytes(gidBytes);
7113
7237
  rawExtraFieldUnix = extraFieldUnix.array;
7114
7238
  } else if (unixExtraFieldType == UNIX_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
7115
7239
  const extraFieldUnix = createRecordWriter(8);
7116
- extraFieldUnix.uint16(EXTRAFIELD_TYPE_UNIX);
7117
- extraFieldUnix.uint16(4);
7118
- extraFieldUnix.uint16((uid === UNDEFINED_VALUE ? 0 : uid) & MAX_16_BITS);
7119
- extraFieldUnix.uint16((gid === UNDEFINED_VALUE ? 0 : gid) & MAX_16_BITS);
7240
+ extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_UNIX);
7241
+ extraFieldUnix.writeUint16(4);
7242
+ extraFieldUnix.writeUint16((uid === UNDEFINED_VALUE ? 0 : uid) & MAX_16_BITS);
7243
+ extraFieldUnix.writeUint16((gid === UNDEFINED_VALUE ? 0 : gid) & MAX_16_BITS);
7120
7244
  rawExtraFieldUnix = extraFieldUnix.array;
7121
7245
  } else {
7122
7246
  rawExtraFieldUnix = EMPTY_UINT8_ARRAY;
@@ -7166,18 +7290,18 @@
7166
7290
  const localHeader = createRecordWriter(HEADER_SIZE + getLength(rawFilename) + extraFieldLength);
7167
7291
  const localHeaderArray = localHeader.array;
7168
7292
  const localHeaderView = getDataView(localHeaderArray);
7169
- localHeader.uint32(LOCAL_FILE_HEADER_SIGNATURE);
7170
- localHeader.bytes(headerArray);
7171
- localHeader.bytes(rawFilename);
7293
+ localHeader.writeUint32(LOCAL_FILE_HEADER_SIGNATURE);
7294
+ localHeader.writeBytes(headerArray);
7295
+ localHeader.writeBytes(rawFilename);
7172
7296
  if (writeLocalExtraFieldZip64) {
7173
- localHeader.bytes(rawLocalExtraFieldZip64);
7174
- }
7175
- localHeader.bytes(rawExtraFieldAES);
7176
- localHeader.bytes(rawExtraFieldExtendedTimestamp);
7177
- localHeader.bytes(rawExtraFieldNTFS);
7178
- localHeader.bytes(rawExtraFieldUnix);
7179
- localHeader.bytes(rawExtraField);
7180
- localHeader.bytes(rawLocalExtraField);
7297
+ localHeader.writeBytes(rawLocalExtraFieldZip64);
7298
+ }
7299
+ localHeader.writeBytes(rawExtraFieldAES);
7300
+ localHeader.writeBytes(rawExtraFieldExtendedTimestamp);
7301
+ localHeader.writeBytes(rawExtraFieldNTFS);
7302
+ localHeader.writeBytes(rawExtraFieldUnix);
7303
+ localHeader.writeBytes(rawExtraField);
7304
+ localHeader.writeBytes(rawLocalExtraField);
7181
7305
  if (dataDescriptor) {
7182
7306
  if (!zip64CompressedSize) {
7183
7307
  setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + LOCAL_HEADER_COMMON_OFFSET, 0);
@@ -7367,7 +7491,7 @@
7367
7491
 
7368
7492
 
7369
7493
  async function closeFile(zipWriter, comment, options) {
7370
- const directoryDataLength = createDirectoryRecords(zipWriter.files);
7494
+ const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
7371
7495
  const { directoryStart, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
7372
7496
  const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
7373
7497
  await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryDataLength, signatureLength });
@@ -7397,19 +7521,19 @@
7397
7521
  if (zip64Offset || zip64DiskNumberStart || zip64UncompressedSize || zip64CompressedSize) {
7398
7522
  const length = 4 + (zip64UncompressedSize ? 8 : 0) + (zip64CompressedSize ? 8 : 0) + (zip64Offset ? 8 : 0) + (zip64DiskNumberStart ? 4 : 0);
7399
7523
  const extraFieldZip64 = createRecordWriter(length);
7400
- extraFieldZip64.uint16(EXTRAFIELD_TYPE_ZIP64);
7401
- extraFieldZip64.uint16(length - 4);
7524
+ extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
7525
+ extraFieldZip64.writeUint16(length - 4);
7402
7526
  if (zip64UncompressedSize) {
7403
- extraFieldZip64.uint64(uncompressedSize);
7527
+ extraFieldZip64.writeUint64(uncompressedSize);
7404
7528
  }
7405
7529
  if (zip64CompressedSize) {
7406
- extraFieldZip64.uint64(compressedSize);
7530
+ extraFieldZip64.writeUint64(compressedSize);
7407
7531
  }
7408
7532
  if (zip64Offset) {
7409
- extraFieldZip64.uint64(fileEntry.offset);
7533
+ extraFieldZip64.writeUint64(fileEntry.offset);
7410
7534
  }
7411
7535
  if (zip64DiskNumberStart) {
7412
- extraFieldZip64.uint32(fileEntry.diskNumberStart);
7536
+ extraFieldZip64.writeUint32(fileEntry.diskNumberStart);
7413
7537
  }
7414
7538
  rawExtraFieldZip64 = extraFieldZip64.array;
7415
7539
  } else {
@@ -7422,10 +7546,10 @@
7422
7546
  const lastModTimeUnix = getTimeUnix(lastModDate);
7423
7547
  if (extendedTimestamp && inUnixTimeRange(lastModTimeUnix)) {
7424
7548
  const extraFieldTimestamp = createRecordWriter(9);
7425
- extraFieldTimestamp.uint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7426
- extraFieldTimestamp.uint16(5);
7427
- extraFieldTimestamp.uint8(extraFieldExtendedTimestampFlag);
7428
- extraFieldTimestamp.uint32(lastModTimeUnix);
7549
+ extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7550
+ extraFieldTimestamp.writeUint16(5);
7551
+ extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
7552
+ extraFieldTimestamp.writeUint32(lastModTimeUnix);
7429
7553
  rawExtraFieldTimestamp = extraFieldTimestamp.array;
7430
7554
  } else {
7431
7555
  rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
@@ -7447,14 +7571,14 @@
7447
7571
  }
7448
7572
 
7449
7573
  async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
7450
- const { files, writer } = zipWriter;
7574
+ const { fileEntries, writer } = zipWriter;
7451
7575
  const directoryArray = new Uint8Array(directoryDataLength);
7452
7576
  await initStream(writer);
7453
7577
  let offset = 0;
7454
7578
  let directoryDiskOffset = 0;
7455
7579
  let directoryStartDiskNumber = getDiskNumber(writer);
7456
7580
  let directoryStartDiskOffset = getDiskOffset(writer);
7457
- for (const [indexFileEntry, fileEntry] of Array.from(files.values()).entries()) {
7581
+ for (const [indexFileEntry, fileEntry] of Array.from(fileEntries.values()).entries()) {
7458
7582
  const {
7459
7583
  offset: fileEntryOffset,
7460
7584
  rawFilename,
@@ -7499,28 +7623,28 @@
7499
7623
  setUint16(headerView, HEADER_OFFSET_VERSION, VERSION_ZIP64);
7500
7624
  }
7501
7625
  const directoryRecord = createRecordWriter(directoryRecordLength);
7502
- directoryRecord.uint32(CENTRAL_FILE_HEADER_SIGNATURE);
7503
- directoryRecord.uint16(versionMadeBy);
7504
- directoryRecord.bytes(headerArray.subarray(0, HEADER_SIZE - 4 - 2));
7505
- directoryRecord.uint16(extraFieldLength);
7506
- directoryRecord.uint16(getLength(rawComment));
7507
- directoryRecord.uint16(zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
7508
- directoryRecord.uint16(internalFileAttributes);
7509
- directoryRecord.uint32(externalFileAttributes);
7510
- directoryRecord.uint32(zip64Offset ? MAX_32_BITS : fileEntryOffset);
7511
- directoryRecord.bytes(rawFilename);
7512
- directoryRecord.bytes(rawExtraFieldZip64);
7513
- directoryRecord.bytes(rawExtraFieldAES);
7514
- directoryRecord.bytes(rawExtraFieldExtendedTimestamp);
7515
- directoryRecord.bytes(rawExtraFieldNTFS);
7516
- directoryRecord.bytes(rawExtraFieldUnix);
7517
- directoryRecord.bytes(rawExtraField);
7518
- directoryRecord.bytes(rawComment);
7626
+ directoryRecord.writeUint32(CENTRAL_FILE_HEADER_SIGNATURE);
7627
+ directoryRecord.writeUint16(versionMadeBy);
7628
+ directoryRecord.writeBytes(headerArray.subarray(0, HEADER_SIZE - 4 - 2));
7629
+ directoryRecord.writeUint16(extraFieldLength);
7630
+ directoryRecord.writeUint16(getLength(rawComment));
7631
+ directoryRecord.writeUint16(zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
7632
+ directoryRecord.writeUint16(internalFileAttributes);
7633
+ directoryRecord.writeUint32(externalFileAttributes);
7634
+ directoryRecord.writeUint32(zip64Offset ? MAX_32_BITS : fileEntryOffset);
7635
+ directoryRecord.writeBytes(rawFilename);
7636
+ directoryRecord.writeBytes(rawExtraFieldZip64);
7637
+ directoryRecord.writeBytes(rawExtraFieldAES);
7638
+ directoryRecord.writeBytes(rawExtraFieldExtendedTimestamp);
7639
+ directoryRecord.writeBytes(rawExtraFieldNTFS);
7640
+ directoryRecord.writeBytes(rawExtraFieldUnix);
7641
+ directoryRecord.writeBytes(rawExtraField);
7642
+ directoryRecord.writeBytes(rawComment);
7519
7643
  arraySet(directoryArray, directoryRecord.array, offset);
7520
7644
  offset += directoryRecordLength;
7521
7645
  if (options.onprogress) {
7522
7646
  try {
7523
- await options.onprogress(indexFileEntry + 1, files.size, new Entry(fileEntry));
7647
+ await options.onprogress(indexFileEntry + 1, fileEntries.size, new Entry(fileEntry));
7524
7648
  } catch {
7525
7649
  // ignored
7526
7650
  }
@@ -7534,7 +7658,7 @@
7534
7658
  }
7535
7659
 
7536
7660
  async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
7537
- const signCentralDirectory = getOptionValue(zipWriter, options, OPTION_SIGN_CENTRAL_DIRECTORY);
7661
+ const signCentralDirectory = getFunctionOptionValue(zipWriter, options, OPTION_SIGN_CENTRAL_DIRECTORY);
7538
7662
  if (signCentralDirectory) {
7539
7663
  const signatureData = await signCentralDirectory(directoryArray);
7540
7664
  const signatureDataLength = getLength(signatureData);
@@ -7542,9 +7666,9 @@
7542
7666
  throw new Error(ERR_INVALID_SIGNATURE_DATA);
7543
7667
  }
7544
7668
  const signatureRecord = createRecordWriter(6 + signatureDataLength);
7545
- signatureRecord.uint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
7546
- signatureRecord.uint16(signatureDataLength);
7547
- signatureRecord.bytes(signatureData);
7669
+ signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
7670
+ signatureRecord.writeUint16(signatureDataLength);
7671
+ signatureRecord.writeBytes(signatureData);
7548
7672
  await writeData(zipWriter.writer, signatureRecord.array);
7549
7673
  return 6 + signatureDataLength;
7550
7674
  }
@@ -7555,7 +7679,7 @@
7555
7679
  const { writer } = zipWriter;
7556
7680
  const { directoryStart, signatureLength } = cdInfo;
7557
7681
  let { directoryDataLength } = cdInfo;
7558
- let filesLength = zipWriter.files.size;
7682
+ let fileEntriesLength = zipWriter.fileEntries.size;
7559
7683
  let diskNumber = directoryStart.diskNumber;
7560
7684
  let directoryOffset = getSegmentOffset(zipWriter, directoryStart);
7561
7685
  let lastDiskNumber = getDiskNumber(writer);
@@ -7563,7 +7687,7 @@
7563
7687
  lastDiskNumber++;
7564
7688
  }
7565
7689
  let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
7566
- if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS || lastDiskNumber >= MAX_16_BITS) {
7690
+ if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || fileEntriesLength >= MAX_16_BITS || lastDiskNumber >= MAX_16_BITS) {
7567
7691
  if (zip64 === false) {
7568
7692
  throw new Error(ERR_UNSUPPORTED_FORMAT);
7569
7693
  } else {
@@ -7580,37 +7704,37 @@
7580
7704
  }
7581
7705
  lastDiskNumber = getDiskNumber(writer);
7582
7706
  if (zip64) {
7583
- endOfdirectoryRecord.uint32(ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
7584
- endOfdirectoryRecord.uint64(44);
7585
- endOfdirectoryRecord.uint16(45);
7586
- endOfdirectoryRecord.uint16(45);
7587
- endOfdirectoryRecord.uint32(lastDiskNumber);
7588
- endOfdirectoryRecord.uint32(diskNumber);
7589
- endOfdirectoryRecord.uint64(filesLength);
7590
- endOfdirectoryRecord.uint64(filesLength);
7591
- endOfdirectoryRecord.uint64(directoryDataLength);
7592
- endOfdirectoryRecord.uint64(directoryOffset);
7593
- endOfdirectoryRecord.uint32(ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
7594
- endOfdirectoryRecord.uint32(lastDiskNumber);
7595
- endOfdirectoryRecord.uint64(BigInt(getSegmentOffset(zipWriter, writer)) + BigInt(directoryDataLength) + BigInt(signatureLength));
7596
- endOfdirectoryRecord.uint32(lastDiskNumber + 1);
7707
+ endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
7708
+ endOfdirectoryRecord.writeUint64(44);
7709
+ endOfdirectoryRecord.writeUint16(45);
7710
+ endOfdirectoryRecord.writeUint16(45);
7711
+ endOfdirectoryRecord.writeUint32(lastDiskNumber);
7712
+ endOfdirectoryRecord.writeUint32(diskNumber);
7713
+ endOfdirectoryRecord.writeUint64(fileEntriesLength);
7714
+ endOfdirectoryRecord.writeUint64(fileEntriesLength);
7715
+ endOfdirectoryRecord.writeUint64(directoryDataLength);
7716
+ endOfdirectoryRecord.writeUint64(directoryOffset);
7717
+ endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
7718
+ endOfdirectoryRecord.writeUint32(lastDiskNumber);
7719
+ endOfdirectoryRecord.writeUint64(BigInt(getSegmentOffset(zipWriter, writer)) + BigInt(directoryDataLength) + BigInt(signatureLength));
7720
+ endOfdirectoryRecord.writeUint32(lastDiskNumber + 1);
7597
7721
  const supportZip64SplitFile = getOptionValue(zipWriter, options, OPTION_SUPPORT_ZIP64_SPLIT_FILE, true);
7598
7722
  if (supportZip64SplitFile) {
7599
7723
  lastDiskNumber = MAX_16_BITS;
7600
7724
  diskNumber = MAX_16_BITS;
7601
7725
  }
7602
- filesLength = MAX_16_BITS;
7726
+ fileEntriesLength = MAX_16_BITS;
7603
7727
  directoryOffset = MAX_32_BITS;
7604
7728
  directoryDataLength = MAX_32_BITS;
7605
7729
  }
7606
- endOfdirectoryRecord.uint32(END_OF_CENTRAL_DIR_SIGNATURE);
7607
- endOfdirectoryRecord.uint16(lastDiskNumber);
7608
- endOfdirectoryRecord.uint16(diskNumber);
7609
- endOfdirectoryRecord.uint16(filesLength);
7610
- endOfdirectoryRecord.uint16(filesLength);
7611
- endOfdirectoryRecord.uint32(directoryDataLength);
7612
- endOfdirectoryRecord.uint32(directoryOffset);
7613
- endOfdirectoryRecord.uint16(commentLength);
7730
+ endOfdirectoryRecord.writeUint32(END_OF_CENTRAL_DIR_SIGNATURE);
7731
+ endOfdirectoryRecord.writeUint16(lastDiskNumber);
7732
+ endOfdirectoryRecord.writeUint16(diskNumber);
7733
+ endOfdirectoryRecord.writeUint16(fileEntriesLength);
7734
+ endOfdirectoryRecord.writeUint16(fileEntriesLength);
7735
+ endOfdirectoryRecord.writeUint32(directoryDataLength);
7736
+ endOfdirectoryRecord.writeUint32(directoryOffset);
7737
+ endOfdirectoryRecord.writeUint16(commentLength);
7614
7738
  await writeData(writer, endOfdirectoryRecord.array);
7615
7739
  if (commentLength) {
7616
7740
  await writeData(writer, comment);
@@ -7623,11 +7747,11 @@
7623
7747
  let offset = 0;
7624
7748
  return {
7625
7749
  array,
7626
- uint8: value => { setUint8(view, offset, value); offset += 1; },
7627
- uint16: value => { setUint16(view, offset, value); offset += 2; },
7628
- uint32: value => { setUint32(view, offset, value); offset += 4; },
7629
- uint64: value => { setBigUint64(view, offset, BigInt(value)); offset += 8; },
7630
- bytes: value => { arraySet(array, value, offset); offset += getLength(value); },
7750
+ writeUint8: value => { setUint8(view, offset, value); offset += 1; },
7751
+ writeUint16: value => { setUint16(view, offset, value); offset += 2; },
7752
+ writeUint32: value => { setUint32(view, offset, value); offset += 4; },
7753
+ writeUint64: value => { setBigUint64(view, offset, BigInt(value)); offset += 8; },
7754
+ writeBytes: value => { arraySet(array, value, offset); offset += getLength(value); },
7631
7755
  skip: count => offset += count
7632
7756
  };
7633
7757
  }
@@ -7651,6 +7775,71 @@
7651
7775
  return zipWriter.offset - diskOffset - (diskNumber ? zipWriter.initialOffset : 0);
7652
7776
  }
7653
7777
 
7778
+ async function startsWithSplitZipSignature(reader) {
7779
+ const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
7780
+ return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
7781
+ }
7782
+
7783
+ async function copyZipData(zipWriter, reader, entries, directoryOffset, splitZipSignatureLength) {
7784
+ const { writer } = zipWriter;
7785
+ const entryPositions = new Map();
7786
+ if (writer.closeDisk) {
7787
+ const sortedEntries = Array.from(entries).sort((firstEntry, secondEntry) =>
7788
+ getSourceOffset(reader, firstEntry) - getSourceOffset(reader, secondEntry));
7789
+ let copiedLength = 0;
7790
+ for (const entry of sortedEntries) {
7791
+ const sourceOffset = getSourceOffset(reader, entry);
7792
+ await copyData(zipWriter, reader, copiedLength, sourceOffset - copiedLength);
7793
+ if (exceedsAvailableSize(writer, await getLocalHeaderLength(reader, sourceOffset))) {
7794
+ await writer.closeDisk();
7795
+ }
7796
+ entryPositions.set(entry, {
7797
+ offset: getSegmentOffset(zipWriter, writer),
7798
+ diskNumberStart: getDiskNumber(writer)
7799
+ });
7800
+ copiedLength = sourceOffset;
7801
+ }
7802
+ await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
7803
+ } else {
7804
+ await copyData(zipWriter, reader, 0, directoryOffset);
7805
+ entries.forEach(entry => entryPositions.set(entry, {
7806
+ offset: splitZipSignatureLength + getSourceOffset(reader, entry),
7807
+ diskNumberStart: 0
7808
+ }));
7809
+ }
7810
+ return entryPositions;
7811
+ }
7812
+
7813
+ async function copyData(zipWriter, reader, offset, size) {
7814
+ if (size > 0) {
7815
+ const { writer } = zipWriter;
7816
+ await createReadable(reader, { offset, size }).pipeTo(writer.writable, { preventClose: true, preventAbort: true });
7817
+ writer.size += size;
7818
+ zipWriter.offset += size;
7819
+ }
7820
+ }
7821
+
7822
+ async function getLocalHeaderLength(reader, offset) {
7823
+ const headerArray = await readUint8Array(reader, offset, HEADER_SIZE);
7824
+ if (getLength(headerArray) < HEADER_SIZE) {
7825
+ return HEADER_SIZE;
7826
+ }
7827
+ const headerView = getDataView(headerArray);
7828
+ return HEADER_SIZE +
7829
+ getUint16(headerView, HEADER_OFFSET_FILENAME_LENGTH + LOCAL_HEADER_COMMON_OFFSET) +
7830
+ getUint16(headerView, HEADER_OFFSET_EXTRAFIELD_LENGTH + LOCAL_HEADER_COMMON_OFFSET);
7831
+ }
7832
+
7833
+ function getSourceOffset(reader, { offset, diskNumberStart }) {
7834
+ return offset + (reader.getDiskOffset ? reader.getDiskOffset(diskNumberStart) : 0);
7835
+ }
7836
+
7837
+ function getSplitZipSignatureArray() {
7838
+ const signatureArray = new Uint8Array(SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
7839
+ setUint32(getDataView(signatureArray), 0, SPLIT_ZIP_FILE_SIGNATURE);
7840
+ return signatureArray;
7841
+ }
7842
+
7654
7843
  async function writeData(writer, array) {
7655
7844
  const { writable } = writer;
7656
7845
  const streamWriter = writable.getWriter();
@@ -7702,6 +7891,21 @@
7702
7891
  return result === UNDEFINED_VALUE ? defaultValue : result;
7703
7892
  }
7704
7893
 
7894
+ function getDateOptionValue(zipWriter, options, name, defaultValue) {
7895
+ const date = getOptionValue(zipWriter, options, name, defaultValue);
7896
+ if (date === null) {
7897
+ return defaultValue;
7898
+ }
7899
+ if (date !== UNDEFINED_VALUE && (typeof date.getTime != FUNCTION_TYPE || Number.isNaN(date.getTime()))) {
7900
+ throw new Error(ERR_INVALID_DATE);
7901
+ }
7902
+ return date;
7903
+ }
7904
+
7905
+ function getFunctionOptionValue(zipWriter, options, name) {
7906
+ return checkFunctionOption(getOptionValue(zipWriter, options, name));
7907
+ }
7908
+
7705
7909
  function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
7706
7910
  const value = getAliasedValue(options, name, deprecatedName);
7707
7911
  const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
@@ -7716,9 +7920,6 @@
7716
7920
  return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
7717
7921
  }
7718
7922
 
7719
- function toNumber(value) {
7720
- return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
7721
- }
7722
7923
 
7723
7924
  function getMaximumCompressedSize(uncompressedSize) {
7724
7925
  return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
@@ -7730,6 +7931,14 @@
7730
7931
  : compressionMethod !== COMPRESSION_METHOD_STORE;
7731
7932
  }
7732
7933
 
7934
+ function getUint16(view, offset) {
7935
+ return view.getUint16(offset, true);
7936
+ }
7937
+
7938
+ function getUint32(view, offset) {
7939
+ return view.getUint32(offset, true);
7940
+ }
7941
+
7733
7942
  function setUint8(view, offset, value) {
7734
7943
  view.setUint8(offset, value);
7735
7944
  }
@@ -7773,9 +7982,9 @@
7773
7982
  const headerRecord = createRecordWriter(HEADER_SIZE - 4);
7774
7983
  const headerArray = headerRecord.array;
7775
7984
  const headerView = getDataView(headerArray);
7776
- headerRecord.uint16(version);
7777
- headerRecord.uint16(bitFlag);
7778
- headerRecord.uint16(compressionMethod);
7985
+ headerRecord.writeUint16(version);
7986
+ headerRecord.writeUint16(bitFlag);
7987
+ headerRecord.writeUint16(compressionMethod);
7779
7988
  if (rawLastModDate === UNDEFINED_VALUE) {
7780
7989
  const dateArray = new Uint32Array(1);
7781
7990
  const dateView = getDataView(dateArray);
@@ -7783,20 +7992,20 @@
7783
7992
  setUint16(dateView, 2, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate());
7784
7993
  rawLastModDate = dateArray[0];
7785
7994
  }
7786
- headerRecord.uint32(rawLastModDate);
7995
+ headerRecord.writeUint32(rawLastModDate);
7787
7996
  headerRecord.skip(4);
7788
7997
  if (zip64CompressedSize || compressedSize !== UNDEFINED_VALUE) {
7789
- headerRecord.uint32(zip64CompressedSize ? MAX_32_BITS : compressedSize);
7998
+ headerRecord.writeUint32(zip64CompressedSize ? MAX_32_BITS : compressedSize);
7790
7999
  } else {
7791
8000
  headerRecord.skip(4);
7792
8001
  }
7793
8002
  if (zip64UncompressedSize || uncompressedSize !== UNDEFINED_VALUE) {
7794
- headerRecord.uint32(zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
8003
+ headerRecord.writeUint32(zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
7795
8004
  } else {
7796
8005
  headerRecord.skip(4);
7797
8006
  }
7798
- headerRecord.uint16(getLength(rawFilename));
7799
- headerRecord.uint16(extraFieldLength);
8007
+ headerRecord.writeUint16(getLength(rawFilename));
8008
+ headerRecord.writeUint16(extraFieldLength);
7800
8009
  return {
7801
8010
  headerArray,
7802
8011
  headerView,
@@ -8319,6 +8528,7 @@
8319
8528
  exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
8320
8529
  exports.ERR_ENCRYPTED = ERR_ENCRYPTED;
8321
8530
  exports.ERR_ENCRYPTED_CENTRAL_DIRECTORY = ERR_ENCRYPTED_CENTRAL_DIRECTORY;
8531
+ exports.ERR_ENTRY_DATA_OUT_OF_BOUNDS = ERR_ENTRY_DATA_OUT_OF_BOUNDS;
8322
8532
  exports.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND = ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND;
8323
8533
  exports.ERR_EOCDR_NOT_FOUND = ERR_EOCDR_NOT_FOUND;
8324
8534
  exports.ERR_EXTRAFIELD_ZIP64_NOT_FOUND = ERR_EXTRAFIELD_ZIP64_NOT_FOUND;
@@ -8331,19 +8541,26 @@
8331
8541
  exports.ERR_INVALID_COMMENT_TYPE = ERR_INVALID_COMMENT_TYPE;
8332
8542
  exports.ERR_INVALID_COMPRESSED_DATA = ERR_INVALID_COMPRESSED_DATA;
8333
8543
  exports.ERR_INVALID_CRC32 = ERR_INVALID_CRC32;
8544
+ exports.ERR_INVALID_DATE = ERR_INVALID_DATE;
8334
8545
  exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
8335
8546
  exports.ERR_INVALID_ENTRY_COMMENT = ERR_INVALID_ENTRY_COMMENT;
8547
+ exports.ERR_INVALID_ENTRY_COMMENT_TYPE = ERR_INVALID_ENTRY_COMMENT_TYPE;
8336
8548
  exports.ERR_INVALID_ENTRY_NAME = ERR_INVALID_ENTRY_NAME;
8549
+ exports.ERR_INVALID_EXTRAFIELD = ERR_INVALID_EXTRAFIELD;
8337
8550
  exports.ERR_INVALID_EXTRAFIELD_DATA = ERR_INVALID_EXTRAFIELD_DATA;
8551
+ exports.ERR_INVALID_EXTRAFIELD_DATA_TYPE = ERR_INVALID_EXTRAFIELD_DATA_TYPE;
8338
8552
  exports.ERR_INVALID_EXTRAFIELD_TYPE = ERR_INVALID_EXTRAFIELD_TYPE;
8339
8553
  exports.ERR_INVALID_FILENAME_VALIDATION = ERR_INVALID_FILENAME_VALIDATION;
8554
+ exports.ERR_INVALID_FUNCTION_OPTION = ERR_INVALID_FUNCTION_OPTION;
8340
8555
  exports.ERR_INVALID_GID = ERR_INVALID_GID;
8341
8556
  exports.ERR_INVALID_LEVEL = ERR_INVALID_LEVEL;
8342
8557
  exports.ERR_INVALID_MAX_APPENDED_DATA_SIZE = ERR_INVALID_MAX_APPENDED_DATA_SIZE;
8558
+ exports.ERR_INVALID_MAX_WORKERS = ERR_INVALID_MAX_WORKERS;
8343
8559
  exports.ERR_INVALID_MSDOS_ATTRIBUTES = ERR_INVALID_MSDOS_ATTRIBUTES;
8344
8560
  exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
8345
8561
  exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
8346
8562
  exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
8563
+ exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
8347
8564
  exports.ERR_INVALID_SIGNATURE = ERR_INVALID_SIGNATURE;
8348
8565
  exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
8349
8566
  exports.ERR_INVALID_STRICTNESS = ERR_INVALID_STRICTNESS;