@zip.js/zip.js 2.7.0 → 2.7.1

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 (2) hide show
  1. package/index.d.ts +1367 -1195
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -2,310 +2,314 @@
2
2
  * The global object.
3
3
  */
4
4
  declare global {
5
- /**
6
- * Represents the `FileSystemEntry` class.
7
- *
8
- * @see {@link https://wicg.github.io/entries-api/#api-entry|specification}
9
- */
10
- // deno-lint-ignore no-empty-interface
11
- interface FileSystemEntry { }
5
+ /**
6
+ * Represents the `FileSystemEntry` class.
7
+ *
8
+ * @see {@link https://wicg.github.io/entries-api/#api-entry|specification}
9
+ */
10
+ // deno-lint-ignore no-empty-interface
11
+ interface FileSystemEntry {}
12
12
  }
13
13
 
14
14
  /**
15
15
  * Represents a generic `TransformStream` class.
16
- *
16
+ *
17
17
  * @see {@link https://streams.spec.whatwg.org/#generictransformstream|specification}
18
18
  */
19
19
  declare class GenericTransformStream {
20
- readable: ReadableStream
21
- writable: WritableStream
20
+ readable: ReadableStream;
21
+ writable: WritableStream;
22
22
  }
23
23
 
24
24
  /**
25
25
  * Configures zip.js
26
- *
27
- * @param configuration The configuration.
26
+ *
27
+ * @param configuration The configuration.
28
28
  */
29
- export function configure(configuration: Configuration): void
29
+ export function configure(configuration: Configuration): void;
30
30
 
31
31
  /**
32
32
  * Represents the configuration passed to {@link configure}.
33
33
  */
34
34
  interface Configuration extends WorkerConfiguration {
35
- /**
36
- * The maximum number of web workers used to compress/decompress data simultaneously.
37
- *
38
- * @defaultValue `navigator.hardwareConcurrency`
39
- */
40
- maxWorkers?: number
41
- /**
42
- * The delay in milliseconds before idle web workers are automatically terminated. You can call `terminateWorkers()` to terminate idle workers.
43
- *
44
- * @defaultValue 5000
45
- */
46
- terminateWorkerTimeout?: number
47
- /**
48
- * The URIs of the compression/decompression scripts run in web workers.
49
- *
50
- * It allows using alternative deflate implementations or specifying a URL to the worker script if the CSP of the page blocks scripts imported from a Blob URI.
51
- * The properties `deflate` and `inflate` must specify arrays of URLs to import the deflate/inflate web workers, respectively.
52
- * The first URL is relative to the base URI of the document. The other URLs are relative to the URL of the first script. Scripts in the array are executed in order.
53
- * If you only use deflation or inflation, the unused `deflate`/`inflate` property can be omitted.
54
- *
55
- * Here is an example:
56
- * ```
57
- * configure({
58
- * workerScripts: {
59
- * deflate: ["library_path/custom-worker.js", "./custom-deflate.js"],
60
- * inflate: ["library_path/custom-worker.js", "./custom-inflate.js"]
61
- * }
62
- * });
63
- * ```
64
- *
65
- * If the CSP of the page blocks scripts imported from a Blob URI you can use `z-worker.js` from https://github.com/gildas-lormeau/zip.js/tree/master/dist and specify the URL where it can be found.
66
- *
67
- * Here is an example:
68
- * ```
69
- * configure({
70
- * workerScripts: {
71
- * deflate: ["library_path/z-worker.js"],
72
- * inflate: ["library_path/z-worker.js"]
73
- * }
74
- * });
75
- * ```
76
- */
77
- workerScripts?: {
78
- /**
79
- * The URIs of the scripts implementing used for compression.
80
- */
81
- deflate?: string[]
82
- /**
83
- * The URIs of the scripts implementing used for decompression.
84
- */
85
- inflate?: string[]
86
- }
87
- /**
88
- * The size of the chunks in bytes during data compression/decompression.
89
- *
90
- * @defaultValue 524288
91
- */
92
- chunkSize?: number
93
- /**
94
- * The codec implementation used to compress data.
95
- *
96
- * @defaultValue {@link ZipDeflate}
97
- */
98
- Deflate?: typeof ZipDeflate
99
- /**
100
- * The codec implementation used to decompress data.
101
- *
102
- * @defaultValue {@link ZipInflate}
103
- */
104
- Inflate?: typeof ZipInflate
105
- /**
106
- * The stream implementation used to compress data when `useCompressionStream` is set to `false`.
107
- *
108
- * @defaultValue {@link CodecStream}
109
- */
110
- CompressionStream?: typeof GenericTransformStream
111
- /**
112
- * The stream implementation used to decompress data when `useCompressionStream` is set to `false`.
113
- *
114
- * @defaultValue {@link CodecStream}
115
- */
116
- DecompressionStream?: typeof GenericTransformStream
35
+ /**
36
+ * The maximum number of web workers used to compress/decompress data simultaneously.
37
+ *
38
+ * @defaultValue `navigator.hardwareConcurrency`
39
+ */
40
+ maxWorkers?: number;
41
+ /**
42
+ * The delay in milliseconds before idle web workers are automatically terminated. You can call `terminateWorkers()` to terminate idle workers.
43
+ *
44
+ * @defaultValue 5000
45
+ */
46
+ terminateWorkerTimeout?: number;
47
+ /**
48
+ * The URIs of the compression/decompression scripts run in web workers.
49
+ *
50
+ * It allows using alternative deflate implementations or specifying a URL to the worker script if the CSP of the page blocks scripts imported from a Blob URI.
51
+ * The properties `deflate` and `inflate` must specify arrays of URLs to import the deflate/inflate web workers, respectively.
52
+ * The first URL is relative to the base URI of the document. The other URLs are relative to the URL of the first script. Scripts in the array are executed in order.
53
+ * If you only use deflation or inflation, the unused `deflate`/`inflate` property can be omitted.
54
+ *
55
+ * Here is an example:
56
+ * ```
57
+ * configure({
58
+ * workerScripts: {
59
+ * deflate: ["library_path/custom-worker.js", "./custom-deflate.js"],
60
+ * inflate: ["library_path/custom-worker.js", "./custom-inflate.js"]
61
+ * }
62
+ * });
63
+ * ```
64
+ *
65
+ * If the CSP of the page blocks scripts imported from a Blob URI you can use `z-worker.js` from https://github.com/gildas-lormeau/zip.js/tree/master/dist and specify the URL where it can be found.
66
+ *
67
+ * Here is an example:
68
+ * ```
69
+ * configure({
70
+ * workerScripts: {
71
+ * deflate: ["library_path/z-worker.js"],
72
+ * inflate: ["library_path/z-worker.js"]
73
+ * }
74
+ * });
75
+ * ```
76
+ */
77
+ workerScripts?: {
78
+ /**
79
+ * The URIs of the scripts implementing used for compression.
80
+ */
81
+ deflate?: string[];
82
+ /**
83
+ * The URIs of the scripts implementing used for decompression.
84
+ */
85
+ inflate?: string[];
86
+ };
87
+ /**
88
+ * The size of the chunks in bytes during data compression/decompression.
89
+ *
90
+ * @defaultValue 524288
91
+ */
92
+ chunkSize?: number;
93
+ /**
94
+ * The codec implementation used to compress data.
95
+ *
96
+ * @defaultValue {@link ZipDeflate}
97
+ */
98
+ Deflate?: typeof ZipDeflate;
99
+ /**
100
+ * The codec implementation used to decompress data.
101
+ *
102
+ * @defaultValue {@link ZipInflate}
103
+ */
104
+ Inflate?: typeof ZipInflate;
105
+ /**
106
+ * The stream implementation used to compress data when `useCompressionStream` is set to `false`.
107
+ *
108
+ * @defaultValue {@link CodecStream}
109
+ */
110
+ CompressionStream?: typeof GenericTransformStream;
111
+ /**
112
+ * The stream implementation used to decompress data when `useCompressionStream` is set to `false`.
113
+ *
114
+ * @defaultValue {@link CodecStream}
115
+ */
116
+ DecompressionStream?: typeof GenericTransformStream;
117
117
  }
118
118
 
119
119
  /**
120
120
  * Represents configuration passed to {@link configure}, the constructor of {@link ZipReader}, {@link Entry#getData}, the constructor of {@link ZipWriter}, and {@link ZipWriter#add}.
121
121
  */
122
122
  interface WorkerConfiguration {
123
- /**
124
- * `true` to use web workers to compress/decompress data in non-blocking background processes.
125
- *
126
- * @defaultValue true
127
- */
128
- useWebWorkers?: boolean
129
- /**
130
- * `true` to use the native API `CompressionStream`/`DecompressionStream` to compress/decompress data.
131
- *
132
- * @defaultValue true
133
- */
134
- useCompressionStream?: boolean
123
+ /**
124
+ * `true` to use web workers to compress/decompress data in non-blocking background processes.
125
+ *
126
+ * @defaultValue true
127
+ */
128
+ useWebWorkers?: boolean;
129
+ /**
130
+ * `true` to use the native API `CompressionStream`/`DecompressionStream` to compress/decompress data.
131
+ *
132
+ * @defaultValue true
133
+ */
134
+ useCompressionStream?: boolean;
135
135
  }
136
136
 
137
137
  /**
138
138
  * Transforms event-based third-party codec implementations into implementations compatible with zip.js
139
- *
139
+ *
140
140
  * @param library The third-party codec implementations.
141
141
  * @param constructorOptions The options passed to the third-party implementations when building instances.
142
142
  * @param registerDataHandler The function called to handle the `data` events triggered by a third-party codec implementation.
143
143
  * @returns An instance containing classes compatible with {@link ZipDeflate} and {@link ZipInflate}.
144
144
  */
145
- export function initShimAsyncCodec(library: EventBasedZipLibrary, constructorOptions: unknown | null, registerDataHandler: registerDataHandler): ZipLibrary
145
+ export function initShimAsyncCodec(
146
+ library: EventBasedZipLibrary,
147
+ constructorOptions: unknown | null,
148
+ registerDataHandler: registerDataHandler,
149
+ ): ZipLibrary;
146
150
 
147
151
  /**
148
152
  * Represents the callback function used to register the `data` event handler.
149
153
  */
150
154
  interface registerDataHandler {
151
- /**
152
- * @param codec The third-party codec instance.
153
- * @param onData The `data` event handler.
154
- */
155
- (codec: EventBasedCodec, onData: dataHandler): void
155
+ /**
156
+ * @param codec The third-party codec instance.
157
+ * @param onData The `data` event handler.
158
+ */
159
+ (codec: EventBasedCodec, onData: dataHandler): void;
156
160
  }
157
161
 
158
162
  /**
159
163
  * Represents the callback function used to handle `data` events.
160
164
  */
161
165
  interface dataHandler {
162
- /**
163
- * @param data The processed chunk of data.
164
- */
165
- (data: Uint8Array): void
166
+ /**
167
+ * @param data The processed chunk of data.
168
+ */
169
+ (data: Uint8Array): void;
166
170
  }
167
171
 
168
172
  /**
169
173
  * Terminates all the idle web workers
170
174
  */
171
- export function terminateWorkers(): void
175
+ export function terminateWorkers(): void;
172
176
 
173
177
  /**
174
178
  * Represents event-based implementations used to compress/decompress data.
175
179
  */
176
180
  interface EventBasedZipLibrary {
177
- /**
178
- * The class used to compress data.
179
- */
180
- Deflate: typeof EventBasedCodec
181
- /**
182
- * The class used to decompress data.
183
- */
184
- Inflate: typeof EventBasedCodec
181
+ /**
182
+ * The class used to compress data.
183
+ */
184
+ Deflate: typeof EventBasedCodec;
185
+ /**
186
+ * The class used to decompress data.
187
+ */
188
+ Inflate: typeof EventBasedCodec;
185
189
  }
186
190
 
187
191
  /**
188
192
  * Represents an event-based implementation of a third-party codec.
189
193
  */
190
194
  declare class EventBasedCodec {
191
- /**
192
- * Appends a chunk of data to compress/decompress
193
- *
194
- * @param data The chunk of data to append.
195
- */
196
- push(data: Uint8Array): void
197
- /**
198
- * The function called when a chunk of data has been compressed/decompressed.
199
- *
200
- * @param data The chunk of compressed/decompressed data.
201
- */
202
- ondata(data?: Uint8Array): void
195
+ /**
196
+ * Appends a chunk of data to compress/decompress
197
+ *
198
+ * @param data The chunk of data to append.
199
+ */
200
+ push(data: Uint8Array): void;
201
+ /**
202
+ * The function called when a chunk of data has been compressed/decompressed.
203
+ *
204
+ * @param data The chunk of compressed/decompressed data.
205
+ */
206
+ ondata(data?: Uint8Array): void;
203
207
  }
204
208
 
205
209
  /**
206
210
  * Represents the implementations zip.js uses to compress/decompress data.
207
211
  */
208
212
  interface ZipLibrary {
209
- /**
210
- * The class used to compress data.
211
- *
212
- * @defaultValue {@link ZipDeflate}
213
- */
214
- Deflate: typeof ZipDeflate
215
- /**
216
- * The class used to decompress data.
217
- *
218
- * @defaultValue {@link ZipInflate}
219
- */
220
- Inflate: typeof ZipInflate
213
+ /**
214
+ * The class used to compress data.
215
+ *
216
+ * @defaultValue {@link ZipDeflate}
217
+ */
218
+ Deflate: typeof ZipDeflate;
219
+ /**
220
+ * The class used to decompress data.
221
+ *
222
+ * @defaultValue {@link ZipInflate}
223
+ */
224
+ Inflate: typeof ZipInflate;
221
225
  }
222
226
 
