@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/index.cjs CHANGED
@@ -39,6 +39,7 @@ const COMPRESSION_METHOD_AES = 0x63;
39
39
 
40
40
  const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50;
41
41
  const SPLIT_ZIP_FILE_SIGNATURE = 0x08074b50;
42
+ const TEMPORARY_SPLIT_ZIP_FILE_SIGNATURE = 0x30304b50;
42
43
  const DATA_DESCRIPTOR_RECORD_SIGNATURE = SPLIT_ZIP_FILE_SIGNATURE;
43
44
  const ARCHIVE_EXTRA_DATA_SIGNATURE = 0x08064b50;
44
45
  const DIGITAL_SIGNATURE_RECORD_SIGNATURE = 0x05054b50;
@@ -55,6 +56,7 @@ const ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH = END_OF_CENTRAL_DIR_LENGTH + ZIP64_
55
56
  const DATA_DESCRIPTOR_RECORD_LENGTH = 12;
56
57
  const DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH = 20;
57
58
  const DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH = 4;
59
+ const SPLIT_ZIP_FILE_SIGNATURE_LENGTH = 4;
58
60
 
59
61
  const EXTRAFIELD_TYPE_ZIP64 = 0x0001;
60
62
  const EXTRAFIELD_TYPE_AES = 0x9901;
@@ -106,6 +108,8 @@ const HEADER_OFFSET_VERSION = 0;
106
108
  const HEADER_OFFSET_SIGNATURE = 10;
107
109
  const HEADER_OFFSET_COMPRESSED_SIZE = 14;
108
110
  const HEADER_OFFSET_UNCOMPRESSED_SIZE = 18;
111
+ const HEADER_OFFSET_FILENAME_LENGTH = 22;
112
+ const HEADER_OFFSET_EXTRAFIELD_LENGTH = 24;
109
113
  const LOCAL_HEADER_COMMON_OFFSET = 4;
110
114
 
111
115
  const MAX_DATE = new Date(2107, 11, 31, 23, 59, 58);
@@ -118,9 +122,116 @@ const FUNCTION_TYPE = "function";
118
122
  const OBJECT_TYPE = "object";
119
123
  const STRING_TYPE = "string";
120
124
  const NUMBER_TYPE = "number";
125
+ const BOOLEAN_TYPE = "boolean";
121
126
 
122
127
  const EMPTY_UINT8_ARRAY = new Uint8Array();
123
128
 
129
+ /*
130
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
131
+
132
+ Redistribution and use in source and binary forms, with or without
133
+ modification, are permitted provided that the following conditions are met:
134
+
135
+ 1. Redistributions of source code must retain the above copyright notice,
136
+ this list of conditions and the following disclaimer.
137
+
138
+ 2. Redistributions in binary form must reproduce the above copyright
139
+ notice, this list of conditions and the following disclaimer in
140
+ the documentation and/or other materials provided with the distribution.
141
+
142
+ 3. The names of the authors may not be used to endorse or promote products
143
+ derived from this software without specific prior written permission.
144
+
145
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
146
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
147
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
148
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
149
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
150
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
151
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
152
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
153
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
154
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
155
+ */
156
+
157
+
158
+ const OPTION_FILENAME_ENCODING = "filenameEncoding";
159
+ const OPTION_COMMENT_ENCODING = "commentEncoding";
160
+ const OPTION_DECODE_TEXT = "decodeText";
161
+ const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
162
+ const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
163
+ const OPTION_PASSWORD = "password";
164
+ const OPTION_RAW_PASSWORD = "rawPassword";
165
+ const OPTION_PASS_THROUGH = "passThrough";
166
+ const OPTION_SIGNAL = "signal";
167
+ const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
168
+ const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
169
+ const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
170
+ const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
171
+ const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
172
+ const OPTION_CHECK_SIGNATURE = "checkSignature";
173
+ const OPTION_CHECK_CRC32 = "checkCrc32";
174
+ const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
175
+ const OPTION_USE_WEB_WORKERS = "useWebWorkers";
176
+ const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
177
+ const OPTION_TRANSFER_STREAMS = "transferStreams";
178
+ const OPTION_PREVENT_CLOSE = "preventClose";
179
+ const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
180
+ const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
181
+ const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
182
+ const OPTION_KEEP_ORDER = "keepOrder";
183
+ const OPTION_LEVEL = "level";
184
+ const OPTION_BUFFERED_WRITE = "bufferedWrite";
185
+ const OPTION_CREATE_TEMP_STREAM = "createTempStream";
186
+ const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
187
+ const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
188
+ const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
189
+ const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
190
+ const OPTION_ENCODE_TEXT = "encodeText";
191
+ const OPTION_OFFSET = "offset";
192
+ const OPTION_USDZ = "usdz";
193
+ const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
194
+ const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
195
+ const OPTION_STRICTNESS = "strictness";
196
+ const OPTION_FILENAME_VALIDATION = "filenameValidation";
197
+ const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
198
+ const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
199
+ const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
200
+ const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
201
+ const TEXT_TYPE_FILENAME = "filename";
202
+ const TEXT_TYPE_COMMENT = "comment";
203
+ const STRICTNESS_STRICT = "strict";
204
+ const STRICTNESS_BALANCED = "balanced";
205
+ const STRICTNESS_TOLERANT = "tolerant";
206
+
207
+ const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
208
+ const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
209
+ const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
210
+
211
+ function checkFunctionOption(value) {
212
+ if (value && typeof value != FUNCTION_TYPE) {
213
+ throw new Error(ERR_INVALID_FUNCTION_OPTION);
214
+ }
215
+ return value;
216
+ }
217
+
218
+ function checkSignalOption(signal) {
219
+ if (signal && (typeof signal.addEventListener != FUNCTION_TYPE || typeof signal.aborted != BOOLEAN_TYPE)) {
220
+ throw new Error(ERR_INVALID_SIGNAL);
221
+ }
222
+ return signal || UNDEFINED_VALUE;
223
+ }
224
+
225
+ function checkPasswordOption(password, rawPassword) {
226
+ if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
227
+ throw new Error(ERR_INVALID_PASSWORD_TYPE);
228
+ }
229
+ }
230
+
231
+ function toNumber(value) {
232
+ return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
233
+ }
234
+
124
235
  /*
125
236
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
126
237
 
@@ -150,7 +261,10 @@ const EMPTY_UINT8_ARRAY = new Uint8Array();
150
261
  */
151
262
 
152
263
 
264
+ const DEFAULT_CHUNK_SIZE$1 = 64 * 1024;
153
265
  const MINIMUM_CHUNK_SIZE = 64;
266
+ const MINIMUM_PROPERTY_VALUE = 1;
267
+ const ERR_INVALID_MAX_WORKERS = "Invalid maxWorkers (must be an integer greater than 0)";
154
268
  let maxWorkers = 2;