223
227
  declare class SyncCodec {
224
- /**
225
- * Appends a chunk of decompressed data to compress
226
- *
227
- * @param data The chunk of decompressed data to append.
228
- * @returns A chunk of compressed data.
229
- */
230
- append(data: Uint8Array): Uint8Array
228
+ /**
229
+ * Appends a chunk of decompressed data to compress
230
+ *
231
+ * @param data The chunk of decompressed data to append.
232
+ * @returns A chunk of compressed data.
233
+ */
234
+ append(data: Uint8Array): Uint8Array;
231
235
  }
232
236
 
233
237
  /**
234
238
  * Represents an intance used to compress data.
235
239
  */
236
240
  declare class ZipDeflate extends SyncCodec {
237
- /**
238
- * Flushes the data
239
- *
240
- * @returns A chunk of compressed data.
241
- */
242
- flush(): Uint8Array
241
+ /**
242
+ * Flushes the data
243
+ *
244
+ * @returns A chunk of compressed data.
245
+ */
246
+ flush(): Uint8Array;
243
247
  }
244
248
 
245
249
  /**
246
250
  * Represents a codec used to decompress data.
247
251
  */
248
252
  declare class ZipInflate extends SyncCodec {
249
- /**
250
- * Flushes the data
251
- */
252
- flush(): void
253
+ /**
254
+ * Flushes the data
255
+ */
256
+ flush(): void;
253
257
  }
254
258
 
255
259
  /**
256
260
  * Represents a class implementing `CompressionStream` or `DecompressionStream` interfaces.
257
261
  */
258
- declare class CodecStream extends TransformStream { }
262
+ declare class CodecStream extends TransformStream {}
259
263
 
260
264
  /**
261
265
  * Returns the MIME type corresponding to a filename extension.
262
- *
266
+ *
263
267
  * @param fileExtension the extension of the filename.
264
- * @returns The corresponding MIME type.
268
+ * @returns The corresponding MIME type.
265
269
  */
266
- export function getMimeType(fileExtension: string): string
270
+ export function getMimeType(fileExtension: string): string;
267
271
 
268
272
  /**
269
273
  * Represents an instance used to read or write unknown type of data.
270
- *
271
- * zip.js can handle multiple types of data thanks to a generic API. This feature is based on 2 abstract constructors: {@link Reader} and {@link Writer}.
274
+ *
275
+ * zip.js can handle multiple types of data thanks to a generic API. This feature is based on 2 abstract constructors: {@link Reader} and {@link Writer}.
272
276
  * The classes inheriting from {@link Reader} help to read data from a source of data. The classes inheriting from {@link Writer} help to write data into a destination.
273
277
  */
274
278
  interface Initializable {
275
- /**
276
- * Initializes the instance asynchronously
277
- */
278
- init?(): Promise<void>
279
+ /**
280
+ * Initializes the instance asynchronously
281
+ */
282
+ init?(): Promise<void>;
279
283
  }
280
284
 
281
285
  /**
282
286
  * Represents an instance used to read data from a `ReadableStream` instance.
283
287
  */
284
288
  interface ReadableReader {
285
- /**
286
- * The `ReadableStream` instance.
287
- */
288
- readable: ReadableStream
289
+ /**
290
+ * The `ReadableStream` instance.
291
+ */
292
+ readable: ReadableStream;
289
293
  }
290
294
 
291
295
  /**
292
296
  * Represents an instance used to read unknown type of data.
293
- *
297
+ *
294
298
  * @example
295
299
  * Here is an example of custom {@link Reader} class used to read binary strings:
296
300
  * ```
297
301
  * class BinaryStringReader extends Reader {
298
- *
302
+ *
299
303
  * constructor(binaryString) {
300
304
  * super();
301
305
  * this.binaryString = binaryString;
302
306
  * }
303
- *
307
+ *
304
308
  * init() {
305
309
  * super.init();
306
310
  * this.size = this.binaryString.length;
307
311
  * }
308
- *
312
+ *
309
313
  * readUint8Array(offset, length) {
310
314
  * const result = new Uint8Array(length);
311
315
  * for (let indexCharacter = 0; indexCharacter < length; indexCharacter++) {
@@ -317,171 +321,172 @@ interface ReadableReader {
317
321
  * ```
318
322
  */
319
323
  export class Reader<Type> implements Initializable, ReadableReader {
320
- /**
321
- * Creates the {@link Reader} instance
322
- *
323
- * @param value The data to read.
324
- */
325
- constructor(value: Type)
326
- /**
327
- * The `ReadableStream` instance.
328
- */
329
- readable: ReadableStream
330
- /**
331
- * The total size of the data in bytes.
332
- */
333
- size: number
334
- /**
335
- * Initializes the instance asynchronously
336
- */
337
- init?(): Promise<void>
338
- /**
339
- * Reads a chunk of data
340
- *
341
- * @param index The byte index of the data to read.
342
- * @param length The length of the data to read in bytes.
343
- * @returns A promise resolving to a chunk of data.
344
- */
345
- readUint8Array(index: number, length: number): Promise<Uint8Array>
324
+ /**
325
+ * Creates the {@link Reader} instance
326
+ *
327
+ * @param value The data to read.
328
+ */
329
+ constructor(value: Type);
330
+ /**
331
+ * The `ReadableStream` instance.
332
+ */
333
+ readable: ReadableStream;
334
+ /**
335
+ * The total size of the data in bytes.
336
+ */
337
+ size: number;
338
+ /**
339
+ * Initializes the instance asynchronously
340
+ */
341
+ init?(): Promise<void>;
342
+ /**
343
+ * Reads a chunk of data
344
+ *
345
+ * @param index The byte index of the data to read.
346
+ * @param length The length of the data to read in bytes.
347
+ * @returns A promise resolving to a chunk of data.
348
+ */
349
+ readUint8Array(index: number, length: number): Promise<Uint8Array>;
346
350
  }
347
351
 
348
352
  /**
349
353
  * Represents a {@link Reader} instance used to read data provided as a `string`.
350
354
  */
351
- export class TextReader extends Reader<string> { }
355
+ export class TextReader extends Reader<string> {}
352
356
 
353
357
  /**
354
358
  * Represents a {@link Reader} instance used to read data provided as a `Blob` instance.
355
359
  */
356
- export class BlobReader extends Reader<Blob> { }
360
+ export class BlobReader extends Reader<Blob> {}
357
361
 
358
362
  /**
359
363
  * Represents a {@link Reader} instance used to read data provided as a Data URI `string` encoded in Base64.
360
364
  */
361
- export class Data64URIReader extends Reader<string> { }
365
+ export class Data64URIReader extends Reader<string> {}
362
366
 
363
367
  /**
364
368
  * Represents a {@link Reader} instance used to read data provided as a `Uint8Array` instance.
365
369
  */
366
- export class Uint8ArrayReader extends Reader<Uint8Array> { }
370
+ export class Uint8ArrayReader extends Reader<Uint8Array> {}
367
371
 
368
372
  /**
369
373
  * Represents a {@link Reader} instance used to read data provided as an array of {@link ReadableReader} instances (e.g. split zip files).
370
- *
374
+ *
371
375
  * @deprecated Use {@link SplitDataReader} instead.
372
376
  */
373
- export class SplitZipReader extends SplitDataReader { }
377
+ export class SplitZipReader extends SplitDataReader {}
374
378
 
375
379
  /**
376
380
  * Represents a {@link Reader} instance used to read data provided as an array of {@link ReadableReader} instances (e.g. split zip files).
377
381
  */
378
- export class SplitDataReader extends Reader<Reader<unknown>[] | ReadableReader[] | ReadableStream[]> { }
382
+ export class SplitDataReader
383
+ extends Reader<Reader<unknown>[] | ReadableReader[] | ReadableStream[]> {}
379
384
 
380
- /**
385
+ /**
381
386
  * Represents a URL stored into a `string`.
382
387
  */
383
388
  // deno-lint-ignore no-empty-interface
384
- interface URLString extends String { }
389
+ interface URLString extends String {}
385
390
 
386
391
  /**
387
392
  * Represents a {@link Reader} instance used to fetch data from a URL.
388
393
  */
389
394
  export class HttpReader extends Reader<URLString> {
390
- /**
391
- * Creates the {@link HttpReader} instance
392
- *
393
- * @param url The URL of the data.
394
- * @param options The options.
395
- */
396
- constructor(url: URLString, options?: HttpOptions)
395
+ /**
396
+ * Creates the {@link HttpReader} instance
397
+ *
398
+ * @param url The URL of the data.
399
+ * @param options The options.
400
+ */
401
+ constructor(url: URLString, options?: HttpOptions);
397
402
  }
398
403
 
399
404
  /**
400
405
  * Represents a {@link Reader} instance used to fetch data from servers returning `Accept-Ranges` headers.
401
406
  */
402
407
  export class HttpRangeReader extends HttpReader {
403
- /**
404
- * Creates the {@link HttpRangeReader} instance
405
- *
406
- * @param url The URL of the data.
407
- * @param options The options.
408
- */
409
- constructor(url: URLString, options?: HttpRangeOptions)
408
+ /**
409
+ * Creates the {@link HttpRangeReader} instance
410
+ *
411
+ * @param url The URL of the data.
412
+ * @param options The options.
413
+ */
414
+ constructor(url: URLString, options?: HttpRangeOptions);
410
415
  }
411
416
 
412
417
  /**
413
418
  * Represents the options passed to the constructor of {@link HttpReader}.
414
419
  */
415
420
  interface HttpOptions extends HttpRangeOptions {
416
- /**
417
- * `true` to use `Range` headers when fetching data from servers returning `Accept-Ranges` headers.
418
- *
419
- * @defaultValue false
420
- */
421
- useRangeHeader?: boolean
422
- /**
423
- * `true` to always use `Range` headers when fetching data.
424
- *
425
- * @defaultValue false
426
- */
427
- forceRangeRequests?: boolean
428
- /**
429
- * `true` to prevent using `HEAD` HTTP request in order the get the size of the content.
430
- *
431
- * @defaultValue false
432
- */
433
- preventHeadRequest?: boolean
421
+ /**
422
+ * `true` to use `Range` headers when fetching data from servers returning `Accept-Ranges` headers.
423
+ *
424
+ * @defaultValue false
425
+ */
426
+ useRangeHeader?: boolean;
427
+ /**
428
+ * `true` to always use `Range` headers when fetching data.
429
+ *
430
+ * @defaultValue false
431
+ */
432
+ forceRangeRequests?: boolean;
433
+ /**
434
+ * `true` to prevent using `HEAD` HTTP request in order the get the size of the content.
435
+ *
436
+ * @defaultValue false
437
+ */
438
+ preventHeadRequest?: boolean;
434
439
  }
435
440
 
436
441
  /**
437
442
  * Represents options passed to the constructor of {@link HttpRangeReader} and {@link HttpReader}.
438
443
  */
439
444
  interface HttpRangeOptions {
440
- /**
441
- * `true` to rely `XMLHttpRequest` instead of `fetch` to fetch data.
442
- *
443
- * @defaultValue false
444
- */
445
- useXHR?: boolean
446
- /**
447
- * The HTTP headers.
448
- */
449
- headers?: Iterable<[string, string]> | Map<string, string>
445
+ /**
446
+ * `true` to rely `XMLHttpRequest` instead of `fetch` to fetch data.
447
+ *
448
+ * @defaultValue false
449
+ */
450
+ useXHR?: boolean;
451
+ /**
452
+ * The HTTP headers.
453
+ */
454
+ headers?: Iterable<[string, string]> | Map<string, string>;
450
455
  }
451
456
 
452
457
  /**
453
458
  * Represents an instance used to write data into a `WritableStream` instance.
454
459
  */
455
460
  interface WritableWriter {
456
- /**
457
- * The `WritableStream` instance.
458
- */
459
- writable: WritableStream,
460
- /**
461
- * The maximum size of split data when creating a {@link ZipWriter} instance or when calling {@link Entry#getData} with a generator of {@link WritableWriter} instances.
462
- */
463
- maxSize?: number
461
+ /**
462
+ * The `WritableStream` instance.
463
+ */
464
+ writable: WritableStream;
465
+ /**
466
+ * The maximum size of split data when creating a {@link ZipWriter} instance or when calling {@link Entry#getData} with a generator of {@link WritableWriter} instances.
467
+ */
468
+ maxSize?: number;
464
469
  }
465
470
 
466
471
  /**
467
472
  * Represents an instance used to write unknown type of data.
468
- *
473
+ *
469
474
  * @example
470
475
  * Here is an example of custom {@link Writer} class used to write binary strings:
471
476
  * ```
472
477
  * class BinaryStringWriter extends Writer {
473
- *
478
+ *
474
479
  * constructor() {
475
480
  * super();
476
481
  * this.binaryString = "";
477
482
  * }
478
- *
483
+ *
479
484
  * writeUint8Array(array) {
480
485
  * for (let indexCharacter = 0; indexCharacter < array.length; indexCharacter++) {
481
486
  * this.binaryString += String.fromCharCode(array[indexCharacter]);
482
487
  * }
483
488
  * }
484
- *
489
+ *
485
490
  * getData() {
486
491
  * return this.binaryString;
487
492
  * }
@@ -489,134 +494,140 @@ interface WritableWriter {
489
494
  * ```
490
495
  */
491
496
  export class Writer<Type> implements Initializable, WritableWriter {
492
- /**
493
- * The `WritableStream` instance.
494
- */
495
- writable: WritableStream
496
- /**
497
- * Initializes the instance asynchronously
498
- *
499
- * @param size the total size of the written data in bytes.
500
- */
501
- init?(size?: number): Promise<void>
502
- /**
503
- * Appends a chunk of data
504
- *
505
- * @param array The chunk data to append.
506
- *
507
- * @virtual
508
- */
509
- writeUint8Array(array: Uint8Array): Promise<void>
510
- /**
511
- * Retrieves all the written data
512
- *
513
- * @returns A promise resolving to the written data.
514
- */
515
- getData(): Promise<Type>
497
+ /**
498
+ * The `WritableStream` instance.
499
+ */
500
+ writable: WritableStream;
501
+ /**
502
+ * Initializes the instance asynchronously
503
+ *
504
+ * @param size the total size of the written data in bytes.
505
+ */
506
+ init?(size?: number): Promise<void>;
507
+ /**
508
+ * Appends a chunk of data
509
+ *
510
+ * @param array The chunk data to append.
511
+ *
512
+ * @virtual
513
+ */
514
+ writeUint8Array(array: Uint8Array): Promise<void>;
515
+ /**
516
+ * Retrieves all the written data
517
+ *
518
+ * @returns A promise resolving to the written data.
519
+ */
520
+ getData(): Promise<Type>;
516
521
  }
517
522
 
518
523
  /**
519
524
  * Represents a {@link Writer} instance used to retrieve the written data as a `string`.
520
525
  */
521
526
  export class TextWriter extends Writer<string> {
522
- /**
523
- * Creates the {@link TextWriter} instance
524
- *
525
- * @param encoding The encoding of the text.
526
- */
527
- constructor(encoding?: string)
527
+ /**
528
+ * Creates the {@link TextWriter} instance
529
+ *
530
+ * @param encoding The encoding of the text.
531
+ */
532
+ constructor(encoding?: string);
528
533
  }
529
534
 
530
535
  /**
531
536
  * Represents a {@link WritableWriter} instance used to retrieve the written data as a `Blob` instance.
532
537
  */
533
538
  export class BlobWriter implements Initializable, WritableWriter {
534
- /**
535
- * The `WritableStream` instance.
536
- */
537
- writable: WritableStream
538
- /**
539
- * Initializes the instance asynchronously
540
- */
541
- init(): Promise<void>
542
- /**
543
- * Creates the {@link BlobWriter} instance
544
- *
545
- * @param mimeString The MIME type of the content.
546
- */
547
- constructor(mimeString?: string)
548
- /**
549
- * Retrieves all the written data
550
- *
551
- * @returns A promise resolving to the written data.
552
- */
553
- getData(): Promise<Blob>
539
+ /**
540
+ * The `WritableStream` instance.
541
+ */
542
+ writable: WritableStream;
543
+ /**
544
+ * Initializes the instance asynchronously
545
+ */
546
+ init(): Promise<void>;
547
+ /**
548
+ * Creates the {@link BlobWriter} instance
549
+ *
550
+ * @param mimeString The MIME type of the content.
551
+ */
552
+ constructor(mimeString?: string);
553
+ /**
554
+ * Retrieves all the written data
555
+ *
556
+ * @returns A promise resolving to the written data.
557
+ */
558
+ getData(): Promise<Blob>;
554
559
  }
555
560
 
556
561
  /**
557
562
  * Represents a {@link Writer} instance used to retrieve the written data as a Data URI `string` encoded in Base64.
558
563
  */
559
564
  export class Data64URIWriter extends Writer<string> {
560
- /**
561
- * Creates the {@link Data64URIWriter} instance
562
- *
563
- * @param mimeString The MIME type of the content.
564
- */
565
- constructor(mimeString?: string)
565
+ /**
566
+ * Creates the {@link Data64URIWriter} instance
567
+ *
568
+ * @param mimeString The MIME type of the content.
569
+ */
570
+ constructor(mimeString?: string);
566
571
  }
567
572
 
568
573
  /**
569
574
  * Represents a {@link Writer} instance used to retrieve the written data from a generator of {@link WritableWriter} instances (i.e. split zip files).
570
- *
575
+ *
571
576
  * @deprecated Use {@link SplitDataWriter} instead.
572
577
  */
573
- export class SplitZipWriter extends SplitDataWriter { }
578
+ export class SplitZipWriter extends SplitDataWriter {}
574
579
 
575
580
  /**
576
581
  * Represents a {@link Writer} instance used to retrieve the written data from a generator of {@link WritableWriter} instances (i.e. split zip files).
577
582
  */
578
583
  export class SplitDataWriter implements Initializable, WritableWriter {
579
- /**
580
- * The `WritableStream` instance.
581
- */
582
- writable: WritableStream
583
- /**
584
- * Initializes the instance asynchronously
585
- */
586
- init(): Promise<void>
587
- /**
588
- * Creates the {@link SplitDataWriter} instance
589
- *
590
- * @param writerGenerator A generator of Writer isntances.
591
- * @param maxSize The maximum size of the data written into {@link Writer} instances (default: 4GB).
592
- */
593
- constructor(writerGenerator: AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream, boolean>, maxSize?: number)
584
+ /**
585
+ * The `WritableStream` instance.
586
+ */
587
+ writable: WritableStream;
588
+ /**
589
+ * Initializes the instance asynchronously
590
+ */
591
+ init(): Promise<void>;
592
+ /**
593
+ * Creates the {@link SplitDataWriter} instance
594
+ *
595
+ * @param writerGenerator A generator of Writer isntances.
596
+ * @param maxSize The maximum size of the data written into {@link Writer} instances (default: 4GB).
597
+ */
598
+ constructor(
599
+ writerGenerator: AsyncGenerator<
600
+ Writer<unknown> | WritableWriter | WritableStream,
601
+ boolean
602
+ >,
603
+ maxSize?: number,
604
+ );
594
605
  }
595
606
 
596
607
  /**
597
608
  * Represents a {@link Writer} instance used to retrieve the written data as a `Uint8Array` instance.
598
609
  */
599
- export class Uint8ArrayWriter extends Writer<Uint8Array> { }
610
+ export class Uint8ArrayWriter extends Writer<Uint8Array> {}
600
611
 
601
612
  /**
602
613
  * Represents an instance used to read a zip file.
603
- *
614
+ *
604
615
  * @example
605
616
  * Here is an example showing how to read the text data of the first entry from a zip file:
606
617
  * ```
607
618
  * // create a BlobReader to read with a ZipReader the zip from a Blob object
608
619
  * const reader = new zip.ZipReader(new zip.BlobReader(blob));
609
- *
620
+ *
610
621
  * // get all entries from the zip
611
622
  * const entries = await reader.getEntries();
612
623
  * if (entries.length) {
613
- *
624
+ *
614
625
  * // get first entry content as text by using a TextWriter
615
626
  * const text = await entries[0].getData(
616
627
  * // writer
617
628
  * new zip.TextWriter(),
618
629
  * // options
619
- * {
630
+ * {
620
631
  * onprogress: (index, max) => {
621
632
  * // onprogress callback
622
633
  * }
@@ -625,895 +636,1056 @@ export class Uint8ArrayWriter extends Writer<Uint8Array> { }
625
636
  * // text contains the entry data as a String
626
637
  * console.log(text);
627
638
  * }
628
- *
639
+ *
629
640
  * // close the ZipReader
630
641
  * await reader.close();
631
642
  * ```
632
643
  */
633
644
  export class ZipReader<Type> {
634
- /**
635
- * Creates the instance
636
- *
637
- * @param reader The {@link Reader} instance used to read data.
638
- * @param options The options.
639
- */
640
- constructor(reader: Reader<Type> | ReadableReader | ReadableStream | Reader<unknown>[] | ReadableReader[] | ReadableStream[], options?: ZipReaderConstructorOptions)
641
- /**
642
- * The global comment of the zip file.
643
- */
644
- comment: Uint8Array
645
- /**
646
- * The data prepended before the zip file.
647
- */
648
- prependedData?: Uint8Array
649
- /**
650
- * The data appended after the zip file.
651
- */
652
- appendedData?: Uint8Array
653
- /**
654
- * Returns all the entries in the zip file
655
- *
656
- * @param options The options.
657
- * @returns A promise resolving to an `array` of {@link Entry} instances.
658
- */
659
- getEntries(options?: ZipReaderGetEntriesOptions): Promise<Entry[]>
660
- /**
661
- * Returns a generator used to iterate on all the entries in the zip file
662
- *
663
- * @param options The options.
664
- * @returns An asynchrounous generator of {@link Entry} instances.
665
- */
666
- getEntriesGenerator(options?: ZipReaderGetEntriesOptions): AsyncGenerator<Entry, boolean>
667
- /**
668
- * Closes the zip file
669
- */
670
- close(): Promise<void>
645
+ /**
646
+ * Creates the instance
647
+ *
648
+ * @param reader The {@link Reader} instance used to read data.
649
+ * @param options The options.
650
+ */
651
+ constructor(
652
+ reader:
653
+ | Reader<Type>
654
+ | ReadableReader
655
+ | ReadableStream
656
+ | Reader<unknown>[]
657
+ | ReadableReader[]
658
+ | ReadableStream[],
659
+ options?: ZipReaderConstructorOptions,
660
+ );
661
+ /**
662
+ * The global comment of the zip file.
663
+ */
664
+ comment: Uint8Array;
665
+ /**
666
+ * The data prepended before the zip file.
667
+ */
668
+ prependedData?: Uint8Array;
669
+ /**
670
+ * The data appended after the zip file.
671
+ */
672
+ appendedData?: Uint8Array;
673
+ /**
674
+ * Returns all the entries in the zip file
675
+ *
676
+ * @param options The options.
677
+ * @returns A promise resolving to an `array` of {@link Entry} instances.
678
+ */
679
+ getEntries(options?: ZipReaderGetEntriesOptions): Promise<Entry[]>;
680
+ /**
681
+ * Returns a generator used to iterate on all the entries in the zip file
682
+ *
683
+ * @param options The options.
684
+ * @returns An asynchrounous generator of {@link Entry} instances.
685
+ */
686
+ getEntriesGenerator(
687
+ options?: ZipReaderGetEntriesOptions,
688
+ ): AsyncGenerator<Entry, boolean>;
689
+ /**
690
+ * Closes the zip file
691
+ */
692
+ close(): Promise<void>;
671
693
  }
672
694
 
673
695
  /**
674
696
  * Represents the options passed to the constructor of {@link ZipReader}, and `{@link ZipDirectory}#import*`.
675
697
  */