155
269
  try {
156
270
  if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
@@ -162,7 +276,7 @@ try {
162
276
  const DEFAULT_CONFIGURATION = {
163
277
  workerURI: "./core/web-worker-wasm.js",
164
278
  wasmURI: "./core/streams/zlib-wasm/zlib-streams.wasm",
165
- chunkSize: 64 * 1024,
279
+ chunkSize: DEFAULT_CHUNK_SIZE$1,
166
280
  maxWorkers,
167
281
  terminateWorkerTimeout: 5000,
168
282
  workerStarvationTimeout: 5000,
@@ -174,24 +288,38 @@ const DEFAULT_CONFIGURATION = {
174
288
  DecompressionStream: typeof DecompressionStream != UNDEFINED_TYPE && DecompressionStream
175
289
  };
176
290
 
177
- const CONFIGURABLE_PROPERTY_NAMES = [
291
+ const PROPERTY_NAME_MAX_WORKERS = "maxWorkers";
292
+
293
+ const STRING_PROPERTY_NAMES = [
178
294
  "baseURI",
179
295
  "wasmURI",
180
- "workerURI",
181
- "createWorker",
296
+ "workerURI"
297
+ ];
298
+ const BOOLEAN_PROPERTY_NAMES = [
299
+ "useCompressionStream",
300
+ "useWebWorkers",
301
+ "transferStreams"
302
+ ];
303
+ const NUMBER_PROPERTY_NAMES = [
182
304
  "chunkSize",
183
- "maxWorkers",
305
+ PROPERTY_NAME_MAX_WORKERS,
184
306
  "terminateWorkerTimeout",
185
307
  "workerStarvationTimeout",
186
- "workerStartupTimeout",
187
- "useCompressionStream",
188
- "useWebWorkers",
189
- "transferStreams",
308
+ "workerStartupTimeout"
309
+ ];
310
+ const FUNCTION_PROPERTY_NAMES = [
311
+ "createWorker",
190
312
  "CompressionStream",
191
313
  "DecompressionStream",
192
314
  "CompressionStreamFallback",
193
315
  "DecompressionStreamFallback"
194
316
  ];
317
+ const CONFIGURABLE_PROPERTY_NAMES = [
318
+ ...STRING_PROPERTY_NAMES,
319
+ ...BOOLEAN_PROPERTY_NAMES,
320
+ ...NUMBER_PROPERTY_NAMES,
321
+ ...FUNCTION_PROPERTY_NAMES
322
+ ];
195
323
 
196
324
  const config = { ...DEFAULT_CONFIGURATION };
197
325
 
@@ -200,20 +328,43 @@ function getConfiguration() {
200
328
  }
201
329
 
202
330
  function getChunkSize(config) {
203
- return Math.max(config.chunkSize, MINIMUM_CHUNK_SIZE);
331
+ return normalizeChunkSize(config.chunkSize);
332
+ }
333
+
334
+ function normalizeChunkSize(chunkSize) {
335
+ chunkSize = toNumber(chunkSize);
336
+ return Number.isInteger(chunkSize) && chunkSize >= MINIMUM_PROPERTY_VALUE ? Math.max(chunkSize, MINIMUM_CHUNK_SIZE) : DEFAULT_CHUNK_SIZE$1;
204
337
  }
205
338
 
206
339
  function configure(configuration) {
207
- configuration = normalizeConfiguration(configuration);
340
+ Object.assign(config, checkConfiguration(normalizeConfiguration(configuration)));
341
+ }
342
+
343
+ function checkConfiguration(configuration) {
344
+ const checkedConfiguration = {};
208
345
  for (const propertyName of CONFIGURABLE_PROPERTY_NAMES) {
209
346
  const propertyValue = configuration[propertyName];
210
347
  if (propertyValue !== UNDEFINED_VALUE) {
211
- config[propertyName] = propertyValue;
348
+ checkedConfiguration[propertyName] = checkPropertyValue(propertyName, propertyValue);
212
349
  }
213
350
  }
351
+ return checkedConfiguration;
352
+ }
353
+
354
+ function checkPropertyValue(propertyName, propertyValue) {
355
+ if (NUMBER_PROPERTY_NAMES.includes(propertyName)) {
356
+ propertyValue = toNumber(propertyValue);
357
+ if (propertyName == PROPERTY_NAME_MAX_WORKERS && (!Number.isInteger(propertyValue) || propertyValue < MINIMUM_PROPERTY_VALUE)) {
358
+ throw new Error(ERR_INVALID_MAX_WORKERS);
359
+ }
360
+ } else if (FUNCTION_PROPERTY_NAMES.includes(propertyName)) {
361
+ checkFunctionOption(propertyValue);
362
+ }
363
+ return propertyValue;
214
364
  }
215
365
 
216
366
  function normalizeConfiguration(configuration) {
367
+ configuration = configuration || {};
217
368
  const { CompressionStreamZlib, DecompressionStreamZlib } = configuration;
218
369
  if (CompressionStreamZlib === UNDEFINED_VALUE && DecompressionStreamZlib === UNDEFINED_VALUE) {
219
370
  return configuration;
@@ -229,14 +380,9 @@ function normalizeConfiguration(configuration) {
229
380
  }
230
381
 
231
382
  function setDefaultConfiguration(configuration) {
232
- configuration = normalizeConfiguration(configuration);
233
- for (const propertyName of CONFIGURABLE_PROPERTY_NAMES) {
234
- const propertyValue = configuration[propertyName];
235
- if (propertyValue !== UNDEFINED_VALUE) {
236
- DEFAULT_CONFIGURATION[propertyName] = propertyValue;
237
- }
238
- }
239
- configure(configuration);
383
+ const checkedConfiguration = checkConfiguration(normalizeConfiguration(configuration));
384
+ Object.assign(DEFAULT_CONFIGURATION, checkedConfiguration);
385
+ Object.assign(config, checkedConfiguration);
240
386
  }
241
387
 
242
388
  function resetConfiguration() {
@@ -246,7 +392,7 @@ function resetConfiguration() {
246
392
  Object.assign(config, DEFAULT_CONFIGURATION);
247
393
  }
248
394
 
249
- const t$1=new Uint8Array(288);t$1.fill(8,0,144),t$1.fill(9,144,256),t$1.fill(7,256,280),t$1.fill(8,280,288),new Uint8Array(30).fill(5);const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n$1=t=>t({workerURI:t=>{const n="text/javascript";let s='(t=>{"function"==typeof define&&define.amd?define(t):t()})(function(){"use strict";const{Array:t,Object:e,Number:n,Math:s,Error:r,Uint8Array:o,Uint16Array:c,Uint32Array:i,Int32Array:a,Map:f,DataView:l,Promise:w,TextEncoder:u,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,b="undefined",k="function",z=new o,C=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;C[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=C[e-1][t];C[e][t]=n>>>8^C[0][255&n]}const[A,I,x,M,P,D,F,B]=C;class R{constructor(t){this.o=t||-1}append(t){let e=0|this.o;const n=0|t.length;let s=0;if(n>=8&&t.buffer){const r=new l(t.buffer,t.byteOffset,n),o=n-8;for(;o>=s;s+=8){const t=e^r.getInt32(s,!0),n=r.getInt32(s+4,!0);e=B[255&t]^F[t>>>8&255]^D[t>>>16&255]^P[t>>>24&255]^M[255&n]^x[n>>>8&255]^I[n>>>16&255]^A[n>>>24&255]}}for(;n>s;s++)e=e>>>8^A[255&(e^t[s])];this.o=e}get(){return~this.o}}class U extends d{constructor(){let t;const e=new R;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new l(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}function W(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function _(t){return new l(t.buffer,t.byteOffset,t.byteLength)}const T={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=T.l(n);return 32===s?t.concat(e):T.h(e,s,0|n,t.slice(0,t.length-1))},bitLength(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+T.l(n)},m(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,s.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=T.S(e,t[n-1]&2147483648>>e-1,1)),t},S:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,l:t=>s.round(t/1099511627776)||32,h(t,e,n,s){for(void 0===s&&(s=[]);e>=32;e-=32)s.push(n),n=0;if(0===e)return s.concat(t);for(let r=0;r<t.length;r++)s.push(n|t[r]>>>e),n=t[r]<<32-e;const r=t.length?t[t.length-1]:0,o=T.l(r);return s.push(T.S(e+o&31,e+o>32?n:s.pop(),1)),s}},V={bytes:{v(t){const e=T.bitLength(t)/8,n=new o(e);let s;for(let r=0;e>r;r++)3&r||(s=t[r/4]),n[r]=s>>>24,s<<=8;return n},C(t){const e=[];let n,s=0;for(n=0;n<t.length;n++)s=s<<8|t[n],3&~n||(e.push(s),s=0);return 3&n&&e.push(T.S(8*(3&n),s)),e}}},K=class{constructor(t){const e=this;e.blockSize=512,e.A=[1732584193,4023233417,2562383102,271733878,3285377520],e.I=[1518500249,1859775393,2400959708,3395469782],t?(e.M=t.M.slice(0),e.P=t.P.slice(0),e.D=t.D):e.reset()}reset(){const t=this;return t.M=t.A.slice(0),t.P=[],t.D=0,t}update(t){const e=this;"string"==typeof t&&(t=V.F.C(t));const n=e.P=T.concat(e.P,t),s=e.D,o=e.D=s+T.bitLength(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const c=new i(n);let a=0;for(let t=e.blockSize+s-(e.blockSize+s&e.blockSize-1);o>=t;t+=e.blockSize)e.B(c.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),e}R(){const t=this;let e=t.P;const n=t.M;e=T.concat(e,[T.S(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(s.floor(t.D/4294967296)),e.push(0|t.D);e.length;)t.B(e.splice(0,16));return t.reset(),n}U(t,e,n,s){return t>19?t>39?t>59?t>79?void 0:e^n^s:e&n|e&s|n&s:e^n^s:e&n|~e&s}W(t,e){return e<<t|e>>>32-t}B(e){const n=this,r=n.M,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let c=r[0],i=r[1],a=r[2],f=r[3],l=r[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.W(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.W(5,c)+n.U(t,i,a,f)+l+o[t]+n.I[s.floor(t/20)]|0;l=f,f=a,a=n.W(30,i),i=c,c=e}r[0]=r[0]+c|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+f|0,r[4]=r[4]+l|0}},E={importKey:t=>new E._(V.bytes.C(t)),T(t,e,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const o=1+(s>>5)<<2;let c,i,a,f,w;const u=new ArrayBuffer(o),h=new l(u);let p=0;const d=T;for(e=V.bytes.C(e),w=1;(o||1)>p;w++){for(c=i=t.encrypt(d.concat(e,[w])),a=1;n>a;a++)for(i=t.encrypt(i),f=0;f<i.length;f++)c[f]^=i[f];for(a=0;(o||1)>p&&a<c.length;a++)h.setInt32(p,c[a]),p+=4}return u.slice(0,s/8)},_:class{constructor(t){const e=this,n=e.V=K,s=[[],[]];e.K=[new n,new n];const r=e.K[0].blockSize/32;t.length>r&&(t=(new n).update(t).R());for(let e=0;r>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e.K[0].update(s[0]),e.K[1].update(s[1]),e.L=new n(e.K[0])}reset(){const t=this;t.L=new t.V(t.K[0]),t.O=!1}update(t){this.O=!0,this.L.update(t)}digest(){const t=this,e=t.L.R(),n=new t.V(t.K[1]).update(e).R();return t.reset(),n}encrypt(t){if(this.O)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},L=typeof h!=b&&typeof h.getRandomValues==k,O="Invalid password",j="Invalid signature",H=j,N="zipjs-abort-check-password";function q(t){if(L)return h.getRandomValues(t);throw new r("Crypto API not supported")}const G=16,J={name:"PBKDF2"},Q=e.assign({hash:{name:"HMAC"}},J),X=e.assign({iterations:1e3,hash:{name:"SHA-1"}},J),Y=["deriveBits"],Z=[8,12,16],$=[16,24,32],tt=10,et=[0,0,0,0],nt=typeof h!=b,st=nt&&h.subtle,rt=nt&&typeof st!=b,ot=V.bytes,ct=class{constructor(t){const e=this;e.j=[[[],[],[],[],[]],[[],[],[],[],[]]],e.j[0][0][0]||e.H();const n=e.j[0][4],s=e.j[1],o=t.length;let c,i,a,f=1;if(4!==o&&6!==o&&8!==o)throw new r("invalid aes key size");for(e.I=[i=t.slice(0),a=[]],c=o;4*o+28>c;c++){let t=i[c-1];(c%o===0||8===o&&c%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],c%o===0&&(t=t<<8^t>>>24^f<<24,f=f<<1^283*(f>>7))),i[c]=i[c-o]^t}for(let t=0;c;t++,c--){const e=i[3&t?c:c-4];a[t]=4>=c||4>t?e:s[0][n[e>>>24]]^s[1][n[e>>16&255]]^s[2][n[e>>8&255]]^s[3][n[255&e]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}H(){const t=this.j[0],e=this.j[1],n=t[4],s=e[4],r=[],o=[];let c,i,a,f;for(let t=0;256>t;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let l=c=0;!n[l];l^=i||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,n[l]=o,s[o]=l,f=r[a=r[i=r[l]]];let w=16843009*f^65537*a^257*i^16843008*l,u=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][l]=u=u<<24^u>>>8,e[n][o]=w=w<<24^w>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}N(t,e){if(4!==t.length)throw new r("invalid aes block size");const n=this.I[e],s=n.length/4-2,o=[0,0,0,0],c=this.j[e],i=c[0],a=c[1],f=c[2],l=c[3],w=c[4];let u,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],S=t[e?1:3]^n[3],g=4;for(let t=0;s>t;t++)u=i[d>>>24]^a[y>>16&255]^f[m>>8&255]^l[255&S]^n[g],h=i[y>>>24]^a[m>>16&255]^f[S>>8&255]^l[255&d]^n[g+1],p=i[m>>>24]^a[S>>16&255]^f[d>>8&255]^l[255&y]^n[g+2],S=i[S>>>24]^a[d>>16&255]^f[y>>8&255]^l[255&m]^n[g+3],g+=4,d=u,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=w[d>>>24]<<24^w[y>>16&255]<<16^w[m>>8&255]<<8^w[255&S]^n[g++],u=d,d=y,y=m,m=S,S=u;return o}},it=class{constructor(t,e){this.G=t,this.J=e,this.X=e}reset(){this.X=this.J}update(t){return this.Y(this.G,t,this.X)}Z(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,s=255&t;255===e?(e=0,255===n?(n=0,255===s?s=0:++s):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=s}return t}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,e,n){let s;if(!(s=e.length))return[];const r=T.bitLength(e);for(let r=0;s>r;r+=4){this.$(n);const s=t.encrypt(n);e[r]^=s[0],e[r+1]^=s[1],e[r+2]^=s[2],e[r+3]^=s[3]}return T.m(e,r)}},at=E._;let ft=nt&&rt&&typeof st.importKey==k,lt=nt&&rt&&typeof st.deriveBits==k;class wt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:s,checkAuthenticationCode:c=!0}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:i,et:a,ready:f}=n;c?(await(async(t,e,n,s)=>{const o=await dt(t,e,n,mt(s,0,Z[e])),c=mt(s,Z[e]);if(o[0]!=c[0]||o[1]!=c[1])throw new r(O)})(n,i,c,mt(t,0,Z[i]+2)),t=mt(t,Z[i]+2),s?e.error(new r(N)):a()):await f;const l=new o(t.length-tt-(t.length-tt)%G);e.enqueue(pt(n,t,l,0,tt,!0))},async flush(t){const{nt:e,st:n,pending:s,ready:o}=this;if(n&&e){await o;const i=mt(s,0,s.length-tt),a=mt(s,s.length-tt);let f=z;if(i.length){const t=gt(ot,i);n.update(t);const s=e.update(t);f=St(ot,s)}const l=mt(St(ot,n.digest()),0,tt);let w=s.length<tt?1:0;for(let t=0;tt>t;t++)w|=l[t]^a[t];if(w&&c)throw new r(H);t.enqueue(f)}}})}}class ut extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:s,strength:r,et:c,ready:i}=n;let a=z;s?(a=await(async(t,e,n)=>{const s=q(new o(Z[e]));return W(s,await dt(t,e,n,s))})(n,r,s),c()):await i;const f=new o(a.length+t.length-t.length%G);f.set(a,0),e.enqueue(pt(n,t,f,a.length,0))},async flush(t){const{nt:e,st:n,pending:s,ready:r}=this;if(n&&e){await r;let o=z;if(s.length){const t=e.update(gt(ot,s));n.update(t),o=St(ot,t)}const c=St(ot,n.digest()).slice(0,tt);t.enqueue(W(o,c))}}})}}function ht(t,n,s,r){e.assign(t,{ready:new w(e=>t.et=e),password:yt(n,s),strength:r-1,pending:z})}function pt(t,e,n,s,r,c){const{nt:i,st:a,pending:f}=t;f.length&&(e=W(f,e));const l=e.length-r;let w;for(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,s+(l-l%G)),w=0;l-G>=w;w+=G){const t=gt(ot,mt(e,w,w+G));c&&a.update(t);const r=i.update(t);c||a.update(r),n.set(St(ot,r),w+s)}return t.pending=mt(e,w),n}async function dt(n,s,r,c){n.password=null;const i=await(async(t,e,n,s,r)=>{if(!ft)return E.importKey(e);try{return await st.importKey("raw",e,n,!1,r)}catch{return ft=!1,E.importKey(e)}})(0,r,Q,0,Y),a=await(async(t,e,n)=>{if(!lt)return E.T(e,t.salt,X.iterations,n);try{return await st.deriveBits(t,e,n)}catch{return lt=!1,E.T(e,t.salt,X.iterations,n)}})(e.assign({salt:c},X),i,8*(2*$[s]+2)),f=new o(a),l=gt(ot,mt(f,0,$[s])),w=gt(ot,mt(f,$[s],2*$[s])),u=mt(f,2*$[s]);return e.assign(n,{keys:{key:l,ot:w,passwordVerification:u},nt:new it(new ct(l),t.from(et)),st:new at(w)}),u}function yt(t,e){return e===v?(t=>{if(typeof u==b){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new u).encode(t)})(t):e}function mt(t,e,n){return t.subarray(e,n)}function St(t,e){return t.v(e)}function gt(t,e){return t.C(e)}class vt extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){kt(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=zt(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e[11]^n.passwordVerification))throw new r(O);t=t.subarray(12)}s?e.error(new r(N)):e.enqueue(zt(n,t))}})}}class bt extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){kt(this,t,e,n)},transform(t,e){const n=this;let s,r;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=q(new o(12));e[11]=n.passwordVerification,s=new o(t.length+e.length),s.set(Ct(n,e),0),r=12}else s=new o(t.length),r=0;s.set(Ct(n,t),r),e.enqueue(s)}})}}function kt(t,n,s,r){e.assign(t,{password:n,rawPassword:s,passwordVerification:r}),((t,n,s)=>{const r=[305419896,591751049,878082192];if(e.assign(t,{keys:r,ct:new R(r[0]),it:new R(r[2])}),s)for(let e=0;e<s.length;e++)At(t,s[e]);else for(let e=0;e<n.length;e++)At(t,n.charCodeAt(e))})(t,n,s)}function zt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=It(t)^e[s],At(t,n[s]);return n}function Ct(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=It(t)^e[s],At(t,e[s]);return n}function At(t,e){let[,n]=t.keys;t.ct.append([e]);const r=~t.ct.get();n=Mt(s.imul(Mt(n+xt(r)),134775813)+1),t.it.append([n>>>24]);const o=~t.it.get();t.keys=[r,n,o]}function It(t){const e=2|t.keys[2];return xt(s.imul(e,1^e)>>>8)}function xt(t){return 255&t}function Mt(t){return 4294967295&t}const Pt=new f;function Dt(t){return Pt.get(t)}const Ft="Invalid uncompressed size",Bt=j,Rt="deflate-raw",Ut="gzip",Wt=[31,139,8];class _t extends d{constructor(t,{chunkSize:e,CompressionStreamFallback:n,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:c,zipCrypto:i,computeCrc32:a,level:f,deflate64:w,format:u,compressionMethod:h}=t,p=this;let d,y,m,S=super.readable;const g=u&&Dt(u),v=a&&r&&!w&&!g&&(!o||i)&&!(!c||!s);if(o&&!i||!a||v||(d=new U,S=jt(S,d)),r)if(g)S=Ht(S,Lt(g.CompressionStream,u,{level:f,chunkSize:e,compressionMethod:h}));else if(v)m=new Tt,S=Ht(S,new s(Ut)),S=jt(S,m);else try{S=Ot(S,c,{level:f,chunkSize:e},s,n)}catch(t){let e;try{e=new s(Ut)}catch{throw t}S=Ht(S,e),S=jt(S,new Tt)}o&&(i?S=jt(S,new bt(t)):(y=new ut(t),S=jt(S,y))),Et(p,S,()=>{o&&!i||!a||(p.crc32=v?m.crc32:new l(d.value.buffer).getUint32(0))})}}class Tt extends d{constructor(){let t,e=10,n=new o(0);super({transform(t,r){if(e){const n=s.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const o=n.length+t.length;if(8>=o)return void(n=W(n,t));const c=o-8,i=s.min(c,n.length);r.enqueue(W(n.subarray(0,i),t.subarray(0,c-i))),n=W(n.subarray(i),t.subarray(c-i))},flush(){const e=_(n);t.crc32=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Vt extends d{constructor(t,{chunkSize:e,DecompressionStreamFallback:n,DecompressionStream:s}){super({});const{zipCrypto:c,encrypted:i,checkCrc32:a,crc32:f,compressed:u,useCompressionStream:h,deflate64:p,format:m,compressionMethod:S,rawBitFlag:g,outputSize:b}=t;let k,z,C=super.readable;if(i&&(c?C=jt(C,new vt(t)):(z=new wt(t),C=jt(C,z))),u){const t=m&&Dt(m);if(t)C=Ht(C,Lt(t.DecompressionStream,m,{chunkSize:e,compressionMethod:S,rawBitFlag:g,uncompressedSize:b}));else try{C=Ot(C,h,{chunkSize:e,deflate64:p},s,n)}catch(t){if(p||b===v)throw t;let e;try{e=new s(Ut)}catch{throw t}C=((t,e,n)=>{const s=new R;let c,i,a,f=0,l=!1;const u=new w((t,e)=>{i=t,a=e});u.catch(()=>{}),n||i();const h=new d({start(t){const e=new o(10);e.set(Wt),t.enqueue(e)},transform(t,e){e.enqueue(t)},async flush(t){l=!0,y();try{await u}finally{m()}const e=new o(8),r=_(e);r.setUint32(0,s.get(),!0),r.setUint32(4,n,!0),t.enqueue(e)},cancel(t){a(t)}}),p=new d({transform(t,e){s.append(t),f+=t.length,n>f?l&&y():i(),e.enqueue(t)},cancel(t){a(t)}});return t=jt(t,h),jt(t=Ht(t,e),p);function y(){m(),c=setTimeout(()=>a(new r(Ft)),5e3)}function m(){clearTimeout(c)}})(C,e,b)}C=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new r("Invalid compressed data");throw e.cause=t,e}const{value:s,done:o}=n;o?t.close():t.enqueue(s)},cancel:t=>e.cancel(t)})})(C)}a&&(k=new U,C=jt(C,k)),Et(this,C,()=>{if(a){const t=new l(k.value.buffer);if(f!=t.getUint32(0,!1))throw new r(Bt)}})}}const Kt=new f;function Et(t,n,s){n=jt(n,new d({flush:s})),e.defineProperty(t,"readable",{get:()=>n})}function Lt(t,e,n){if(!t)throw new r("Compression method not supported");return new t(e,n)}function Ot(t,e,n,s,r){const o=e&&s?s:r||s,c=n.deflate64?"deflate64-raw":Rt;let i;try{i=new o(c,n)}catch(t){if(!e||!r||o==r)throw t;i=new r(c,n)}return Ht(t,i)}function jt(t,e){return(t=>{if(t instanceof y)return t;const e=t.getReader();return new y({async pull(t){const{value:n,done:s}=await e.read();s?t.close():t.enqueue(n)},cancel:t=>e.cancel(t)})})(t).pipeThrough(e)}function Ht(t,e){const n=e.writable.getWriter(),s=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await s.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(s,t)}})(),e.readable}const Nt="data",qt="close",Gt="deflate";class Jt extends d{constructor(t,n){super({});const s=this,{codecType:o}=t;let c;o.startsWith(Gt)?c=_t:o.startsWith("inflate")&&(c=Vt),s.outputSize=0;let i=0;const a=new c(t,n),f=super.readable,l=new d({transform(t,e){t&&t.length&&(i+=t.length,e.enqueue(t))},flush(){e.assign(s,{inputSize:i})}}),w=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),s.outputSize+=e.length,t.outputSize!==v&&s.outputSize>t.outputSize))throw new r(Ft)},flush(){const{crc32:t}=a;e.assign(s,{crc32:t,inputSize:i})}});e.defineProperty(s,"readable",{get:()=>f.pipeThrough(l).pipeThrough(a).pipeThrough(w)})}}class Qt extends d{constructor(t){const e=[];let s=0;function r(){const n=new o(t);let r=0;for(;t>r;){const s=e[0],o=t-r;s.length>o?(n.set(s.subarray(0,o),r),e[0]=s.subarray(o),r+=o):(n.set(s,r),r+=s.length,e.shift())}return s-=t,n}n.isFinite(t)&&t>=1||(t=65536),super({transform(n,o){for(e.push(n),s+=n.length;s>t;)o.enqueue(r())},flush(t){s&&t.enqueue(((t,e)=>{const n=new o(e);let s=0;for(const e of t)n.set(e,s),s+=e.length;return n})(e,s))}})}}let Xt=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(Xt=navigator.hardwareConcurrency)}catch{}const Yt=new f,Zt=new f;let $t,te,ee,ne,se,re,oe=0;async function ce(t){let e,o;try{const{options:c,config:i}=t;if(c.format)try{await(async(t,e)=>{!Pt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:s}=e;if(typeof n!=k&&typeof s!=k)throw new r("Invalid codec module");Pt.set(t,{CompressionStream:n,DecompressionStream:s})})(t,await(import(e)))})(c.format,c.codecURI)}catch(t){throw t.codecImportFailed=!0,t}if(i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,c.compressed&&!c.format)if(c.useCompressionStream){if(!((t,e)=>{if(!t)return!1;let n=Kt.get(t);n||(n=new f,Kt.set(t,n));let s=n.get(e);if(s===v){try{new t(e),s=!0}catch{s=!1}n.set(e,s)}return s})(c.codecType.startsWith(Gt)?i.CompressionStream:i.DecompressionStream,Rt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{c.useCompressionStream=!0}!i.CompressionStreamFallback&&i.CompressionStreamZlib&&(i.CompressionStreamFallback=i.CompressionStreamZlib),!i.DecompressionStreamFallback&&i.DecompressionStreamZlib&&(i.DecompressionStreamFallback=i.DecompressionStreamZlib);const a={highWaterMark:1},l=t.readable||new y({async pull(t){const e=new w(t=>Yt.set(oe,t));ie({type:"pull",messageId:oe}),oe=(oe+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await e;t.enqueue(s),r&&t.close()}},a);o=t.writable||new m({async write(t){let e;const s=new w(t=>e=t);Zt.set(oe,e),ie({type:Nt,value:t,messageId:oe}),oe=(oe+1)%n.MAX_SAFE_INTEGER,await s}},a),e=new Jt(c,i),$t=new AbortController;const{signal:u}=$t;await l.pipeThrough(e).pipeThrough(new Qt((t=>s.max(t.chunkSize,64))(i))).pipeTo(o,{signal:u,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{crc32:h,inputSize:p,outputSize:d}=e;ie({type:qt,result:{crc32:h,inputSize:p,outputSize:d}})}catch(t){if(t.outputSize=e?e.outputSize:0,o&&!o.locked)try{await o.getWriter().close()}catch{}ae(t)}}function ie(t){const{value:e}=t;if(e)if(e.length)try{t.value=(n=e,n.byteOffset||n.byteLength!=n.buffer.byteLength?new o(n):n).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var n}function ae(t=new r("Unknown error")){const{message:e,stack:n,code:s,name:o,outputSize:c,cause:i,codecImportFailed:a}=t,f={message:e,stack:n,code:s,name:o,outputSize:c};i&&(f.cause={name:i.name,message:i.message}),a&&(f.codecImportFailed=!0),p({error:f})}function fe(t,e,n={}){if(!te){const t=new r("WASM module not loaded");throw t.cause=re,t}const c="number"==typeof n.level?n.level:-1,i="number"==typeof n.outBuffer?n.outBuffer:65536,a="number"==typeof n.inBufferSize?n.inBufferSize:65536;return new d({start(){try{let n;if(this.ft=ee(i),this.in=ee(a),this.inBufferSize=a,!this.ft||!this.in)throw new r("allocation failed");if(this.lt=new o(i),t?(this.wt=te.deflate_process,this.ut=te.deflate_last_consumed,this.ht=te.deflate_end,this.yt=te.deflate_new(),n="gzip"===e?te.deflate_init_gzip(this.yt,c):"deflate-raw"===e?te.deflate_init_raw(this.yt,c):te.deflate_init(this.yt,c)):"deflate64-raw"===e?(this.wt=te.inflate9_process,this.ut=te.inflate9_last_consumed,this.ht=te.inflate9_end,this.yt=te.inflate9_new(),n=te.inflate9_init_raw(this.yt)):(this.wt=te.inflate_process,this.ut=te.inflate_last_consumed,this.ht=te.inflate_end,this.yt=te.inflate_new(),n="deflate-raw"===e?te.inflate_init_raw(this.yt):"gzip"===e?te.inflate_init_gzip(this.yt):te.inflate_init(this.yt)),0!==n)throw new r("init failed:"+n)}catch(t){throw f(this),t}},transform(e,n){try{const c=e,a=new o(se.buffer),f=this.wt,l=this.ut,w=this.ft,u=this.lt;let h=0;for(;h<c.length;){const e=s.min(c.length-h,32768);if((!this.in||this.inBufferSize<e)&&(this.in&&ne&&(ne(this.in),this.in=0),this.in=ee(e),this.inBufferSize=e,!this.in))throw new r("allocation failed");a.set(c.subarray(h,h+e),this.in);const o=f(this.yt,this.in,e,w,i,0),p=16777215&o;if(p&&(u.set(a.subarray(w,w+p),0),n.enqueue(u.slice(0,p))),!t){const t=o>>24&255,e=128&t?t-256:t;if(0>e)throw new r("process error:"+e)}const d=l(this.yt);if(0===d)break;h+=d}}catch(t){f(this),n.error(t)}},flush(e){try{const n=new o(se.buffer),s=this.wt,c=this.ft,a=this.lt;for(;;){const o=s(this.yt,0,0,c,i,4),f=16777215&o,l=o>>24&255;if(!t){const t=128&l?l-256:l;if(0>t)throw new r("process error:"+t)}if(f&&(a.set(n.subarray(c,c+f),0),e.enqueue(a.slice(0,f))),1===l||0===f)break}}catch(t){e.error(t)}finally{const t=f(this);0!==t&&e.error(new r("end error:"+t))}},cancel(){f(this)}});function f(t){let e=0;return t.yt&&t.ht&&(e=t.ht(t.yt)),t.yt=0,t.in&&ne&&ne(t.in),t.in=0,t.ft&&ne&&ne(t.ft),t.ft=0,e}}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:s,done:r}=t;try{if("start"==e&&ce(t),e==Nt){const t=Yt.get(n);Yt.delete(n),t({value:s||new o,done:r})}if("ack"==e){const t=Zt.get(n);Zt.delete(n),t()}e==qt&&$t.abort()}catch(t){ae(t)}}),p({type:"ready"});class le{constructor(t="deflate",e){return fe(!0,t,e)}}class we{constructor(t="deflate",e){return fe(!1,t,e)}}le.St=!0,we.St=!0;let ue=!1;((t={})=>{const{init:e}=t,n=t.CompressionStreamFallback||t.CompressionStreamZlib,s=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{e&&await e(t),n&&(t.CompressionStreamFallback=n),s&&(t.DecompressionStreamFallback=s)}})({CompressionStreamFallback:le,DecompressionStreamFallback:we,init:t=>(async(t,{baseURI:e})=>{if(!ue)try{await(async(t,e)=>{let n,s;try{try{s=new URL(t,e)}catch{}const r=await fetch(s);n=await r.arrayBuffer()}catch(e){if(!t.startsWith("data:application/wasm;base64,"))throw e;n=(t=>{const e=t.split(",")[1],n=atob(e),s=n.length,r=new o(s);for(let t=0;s>t;++t)r[t]=n.charCodeAt(t);return r.buffer})(t)}(t=>{if(te=t,({malloc:ee,free:ne,memory:se}=te),"function"!=typeof ee||"function"!=typeof ne||!se)throw te=ee=ne=se=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports)})(t,e),ue=!0}catch(t){throw(t=>{re=t})(t),t}})(t.wasmURI,t)})});\n';if("string"==typeof s&&(s=(new TextEncoder).encode(s)),t){const t=new Blob([s],{type:n});return URL.createObjectURL(t)}return "data:"+n+";base64,"+(t=>{let n="";const s=t.length;let r=0;for(;s>r+2;r+=3){const s=t[r]<<16|t[r+1]<<8|t[r+2];n+=e[s>>18&63]+e[s>>12&63]+e[s>>6&63]+e[63&s];}const o=s-r;if(1===o){const s=t[r]<<16;n+=e[s>>18&63]+e[s>>12&63]+"==";}else if(2===o){const s=t[r]<<16|t[r+1]<<8;n+=e[s>>18&63]+e[s>>12&63]+e[s>>6&63]+"=";}return n})(s)}});
395
+ const t$1=new Uint8Array(288);t$1.fill(8,0,144),t$1.fill(9,144,256),t$1.fill(7,256,280),t$1.fill(8,280,288),new Uint8Array(30).fill(5);const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n$1=t=>t({workerURI:t=>{const n="text/javascript";let s='(t=>{"function"==typeof define&&define.amd?define(t):t()})(function(){"use strict";const{Array:t,Object:e,Number:n,Math:s,Error:r,Uint8Array:o,Uint16Array:c,Uint32Array:i,Int32Array:a,Map:f,DataView:l,Promise:u,TextEncoder:w,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,b="undefined",k="function",z=new o,C=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;C[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=C[e-1][t];C[e][t]=n>>>8^C[0][255&n]}const[I,A,x,M,P,D,F,B]=C;class R{constructor(t){this.o=t||-1}append(t){let e=0|this.o;const n=0|t.length;let s=0;if(n>=8&&t.buffer){const r=new l(t.buffer,t.byteOffset,n),o=n-8;for(;o>=s;s+=8){const t=e^r.getInt32(s,!0),n=r.getInt32(s+4,!0);e=B[255&t]^F[t>>>8&255]^D[t>>>16&255]^P[t>>>24&255]^M[255&n]^x[n>>>8&255]^A[n>>>16&255]^I[n>>>24&255]}}for(;n>s;s++)e=e>>>8^I[255&(e^t[s])];this.o=e}get(){return~this.o}}class U extends d{constructor(){let t;const e=new R;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new l(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}function W(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function _(t){return new l(t.buffer,t.byteOffset,t.byteLength)}const T={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=T.l(n);return 32===s?t.concat(e):T.h(e,s,0|n,t.slice(0,t.length-1))},bitLength(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+T.l(n)},m(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,s.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=T.S(e,t[n-1]&2147483648>>e-1,1)),t},S:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,l:t=>s.round(t/1099511627776)||32,h(t,e,n,s){for(void 0===s&&(s=[]);e>=32;e-=32)s.push(n),n=0;if(0===e)return s.concat(t);for(let r=0;r<t.length;r++)s.push(n|t[r]>>>e),n=t[r]<<32-e;const r=t.length?t[t.length-1]:0,o=T.l(r);return s.push(T.S(e+o&31,e+o>32?n:s.pop(),1)),s}},V={bytes:{v(t){const e=T.bitLength(t)/8,n=new o(e);let s;for(let r=0;e>r;r++)3&r||(s=t[r/4]),n[r]=s>>>24,s<<=8;return n},C(t){const e=[];let n,s=0;for(n=0;n<t.length;n++)s=s<<8|t[n],3&~n||(e.push(s),s=0);return 3&n&&e.push(T.S(8*(3&n),s)),e}}},K=class{constructor(t){const e=this;e.blockSize=512,e.I=[1732584193,4023233417,2562383102,271733878,3285377520],e.A=[1518500249,1859775393,2400959708,3395469782],t?(e.M=t.M.slice(0),e.P=t.P.slice(0),e.D=t.D):e.reset()}reset(){const t=this;return t.M=t.I.slice(0),t.P=[],t.D=0,t}update(t){const e=this;"string"==typeof t&&(t=V.F.C(t));const n=e.P=T.concat(e.P,t),s=e.D,o=e.D=s+T.bitLength(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const c=new i(n);let a=0;for(let t=e.blockSize+s-(e.blockSize+s&e.blockSize-1);o>=t;t+=e.blockSize)e.B(c.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),e}R(){const t=this;let e=t.P;const n=t.M;e=T.concat(e,[T.S(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(s.floor(t.D/4294967296)),e.push(0|t.D);e.length;)t.B(e.splice(0,16));return t.reset(),n}U(t,e,n,s){return t>19?t>39?t>59?t>79?void 0:e^n^s:e&n|e&s|n&s:e^n^s:e&n|~e&s}W(t,e){return e<<t|e>>>32-t}B(e){const n=this,r=n.M,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let c=r[0],i=r[1],a=r[2],f=r[3],l=r[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.W(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.W(5,c)+n.U(t,i,a,f)+l+o[t]+n.A[s.floor(t/20)]|0;l=f,f=a,a=n.W(30,i),i=c,c=e}r[0]=r[0]+c|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+f|0,r[4]=r[4]+l|0}},E={importKey:t=>new E._(V.bytes.C(t)),T(t,e,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const o=1+(s>>5)<<2;let c,i,a,f,u;const w=new ArrayBuffer(o),h=new l(w);let p=0;const d=T;for(e=V.bytes.C(e),u=1;(o||1)>p;u++){for(c=i=t.encrypt(d.concat(e,[u])),a=1;n>a;a++)for(i=t.encrypt(i),f=0;f<i.length;f++)c[f]^=i[f];for(a=0;(o||1)>p&&a<c.length;a++)h.setInt32(p,c[a]),p+=4}return w.slice(0,s/8)},_:class{constructor(t){const e=this,n=e.V=K,s=[[],[]];e.K=[new n,new n];const r=e.K[0].blockSize/32;t.length>r&&(t=(new n).update(t).R());for(let e=0;r>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e.K[0].update(s[0]),e.K[1].update(s[1]),e.L=new n(e.K[0])}reset(){const t=this;t.L=new t.V(t.K[0]),t.O=!1}update(t){this.O=!0,this.L.update(t)}digest(){const t=this,e=t.L.R(),n=new t.V(t.K[1]).update(e).R();return t.reset(),n}encrypt(t){if(this.O)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},L=typeof h!=b&&typeof h.getRandomValues==k,O="Invalid password",j="Invalid signature",H=j,N="zipjs-abort-check-password";function q(t){if(L)return h.getRandomValues(t);throw new r("Crypto API not supported")}const G=16,J={name:"PBKDF2"},Q=e.assign({hash:{name:"HMAC"}},J),X=e.assign({iterations:1e3,hash:{name:"SHA-1"}},J),Y=["deriveBits"],Z=[8,12,16],$=[16,24,32],tt=10,et=[0,0,0,0],nt=typeof h!=b,st=nt&&h.subtle,rt=nt&&typeof st!=b,ot=V.bytes,ct=class{constructor(t){const e=this;e.j=[[[],[],[],[],[]],[[],[],[],[],[]]],e.j[0][0][0]||e.H();const n=e.j[0][4],s=e.j[1],o=t.length;let c,i,a,f=1;if(4!==o&&6!==o&&8!==o)throw new r("invalid aes key size");for(e.A=[i=t.slice(0),a=[]],c=o;4*o+28>c;c++){let t=i[c-1];(c%o===0||8===o&&c%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],c%o===0&&(t=t<<8^t>>>24^f<<24,f=f<<1^283*(f>>7))),i[c]=i[c-o]^t}for(let t=0;c;t++,c--){const e=i[3&t?c:c-4];a[t]=4>=c||4>t?e:s[0][n[e>>>24]]^s[1][n[e>>16&255]]^s[2][n[e>>8&255]]^s[3][n[255&e]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}H(){const t=this.j[0],e=this.j[1],n=t[4],s=e[4],r=[],o=[];let c,i,a,f;for(let t=0;256>t;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let l=c=0;!n[l];l^=i||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,n[l]=o,s[o]=l,f=r[a=r[i=r[l]]];let u=16843009*f^65537*a^257*i^16843008*l,w=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][l]=w=w<<24^w>>>8,e[n][o]=u=u<<24^u>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}N(t,e){if(4!==t.length)throw new r("invalid aes block size");const n=this.A[e],s=n.length/4-2,o=[0,0,0,0],c=this.j[e],i=c[0],a=c[1],f=c[2],l=c[3],u=c[4];let w,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],S=t[e?1:3]^n[3],g=4;for(let t=0;s>t;t++)w=i[d>>>24]^a[y>>16&255]^f[m>>8&255]^l[255&S]^n[g],h=i[y>>>24]^a[m>>16&255]^f[S>>8&255]^l[255&d]^n[g+1],p=i[m>>>24]^a[S>>16&255]^f[d>>8&255]^l[255&y]^n[g+2],S=i[S>>>24]^a[d>>16&255]^f[y>>8&255]^l[255&m]^n[g+3],g+=4,d=w,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=u[d>>>24]<<24^u[y>>16&255]<<16^u[m>>8&255]<<8^u[255&S]^n[g++],w=d,d=y,y=m,m=S,S=w;return o}},it=class{constructor(t,e){this.G=t,this.J=e,this.X=e}reset(){this.X=this.J}update(t){return this.Y(this.G,t,this.X)}Z(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,s=255&t;255===e?(e=0,255===n?(n=0,255===s?s=0:++s):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=s}return t}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,e,n){let s;if(!(s=e.length))return[];const r=T.bitLength(e);for(let r=0;s>r;r+=4){this.$(n);const s=t.encrypt(n);e[r]^=s[0],e[r+1]^=s[1],e[r+2]^=s[2],e[r+3]^=s[3]}return T.m(e,r)}},at=E._;let ft=nt&&rt&&typeof st.importKey==k,lt=nt&&rt&&typeof st.deriveBits==k;class ut extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:s,checkAuthenticationCode:c=!0}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:i,et:a,ready:f}=n;c?(await(async(t,e,n,s)=>{const o=await dt(t,e,n,mt(s,0,Z[e])),c=mt(s,Z[e]);if(o[0]!=c[0]||o[1]!=c[1])throw new r(O)})(n,i,c,mt(t,0,Z[i]+2)),t=mt(t,Z[i]+2),s?e.error(new r(N)):a()):await f;const l=new o(t.length-tt-(t.length-tt)%G);e.enqueue(pt(n,t,l,0,tt,!0))},async flush(t){const{nt:e,st:n,ot:s,ready:o}=this;if(n&&e){await o;const i=mt(s,0,s.length-tt),a=mt(s,s.length-tt);let f=z;if(i.length){const t=gt(ot,i);n.update(t);const s=e.update(t);f=St(ot,s)}const l=mt(St(ot,n.digest()),0,tt);let u=s.length<tt?1:0;for(let t=0;tt>t;t++)u|=l[t]^a[t];if(u&&c)throw new r(H);t.enqueue(f)}}})}}class wt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:s,strength:r,et:c,ready:i}=n;let a=z;s?(a=await(async(t,e,n)=>{const s=q(new o(Z[e]));return W(s,await dt(t,e,n,s))})(n,r,s),c()):await i;const f=new o(a.length+t.length-t.length%G);f.set(a,0),e.enqueue(pt(n,t,f,a.length,0))},async flush(t){const{nt:e,st:n,ot:s,ready:r}=this;if(n&&e){await r;let o=z;if(s.length){const t=e.update(gt(ot,s));n.update(t),o=St(ot,t)}const c=St(ot,n.digest()).slice(0,tt);t.enqueue(W(o,c))}}})}}function ht(t,n,s,r){e.assign(t,{ready:new u(e=>t.et=e),password:yt(n,s),strength:r-1,ot:z})}function pt(t,e,n,s,r,c){const{nt:i,st:a,ot:f}=t;f.length&&(e=W(f,e));const l=e.length-r;let u;for(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,s+(l-l%G)),u=0;l-G>=u;u+=G){const t=gt(ot,mt(e,u,u+G));c&&a.update(t);const r=i.update(t);c||a.update(r),n.set(St(ot,r),u+s)}return t.ot=mt(e,u),n}async function dt(n,s,r,c){n.password=null;const i=await(async(t,e,n,s,r)=>{if(!ft)return E.importKey(e);try{return await st.importKey("raw",e,n,!1,r)}catch{return ft=!1,E.importKey(e)}})(0,r,Q,0,Y),a=await(async(t,e,n)=>{if(!lt)return E.T(e,t.salt,X.iterations,n);try{return await st.deriveBits(t,e,n)}catch{return lt=!1,E.T(e,t.salt,X.iterations,n)}})(e.assign({salt:c},X),i,8*(2*$[s]+2)),f=new o(a),l=gt(ot,mt(f,0,$[s])),u=gt(ot,mt(f,$[s],2*$[s])),w=mt(f,2*$[s]);return e.assign(n,{keys:{key:l,ct:u,passwordVerification:w},nt:new it(new ct(l),t.from(et)),st:new at(u)}),w}function yt(t,e){return e===v?(t=>{if(typeof w==b){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new w).encode(t)})(t):e}function mt(t,e,n){return t.subarray(e,n)}function St(t,e){return t.v(e)}function gt(t,e){return t.C(e)}class vt extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){kt(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=zt(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e[11]^n.passwordVerification))throw new r(O);t=t.subarray(12)}s?e.error(new r(N)):e.enqueue(zt(n,t))}})}}class bt extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){kt(this,t,e,n)},transform(t,e){const n=this;let s,r;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=q(new o(12));e[11]=n.passwordVerification,s=new o(t.length+e.length),s.set(Ct(n,e),0),r=12}else s=new o(t.length),r=0;s.set(Ct(n,t),r),e.enqueue(s)}})}}function kt(t,n,s,r){e.assign(t,{password:n,rawPassword:s,passwordVerification:r}),((t,n,s)=>{const r=[305419896,591751049,878082192];if(e.assign(t,{keys:r,it:new R(r[0]),ft:new R(r[2])}),s)for(let e=0;e<s.length;e++)It(t,s[e]);else for(let e=0;e<n.length;e++)It(t,n.charCodeAt(e))})(t,n,s)}function zt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=At(t)^e[s],It(t,n[s]);return n}function Ct(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=At(t)^e[s],It(t,e[s]);return n}function It(t,e){let[,n]=t.keys;t.it.append([e]);const r=~t.it.get();n=Mt(s.imul(Mt(n+xt(r)),134775813)+1),t.ft.append([n>>>24]);const o=~t.ft.get();t.keys=[r,n,o]}function At(t){const e=2|t.keys[2];return xt(s.imul(e,1^e)>>>8)}function xt(t){return 255&t}function Mt(t){return 4294967295&t}function Pt(t){if(t instanceof y)return t;const e=t.getReader();return new y({async pull(t){const{value:n,done:s}=await e.read();s?t.close():t.enqueue(n)},cancel:t=>e.cancel(t)})}const Dt=new f;function Ft(t){return Dt.get(t)}const Bt="Invalid uncompressed size",Rt=j,Ut="deflate-raw",Wt="gzip",_t=[31,139,8];class Tt extends d{constructor(t,{chunkSize:e,CompressionStreamFallback:n,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:c,zipCrypto:i,computeCrc32:a,level:f,deflate64:u,format:w,compressionMethod:h}=t,p=this;let d,y,m,S=super.readable;const g=w&&Ft(w),v=a&&r&&!u&&!g&&(!o||i)&&!(!c||!s);if(o&&!i||!a||v||(d=new U,S=Ht(S,d)),r)if(g)S=Nt(S,Ot(g.CompressionStream,w,{level:f,chunkSize:e,compressionMethod:h}));else if(v)m=new Vt,S=Nt(S,new s(Wt)),S=Ht(S,m);else try{S=jt(S,c,{level:f,chunkSize:e},s,n)}catch(t){let e;try{e=new s(Wt)}catch{throw t}S=Nt(S,e),S=Ht(S,new Vt)}o&&(i?S=Ht(S,new bt(t)):(y=new wt(t),S=Ht(S,y))),Lt(p,S,()=>{o&&!i||!a||(p.crc32=v?m.crc32:new l(d.value.buffer).getUint32(0))})}}class Vt extends d{constructor(){let t,e=10,n=new o(0);super({transform(t,r){if(e){const n=s.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const o=n.length+t.length;if(8>=o)return void(n=W(n,t));const c=o-8,i=s.min(c,n.length);r.enqueue(W(n.subarray(0,i),t.subarray(0,c-i))),n=W(n.subarray(i),t.subarray(c-i))},flush(){const e=_(n);t.crc32=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Kt extends d{constructor(t,{chunkSize:e,DecompressionStreamFallback:n,DecompressionStream:s}){super({});const{zipCrypto:c,encrypted:i,checkCrc32:a,crc32:f,compressed:w,useCompressionStream:h,deflate64:p,format:m,compressionMethod:S,rawBitFlag:g,outputSize:b}=t;let k,z,C=super.readable;if(i&&(c?C=Ht(C,new vt(t)):(z=new ut(t),C=Ht(C,z))),w){const t=m&&Ft(m);if(t)C=Nt(C,Ot(t.DecompressionStream,m,{chunkSize:e,compressionMethod:S,rawBitFlag:g,uncompressedSize:b}));else try{C=jt(C,h,{chunkSize:e,deflate64:p},s,n)}catch(t){if(p||b===v)throw t;let e;try{e=new s(Wt)}catch{throw t}C=((t,e,n)=>{const s=new R;let c,i,a,f=0,l=!1;const w=new u((t,e)=>{i=t,a=e});w.catch(()=>{}),n||i();const h=new d({start(t){const e=new o(10);e.set(_t),t.enqueue(e)},transform(t,e){e.enqueue(t)},async flush(t){l=!0,y();try{await w}finally{m()}const e=new o(8),r=_(e);r.setUint32(0,s.get(),!0),r.setUint32(4,n,!0),t.enqueue(e)},cancel(t){a(t)}}),p=new d({transform(t,e){s.append(t),f+=t.length,n>f?l&&y():i(),e.enqueue(t)},cancel(t){a(t)}});return t=Ht(t,h),Ht(t=Nt(t,e),p);function y(){m(),c=setTimeout(()=>a(new r(Bt)),5e3)}function m(){clearTimeout(c)}})(C,e,b)}C=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new r("Invalid compressed data");throw e.cause=t,e}const{value:s,done:o}=n;o?t.close():t.enqueue(s)},cancel:t=>e.cancel(t)})})(C)}a&&(k=new U,C=Ht(C,k)),Lt(this,C,()=>{if(a){const t=new l(k.value.buffer);if(f!=t.getUint32(0,!1))throw new r(Rt)}})}}const Et=new f;function Lt(t,n,s){n=Ht(n,new d({flush:s})),e.defineProperty(t,"readable",{get:()=>n})}function Ot(t,e,n){if(!t)throw new r("Compression method not supported");return new t(e,n)}function jt(t,e,n,s,r){const o=e&&s?s:r||s,c=n.deflate64?"deflate64-raw":Ut;let i;try{i=new o(c,n)}catch(t){if(!e||!r||o==r)throw t;i=new r(c,n)}return Nt(t,i)}function Ht(t,e){return Pt(t).pipeThrough(e)}function Nt(t,e){const n=e.writable.getWriter(),s=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await s.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(s,t)}})(),e.readable}const qt="data",Gt="close",Jt="deflate";class Qt extends d{constructor(t,n){super({});const s=this,{codecType:o}=t;let c;o.startsWith(Jt)?c=Tt:o.startsWith("inflate")&&(c=Kt),s.outputSize=0;let i=0;const a=new c(t,n),f=super.readable,l=new d({transform(t,e){t&&t.length&&(i+=t.length,e.enqueue(t))},flush(){e.assign(s,{inputSize:i})}}),u=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),s.outputSize+=e.length,t.outputSize!==v&&s.outputSize>t.outputSize))throw new r(Bt)},flush(){const{crc32:t}=a;e.assign(s,{crc32:t,inputSize:i})}});e.defineProperty(s,"readable",{get:()=>f.pipeThrough(l).pipeThrough(a).pipeThrough(u)})}}class Xt extends d{constructor(t){const e=[];let s=0;function r(){const n=new o(t);let r=0;for(;t>r;){const s=e[0],o=t-r;s.length>o?(n.set(s.subarray(0,o),r),e[0]=s.subarray(o),r+=o):(n.set(s,r),r+=s.length,e.shift())}return s-=t,n}n.isFinite(t)&&t>=1||(t=65536),super({transform(n,o){for(e.push(n),s+=n.length;s>t;)o.enqueue(r())},flush(t){s&&t.enqueue(((t,e)=>{const n=new o(e);let s=0;for(const e of t)n.set(e,s),s+=e.length;return n})(e,s))}})}}let Yt=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(Yt=navigator.hardwareConcurrency)}catch{}const Zt=new f,$t=new f;let te,ee,ne,se,re,oe,ce=0;async function ie(t){let e,o;try{const{options:c,config:i}=t;if(c.format)try{await(async(t,e)=>{!Dt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:s}=e;if(typeof n!=k&&typeof s!=k)throw new r("Invalid codec module");Dt.set(t,{CompressionStream:n,DecompressionStream:s})})(t,await(import(e)))})(c.format,c.codecURI)}catch(t){throw t.codecImportFailed=!0,t}if(i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,c.compressed&&!c.format)if(c.useCompressionStream){if(!((t,e)=>{if(!t)return!1;let n=Et.get(t);n||(n=new f,Et.set(t,n));let s=n.get(e);if(s===v){try{new t(e),s=!0}catch{s=!1}n.set(e,s)}return s})(c.codecType.startsWith(Jt)?i.CompressionStream:i.DecompressionStream,Ut))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{c.useCompressionStream=!0}!i.CompressionStreamFallback&&i.CompressionStreamZlib&&(i.CompressionStreamFallback=i.CompressionStreamZlib),!i.DecompressionStreamFallback&&i.DecompressionStreamZlib&&(i.DecompressionStreamFallback=i.DecompressionStreamZlib);const a={highWaterMark:1},l=t.readable?Pt(t.readable):new y({async pull(t){const e=new u(t=>Zt.set(ce,t));ae({type:"pull",messageId:ce}),ce=(ce+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await e;t.enqueue(s),r&&t.close()}},a);o=t.writable?(t=>{if(t instanceof m)return t;const e=t.getWriter();return new m({write:t=>e.write(t),close:()=>e.close(),abort:t=>e.abort(t)})})(t.writable):new m({async write(t){let e;const s=new u(t=>e=t);$t.set(ce,e),ae({type:qt,value:t,messageId:ce}),ce=(ce+1)%n.MAX_SAFE_INTEGER,await s}},a),e=new Qt(c,i),te=new AbortController;const{signal:w}=te;await l.pipeThrough(e).pipeThrough(new Xt((t=>{return r="string"==typeof(e=r=t.chunkSize)&&e.trim()?n(e):e,n.isInteger(r)&&r>=1?s.max(r,64):65536;var e,r})(i))).pipeTo(o,{signal:w,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{crc32:h,inputSize:p,outputSize:d}=e;ae({type:Gt,result:{crc32:h,inputSize:p,outputSize:d}})}catch(t){if(t.outputSize=e?e.outputSize:0,o&&!o.locked)try{await o.getWriter().close()}catch{}fe(t)}}function ae(t){const{value:e}=t;if(e)if(e.length)try{t.value=(n=e,n.byteOffset||n.byteLength!=n.buffer.byteLength?new o(n):n).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var n}function fe(t=new r("Unknown error")){const{message:e,stack:n,code:s,name:o,outputSize:c,cause:i,codecImportFailed:a}=t,f={message:e,stack:n,code:s,name:o,outputSize:c};i&&(f.cause={name:i.name,message:i.message}),a&&(f.codecImportFailed=!0),p({error:f})}function le(t,e,n={}){if(!ee){const t=new r("WASM module not loaded");throw t.cause=oe,t}const c="number"==typeof n.level?n.level:-1,i="number"==typeof n.outBuffer?n.outBuffer:65536,a="number"==typeof n.inBufferSize?n.inBufferSize:65536;return new d({start(){try{let n;if(this.lt=ne(i),this.in=ne(a),this.inBufferSize=a,!this.lt||!this.in)throw new r("allocation failed");if(this.ut=new o(i),t?(this.wt=ee.deflate_process,this.ht=ee.deflate_last_consumed,this.yt=ee.deflate_end,this.St=ee.deflate_new(),n="gzip"===e?ee.deflate_init_gzip(this.St,c):"deflate-raw"===e?ee.deflate_init_raw(this.St,c):ee.deflate_init(this.St,c)):"deflate64-raw"===e?(this.wt=ee.inflate9_process,this.ht=ee.inflate9_last_consumed,this.yt=ee.inflate9_end,this.St=ee.inflate9_new(),n=ee.inflate9_init_raw(this.St)):(this.wt=ee.inflate_process,this.ht=ee.inflate_last_consumed,this.yt=ee.inflate_end,this.St=ee.inflate_new(),n="deflate-raw"===e?ee.inflate_init_raw(this.St):"gzip"===e?ee.inflate_init_gzip(this.St):ee.inflate_init(this.St)),0!==n)throw new r("init failed:"+n)}catch(t){throw f(this),t}},transform(e,n){try{const c=e,a=new o(re.buffer),f=this.wt,l=this.ht,u=this.lt,w=this.ut;let h=0;for(;h<c.length;){const e=s.min(c.length-h,32768);if((!this.in||this.inBufferSize<e)&&(this.in&&se&&(se(this.in),this.in=0),this.in=ne(e),this.inBufferSize=e,!this.in))throw new r("allocation failed");a.set(c.subarray(h,h+e),this.in);const o=f(this.St,this.in,e,u,i,0),p=16777215&o;if(p&&(w.set(a.subarray(u,u+p),0),n.enqueue(w.slice(0,p))),!t){const t=o>>24&255,e=128&t?t-256:t;if(0>e)throw new r("process error:"+e)}const d=l(this.St);if(0===d)break;h+=d}}catch(t){f(this),n.error(t)}},flush(e){try{const n=new o(re.buffer),s=this.wt,c=this.lt,a=this.ut;for(;;){const o=s(this.St,0,0,c,i,4),f=16777215&o,l=o>>24&255;if(!t){const t=128&l?l-256:l;if(0>t)throw new r("process error:"+t)}if(f&&(a.set(n.subarray(c,c+f),0),e.enqueue(a.slice(0,f))),1===l||0===f)break}}catch(t){e.error(t)}finally{const t=f(this);0!==t&&e.error(new r("end error:"+t))}},cancel(){f(this)}});function f(t){let e=0;return t.St&&t.yt&&(e=t.yt(t.St)),t.St=0,t.in&&se&&se(t.in),t.in=0,t.lt&&se&&se(t.lt),t.lt=0,e}}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:s,done:r}=t;try{if("start"==e&&ie(t),e==qt){const t=Zt.get(n);Zt.delete(n),t({value:s||new o,done:r})}if("ack"==e){const t=$t.get(n);$t.delete(n),t()}e==Gt&&te.abort()}catch(t){fe(t)}}),p({type:"ready"});class ue{constructor(t="deflate",e){return le(!0,t,e)}}class we{constructor(t="deflate",e){return le(!1,t,e)}}ue.gt=!0,we.gt=!0;let he=!1;((t={})=>{const{init:e}=t,n=t.CompressionStreamFallback||t.CompressionStreamZlib,s=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{e&&await e(t),n&&(t.CompressionStreamFallback=n),s&&(t.DecompressionStreamFallback=s)}})({CompressionStreamFallback:ue,DecompressionStreamFallback:we,init:t=>(async(t,{baseURI:e})=>{if(!he)try{await(async(t,e)=>{let n,s;try{try{s=new URL(t,e)}catch{}const r=await fetch(s);n=await r.arrayBuffer()}catch(e){if(!t.startsWith("data:application/wasm;base64,"))throw e;n=(t=>{const e=t.split(",")[1],n=atob(e),s=n.length,r=new o(s);for(let t=0;s>t;++t)r[t]=n.charCodeAt(t);return r.buffer})(t)}(t=>{if(ee=t,({malloc:ne,free:se,memory:re}=ee),"function"!=typeof ne||"function"!=typeof se||!re)throw ee=ne=se=re=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports)})(t,e),he=!0}catch(t){throw(t=>{oe=t})(t),t}})(t.wasmURI,t)})});\n';if("string"==typeof s&&(s=(new TextEncoder).encode(s)),t){const t=new Blob([s],{type:n});return URL.createObjectURL(t)}return "data:"+n+";base64,"+(t=>{let n="";const s=t.length;let r=0;for(;s>r+2;r+=3){const s=t[r]<<16|t[r+1]<<8|t[r+2];n+=e[s>>18&63]+e[s>>12&63]+e[s>>6&63]+e[63&s];}const o=s-r;if(1===o){const s=t[r]<<16;n+=e[s>>18&63]+e[s>>12&63]+"==";}else if(2===o){const s=t[r]<<16|t[r+1]<<8;n+=e[s>>18&63]+e[s>>12&63]+e[s>>6&63]+"=";}return n})(s)}});
250
396
 
251
397
  /*
252
398
  Copyright (c) 2026 Gildas Lormeau. All rights reserved.
@@ -1394,13 +1540,13 @@ class AESDecryptionStream extends TransformStream {
1394
1540
  const {
1395
1541
  ctr,
1396
1542
  hmac,
1397
- pending,
1543
+ pendingInput,
1398
1544
  ready
1399
1545
  } = this;
1400
1546
  if (hmac && ctr) {
1401
1547
  await ready;
1402
- const chunkToDecrypt = subarray(pending, 0, pending.length - AUTHENTICATION_CODE_LENGTH);
1403
- const originalAuthenticationCode = subarray(pending, pending.length - AUTHENTICATION_CODE_LENGTH);
1548
+ const chunkToDecrypt = subarray(pendingInput, 0, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
1549
+ const originalAuthenticationCode = subarray(pendingInput, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
1404
1550
  let decryptedChunkArray = EMPTY_UINT8_ARRAY;
1405
1551
  if (chunkToDecrypt.length) {
1406
1552
  const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
@@ -1409,7 +1555,7 @@ class AESDecryptionStream extends TransformStream {
1409
1555
  decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
1410
1556
  }
1411
1557
  const authenticationCode = subarray(fromBits(codecBytes, hmac.digest()), 0, AUTHENTICATION_CODE_LENGTH);
1412
- let invalidAuthenticationCode = pending.length < AUTHENTICATION_CODE_LENGTH ? 1 : 0;
1558
+ let invalidAuthenticationCode = pendingInput.length < AUTHENTICATION_CODE_LENGTH ? 1 : 0;
1413
1559
  for (let indexByte = 0; indexByte < AUTHENTICATION_CODE_LENGTH; indexByte++) {
1414
1560
  invalidAuthenticationCode |= authenticationCode[indexByte] ^ originalAuthenticationCode[indexByte];
1415
1561
  }
@@ -1453,14 +1599,14 @@ class AESEncryptionStream extends TransformStream {
1453
1599
  const {
1454
1600
  ctr,
1455
1601
  hmac,
1456
- pending,
1602
+ pendingInput,
1457
1603
  ready
1458
1604
  } = this;
1459
1605
  if (hmac && ctr) {
1460
1606
  await ready;
1461
1607
  let encryptedChunkArray = EMPTY_UINT8_ARRAY;
1462
- if (pending.length) {
1463
- const encryptedChunk = ctr.update(toBits(codecBytes, pending));
1608
+ if (pendingInput.length) {
1609
+ const encryptedChunk = ctr.update(toBits(codecBytes, pendingInput));
1464
1610
  hmac.update(encryptedChunk);
1465
1611
  encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
1466
1612
  }
@@ -1477,7 +1623,7 @@ function initAesCrypto(aesCrypto, password, rawPassword, encryptionStrength) {
1477
1623
  ready: new Promise(resolve => aesCrypto.resolveReady = resolve),
1478
1624
  password: encodePassword(password, rawPassword),
1479
1625
  strength: encryptionStrength - 1,
1480
- pending: EMPTY_UINT8_ARRAY
1626
+ pendingInput: EMPTY_UINT8_ARRAY
1481
1627
  });
1482
1628
  }
1483
1629
 
@@ -1485,10 +1631,10 @@ function append(aesCrypto, input, output, paddingStart, paddingEnd, verifyAuthen
1485
1631
  const {
1486
1632
  ctr,
1487
1633
  hmac,
1488
- pending
1634
+ pendingInput
1489
1635
  } = aesCrypto;
1490
- if (pending.length) {
1491
- input = concat(pending, input);
1636
+ if (pendingInput.length) {
1637
+ input = concat(pendingInput, input);
1492
1638
  }
1493
1639
  const inputLength = input.length - paddingEnd;
1494
1640
  output = expand(output, paddingStart + (inputLength - (inputLength % BLOCK_LENGTH)));
@@ -1504,7 +1650,7 @@ function append(aesCrypto, input, output, paddingStart, paddingEnd, verifyAuthen
1504
1650
  }
1505
1651
  output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
1506
1652
  }
1507
- aesCrypto.pending = subarray(input, offset);
1653
+ aesCrypto.pendingInput = subarray(input, offset);
1508
1654
  return output;
1509
1655
  }
1510
1656
 
@@ -3281,6 +3427,96 @@ async function terminateWorkers() {
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 @@ class Reader extends Stream {
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 @@ class Reader extends Stream {
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 @@ class Data64URIWriter extends Writer {
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 @@ class BlobReader extends Reader {
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 @@ class BlobReader extends Reader {
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 @@ class BlobReader extends Reader {
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 @@ class BlobWriter extends Stream {
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
 
@@ -3580,7 +3817,7 @@ function getTextSize(text) {
3580
3817
  class TextWriter extends BlobWriter {
3581
3818
 
3582
3819
  constructor(encoding) {
3583
- super(encoding);
3820
+ super();
3584
3821
  Object.assign(this, {
3585
3822
  encoding,
3586
3823
  utf8: !encoding || encoding.toLowerCase() == "utf-8"
@@ -3596,14 +3833,7 @@ class TextWriter extends BlobWriter {
3596
3833
  if (blob.text && utf8) {
3597
3834
  return blob.text();
3598
3835
  } else {
3599
- const reader = new FileReader();
3600
- return new Promise((resolve, reject) => {
3601
- Object.assign(reader, {
3602
- onload: ({ target }) => resolve(target.result),
3603
- onerror: () => reject(reader.error)
3604
- });
3605
- reader.readAsText(blob, encoding);
3606
- });
3836
+ return decodeTextRemovingBOM(new Uint8Array(await blob.arrayBuffer()), encoding);
3607
3837
  }
3608
3838
  }
3609
3839
  }
@@ -4271,85 +4501,13 @@ function readUint8Array(reader, offset, size) {
4271
4501
  return reader.readUint8Array(offset, size);
4272
4502
  }
4273
4503
 
4274
- /*
4275
- Copyright (c) 2022 Gildas Lormeau. All rights reserved.
4276
-
4277
- Redistribution and use in source and binary forms, with or without
4278
- modification, are permitted provided that the following conditions are met:
4279
-
4280
- 1. Redistributions of source code must retain the above copyright notice,
4281
- this list of conditions and the following disclaimer.
4282
-
4283
- 2. Redistributions in binary form must reproduce the above copyright
4284
- notice, this list of conditions and the following disclaimer in
4285
- the documentation and/or other materials provided with the distribution.
4286
-
4287
- 3. The names of the authors may not be used to endorse or promote products
4288
- derived from this software without specific prior written permission.
4289
-
4290
- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
4291
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
4292
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
4293
- INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
4294
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4295
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
4296
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4297
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4298
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4299
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4300
- */
4301
-
4302
- /* global TextDecoder */
4303
-
4304
- const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
4305
- const VALID_CP437 = CP437.length == 256;
4306
-
4307
- function decodeCP437(stringValue) {
4308
- if (VALID_CP437) {
4309
- let result = "";
4310
- for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
4311
- result += CP437[stringValue[indexCharacter]];
4312
- }
4313
- return result;
4314
- } else {
4315
- return new TextDecoder().decode(stringValue);
4316
- }
4317
- }
4318
-
4319
- /*
4320
- Copyright (c) 2022 Gildas Lormeau. All rights reserved.
4321
-
4322
- Redistribution and use in source and binary forms, with or without
4323
- modification, are permitted provided that the following conditions are met:
4324
-
4325
- 1. Redistributions of source code must retain the above copyright notice,
4326
- this list of conditions and the following disclaimer.
4327
-
4328
- 2. Redistributions in binary form must reproduce the above copyright
4329
- notice, this list of conditions and the following disclaimer in
4330
- the documentation and/or other materials provided with the distribution.
4331
-
4332
- 3. The names of the authors may not be used to endorse or promote products
4333
- derived from this software without specific prior written permission.
4334
-
4335
- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
4336
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
4337
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
4338
- INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
4339
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4340
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
4341
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4342
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4343
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4344
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4345
- */
4346
-
4347
-
4348
- function decodeText(value, encoding) {
4349
- if (encoding && encoding.trim().toLowerCase() == "cp437") {
4350
- return decodeCP437(value);
4504
+ function createReadable(reader, options) {
4505
+ if (reader.createReadable) {
4506
+ return reader.createReadable(options);
4507
+ } else if (reader.readUint8Array) {
4508
+ return Reader.prototype.createReadable.call(reader, options);
4351
4509
  } else {
4352
- return new TextDecoder(encoding, { ignoreBOM: true }).decode(value);
4510
+ return reader.readable;
4353
4511
  }
4354
4512
  }
4355
4513
 
@@ -4509,83 +4667,6 @@ class Entry {
4509
4667
 
4510
4668
  }
4511
4669
 
4512
- /*
4513
- Copyright (c) 2022 Gildas Lormeau. All rights reserved.
4514
-
4515
- Redistribution and use in source and binary forms, with or without
4516
- modification, are permitted provided that the following conditions are met:
4517
-
4518
- 1. Redistributions of source code must retain the above copyright notice,
4519
- this list of conditions and the following disclaimer.
4520
-
4521
- 2. Redistributions in binary form must reproduce the above copyright
4522
- notice, this list of conditions and the following disclaimer in
4523
- the documentation and/or other materials provided with the distribution.
4524
-
4525
- 3. The names of the authors may not be used to endorse or promote products
4526
- derived from this software without specific prior written permission.
4527
-
4528
- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
4529
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
4530
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
4531
- INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
4532
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4533
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
4534
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4535
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4536
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4537
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4538
- */
4539
-
4540
- const OPTION_FILENAME_ENCODING = "filenameEncoding";
4541
- const OPTION_COMMENT_ENCODING = "commentEncoding";
4542
- const OPTION_DECODE_TEXT = "decodeText";
4543
- const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
4544
- const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
4545
- const OPTION_PASSWORD = "password";
4546
- const OPTION_RAW_PASSWORD = "rawPassword";
4547
- const OPTION_PASS_THROUGH = "passThrough";
4548
- const OPTION_SIGNAL = "signal";
4549
- const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
4550
- const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
4551
- const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
4552
- const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
4553
- const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
4554
- const OPTION_CHECK_SIGNATURE = "checkSignature";
4555
- const OPTION_CHECK_CRC32 = "checkCrc32";
4556
- const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
4557
- const OPTION_USE_WEB_WORKERS = "useWebWorkers";
4558
- const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
4559
- const OPTION_TRANSFER_STREAMS = "transferStreams";
4560
- const OPTION_PREVENT_CLOSE = "preventClose";
4561
- const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
4562
- const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
4563
- const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
4564
- const OPTION_KEEP_ORDER = "keepOrder";
4565
- const OPTION_LEVEL = "level";
4566
- const OPTION_BUFFERED_WRITE = "bufferedWrite";
4567
- const OPTION_CREATE_TEMP_STREAM = "createTempStream";
4568
- const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
4569
- const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
4570
- const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
4571
- const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
4572
- const OPTION_ENCODE_TEXT = "encodeText";
4573
- const OPTION_OFFSET = "offset";
4574
- const OPTION_USDZ = "usdz";
4575
- const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
4576
- const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
4577
- const OPTION_STRICTNESS = "strictness";
4578
- const OPTION_FILENAME_VALIDATION = "filenameValidation";
4579
- const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
4580
- const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
4581
- const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
4582
- const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
4583
- const TEXT_TYPE_FILENAME = "filename";
4584
- const TEXT_TYPE_COMMENT = "comment";
4585
- const STRICTNESS_STRICT = "strict";
4586
- const STRICTNESS_BALANCED = "balanced";
4587
- const STRICTNESS_TOLERANT = "tolerant";
4588
-
4589
4670
  /*
4590
4671
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
4591
4672
 
@@ -4626,6 +4707,7 @@ const ERR_UNSUPPORTED_ENCRYPTION = "Encryption method not supported";
4626
4707
  const ERR_UNSUPPORTED_COMPRESSION$1 = "Compression method not supported";
4627
4708
  const ERR_SPLIT_ZIP_FILE = "Split zip file";
4628
4709
  const ERR_OVERLAPPING_ENTRY = "Overlapping entry found";
4710
+ const ERR_ENTRY_DATA_OUT_OF_BOUNDS = "Entry data out of bounds";
4629
4711
  const ERR_AMBIGUOUS_ARCHIVE = "Ambiguous archive";
4630
4712
  const ERR_ENCRYPTED_CENTRAL_DIRECTORY = "Encrypted central directory is not supported";
4631
4713
  const ERR_UNSAFE_FILENAME = "Unsafe filename";
@@ -4646,7 +4728,7 @@ const ZIP64_PROPERTIES = [
4646
4728
  ];
4647
4729
  const ZIP64_EXTRACTION = {
4648
4730
  [MAX_16_BITS]: {
4649
- getValue: getUint32,
4731
+ getValue: getUint32$1,
4650
4732
  bytes: 4
4651
4733
  },
4652
4734
  [MAX_32_BITS]: {
@@ -4655,6 +4737,7 @@ const ZIP64_EXTRACTION = {
4655
4737
  }
4656
4738
  };
4657
4739
  const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
4740
+ const MAX_DEFLATE_EXPANSION_RATIO = 1032;
4658
4741
  const CENTRAL_DIRECTORY_UNREACHABLE = 0;
4659
4742
  const CENTRAL_DIRECTORY_PLAUSIBLE = 1;
4660
4743
  const CENTRAL_DIRECTORY_REACHABLE = 2;
@@ -4665,7 +4748,6 @@ class ZipReader {
4665
4748
  Object.assign(this, {
4666
4749
  reader: new GenericReader(reader),
4667
4750
  options,
4668
- config: getConfiguration(),
4669
4751
  readRanges: new Map()
4670
4752
  });
4671
4753
  }
@@ -4673,7 +4755,6 @@ class ZipReader {
4673
4755
  async* getEntriesGenerator(options = {}) {
4674
4756
  const zipReader = this;
4675
4757
  let { reader } = zipReader;
4676
- const { config } = zipReader;
4677
4758
  await initStream(reader);
4678
4759
  if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
4679
4760
  reader = new BlobReader(await streamToBlob(reader.readable));
@@ -4690,9 +4771,7 @@ class ZipReader {
4690
4771
  const normalizeFilename = getOptionValue$1(zipReader, options, OPTION_NORMALIZE_FILENAME);
4691
4772
  const { endOfDirectoryInfo, endOfDirectoryReachingEndCount } = await findEndOfCentralDirectory(reader, rejectAmbiguousEndOfDirectory, maxAppendedDataSize);
4692
4773
  if (!endOfDirectoryInfo) {
4693
- const signatureArray = await readUint8Array(reader, 0, 4);
4694
- const signatureView = getDataView(signatureArray);
4695
- if (getUint32(signatureView) == SPLIT_ZIP_FILE_SIGNATURE) {
4774
+ if (await startsWithSplitZipSignature$1(reader)) {
4696
4775
  throw new Error(ERR_SPLIT_ZIP_FILE);
4697
4776
  } else {
4698
4777
  throw new Error(ERR_EOCDR_NOT_FOUND);
@@ -4702,18 +4781,18 @@ class ZipReader {
4702
4781
  throwAmbiguousArchive("multiple end of central directory records");
4703
4782
  }
4704
4783
  const endOfDirectoryView = getDataView(endOfDirectoryInfo);
4705
- let directoryDataLength = getUint32(endOfDirectoryView, 12);
4706
- let directoryDataOffset = getUint32(endOfDirectoryView, 16);
4784
+ let directoryDataLength = getUint32$1(endOfDirectoryView, 12);
4785
+ let directoryDataOffset = getUint32$1(endOfDirectoryView, 16);
4707
4786
  const commentOffset = endOfDirectoryInfo.offset;
4708
- const commentLength = getUint16(endOfDirectoryView, 20);
4787
+ const commentLength = getUint16$1(endOfDirectoryView, 20);
4709
4788
  const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
4710
4789
  if (reader.size - appendedDataOffset > maxAppendedDataSize) {
4711
4790
  throwAmbiguousArchive("appended data");
4712
4791
  }
4713
- let lastDiskNumber = getUint16(endOfDirectoryView, 4);
4792
+ let lastDiskNumber = getUint16$1(endOfDirectoryView, 4);
4714
4793
  const expectedLastDiskNumber = reader.lastDiskNumber || 0;
4715
- let diskNumber = getUint16(endOfDirectoryView, 6);
4716
- let filesLength = getUint16(endOfDirectoryView, 10);
4794
+ let diskNumber = getUint16$1(endOfDirectoryView, 6);
4795
+ let filesLength = getUint16$1(endOfDirectoryView, 10);
4717
4796
  let prependedDataLength = 0;
4718
4797
  let startOffset;
4719
4798
  let zip64EndOfDirectory;
@@ -4729,12 +4808,12 @@ class ZipReader {
4729
4808
  EMPTY_UINT8_ARRAY;
4730
4809
  const endOfDirectoryLocatorView = getDataView(endOfDirectoryLocatorArray);
4731
4810
  if (endOfDirectoryLocatorArray.length == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH &&
4732
- getUint32(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
4733
- directoryDataOffset = getDiskOffset$1(reader, getUint32(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
4811
+ getUint32$1(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
4812
+ directoryDataOffset = getDiskOffset$1(reader, getUint32$1(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
4734
4813
  let endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
4735
4814
  let endOfDirectoryView = getDataView(endOfDirectoryArray);
4736
4815
  const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH - ZIP64_END_OF_CENTRAL_DIR_LENGTH;
4737
- if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
4816
+ if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
4738
4817
  directoryDataOffset != expectedDirectoryDataOffset && expectedDirectoryDataOffset >= 0) {
4739
4818
  const originalDirectoryDataOffset = directoryDataOffset;
4740
4819
  directoryDataOffset = expectedDirectoryDataOffset;
@@ -4744,7 +4823,7 @@ class ZipReader {
4744
4823
  endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
4745
4824
  endOfDirectoryView = getDataView(endOfDirectoryArray);
4746
4825
  }
4747
- if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
4826
+ if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
4748
4827
  throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
4749
4828
  }
4750
4829
  zip64EndOfDirectory = true;
@@ -4759,13 +4838,13 @@ class ZipReader {
4759
4838
  }
4760
4839
  }
4761
4840
  if (lastDiskNumber == MAX_16_BITS) {
4762
- lastDiskNumber = getUint32(endOfDirectoryView, 16);
4763
- } else if (checkAmbiguity && lastDiskNumber != getUint32(endOfDirectoryView, 16)) {
4841
+ lastDiskNumber = getUint32$1(endOfDirectoryView, 16);
4842
+ } else if (checkAmbiguity && lastDiskNumber != getUint32$1(endOfDirectoryView, 16)) {
4764
4843
  throwAmbiguousArchive("mismatched zip64 end of central directory record");
4765
4844
  }
4766
4845
  if (diskNumber == MAX_16_BITS) {
4767
- diskNumber = getUint32(endOfDirectoryView, 20);
4768
- } else if (checkAmbiguity && diskNumber != getUint32(endOfDirectoryView, 20)) {
4846
+ diskNumber = getUint32$1(endOfDirectoryView, 20);
4847
+ } else if (checkAmbiguity && diskNumber != getUint32$1(endOfDirectoryView, 20)) {
4769
4848
  throwAmbiguousArchive("mismatched zip64 end of central directory record");
4770
4849
  }
4771
4850
  if (filesLength == MAX_16_BITS) {
@@ -4803,11 +4882,11 @@ class ZipReader {
4803
4882
  }
4804
4883
  const expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
4805
4884
  if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
4806
- const storedPointsAtDirectory = getUint32(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
4885
+ const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
4807
4886
  let reconcile = !storedPointsAtDirectory;
4808
4887
  if (!reconcile && expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
4809
4888
  const expectedSignatureArray = await readUint8Array(reader, expectedDirectoryDataOffset, 4);
4810
- reconcile = getUint32(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
4889
+ reconcile = getUint32$1(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
4811
4890
  }
4812
4891
  if (reconcile) {
4813
4892
  const originalDirectoryDataOffset = directoryDataOffset;
@@ -4831,10 +4910,10 @@ class ZipReader {
4831
4910
  }
4832
4911
  zipReader.directoryOffset = directoryDataOffset;
4833
4912
  zipReader.directoryLength = declaredDirectoryDataLength;
4834
- const decryptCentralDirectory = getOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
4913
+ const decryptCentralDirectory = getFunctionOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
4835
4914
  let decryptedDirectory;
4836
4915
  if (decryptCentralDirectory && filesLength && directoryArray.length >= 4 &&
4837
- getUint32(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
4916
+ getUint32$1(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
4838
4917
  (zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
4839
4918
  directoryArray = await decryptCentralDirectory(directoryArray, directoryEncryptionInfo);
4840
4919
  directoryView = getDataView(directoryArray);
@@ -4847,8 +4926,8 @@ class ZipReader {
4847
4926
  const filenames = checkAmbiguity ? new Set() : UNDEFINED_VALUE;
4848
4927
  let duplicateFilename;
4849
4928
  for (let indexFile = 0; indexFile < filesLength; indexFile++) {
4850
- const fileEntry = new ZipEntry$1(reader, config, zipReader.options);
4851
- if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
4929
+ const fileEntry = new ZipEntry$1(reader, zipReader.options);
4930
+ if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32$1(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
4852
4931
  if (indexFile == 0 && !decryptedDirectory && (zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
4853
4932
  throw new Error(ERR_ENCRYPTED_CENTRAL_DIRECTORY);
4854
4933
  }
@@ -4859,16 +4938,16 @@ class ZipReader {
4859
4938
  const filenameOffset = offset + CENTRAL_FILE_HEADER_LENGTH;
4860
4939
  const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
4861
4940
  const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
4862
- const versionMadeBy = getUint16(directoryView, offset + 4);
4941
+ const versionMadeBy = getUint16$1(directoryView, offset + 4);
4863
4942
  const msDosCompatible = versionMadeBy >> 8 == 0;
4864
4943
  const unixCompatible = versionMadeBy >> 8 == 3;
4865
4944
  const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
4866
- const commentLength = getUint16(directoryView, offset + 32);
4945
+ const commentLength = getUint16$1(directoryView, offset + 32);
4867
4946
  const endOffset = commentOffset + commentLength;
4868
4947
  const rawComment = directoryArray.subarray(commentOffset, endOffset);
4869
4948
  const filenameUTF8 = languageEncodingFlag;
4870
4949
  const commentUTF8 = languageEncodingFlag;
4871
- const externalFileAttributes = getUint32(directoryView, offset + 38);
4950
+ const externalFileAttributes = getUint32$1(directoryView, offset + 38);
4872
4951
  const msdosAttributesRaw = externalFileAttributes & MAX_8_BITS;
4873
4952
  const msdosAttributes = {
4874
4953
  readOnly: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_READONLY_MASK),
@@ -4877,8 +4956,8 @@ class ZipReader {
4877
4956
  directory: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_DIR_MASK),
4878
4957
  archive: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_ARCHIVE_MASK)
4879
4958
  };
4880
- const offsetFileEntry = getUint32(directoryView, offset + 42);
4881
- const decode = getOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
4959
+ const offsetFileEntry = getUint32$1(directoryView, offset + 42);
4960
+ const decode = getFunctionOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
4882
4961
  const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
4883
4962
  const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
4884
4963
  let filename = decode(rawFilename, rawFilenameEncoding, TEXT_TYPE_FILENAME);
@@ -4909,8 +4988,8 @@ class ZipReader {
4909
4988
  uncompressedSize: 0,
4910
4989
  commentLength,
4911
4990
  offset: offsetFileEntry,
4912
- diskNumberStart: getUint16(directoryView, offset + 34),
4913
- internalFileAttributes: getUint16(directoryView, offset + 36),
4991
+ diskNumberStart: getUint16$1(directoryView, offset + 34),
4992
+ internalFileAttributes: getUint16$1(directoryView, offset + 36),
4914
4993
  externalFileAttributes,
4915
4994
  msdosAttributesRaw,
4916
4995
  msdosAttributes,
@@ -4978,8 +5057,8 @@ class ZipReader {
4978
5057
  yield entry;
4979
5058
  }
4980
5059
  let offsetAfterSignature = offset;
4981
- if (offset + 6 <= directoryArray.length && getUint32(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
4982
- const signatureDataLength = getUint16(directoryView, offset + 4);
5060
+ if (offset + 6 <= directoryArray.length && getUint32$1(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
5061
+ const signatureDataLength = getUint16$1(directoryView, offset + 4);
4983
5062
  if (offset + 6 + signatureDataLength <= directoryArray.length) {
4984
5063
  zipReader.digitalSignature = directoryArray.subarray(offset + 6, offset + 6 + signatureDataLength);
4985
5064
  offsetAfterSignature = offset + 6 + signatureDataLength;
@@ -4991,13 +5070,17 @@ class ZipReader {
4991
5070
  if (duplicateFilename) {
4992
5071
  throwAmbiguousArchive("duplicate filename");
4993
5072
  }
4994
- if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > 0))) {
4995
- throwAmbiguousArchive("prepended data");
4996
- }
4997
5073
  const extractPrependedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_PREPENDED_DATA);
4998
5074
  const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
5075
+ const splitZipSignatureLength = (checkAmbiguity || extractPrependedData) && filesLength &&
5076
+ startOffset == SPLIT_ZIP_FILE_SIGNATURE_LENGTH && await startsWithSplitZipMarker(reader) ? SPLIT_ZIP_FILE_SIGNATURE_LENGTH : 0;
5077
+ if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > splitZipSignatureLength))) {
5078
+ throwAmbiguousArchive("prepended data");
5079
+ }
4999
5080
  if (extractPrependedData) {
5000
- zipReader.prependedData = startOffset > 0 ? await readUint8Array(reader, 0, startOffset) : EMPTY_UINT8_ARRAY;
5081
+ zipReader.prependedData = startOffset > splitZipSignatureLength ?
5082
+ await readUint8Array(reader, splitZipSignatureLength, startOffset - splitZipSignatureLength) :
5083
+ EMPTY_UINT8_ARRAY;
5001
5084
  }
5002
5085
  zipReader.comment = commentLength ? await readUint8Array(reader, commentOffset + END_OF_CENTRAL_DIR_LENGTH, commentLength) : EMPTY_UINT8_ARRAY;
5003
5086
  if (extractAppendedData) {
@@ -5064,16 +5147,16 @@ class ZipReaderStream {
5064
5147
 
5065
5148
  let ZipEntry$1 = class ZipEntry {
5066
5149
 
5067
- constructor(reader, config, options) {
5150
+ constructor(reader, options) {
5068
5151
  Object.assign(this, {
5069
5152
  reader,
5070
- config,
5071
5153
  options
5072
5154
  });
5073
5155
  }
5074
5156
 
5075
5157
  async getData(writer, fileEntry, readRanges, options = {}) {
5076
5158
  const zipEntry = this;
5159
+ const config = getConfiguration();
5077
5160
  const {
5078
5161
  reader,
5079
5162
  index,
@@ -5082,7 +5165,6 @@ let ZipEntry$1 = class ZipEntry {
5082
5165
  extraFieldAES,
5083
5166
  extraFieldZip64,
5084
5167
  compressionMethod,
5085
- config,
5086
5168
  bitFlag,
5087
5169
  rawBitFlag,
5088
5170
  crc32,
@@ -5100,6 +5182,7 @@ let ZipEntry$1 = class ZipEntry {
5100
5182
  let password = getOptionValue$1(zipEntry, options, OPTION_PASSWORD);
5101
5183
  let rawPassword = getOptionValue$1(zipEntry, options, OPTION_RAW_PASSWORD);
5102
5184
  const passThrough = getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH);
5185
+ checkPasswordOption(password, rawPassword);
5103
5186
  password = password && password.length && password;
5104
5187
  rawPassword = rawPassword && rawPassword.length && rawPassword;
5105
5188
  if (extraFieldAES) {
@@ -5107,7 +5190,7 @@ let ZipEntry$1 = class ZipEntry {
5107
5190
  throw new Error(ERR_UNSUPPORTED_COMPRESSION$1);
5108
5191
  }
5109
5192
  }
5110
- if (dataArray.length < HEADER_SIZE || getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
5193
+ if (dataArray.length < HEADER_SIZE || getUint32$1(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
5111
5194
  throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND);
5112
5195
  }
5113
5196
  readCommonHeader(localDirectory, dataView, 4);
@@ -5169,9 +5252,12 @@ let ZipEntry$1 = class ZipEntry {
5169
5252
  }
5170
5253
  }
5171
5254
  const dataOffset = localHeaderOffset + HEADER_SIZE + filenameLength + extraFieldLength;
5255
+ if (dataOffset + compressedSize > reader.size) {
5256
+ throw new Error(ERR_ENTRY_DATA_OUT_OF_BOUNDS);
5257
+ }
5172
5258
  const size = compressedSize;
5173
5259
  const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
5174
- const signal = getOptionValue$1(zipEntry, options, OPTION_SIGNAL);
5260
+ const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
5175
5261
  const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
5176
5262
  let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
5177
5263
  const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
@@ -5179,6 +5265,8 @@ let ZipEntry$1 = class ZipEntry {
5179
5265
  checkOverlappingEntry = true;
5180
5266
  }
5181
5267
  const { onstart, onprogress, onend } = options;
5268
+ const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !passThrough;
5269
+ const outputSize = passThrough ? compressedSize : uncompressedSize;
5182
5270
  const deflate64 = compressionMethod == COMPRESSION_METHOD_DEFLATE_64;
5183
5271
  let useCompressionStream = getOptionValue$1(zipEntry, options, OPTION_USE_COMPRESSION_STREAM);
5184
5272
  if (deflate64) {
@@ -5199,9 +5287,9 @@ let ZipEntry$1 = class ZipEntry {
5199
5287
  checkCrc32,
5200
5288
  checkAuthenticationCode: getOptionValue$1(zipEntry, options, OPTION_CHECK_AUTHENTICATION_CODE),
5201
5289
  passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((crc32 >>> 24) & MAX_8_BITS)),
5202
- outputSize: passThrough ? compressedSize : uncompressedSize,
5290
+ outputSize,
5203
5291
  crc32,
5204
- compressed: compressionMethod != 0 && !passThrough,
5292
+ compressed,
5205
5293
  encrypted,
5206
5294
  useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
5207
5295
  useCompressionStream,
@@ -5238,11 +5326,11 @@ let ZipEntry$1 = class ZipEntry {
5238
5326
  writer = new WritableStream();
5239
5327
  }
5240
5328
  writer = new GenericWriter(writer);
5241
- await initStream(writer, passThrough ? compressedSize : uncompressedSize);
5329
+ await initStream(writer, getDecodableOutputSize(outputSize, compressedSize, compressed));
5242
5330
  ({ writable } = writer);
5243
- const { outputSize } = await runWorker({ readable, writable }, workerOptions);
5244
- writer.size += outputSize;
5245
- if (outputSize != (passThrough ? compressedSize : uncompressedSize)) {
5331
+ const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
5332
+ writer.size += writtenSize;
5333
+ if (writtenSize != outputSize) {
5246
5334
  throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
5247
5335
  }
5248
5336
  }
@@ -5276,7 +5364,7 @@ let ZipEntry$1 = class ZipEntry {
5276
5364
  function detectEncryptedCentralDirectory(directoryView) {
5277
5365
  const maxOffset = Math.min(directoryView.byteLength, 1024) - 3;
5278
5366
  for (let offset = 0; offset < maxOffset; offset++) {
5279
- if (getUint32(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
5367
+ if (getUint32$1(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
5280
5368
  return true;
5281
5369
  }
5282
5370
  }
@@ -5287,15 +5375,15 @@ function getDirectoryEncryptionInfo(rawExtensibleData) {
5287
5375
  const directoryEncryptionInfo = { rawExtensibleData };
5288
5376
  if (rawExtensibleData.length >= 28) {
5289
5377
  const extensibleDataView = getDataView(rawExtensibleData);
5290
- const hashDataLength = getUint16(extensibleDataView, 26);
5378
+ const hashDataLength = getUint16$1(extensibleDataView, 26);
5291
5379
  Object.assign(directoryEncryptionInfo, {
5292
- compressionMethod: getUint16(extensibleDataView, 0),
5380
+ compressionMethod: getUint16$1(extensibleDataView, 0),
5293
5381
  compressedSize: Number(getBigUint64(extensibleDataView, 2)),
5294
5382
  uncompressedSize: Number(getBigUint64(extensibleDataView, 10)),
5295
- encryptionAlgorithm: getUint16(extensibleDataView, 18),
5296
- bitLength: getUint16(extensibleDataView, 20),
5297
- flags: getUint16(extensibleDataView, 22),
5298
- hashAlgorithm: getUint16(extensibleDataView, 24),
5383
+ encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
5384
+ bitLength: getUint16$1(extensibleDataView, 20),
5385
+ flags: getUint16$1(extensibleDataView, 22),
5386
+ hashAlgorithm: getUint16$1(extensibleDataView, 24),
5299
5387
  hashData: rawExtensibleData.subarray(28, 28 + hashDataLength)
5300
5388
  });
5301
5389
  }
@@ -5303,12 +5391,12 @@ function getDirectoryEncryptionInfo(rawExtensibleData) {
5303
5391
  }
5304
5392
 
5305
5393
  function readCommonHeader(directory, dataView, offset) {
5306
- const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2);
5394
+ const rawBitFlag = directory.rawBitFlag = getUint16$1(dataView, offset + 2);
5307
5395
  const encrypted = (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED;
5308
- const rawLastModDate = getUint32(dataView, offset + 6);
5396
+ const rawLastModDate = getUint32$1(dataView, offset + 6);
5309
5397
  Object.assign(directory, {
5310
5398
  encrypted,
5311
- version: getUint16(dataView, offset),
5399
+ version: getUint16$1(dataView, offset),
5312
5400
  bitFlag: {
5313
5401
  level: (rawBitFlag & BITFLAG_LEVEL) >> 1,
5314
5402
  dataDescriptor: (rawBitFlag & BITFLAG_DATA_DESCRIPTOR) == BITFLAG_DATA_DESCRIPTOR,
@@ -5316,8 +5404,8 @@ function readCommonHeader(directory, dataView, offset) {
5316
5404
  },
5317
5405
  rawLastModDate,
5318
5406
  lastModDate: getDate(rawLastModDate),
5319
- filenameLength: getUint16(dataView, offset + 22),
5320
- extraFieldLength: getUint16(dataView, offset + 24)
5407
+ filenameLength: getUint16$1(dataView, offset + 22),
5408
+ extraFieldLength: getUint16$1(dataView, offset + 24)
5321
5409
  });
5322
5410
  }
5323
5411
 
@@ -5328,8 +5416,8 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
5328
5416
  let offsetExtraField = 0;
5329
5417
  try {
5330
5418
  while (offsetExtraField < rawExtraField.length) {
5331
- const type = getUint16(rawExtraFieldView, offsetExtraField);
5332
- const size = getUint16(rawExtraFieldView, offsetExtraField + 2);
5419
+ const type = getUint16$1(rawExtraFieldView, offsetExtraField);
5420
+ const size = getUint16$1(rawExtraFieldView, offsetExtraField + 2);
5333
5421
  extraField.set(type, {
5334
5422
  type,
5335
5423
  data: rawExtraField.slice(offsetExtraField + 4, offsetExtraField + 4 + size)
@@ -5339,12 +5427,12 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
5339
5427
  } catch {
5340
5428
  // ignored
5341
5429
  }
5342
- const compressionMethod = getUint16(dataView, offset + 4);
5430
+ const compressionMethod = getUint16$1(dataView, offset + 4);
5343
5431
  Object.assign(directory, {
5344
- signature: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
5345
- crc32: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
5346
- compressedSize: getUint32(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
5347
- uncompressedSize: getUint32(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
5432
+ signature: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
5433
+ crc32: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
5434
+ compressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
5435
+ uncompressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
5348
5436
  });
5349
5437
  const extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64);
5350
5438
  if (extraFieldZip64) {
@@ -5433,11 +5521,11 @@ function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName,
5433
5521
  computedCrc32.append(fileEntry[rawPropertyName]);
5434
5522
  const computedCrc32View = getDataView(new Uint8Array(4));
5435
5523
  computedCrc32View.setUint32(0, computedCrc32.get(), true);
5436
- const nameCrc32 = getUint32(extraFieldView, 1);
5524
+ const nameCrc32 = getUint32$1(extraFieldView, 1);
5437
5525
  Object.assign(extraFieldUnicode, {
5438
5526
  version: getUint8(extraFieldView, 0),
5439
5527
  [propertyName]: decodeText(extraFieldUnicode.data.subarray(5)),
5440
- valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32(computedCrc32View, 0)
5528
+ valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32$1(computedCrc32View, 0)
5441
5529
  });
5442
5530
  if (extraFieldUnicode.valid) {
5443
5531
  directory[propertyName] = extraFieldUnicode[propertyName];
@@ -5453,7 +5541,7 @@ function readExtraFieldAES(extraFieldAES, directory, compressionMethod) {
5453
5541
  vendorId: getUint8(extraFieldView, 2),
5454
5542
  strength,
5455
5543
  originalCompressionMethod: compressionMethod,
5456
- compressionMethod: getUint16(extraFieldView, 5)
5544
+ compressionMethod: getUint16$1(extraFieldView, 5)
5457
5545
  });
5458
5546
  directory.compressionMethod = extraFieldAES.compressionMethod;
5459
5547
  if (extraFieldAES.vendorVersion != VENDOR_VERSION_AE_1$1) {
@@ -5467,8 +5555,8 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
5467
5555
  let tag1Data;
5468
5556
  try {
5469
5557
  while (offsetExtraField < extraFieldNTFS.data.length && !tag1Data) {
5470
- const tagValue = getUint16(extraFieldView, offsetExtraField);
5471
- const attributeSize = getUint16(extraFieldView, offsetExtraField + 2);
5558
+ const tagValue = getUint16$1(extraFieldView, offsetExtraField);
5559
+ const attributeSize = getUint16$1(extraFieldView, offsetExtraField + 2);
5472
5560
  if (tagValue == EXTRAFIELD_TYPE_NTFS_TAG1) {
5473
5561
  tag1Data = extraFieldNTFS.data.slice(offsetExtraField + 4, offsetExtraField + 4 + attributeSize);
5474
5562
  }
@@ -5501,12 +5589,12 @@ function readExtraFieldUnixDates(extraField, directory) {
5501
5589
  return;
5502
5590
  }
5503
5591
  const extraFieldView = getDataView(extraField.data);
5504
- const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
5505
- const lastModDate = new Date((getUint32(extraFieldView, 4) | 0) * 1000);
5592
+ const lastAccessDate = new Date((getUint32$1(extraFieldView, 0) | 0) * 1000);
5593
+ const lastModDate = new Date((getUint32$1(extraFieldView, 4) | 0) * 1000);
5506
5594
  const extraFieldData = { lastAccessDate, lastModDate };
5507
5595
  if (extraField.data.length >= 12) {
5508
- extraFieldData.uid = getUint16(extraFieldView, 8);
5509
- extraFieldData.gid = getUint16(extraFieldView, 10);
5596
+ extraFieldData.uid = getUint16$1(extraFieldView, 8);
5597
+ extraFieldData.gid = getUint16$1(extraFieldView, 10);
5510
5598
  }
5511
5599
  Object.assign(extraField, extraFieldData);
5512
5600
  Object.assign(directory, extraFieldData);
@@ -5526,8 +5614,8 @@ function readExtraFieldUnix(extraField, directory, isInfoZip) {
5526
5614
  gid = unpackUnixId(extraField.data.subarray(offset, offset + gidSize));
5527
5615
  Object.assign(extraField, { version, uid, gid });
5528
5616
  } else if (extraField.data.length >= 4) {
5529
- uid = getUint16(view, 0);
5530
- gid = getUint16(view, 2);
5617
+ uid = getUint16$1(view, 0);
5618
+ gid = getUint16$1(view, 2);
5531
5619
  Object.assign(extraField, { uid, gid });
5532
5620
  }
5533
5621
  if (uid !== UNDEFINED_VALUE) {
@@ -5577,7 +5665,7 @@ function readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory,
5577
5665
  let offset = 1;
5578
5666
  timeProperties.forEach((propertyName, indexProperty) => {
5579
5667
  if (extraFieldExtendedTimestamp.data.length >= offset + 4) {
5580
- const time = getUint32(extraFieldView, offset);
5668
+ const time = getUint32$1(extraFieldView, offset);
5581
5669
  directory[propertyName] = extraFieldExtendedTimestamp[propertyName] = new Date((time | 0) * 1000);
5582
5670
  const rawPropertyName = timeRawProperties[indexProperty];
5583
5671
  extraFieldExtendedTimestamp[rawPropertyName] = time;
@@ -5611,7 +5699,7 @@ async function detectOverlappingEntry({
5611
5699
  const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
5612
5700
  const dataDescriptorView = getDataView(dataDescriptorArray);
5613
5701
  let signature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
5614
- getUint32(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
5702
+ getUint32$1(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
5615
5703
  if (signature) {
5616
5704
  const signedDataDescriptor = readDataDescriptor(dataDescriptorView, DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, extraFieldZip64);
5617
5705
  const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || signedDataDescriptor.crc32 == crc32;
@@ -5645,15 +5733,15 @@ async function detectOverlappingEntry({
5645
5733
  }
5646
5734
 
5647
5735
  function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
5648
- const crc32 = getUint32(dataDescriptorView, offset);
5736
+ const crc32 = getUint32$1(dataDescriptorView, offset);
5649
5737
  let compressedSize;
5650
5738
  let uncompressedSize;
5651
5739
  if (extraFieldZip64) {
5652
5740
  compressedSize = getBigUint64(dataDescriptorView, offset + 4);
5653
5741
  uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
5654
5742
  } else {
5655
- compressedSize = getUint32(dataDescriptorView, offset + 4);
5656
- uncompressedSize = getUint32(dataDescriptorView, offset + 8);
5743
+ compressedSize = getUint32$1(dataDescriptorView, offset + 4);
5744
+ uncompressedSize = getUint32$1(dataDescriptorView, offset + 8);
5657
5745
  }
5658
5746
  return { crc32, compressedSize, uncompressedSize };
5659
5747
  }
@@ -5662,10 +5750,28 @@ function getDiskOffset$1(reader, diskNumber) {
5662
5750
  return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
5663
5751
  }
5664
5752
 
5753
+ async function startsWithSplitZipSignature$1(reader) {
5754
+ return await getFirstSignature(reader) == SPLIT_ZIP_FILE_SIGNATURE;
5755
+ }
5756
+
5757
+ async function startsWithSplitZipMarker(reader) {
5758
+ const signature = await getFirstSignature(reader);
5759
+ return signature == SPLIT_ZIP_FILE_SIGNATURE || signature == TEMPORARY_SPLIT_ZIP_FILE_SIGNATURE;
5760
+ }
5761
+
5762
+ async function getFirstSignature(reader) {
5763
+ const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
5764
+ return getUint32$1(getDataView(signatureArray));
5765
+ }
5766
+
5665
5767
  function isStrictnessValue(value) {
5666
5768
  return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
5667
5769
  }
5668
5770
 
5771
+ function getDecodableOutputSize(outputSize, compressedSize, compressed) {
5772
+ return Math.min(outputSize, compressed ? compressedSize * MAX_DEFLATE_EXPANSION_RATIO : compressedSize);
5773
+ }
5774
+
5669
5775
  function getStrictness(options, inheritedOptions) {
5670
5776
  return resolveStrictness(options, resolveStrictness(inheritedOptions, STRICTNESS_BALANCED));
5671
5777
  }
@@ -5728,7 +5834,7 @@ function isUnsafeFilename(filename, filenameValidation) {
5728
5834
 
5729
5835
  function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
5730
5836
  if (maxAppendedDataSize !== UNDEFINED_VALUE) {
5731
- const size = toNumber$1(maxAppendedDataSize);
5837
+ const size = toNumber(maxAppendedDataSize);
5732
5838
  if (typeof size != NUMBER_TYPE || Number.isNaN(size) || size < 0) {
5733
5839
  throw new Error(ERR_INVALID_MAX_APPENDED_DATA_SIZE);
5734
5840
  }
@@ -5751,7 +5857,7 @@ async function findEndOfCentralDirectory(reader, rejectAmbiguous, maxAppendedDat
5751
5857
  let plausibleEndOfDirectoryInfo;
5752
5858
  let endOfDirectoryReachingEndCount = 0;
5753
5859
  for await (const [anchoredView, anchoredOffset, anchoredArray, indexByte, offset] of scanEndOfCentralDirectory(reader, anchoredLength)) {
5754
- const commentLength = getUint16(anchoredView, indexByte + 20);
5860
+ const commentLength = getUint16$1(anchoredView, indexByte + 20);
5755
5861
  if (offset + END_OF_CENTRAL_DIR_LENGTH + commentLength == size) {
5756
5862
  const reachability = await getCentralDirectoryReachability(reader, anchoredView, anchoredOffset, indexByte, offset, size, remoteProbeBudget);
5757
5863
  if (reachability == CENTRAL_DIRECTORY_REACHABLE) {
@@ -5802,7 +5908,7 @@ async function* scanEndOfCentralDirectory(reader, scanLength) {
5802
5908
  const scanArray = await readUint8Array(reader, scanOffset, scanLength);
5803
5909
  const scanView = getDataView(scanArray);
5804
5910
  for (let indexByte = scanArray.length - END_OF_CENTRAL_DIR_LENGTH; indexByte >= 0; indexByte--) {
5805
- if (getUint32(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
5911
+ if (getUint32$1(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
5806
5912
  yield [scanView, scanOffset, scanArray, indexByte, scanOffset + indexByte];
5807
5913
  }
5808
5914
  }
@@ -5813,9 +5919,9 @@ function getEndOfCentralDirectoryInfo(scanArray, indexByte, offset) {
5813
5919
  }
5814
5920
 
5815
5921
  async function getCentralDirectoryReachability(reader, view, anchoredOffset, indexByte, offset, size, remoteProbeBudget) {
5816
- const filesLength = getUint16(view, indexByte + 10);
5817
- const directoryDataLength = getUint32(view, indexByte + 12);
5818
- const directoryDataOffset = getUint32(view, indexByte + 16);
5922
+ const filesLength = getUint16$1(view, indexByte + 10);
5923
+ const directoryDataLength = getUint32$1(view, indexByte + 12);
5924
+ const directoryDataOffset = getUint32$1(view, indexByte + 16);
5819
5925
  if (filesLength == MAX_16_BITS || directoryDataLength == MAX_32_BITS || directoryDataOffset == MAX_32_BITS) {
5820
5926
  const locatorSignature = await readSignature(reader, view, anchoredOffset, offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, size, remoteProbeBudget);
5821
5927
  return locatorSignature == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE ? CENTRAL_DIRECTORY_REACHABLE : CENTRAL_DIRECTORY_UNREACHABLE;
@@ -5823,7 +5929,7 @@ async function getCentralDirectoryReachability(reader, view, anchoredOffset, ind
5823
5929
  if (!filesLength && !directoryDataLength) {
5824
5930
  return CENTRAL_DIRECTORY_PLAUSIBLE;
5825
5931
  }
5826
- const directoryDiskNumber = getUint16(view, indexByte + 6);
5932
+ const directoryDiskNumber = getUint16$1(view, indexByte + 6);
5827
5933
  for (const centralDirectoryOffset of [offset - directoryDataLength, getDiskOffset$1(reader, directoryDiskNumber) + directoryDataOffset]) {
5828
5934
  if (await readSignature(reader, view, anchoredOffset, centralDirectoryOffset, size, remoteProbeBudget) == CENTRAL_FILE_HEADER_SIGNATURE) {
5829
5935
  return CENTRAL_DIRECTORY_REACHABLE;
@@ -5837,12 +5943,12 @@ async function readSignature(reader, view, anchoredOffset, signatureOffset, size
5837
5943
  return UNDEFINED_VALUE;
5838
5944
  }
5839
5945
  if (signatureOffset >= anchoredOffset) {
5840
- return getUint32(view, signatureOffset - anchoredOffset);
5946
+ return getUint32$1(view, signatureOffset - anchoredOffset);
5841
5947
  }
5842
5948
  if (remoteProbeBudget.count > 0) {
5843
5949
  remoteProbeBudget.count--;
5844
5950
  const signatureArray = await readUint8Array(reader, signatureOffset, 4);
5845
- return getUint32(getDataView(signatureArray), 0);
5951
+ return getUint32$1(getDataView(signatureArray), 0);
5846
5952
  }
5847
5953
  return UNDEFINED_VALUE;
5848
5954
  }
@@ -5879,10 +5985,11 @@ function getOptionValue$1(zipReader, options, name) {
5879
5985
  return options[name] === UNDEFINED_VALUE ? zipReader.options[name] : options[name];
5880
5986
  }
5881
5987
 
5882
- function toNumber$1(value) {
5883
- return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
5988
+ function getFunctionOptionValue$1(zipReader, options, name) {
5989
+ return checkFunctionOption(getOptionValue$1(zipReader, options, name));
5884
5990
  }
5885
5991
 
5992
+
5886
5993
  function getDate(timeRaw) {
5887
5994
  const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS;
5888
5995
  return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
@@ -5896,11 +6003,11 @@ function getUint8(view, offset) {
5896
6003
  return view.getUint8(offset);
5897
6004
  }
5898
6005
 
5899
- function getUint16(view, offset) {
6006
+ function getUint16$1(view, offset) {
5900
6007
  return view.getUint16(offset, true);
5901
6008
  }
5902
6009
 
5903
- function getUint32(view, offset) {
6010
+ function getUint32$1(view, offset) {
5904
6011
  return view.getUint32(offset, true);
5905
6012
  }
5906
6013
 
@@ -5915,6 +6022,7 @@ var zipReader = /*#__PURE__*/Object.freeze({
5915
6022
  ERR_CENTRAL_DIRECTORY_NOT_FOUND: ERR_CENTRAL_DIRECTORY_NOT_FOUND,
5916
6023
  ERR_ENCRYPTED: ERR_ENCRYPTED,
5917
6024
  ERR_ENCRYPTED_CENTRAL_DIRECTORY: ERR_ENCRYPTED_CENTRAL_DIRECTORY,
6025
+ ERR_ENTRY_DATA_OUT_OF_BOUNDS: ERR_ENTRY_DATA_OUT_OF_BOUNDS,
5918
6026
  ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND,
5919
6027
  ERR_EOCDR_NOT_FOUND: ERR_EOCDR_NOT_FOUND,
5920
6028
  ERR_EXTRAFIELD_ZIP64_NOT_FOUND: ERR_EXTRAFIELD_ZIP64_NOT_FOUND,
@@ -5971,12 +6079,16 @@ const ERR_DUPLICATED_NAME = "File already exists";
5971
6079
  const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
5972
6080
  const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
5973
6081
  const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
6082
+ const ERR_INVALID_ENTRY_COMMENT_TYPE = "Invalid file entry comment (must be a string)";
6083
+ const ERR_INVALID_DATE = "Invalid date (must be a valid Date instance)";
5974
6084
  const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
5975
6085
  const ERR_INVALID_VERSION = "Version exceeds 65535";
5976
6086
  const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
5977
6087
  const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
5978
6088
  const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
5979
- const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
6089
+ const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
6090
+ const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
6091
+ const ERR_INVALID_EXTRAFIELD_DATA_TYPE = "Invalid extra field data (must be a Uint8Array)";
5980
6092
  const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
5981
6093
  const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
5982
6094
  const MIN_UNIX_TIME = -2147483648;
@@ -5996,7 +6108,6 @@ const ERR_INVALID_UNIX_ID_SIZE = "uid/gid must be 0..65535 for unixExtraFieldTyp
5996
6108
  const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be integer 0..255)";
5997
6109
  const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
5998
6110
  const ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
5999
- const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
6000
6111
  const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
6001
6112
 
6002
6113
  const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
@@ -6021,8 +6132,7 @@ class ZipWriter {
6021
6132
  writer,
6022
6133
  addSplitZipSignature,
6023
6134
  options,
6024
- config: getConfiguration(),
6025
- files: new Map(),
6135
+ fileEntries: new Map(),
6026
6136
  filenames: new Set(),
6027
6137
  offset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? writer.size || writer.writable.size || 0 : options[OPTION_OFFSET],
6028
6138
  initialOffset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : options[OPTION_OFFSET] - (writer.size || writer.writable.size || 0),
@@ -6043,14 +6153,23 @@ class ZipWriter {
6043
6153
  await initStream(reader);
6044
6154
  }
6045
6155
  const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
6046
- const zipReader$1 = new ZipReader(reader.readable);
6156
+ const zipReader$1 = new ZipReader(reader);
6047
6157
  const entries = await zipReader$1.getEntries();
6048
6158
  await zipReader$1.close();
6049
6159
  await initStream(this.writer);
6050
- await reader.readable.pipeTo(this.writer.writable, { preventClose: true, preventAbort: true });
6051
- this.writer.size = this.offset = reader.size;
6160
+ const { directoryOffset } = zipReader$1;
6161
+ let splitZipSignatureLength = 0;
6162
+ if (this.addSplitZipSignature) {
6163
+ delete this.addSplitZipSignature;
6164
+ if (!await startsWithSplitZipSignature(reader)) {
6165
+ await writeData(this.writer, getSplitZipSignatureArray());
6166
+ splitZipSignatureLength = SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
6167
+ this.offset += splitZipSignatureLength;
6168
+ }
6169
+ }
6170
+ const entryPositions = await copyZipData(this, reader, entries, directoryOffset, splitZipSignatureLength);
6052
6171
  this.filenames = new Set(entries.map(entry => entry.filename));
6053
- this.files = new Map(entries.map(entry => {
6172
+ this.fileEntries = new Map(entries.map(entry => {
6054
6173
  const {
6055
6174
  version,
6056
6175
  rawLastModDate,
@@ -6105,11 +6224,12 @@ class ZipWriter {
6105
6224
  if (crc32 !== UNDEFINED_VALUE) {
6106
6225
  setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
6107
6226
  }
6227
+ const { offset, diskNumberStart } = entryPositions.get(entry);
6108
6228
  Object.assign(entry, {
6109
6229
  zip64UncompressedSize,
6110
6230
  zip64CompressedSize,
6111
- zip64Offset: zip64 && entry.offset >= MAX_32_BITS,
6112
- diskNumberStart: 0,
6231
+ offset,
6232
+ diskNumberStart,
6113
6233
  zip64DiskNumberStart: false,
6114
6234
  rawExtraFieldZip64,
6115
6235
  rawExtraFieldAES,
@@ -6129,11 +6249,8 @@ class ZipWriter {
6129
6249
  async add(name = "", reader, options = {}) {
6130
6250
  const zipWriter = this;
6131
6251
  options = Object.assign({}, options);
6132
- const {
6133
- pendingAddFileCalls,
6134
- config
6135
- } = zipWriter;
6136
- if (workers < config.maxWorkers) {
6252
+ const { pendingAddFileCalls } = zipWriter;
6253
+ if (workers < getConfiguration().maxWorkers) {
6137
6254
  workers++;
6138
6255
  } else {
6139
6256
  await new Promise(resolve => pendingEntries.push(resolve));
@@ -6170,16 +6287,16 @@ class ZipWriter {
6170
6287
  }
6171
6288
 
6172
6289
  remove(entry) {
6173
- const { filenames, files } = this;
6290
+ const { filenames, fileEntries } = this;
6174
6291
  // deno-lint-ignore valid-typeof
6175
6292
  if (typeof entry == STRING_TYPE) {
6176
- entry = files.get(entry);
6293
+ entry = fileEntries.get(entry);
6177
6294
  }
6178
6295
  if (entry && entry.filename !== UNDEFINED_VALUE) {
6179
6296
  const { filename } = entry;
6180
- if (filenames.has(filename) && files.has(filename)) {
6297
+ if (filenames.has(filename) && fileEntries.has(filename)) {
6181
6298
  filenames.delete(filename);
6182
- files.delete(filename);
6299
+ fileEntries.delete(filename);
6183
6300
  return true;
6184
6301
  }
6185
6302
  }
@@ -6276,12 +6393,12 @@ async function addFile(zipWriter, name, reader, options) {
6276
6393
  const metadataInfo = resolveMetadata(zipWriter, name, options);
6277
6394
  const { comment } = metadataInfo;
6278
6395
  const extraField = options[PROPERTY_NAME_EXTRA_FIELD];
6279
- zipWriter.files.set(name, UNDEFINED_VALUE);
6396
+ zipWriter.fileEntries.set(name, UNDEFINED_VALUE);
6280
6397
  let fileEntry;
6281
6398
  try {
6282
6399
  const { resolvedOptions } = metadataInfo;
6283
6400
  if (resolvedOptions.level != 0 && resolvedOptions.compressionMethod === UNDEFINED_VALUE &&
6284
- !resolvedOptions.passThrough && !(await supportsDeflate(zipWriter.config))) {
6401
+ !resolvedOptions.passThrough && !(await supportsDeflate(getConfiguration()))) {
6285
6402
  resolvedOptions.level = 0;
6286
6403
  }
6287
6404
  const sizesInfo = await resolveSizes(zipWriter, reader, metadataInfo, options);
@@ -6299,7 +6416,7 @@ async function addFile(zipWriter, name, reader, options) {
6299
6416
  const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
6300
6417
  fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo, metadataSize }, options);
6301
6418
  } catch (error) {
6302
- zipWriter.files.delete(name);
6419
+ zipWriter.fileEntries.delete(name);
6303
6420
  throw error;
6304
6421
  }
6305
6422
  Object.assign(fileEntry, {
@@ -6343,9 +6460,9 @@ function resolveAttributes(zipWriter, name, options) {
6343
6460
  if (unixExtraFieldType === UNDEFINED_VALUE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
6344
6461
  unixExtraFieldType = INFOZIP_EXTRA_FIELD_TYPE$1;
6345
6462
  }
6346
- let msdosAttributesRaw = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
6463
+ let msdosAttributesRaw = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
6347
6464
  let msdosAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES);
6348
- const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType;
6465
+ const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType || executable;
6349
6466
  const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
6350
6467
  if (hasUnixMetadata) {
6351
6468
  msDosCompatible = false;
@@ -6354,10 +6471,10 @@ function resolveAttributes(zipWriter, name, options) {
6354
6471
  msDosCompatible = true;
6355
6472
  versionMadeBy = (versionMadeBy & MAX_8_BITS);
6356
6473
  }
6357
- if (msdosAttributesRaw !== UNDEFINED_VALUE && (msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
6474
+ if (msdosAttributesRaw !== UNDEFINED_VALUE && (!Number.isInteger(msdosAttributesRaw) || msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
6358
6475
  throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
6359
6476
  }
6360
- if (msdosAttributes && typeof msdosAttributes !== OBJECT_TYPE) {
6477
+ if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
6361
6478
  throw new Error(ERR_INVALID_MSDOS_DATA);
6362
6479
  }
6363
6480
  if (versionMadeBy > MAX_16_BITS) {
@@ -6445,7 +6562,7 @@ function resolveAttributes(zipWriter, name, options) {
6445
6562
  }
6446
6563
 
6447
6564
  function resolveMetadata(zipWriter, name, options) {
6448
- const encode = getOptionValue(zipWriter, options, OPTION_ENCODE_TEXT, encodeText);
6565
+ const encode = getFunctionOptionValue(zipWriter, options, OPTION_ENCODE_TEXT) || encodeText;
6449
6566
  let rawFilename = encode(name, TEXT_TYPE_FILENAME);
6450
6567
  if (rawFilename === UNDEFINED_VALUE) {
6451
6568
  rawFilename = encodeText(name);
@@ -6454,6 +6571,10 @@ function resolveMetadata(zipWriter, name, options) {
6454
6571
  throw new Error(ERR_INVALID_ENTRY_NAME);
6455
6572
  }
6456
6573
  const comment = options[PROPERTY_NAME_COMMENT] || "";
6574
+ // deno-lint-ignore valid-typeof
6575
+ if (typeof comment != STRING_TYPE) {
6576
+ throw new Error(ERR_INVALID_ENTRY_COMMENT_TYPE);
6577
+ }
6457
6578
  let rawComment = encode(comment, TEXT_TYPE_COMMENT);
6458
6579
  if (rawComment === UNDEFINED_VALUE) {
6459
6580
  rawComment = encodeText(comment);
@@ -6465,16 +6586,14 @@ function resolveMetadata(zipWriter, name, options) {
6465
6586
  if (version > MAX_16_BITS) {
6466
6587
  throw new Error(ERR_INVALID_VERSION);
6467
6588
  }
6468
- const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
6469
- const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
6470
- const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
6589
+ const lastModDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
6590
+ const lastAccessDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
6591
+ const creationDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
6471
6592
  const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
6472
6593
  const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
6473
6594
  const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
6474
6595
  const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
6475
- if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
6476
- throw new Error(ERR_INVALID_PASSWORD_TYPE);
6477
- }
6596
+ checkPasswordOption(password, rawPassword);
6478
6597
  const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
6479
6598
  const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
6480
6599
  const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
@@ -6483,9 +6602,9 @@ function resolveMetadata(zipWriter, name, options) {
6483
6602
  const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
6484
6603
  const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS);
6485
6604
  const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
6486
- const createTempStream = getOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
6605
+ const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
6487
6606
  const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
6488
- const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
6607
+ const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
6489
6608
  const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
6490
6609
  const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
6491
6610
  const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
@@ -6565,18 +6684,26 @@ function serializeExtraField(extraField) {
6565
6684
  if (!extraField) {
6566
6685
  return EMPTY_UINT8_ARRAY;
6567
6686
  }
6687
+ if (!(extraField instanceof Map)) {
6688
+ throw new Error(ERR_INVALID_EXTRAFIELD);
6689
+ }
6568
6690
  let extraFieldSize = 0;
6569
6691
  let offset = 0;
6570
- extraField.forEach(data => extraFieldSize += 4 + getLength(data));
6571
- const rawExtraField = new Uint8Array(extraFieldSize);
6572
- const rawExtraFieldView = getDataView(rawExtraField);
6573
6692
  extraField.forEach((data, type) => {
6574
- if (type > MAX_16_BITS) {
6693
+ if (!Number.isInteger(type) || type < 0 || type > MAX_16_BITS) {
6575
6694
  throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
6576
6695
  }
6696
+ if (!(data instanceof Uint8Array)) {
6697
+ throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
6698
+ }
6577
6699
  if (getLength(data) > MAX_16_BITS) {
6578
6700
  throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
6579
6701
  }
6702
+ extraFieldSize += 4 + getLength(data);
6703
+ });
6704
+ const rawExtraField = new Uint8Array(extraFieldSize);
6705
+ const rawExtraFieldView = getDataView(rawExtraField);
6706
+ extraField.forEach((data, type) => {
6580
6707
  setUint16(rawExtraFieldView, offset, type);
6581
6708
  setUint16(rawExtraFieldView, offset + 2, getLength(data));
6582
6709
  arraySet(rawExtraField, data, offset + 4);
@@ -6663,8 +6790,8 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
6663
6790
  }
6664
6791
 
6665
6792
  async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comment) {
6666
- const zipWriter = { options: writerOptions, config: getConfiguration() };
6667
- if (writerOptions[OPTION_SIGN_CENTRAL_DIRECTORY]) {
6793
+ const zipWriter = { options: writerOptions };
6794
+ if (checkFunctionOption(writerOptions[OPTION_SIGN_CENTRAL_DIRECTORY])) {
6668
6795
  throw new Error(ERR_UNDETERMINED_SIZE);
6669
6796
  }
6670
6797
  if (comment !== UNDEFINED_VALUE && !(comment instanceof Uint8Array)) {
@@ -6690,7 +6817,7 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
6690
6817
  ({ name } = attributesInfo);
6691
6818
  const { resolvedOptions: metadata } = resolveMetadata(zipWriter, name, options);
6692
6819
  if (metadata.level != 0 && metadata.compressionMethod === UNDEFINED_VALUE &&
6693
- !metadata.passThrough && !(await supportsDeflate(zipWriter.config))) {
6820
+ !metadata.passThrough && !(await supportsDeflate(getConfiguration()))) {
6694
6821
  metadata.level = 0;
6695
6822
  }
6696
6823
  const hasContent = !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY);
@@ -6739,7 +6866,7 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
6739
6866
 
6740
6867
  async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6741
6868
  const {
6742
- files,
6869
+ fileEntries,
6743
6870
  writer
6744
6871
  } = zipWriter;
6745
6872
  const {
@@ -6761,12 +6888,12 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6761
6888
  let writerSizeBeforeEntry;
6762
6889
  let flushedBufferedSize = 0;
6763
6890
  let fileWriter;
6764
- files.set(name, fileEntry);
6891
+ fileEntries.set(name, fileEntry);
6765
6892
  zipWriter.lastFileEntry = fileEntry;
6766
6893
  try {
6767
6894
  let lockPreviousFileEntry;
6768
6895
  if (keepOrder) {
6769
- lockPreviousFileEntry = previousFileEntry && previousFileEntry.lock;
6896
+ lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
6770
6897
  requestLockCurrentFileEntry();
6771
6898
  }
6772
6899
  if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
@@ -6787,11 +6914,8 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6787
6914
  const diskOffset = getDiskOffset(writer);
6788
6915
  if (zipWriter.addSplitZipSignature) {
6789
6916
  delete zipWriter.addSplitZipSignature;
6790
- const signatureArray = new Uint8Array(4);
6791
- const signatureArrayView = getDataView(signatureArray);
6792
- setUint32(signatureArrayView, 0, SPLIT_ZIP_FILE_SIGNATURE);
6793
- await writeData(writer, signatureArray);
6794
- zipWriter.offset += 4;
6917
+ await writeData(writer, getSplitZipSignatureArray());
6918
+ zipWriter.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
6795
6919
  }
6796
6920
  if (usdz && !bufferedWrite) {
6797
6921
  appendExtraFieldUSDZ(entryInfo, zipWriter.offset - diskOffset);
@@ -6809,11 +6933,11 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6809
6933
  writerSizeBeforeEntry = writer.size;
6810
6934
  await writeData(fileWriter, localHeaderArray);
6811
6935
  }
6812
- fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, zipWriter.config, options);
6936
+ fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, getConfiguration(), options);
6813
6937
  if (!bufferedWrite) {
6814
6938
  writingEntryData = false;
6815
6939
  }
6816
- files.set(name, fileEntry);
6940
+ fileEntries.set(name, fileEntry);
6817
6941
  fileEntry.filename = name;
6818
6942
  if (bufferedWrite) {
6819
6943
  await Promise.all([fileWriter.writable.getWriter().close(), lockPreviousFileEntry]);
@@ -6854,7 +6978,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6854
6978
  zipWriter.offset += flushedBufferedSize;
6855
6979
  }
6856
6980
  }
6857
- files.delete(name);
6981
+ fileEntries.delete(name);
6858
6982
  throw error;
6859
6983
  } finally {
6860
6984
  if (bufferedWrite) {
@@ -6876,7 +7000,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6876
7000
  }
6877
7001
 
6878
7002
  function requestLockCurrentFileEntry() {
6879
- fileEntry.lock = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
7003
+ fileEntry.lockFileEntry = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
6880
7004
  }
6881
7005
 
6882
7006
  async function requestLockWriter() {
@@ -6896,7 +7020,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6896
7020
  }
6897
7021
  }
6898
7022
 
6899
- async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryInfo, config, options) {
7023
+ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry }, entryInfo, config, options) {
6900
7024
  const {
6901
7025
  headerInfo,
6902
7026
  dataDescriptorInfo,
@@ -6964,7 +7088,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
6964
7088
  codecURI
6965
7089
  } = options;
6966
7090
  const fileEntry = {
6967
- lock,
7091
+ lockFileEntry,
6968
7092
  versionMadeBy,
6969
7093
  zip64,
6970
7094
  directory: Boolean(directory),
@@ -7006,7 +7130,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
7006
7130
  }
7007
7131
  const { writable } = writer;
7008
7132
  if (reader) {
7009
- const readable = toCompatibleReadable(reader.createReadable ? reader.createReadable() : reader.readable);
7133
+ const readable = toCompatibleReadable(createReadable(reader));
7010
7134
  const size = reader.size;
7011
7135
  const workerOptions = {
7012
7136
  options: {
@@ -7118,14 +7242,14 @@ function getHeaderInfo(options) {
7118
7242
  if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
7119
7243
  const length = 4 + 16;
7120
7244
  const extraFieldZip64 = createRecordWriter(length);
7121
- extraFieldZip64.uint16(EXTRAFIELD_TYPE_ZIP64);
7122
- extraFieldZip64.uint16(length - 4);
7245
+ extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
7246
+ extraFieldZip64.writeUint16(length - 4);
7123
7247
  rawLocalExtraFieldZip64 = extraFieldZip64.array;
7124
7248
  if (zip64ExtraFieldComplete) {
7125
- extraFieldZip64.uint64(uncompressedSize);
7249
+ extraFieldZip64.writeUint64(uncompressedSize);
7126
7250
  if (uncompressedFile) {
7127
7251
  const encryptionOverhead = encrypted ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
7128
- extraFieldZip64.uint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
7252
+ extraFieldZip64.writeUint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
7129
7253
  }
7130
7254
  }
7131
7255
  } else {
@@ -7134,8 +7258,8 @@ function getHeaderInfo(options) {
7134
7258
  let rawExtraFieldAES;
7135
7259
  if (encrypted && !zipCrypto) {
7136
7260
  const extraFieldAES = createRecordWriter(getLength(EXTRAFIELD_DATA_AES) + 2);
7137
- extraFieldAES.uint16(EXTRAFIELD_TYPE_AES);
7138
- extraFieldAES.bytes(EXTRAFIELD_DATA_AES);
7261
+ extraFieldAES.writeUint16(EXTRAFIELD_TYPE_AES);
7262
+ extraFieldAES.writeBytes(EXTRAFIELD_DATA_AES);
7139
7263
  rawExtraFieldAES = extraFieldAES.array;
7140
7264
  rawExtraFieldAES[8] = encryptionStrength;
7141
7265
  } else {
@@ -7151,15 +7275,15 @@ function getHeaderInfo(options) {
7151
7275
  const extraFieldTimestampLength = 9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0);
7152
7276
  const extraFieldTimestamp = createRecordWriter(extraFieldTimestampLength);
7153
7277
  extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
7154
- extraFieldTimestamp.uint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7155
- extraFieldTimestamp.uint16(extraFieldTimestampLength - 4);
7156
- extraFieldTimestamp.uint8(extraFieldExtendedTimestampFlag);
7157
- extraFieldTimestamp.uint32(lastModTimeUnix);
7278
+ extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7279
+ extraFieldTimestamp.writeUint16(extraFieldTimestampLength - 4);
7280
+ extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
7281
+ extraFieldTimestamp.writeUint32(lastModTimeUnix);
7158
7282
  if (lastAccessDate) {
7159
- extraFieldTimestamp.uint32(clampUnixTime(getTimeUnix(lastAccessDate)));
7283
+ extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(lastAccessDate)));
7160
7284
  }
7161
7285
  if (creationDate) {
7162
- extraFieldTimestamp.uint32(clampUnixTime(getTimeUnix(creationDate)));
7286
+ extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(creationDate)));
7163
7287
  }
7164
7288
  rawExtraFieldExtendedTimestamp = extraFieldTimestamp.array;
7165
7289
  } else {
@@ -7172,14 +7296,14 @@ function getHeaderInfo(options) {
7172
7296
  try {
7173
7297
  const lastModTimeNTFS = getTimeNTFS(lastModDate);
7174
7298
  const extraFieldNTFS = createRecordWriter(36);
7175
- extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS);
7176
- extraFieldNTFS.uint16(32);
7299
+ extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS);
7300
+ extraFieldNTFS.writeUint16(32);
7177
7301
  extraFieldNTFS.skip(4);
7178
- extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS_TAG1);
7179
- extraFieldNTFS.uint16(24);
7180
- extraFieldNTFS.uint64(lastModTimeNTFS);
7181
- extraFieldNTFS.uint64(lastAccessDate ? getTimeNTFS(lastAccessDate) : lastModTimeNTFS);
7182
- extraFieldNTFS.uint64(creationDate ? getTimeNTFS(creationDate) : lastModTimeNTFS);
7302
+ extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS_TAG1);
7303
+ extraFieldNTFS.writeUint16(24);
7304
+ extraFieldNTFS.writeUint64(lastModTimeNTFS);
7305
+ extraFieldNTFS.writeUint64(lastAccessDate ? getTimeNTFS(lastAccessDate) : lastModTimeNTFS);
7306
+ extraFieldNTFS.writeUint64(creationDate ? getTimeNTFS(creationDate) : lastModTimeNTFS);
7183
7307
  rawExtraFieldNTFS = extraFieldNTFS.array;
7184
7308
  } catch {
7185
7309
  rawExtraFieldNTFS = EMPTY_UINT8_ARRAY;
@@ -7198,20 +7322,20 @@ function getHeaderInfo(options) {
7198
7322
  const gidBytes = packUnixId(gid);
7199
7323
  const payloadLength = 3 + uidBytes.length + gidBytes.length;
7200
7324
  const extraFieldUnix = createRecordWriter(4 + payloadLength);
7201
- extraFieldUnix.uint16(EXTRAFIELD_TYPE_INFOZIP);
7202
- extraFieldUnix.uint16(payloadLength);
7203
- extraFieldUnix.uint8(1);
7204
- extraFieldUnix.uint8(uidBytes.length);
7205
- extraFieldUnix.bytes(uidBytes);
7206
- extraFieldUnix.uint8(gidBytes.length);
7207
- extraFieldUnix.bytes(gidBytes);
7325
+ extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
7326
+ extraFieldUnix.writeUint16(payloadLength);
7327
+ extraFieldUnix.writeUint8(1);
7328
+ extraFieldUnix.writeUint8(uidBytes.length);
7329
+ extraFieldUnix.writeBytes(uidBytes);
7330
+ extraFieldUnix.writeUint8(gidBytes.length);
7331
+ extraFieldUnix.writeBytes(gidBytes);
7208
7332
  rawExtraFieldUnix = extraFieldUnix.array;
7209
7333
  } else if (unixExtraFieldType == UNIX_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
7210
7334
  const extraFieldUnix = createRecordWriter(8);
7211
- extraFieldUnix.uint16(EXTRAFIELD_TYPE_UNIX);
7212
- extraFieldUnix.uint16(4);
7213
- extraFieldUnix.uint16((uid === UNDEFINED_VALUE ? 0 : uid) & MAX_16_BITS);
7214
- extraFieldUnix.uint16((gid === UNDEFINED_VALUE ? 0 : gid) & MAX_16_BITS);
7335
+ extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_UNIX);
7336
+ extraFieldUnix.writeUint16(4);
7337
+ extraFieldUnix.writeUint16((uid === UNDEFINED_VALUE ? 0 : uid) & MAX_16_BITS);
7338
+ extraFieldUnix.writeUint16((gid === UNDEFINED_VALUE ? 0 : gid) & MAX_16_BITS);
7215
7339
  rawExtraFieldUnix = extraFieldUnix.array;
7216
7340
  } else {
7217
7341
  rawExtraFieldUnix = EMPTY_UINT8_ARRAY;
@@ -7261,18 +7385,18 @@ function getHeaderInfo(options) {
7261
7385
  const localHeader = createRecordWriter(HEADER_SIZE + getLength(rawFilename) + extraFieldLength);
7262
7386
  const localHeaderArray = localHeader.array;
7263
7387
  const localHeaderView = getDataView(localHeaderArray);
7264
- localHeader.uint32(LOCAL_FILE_HEADER_SIGNATURE);
7265
- localHeader.bytes(headerArray);
7266
- localHeader.bytes(rawFilename);
7388
+ localHeader.writeUint32(LOCAL_FILE_HEADER_SIGNATURE);
7389
+ localHeader.writeBytes(headerArray);
7390
+ localHeader.writeBytes(rawFilename);
7267
7391
  if (writeLocalExtraFieldZip64) {
7268
- localHeader.bytes(rawLocalExtraFieldZip64);
7269
- }
7270
- localHeader.bytes(rawExtraFieldAES);
7271
- localHeader.bytes(rawExtraFieldExtendedTimestamp);
7272
- localHeader.bytes(rawExtraFieldNTFS);
7273
- localHeader.bytes(rawExtraFieldUnix);
7274
- localHeader.bytes(rawExtraField);
7275
- localHeader.bytes(rawLocalExtraField);
7392
+ localHeader.writeBytes(rawLocalExtraFieldZip64);
7393
+ }
7394
+ localHeader.writeBytes(rawExtraFieldAES);
7395
+ localHeader.writeBytes(rawExtraFieldExtendedTimestamp);
7396
+ localHeader.writeBytes(rawExtraFieldNTFS);
7397
+ localHeader.writeBytes(rawExtraFieldUnix);
7398
+ localHeader.writeBytes(rawExtraField);
7399
+ localHeader.writeBytes(rawLocalExtraField);
7276
7400
  if (dataDescriptor) {
7277
7401
  if (!zip64CompressedSize) {
7278
7402
  setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + LOCAL_HEADER_COMMON_OFFSET, 0);
@@ -7462,7 +7586,7 @@ function updateLocalHeader({
7462
7586
 
7463
7587
 
7464
7588
  async function closeFile(zipWriter, comment, options) {
7465
- const directoryDataLength = createDirectoryRecords(zipWriter.files);
7589
+ const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
7466
7590
  const { directoryStart, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
7467
7591
  const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
7468
7592
  await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryDataLength, signatureLength });
@@ -7492,19 +7616,19 @@ function createDirectoryRecords(files) {
7492
7616
  if (zip64Offset || zip64DiskNumberStart || zip64UncompressedSize || zip64CompressedSize) {
7493
7617
  const length = 4 + (zip64UncompressedSize ? 8 : 0) + (zip64CompressedSize ? 8 : 0) + (zip64Offset ? 8 : 0) + (zip64DiskNumberStart ? 4 : 0);
7494
7618
  const extraFieldZip64 = createRecordWriter(length);
7495
- extraFieldZip64.uint16(EXTRAFIELD_TYPE_ZIP64);
7496
- extraFieldZip64.uint16(length - 4);
7619
+ extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
7620
+ extraFieldZip64.writeUint16(length - 4);
7497
7621
  if (zip64UncompressedSize) {
7498
- extraFieldZip64.uint64(uncompressedSize);
7622
+ extraFieldZip64.writeUint64(uncompressedSize);
7499
7623
  }
7500
7624
  if (zip64CompressedSize) {
7501
- extraFieldZip64.uint64(compressedSize);
7625
+ extraFieldZip64.writeUint64(compressedSize);
7502
7626
  }
7503
7627
  if (zip64Offset) {
7504
- extraFieldZip64.uint64(fileEntry.offset);
7628
+ extraFieldZip64.writeUint64(fileEntry.offset);
7505
7629
  }
7506
7630
  if (zip64DiskNumberStart) {
7507
- extraFieldZip64.uint32(fileEntry.diskNumberStart);
7631
+ extraFieldZip64.writeUint32(fileEntry.diskNumberStart);
7508
7632
  }
7509
7633
  rawExtraFieldZip64 = extraFieldZip64.array;
7510
7634
  } else {
@@ -7517,10 +7641,10 @@ function createDirectoryRecords(files) {
7517
7641
  const lastModTimeUnix = getTimeUnix(lastModDate);
7518
7642
  if (extendedTimestamp && inUnixTimeRange(lastModTimeUnix)) {
7519
7643
  const extraFieldTimestamp = createRecordWriter(9);
7520
- extraFieldTimestamp.uint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7521
- extraFieldTimestamp.uint16(5);
7522
- extraFieldTimestamp.uint8(extraFieldExtendedTimestampFlag);
7523
- extraFieldTimestamp.uint32(lastModTimeUnix);
7644
+ extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7645
+ extraFieldTimestamp.writeUint16(5);
7646
+ extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
7647
+ extraFieldTimestamp.writeUint32(lastModTimeUnix);
7524
7648
  rawExtraFieldTimestamp = extraFieldTimestamp.array;
7525
7649
  } else {
7526
7650
  rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
@@ -7542,14 +7666,14 @@ function createDirectoryRecords(files) {
7542
7666
  }
7543
7667
 
7544
7668
  async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
7545
- const { files, writer } = zipWriter;
7669
+ const { fileEntries, writer } = zipWriter;
7546
7670
  const directoryArray = new Uint8Array(directoryDataLength);
7547
7671
  await initStream(writer);
7548
7672
  let offset = 0;
7549
7673
  let directoryDiskOffset = 0;
7550
7674
  let directoryStartDiskNumber = getDiskNumber(writer);
7551
7675
  let directoryStartDiskOffset = getDiskOffset(writer);
7552
- for (const [indexFileEntry, fileEntry] of Array.from(files.values()).entries()) {
7676
+ for (const [indexFileEntry, fileEntry] of Array.from(fileEntries.values()).entries()) {
7553
7677
  const {
7554
7678
  offset: fileEntryOffset,
7555
7679
  rawFilename,
@@ -7594,28 +7718,28 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
7594
7718
  setUint16(headerView, HEADER_OFFSET_VERSION, VERSION_ZIP64);
7595
7719
  }
7596
7720
  const directoryRecord = createRecordWriter(directoryRecordLength);
7597
- directoryRecord.uint32(CENTRAL_FILE_HEADER_SIGNATURE);
7598
- directoryRecord.uint16(versionMadeBy);
7599
- directoryRecord.bytes(headerArray.subarray(0, HEADER_SIZE - 4 - 2));
7600
- directoryRecord.uint16(extraFieldLength);
7601
- directoryRecord.uint16(getLength(rawComment));
7602
- directoryRecord.uint16(zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
7603
- directoryRecord.uint16(internalFileAttributes);
7604
- directoryRecord.uint32(externalFileAttributes);
7605
- directoryRecord.uint32(zip64Offset ? MAX_32_BITS : fileEntryOffset);
7606
- directoryRecord.bytes(rawFilename);
7607
- directoryRecord.bytes(rawExtraFieldZip64);
7608
- directoryRecord.bytes(rawExtraFieldAES);
7609
- directoryRecord.bytes(rawExtraFieldExtendedTimestamp);
7610
- directoryRecord.bytes(rawExtraFieldNTFS);
7611
- directoryRecord.bytes(rawExtraFieldUnix);
7612
- directoryRecord.bytes(rawExtraField);
7613
- directoryRecord.bytes(rawComment);
7721
+ directoryRecord.writeUint32(CENTRAL_FILE_HEADER_SIGNATURE);
7722
+ directoryRecord.writeUint16(versionMadeBy);
7723
+ directoryRecord.writeBytes(headerArray.subarray(0, HEADER_SIZE - 4 - 2));
7724
+ directoryRecord.writeUint16(extraFieldLength);
7725
+ directoryRecord.writeUint16(getLength(rawComment));
7726
+ directoryRecord.writeUint16(zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
7727
+ directoryRecord.writeUint16(internalFileAttributes);
7728
+ directoryRecord.writeUint32(externalFileAttributes);
7729
+ directoryRecord.writeUint32(zip64Offset ? MAX_32_BITS : fileEntryOffset);
7730
+ directoryRecord.writeBytes(rawFilename);
7731
+ directoryRecord.writeBytes(rawExtraFieldZip64);
7732
+ directoryRecord.writeBytes(rawExtraFieldAES);
7733
+ directoryRecord.writeBytes(rawExtraFieldExtendedTimestamp);
7734
+ directoryRecord.writeBytes(rawExtraFieldNTFS);
7735
+ directoryRecord.writeBytes(rawExtraFieldUnix);
7736
+ directoryRecord.writeBytes(rawExtraField);
7737
+ directoryRecord.writeBytes(rawComment);
7614
7738
  arraySet(directoryArray, directoryRecord.array, offset);
7615
7739
  offset += directoryRecordLength;
7616
7740
  if (options.onprogress) {
7617
7741
  try {
7618
- await options.onprogress(indexFileEntry + 1, files.size, new Entry(fileEntry));
7742
+ await options.onprogress(indexFileEntry + 1, fileEntries.size, new Entry(fileEntry));
7619
7743
  } catch {
7620
7744
  // ignored
7621
7745
  }
@@ -7629,7 +7753,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
7629
7753
  }
7630
7754
 
7631
7755
  async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
7632
- const signCentralDirectory = getOptionValue(zipWriter, options, OPTION_SIGN_CENTRAL_DIRECTORY);
7756
+ const signCentralDirectory = getFunctionOptionValue(zipWriter, options, OPTION_SIGN_CENTRAL_DIRECTORY);
7633
7757
  if (signCentralDirectory) {
7634
7758
  const signatureData = await signCentralDirectory(directoryArray);
7635
7759
  const signatureDataLength = getLength(signatureData);
@@ -7637,9 +7761,9 @@ async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
7637
7761
  throw new Error(ERR_INVALID_SIGNATURE_DATA);
7638
7762
  }
7639
7763
  const signatureRecord = createRecordWriter(6 + signatureDataLength);
7640
- signatureRecord.uint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
7641
- signatureRecord.uint16(signatureDataLength);
7642
- signatureRecord.bytes(signatureData);
7764
+ signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
7765
+ signatureRecord.writeUint16(signatureDataLength);
7766
+ signatureRecord.writeBytes(signatureData);
7643
7767
  await writeData(zipWriter.writer, signatureRecord.array);
7644
7768
  return 6 + signatureDataLength;
7645
7769
  }
@@ -7650,7 +7774,7 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
7650
7774
  const { writer } = zipWriter;
7651
7775
  const { directoryStart, signatureLength } = cdInfo;
7652
7776
  let { directoryDataLength } = cdInfo;
7653
- let filesLength = zipWriter.files.size;
7777
+ let fileEntriesLength = zipWriter.fileEntries.size;
7654
7778
  let diskNumber = directoryStart.diskNumber;
7655
7779
  let directoryOffset = getSegmentOffset(zipWriter, directoryStart);
7656
7780
  let lastDiskNumber = getDiskNumber(writer);
@@ -7658,7 +7782,7 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
7658
7782
  lastDiskNumber++;
7659
7783
  }
7660
7784
  let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
7661
- if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS || lastDiskNumber >= MAX_16_BITS) {
7785
+ if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || fileEntriesLength >= MAX_16_BITS || lastDiskNumber >= MAX_16_BITS) {
7662
7786
  if (zip64 === false) {
7663
7787
  throw new Error(ERR_UNSUPPORTED_FORMAT);
7664
7788
  } else {
@@ -7675,37 +7799,37 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
7675
7799
  }
7676
7800
  lastDiskNumber = getDiskNumber(writer);
7677
7801
  if (zip64) {
7678
- endOfdirectoryRecord.uint32(ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
7679
- endOfdirectoryRecord.uint64(44);
7680
- endOfdirectoryRecord.uint16(45);
7681
- endOfdirectoryRecord.uint16(45);
7682
- endOfdirectoryRecord.uint32(lastDiskNumber);
7683
- endOfdirectoryRecord.uint32(diskNumber);
7684
- endOfdirectoryRecord.uint64(filesLength);
7685
- endOfdirectoryRecord.uint64(filesLength);
7686
- endOfdirectoryRecord.uint64(directoryDataLength);
7687
- endOfdirectoryRecord.uint64(directoryOffset);
7688
- endOfdirectoryRecord.uint32(ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
7689
- endOfdirectoryRecord.uint32(lastDiskNumber);
7690
- endOfdirectoryRecord.uint64(BigInt(getSegmentOffset(zipWriter, writer)) + BigInt(directoryDataLength) + BigInt(signatureLength));
7691
- endOfdirectoryRecord.uint32(lastDiskNumber + 1);
7802
+ endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
7803
+ endOfdirectoryRecord.writeUint64(44);
7804
+ endOfdirectoryRecord.writeUint16(45);
7805
+ endOfdirectoryRecord.writeUint16(45);
7806
+ endOfdirectoryRecord.writeUint32(lastDiskNumber);
7807
+ endOfdirectoryRecord.writeUint32(diskNumber);
7808
+ endOfdirectoryRecord.writeUint64(fileEntriesLength);
7809
+ endOfdirectoryRecord.writeUint64(fileEntriesLength);
7810
+ endOfdirectoryRecord.writeUint64(directoryDataLength);
7811
+ endOfdirectoryRecord.writeUint64(directoryOffset);
7812
+ endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
7813
+ endOfdirectoryRecord.writeUint32(lastDiskNumber);
7814
+ endOfdirectoryRecord.writeUint64(BigInt(getSegmentOffset(zipWriter, writer)) + BigInt(directoryDataLength) + BigInt(signatureLength));
7815
+ endOfdirectoryRecord.writeUint32(lastDiskNumber + 1);
7692
7816
  const supportZip64SplitFile = getOptionValue(zipWriter, options, OPTION_SUPPORT_ZIP64_SPLIT_FILE, true);
7693
7817
  if (supportZip64SplitFile) {
7694
7818
  lastDiskNumber = MAX_16_BITS;
7695
7819
  diskNumber = MAX_16_BITS;
7696
7820
  }
7697
- filesLength = MAX_16_BITS;
7821
+ fileEntriesLength = MAX_16_BITS;
7698
7822
  directoryOffset = MAX_32_BITS;
7699
7823
  directoryDataLength = MAX_32_BITS;
7700
7824
  }
7701
- endOfdirectoryRecord.uint32(END_OF_CENTRAL_DIR_SIGNATURE);
7702
- endOfdirectoryRecord.uint16(lastDiskNumber);
7703
- endOfdirectoryRecord.uint16(diskNumber);
7704
- endOfdirectoryRecord.uint16(filesLength);
7705
- endOfdirectoryRecord.uint16(filesLength);
7706
- endOfdirectoryRecord.uint32(directoryDataLength);
7707
- endOfdirectoryRecord.uint32(directoryOffset);
7708
- endOfdirectoryRecord.uint16(commentLength);
7825
+ endOfdirectoryRecord.writeUint32(END_OF_CENTRAL_DIR_SIGNATURE);
7826
+ endOfdirectoryRecord.writeUint16(lastDiskNumber);
7827
+ endOfdirectoryRecord.writeUint16(diskNumber);
7828
+ endOfdirectoryRecord.writeUint16(fileEntriesLength);
7829
+ endOfdirectoryRecord.writeUint16(fileEntriesLength);
7830
+ endOfdirectoryRecord.writeUint32(directoryDataLength);
7831
+ endOfdirectoryRecord.writeUint32(directoryOffset);
7832
+ endOfdirectoryRecord.writeUint16(commentLength);
7709
7833
  await writeData(writer, endOfdirectoryRecord.array);
7710
7834
  if (commentLength) {
7711
7835
  await writeData(writer, comment);
@@ -7718,11 +7842,11 @@ function createRecordWriter(length) {
7718
7842
  let offset = 0;
7719
7843
  return {
7720
7844
  array,
7721
- uint8: value => { setUint8(view, offset, value); offset += 1; },
7722
- uint16: value => { setUint16(view, offset, value); offset += 2; },
7723
- uint32: value => { setUint32(view, offset, value); offset += 4; },
7724
- uint64: value => { setBigUint64(view, offset, BigInt(value)); offset += 8; },
7725
- bytes: value => { arraySet(array, value, offset); offset += getLength(value); },
7845
+ writeUint8: value => { setUint8(view, offset, value); offset += 1; },
7846
+ writeUint16: value => { setUint16(view, offset, value); offset += 2; },
7847
+ writeUint32: value => { setUint32(view, offset, value); offset += 4; },
7848
+ writeUint64: value => { setBigUint64(view, offset, BigInt(value)); offset += 8; },
7849
+ writeBytes: value => { arraySet(array, value, offset); offset += getLength(value); },
7726
7850
  skip: count => offset += count
7727
7851
  };
7728
7852
  }
@@ -7746,6 +7870,71 @@ function getSegmentOffset(zipWriter, { diskNumber = 0, diskOffset = 0 }) {
7746
7870
  return zipWriter.offset - diskOffset - (diskNumber ? zipWriter.initialOffset : 0);
7747
7871
  }
7748
7872
 
7873
+ async function startsWithSplitZipSignature(reader) {
7874
+ const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
7875
+ return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
7876
+ }
7877
+
7878
+ async function copyZipData(zipWriter, reader, entries, directoryOffset, splitZipSignatureLength) {
7879
+ const { writer } = zipWriter;
7880
+ const entryPositions = new Map();
7881
+ if (writer.closeDisk) {
7882
+ const sortedEntries = Array.from(entries).sort((firstEntry, secondEntry) =>
7883
+ getSourceOffset(reader, firstEntry) - getSourceOffset(reader, secondEntry));
7884
+ let copiedLength = 0;
7885
+ for (const entry of sortedEntries) {
7886
+ const sourceOffset = getSourceOffset(reader, entry);
7887
+ await copyData(zipWriter, reader, copiedLength, sourceOffset - copiedLength);
7888
+ if (exceedsAvailableSize(writer, await getLocalHeaderLength(reader, sourceOffset))) {
7889
+ await writer.closeDisk();
7890
+ }
7891
+ entryPositions.set(entry, {
7892
+ offset: getSegmentOffset(zipWriter, writer),
7893
+ diskNumberStart: getDiskNumber(writer)
7894
+ });
7895
+ copiedLength = sourceOffset;
7896
+ }
7897
+ await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
7898
+ } else {
7899
+ await copyData(zipWriter, reader, 0, directoryOffset);
7900
+ entries.forEach(entry => entryPositions.set(entry, {
7901
+ offset: splitZipSignatureLength + getSourceOffset(reader, entry),
7902
+ diskNumberStart: 0
7903
+ }));
7904
+ }
7905
+ return entryPositions;
7906
+ }
7907
+
7908
+ async function copyData(zipWriter, reader, offset, size) {
7909
+ if (size > 0) {
7910
+ const { writer } = zipWriter;
7911
+ await createReadable(reader, { offset, size }).pipeTo(writer.writable, { preventClose: true, preventAbort: true });
7912
+ writer.size += size;
7913
+ zipWriter.offset += size;
7914
+ }
7915
+ }
7916
+
7917
+ async function getLocalHeaderLength(reader, offset) {
7918
+ const headerArray = await readUint8Array(reader, offset, HEADER_SIZE);
7919
+ if (getLength(headerArray) < HEADER_SIZE) {
7920
+ return HEADER_SIZE;
7921
+ }
7922
+ const headerView = getDataView(headerArray);
7923
+ return HEADER_SIZE +
7924
+ getUint16(headerView, HEADER_OFFSET_FILENAME_LENGTH + LOCAL_HEADER_COMMON_OFFSET) +
7925
+ getUint16(headerView, HEADER_OFFSET_EXTRAFIELD_LENGTH + LOCAL_HEADER_COMMON_OFFSET);
7926
+ }
7927
+
7928
+ function getSourceOffset(reader, { offset, diskNumberStart }) {
7929
+ return offset + (reader.getDiskOffset ? reader.getDiskOffset(diskNumberStart) : 0);
7930
+ }
7931
+
7932
+ function getSplitZipSignatureArray() {
7933
+ const signatureArray = new Uint8Array(SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
7934
+ setUint32(getDataView(signatureArray), 0, SPLIT_ZIP_FILE_SIGNATURE);
7935
+ return signatureArray;
7936
+ }
7937
+
7749
7938
  async function writeData(writer, array) {
7750
7939
  const { writable } = writer;
7751
7940
  const streamWriter = writable.getWriter();
@@ -7797,6 +7986,21 @@ function getOptionValue(zipWriter, options, name, defaultValue) {
7797
7986
  return result === UNDEFINED_VALUE ? defaultValue : result;
7798
7987
  }
7799
7988
 
7989
+ function getDateOptionValue(zipWriter, options, name, defaultValue) {
7990
+ const date = getOptionValue(zipWriter, options, name, defaultValue);
7991
+ if (date === null) {
7992
+ return defaultValue;
7993
+ }
7994
+ if (date !== UNDEFINED_VALUE && (typeof date.getTime != FUNCTION_TYPE || Number.isNaN(date.getTime()))) {
7995
+ throw new Error(ERR_INVALID_DATE);
7996
+ }
7997
+ return date;
7998
+ }
7999
+
8000
+ function getFunctionOptionValue(zipWriter, options, name) {
8001
+ return checkFunctionOption(getOptionValue(zipWriter, options, name));
8002
+ }
8003
+
7800
8004
  function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
7801
8005
  const value = getAliasedValue(options, name, deprecatedName);
7802
8006
  const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
@@ -7811,9 +8015,6 @@ function getNumberOptionValue(zipWriter, options, name, defaultValue) {
7811
8015
  return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
7812
8016
  }
7813
8017
 
7814
- function toNumber(value) {
7815
- return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
7816
- }
7817
8018
 
7818
8019
  function getMaximumCompressedSize(uncompressedSize) {
7819
8020
  return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
@@ -7825,6 +8026,14 @@ function isCompressed(compressionMethod, level) {
7825
8026
  : compressionMethod !== COMPRESSION_METHOD_STORE;
7826
8027
  }
7827
8028
 
8029
+ function getUint16(view, offset) {
8030
+ return view.getUint16(offset, true);
8031
+ }
8032
+
8033
+ function getUint32(view, offset) {
8034
+ return view.getUint32(offset, true);
8035
+ }
8036
+
7828
8037
  function setUint8(view, offset, value) {
7829
8038
  view.setUint8(offset, value);
7830
8039
  }
@@ -7868,9 +8077,9 @@ function getHeaderArrayData({
7868
8077
  const headerRecord = createRecordWriter(HEADER_SIZE - 4);
7869
8078
  const headerArray = headerRecord.array;
7870
8079
  const headerView = getDataView(headerArray);
7871
- headerRecord.uint16(version);
7872
- headerRecord.uint16(bitFlag);
7873
- headerRecord.uint16(compressionMethod);
8080
+ headerRecord.writeUint16(version);
8081
+ headerRecord.writeUint16(bitFlag);
8082
+ headerRecord.writeUint16(compressionMethod);
7874
8083
  if (rawLastModDate === UNDEFINED_VALUE) {
7875
8084
  const dateArray = new Uint32Array(1);
7876
8085
  const dateView = getDataView(dateArray);
@@ -7878,20 +8087,20 @@ function getHeaderArrayData({
7878
8087
  setUint16(dateView, 2, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate());
7879
8088
  rawLastModDate = dateArray[0];
7880
8089
  }
7881
- headerRecord.uint32(rawLastModDate);
8090
+ headerRecord.writeUint32(rawLastModDate);
7882
8091
  headerRecord.skip(4);
7883
8092
  if (zip64CompressedSize || compressedSize !== UNDEFINED_VALUE) {
7884
- headerRecord.uint32(zip64CompressedSize ? MAX_32_BITS : compressedSize);
8093
+ headerRecord.writeUint32(zip64CompressedSize ? MAX_32_BITS : compressedSize);
7885
8094
  } else {
7886
8095
  headerRecord.skip(4);
7887
8096
  }
7888
8097
  if (zip64UncompressedSize || uncompressedSize !== UNDEFINED_VALUE) {
7889
- headerRecord.uint32(zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
8098
+ headerRecord.writeUint32(zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
7890
8099
  } else {
7891
8100
  headerRecord.skip(4);
7892
8101
  }
7893
- headerRecord.uint16(getLength(rawFilename));
7894
- headerRecord.uint16(extraFieldLength);
8102
+ headerRecord.writeUint16(getLength(rawFilename));
8103
+ headerRecord.writeUint16(extraFieldLength);
7895
8104
  return {
7896
8105
  headerArray,
7897
8106
  headerView,
@@ -8839,6 +9048,7 @@ U(setDefaultConfiguration);
8839
9048
  const ERR_ENTRY_EXISTS = "Entry filename already exists";
8840
9049
  const ERR_READABLE_CONSUMED = "Readable stream already consumed";
8841
9050
  const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.passThrough or set uncompressedSize for each entry)";
9051
+ const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
8842
9052
  const ERR_ABORT_EXPORT = "zipjs-abort-export";
8843
9053
  const ERR_ABORTED = "The operation was aborted";
8844
9054
  const ABORT_ERROR_NAME = "AbortError";
@@ -8871,13 +9081,14 @@ class ZipEntry {
8871
9081
  fs,
8872
9082
  name,
8873
9083
  data: params.data,
8874
- options: params.options,
9084
+ options: params.options && Object.assign({}, params.options),
8875
9085
  id: fs.entryIdCounter++,
8876
9086
  parent,
8877
9087
  children: [],
8878
9088
  uncompressedSize: params.uncompressedSize || 0,
8879
9089
  undeterminedSize: params.undeterminedSize || params.uncompressedSize === UNDEFINED_VALUE,
8880
- passThrough: params.passThrough
9090
+ passThrough: params.passThrough,
9091
+ defaultLastModDate: params.defaultLastModDate || new Date()
8881
9092
  });
8882
9093
  if (parent || !fs.root) {
8883
9094
  fs.entries[zipEntry.id] = zipEntry;
@@ -8887,12 +9098,6 @@ class ZipEntry {
8887
9098
  }
8888
9099
  }
8889
9100
 
8890
- moveTo(target) {
8891
- // deprecated
8892
- const zipEntry = this;
8893
- zipEntry.fs.move(zipEntry, target);
8894
- }
8895
-
8896
9101
  getFullname() {
8897
9102
  return this.getRelativeName();
8898
9103
  }
@@ -8924,6 +9129,11 @@ class ZipEntry {
8924
9129
  this.name = name;
8925
9130
  }
8926
9131
  }
9132
+
9133
+ setOptions(options) {
9134
+ const entryOptions = Object.assign({}, this.options, options);
9135
+ this.options = Object.fromEntries(Object.entries(entryOptions).filter(([, value]) => value !== UNDEFINED_VALUE));
9136
+ }
8927
9137
  }
8928
9138
 
8929
9139
  class ZipFileEntry extends ZipEntry {
@@ -8950,7 +9160,7 @@ class ZipFileEntry extends ZipEntry {
8950
9160
  const reader = zipEntry.reader = createReader(zipEntry.Reader, zipEntry.data, options);
8951
9161
  const dataSize = zipEntry.uncompressedSize || reader.size;
8952
9162
  await Promise.all([initStream(reader), initStream(writer, dataSize)]);
8953
- const { signal } = options;
9163
+ const signal = checkSignalOption(options.signal);
8954
9164
  const readable = createProgressReadable(zipEntry, reader, options, signal);
8955
9165
  const preventClose = !ownsWritable(writer) && Boolean(options.preventClose);
8956
9166
  zipEntry.uncompressedSize = reader.size;
@@ -9168,10 +9378,6 @@ class ZipDirectoryEntry extends ZipEntry {
9168
9378
  });
9169
9379
  }
9170
9380
 
9171
- addData(name, params) {
9172
- return addChild(this, name, params);
9173
- }
9174
-
9175
9381
  importBlob(blob, options) {
9176
9382
  return this.importZip(new BlobReader(blob), options);
9177
9383
  }
@@ -9285,7 +9491,7 @@ class ZipDirectoryEntry extends ZipEntry {
9285
9491
  if (options.bufferedWrite === UNDEFINED_VALUE) {
9286
9492
  options.bufferedWrite = true;
9287
9493
  }
9288
- const [readers] = await Promise.all([initReaders(zipEntry, options.readerOptions), initStream(writer)]);
9494
+ const [readers] = await Promise.all([initReaders(zipEntry, checkReaderOptions(options.readerOptions)), initStream(writer)]);
9289
9495
  const zipWriter = new ZipWriter(writer, options);
9290
9496
  await exportZip(zipWriter, zipEntry, getTotalSize([zipEntry], getUncompressedSize), options, readers);
9291
9497
  await zipWriter.close(options.globalComment);
@@ -9295,12 +9501,13 @@ class ZipDirectoryEntry extends ZipEntry {
9295
9501
  getExportedSize(options = {}) {
9296
9502
  const zipEntry = this;
9297
9503
  options = Object.assign({}, options);
9504
+ checkReaderOptions(options.readerOptions);
9298
9505
  if (options.bufferedWrite === UNDEFINED_VALUE) {
9299
9506
  options.bufferedWrite = true;
9300
9507
  }
9301
9508
  const writeOrderGuaranteed = !options.bufferedWrite ||
9302
9509
  (options.keepOrder !== false && zipEntry.children.every(child => !child.children.length));
9303
- return getEntriesSize(options, Array.from(zipEntry.getChildren({ recursive: true }), child => {
9510
+ return getEntriesSize(options, zipEntry.getChildren({ recursive: true }).filter(child => !isImplicitDirectory(child)).map(child => {
9304
9511
  const { name, entryOptions } = getChildEntryOptions(child, zipEntry, options);
9305
9512
  return { name, size: child.directory ? 0 : getDeterminedSize(child, isPassThrough(child, options)), options: entryOptions };
9306
9513
  }), writeOrderGuaranteed, options.globalComment);
@@ -9339,7 +9546,7 @@ class ZipDirectoryEntry extends ZipEntry {
9339
9546
  }
9340
9547
 
9341
9548
 
9342
- class FS {
9549
+ class ZipFS {
9343
9550
 
9344
9551
  constructor() {
9345
9552
  resetFS(this);
@@ -9455,10 +9662,6 @@ class FS {
9455
9662
  return this.root.addFile(file, options);
9456
9663
  }
9457
9664
 
9458
- addData(name, params) {
9459
- return this.root.addData(name, params);
9460
- }
9461
-
9462
9665
  importBlob(blob, options) {
9463
9666
  resetFS(this);
9464
9667
  return this.root.importBlob(blob, options);
@@ -9526,7 +9729,7 @@ class FS {
9526
9729
  }
9527
9730
  }
9528
9731
 
9529
- const fs = { FS, ZipDirectoryEntry, ZipFileEntry };
9732
+ const fs = { FS: ZipFS, ZipDirectoryEntry, ZipFileEntry };
9530
9733
 
9531
9734
  function getTotalSize(entries, getEntrySize) {
9532
9735
  let size = 0;
@@ -9670,7 +9873,7 @@ function detach(entry) {
9670
9873
  }
9671
9874
 
9672
9875
  function forwardAbort(signal, abortController) {
9673
- if (!signal) {
9876
+ if (!checkSignalOption(signal)) {
9674
9877
  return () => { };
9675
9878
  }
9676
9879
  if (signal.aborted) {
@@ -9766,7 +9969,7 @@ function getChildEntryOptions(child, selectedEntry, options) {
9766
9969
  };
9767
9970
  }
9768
9971
  }
9769
- const entryOptions = Object.assign({}, zipEntryMetadata, options, passThroughOptions, childOptions, { directory: child.directory });
9972
+ const entryOptions = Object.assign({ lastModDate: child.defaultLastModDate }, zipEntryMetadata, options, childOptions, passThroughOptions, { directory: child.directory });
9770
9973
  if (!child.directory && entryOptions.passThrough && entryOptions.uncompressedSize === UNDEFINED_VALUE) {
9771
9974
  throw new Error(ERR_INVALID_PASS_THROUGH);
9772
9975
  }
@@ -9781,11 +9984,22 @@ function getDeterminedSize(child, passThrough) {
9781
9984
  return child.undeterminedSize ? UNDEFINED_VALUE : getExtractedSize(child, passThrough);
9782
9985
  }
9783
9986
 
9987
+ function checkReaderOptions(readerOptions) {
9988
+ if (readerOptions && (typeof readerOptions != OBJECT_TYPE || Array.isArray(readerOptions))) {
9989
+ throw new Error(ERR_INVALID_READER_OPTIONS);
9990
+ }
9991
+ return readerOptions;
9992
+ }
9993
+
9784
9994
  function isPassThrough(child, options) {
9785
9995
  const { readerOptions } = options;
9786
9996
  return Boolean(!child.directory && (child.passThrough || (readerOptions && readerOptions.passThrough)));
9787
9997
  }
9788
9998
 
9999
+ function isImplicitDirectory(child) {
10000
+ return child.directory && child.data === null;
10001
+ }
10002
+
9789
10003
  function getUserExtraField(extraField) {
9790
10004
  if (extraField) {
9791
10005
  const userExtraField = new Map();
@@ -9803,7 +10017,7 @@ function getUserExtraField(extraField) {
9803
10017
  async function exportZip(zipWriter, entry, totalSize, options, readers) {
9804
10018
  const { onstart, onprogress, onend, onentryprogress } = options;
9805
10019
  const selectedEntry = entry;
9806
- const totalEntries = getTotalSize(entry.children, () => 1);
10020
+ const totalEntries = getTotalSize(entry.children, child => isImplicitDirectory(child) ? 0 : 1);
9807
10021
  let writtenSize = 0;
9808
10022
  let writtenEntries = 0;
9809
10023
  if (onstart) {
@@ -9832,6 +10046,9 @@ async function exportZip(zipWriter, entry, totalSize, options, readers) {
9832
10046
  }
9833
10047
 
9834
10048
  async function addChild(child) {
10049
+ if (isImplicitDirectory(child)) {
10050
+ return;
10051
+ }
9835
10052
  const { name, entryOptions } = getChildEntryOptions(child, selectedEntry, options);
9836
10053
  let entryWrittenSize = 0;
9837
10054
  const entryMetadata = await zipWriter.add(name, readers.get(child), Object.assign(entryOptions, {
@@ -9865,7 +10082,7 @@ function addFileSystemHandle(zipEntry, handle, options) {
9865
10082
  if (handle.kind == "file") {
9866
10083
  const file = await handle.getFile();
9867
10084
  addedEntries.push(
9868
- parentEntry.addData(file.name, {
10085
+ addChild(parentEntry, file.name, {
9869
10086
  Reader: function () {
9870
10087
  const readable = file.stream();
9871
10088
  const size = file.size;
@@ -9899,10 +10116,11 @@ function addFileSystemHandle(zipEntry, handle, options) {
9899
10116
 
9900
10117
  async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
9901
10118
  const { onstart, onprogress, onend } = options;
10119
+ const readerOptions = checkReaderOptions(options.readerOptions);
9902
10120
  const abortController = new AbortController();
9903
10121
  const { signal } = abortController;
9904
10122
  const releaseSignal = forwardAbort(options.signal, abortController);
9905
- const getDataOptions = Object.assign({}, options, options.readerOptions, {
10123
+ const getDataOptions = Object.assign({}, options, readerOptions, {
9906
10124
  signal,
9907
10125
  onstart: UNDEFINED_VALUE,
9908
10126
  onprogress: UNDEFINED_VALUE,
@@ -10202,6 +10420,7 @@ exports.ERR_CENTRAL_DIRECTORY_NOT_FOUND = ERR_CENTRAL_DIRECTORY_NOT_FOUND;
10202
10420
  exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
10203
10421
  exports.ERR_ENCRYPTED = ERR_ENCRYPTED;
10204
10422
  exports.ERR_ENCRYPTED_CENTRAL_DIRECTORY = ERR_ENCRYPTED_CENTRAL_DIRECTORY;
10423
+ exports.ERR_ENTRY_DATA_OUT_OF_BOUNDS = ERR_ENTRY_DATA_OUT_OF_BOUNDS;
10205
10424
  exports.ERR_ENTRY_EXISTS = ERR_ENTRY_EXISTS;
10206
10425
  exports.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND = ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND;
10207
10426
  exports.ERR_EOCDR_NOT_FOUND = ERR_EOCDR_NOT_FOUND;
@@ -10215,20 +10434,28 @@ exports.ERR_INVALID_COMMENT = ERR_INVALID_COMMENT;
10215
10434
  exports.ERR_INVALID_COMMENT_TYPE = ERR_INVALID_COMMENT_TYPE;
10216
10435
  exports.ERR_INVALID_COMPRESSED_DATA = ERR_INVALID_COMPRESSED_DATA;
10217
10436
  exports.ERR_INVALID_CRC32 = ERR_INVALID_CRC32;
10437
+ exports.ERR_INVALID_DATE = ERR_INVALID_DATE;
10218
10438
  exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
10219
10439
  exports.ERR_INVALID_ENTRY_COMMENT = ERR_INVALID_ENTRY_COMMENT;
10440
+ exports.ERR_INVALID_ENTRY_COMMENT_TYPE = ERR_INVALID_ENTRY_COMMENT_TYPE;
10220
10441
  exports.ERR_INVALID_ENTRY_NAME = ERR_INVALID_ENTRY_NAME;
10442
+ exports.ERR_INVALID_EXTRAFIELD = ERR_INVALID_EXTRAFIELD;
10221
10443
  exports.ERR_INVALID_EXTRAFIELD_DATA = ERR_INVALID_EXTRAFIELD_DATA;
10444
+ exports.ERR_INVALID_EXTRAFIELD_DATA_TYPE = ERR_INVALID_EXTRAFIELD_DATA_TYPE;
10222
10445
  exports.ERR_INVALID_EXTRAFIELD_TYPE = ERR_INVALID_EXTRAFIELD_TYPE;
10223
10446
  exports.ERR_INVALID_FILENAME_VALIDATION = ERR_INVALID_FILENAME_VALIDATION;
10447
+ exports.ERR_INVALID_FUNCTION_OPTION = ERR_INVALID_FUNCTION_OPTION;
10224
10448
  exports.ERR_INVALID_GID = ERR_INVALID_GID;
10225
10449
  exports.ERR_INVALID_LEVEL = ERR_INVALID_LEVEL;
10226
10450
  exports.ERR_INVALID_MAX_APPENDED_DATA_SIZE = ERR_INVALID_MAX_APPENDED_DATA_SIZE;
10451
+ exports.ERR_INVALID_MAX_WORKERS = ERR_INVALID_MAX_WORKERS;
10227
10452
  exports.ERR_INVALID_MSDOS_ATTRIBUTES = ERR_INVALID_MSDOS_ATTRIBUTES;
10228
10453
  exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
10229
10454
  exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
10230
10455
  exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
10231
10456
  exports.ERR_INVALID_PASS_THROUGH = ERR_INVALID_PASS_THROUGH;
10457
+ exports.ERR_INVALID_READER_OPTIONS = ERR_INVALID_READER_OPTIONS;
10458
+ exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
10232
10459
  exports.ERR_INVALID_SIGNATURE = ERR_INVALID_SIGNATURE;
10233
10460
  exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
10234
10461
  exports.ERR_INVALID_STRICTNESS = ERR_INVALID_STRICTNESS;
@@ -10268,6 +10495,10 @@ exports.TextWriter = TextWriter;
10268
10495
  exports.Uint8ArrayReader = Uint8ArrayReader;
10269
10496
  exports.Uint8ArrayWriter = Uint8ArrayWriter;
10270
10497
  exports.Writer = Writer;
10498
+ exports.ZipDirectoryEntry = ZipDirectoryEntry;
10499
+ exports.ZipEntry = ZipEntry;
10500
+ exports.ZipFS = ZipFS;
10501
+ exports.ZipFileEntry = ZipFileEntry;
10271
10502
  exports.ZipReader = ZipReader;
10272
10503
  exports.ZipReaderStream = ZipReaderStream;
10273
10504
  exports.ZipWriter = ZipWriter;