676
- interface ZipReaderConstructorOptions extends ZipReaderOptions, GetEntriesOptions, WorkerConfiguration {
677
- /**
678
- * `true` to extract the prepended data into {@link ZipReader#prependedData}.
679
- *
680
- * @defaultValue false
681
- */
682
- extractPrependedData?: boolean
683
- /**
684
- * `true` to extract the appended data into {@link ZipReader#appendedData}.
685
- *
686
- * @defaultValue false
687
- */
688
- extractAppendedData?: boolean
698
+ interface ZipReaderConstructorOptions
699
+ extends ZipReaderOptions, GetEntriesOptions, WorkerConfiguration {
700
+ /**
701
+ * `true` to extract the prepended data into {@link ZipReader#prependedData}.
702
+ *
703
+ * @defaultValue false
704
+ */
705
+ extractPrependedData?: boolean;
706
+ /**
707
+ * `true` to extract the appended data into {@link ZipReader#appendedData}.
708
+ *
709
+ * @defaultValue false
710
+ */
711
+ extractAppendedData?: boolean;
689
712
  }
690
713
 
691
714
  /**
692
715
  * Represents the options passed to {@link ZipReader#getEntries} and {@link ZipReader#getEntriesGenerator}.
693
716
  */
694
- interface ZipReaderGetEntriesOptions extends GetEntriesOptions, EntryOnprogressOptions { }
717
+ interface ZipReaderGetEntriesOptions
718
+ extends GetEntriesOptions, EntryOnprogressOptions {}
695
719
 
696
720
  /**
697
721
  * Represents options passed to the constructor of {@link ZipReader}, {@link ZipReader#getEntries} and {@link ZipReader#getEntriesGenerator}.
698
722
  */
699
723
  interface GetEntriesOptions {
700
- /**
701
- * The encoding of the filename of the entry.
702
- */
703
- filenameEncoding?: string
704
- /**
705
- * The encoding of the comment of the entry.
706
- */
707
- commentEncoding?: string
724
+ /**
725
+ * The encoding of the filename of the entry.
726
+ */
727
+ filenameEncoding?: string;
728
+ /**
729
+ * The encoding of the comment of the entry.
730
+ */
731
+ commentEncoding?: string;
732
+ }
733
+
734
+ /**
735
+ * Represents options passed to the constructor of {@link ZipReader} and {@link Entry#getData}.
736
+ */
737
+ interface ZipReaderCheckPasswordOptions {
738
+ /**
739
+ * `true` to check only if the password is valid.
740
+ *
741
+ * @defaultValue false
742
+ */
743
+ checkPasswordOnly: boolean;
708
744
  }
709
745
 
710
746
  /**
711
747
  * Represents options passed to the constructor of {@link ZipReader} and {@link Entry#getData}.
712
748
  */
713
749
  interface ZipReaderOptions {
714
- /**
715
- * `true` to check only if the password is valid.
716
- *
717
- * @defaultValue false
718
- */
719
- checkPasswordOnly?: boolean
720
- /**
721
- * `true` to check the signature of the entry.
722
- *
723
- * @defaultValue false
724
- */
725
- checkSignature?: boolean
726
- /**
727
- * The password used to decrypt the content of the entry.
728
- */
729
- password?: string
730
- /**
731
- * The `AbortSignal` instance used to cancel the decompression.
732
- */
733
- signal?: AbortSignal
734
- /**
735
- * `true` to prevent closing of {@link Writer#writable} when calling {@link Entry#getData}.
736
- *
737
- * @defaultValue false
738
- */
739
- preventClose?: boolean
740
- /**
741
- * `true` to transfer streams to web workers when decompressing data.
742
- *
743
- * @defaultValue true
744
- */
745
- transferStreams?: boolean
750
+ /**
751
+ * `true` to check the signature of the entry.
752
+ *
753
+ * @defaultValue false
754
+ */
755
+ checkSignature?: boolean;
756
+ /**
757
+ * The password used to decrypt the content of the entry.
758
+ */
759
+ password?: string;
760
+ /**
761
+ * The `AbortSignal` instance used to cancel the decompression.
762
+ */
763
+ signal?: AbortSignal;
764
+ /**
765
+ * `true` to prevent closing of {@link Writer#writable} when calling {@link Entry#getData}.
766
+ *
767
+ * @defaultValue false
768
+ */
769
+ preventClose?: boolean;
770
+ /**
771
+ * `true` to transfer streams to web workers when decompressing data.
772
+ *
773
+ * @defaultValue true
774
+ */
775
+ transferStreams?: boolean;
746
776
  }
747
777
 
748
778
  /**
749
779
  * Represents the metadata of an entry in a zip file (Core API).
750
780
  */
751
781
  export interface EntryMetaData {
752
- /**
753
- * The byte offset of the entry.
754
- */
755
- offset: number
756
- /**
757
- * The filename of the entry.
758
- */
759
- filename: string
760
- /**
761
- * The filename of the entry (raw).
762
- */
763
- rawFilename: Uint8Array
764
- /**
765
- * `true` if the filename is encoded in UTF-8.
766
- */
767
- filenameUTF8: boolean
768
- /**
769
- * `true` if the entry is a directory.
770
- */
771
- directory: boolean
772
- /**
773
- * `true` if the content of the entry is encrypted.
774
- */
775
- encrypted: boolean
776
- /**
777
- * The size of the compressed data in bytes.
778
- */
779
- compressedSize: number
780
- /**
781
- * The size of the decompressed data in bytes.
782
- */
783
- uncompressedSize: number
784
- /**
785
- * The last modification date.
786
- */
787
- lastModDate: Date
788
- /**
789
- * The last access date.
790
- */
791
- lastAccessDate?: Date
792
- /**
793
- * The creation date.
794
- */
795
- creationDate?: Date
796
- /**
797
- * The last modification date (raw).
798
- */
799
- rawLastModDate: number | bigint
800
- /**
801
- * The last access date (raw).
802
- */
803
- rawLastAccessDate?: number | bigint
804
- /**
805
- * The creation date (raw).
806
- */
807
- rawCreationDate?: number | bigint
808
- /**
809
- * The comment of the entry.
810
- */
811
- comment: string
812
- /**
813
- * The comment of the entry (raw).
814
- */
815
- rawComment: Uint8Array
816
- /**
817
- * `true` if the comment is encoded in UTF-8.
818
- */
819
- commentUTF8: boolean
820
- /**
821
- * The signature (CRC32 checksum) of the content.
822
- */
823
- signature: number
824
- /**
825
- * The extra field.
826
- */
827
- extraField?: Map<number, Uint8Array>
828
- /**
829
- * The extra field (raw).
830
- */
831
- rawExtraField: Uint8Array
832
- /**
833
- * `true` if the entry is using Zip64.
834
- */
835
- zip64: boolean
836
- /**
837
- * The "Version" field.
838
- */
839
- version: number
840
- /**
841
- * The "Version made by" field.
842
- */
843
- versionMadeBy: number
844
- /**
845
- * `true` if `internalFileAttribute` and `externalFileAttribute` are compatible with MS-DOS format.
846
- */
847
- msDosCompatible: boolean
848
- /**
849
- * The internal file attribute (raw).
850
- */
851
- internalFileAttribute: number
852
- /**
853
- * The external file attribute (raw).
854
- */
855
- externalFileAttribute: number
856
- /**
857
- * The number of the disk where the entry data starts.
858
- */
859
- diskNumberStart: number
860
- /**
861
- * Returns the content of the entry
862
- *
863
- * @param writer The {@link Writer} instance used to write the content of the entry.
864
- * @param options The options.
865
- * @returns A promise resolving to the type to data associated to `writer`.
866
- */
867
- getData?<Type>(writer: Writer<Type> | WritableWriter | WritableStream | AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream | undefined | null, boolean>, options?: EntryGetDataOptions): Promise<Type | undefined>
782
+ /**
783
+ * The byte offset of the entry.
784
+ */
785
+ offset: number;
786
+ /**
787
+ * The filename of the entry.
788
+ */
789
+ filename: string;
790
+ /**
791
+ * The filename of the entry (raw).
792
+ */
793
+ rawFilename: Uint8Array;
794
+ /**
795
+ * `true` if the filename is encoded in UTF-8.
796
+ */
797
+ filenameUTF8: boolean;
798
+ /**
799
+ * `true` if the entry is a directory.
800
+ */
801
+ directory: boolean;
802
+ /**
803
+ * `true` if the content of the entry is encrypted.
804
+ */
805
+ encrypted: boolean;
806
+ /**
807
+ * The size of the compressed data in bytes.
808
+ */
809
+ compressedSize: number;
810
+ /**
811
+ * The size of the decompressed data in bytes.
812
+ */
813
+ uncompressedSize: number;
814
+ /**
815
+ * The last modification date.
816
+ */
817
+ lastModDate: Date;
818
+ /**
819
+ * The last access date.
820
+ */
821
+ lastAccessDate?: Date;
822
+ /**
823
+ * The creation date.
824
+ */
825
+ creationDate?: Date;
826
+ /**
827
+ * The last modification date (raw).
828
+ */
829
+ rawLastModDate: number | bigint;
830
+ /**
831
+ * The last access date (raw).
832
+ */
833
+ rawLastAccessDate?: number | bigint;
834
+ /**
835
+ * The creation date (raw).
836
+ */
837
+ rawCreationDate?: number | bigint;
838
+ /**
839
+ * The comment of the entry.
840
+ */
841
+ comment: string;
842
+ /**
843
+ * The comment of the entry (raw).
844
+ */
845
+ rawComment: Uint8Array;
846
+ /**
847
+ * `true` if the comment is encoded in UTF-8.
848
+ */
849
+ commentUTF8: boolean;
850
+ /**
851
+ * The signature (CRC32 checksum) of the content.
852
+ */
853
+ signature: number;
854
+ /**
855
+ * The extra field.
856
+ */
857
+ extraField?: Map<number, Uint8Array>;
858
+ /**
859
+ * The extra field (raw).
860
+ */
861
+ rawExtraField: Uint8Array;
862
+ /**
863
+ * `true` if the entry is using Zip64.
864
+ */
865
+ zip64: boolean;
866
+ /**
867
+ * The "Version" field.
868
+ */
869
+ version: number;
870
+ /**
871
+ * The "Version made by" field.
872
+ */
873
+ versionMadeBy: number;
874
+ /**
875
+ * `true` if `internalFileAttribute` and `externalFileAttribute` are compatible with MS-DOS format.
876
+ */
877
+ msDosCompatible: boolean;
878
+ /**
879
+ * The internal file attribute (raw).
880
+ */
881
+ internalFileAttribute: number;
882
+ /**
883
+ * The external file attribute (raw).
884
+ */
885
+ externalFileAttribute: number;
886
+ /**
887
+ * The number of the disk where the entry data starts.
888
+ */
889
+ diskNumberStart: number;
868
890
  }
869
891
 
870
892
  /**
871
893
  * Represents an entry with its data and metadata in a zip file (Core API).
872
894
  */
873
895
  export interface Entry extends EntryMetaData {
874
- /**
875
- * Returns the content of the entry
876
- *
877
- * @param writer The {@link Writer} instance used to write the content of the entry or `undefined`/`null` if the option `checkPasswordOnly` is set to `true`.
878
- * @param options The options.
879
- * @returns A promise resolving to the type to data associated to `writer` or `undefined` if the option `checkPasswordOnly` is set to `true`.
880
- */
881
- getData<Type>(writer: Writer<Type> | WritableWriter | WritableStream | AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream | undefined | null, boolean>, options?: EntryGetDataOptions): Promise<Type | undefined>
896
+ /**
897
+ * Returns the content of the entry
898
+ *
899
+ * @param writer The {@link Writer} instance used to write the content of the entry.
900
+ * @param options The options.
901
+ * @returns A promise resolving to the type to data associated to `writer`.
902
+ */
903
+ getData?<Type>(
904
+ writer:
905
+ | Writer<Type>
906
+ | WritableWriter
907
+ | WritableStream
908
+ | AsyncGenerator<
909
+ Writer<unknown> | WritableWriter | WritableStream,
910
+ boolean
911
+ >,
912
+ options?: EntryGetDataOptions,
913
+ ): Promise<Type>;
914
+
915
+ /**
916
+ * Tests if the password is valid.
917
+ *
918
+ * @param writer `undefined` or `null`.
919
+ * @param options The options with `checkPasswordOnly` set to `true`.
920
+ */
921
+ getData?(
922
+ writer: undefined | null,
923
+ options: EntryGetDataCheckPasswordOptions,
924
+ ): Promise<void>;
882
925
  }
883
926
 
884
927
  /**
885
928
  * Represents the options passed to {@link Entry#getData} and `{@link ZipFileEntry}.get*`.
886
929
  */
887
- interface EntryGetDataOptions extends EntryDataOnprogressOptions, ZipReaderOptions, WorkerConfiguration { }
930
+ interface EntryGetDataOptions
931
+ extends EntryDataOnprogressOptions, ZipReaderOptions, WorkerConfiguration {}
932
+
933
+ /**
934
+ * Represents the options passed to {@link Entry#getData} and `{@link ZipFileEntry}.get*`.
935
+ */
936
+ interface EntryGetDataCheckPasswordOptions
937
+ extends EntryGetDataOptions, ZipReaderCheckPasswordOptions {}
888
938
 
889
939
  /**
890
940
  * Represents an instance used to create a zip file.
891
- *
941
+ *
892
942
  * @example
893
943
  * Here is an example showing how to create a zip file containing a compressed text file:
894
944
  * ```
895
945
  * // use a BlobWriter to store with a ZipWriter the zip into a Blob object
896
946
  * const blobWriter = new zip.BlobWriter("application/zip");
897
947
  * const writer = new zip.ZipWriter(blobWriter);
898
- *
948
+ *
899
949
  * // use a TextReader to read the String to add
900
950
  * await writer.add("filename.txt", new zip.TextReader("test!"));
901
- *
951
+ *
902
952
  * // close the ZipReader
903
953
  * await writer.close();
904
- *
954
+ *
905
955
  * // get the zip file as a Blob
906
956
  * const blob = await blobWriter.getData();
907
957
  * ```
908
958
  */
909
959
  export class ZipWriter<Type> {
910
- /**
911
- * Creates the {@link ZipWriter} instance
912
- *
913
- * @param writer The {@link Writer} instance where the zip content will be written.
914
- * @param options The options.
915
- */
916
- constructor(writer: Writer<Type> | WritableWriter | WritableStream | AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream, boolean>, options?: ZipWriterConstructorOptions)
917
- /**
918
- * `true` if the zip contains at least one entry that has been partially written.
919
- */
920
- readonly hasCorruptedEntries?: boolean
921
- /**
922
- * Adds an entry into the zip file
923
- *
924
- * @param filename The filename of the entry.
925
- * @param reader The {@link Reader} instance used to read the content of the entry.
926
- * @param options The options.
927
- * @returns A promise resolving to an {@link EntryMetaData} instance.
928
- */
929
- add<ReaderType>(filename: string, reader?: Reader<ReaderType> | ReadableReader | ReadableStream | Reader<unknown>[] | ReadableReader[] | ReadableStream[], options?: ZipWriterAddDataOptions): Promise<EntryMetaData>
930
- /**
931
- * Writes the entries directory, writes the global comment, and returns the content of the zip file
932
- *
933
- * @param comment The global comment of the zip file.
934
- * @param options The options.
935
- * @returns The content of the zip file.
936
- */
937
- close(comment?: Uint8Array, options?: ZipWriterCloseOptions): Promise<Type>
960
+ /**
961
+ * Creates the {@link ZipWriter} instance
962
+ *
963
+ * @param writer The {@link Writer} instance where the zip content will be written.
964
+ * @param options The options.
965
+ */
966
+ constructor(
967
+ writer:
968
+ | Writer<Type>
969
+ | WritableWriter
970
+ | WritableStream
971
+ | AsyncGenerator<
972
+ Writer<unknown> | WritableWriter | WritableStream,
973
+ boolean
974
+ >,
975
+ options?: ZipWriterConstructorOptions,
976
+ );
977
+ /**
978
+ * `true` if the zip contains at least one entry that has been partially written.
979
+ */
980
+ readonly hasCorruptedEntries?: boolean;
981
+ /**
982
+ * Adds an entry into the zip file
983
+ *
984
+ * @param filename The filename of the entry.
985
+ * @param reader The {@link Reader} instance used to read the content of the entry.
986
+ * @param options The options.
987
+ * @returns A promise resolving to an {@link EntryMetaData} instance.
988
+ */
989
+ add<ReaderType>(
990
+ filename: string,
991
+ reader?:
992
+ | Reader<ReaderType>
993
+ | ReadableReader
994
+ | ReadableStream
995
+ | Reader<unknown>[]
996
+ | ReadableReader[]
997
+ | ReadableStream[],
998
+ options?: ZipWriterAddDataOptions,
999
+ ): Promise<EntryMetaData>;
1000
+ /**
1001
+ * Writes the entries directory, writes the global comment, and returns the content of the zip file
1002
+ *
1003
+ * @param comment The global comment of the zip file.
1004
+ * @param options The options.
1005
+ * @returns The content of the zip file.
1006
+ */
1007
+ close(comment?: Uint8Array, options?: ZipWriterCloseOptions): Promise<Type>;
938
1008
  }
939
1009
 
940
1010
  /**
941
1011
  * Represents the options passed to {@link ZipWriter#add}.
942
1012
  */
943
- interface ZipWriterAddDataOptions extends ZipWriterConstructorOptions, EntryDataOnprogressOptions, WorkerConfiguration {
944
- /**
945
- * `true` if the entry is a directory.
946
- *
947
- * @defaultValue false
948
- */
949
- directory?: boolean
950
- /**
951
- * The comment of the entry.
952
- */
953
- comment?: string
954
- /**
955
- * The extra field of the entry.
956
- */
957
- extraField?: Map<number, Uint8Array>
1013
+ interface ZipWriterAddDataOptions
1014
+ extends
1015
+ ZipWriterConstructorOptions,
1016
+ EntryDataOnprogressOptions,
1017
+ WorkerConfiguration {
1018
+ /**
1019
+ * `true` if the entry is a directory.
1020
+ *
1021
+ * @defaultValue false
1022
+ */
1023
+ directory?: boolean;
1024
+ /**
1025
+ * The comment of the entry.
1026
+ */
1027
+ comment?: string;
1028
+ /**
1029
+ * The extra field of the entry.
1030
+ */
1031
+ extraField?: Map<number, Uint8Array>;
958
1032
  }
959
1033
 
960
1034
  /**
961
1035
  * Represents the options passed to {@link ZipWriter#close}.
962
1036
  */
963
1037
  interface ZipWriterCloseOptions extends EntryOnprogressOptions {
964
- /**
965
- * `true` to use Zip64 to write the entries directory.
966
- *
967
- * @defaultValue false
968
- */
969
- zip64?: boolean
970
- /**
971
- * `true` to prevent closing of {@link WritableWriter#writable}.
972
- *
973
- * @defaultValue false
974
- */
975
- preventClose?: boolean
1038
+ /**
1039
+ * `true` to use Zip64 to write the entries directory.
1040
+ *
1041
+ * @defaultValue false
1042
+ */
1043
+ zip64?: boolean;
1044
+ /**
1045
+ * `true` to prevent closing of {@link WritableWriter#writable}.
1046
+ *
1047
+ * @defaultValue false
1048
+ */
1049
+ preventClose?: boolean;
976
1050
  }
977
1051
 
978
1052
  /**
979
1053
  * Represents options passed to the constructor of {@link ZipWriter}, {@link ZipWriter#add} and `{@link ZipDirectoryEntry}#export*`.
980
1054
  */
981
1055
  interface ZipWriterConstructorOptions {
982
- /**
983
- * `true` to use Zip64 to store the entry.
984
- *
985
- * `zip64` is automatically set to `true` when necessary (e.g. compressed data larger than 4GB or with unknown size).
986
- *
987
- * @defaultValue false
988
- */
989
- zip64?: boolean
990
- /**
991
- * `true` to prevent closing of {@link WritableWriter#writable}.
992
- *
993
- * @defaultValue false
994
- */
995
- preventClose?: boolean
996
- /**
997
- * The level of compression.
998
- *
999
- * The minimum value is 0 and means that no compression is applied. The maximum value is 9.
1000
- *
1001
- * @defaultValue 5
1002
- */
1003
- level?: number
1004
- /**
1005
- * `true` to write entry data in a buffer before appending it to the zip file.
1006
- *
1007
- * `bufferedWrite` is automatically set to `true` when compressing more than one entry in parallel.
1008
- *
1009
- * @defaultValue false
1010
- */
1011
- bufferedWrite?: boolean
1012
- /**
1013
- * `true` to keep the order of the entry physically in the zip file.
1014
- *
1015
- * When set to `true`, the use of web workers will be improved. However, it also prevents files larger than 4GB from being created without setting the `zip54` option to `true` explicitly.
1016
- * Another solution to improve the use of web workers is to add entries from smallest to largest in uncompressed size.
1017
- *
1018
- * @defaultValue true
1019
- */
1020
- keepOrder?: boolean
1021
- /**
1022
- * The password used to encrypt the content of the entry.
1023
- */
1024
- password?: string
1025
- /**
1026
- * The encryption strength (AES).
1027
- *
1028
- * @defaultValue 3
1029
- */
1030
- encryptionStrength?: 1 | 2 | 3
1031
- /**
1032
- * The `AbortSignal` instance used to cancel the compression.
1033
- */
1034
- signal?: AbortSignal
1035
- /**
1036
- * The last modification date.
1037
- *
1038
- * @defaultValue The current date.
1039
- */
1040
- lastModDate?: Date
1041
- /**
1042
- * The last access date.
1043
- *
1044
- * This option is ignored if the {@link ZipWriterConstructorOptions#extendedTimestamp} option is set to `false`.
1045
- *
1046
- * @defaultValue The current date.
1047
- */
1048
- lastAccessDate?: Date
1049
- /**
1050
- * The creation date.
1051
- *
1052
- * This option is ignored if the {@link ZipWriterConstructorOptions#extendedTimestamp} option is set to `false`.
1053
- *
1054
- * @defaultValue The current date.
1055
- */
1056
- creationDate?: Date
1057
- /**
1058
- * `true` to store extended timestamp extra fields.
1059
- *
1060
- * When set to `false`, the maximum last modification date cannot exceed November 31, 2107 and the maximum accuracy is 2 seconds.
1061
- *
1062
- * @defaultValue true
1063
- */
1064
- extendedTimestamp?: boolean
1065
- /**
1066
- * `true` to use the ZipCrypto algorithm to encrypt the content of the entry.
1067
- *
1068
- * It is not recommended to set `zipCrypto` to `true` because the ZipCrypto encryption can be easily broken.
1069
- *
1070
- * @defaultValue false
1071
- */
1072
- zipCrypto?: boolean
1073
- /**
1074
- * The "Version" field.
1075
- */
1076
- version?: number
1077
- /**
1078
- * The "Version made by" field.
1079
- *
1080
- * @defaultValue 20
1081
- */
1082
- versionMadeBy?: number
1083
- /**
1084
- * `true` to to add a data descriptor.
1085
- *
1086
- * When set to `false`, the {@link ZipWriterConstructorOptions#bufferedWrite} option will automatically be set to `true`.
1087
- *
1088
- * @defaultValue true
1089
- */
1090
- dataDescriptor?: boolean
1091
- /**
1092
- * `true` to add the signature of the data descriptor.
1093
- *
1094
- * @defaultValue false
1095
- */
1096
- dataDescriptorSignature?: boolean
1097
- /**
1098
- * `true` to write {@link EntryMetaData#externalFileAttribute} in MS-DOS format for folder entries.
1099
- *
1100
- * @defaultValue true
1101
- */
1102
- msDosCompatible?: boolean
1103
- /**
1104
- * The external file attribute.
1105
- *
1106
- * @defaultValue 0
1107
- */
1108
- externalFileAttribute?: number
1109
- /**
1110
- * The internal file attribute.
1111
- *
1112
- * @defaultValue 0
1113
- */
1114
- internalFileAttribute?: number
1115
- /**
1116
- * `false` to never write disk numbers in zip64 data.
1117
- *
1118
- * @defaultValue true
1119
- */
1120
- supportZip64SplitFile?: boolean
1056
+ /**
1057
+ * `true` to use Zip64 to store the entry.
1058
+ *
1059
+ * `zip64` is automatically set to `true` when necessary (e.g. compressed data larger than 4GB or with unknown size).
1060
+ *
1061
+ * @defaultValue false
1062
+ */
1063
+ zip64?: boolean;
1064
+ /**
1065
+ * `true` to prevent closing of {@link WritableWriter#writable}.
1066
+ *
1067
+ * @defaultValue false
1068
+ */
1069
+ preventClose?: boolean;
1070
+ /**
1071
+ * The level of compression.
1072
+ *
1073
+ * The minimum value is 0 and means that no compression is applied. The maximum value is 9.
1074
+ *
1075
+ * @defaultValue 5
1076
+ */
1077
+ level?: number;
1078
+ /**
1079
+ * `true` to write entry data in a buffer before appending it to the zip file.
1080
+ *
1081
+ * `bufferedWrite` is automatically set to `true` when compressing more than one entry in parallel.
1082
+ *
1083
+ * @defaultValue false
1084
+ */
1085
+ bufferedWrite?: boolean;
1086
+ /**
1087
+ * `true` to keep the order of the entry physically in the zip file.
1088
+ *
1089
+ * When set to `true`, the use of web workers will be improved. However, it also prevents files larger than 4GB from being created without setting the `zip54` option to `true` explicitly.
1090
+ * Another solution to improve the use of web workers is to add entries from smallest to largest in uncompressed size.
1091
+ *
1092
+ * @defaultValue true
1093
+ */
1094
+ keepOrder?: boolean;
1095
+ /**
1096
+ * The password used to encrypt the content of the entry.
1097
+ */
1098
+ password?: string;
1099
+ /**
1100
+ * The encryption strength (AES).
1101
+ *
1102
+ * @defaultValue 3
1103
+ */
1104
+ encryptionStrength?: 1 | 2 | 3;
1105
+ /**
1106
+ * The `AbortSignal` instance used to cancel the compression.
1107
+ */
1108
+ signal?: AbortSignal;
1109
+ /**
1110
+ * The last modification date.
1111
+ *
1112
+ * @defaultValue The current date.
1113
+ */
1114
+ lastModDate?: Date;
1115
+ /**
1116
+ * The last access date.
1117
+ *
1118
+ * This option is ignored if the {@link ZipWriterConstructorOptions#extendedTimestamp} option is set to `false`.
1119
+ *
1120
+ * @defaultValue The current date.
1121
+ */
1122
+ lastAccessDate?: Date;
1123
+ /**
1124
+ * The creation date.
1125
+ *
1126
+ * This option is ignored if the {@link ZipWriterConstructorOptions#extendedTimestamp} option is set to `false`.
1127
+ *
1128
+ * @defaultValue The current date.
1129
+ */
1130
+ creationDate?: Date;
1131
+ /**
1132
+ * `true` to store extended timestamp extra fields.
1133
+ *
1134
+ * When set to `false`, the maximum last modification date cannot exceed November 31, 2107 and the maximum accuracy is 2 seconds.
1135
+ *
1136
+ * @defaultValue true
1137
+ */
1138
+ extendedTimestamp?: boolean;
1139
+ /**
1140
+ * `true` to use the ZipCrypto algorithm to encrypt the content of the entry.
1141
+ *
1142
+ * It is not recommended to set `zipCrypto` to `true` because the ZipCrypto encryption can be easily broken.
1143
+ *
1144
+ * @defaultValue false
1145
+ */
1146
+ zipCrypto?: boolean;
1147
+ /**
1148
+ * The "Version" field.
1149
+ */
1150
+ version?: number;
1151
+ /**
1152
+ * The "Version made by" field.
1153
+ *
1154
+ * @defaultValue 20
1155
+ */
1156
+ versionMadeBy?: number;
1157
+ /**
1158
+ * `true` to to add a data descriptor.
1159
+ *
1160
+ * When set to `false`, the {@link ZipWriterConstructorOptions#bufferedWrite} option will automatically be set to `true`.
1161
+ *
1162
+ * @defaultValue true
1163
+ */
1164
+ dataDescriptor?: boolean;
1165
+ /**
1166
+ * `true` to add the signature of the data descriptor.
1167
+ *
1168
+ * @defaultValue false
1169
+ */
1170
+ dataDescriptorSignature?: boolean;
1171
+ /**
1172
+ * `true` to write {@link EntryMetaData#externalFileAttribute} in MS-DOS format for folder entries.
1173
+ *
1174
+ * @defaultValue true
1175
+ */
1176
+ msDosCompatible?: boolean;
1177
+ /**
1178
+ * The external file attribute.
1179
+ *
1180
+ * @defaultValue 0
1181
+ */
1182
+ externalFileAttribute?: number;
1183
+ /**
1184
+ * The internal file attribute.
1185
+ *
1186
+ * @defaultValue 0
1187
+ */
1188
+ internalFileAttribute?: number;
1189
+ /**
1190
+ * `false` to never write disk numbers in zip64 data.
1191
+ *
1192
+ * @defaultValue true
1193
+ */
1194
+ supportZip64SplitFile?: boolean;
1121
1195
  }
1122
1196
 
1123
1197
  /**
1124
1198
  * Represents options passed to {@link Entry#getData}, {@link ZipWriter.add} and `{@link ZipDirectory}.export*`.
1125
1199
  */
1126
1200
  interface EntryDataOnprogressOptions {
1127
- /**
1128
- * The function called when starting compression/decompression.
1129
- *
1130
- * @param total The total number of bytes.
1131
- * @returns An empty promise or `undefined`.
1132
- */
1133
- onstart?(total: number): Promise<void> | undefined
1134
- /**
1135
- * The function called during compression/decompression.
1136
- *
1137
- * @param progress The current progress in bytes.
1138
- * @param total The total number of bytes.
1139
- * @returns An empty promise or `undefined`.
1140
- */
1141
- onprogress?(progress: number, total: number): Promise<void> | undefined
1142
- /**
1143
- * The function called when ending compression/decompression.
1144
- *
1145
- * @param computedSize The total number of bytes (computed).
1146
- * @returns An empty promise or `undefined`.
1147
- */
1148
- onend?(computedSize: number): Promise<void> | undefined
1201
+ /**
1202
+ * The function called when starting compression/decompression.
1203
+ *
1204
+ * @param total The total number of bytes.
1205
+ * @returns An empty promise or `undefined`.
1206
+ */
1207
+ onstart?(total: number): Promise<void> | undefined;
1208
+ /**
1209
+ * The function called during compression/decompression.
1210
+ *
1211
+ * @param progress The current progress in bytes.
1212
+ * @param total The total number of bytes.
1213
+ * @returns An empty promise or `undefined`.
1214
+ */
1215
+ onprogress?(progress: number, total: number): Promise<void> | undefined;
1216
+ /**
1217
+ * The function called when ending compression/decompression.
1218
+ *
1219
+ * @param computedSize The total number of bytes (computed).
1220
+ * @returns An empty promise or `undefined`.
1221
+ */
1222
+ onend?(computedSize: number): Promise<void> | undefined;
1149
1223
  }
1150
1224
 
1151
1225
  /**
1152
1226
  * Represents options passed to {@link ZipReader#getEntries}, {@link ZipReader#getEntriesGenerator}, and {@link ZipWriter#close}.
1153
1227
  */
1154
1228
  interface EntryOnprogressOptions {
1155
- /**
1156
- * The function called each time an entry is read/written.
1157
- *
1158
- * @param progress The entry index.
1159
- * @param total The total number of entries.
1160
- * @param entry The entry being read/written.
1161
- * @returns An empty promise or `undefined`.
1162
- */
1163
- onprogress?(progress: number, total: number, entry: EntryMetaData): Promise<void> | undefined
1229
+ /**
1230
+ * The function called each time an entry is read/written.
1231
+ *
1232
+ * @param progress The entry index.
1233
+ * @param total The total number of entries.
1234
+ * @param entry The entry being read/written.
1235
+ * @returns An empty promise or `undefined`.
1236
+ */
1237
+ onprogress?(
1238
+ progress: number,
1239
+ total: number,
1240
+ entry: EntryMetaData,
1241
+ ): Promise<void> | undefined;
1164
1242
  }
1165
1243
 
1166
1244
  /**
1167
1245
  * Represents an entry in a zip file (Filesystem API).
1168
1246
  */
1169
1247
  declare class ZipEntry {
1170
- /**
1171
- * The relative filename of the entry.
1172
- */
1173
- name: string
1174
- /**
1175
- * The underlying {@link EntryMetaData} instance.
1176
- */
1177
- data?: EntryMetaData
1178
- /**
1179
- * The ID of the instance.
1180
- */
1181
- id: number
1182
- /**
1183
- * The parent directory of the entry.
1184
- */
1185
- parent?: ZipEntry
1186
- /**
1187
- * The uncompressed size of the content.
1188
- */
1189
- uncompressedSize: number
1190
- /**
1191
- * The children of the entry.
1192
- */
1193
- children: ZipEntry[]
1194
- /**
1195
- * Clones the entry
1196
- *
1197
- * @param deepClone `true` to clone all the descendants.
1198
- */
1199
- clone(deepClone?: boolean): ZipEntry
1200
- /**
1201
- * Returns the full filename of the entry
1202
- */
1203
- getFullname(): string
1204
- /**
1205
- * Returns the filename of the entry relative to a parent directory
1206
- */
1207
- getRelativeName(ancestor: ZipDirectoryEntry): string
1208
- /**
1209
- * Tests if a {@link ZipDirectoryEntry} instance is an ancestor of the entry
1210
- *
1211
- * @param ancestor The {@link ZipDirectoryEntry} instance.
1212
- */
1213
- isDescendantOf(ancestor: ZipDirectoryEntry): boolean
1214
- /**
1215
- * Tests if the entry or any of its children is password protected
1216
- */
1217
- isPasswordProtected(): boolean
1218
- /**
1219
- * Tests the password on the entry and all children if any, returns `true` if the entry is not password protected
1220
- */
1221
- checkPassword(password: string, options?: EntryGetDataOptions): Promise<boolean>
1222
- /**
1223
- * Set the name of the entry
1224
- *
1225
- * @param name The new name of the netry.
1226
- */
1227
- rename(name: string): void
1248
+ /**
1249
+ * The relative filename of the entry.
1250
+ */
1251
+ name: string;
1252
+ /**
1253
+ * The underlying {@link EntryMetaData} instance.
1254
+ */
1255
+ data?: EntryMetaData;
1256
+ /**
1257
+ * The ID of the instance.
1258
+ */
1259
+ id: number;
1260
+ /**
1261
+ * The parent directory of the entry.
1262
+ */
1263
+ parent?: ZipEntry;
1264
+ /**
1265
+ * The uncompressed size of the content.
1266
+ */
1267
+ uncompressedSize: number;
1268
+ /**
1269
+ * The children of the entry.
1270
+ */
1271
+ children: ZipEntry[];
1272
+ /**
1273
+ * Clones the entry
1274
+ *
1275
+ * @param deepClone `true` to clone all the descendants.
1276
+ */
1277
+ clone(deepClone?: boolean): ZipEntry;
1278
+ /**
1279
+ * Returns the full filename of the entry
1280
+ */
1281
+ getFullname(): string;
1282
+ /**
1283
+ * Returns the filename of the entry relative to a parent directory
1284
+ */
1285
+ getRelativeName(ancestor: ZipDirectoryEntry): string;
1286
+ /**
1287
+ * Tests if a {@link ZipDirectoryEntry} instance is an ancestor of the entry
1288
+ *
1289
+ * @param ancestor The {@link ZipDirectoryEntry} instance.
1290
+ */
1291
+ isDescendantOf(ancestor: ZipDirectoryEntry): boolean;
1292
+ /**
1293
+ * Tests if the entry or any of its children is password protected
1294
+ */
1295
+ isPasswordProtected(): boolean;
1296
+ /**
1297
+ * Tests the password on the entry and all children if any, returns `true` if the entry is not password protected
1298
+ */
1299
+ checkPassword(
1300
+ password: string,
1301
+ options?: EntryGetDataOptions,
1302
+ ): Promise<boolean>;
1303
+ /**
1304
+ * Set the name of the entry
1305
+ *
1306
+ * @param name The new name of the netry.
1307
+ */
1308
+ rename(name: string): void;
1228
1309
  }
1229
1310
 
1230
1311
  /**
1231
1312
  * Represents a file entry in the zip (Filesystem API).
1232
1313
  */
1233
1314
  export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
1234
- /**
1235
- * `void` for {@link ZipFileEntry} instances.
1236
- */
1237
- directory: void
1238
- /**
1239
- * The {@link Reader} instance used to read the content of the entry.
1240
- */
1241
- reader: Reader<ReaderType> | ReadableReader | ReadableStream | Reader<unknown>[] | ReadableReader[] | ReadableStream[]
1242
- /**
1243
- * The {@link Writer} instance used to write the content of the entry.
1244
- */
1245
- writer: Writer<WriterType> | WritableWriter | WritableStream | AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream>
1246
- /**
1247
- * Retrieves the text content of the entry as a `string`
1248
- *
1249
- * @param encoding The encoding of the text.
1250
- * @param options The options.
1251
- * @returns A promise resolving to a `string`.
1252
- */
1253
- getText(encoding?: string, options?: EntryGetDataOptions): Promise<string>
1254
- /**
1255
- * Retrieves the content of the entry as a `Blob` instance
1256
- *
1257
- * @param mimeType The MIME type of the content.
1258
- * @param options The options.
1259
- * @returns A promise resolving to a `Blob` instance.
1260
- */
1261
- getBlob(mimeType?: string, options?: EntryGetDataOptions): Promise<Blob>
1262
- /**
1263
- * Retrieves the content of the entry as as a Data URI `string` encoded in Base64
1264
- *
1265
- * @param mimeType The MIME type of the content.
1266
- * @param options The options.
1267
- * @returns A promise resolving to a Data URI `string` encoded in Base64.
1268
- */
1269
- getData64URI(mimeType?: string, options?: EntryGetDataOptions): Promise<string>
1270
- /**
1271
- * Retrieves the content of the entry as a `Uint8Array` instance
1272
- *
1273
- * @param options The options.
1274
- * @returns A promise resolving to a `Uint8Array` instance.
1275
- */
1276
- getUint8Array(options?: EntryGetDataOptions): Promise<Uint8Array>
1277
- /**
1278
- * Retrieves the content of the entry via a `WritableStream` instance
1279
- *
1280
- * @param writable The `WritableStream` instance.
1281
- * @param options The options.
1282
- * @returns A promise resolving to the `WritableStream` instance.
1283
- */
1284
- getWritable(writable?: WritableStream, options?: EntryGetDataOptions): Promise<WritableStream>
1285
- /**
1286
- * Retrieves the content of the entry via a {@link Writer} instance
1287
- *
1288
- * @param writer The {@link Writer} instance.
1289
- * @param options The options.
1290
- * @returns A promise resolving to data associated to the {@link Writer} instance.
1291
- */
1292
- getData(writer: Writer<unknown> | WritableWriter | WritableStream | AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream>, options?: EntryGetDataOptions): Promise<unknown>
1293
- /**
1294
- * Replaces the content of the entry with a `Blob` instance
1295
- *
1296
- * @param blob The `Blob` instance.
1297
- */
1298
- replaceBlob(blob: Blob): void
1299
- /**
1300
- * Replaces the content of the entry with a `string`
1301
- *
1302
- * @param text The `string`.
1303
- */
1304
- replaceText(text: string): void
1305
- /**
1306
- * Replaces the content of the entry with a Data URI `string` encoded in Base64
1307
- *
1308
- * @param dataURI The Data URI `string` encoded in Base64.
1309
- */
1310
- replaceData64URI(dataURI: string): void
1311
- /**
1312
- * Replaces the content of the entry with a `Uint8Array` instance
1313
- *
1314
- * @param array The `Uint8Array` instance.
1315
- */
1316
- replaceUint8Array(array: Uint8Array): void
1317
- /**
1318
- * Replaces the content of the entry with a `ReadableStream` instance
1319
- *
1320
- * @param readable The `ReadableStream` instance.
1321
- */
1322
- replaceReadable(readable: ReadableStream): void
1315
+ /**
1316
+ * `void` for {@link ZipFileEntry} instances.
1317
+ */
1318
+ directory: void;
1319
+ /**
1320
+ * The {@link Reader} instance used to read the content of the entry.
1321
+ */
1322
+ reader:
1323
+ | Reader<ReaderType>
1324
+ | ReadableReader
1325
+ | ReadableStream
1326
+ | Reader<unknown>[]
1327
+ | ReadableReader[]
1328
+ | ReadableStream[];
1329
+ /**
1330
+ * The {@link Writer} instance used to write the content of the entry.
1331
+ */
1332
+ writer:
1333
+ | Writer<WriterType>
1334
+ | WritableWriter
1335
+ | WritableStream
1336
+ | AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream>;
1337
+ /**
1338
+ * Retrieves the text content of the entry as a `string`
1339
+ *
1340
+ * @param encoding The encoding of the text.
1341
+ * @param options The options.
1342
+ * @returns A promise resolving to a `string`.
1343
+ */
1344
+ getText(encoding?: string, options?: EntryGetDataOptions): Promise<string>;
1345
+ /**
1346
+ * Retrieves the content of the entry as a `Blob` instance
1347
+ *
1348
+ * @param mimeType The MIME type of the content.
1349
+ * @param options The options.
1350
+ * @returns A promise resolving to a `Blob` instance.
1351
+ */
1352
+ getBlob(mimeType?: string, options?: EntryGetDataOptions): Promise<Blob>;
1353
+ /**
1354
+ * Retrieves the content of the entry as as a Data URI `string` encoded in Base64
1355
+ *
1356
+ * @param mimeType The MIME type of the content.
1357
+ * @param options The options.
1358
+ * @returns A promise resolving to a Data URI `string` encoded in Base64.
1359
+ */
1360
+ getData64URI(
1361
+ mimeType?: string,
1362
+ options?: EntryGetDataOptions,
1363
+ ): Promise<string>;
1364
+ /**
1365
+ * Retrieves the content of the entry as a `Uint8Array` instance
1366
+ *
1367
+ * @param options The options.
1368
+ * @returns A promise resolving to a `Uint8Array` instance.
1369
+ */
1370
+ getUint8Array(options?: EntryGetDataOptions): Promise<Uint8Array>;
1371
+ /**
1372
+ * Retrieves the content of the entry via a `WritableStream` instance
1373
+ *
1374
+ * @param writable The `WritableStream` instance.
1375
+ * @param options The options.
1376
+ * @returns A promise resolving to the `WritableStream` instance.
1377
+ */
1378
+ getWritable(
1379
+ writable?: WritableStream,
1380
+ options?: EntryGetDataOptions,
1381
+ ): Promise<WritableStream>;
1382
+ /**
1383
+ * Retrieves the content of the entry via a {@link Writer} instance
1384
+ *
1385
+ * @param writer The {@link Writer} instance.
1386
+ * @param options The options.
1387
+ * @returns A promise resolving to data associated to the {@link Writer} instance.
1388
+ */
1389
+ getData(
1390
+ writer:
1391
+ | Writer<unknown>
1392
+ | WritableWriter
1393
+ | WritableStream
1394
+ | AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream>,
1395
+ options?: EntryGetDataOptions,
1396
+ ): Promise<unknown>;
1397
+ /**
1398
+ * Replaces the content of the entry with a `Blob` instance
1399
+ *
1400
+ * @param blob The `Blob` instance.
1401
+ */
1402
+ replaceBlob(blob: Blob): void;
1403
+ /**
1404
+ * Replaces the content of the entry with a `string`
1405
+ *
1406
+ * @param text The `string`.
1407
+ */
1408
+ replaceText(text: string): void;
1409
+ /**
1410
+ * Replaces the content of the entry with a Data URI `string` encoded in Base64
1411
+ *
1412
+ * @param dataURI The Data URI `string` encoded in Base64.
1413
+ */
1414
+ replaceData64URI(dataURI: string): void;
1415
+ /**
1416
+ * Replaces the content of the entry with a `Uint8Array` instance
1417
+ *
1418
+ * @param array The `Uint8Array` instance.
1419
+ */
1420
+ replaceUint8Array(array: Uint8Array): void;
1421
+ /**
1422
+ * Replaces the content of the entry with a `ReadableStream` instance
1423
+ *
1424
+ * @param readable The `ReadableStream` instance.
1425
+ */
1426
+ replaceReadable(readable: ReadableStream): void;
1323
1427
  }
1324
1428
 
1325
1429
  /**
1326
1430
  * Represents a directory entry in the zip (Filesystem API).
1327
1431
  */
1328
1432
  export class ZipDirectoryEntry extends ZipEntry {
1329
- /**
1330
- * `true` for {@link ZipDirectoryEntry} instances.
1331
- */
1332
- directory: true
1333
- /**
1334
- * Gets a {@link ZipEntry} child instance from its relative filename
1335
- *
1336
- * @param name The relative filename.
1337
- * @returns A {@link ZipFileEntry} or a {@link ZipDirectoryEntry} instance (use the {@link ZipFileEntry#directory} and {@link ZipDirectoryEntry#directory} properties to differentiate entries).
1338
- */
1339
- getChildByName(name: string): ZipEntry | undefined
1340
- /**
1341
- * Adds a directory
1342
- *
1343
- * @param name The relative filename of the directory.
1344
- * @param options The options.
1345
- * @returns A {@link ZipDirectoryEntry} instance.
1346
- */
1347
- addDirectory(name: string, options?: ZipWriterAddDataOptions): ZipDirectoryEntry
1348
- /**
1349
- * Adds an entry with content provided as text
1350
- *
1351
- * @param name The relative filename of the entry.
1352
- * @param text The text.
1353
- * @param options The options.
1354
- * @returns A {@link ZipFileEntry} instance.
1355
- */
1356
- addText(name: string, text: string, options?: ZipWriterAddDataOptions): ZipFileEntry<string, string>
1357
- /**
1358
- * Adds aentry entry with content provided as a `Blob` instance
1359
- *
1360
- * @param name The relative filename of the entry.
1361
- * @param blob The `Blob` instance.
1362
- * @param options The options.
1363
- * @returns A {@link ZipFileEntry} instance.
1364
- */
1365
- addBlob(name: string, blob: Blob, options?: ZipWriterAddDataOptions): ZipFileEntry<Blob, Blob>
1366
- /**
1367
- * Adds aentry entry with content provided as a Data URI `string` encoded in Base64
1368
- *
1369
- * @param name The relative filename of the entry.
1370
- * @param dataURI The Data URI `string` encoded in Base64.
1371
- * @param options The options.
1372
- * @returns A {@link ZipFileEntry} instance.
1373
- */
1374
- addData64URI(name: string, dataURI: string, options?: ZipWriterAddDataOptions): ZipFileEntry<string, string>
1375
- /**
1376
- * Adds an entry with content provided as a `Uint8Array` instance
1377
- *
1378
- * @param name The relative filename of the entry.
1379
- * @param array The `Uint8Array` instance.
1380
- * @param options The options.
1381
- * @returns A {@link ZipFileEntry} instance.
1382
- */
1383
- addUint8Array(name: string, array: Uint8Array, options?: ZipWriterAddDataOptions): ZipFileEntry<Uint8Array, Uint8Array>
1384
- /**
1385
- * Adds an entry with content fetched from a URL
1386
- *
1387
- * @param name The relative filename of the entry.
1388
- * @param url The URL.
1389
- * @param options The options.
1390
- * @returns A {@link ZipFileEntry} instance.
1391
- */
1392
- addHttpContent(name: string, url: string, options?: HttpOptions & ZipWriterAddDataOptions): ZipFileEntry<string, void>
1393
- /**
1394
- * Adds aentry entry with content provided via a `ReadableStream` instance
1395
- *
1396
- * @param name The relative filename of the entry.
1397
- * @param readable The `ReadableStream` instance.
1398
- * @param options The options.
1399
- * @returns A {@link ZipFileEntry} instance.
1400
- */
1401
- addReadable(name: string, readable: ReadableStream, options?: ZipWriterAddDataOptions): ZipFileEntry<ReadableStream, void>
1402
- /**
1403
- * Adds an entry with content provided via a `FileSystemEntry` instance
1404
- *
1405
- * @param fileSystemEntry The `FileSystemEntry` instance.
1406
- * @param options The options.
1407
- * @returns A promise resolving to a {@link ZipFileEntry} or a {@link ZipDirectoryEntry} instance.
1408
- */
1409
- addFileSystemEntry(fileSystemEntry: FileSystemEntry, options?: ZipWriterAddDataOptions): Promise<ZipEntry>
1410
- /**
1411
- * Extracts a zip file provided as a `Blob` instance into the entry
1412
- *
1413
- * @param blob The `Blob` instance.
1414
- * @param options The options.
1415
- */
1416
- importBlob(blob: Blob, options?: ZipReaderConstructorOptions): Promise<[ZipEntry]>
1417
- /**
1418
- * Extracts a zip file provided as a Data URI `string` encoded in Base64 into the entry
1419
- *
1420
- * @param dataURI The Data URI `string` encoded in Base64.
1421
- * @param options The options.
1422
- */
1423
- importData64URI(dataURI: string, options?: ZipReaderConstructorOptions): Promise<[ZipEntry]>
1424
- /**
1425
- * Extracts a zip file provided as a `Uint8Array` instance into the entry
1426
- *
1427
- * @param array The `Uint8Array` instance.
1428
- * @param options The options.
1429
- */
1430
- importUint8Array(array: Uint8Array, options?: ZipReaderConstructorOptions): Promise<[ZipEntry]>
1431
- /**
1432
- * Extracts a zip file fetched from a URL into the entry
1433
- *
1434
- * @param url The URL.
1435
- * @param options The options.
1436
- */
1437
- importHttpContent(url: string, options?: ZipDirectoryEntryImportHttpOptions): Promise<[ZipEntry]>
1438
- /**
1439
- * Extracts a zip file provided via a `ReadableStream` instance into the entry
1440
- *
1441
- * @param readable The `ReadableStream` instance.
1442
- * @param options The options.
1443
- */
1444
- importReadable(readable: ReadableStream, options?: ZipReaderConstructorOptions): Promise<[ZipEntry]>
1445
- /**
1446
- * Extracts a zip file provided via a custom {@link Reader} instance into the entry
1447
- *
1448
- * @param reader The {@link Reader} instance.
1449
- * @param options The options.
1450
- */
1451
- importZip(reader: Reader<unknown> | ReadableReader | ReadableStream | Reader<unknown>[] | ReadableReader[] | ReadableStream[], options?: ZipReaderConstructorOptions): Promise<[ZipEntry]>
1452
- /**
1453
- * Returns a `Blob` instance containing a zip file of the entry and its descendants
1454
- *
1455
- * @param options The options.
1456
- * @returns A promise resolving to the `Blob` instance.
1457
- */
1458
- exportBlob(options?: ZipDirectoryEntryExportOptions): Promise<Blob>
1459
- /**
1460
- * Returns a Data URI `string` encoded in Base64 containing a zip file of the entry and its descendants
1461
- *
1462
- * @param options The options.
1463
- * @returns A promise resolving to the Data URI `string` encoded in Base64.
1464
- */
1465
- exportData64URI(options?: ZipDirectoryEntryExportOptions): Promise<string>
1466
- /**
1467
- * Returns a `Uint8Array` instance containing a zip file of the entry and its descendants
1468
- *
1469
- * @param options The options.
1470
- * @returns A promise resolving to the `Uint8Array` instance.
1471
- */
1472
- exportUint8Array(options?: ZipDirectoryEntryExportOptions): Promise<Uint8Array>
1473
- /**
1474
- * Creates a zip file via a `WritableStream` instance containing the entry and its descendants
1475
- *
1476
- * @param writable The `WritableStream` instance.
1477
- * @param options The options.
1478
- * @returns A promise resolving to the `Uint8Array` instance.
1479
- */
1480
- exportWritable(writable?: WritableStream, options?: ZipDirectoryEntryExportOptions): Promise<WritableStream>
1481
- /**
1482
- * Creates a zip file via a custom {@link Writer} instance containing the entry and its descendants
1483
- *
1484
- * @param writer The {@link Writer} instance.
1485
- * @param options The options.
1486
- * @returns A promise resolving to the data.
1487
- */
1488
- exportZip(writer: Writer<unknown> | WritableWriter | WritableStream | AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream>, options?: ZipDirectoryEntryExportOptions): Promise<unknown>
1433
+ /**
1434
+ * `true` for {@link ZipDirectoryEntry} instances.
1435
+ */
1436
+ directory: true;
1437
+ /**
1438
+ * Gets a {@link ZipEntry} child instance from its relative filename
1439
+ *
1440
+ * @param name The relative filename.
1441
+ * @returns A {@link ZipFileEntry} or a {@link ZipDirectoryEntry} instance (use the {@link ZipFileEntry#directory} and {@link ZipDirectoryEntry#directory} properties to differentiate entries).
1442
+ */
1443
+ getChildByName(name: string): ZipEntry | undefined;
1444
+ /**
1445
+ * Adds a directory
1446
+ *
1447
+ * @param name The relative filename of the directory.
1448
+ * @param options The options.
1449
+ * @returns A {@link ZipDirectoryEntry} instance.
1450
+ */
1451
+ addDirectory(
1452
+ name: string,
1453
+ options?: ZipWriterAddDataOptions,
1454
+ ): ZipDirectoryEntry;
1455
+ /**
1456
+ * Adds an entry with content provided as text
1457
+ *
1458
+ * @param name The relative filename of the entry.
1459
+ * @param text The text.
1460
+ * @param options The options.
1461
+ * @returns A {@link ZipFileEntry} instance.
1462
+ */
1463
+ addText(
1464
+ name: string,
1465
+ text: string,
1466
+ options?: ZipWriterAddDataOptions,
1467
+ ): ZipFileEntry<string, string>;
1468
+ /**
1469
+ * Adds aentry entry with content provided as a `Blob` instance
1470
+ *
1471
+ * @param name The relative filename of the entry.
1472
+ * @param blob The `Blob` instance.
1473
+ * @param options The options.
1474
+ * @returns A {@link ZipFileEntry} instance.
1475
+ */
1476
+ addBlob(
1477
+ name: string,
1478
+ blob: Blob,
1479
+ options?: ZipWriterAddDataOptions,
1480
+ ): ZipFileEntry<Blob, Blob>;
1481
+ /**
1482
+ * Adds aentry entry with content provided as a Data URI `string` encoded in Base64
1483
+ *
1484
+ * @param name The relative filename of the entry.
1485
+ * @param dataURI The Data URI `string` encoded in Base64.
1486
+ * @param options The options.
1487
+ * @returns A {@link ZipFileEntry} instance.
1488
+ */
1489
+ addData64URI(
1490
+ name: string,
1491
+ dataURI: string,
1492
+ options?: ZipWriterAddDataOptions,
1493
+ ): ZipFileEntry<string, string>;
1494
+ /**
1495
+ * Adds an entry with content provided as a `Uint8Array` instance
1496
+ *
1497
+ * @param name The relative filename of the entry.
1498
+ * @param array The `Uint8Array` instance.
1499
+ * @param options The options.
1500
+ * @returns A {@link ZipFileEntry} instance.
1501
+ */
1502
+ addUint8Array(
1503
+ name: string,
1504
+ array: Uint8Array,
1505
+ options?: ZipWriterAddDataOptions,
1506
+ ): ZipFileEntry<Uint8Array, Uint8Array>;
1507
+ /**
1508
+ * Adds an entry with content fetched from a URL
1509
+ *
1510
+ * @param name The relative filename of the entry.
1511
+ * @param url The URL.
1512
+ * @param options The options.
1513
+ * @returns A {@link ZipFileEntry} instance.
1514
+ */
1515
+ addHttpContent(
1516
+ name: string,
1517
+ url: string,
1518
+ options?: HttpOptions & ZipWriterAddDataOptions,
1519
+ ): ZipFileEntry<string, void>;
1520
+ /**
1521
+ * Adds aentry entry with content provided via a `ReadableStream` instance
1522
+ *
1523
+ * @param name The relative filename of the entry.
1524
+ * @param readable The `ReadableStream` instance.
1525
+ * @param options The options.
1526
+ * @returns A {@link ZipFileEntry} instance.
1527
+ */
1528
+ addReadable(
1529
+ name: string,
1530
+ readable: ReadableStream,
1531
+ options?: ZipWriterAddDataOptions,
1532
+ ): ZipFileEntry<ReadableStream, void>;
1533
+ /**
1534
+ * Adds an entry with content provided via a `FileSystemEntry` instance
1535
+ *
1536
+ * @param fileSystemEntry The `FileSystemEntry` instance.
1537
+ * @param options The options.
1538
+ * @returns A promise resolving to a {@link ZipFileEntry} or a {@link ZipDirectoryEntry} instance.
1539
+ */
1540
+ addFileSystemEntry(
1541
+ fileSystemEntry: FileSystemEntry,
1542
+ options?: ZipWriterAddDataOptions,
1543
+ ): Promise<ZipEntry>;
1544
+ /**
1545
+ * Extracts a zip file provided as a `Blob` instance into the entry
1546
+ *
1547
+ * @param blob The `Blob` instance.
1548
+ * @param options The options.
1549
+ */
1550
+ importBlob(
1551
+ blob: Blob,
1552
+ options?: ZipReaderConstructorOptions,
1553
+ ): Promise<[ZipEntry]>;
1554
+ /**
1555
+ * Extracts a zip file provided as a Data URI `string` encoded in Base64 into the entry
1556
+ *
1557
+ * @param dataURI The Data URI `string` encoded in Base64.
1558
+ * @param options The options.
1559
+ */
1560
+ importData64URI(
1561
+ dataURI: string,
1562
+ options?: ZipReaderConstructorOptions,
1563
+ ): Promise<[ZipEntry]>;
1564
+ /**
1565
+ * Extracts a zip file provided as a `Uint8Array` instance into the entry
1566
+ *
1567
+ * @param array The `Uint8Array` instance.
1568
+ * @param options The options.
1569
+ */
1570
+ importUint8Array(
1571
+ array: Uint8Array,
1572
+ options?: ZipReaderConstructorOptions,
1573
+ ): Promise<[ZipEntry]>;
1574
+ /**
1575
+ * Extracts a zip file fetched from a URL into the entry
1576
+ *
1577
+ * @param url The URL.
1578
+ * @param options The options.
1579
+ */
1580
+ importHttpContent(
1581
+ url: string,
1582
+ options?: ZipDirectoryEntryImportHttpOptions,
1583
+ ): Promise<[ZipEntry]>;
1584
+ /**
1585
+ * Extracts a zip file provided via a `ReadableStream` instance into the entry
1586
+ *
1587
+ * @param readable The `ReadableStream` instance.
1588
+ * @param options The options.
1589
+ */
1590
+ importReadable(
1591
+ readable: ReadableStream,
1592
+ options?: ZipReaderConstructorOptions,
1593
+ ): Promise<[ZipEntry]>;
1594
+ /**
1595
+ * Extracts a zip file provided via a custom {@link Reader} instance into the entry
1596
+ *
1597
+ * @param reader The {@link Reader} instance.
1598
+ * @param options The options.
1599
+ */
1600
+ importZip(
1601
+ reader:
1602
+ | Reader<unknown>
1603
+ | ReadableReader
1604
+ | ReadableStream
1605
+ | Reader<unknown>[]
1606
+ | ReadableReader[]
1607
+ | ReadableStream[],
1608
+ options?: ZipReaderConstructorOptions,
1609
+ ): Promise<[ZipEntry]>;
1610
+ /**
1611
+ * Returns a `Blob` instance containing a zip file of the entry and its descendants
1612
+ *
1613
+ * @param options The options.
1614
+ * @returns A promise resolving to the `Blob` instance.
1615
+ */
1616
+ exportBlob(options?: ZipDirectoryEntryExportOptions): Promise<Blob>;
1617
+ /**
1618
+ * Returns a Data URI `string` encoded in Base64 containing a zip file of the entry and its descendants
1619
+ *
1620
+ * @param options The options.
1621
+ * @returns A promise resolving to the Data URI `string` encoded in Base64.
1622
+ */
1623
+ exportData64URI(options?: ZipDirectoryEntryExportOptions): Promise<string>;
1624
+ /**
1625
+ * Returns a `Uint8Array` instance containing a zip file of the entry and its descendants
1626
+ *
1627
+ * @param options The options.
1628
+ * @returns A promise resolving to the `Uint8Array` instance.
1629
+ */
1630
+ exportUint8Array(
1631
+ options?: ZipDirectoryEntryExportOptions,
1632
+ ): Promise<Uint8Array>;
1633
+ /**
1634
+ * Creates a zip file via a `WritableStream` instance containing the entry and its descendants
1635
+ *
1636
+ * @param writable The `WritableStream` instance.
1637
+ * @param options The options.
1638
+ * @returns A promise resolving to the `Uint8Array` instance.
1639
+ */
1640
+ exportWritable(
1641
+ writable?: WritableStream,
1642
+ options?: ZipDirectoryEntryExportOptions,
1643
+ ): Promise<WritableStream>;
1644
+ /**
1645
+ * Creates a zip file via a custom {@link Writer} instance containing the entry and its descendants
1646
+ *
1647
+ * @param writer The {@link Writer} instance.
1648
+ * @param options The options.
1649
+ * @returns A promise resolving to the data.
1650
+ */
1651
+ exportZip(
1652
+ writer:
1653
+ | Writer<unknown>
1654
+ | WritableWriter
1655
+ | WritableStream
1656
+ | AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream>,
1657
+ options?: ZipDirectoryEntryExportOptions,
1658
+ ): Promise<unknown>;
1489
1659
  }
1490
1660
 
1491
1661
  /**
1492
1662
  * Represents the options passed to {@link ZipDirectoryEntry#importHttpContent}.
1493
1663
  */
1494
- interface ZipDirectoryEntryImportHttpOptions extends ZipReaderConstructorOptions, HttpOptions { }
1664
+ interface ZipDirectoryEntryImportHttpOptions
1665
+ extends ZipReaderConstructorOptions, HttpOptions {}
1495
1666
 
1496
1667
  /**
1497
1668
  * Represents the options passed to `{@link ZipDirectoryEntry}#export*()`.
1498
1669
  */
1499
- interface ZipDirectoryEntryExportOptions extends ZipWriterConstructorOptions, EntryDataOnprogressOptions {
1500
- /**
1501
- * `true` to use filenames relative to the entry instead of full filenames.
1502
- */
1503
- relativePath?: boolean
1504
- /**
1505
- * The MIME type of the exported data when relevant.
1506
- */
1507
- mimeType?: string
1508
- /**
1509
- * The options passed to the Reader instances
1510
- */
1511
- readerOptions?: ZipReaderConstructorOptions
1670
+ interface ZipDirectoryEntryExportOptions
1671
+ extends ZipWriterConstructorOptions, EntryDataOnprogressOptions {
1672
+ /**
1673
+ * `true` to use filenames relative to the entry instead of full filenames.
1674
+ */
1675
+ relativePath?: boolean;
1676
+ /**
1677
+ * The MIME type of the exported data when relevant.
1678
+ */
1679
+ mimeType?: string;
1680
+ /**
1681
+ * The options passed to the Reader instances
1682
+ */
1683
+ readerOptions?: ZipReaderConstructorOptions;
1512
1684
  }
1513
1685
 
1514
1686
  /**
1515
1687
  * Represents a Filesystem instance.
1516
- *
1688
+ *
1517
1689
  * @example
1518
1690
  * Here is an example showing how to create and read a zip file containing a compressed text file:
1519
1691
  * ```
@@ -1530,85 +1702,85 @@ interface ZipDirectoryEntryExportOptions extends ZipWriterConstructorOptions, En
1530
1702
  * ```
1531
1703
  */
1532
1704
  export class FS extends ZipDirectoryEntry {
1533
- /**
1534
- * The root directory.
1535
- */
1536
- root: ZipDirectoryEntry
1537
- /**
1538
- * Removes a {@link ZipEntry} instance and its children
1539
- *
1540
- * @param entry The {@link ZipEntry} instance to remove.
1541
- */
1542
- remove(entry: ZipEntry): void
1543
- /**
1544
- * Moves a {@link ZipEntry} instance and its children into a {@link ZipDirectoryEntry} instance
1545
- *
1546
- * @param entry The {@link ZipEntry} instance to move.
1547
- * @param destination The {@link ZipDirectoryEntry} instance.
1548
- */
1549
- move(entry: ZipEntry, destination: ZipDirectoryEntry): void
1550
- /**
1551
- * Returns a {@link ZipEntry} instance from its full filename
1552
- *
1553
- * @param fullname The full filename.
1554
- * @returns The {@link ZipEntry} instance.
1555
- */
1556
- find(fullname: string): ZipEntry | undefined
1557
- /**
1558
- * Returns a {@link ZipEntry} instance from the value of {@link ZipEntry#id}
1559
- *
1560
- * @param id The id of the {@link ZipEntry} instance.
1561
- * @returns The {@link ZipEntry} instance.
1562
- */
1563
- getById(id: number): ZipEntry | undefined
1705
+ /**
1706
+ * The root directory.
1707
+ */
1708
+ root: ZipDirectoryEntry;
1709
+ /**
1710
+ * Removes a {@link ZipEntry} instance and its children
1711
+ *
1712
+ * @param entry The {@link ZipEntry} instance to remove.
1713
+ */
1714
+ remove(entry: ZipEntry): void;
1715
+ /**
1716
+ * Moves a {@link ZipEntry} instance and its children into a {@link ZipDirectoryEntry} instance
1717
+ *
1718
+ * @param entry The {@link ZipEntry} instance to move.
1719
+ * @param destination The {@link ZipDirectoryEntry} instance.
1720
+ */
1721
+ move(entry: ZipEntry, destination: ZipDirectoryEntry): void;
1722
+ /**
1723
+ * Returns a {@link ZipEntry} instance from its full filename
1724
+ *
1725
+ * @param fullname The full filename.
1726
+ * @returns The {@link ZipEntry} instance.
1727
+ */
1728
+ find(fullname: string): ZipEntry | undefined;
1729
+ /**
1730
+ * Returns a {@link ZipEntry} instance from the value of {@link ZipEntry#id}
1731
+ *
1732
+ * @param id The id of the {@link ZipEntry} instance.
1733
+ * @returns The {@link ZipEntry} instance.
1734
+ */
1735
+ getById(id: number): ZipEntry | undefined;
1564
1736
  }
1565
1737
 
1566
1738
  /**
1567
1739
  * The Filesystem API.
1568
1740
  */
1569
1741
  export const fs: {
1570
- /**
1571
- * The Filesystem constructor.
1572
- *
1573
- * @defaultValue {@link FS}
1574
- */
1575
- FS: typeof FS
1576
- /**
1577
- * The {@link ZipDirectoryEntry} constructor.
1578
- *
1579
- * @defaultValue {@link ZipDirectoryEntry}
1580
- */
1581
- ZipDirectoryEntry: typeof ZipDirectoryEntry
1582
- /**
1583
- * The {@link ZipFileEntry} constructor.
1584
- *
1585
- * @defaultValue {@link ZipFileEntry}
1586
- */
1587
- ZipFileEntry: typeof ZipFileEntry
1588
- }
1742
+ /**
1743
+ * The Filesystem constructor.
1744
+ *
1745
+ * @defaultValue {@link FS}
1746
+ */
1747
+ FS: typeof FS;
1748
+ /**
1749
+ * The {@link ZipDirectoryEntry} constructor.
1750
+ *
1751
+ * @defaultValue {@link ZipDirectoryEntry}
1752
+ */
1753
+ ZipDirectoryEntry: typeof ZipDirectoryEntry;
1754
+ /**
1755
+ * The {@link ZipFileEntry} constructor.
1756
+ *
1757
+ * @defaultValue {@link ZipFileEntry}
1758
+ */
1759
+ ZipFileEntry: typeof ZipFileEntry;
1760
+ };
1589
1761
 
1590
1762
  // The error messages.
1591
- export const ERR_HTTP_RANGE: string
1592
- export const ERR_BAD_FORMAT: string
1593
- export const ERR_EOCDR_NOT_FOUND: string
1594
- export const ERR_EOCDR_ZIP64_NOT_FOUND: string
1595
- export const ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: string
1596
- export const ERR_CENTRAL_DIRECTORY_NOT_FOUND: string
1597
- export const ERR_LOCAL_FILE_HEADER_NOT_FOUND: string
1598
- export const ERR_EXTRAFIELD_ZIP64_NOT_FOUND: string
1599
- export const ERR_ENCRYPTED: string
1600
- export const ERR_UNSUPPORTED_ENCRYPTION: string
1601
- export const ERR_UNSUPPORTED_COMPRESSION: string
1602
- export const ERR_INVALID_SIGNATURE: string
1603
- export const ERR_INVALID_PASSWORD: string
1604
- export const ERR_DUPLICATED_NAME: string
1605
- export const ERR_INVALID_COMMENT: string
1606
- export const ERR_INVALID_ENTRY_NAME: string
1607
- export const ERR_INVALID_ENTRY_COMMENT: string
1608
- export const ERR_INVALID_VERSION: string
1609
- export const ERR_INVALID_EXTRAFIELD_TYPE: string
1610
- export const ERR_INVALID_EXTRAFIELD_DATA: string
1611
- export const ERR_INVALID_ENCRYPTION_STRENGTH: string
1612
- export const ERR_UNSUPPORTED_FORMAT: string
1613
- export const ERR_SPLIT_ZIP_FILE: string
1614
- export const ERR_ITERATOR_COMPLETED_TOO_SOON: string
1763
+ export const ERR_HTTP_RANGE: string;
1764
+ export const ERR_BAD_FORMAT: string;
1765
+ export const ERR_EOCDR_NOT_FOUND: string;
1766
+ export const ERR_EOCDR_ZIP64_NOT_FOUND: string;
1767
+ export const ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: string;
1768
+ export const ERR_CENTRAL_DIRECTORY_NOT_FOUND: string;
1769
+ export const ERR_LOCAL_FILE_HEADER_NOT_FOUND: string;
1770
+ export const ERR_EXTRAFIELD_ZIP64_NOT_FOUND: string;
1771
+ export const ERR_ENCRYPTED: string;
1772
+ export const ERR_UNSUPPORTED_ENCRYPTION: string;
1773
+ export const ERR_UNSUPPORTED_COMPRESSION: string;
1774
+ export const ERR_INVALID_SIGNATURE: string;
1775
+ export const ERR_INVALID_PASSWORD: string;
1776
+ export const ERR_DUPLICATED_NAME: string;
1777
+ export const ERR_INVALID_COMMENT: string;
1778
+ export const ERR_INVALID_ENTRY_NAME: string;
1779
+ export const ERR_INVALID_ENTRY_COMMENT: string;
1780
+ export const ERR_INVALID_VERSION: string;
1781
+ export const ERR_INVALID_EXTRAFIELD_TYPE: string;
1782
+ export const ERR_INVALID_EXTRAFIELD_DATA: string;
1783
+ export const ERR_INVALID_ENCRYPTION_STRENGTH: string;
1784
+ export const ERR_UNSUPPORTED_FORMAT: string;
1785
+ export const ERR_SPLIT_ZIP_FILE: string;
1786
+ export const ERR_ITERATOR_COMPLETED_TOO_SOON: string;