@zip.js/zip.js 2.8.52 → 2.8.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/deno.json +2 -1
- package/dist/zip-core-external.js +839 -528
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +847 -527
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +880 -557
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +829 -538
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +880 -557
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +895 -558
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +894 -557
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +849 -529
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +849 -529
- package/dist/zip-native.min.js +1 -1
- package/dist/zip-web-worker-native.js +1 -1
- package/dist/zip-web-worker.js +1 -1
- package/dist/zip.js +848 -528
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +2 -1
- package/index-native.cjs +895 -558
- package/index-native.min.js +1 -1
- package/index.cjs +894 -557
- package/index.d.cts +672 -78
- package/index.d.ts +672 -78
- package/index.min.js +1 -1
- package/lib/core/codec-worker-web.js +13 -4
- package/lib/core/configuration.js +62 -21
- package/lib/core/constants.js +16 -1
- package/lib/core/io.js +44 -29
- package/lib/core/options.js +46 -2
- package/lib/core/streams/aes-crypto-stream.js +12 -12
- package/lib/core/util/decode-text.js +11 -2
- package/lib/core/web-worker-base.js +3 -2
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-entry.js +8 -0
- package/lib/core/zip-fs.js +38 -27
- package/lib/core/zip-reader.js +149 -60
- package/lib/core/zip-writer.js +329 -189
- package/lib/zip-core-base.js +6 -1
- package/lib/zip-core-reader.js +1 -0
- package/lib/zip-core-writer.js +5 -0
- package/package.json +11 -3
package/index.d.cts
CHANGED
|
@@ -190,6 +190,32 @@ declare class TransformStreamLike {
|
|
|
190
190
|
writable: WritableStream;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Represents a generic class compressing data, e.g. the native `CompressionStream` class.
|
|
195
|
+
*/
|
|
196
|
+
declare class CompressionStreamLike extends TransformStreamLike {
|
|
197
|
+
/**
|
|
198
|
+
* Creates the stream
|
|
199
|
+
*
|
|
200
|
+
* @param format The compression format.
|
|
201
|
+
* @param options The options.
|
|
202
|
+
*/
|
|
203
|
+
constructor(format: string, options?: CompressionStreamOptions);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Represents a generic class decompressing data, e.g. the native `DecompressionStream` class.
|
|
208
|
+
*/
|
|
209
|
+
declare class DecompressionStreamLike extends TransformStreamLike {
|
|
210
|
+
/**
|
|
211
|
+
* Creates the stream
|
|
212
|
+
*
|
|
213
|
+
* @param format The decompression format.
|
|
214
|
+
* @param options The options.
|
|
215
|
+
*/
|
|
216
|
+
constructor(format: string, options?: DecompressionStreamOptions);
|
|
217
|
+
}
|
|
218
|
+
|
|
193
219
|
/**
|
|
194
220
|
* Configures zip.js
|
|
195
221
|
*
|
|
@@ -237,27 +263,20 @@ export interface CodecDefinition {
|
|
|
237
263
|
format: string;
|
|
238
264
|
/**
|
|
239
265
|
* The URL of a module exporting the `CompressionStream` and/or `DecompressionStream` classes of
|
|
240
|
-
* the codec. Relative URLs are resolved against
|
|
241
|
-
* (e.g. via `import.meta.resolve()`) is recommended.
|
|
266
|
+
* the codec. Relative URLs are resolved against {@link Configuration#baseURI}; passing an absolute
|
|
267
|
+
* URL (e.g. via `import.meta.resolve()`) is recommended.
|
|
242
268
|
*/
|
|
243
269
|
codecURI?: string;
|
|
244
270
|
/**
|
|
245
|
-
* The stream implementation used to compress data, constructed with
|
|
246
|
-
*
|
|
271
|
+
* The stream implementation used to compress data, constructed with `(format, options)`, see
|
|
272
|
+
* {@link CompressionStreamOptions}.
|
|
247
273
|
*/
|
|
248
|
-
CompressionStream?: typeof
|
|
274
|
+
CompressionStream?: typeof CompressionStreamLike;
|
|
249
275
|
/**
|
|
250
|
-
* The stream implementation used to decompress data, constructed with
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* `compressionMethod` allows codecs registered for multiple methods with the same format to
|
|
254
|
-
* distinguish them (e.g. Reduce, methods 2 to 5). `rawBitFlag` exposes the general purpose bit
|
|
255
|
-
* flag of the entry, which some methods need to decode the data (e.g. the dictionary size and
|
|
256
|
-
* number of trees of Implode, or the end-of-stream marker presence of LZMA). `uncompressedSize`
|
|
257
|
-
* allows size-driven decoders (e.g. Shrink, Reduce, Implode, LZMA without end-of-stream marker)
|
|
258
|
-
* to stop at the exact output size instead of decoding trailing padding bits.
|
|
276
|
+
* The stream implementation used to decompress data, constructed with `(format, options)`, see
|
|
277
|
+
* {@link DecompressionStreamOptions}.
|
|
259
278
|
*/
|
|
260
|
-
DecompressionStream?: typeof
|
|
279
|
+
DecompressionStream?: typeof DecompressionStreamLike;
|
|
261
280
|
/**
|
|
262
281
|
* The minimum "version needed to extract" value written in zip entry headers (e.g. `63` for
|
|
263
282
|
* Zstandard).
|
|
@@ -265,6 +284,72 @@ export interface CodecDefinition {
|
|
|
265
284
|
versionNeeded?: number;
|
|
266
285
|
}
|
|
267
286
|
|
|
287
|
+
/**
|
|
288
|
+
* Represents the options passed as the second argument to the constructor of the classes
|
|
289
|
+
* compressing data, i.e. {@link CodecDefinition#CompressionStream},
|
|
290
|
+
* {@link Configuration#CompressionStream} and {@link Configuration#CompressionStreamFallback}.
|
|
291
|
+
*/
|
|
292
|
+
export interface CompressionStreamOptions {
|
|
293
|
+
/**
|
|
294
|
+
* The compression level, see {@link ZipWriterConstructorOptions#level}.
|
|
295
|
+
*/
|
|
296
|
+
level?: number;
|
|
297
|
+
/**
|
|
298
|
+
* The size of the chunks in bytes, see {@link Configuration#chunkSize}.
|
|
299
|
+
*/
|
|
300
|
+
chunkSize?: number;
|
|
301
|
+
/**
|
|
302
|
+
* The compression method of the entry. It allows codecs registered for several methods sharing
|
|
303
|
+
* the same format to distinguish them (e.g. Reduce, methods 2 to 5).
|
|
304
|
+
*
|
|
305
|
+
* It is only set for the codecs registered with {@link registerCodec}.
|
|
306
|
+
*/
|
|
307
|
+
compressionMethod?: number;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Represents the options passed as the second argument to the constructor of the classes
|
|
312
|
+
* decompressing data, i.e. {@link CodecDefinition#DecompressionStream},
|
|
313
|
+
* {@link Configuration#DecompressionStream} and {@link Configuration#DecompressionStreamFallback}.
|
|
314
|
+
*/
|
|
315
|
+
export interface DecompressionStreamOptions {
|
|
316
|
+
/**
|
|
317
|
+
* The size of the chunks in bytes, see {@link Configuration#chunkSize}.
|
|
318
|
+
*/
|
|
319
|
+
chunkSize?: number;
|
|
320
|
+
/**
|
|
321
|
+
* `true` when the data is compressed with the Deflate64 method, the format passed as the first
|
|
322
|
+
* argument being `"deflate64-raw"` instead of `"deflate-raw"`.
|
|
323
|
+
*
|
|
324
|
+
* It is only set for the classes decompressing the deflate methods, i.e.
|
|
325
|
+
* {@link Configuration#DecompressionStream} and {@link Configuration#DecompressionStreamFallback}.
|
|
326
|
+
*/
|
|
327
|
+
deflate64?: boolean;
|
|
328
|
+
/**
|
|
329
|
+
* The compression method of the entry. It allows codecs registered for several methods sharing
|
|
330
|
+
* the same format to distinguish them (e.g. Reduce, methods 2 to 5).
|
|
331
|
+
*
|
|
332
|
+
* It is only set for the codecs registered with {@link registerCodec}.
|
|
333
|
+
*/
|
|
334
|
+
compressionMethod?: number;
|
|
335
|
+
/**
|
|
336
|
+
* The general purpose bit flag of the entry, which some methods need to decode the data (e.g. the
|
|
337
|
+
* dictionary size and the number of trees of Implode, or the presence of the end-of-stream marker
|
|
338
|
+
* of LZMA).
|
|
339
|
+
*
|
|
340
|
+
* It is only set for the codecs registered with {@link registerCodec}.
|
|
341
|
+
*/
|
|
342
|
+
rawBitFlag?: number;
|
|
343
|
+
/**
|
|
344
|
+
* The uncompressed size of the entry declared in its header, undefined when the size is unknown.
|
|
345
|
+
* It allows size-driven decoders (e.g. Shrink, Reduce, Implode, LZMA without end-of-stream
|
|
346
|
+
* marker) to stop at the exact output size instead of decoding trailing padding bits.
|
|
347
|
+
*
|
|
348
|
+
* It is only set for the codecs registered with {@link registerCodec}.
|
|
349
|
+
*/
|
|
350
|
+
uncompressedSize?: number;
|
|
351
|
+
}
|
|
352
|
+
|
|
268
353
|
/**
|
|
269
354
|
* Represents the configuration passed to {@link configure}.
|
|
270
355
|
*/
|
|
@@ -272,7 +357,9 @@ export interface Configuration extends WorkerConfiguration {
|
|
|
272
357
|
/**
|
|
273
358
|
* The maximum number of web workers used to compress/decompress data simultaneously.
|
|
274
359
|
*
|
|
275
|
-
* @
|
|
360
|
+
* It must be an integer greater than 0, see {@link ERR_INVALID_MAX_WORKERS}.
|
|
361
|
+
*
|
|
362
|
+
* @defaultValue `navigator.hardwareConcurrency`, or 2 when the environment does not provide it
|
|
276
363
|
*/
|
|
277
364
|
maxWorkers?: number;
|
|
278
365
|
/**
|
|
@@ -297,6 +384,13 @@ export interface Configuration extends WorkerConfiguration {
|
|
|
297
384
|
* @defaultValue 5000
|
|
298
385
|
*/
|
|
299
386
|
workerStartupTimeout?: number;
|
|
387
|
+
/**
|
|
388
|
+
* The base URL against which the relative URIs are resolved, i.e. {@link Configuration#workerURI},
|
|
389
|
+
* {@link Configuration#wasmURI} and {@link CodecDefinition#codecURI}.
|
|
390
|
+
*
|
|
391
|
+
* @defaultValue the URL of the module of zip.js
|
|
392
|
+
*/
|
|
393
|
+
baseURI?: string;
|
|
300
394
|
/**
|
|
301
395
|
* The URI of the web worker.
|
|
302
396
|
*
|
|
@@ -311,7 +405,10 @@ export interface Configuration extends WorkerConfiguration {
|
|
|
311
405
|
* });
|
|
312
406
|
* ```
|
|
313
407
|
*
|
|
314
|
-
*
|
|
408
|
+
* The worker is created as a module worker, unless the URI is a Data URI or a Blob URI, in which case it is created as a classic
|
|
409
|
+
* worker. See {@link Configuration#createWorker} for an example of classic worker script installing a polyfill of the Streams API.
|
|
410
|
+
*
|
|
411
|
+
* @defaultValue "./core/web-worker-wasm.js", or "./core/web-worker-native.js" for the builds using the native implementations
|
|
315
412
|
*/
|
|
316
413
|
workerURI?: string;
|
|
317
414
|
/**
|
|
@@ -325,6 +422,21 @@ export interface Configuration extends WorkerConfiguration {
|
|
|
325
422
|
* createWorker: () => new Worker(new URL("./zip-worker.js", import.meta.url), { type: "module" })
|
|
326
423
|
* });
|
|
327
424
|
* ```
|
|
425
|
+
*
|
|
426
|
+
* It is also the way to run the web workers on engines where `TransformStream` is missing from the scope of the workers, e.g. Firefox
|
|
427
|
+
* before version 102. There, the worker script of zip.js throws when it is evaluated and the data is silently compressed/decompressed
|
|
428
|
+
* in the main scope instead. A polyfill imported by the page does not help, because the worker reads the globals of the Streams API
|
|
429
|
+
* from its own scope, so it has to be installed by the worker itself before the worker script of zip.js runs. These engines predate
|
|
430
|
+
* the support of module workers, hence the classic worker script below:
|
|
431
|
+
* ```
|
|
432
|
+
* // zip-worker-with-polyfill.js
|
|
433
|
+
* importScripts("./web-streams-polyfill.js", "./zip-web-worker.js");
|
|
434
|
+
* ```
|
|
435
|
+
* ```
|
|
436
|
+
* configure({
|
|
437
|
+
* createWorker: () => new Worker("./zip-worker-with-polyfill.js")
|
|
438
|
+
* });
|
|
439
|
+
* ```
|
|
328
440
|
*/
|
|
329
441
|
createWorker?: () => Worker;
|
|
330
442
|
/**
|
|
@@ -345,41 +457,44 @@ export interface Configuration extends WorkerConfiguration {
|
|
|
345
457
|
/**
|
|
346
458
|
* The size of the chunks in bytes during data compression/decompression.
|
|
347
459
|
*
|
|
460
|
+
* Values lower than 64 are raised to 64, and a value that is not an integer greater than 0 is replaced with the default
|
|
461
|
+
* value.
|
|
462
|
+
*
|
|
348
463
|
* @defaultValue 65536
|
|
349
464
|
*/
|
|
350
465
|
chunkSize?: number;
|
|
351
466
|
/**
|
|
352
467
|
* The stream implementation used to compress data when `useCompressionStream` is set to `true`.
|
|
353
468
|
*
|
|
354
|
-
* @defaultValue
|
|
469
|
+
* @defaultValue the global `CompressionStream`, or `false` when the environment does not provide it
|
|
355
470
|
*/
|
|
356
|
-
CompressionStream?: typeof
|
|
471
|
+
CompressionStream?: typeof CompressionStreamLike;
|
|
357
472
|
/**
|
|
358
473
|
* The stream implementation used to decompress data when `useCompressionStream` is set to `true`.
|
|
359
474
|
*
|
|
360
|
-
* @defaultValue
|
|
475
|
+
* @defaultValue the global `DecompressionStream`, or `false` when the environment does not provide it
|
|
361
476
|
*/
|
|
362
|
-
DecompressionStream?: typeof
|
|
477
|
+
DecompressionStream?: typeof DecompressionStreamLike;
|
|
363
478
|
/**
|
|
364
479
|
* The stream implementation used to compress data when `useCompressionStream` is set to `false`.
|
|
365
480
|
*
|
|
366
|
-
* @defaultValue
|
|
481
|
+
* @defaultValue the implementation embedded in the entry point that was imported, e.g. the WebAssembly one
|
|
367
482
|
*/
|
|
368
|
-
CompressionStreamFallback?: typeof
|
|
483
|
+
CompressionStreamFallback?: typeof CompressionStreamLike;
|
|
369
484
|
/**
|
|
370
485
|
* The stream implementation used to decompress data when `useCompressionStream` is set to `false`.
|
|
371
486
|
*
|
|
372
|
-
* @defaultValue
|
|
487
|
+
* @defaultValue the implementation embedded in the entry point that was imported, e.g. the WebAssembly one
|
|
373
488
|
*/
|
|
374
|
-
DecompressionStreamFallback?: typeof
|
|
489
|
+
DecompressionStreamFallback?: typeof DecompressionStreamLike;
|
|
375
490
|
/**
|
|
376
491
|
* @deprecated Use {@link Configuration#CompressionStreamFallback} instead.
|
|
377
492
|
*/
|
|
378
|
-
CompressionStreamZlib?: typeof
|
|
493
|
+
CompressionStreamZlib?: typeof CompressionStreamLike;
|
|
379
494
|
/**
|
|
380
495
|
* @deprecated Use {@link Configuration#DecompressionStreamFallback} instead.
|
|
381
496
|
*/
|
|
382
|
-
DecompressionStreamZlib?: typeof
|
|
497
|
+
DecompressionStreamZlib?: typeof DecompressionStreamLike;
|
|
383
498
|
}
|
|
384
499
|
|
|
385
500
|
/**
|
|
@@ -471,22 +586,17 @@ export function initWorker(options?: {
|
|
|
471
586
|
/**
|
|
472
587
|
* The stream implementation used to compress data when `useCompressionStream` is set to `false` or when `CompressionStream` is unsupported.
|
|
473
588
|
*/
|
|
474
|
-
CompressionStreamFallback?: typeof
|
|
589
|
+
CompressionStreamFallback?: typeof CompressionStreamLike;
|
|
475
590
|
/**
|
|
476
591
|
* The stream implementation used to decompress data when `useCompressionStream` is set to `false` or when `DecompressionStream` is unsupported.
|
|
477
592
|
*/
|
|
478
|
-
DecompressionStreamFallback?: typeof
|
|
593
|
+
DecompressionStreamFallback?: typeof DecompressionStreamLike;
|
|
479
594
|
/**
|
|
480
595
|
* The function called before resolving the stream implementations, e.g. to load a WebAssembly module.
|
|
481
596
|
*/
|
|
482
597
|
init?(config: Configuration): Promise<unknown> | unknown;
|
|
483
598
|
}): void;
|
|
484
599
|
|
|
485
|
-
/**
|
|
486
|
-
* Represents a class implementing `CompressionStream` or `DecompressionStream` interfaces.
|
|
487
|
-
*/
|
|
488
|
-
declare class CodecStream extends TransformStream {}
|
|
489
|
-
|
|
490
600
|
/**
|
|
491
601
|
* Returns the MIME type corresponding to a filename extension.
|
|
492
602
|
*
|
|
@@ -699,6 +809,8 @@ export interface CreateReadableOptions {
|
|
|
699
809
|
/**
|
|
700
810
|
* The size in bytes of the chunks emitted by the default implementation (the `chunkSize` value
|
|
701
811
|
* of the global configuration by default).
|
|
812
|
+
*
|
|
813
|
+
* It is normalized like {@link Configuration#chunkSize}.
|
|
702
814
|
*/
|
|
703
815
|
chunkSize?: number;
|
|
704
816
|
}
|
|
@@ -724,7 +836,11 @@ export class Data64URIReader extends Reader<string> {}
|
|
|
724
836
|
export class Uint8ArrayReader extends Reader<Uint8Array> {}
|
|
725
837
|
|
|
726
838
|
/**
|
|
727
|
-
* Represents a {@link Reader} instance used to read data provided as an array of {@link
|
|
839
|
+
* Represents a {@link Reader} instance used to read data provided as an array of {@link Reader} instances,
|
|
840
|
+
* {@link ReadableReader} instances or `ReadableStream` instances (e.g. split zip files).
|
|
841
|
+
*
|
|
842
|
+
* @remarks Elements that only provide a `ReadableStream` are buffered when the reader is initialized, since
|
|
843
|
+
* mapping a global offset onto a disk requires the size of every disk.
|
|
728
844
|
*/
|
|
729
845
|
export class SplitDataReader extends Reader<
|
|
730
846
|
Reader<unknown>[] | ReadableReader[] | ReadableStream[]
|
|
@@ -739,6 +855,10 @@ type URLString = string;
|
|
|
739
855
|
* Represents a {@link Reader} instance used to fetch data from a URL.
|
|
740
856
|
*/
|
|
741
857
|
export class HttpReader extends Reader<URLString> {
|
|
858
|
+
/**
|
|
859
|
+
* The URL of the data, as passed to the constructor.
|
|
860
|
+
*/
|
|
861
|
+
url: URLString | URL;
|
|
742
862
|
/**
|
|
743
863
|
* Creates the {@link HttpReader} instance
|
|
744
864
|
*
|
|
@@ -783,7 +903,11 @@ export interface HttpOptions extends HttpRangeOptions {
|
|
|
783
903
|
* `true` to prevent using `HEAD` HTTP request in order the get the size of the content.
|
|
784
904
|
* `false` to explicitly use `HEAD`, this is useful in case of CORS where `Access-Control-Expose-Headers: Content-Range` is not returned by the server.
|
|
785
905
|
*
|
|
786
|
-
* @
|
|
906
|
+
* Leaving it unset is not the same as setting it to `false` when {@link HttpOptions#useRangeHeader} or
|
|
907
|
+
* {@link HttpOptions#forceRangeRequests} is set: the size is then read from a ranged `GET` request instead, and
|
|
908
|
+
* only an explicit `false` restores the `HEAD` request.
|
|
909
|
+
*
|
|
910
|
+
* @defaultValue false, and `true` when {@link HttpOptions#useRangeHeader} or {@link HttpOptions#forceRangeRequests} is set
|
|
787
911
|
*/
|
|
788
912
|
preventHeadRequest?: boolean;
|
|
789
913
|
/**
|
|
@@ -851,6 +975,12 @@ export interface WritableWriter {
|
|
|
851
975
|
* The `WritableStream` instance.
|
|
852
976
|
*/
|
|
853
977
|
writable: WritableStream;
|
|
978
|
+
/**
|
|
979
|
+
* The number of bytes written into the instance. It is set to 0 before the first write and
|
|
980
|
+
* updated as the data is written, so a writer needing the value (e.g. to compute the offset of a
|
|
981
|
+
* disk) can read it.
|
|
982
|
+
*/
|
|
983
|
+
size?: number;
|
|
854
984
|
/**
|
|
855
985
|
* The maximum size of split data when creating a {@link ZipWriter} instance or when calling {@link FileEntry#getData} with a generator of {@link WritableWriter} instances.
|
|
856
986
|
*/
|
|
@@ -887,6 +1017,10 @@ export class Writer<Type> implements Initializable, WritableWriter {
|
|
|
887
1017
|
* The `WritableStream` instance.
|
|
888
1018
|
*/
|
|
889
1019
|
writable: WritableStream;
|
|
1020
|
+
/**
|
|
1021
|
+
* The number of bytes written into the instance.
|
|
1022
|
+
*/
|
|
1023
|
+
size: number;
|
|
890
1024
|
/**
|
|
891
1025
|
* Initializes the instance asynchronously
|
|
892
1026
|
*
|
|
@@ -912,13 +1046,35 @@ export class Writer<Type> implements Initializable, WritableWriter {
|
|
|
912
1046
|
/**
|
|
913
1047
|
* Represents a {@link Writer} instance used to retrieve the written data as a `string`.
|
|
914
1048
|
*/
|
|
915
|
-
export class TextWriter
|
|
1049
|
+
export class TextWriter implements Initializable, WritableWriter {
|
|
1050
|
+
/**
|
|
1051
|
+
* The `WritableStream` instance.
|
|
1052
|
+
*/
|
|
1053
|
+
writable: WritableStream;
|
|
1054
|
+
/**
|
|
1055
|
+
* The number of bytes written into the instance.
|
|
1056
|
+
*/
|
|
1057
|
+
size: number;
|
|
1058
|
+
/**
|
|
1059
|
+
* The encoding of the text returned by {@link TextWriter#getData}.
|
|
1060
|
+
*/
|
|
1061
|
+
encoding?: string;
|
|
1062
|
+
/**
|
|
1063
|
+
* Initializes the instance asynchronously
|
|
1064
|
+
*/
|
|
1065
|
+
init(): Promise<void>;
|
|
916
1066
|
/**
|
|
917
1067
|
* Creates the {@link TextWriter} instance
|
|
918
1068
|
*
|
|
919
1069
|
* @param encoding The encoding of the text.
|
|
920
1070
|
*/
|
|
921
1071
|
constructor(encoding?: string);
|
|
1072
|
+
/**
|
|
1073
|
+
* Retrieves all the written data
|
|
1074
|
+
*
|
|
1075
|
+
* @returns A promise resolving to the written data.
|
|
1076
|
+
*/
|
|
1077
|
+
getData(): Promise<string>;
|
|
922
1078
|
}
|
|
923
1079
|
|
|
924
1080
|
/**
|
|
@@ -929,6 +1085,15 @@ export class BlobWriter implements Initializable, WritableWriter {
|
|
|
929
1085
|
* The `WritableStream` instance.
|
|
930
1086
|
*/
|
|
931
1087
|
writable: WritableStream;
|
|
1088
|
+
/**
|
|
1089
|
+
* The number of bytes written into the instance.
|
|
1090
|
+
*/
|
|
1091
|
+
size: number;
|
|
1092
|
+
/**
|
|
1093
|
+
* The MIME type of the content, i.e. the type of the `Blob` instance returned by
|
|
1094
|
+
* {@link BlobWriter#getData}.
|
|
1095
|
+
*/
|
|
1096
|
+
contentType?: string;
|
|
932
1097
|
/**
|
|
933
1098
|
* Initializes the instance asynchronously
|
|
934
1099
|
*/
|
|
@@ -951,6 +1116,11 @@ export class BlobWriter implements Initializable, WritableWriter {
|
|
|
951
1116
|
* Represents a {@link Writer} instance used to retrieve the written data as a Data URI `string` encoded in Base64.
|
|
952
1117
|
*/
|
|
953
1118
|
export class Data64URIWriter extends Writer<string> {
|
|
1119
|
+
/**
|
|
1120
|
+
* The MIME type of the content, i.e. the type declared by the Data URI returned by
|
|
1121
|
+
* {@link Data64URIWriter#getData}.
|
|
1122
|
+
*/
|
|
1123
|
+
contentType?: string;
|
|
954
1124
|
/**
|
|
955
1125
|
* Creates the {@link Data64URIWriter} instance
|
|
956
1126
|
*
|
|
@@ -967,6 +1137,10 @@ export class SplitDataWriter implements Initializable, WritableWriter {
|
|
|
967
1137
|
* The `WritableStream` instance.
|
|
968
1138
|
*/
|
|
969
1139
|
writable: WritableStream;
|
|
1140
|
+
/**
|
|
1141
|
+
* The number of bytes written into the instance.
|
|
1142
|
+
*/
|
|
1143
|
+
size: number;
|
|
970
1144
|
/**
|
|
971
1145
|
* The number of the disk being written.
|
|
972
1146
|
*/
|
|
@@ -1111,6 +1285,13 @@ export class ZipReader<Type> {
|
|
|
1111
1285
|
);
|
|
1112
1286
|
/**
|
|
1113
1287
|
* The global comment of the zip file.
|
|
1288
|
+
*
|
|
1289
|
+
* @remarks
|
|
1290
|
+
* Unlike {@link EntryMetaData#comment}, it is exposed as raw bytes because the zip format defines no
|
|
1291
|
+
* way to record its encoding: section 4.4.26 of the zip specification says nothing about it, and the
|
|
1292
|
+
* end of central directory record has neither a general purpose bit flag nor an extra field, so the
|
|
1293
|
+
* language encoding flag (see Appendix D - Language Encoding (EFS)) cannot apply to it. Decode it with
|
|
1294
|
+
* the encoding agreed with the producer of the zip file.
|
|
1114
1295
|
*/
|
|
1115
1296
|
comment: Uint8Array;
|
|
1116
1297
|
/**
|
|
@@ -1221,6 +1402,12 @@ export interface GetEntriesOptions {
|
|
|
1221
1402
|
* the content of an entry, it also validates the local file header against the central directory record (see
|
|
1222
1403
|
* {@link ZipReaderOptions#checkAmbiguity}).
|
|
1223
1404
|
*
|
|
1405
|
+
* This is the boolean form of {@link GetEntriesOptions#strictness}: `true` means `"strict"` and `false` means
|
|
1406
|
+
* any value but `"strict"`. When both options are set, the value passed to {@link ZipReader#getEntries} takes
|
|
1407
|
+
* precedence over the value passed to the constructor of {@link ZipReader}, and `strictness` takes precedence
|
|
1408
|
+
* over `checkAmbiguity` when both are set at the same level. `false` downgrades an inherited `"strict"` value
|
|
1409
|
+
* to `"balanced"` and leaves an inherited `"tolerant"` value unchanged.
|
|
1410
|
+
*
|
|
1224
1411
|
* @defaultValue false
|
|
1225
1412
|
*/
|
|
1226
1413
|
checkAmbiguity?: boolean;
|
|
@@ -1362,9 +1549,18 @@ export interface DirectoryEncryptionInfo {
|
|
|
1362
1549
|
export interface ZipReaderOptions {
|
|
1363
1550
|
/**
|
|
1364
1551
|
* How tolerant the reader should be when the local file header of an entry disagrees with its central
|
|
1365
|
-
* directory record.
|
|
1366
|
-
*
|
|
1367
|
-
*
|
|
1552
|
+
* directory record. Any difference throws an {@link ERR_AMBIGUOUS_ARCHIVE} error.
|
|
1553
|
+
*
|
|
1554
|
+
* - `"strict"`: compare the filename, the general purpose bit flag, the compression method, the CRC-32
|
|
1555
|
+
* checksum and the sizes.
|
|
1556
|
+
* - `"balanced"`: compare everything except the filename.
|
|
1557
|
+
* - `"tolerant"`: compare nothing and trust the central directory record.
|
|
1558
|
+
*
|
|
1559
|
+
* Every field except the filename is read from the local file header anyway, to locate the entry data, so
|
|
1560
|
+
* the comparison `"balanced"` performs reads no additional bytes. Comparing the filename reads the filename
|
|
1561
|
+
* bytes as well, which costs one extra read per entry whenever the local file header carries no extra field
|
|
1562
|
+
* — the common case in practice. Use {@link ZipReaderOptions#checkLocalDirectory} to request or suppress the
|
|
1563
|
+
* whole comparison explicitly.
|
|
1368
1564
|
*
|
|
1369
1565
|
* @defaultValue "balanced"
|
|
1370
1566
|
*/
|
|
@@ -1377,9 +1573,31 @@ export interface ZipReaderOptions {
|
|
|
1377
1573
|
* methods, CRC-32 checksums and sizes. The extra fields are not compared because the zip specification allows
|
|
1378
1574
|
* them to differ.
|
|
1379
1575
|
*
|
|
1576
|
+
* This is the boolean form of {@link ZipReaderOptions#strictness}: `true` means `"strict"` and `false` means
|
|
1577
|
+
* any value but `"strict"`. When both options are set, the value passed to {@link FileEntry#getData} takes
|
|
1578
|
+
* precedence over the value passed to the constructor of {@link ZipReader}, and `strictness` takes precedence
|
|
1579
|
+
* over `checkAmbiguity` when both are set at the same level. `false` downgrades an inherited `"strict"` value
|
|
1580
|
+
* to `"balanced"` and leaves an inherited `"tolerant"` value unchanged.
|
|
1581
|
+
*
|
|
1380
1582
|
* @defaultValue false
|
|
1381
1583
|
*/
|
|
1382
1584
|
checkAmbiguity?: boolean;
|
|
1585
|
+
/**
|
|
1586
|
+
* `true` to validate the local file header of the entry against its central directory record when calling
|
|
1587
|
+
* {@link FileEntry#getData}, `false` to skip that validation. This is the entry-level half of
|
|
1588
|
+
* {@link ZipReaderOptions#checkAmbiguity}, exposed on its own so it can be enabled without the archive-level
|
|
1589
|
+
* checks and disabled without giving up the rest of {@link ZipReaderOptions#strictness}. It is the only way to
|
|
1590
|
+
* validate the local file headers of a self-extracting archive, since
|
|
1591
|
+
* {@link GetEntriesOptions#checkAmbiguity} rejects prepended data outright.
|
|
1592
|
+
*
|
|
1593
|
+
* `true` compares the filename as well, like {@link ZipReaderOptions#strictness} set to `"strict"`; `false`
|
|
1594
|
+
* compares nothing, like `"tolerant"`. An explicit value takes precedence over the strictness default at
|
|
1595
|
+
* every level.
|
|
1596
|
+
*
|
|
1597
|
+
* @defaultValue `true` when {@link ZipReaderOptions#strictness} is `"strict"` or `"balanced"`, `false` when
|
|
1598
|
+
* it is `"tolerant"`.
|
|
1599
|
+
*/
|
|
1600
|
+
checkLocalDirectory?: boolean;
|
|
1383
1601
|
/**
|
|
1384
1602
|
* `true` to check only if the password is valid.
|
|
1385
1603
|
*
|
|
@@ -1503,9 +1721,14 @@ export interface EntryExtraFieldAES extends EntryExtraField {
|
|
|
1503
1721
|
*/
|
|
1504
1722
|
vendorId?: number;
|
|
1505
1723
|
/**
|
|
1506
|
-
* The compression method stored in the
|
|
1724
|
+
* The compression method stored in the header of the entry, i.e. `99` for a WinZip AES entry.
|
|
1507
1725
|
*/
|
|
1508
1726
|
originalCompressionMethod?: number;
|
|
1727
|
+
/**
|
|
1728
|
+
* The real compression method of the entry, stored in the AES extra field because the header carries `99`
|
|
1729
|
+
* instead. This is the value reported by {@link EntryMetaData#compressionMethod}.
|
|
1730
|
+
*/
|
|
1731
|
+
compressionMethod?: number;
|
|
1509
1732
|
}
|
|
1510
1733
|
/**
|
|
1511
1734
|
* Represents a Unix extra field record storing timestamps: the Info-ZIP Unix type 1 extra field (0x5855),
|
|
@@ -1539,7 +1762,149 @@ export interface EntryExtraFieldUnicode extends EntryExtraField {
|
|
|
1539
1762
|
* `true` if the extra field is consistent with the entry metadata.
|
|
1540
1763
|
*/
|
|
1541
1764
|
valid?: boolean;
|
|
1765
|
+
/**
|
|
1766
|
+
* The version of the extra field.
|
|
1767
|
+
*/
|
|
1768
|
+
version?: number;
|
|
1769
|
+
/**
|
|
1770
|
+
* The filename stored in the extra field, when it is a Unicode path extra field (0x7075).
|
|
1771
|
+
*/
|
|
1772
|
+
filename?: string;
|
|
1773
|
+
/**
|
|
1774
|
+
* The comment stored in the extra field, when it is a Unicode comment extra field (0x6375).
|
|
1775
|
+
*/
|
|
1776
|
+
comment?: string;
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Represents the Zip64 extra field record of an entry. Each property is only defined when the matching field
|
|
1780
|
+
* of the header was set to its maximum value, i.e. when the real value had to be stored in the extra field.
|
|
1781
|
+
*/
|
|
1782
|
+
export interface EntryExtraFieldZip64 extends EntryExtraField {
|
|
1783
|
+
/**
|
|
1784
|
+
* The uncompressed size of the entry.
|
|
1785
|
+
*/
|
|
1786
|
+
uncompressedSize?: number;
|
|
1787
|
+
/**
|
|
1788
|
+
* The compressed size of the entry.
|
|
1789
|
+
*/
|
|
1790
|
+
compressedSize?: number;
|
|
1791
|
+
/**
|
|
1792
|
+
* The offset of the local file header of the entry.
|
|
1793
|
+
*/
|
|
1794
|
+
offset?: number;
|
|
1795
|
+
/**
|
|
1796
|
+
* The number of the disk where the entry data starts.
|
|
1797
|
+
*/
|
|
1798
|
+
diskNumberStart?: number;
|
|
1542
1799
|
}
|
|
1800
|
+
/**
|
|
1801
|
+
* Represents the NTFS extra field record of an entry (0x000a), storing the dates as Windows `FILETIME` values.
|
|
1802
|
+
*/
|
|
1803
|
+
export interface EntryExtraFieldNTFS extends EntryExtraField {
|
|
1804
|
+
/**
|
|
1805
|
+
* The last modification date.
|
|
1806
|
+
*/
|
|
1807
|
+
lastModDate?: Date;
|
|
1808
|
+
/**
|
|
1809
|
+
* The last access date.
|
|
1810
|
+
*/
|
|
1811
|
+
lastAccessDate?: Date;
|
|
1812
|
+
/**
|
|
1813
|
+
* The creation date.
|
|
1814
|
+
*/
|
|
1815
|
+
creationDate?: Date;
|
|
1816
|
+
/**
|
|
1817
|
+
* The last modification date (raw), as a Windows `FILETIME` value.
|
|
1818
|
+
*/
|
|
1819
|
+
rawLastModDate?: bigint;
|
|
1820
|
+
/**
|
|
1821
|
+
* The last access date (raw), as a Windows `FILETIME` value.
|
|
1822
|
+
*/
|
|
1823
|
+
rawLastAccessDate?: bigint;
|
|
1824
|
+
/**
|
|
1825
|
+
* The creation date (raw), as a Windows `FILETIME` value.
|
|
1826
|
+
*/
|
|
1827
|
+
rawCreationDate?: bigint;
|
|
1828
|
+
}
|
|
1829
|
+
/**
|
|
1830
|
+
* Represents the extended timestamp extra field record of an entry (0x5455), storing the dates as 32-bit Unix
|
|
1831
|
+
* times. The central directory record only carries the last modification date, the local file header carries
|
|
1832
|
+
* the dates selected by the flags of the extra field.
|
|
1833
|
+
*/
|
|
1834
|
+
export interface EntryExtraFieldExtendedTimestamp extends EntryExtraField {
|
|
1835
|
+
/**
|
|
1836
|
+
* The last modification date.
|
|
1837
|
+
*/
|
|
1838
|
+
lastModDate?: Date;
|
|
1839
|
+
/**
|
|
1840
|
+
* The last access date.
|
|
1841
|
+
*/
|
|
1842
|
+
lastAccessDate?: Date;
|
|
1843
|
+
/**
|
|
1844
|
+
* The creation date.
|
|
1845
|
+
*/
|
|
1846
|
+
creationDate?: Date;
|
|
1847
|
+
/**
|
|
1848
|
+
* The last modification date (raw), as a 32-bit Unix time.
|
|
1849
|
+
*/
|
|
1850
|
+
rawLastModDate?: number;
|
|
1851
|
+
/**
|
|
1852
|
+
* The last access date (raw), as a 32-bit Unix time.
|
|
1853
|
+
*/
|
|
1854
|
+
rawLastAccessDate?: number;
|
|
1855
|
+
/**
|
|
1856
|
+
* The creation date (raw), as a 32-bit Unix time.
|
|
1857
|
+
*/
|
|
1858
|
+
rawCreationDate?: number;
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Represents a Unix extra field record storing ownership: the Info-ZIP "new" Unix extra field (0x7875), read
|
|
1862
|
+
* into {@link EntryMetaData#extraFieldInfoZip}, or the Info-ZIP "old" Unix extra field (0x7855), read into
|
|
1863
|
+
* {@link EntryMetaData#extraFieldUnix}.
|
|
1864
|
+
*/
|
|
1865
|
+
export interface EntryExtraFieldUnix extends EntryExtraField {
|
|
1866
|
+
/**
|
|
1867
|
+
* The version of the extra field, only defined for the Info-ZIP "new" Unix extra field (0x7875).
|
|
1868
|
+
*/
|
|
1869
|
+
version?: number;
|
|
1870
|
+
/**
|
|
1871
|
+
* The Unix user id.
|
|
1872
|
+
*/
|
|
1873
|
+
uid?: number;
|
|
1874
|
+
/**
|
|
1875
|
+
* The Unix group id.
|
|
1876
|
+
*/
|
|
1877
|
+
gid?: number;
|
|
1878
|
+
}
|
|
1879
|
+
/**
|
|
1880
|
+
* Represents the data descriptor record written after the content of an entry, when
|
|
1881
|
+
* {@link EntryBitFlag#dataDescriptor} is set.
|
|
1882
|
+
*/
|
|
1883
|
+
export interface LocalDataDescriptor {
|
|
1884
|
+
/**
|
|
1885
|
+
* `true` if the record is preceded by its optional signature.
|
|
1886
|
+
*
|
|
1887
|
+
* The signature is not part of the original format, it is a later convention writers are free to follow. It is
|
|
1888
|
+
* reported as absent when the values following it disagree with the central directory, since the record is then
|
|
1889
|
+
* read as starting at the first byte.
|
|
1890
|
+
*/
|
|
1891
|
+
signature: boolean;
|
|
1892
|
+
/**
|
|
1893
|
+
* The CRC-32 checksum stored in the record, which is allowed to differ from {@link EntryMetaData#crc32}.
|
|
1894
|
+
*/
|
|
1895
|
+
crc32: number;
|
|
1896
|
+
/**
|
|
1897
|
+
* The compressed size stored in the record, which is allowed to differ from
|
|
1898
|
+
* {@link EntryMetaData#compressedSize}.
|
|
1899
|
+
*/
|
|
1900
|
+
compressedSize: number;
|
|
1901
|
+
/**
|
|
1902
|
+
* The uncompressed size stored in the record, which is allowed to differ from
|
|
1903
|
+
* {@link EntryMetaData#uncompressedSize}.
|
|
1904
|
+
*/
|
|
1905
|
+
uncompressedSize: number;
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1543
1908
|
/**
|
|
1544
1909
|
* Represents the local file header fields of an entry, read when getting the entry data.
|
|
1545
1910
|
*/
|
|
@@ -1584,6 +1949,23 @@ export interface LocalDirectory {
|
|
|
1584
1949
|
* The extra field.
|
|
1585
1950
|
*/
|
|
1586
1951
|
extraField?: Map<number, EntryExtraField>;
|
|
1952
|
+
/**
|
|
1953
|
+
* The filename of the entry stored in the local file header (raw), which is allowed to differ from
|
|
1954
|
+
* {@link EntryMetaData#rawFilename}.
|
|
1955
|
+
*
|
|
1956
|
+
* Only defined when the local filename has been read, i.e. when the {@link ZipReaderOptions#strictness} option
|
|
1957
|
+
* is set to `"strict"` or when the {@link ZipReaderOptions#checkLocalDirectory} option is set to `true`, since
|
|
1958
|
+
* reading it costs one read the central directory does not need.
|
|
1959
|
+
*/
|
|
1960
|
+
rawFilename?: Uint8Array;
|
|
1961
|
+
/**
|
|
1962
|
+
* The data descriptor record written after the content, when the entry has one.
|
|
1963
|
+
*
|
|
1964
|
+
* Only defined when the record has been read, i.e. when the {@link ZipReaderOptions#checkOverlappingEntry} or
|
|
1965
|
+
* the {@link ZipReaderOptions#checkOverlappingEntryOnly} option is set to `true`, since the sizes stored in the
|
|
1966
|
+
* central directory make it unnecessary to read it otherwise.
|
|
1967
|
+
*/
|
|
1968
|
+
dataDescriptor?: LocalDataDescriptor;
|
|
1587
1969
|
/**
|
|
1588
1970
|
* The CRC-32 checksum of the content.
|
|
1589
1971
|
*/
|
|
@@ -1609,7 +1991,7 @@ export interface LocalDirectory {
|
|
|
1609
1991
|
/**
|
|
1610
1992
|
* The Zip64 extra field.
|
|
1611
1993
|
*/
|
|
1612
|
-
extraFieldZip64?:
|
|
1994
|
+
extraFieldZip64?: EntryExtraFieldZip64;
|
|
1613
1995
|
/**
|
|
1614
1996
|
* The AES extra field.
|
|
1615
1997
|
*/
|
|
@@ -1617,16 +1999,18 @@ export interface LocalDirectory {
|
|
|
1617
1999
|
/**
|
|
1618
2000
|
* The NTFS extra field.
|
|
1619
2001
|
*/
|
|
1620
|
-
extraFieldNTFS?:
|
|
2002
|
+
extraFieldNTFS?: EntryExtraFieldNTFS;
|
|
1621
2003
|
/**
|
|
1622
2004
|
* The Info-ZIP Unix type 2 extra field (0x7855). Its uid/gid are stored in the local file header only, the
|
|
1623
2005
|
* central directory version carries no data and merely flags their presence.
|
|
1624
2006
|
*/
|
|
1625
|
-
extraFieldUnix?:
|
|
2007
|
+
extraFieldUnix?: EntryExtraFieldUnix;
|
|
1626
2008
|
/**
|
|
1627
|
-
* The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers.
|
|
2009
|
+
* The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers. It is read
|
|
2010
|
+
* whenever the type 2 extra field (0x7855) is absent or carries no ids, which is its usual state in the
|
|
2011
|
+
* central directory.
|
|
1628
2012
|
*/
|
|
1629
|
-
extraFieldInfoZip?:
|
|
2013
|
+
extraFieldInfoZip?: EntryExtraFieldUnix;
|
|
1630
2014
|
/**
|
|
1631
2015
|
* The Info-ZIP Unix type 1 extra field (0x5855).
|
|
1632
2016
|
*/
|
|
@@ -1638,7 +2022,7 @@ export interface LocalDirectory {
|
|
|
1638
2022
|
/**
|
|
1639
2023
|
* The extended timestamp extra field.
|
|
1640
2024
|
*/
|
|
1641
|
-
extraFieldExtendedTimestamp?:
|
|
2025
|
+
extraFieldExtendedTimestamp?: EntryExtraFieldExtendedTimestamp;
|
|
1642
2026
|
/**
|
|
1643
2027
|
* The Unicode path extra field.
|
|
1644
2028
|
*/
|
|
@@ -1653,13 +2037,24 @@ export interface LocalDirectory {
|
|
|
1653
2037
|
extraFieldUSDZ?: EntryExtraField;
|
|
1654
2038
|
}
|
|
1655
2039
|
/**
|
|
1656
|
-
* Represents an error raised while processing an
|
|
2040
|
+
* Represents an error raised while processing an archive or one of its entries, decorated with context.
|
|
1657
2041
|
*/
|
|
1658
2042
|
export interface EntryError extends Error {
|
|
1659
2043
|
/**
|
|
1660
2044
|
* `true` if the zip file is corrupted because the entry data could not be written entirely.
|
|
1661
2045
|
*/
|
|
1662
2046
|
corruptedEntry?: boolean;
|
|
2047
|
+
/**
|
|
2048
|
+
* The entry whose data overlaps the data of the entry being read, set on the
|
|
2049
|
+
* {@link ERR_OVERLAPPING_ENTRY} error raised by {@link ZipReaderOptions#checkOverlappingEntry}.
|
|
2050
|
+
* It is the only way to identify the other entry of the pair.
|
|
2051
|
+
*/
|
|
2052
|
+
overlappingEntry?: Entry;
|
|
2053
|
+
/**
|
|
2054
|
+
* The ambiguity that was detected, set on the {@link ERR_AMBIGUOUS_ARCHIVE} error raised by
|
|
2055
|
+
* {@link GetEntriesOptions#strictness}. See {@link ERR_AMBIGUOUS_ARCHIVE} for the values it takes.
|
|
2056
|
+
*/
|
|
2057
|
+
reason?: string;
|
|
1663
2058
|
/**
|
|
1664
2059
|
* The id of the related {@link ZipEntry} (filesystem API).
|
|
1665
2060
|
*/
|
|
@@ -1722,6 +2117,10 @@ export interface EntryMetaData {
|
|
|
1722
2117
|
*
|
|
1723
2118
|
* The path is not validated: it can be absolute or escape the archive with `..` segments. It must
|
|
1724
2119
|
* be checked before being used to resolve a file.
|
|
2120
|
+
*
|
|
2121
|
+
* There is no option to write a symbolic link. Set the file type in
|
|
2122
|
+
* {@link ZipWriterConstructorOptions#unixMode} instead, i.e. pass `0o120777` with the path of the
|
|
2123
|
+
* target as the content of the entry.
|
|
1725
2124
|
*/
|
|
1726
2125
|
symlink: boolean;
|
|
1727
2126
|
/**
|
|
@@ -1753,15 +2152,19 @@ export interface EntryMetaData {
|
|
|
1753
2152
|
*/
|
|
1754
2153
|
creationDate?: Date;
|
|
1755
2154
|
/**
|
|
1756
|
-
* The last modification date (raw).
|
|
2155
|
+
* The last modification date (raw), as the MS-DOS date and time stored in the header. Unlike
|
|
2156
|
+
* {@link EntryMetaData#lastModDate}, it is not replaced by the value of the NTFS extra field when that field
|
|
2157
|
+
* is present; read {@link EntryMetaData#extraFieldNTFS} for the raw NTFS value.
|
|
1757
2158
|
*/
|
|
1758
2159
|
rawLastModDate: number | bigint;
|
|
1759
2160
|
/**
|
|
1760
|
-
* The last access date (raw).
|
|
2161
|
+
* The last access date (raw), as the Windows `FILETIME` value stored in the NTFS extra field. Only defined
|
|
2162
|
+
* when that extra field is present.
|
|
1761
2163
|
*/
|
|
1762
2164
|
rawLastAccessDate?: number | bigint;
|
|
1763
2165
|
/**
|
|
1764
|
-
* The creation date (raw).
|
|
2166
|
+
* The creation date (raw), as the Windows `FILETIME` value stored in the NTFS extra field. Only defined when
|
|
2167
|
+
* that extra field is present.
|
|
1765
2168
|
*/
|
|
1766
2169
|
rawCreationDate?: number | bigint;
|
|
1767
2170
|
/**
|
|
@@ -1850,9 +2253,12 @@ export interface EntryMetaData {
|
|
|
1850
2253
|
*
|
|
1851
2254
|
* The value is read from the central directory. The Info-ZIP Unix extra fields type 1 (0x5855) and type 2
|
|
1852
2255
|
* (0x7855) store the ids in the local file header only, so entries carrying just these fields leave the
|
|
1853
|
-
* property undefined until the data has been read
|
|
2256
|
+
* property undefined until the data has been read, at which point it is filled in from
|
|
1854
2257
|
* {@link EntryMetaData#localDirectory}. The Info-ZIP New Unix extra field (0x7875) and the PKWARE Unix
|
|
1855
2258
|
* extra field (0x000d) store the ids in both headers and are unaffected.
|
|
2259
|
+
*
|
|
2260
|
+
* @remarks A value read from the central directory is never overwritten by the local file header, since the
|
|
2261
|
+
* type 2 field truncates the ids to 16 bits while the New Unix field does not.
|
|
1856
2262
|
*/
|
|
1857
2263
|
uid?: number;
|
|
1858
2264
|
/**
|
|
@@ -1934,7 +2340,7 @@ export interface EntryMetaData {
|
|
|
1934
2340
|
/**
|
|
1935
2341
|
* The Zip64 extra field.
|
|
1936
2342
|
*/
|
|
1937
|
-
extraFieldZip64?:
|
|
2343
|
+
extraFieldZip64?: EntryExtraFieldZip64;
|
|
1938
2344
|
/**
|
|
1939
2345
|
* The AES extra field.
|
|
1940
2346
|
*/
|
|
@@ -1942,16 +2348,18 @@ export interface EntryMetaData {
|
|
|
1942
2348
|
/**
|
|
1943
2349
|
* The NTFS extra field.
|
|
1944
2350
|
*/
|
|
1945
|
-
extraFieldNTFS?:
|
|
2351
|
+
extraFieldNTFS?: EntryExtraFieldNTFS;
|
|
1946
2352
|
/**
|
|
1947
2353
|
* The Info-ZIP Unix type 2 extra field (0x7855). Its uid/gid are stored in the local file header only, the
|
|
1948
2354
|
* central directory version carries no data and merely flags their presence.
|
|
1949
2355
|
*/
|
|
1950
|
-
extraFieldUnix?:
|
|
2356
|
+
extraFieldUnix?: EntryExtraFieldUnix;
|
|
1951
2357
|
/**
|
|
1952
|
-
* The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers.
|
|
2358
|
+
* The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers. It is read
|
|
2359
|
+
* whenever the type 2 extra field (0x7855) is absent or carries no ids, which is its usual state in the
|
|
2360
|
+
* central directory.
|
|
1953
2361
|
*/
|
|
1954
|
-
extraFieldInfoZip?:
|
|
2362
|
+
extraFieldInfoZip?: EntryExtraFieldUnix;
|
|
1955
2363
|
/**
|
|
1956
2364
|
* The Info-ZIP Unix type 1 extra field (0x5855).
|
|
1957
2365
|
*/
|
|
@@ -1963,7 +2371,7 @@ export interface EntryMetaData {
|
|
|
1963
2371
|
/**
|
|
1964
2372
|
* The extended timestamp extra field.
|
|
1965
2373
|
*/
|
|
1966
|
-
extraFieldExtendedTimestamp?:
|
|
2374
|
+
extraFieldExtendedTimestamp?: EntryExtraFieldExtendedTimestamp;
|
|
1967
2375
|
/**
|
|
1968
2376
|
* The Unicode path extra field.
|
|
1969
2377
|
*/
|
|
@@ -2194,6 +2602,10 @@ export class ZipWriter<Type> {
|
|
|
2194
2602
|
* Adds an existing zip file at the beginning of the current zip. This method
|
|
2195
2603
|
* cannot be called after the first call to {@link ZipWriter#add}.
|
|
2196
2604
|
*
|
|
2605
|
+
* @remarks The data of the zip file is copied, its central directory is rebuilt and its entries are relocated to
|
|
2606
|
+
* the positions they get in the output. The disks of a split zip file passed as input are therefore unrelated to
|
|
2607
|
+
* the disks of the output, which is a single zip file unless the writer is a split zip file writer.
|
|
2608
|
+
*
|
|
2197
2609
|
* @param reader The {@link Reader} instance used to read the content of the zip file.
|
|
2198
2610
|
* @returns A promise resolving when the zip file has been added.
|
|
2199
2611
|
*/
|
|
@@ -2242,6 +2654,10 @@ export class ZipWriter<Type> {
|
|
|
2242
2654
|
/**
|
|
2243
2655
|
* Writes the entries directory, writes the global comment, and returns the content of the zip file
|
|
2244
2656
|
*
|
|
2657
|
+
* @remarks
|
|
2658
|
+
* The global comment is passed as raw bytes and the comment of an entry
|
|
2659
|
+
* ({@link ZipWriterAddDataOptions#comment}) as a string on purpose, see {@link ZipReader#comment}.
|
|
2660
|
+
*
|
|
2245
2661
|
* @param comment The global comment of the zip file.
|
|
2246
2662
|
* @param options The options.
|
|
2247
2663
|
* @returns The content of the zip file.
|
|
@@ -2270,6 +2686,13 @@ export interface ZipWriterAddDataOptions
|
|
|
2270
2686
|
executable?: boolean;
|
|
2271
2687
|
/**
|
|
2272
2688
|
* The comment of the entry.
|
|
2689
|
+
*
|
|
2690
|
+
* @remarks
|
|
2691
|
+
* It is a string, unlike the global comment passed to {@link ZipWriter#close}, because the encoding of
|
|
2692
|
+
* the comment of an entry is recorded in the header by the general purpose bit 11 (see Appendix D -
|
|
2693
|
+
* Language Encoding (EFS)), set by {@link ZipWriterConstructorOptions#useUnicodeFileNames}. Passing raw
|
|
2694
|
+
* bytes here throws {@link ERR_INVALID_ENTRY_COMMENT_TYPE} instead of writing their textual
|
|
2695
|
+
* representation.
|
|
2273
2696
|
*/
|
|
2274
2697
|
comment?: string;
|
|
2275
2698
|
/**
|
|
@@ -2427,6 +2850,11 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2427
2850
|
/**
|
|
2428
2851
|
* The last modification date.
|
|
2429
2852
|
*
|
|
2853
|
+
* @remarks
|
|
2854
|
+
* This option and the two below must be `Date` instances: a timestamp expressed in milliseconds, e.g.
|
|
2855
|
+
* {@link File#lastModified}, and an invalid `Date` are both rejected with {@link ERR_INVALID_DATE}. An
|
|
2856
|
+
* invalid `Date` used to be written as an entry carrying no timestamp at all.
|
|
2857
|
+
*
|
|
2430
2858
|
* @defaultValue The current date.
|
|
2431
2859
|
*/
|
|
2432
2860
|
lastModDate?: Date;
|
|
@@ -2435,7 +2863,8 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2435
2863
|
*
|
|
2436
2864
|
* This option is ignored if the {@link ZipWriterConstructorOptions#extendedTimestamp} option is set to `false`.
|
|
2437
2865
|
*
|
|
2438
|
-
* @
|
|
2866
|
+
* Unlike {@link ZipWriterConstructorOptions#lastModDate}, it has no default: the date is written only when the
|
|
2867
|
+
* option is set, so that the entries do not carry a meaningless access time.
|
|
2439
2868
|
*/
|
|
2440
2869
|
lastAccessDate?: Date;
|
|
2441
2870
|
/**
|
|
@@ -2443,7 +2872,8 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2443
2872
|
*
|
|
2444
2873
|
* This option is ignored if the {@link ZipWriterConstructorOptions#extendedTimestamp} option is set to `false`.
|
|
2445
2874
|
*
|
|
2446
|
-
* @
|
|
2875
|
+
* Unlike {@link ZipWriterConstructorOptions#lastModDate}, it has no default: the date is written only when the
|
|
2876
|
+
* option is set, so that the entries do not carry a meaningless creation time.
|
|
2447
2877
|
*/
|
|
2448
2878
|
creationDate?: Date;
|
|
2449
2879
|
/**
|
|
@@ -2478,9 +2908,18 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2478
2908
|
*/
|
|
2479
2909
|
version?: number;
|
|
2480
2910
|
/**
|
|
2481
|
-
* The "Version made by" field
|
|
2911
|
+
* The "Version made by" field, whose upper byte is the platform and lower byte the version of the
|
|
2912
|
+
* specification.
|
|
2913
|
+
*
|
|
2914
|
+
* The platform is not taken from the value passed here. It is forced to Unix (`3`) when the entry carries Unix
|
|
2915
|
+
* metadata, i.e. when {@link ZipWriterConstructorOptions#uid}, {@link ZipWriterConstructorOptions#gid},
|
|
2916
|
+
* {@link ZipWriterConstructorOptions#unixMode} or {@link ZipWriterConstructorOptions#unixExtraFieldType} is set,
|
|
2917
|
+
* since Unix mode bits stored under another platform are ignored by the extractors. It is forced to MS-DOS (`0`)
|
|
2918
|
+
* when {@link ZipWriterConstructorOptions#msdosAttributes} or
|
|
2919
|
+
* {@link ZipWriterConstructorOptions#msdosAttributesRaw} is set. Only the lower byte of the value survives in
|
|
2920
|
+
* both cases.
|
|
2482
2921
|
*
|
|
2483
|
-
* @defaultValue 20
|
|
2922
|
+
* @defaultValue 768, i.e. `3 << 8`, or 20 when {@link ZipWriterConstructorOptions#msDosCompatible} is set to `true`
|
|
2484
2923
|
*/
|
|
2485
2924
|
versionMadeBy?: number;
|
|
2486
2925
|
/**
|
|
@@ -2510,6 +2949,12 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2510
2949
|
/**
|
|
2511
2950
|
* `true` to write {@link EntryMetaData#externalFileAttributes} in MS-DOS format for folder entries.
|
|
2512
2951
|
*
|
|
2952
|
+
* It also selects the MS-DOS platform for {@link ZipWriterConstructorOptions#versionMadeBy} and leaves the Unix
|
|
2953
|
+
* attributes out of the entries. Setting any Unix metadata option, e.g.
|
|
2954
|
+
* {@link ZipWriterConstructorOptions#unixMode} or {@link ZipWriterAddDataOptions#executable}, turns it back off, and setting
|
|
2955
|
+
* {@link ZipWriterConstructorOptions#msdosAttributesRaw} or {@link ZipWriterConstructorOptions#msdosAttributes}
|
|
2956
|
+
* turns it on, overriding an explicit `false`.
|
|
2957
|
+
*
|
|
2513
2958
|
* @defaultValue false
|
|
2514
2959
|
*/
|
|
2515
2960
|
msDosCompatible?: boolean;
|
|
@@ -2543,8 +2988,9 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2543
2988
|
* `0o120777` and use the path of the link target as the content of the entry. Extractors that
|
|
2544
2989
|
* support symbolic links, e.g. Info-ZIP `unzip`, then restore the entry as a link.
|
|
2545
2990
|
*
|
|
2546
|
-
*
|
|
2547
|
-
*
|
|
2991
|
+
* A folder entry is always written with `S_IFDIR` (`0o040000`), replacing any file type carried by the
|
|
2992
|
+
* value, so the same mode can be set once on the writer and reused for every entry. Any other entry keeps
|
|
2993
|
+
* the file type it is given, and is written with `S_IFREG` (`0o100000`) when the value carries none. Set
|
|
2548
2994
|
* {@link ZipWriterConstructorOptions#externalFileAttributes} instead to write a mode with no
|
|
2549
2995
|
* file type.
|
|
2550
2996
|
*/
|
|
@@ -2584,10 +3030,28 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2584
3030
|
/**
|
|
2585
3031
|
* When provided, the low 8-bit MS-DOS attributes to write into external file attributes.
|
|
2586
3032
|
* Must be an integer between 0 and 255.
|
|
3033
|
+
*
|
|
3034
|
+
* @remarks
|
|
3035
|
+
* Setting this option or {@link ZipWriterConstructorOptions#msdosAttributes} selects the MS-DOS platform for
|
|
3036
|
+
* the entry exactly as {@link ZipWriterConstructorOptions#msDosCompatible} does, and overrides that option
|
|
3037
|
+
* when it is explicitly set to `false`. {@link EntryMetaData#versionMadeBy} then loses its Unix upper byte
|
|
3038
|
+
* and no Unix mode is written, so the `0o100644` of a file entry and the `0o040755` of a folder entry are
|
|
3039
|
+
* lost. What counts is that the option is provided, not its value: `0` and `{}` trigger it too.
|
|
3040
|
+
*
|
|
3041
|
+
* Setting any Unix metadata option, i.e. {@link ZipWriterConstructorOptions#uid},
|
|
3042
|
+
* {@link ZipWriterConstructorOptions#gid}, {@link ZipWriterConstructorOptions#unixMode},
|
|
3043
|
+
* {@link ZipWriterConstructorOptions#unixExtraFieldType} or {@link ZipWriterAddDataOptions#executable},
|
|
3044
|
+
* takes precedence and keeps the Unix attributes, with the MS-DOS attributes written into the low byte.
|
|
3045
|
+
* {@link ZipWriterConstructorOptions#externalFileAttributes} is preserved as well, although the entry still
|
|
3046
|
+
* declares the MS-DOS platform.
|
|
2587
3047
|
*/
|
|
2588
3048
|
msdosAttributesRaw?: number;
|
|
2589
3049
|
/**
|
|
2590
3050
|
* When provided, MS-DOS attribute flags (boolean object) to write into external file attributes low byte.
|
|
3051
|
+
*
|
|
3052
|
+
* @remarks
|
|
3053
|
+
* See {@link ZipWriterConstructorOptions#msdosAttributesRaw} for the platform this option selects and for
|
|
3054
|
+
* the Unix metadata it leaves out of the entry.
|
|
2591
3055
|
*/
|
|
2592
3056
|
msdosAttributes?: {
|
|
2593
3057
|
readOnly?: boolean;
|
|
@@ -2704,7 +3168,7 @@ export interface EntryOnprogressOptions {
|
|
|
2704
3168
|
/**
|
|
2705
3169
|
* Represents an entry in a zip file (Filesystem API).
|
|
2706
3170
|
*/
|
|
2707
|
-
|
|
3171
|
+
export class ZipEntry {
|
|
2708
3172
|
/**
|
|
2709
3173
|
* The relative filename of the entry.
|
|
2710
3174
|
*/
|
|
@@ -2733,6 +3197,15 @@ declare class ZipEntry {
|
|
|
2733
3197
|
* The children of the entry.
|
|
2734
3198
|
*/
|
|
2735
3199
|
children: ZipEntry[];
|
|
3200
|
+
/**
|
|
3201
|
+
* The options applied to the entry when the zip file is exported.
|
|
3202
|
+
*
|
|
3203
|
+
* @remarks
|
|
3204
|
+
* These are the options passed when the entry was added to the filesystem, updated by
|
|
3205
|
+
* {@link ZipEntry#setOptions}. An entry imported from a zip file has none until
|
|
3206
|
+
* {@link ZipEntry#setOptions} is called.
|
|
3207
|
+
*/
|
|
3208
|
+
readonly options?: ZipWriterAddDataOptions;
|
|
2736
3209
|
/**
|
|
2737
3210
|
* Clones the entry
|
|
2738
3211
|
*
|
|
@@ -2770,6 +3243,24 @@ declare class ZipEntry {
|
|
|
2770
3243
|
* @param name The new name of the entry.
|
|
2771
3244
|
*/
|
|
2772
3245
|
rename(name: string): void;
|
|
3246
|
+
/**
|
|
3247
|
+
* Sets the options applied to the entry when the zip file is exported
|
|
3248
|
+
*
|
|
3249
|
+
* @remarks
|
|
3250
|
+
* The options are merged into {@link ZipEntry#options}, and an option set to `undefined` is removed
|
|
3251
|
+
* from it instead of being stored. They take precedence over the options passed to
|
|
3252
|
+
* `{@link ZipDirectoryEntry}#export*()` and over the metadata of the entry they were imported from,
|
|
3253
|
+
* exactly like the options passed when adding an entry to the filesystem.
|
|
3254
|
+
*
|
|
3255
|
+
* The options describing the data of an entry exported as-is, e.g.
|
|
3256
|
+
* {@link ZipWriterConstructorOptions#compressionMethod} and
|
|
3257
|
+
* {@link ZipWriterAddDataOptions#uncompressedSize}, are ignored: they are always the ones of the
|
|
3258
|
+
* original entry. The {@link ZipWriterAddDataOptions#directory} option and the progress callbacks
|
|
3259
|
+
* are ignored as well. Invalid option values are reported when the zip file is exported.
|
|
3260
|
+
*
|
|
3261
|
+
* @param options The options.
|
|
3262
|
+
*/
|
|
3263
|
+
setOptions(options: ZipWriterAddDataOptions): void;
|
|
2773
3264
|
}
|
|
2774
3265
|
|
|
2775
3266
|
/**
|
|
@@ -2923,7 +3414,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
2923
3414
|
* before the children of its subdirectories, like the result of `readdir(path, { recursive: true })` in
|
|
2924
3415
|
* Node.js. This is also the order in which `{@link ZipDirectoryEntry}#export*()` writes them.
|
|
2925
3416
|
*
|
|
2926
|
-
* Unlike {@link
|
|
3417
|
+
* Unlike {@link ZipFS#entries}, the directory itself is not included and removed entries leave no empty slot.
|
|
2927
3418
|
*
|
|
2928
3419
|
* @param options The options.
|
|
2929
3420
|
* @returns The array of {@link ZipEntry} instances.
|
|
@@ -3137,6 +3628,11 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3137
3628
|
* the same `"a/b.txt"` entry. Filenames are normalized and validated beforehand, see
|
|
3138
3629
|
* {@link GetEntriesOptions#normalizeFilename} and {@link GetEntriesOptions#filenameValidation}.
|
|
3139
3630
|
*
|
|
3631
|
+
* The directories created that way are navigable like any other entry but are not written back when the
|
|
3632
|
+
* tree is exported: only the directories carried by the source zip file and the ones created with
|
|
3633
|
+
* {@link ZipDirectoryEntry#addDirectory} are written. A zip file storing no directory entry therefore
|
|
3634
|
+
* round-trips to a zip file storing no directory entry, instead of gaining one entry per path component.
|
|
3635
|
+
*
|
|
3140
3636
|
* Passing a {@link ZipReader} instance is the way to read the data of the zip file itself, e.g. its
|
|
3141
3637
|
* {@link ZipReader#prependedData} or its {@link ZipReader#comment} property, since the instance created
|
|
3142
3638
|
* otherwise is not exposed. Its options are used as defaults for the options passed here, and it must not
|
|
@@ -3273,7 +3769,7 @@ export interface ZipDirectoryEntryImportHttpOptions
|
|
|
3273
3769
|
HttpOptions {}
|
|
3274
3770
|
|
|
3275
3771
|
/**
|
|
3276
|
-
* Represents the options passed to {@link ZipDirectoryEntry#getChildren} and {@link
|
|
3772
|
+
* Represents the options passed to {@link ZipDirectoryEntry#getChildren} and {@link ZipFS#getChildren}.
|
|
3277
3773
|
*/
|
|
3278
3774
|
export interface ZipDirectoryEntryGetChildrenOptions {
|
|
3279
3775
|
/**
|
|
@@ -3317,6 +3813,13 @@ export interface ZipDirectoryEntryGetChildrenOptions {
|
|
|
3317
3813
|
* {@link ZipDirectoryEntry#exportZip} or {@link ZipDirectoryEntry#exportWritable}. It is ignored by the
|
|
3318
3814
|
* other `{@link ZipDirectoryEntry}#export*()` methods, whose Writer instance can only return its data
|
|
3319
3815
|
* once its writable is closed.
|
|
3816
|
+
*
|
|
3817
|
+
* An entry added without a {@link ZipWriterAddDataOptions#lastModDate} option is dated with the moment
|
|
3818
|
+
* it was added, so exporting an unchanged tree twice produces the same bytes. That date is the weakest
|
|
3819
|
+
* one: it is replaced by the date of the entry the tree was imported from, which is itself replaced by
|
|
3820
|
+
* the {@link ZipWriterConstructorOptions#lastModDate} option passed here, which pins every date of the
|
|
3821
|
+
* exported zip file. Only a {@link ZipWriterAddDataOptions#lastModDate} option passed when the entry
|
|
3822
|
+
* was added takes precedence over all of them.
|
|
3320
3823
|
*/
|
|
3321
3824
|
export interface ZipDirectoryEntryExportOptions
|
|
3322
3825
|
extends ZipWriterConstructorOptions,
|
|
@@ -3380,12 +3883,14 @@ export interface ZipDirectoryEntryExportOptions
|
|
|
3380
3883
|
* The {@link ZipReaderOptions#passThrough} option set here exports the entries imported from a zip
|
|
3381
3884
|
* file as-is, without decompressing and decrypting them, exactly as importing them with this option
|
|
3382
3885
|
* does. It is ignored by the entries added to the filesystem, which are compressed as usual.
|
|
3886
|
+
*
|
|
3887
|
+
* A value which is neither an object nor unset throws an {@link ERR_INVALID_READER_OPTIONS} error.
|
|
3383
3888
|
*/
|
|
3384
3889
|
readerOptions?: ZipReaderConstructorOptions;
|
|
3385
3890
|
}
|
|
3386
3891
|
|
|
3387
3892
|
/**
|
|
3388
|
-
* Represents the options passed to {@link ZipDirectoryEntry#exportFileSystemHandle} and {@link
|
|
3893
|
+
* Represents the options passed to {@link ZipDirectoryEntry#exportFileSystemHandle} and {@link ZipFS#exportFileSystemHandle}.
|
|
3389
3894
|
*
|
|
3390
3895
|
* @remarks
|
|
3391
3896
|
* The {@link ZipReaderOptions#preventClose} option is ignored: the export owns the writable of each
|
|
@@ -3411,6 +3916,8 @@ export interface ZipDirectoryEntryExportFileSystemHandleOptions
|
|
|
3411
3916
|
* These options override the ones passed at the top level. The {@link ZipReaderOptions#password}
|
|
3412
3917
|
* option can be set here or at the top level, unlike {@link ZipDirectoryEntryExportOptions} where
|
|
3413
3918
|
* the top-level password encrypts the exported zip file instead.
|
|
3919
|
+
*
|
|
3920
|
+
* A value which is neither an object nor unset throws an {@link ERR_INVALID_READER_OPTIONS} error.
|
|
3414
3921
|
*/
|
|
3415
3922
|
readerOptions?: ZipReaderConstructorOptions;
|
|
3416
3923
|
}
|
|
@@ -3424,16 +3931,16 @@ export interface ZipDirectoryEntryExportFileSystemHandleOptions
|
|
|
3424
3931
|
* const TEXT_CONTENT = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.";
|
|
3425
3932
|
* const FILENAME = "lorem.txt";
|
|
3426
3933
|
* const BLOB = new Blob([TEXT_CONTENT], { type: zip.getMimeType(FILENAME) });
|
|
3427
|
-
* let zipFs = new zip.
|
|
3934
|
+
* let zipFs = new zip.ZipFS();
|
|
3428
3935
|
* zipFs.addBlob("lorem.txt", BLOB);
|
|
3429
3936
|
* const zippedBlob = await zipFs.exportBlob();
|
|
3430
|
-
* zipFs = new zip.
|
|
3937
|
+
* zipFs = new zip.ZipFS();
|
|
3431
3938
|
* await zipFs.importBlob(zippedBlob);
|
|
3432
3939
|
* const firstEntry = zipFs.children[0];
|
|
3433
3940
|
* const unzippedBlob = await firstEntry.getBlob(zip.getMimeType(firstEntry.name));
|
|
3434
3941
|
* ```
|
|
3435
3942
|
*/
|
|
3436
|
-
export interface
|
|
3943
|
+
export interface ZipFS
|
|
3437
3944
|
extends Pick<
|
|
3438
3945
|
ZipDirectoryEntry,
|
|
3439
3946
|
| "getChildByName"
|
|
@@ -3465,7 +3972,7 @@ export interface FS
|
|
|
3465
3972
|
| "checkPassword"
|
|
3466
3973
|
> {}
|
|
3467
3974
|
|
|
3468
|
-
export class
|
|
3975
|
+
export class ZipFS {
|
|
3469
3976
|
/**
|
|
3470
3977
|
* The root directory.
|
|
3471
3978
|
*/
|
|
@@ -3507,26 +4014,35 @@ export class FS {
|
|
|
3507
4014
|
getById(id: number): ZipEntry | undefined;
|
|
3508
4015
|
}
|
|
3509
4016
|
|
|
4017
|
+
/**
|
|
4018
|
+
* The type of the filesystem.
|
|
4019
|
+
*
|
|
4020
|
+
* @deprecated Use {@link ZipFS} instead.
|
|
4021
|
+
*/
|
|
4022
|
+
export type FS = ZipFS;
|
|
4023
|
+
|
|
3510
4024
|
/**
|
|
3511
4025
|
* The Filesystem API.
|
|
4026
|
+
*
|
|
4027
|
+
* @deprecated Use the {@link ZipFS}, {@link ZipDirectoryEntry} and {@link ZipFileEntry} exports instead.
|
|
3512
4028
|
*/
|
|
3513
4029
|
export const fs: {
|
|
3514
4030
|
/**
|
|
3515
4031
|
* The Filesystem constructor.
|
|
3516
4032
|
*
|
|
3517
|
-
* @
|
|
4033
|
+
* @deprecated Use {@link ZipFS} instead.
|
|
3518
4034
|
*/
|
|
3519
|
-
FS: typeof
|
|
4035
|
+
FS: typeof ZipFS;
|
|
3520
4036
|
/**
|
|
3521
4037
|
* The {@link ZipDirectoryEntry} constructor.
|
|
3522
4038
|
*
|
|
3523
|
-
* @
|
|
4039
|
+
* @deprecated Use the {@link ZipDirectoryEntry} export instead.
|
|
3524
4040
|
*/
|
|
3525
4041
|
ZipDirectoryEntry: typeof ZipDirectoryEntry;
|
|
3526
4042
|
/**
|
|
3527
4043
|
* The {@link ZipFileEntry} constructor.
|
|
3528
4044
|
*
|
|
3529
|
-
* @
|
|
4045
|
+
* @deprecated Use the {@link ZipFileEntry} export instead.
|
|
3530
4046
|
*/
|
|
3531
4047
|
ZipFileEntry: typeof ZipFileEntry;
|
|
3532
4048
|
};
|
|
@@ -3643,6 +4159,10 @@ export const ERR_DUPLICATED_NAME: string;
|
|
|
3643
4159
|
* Invalid comment error
|
|
3644
4160
|
*/
|
|
3645
4161
|
export const ERR_INVALID_COMMENT: string;
|
|
4162
|
+
/**
|
|
4163
|
+
* Invalid comment type error
|
|
4164
|
+
*/
|
|
4165
|
+
export const ERR_INVALID_COMMENT_TYPE: string;
|
|
3646
4166
|
/**
|
|
3647
4167
|
* Invalid entry name error
|
|
3648
4168
|
*/
|
|
@@ -3651,14 +4171,59 @@ export const ERR_INVALID_ENTRY_NAME: string;
|
|
|
3651
4171
|
* Invalid entry comment error
|
|
3652
4172
|
*/
|
|
3653
4173
|
export const ERR_INVALID_ENTRY_COMMENT: string;
|
|
4174
|
+
/**
|
|
4175
|
+
* Invalid entry comment type error
|
|
4176
|
+
*/
|
|
4177
|
+
export const ERR_INVALID_ENTRY_COMMENT_TYPE: string;
|
|
4178
|
+
/**
|
|
4179
|
+
* Invalid date error
|
|
4180
|
+
*/
|
|
4181
|
+
export const ERR_INVALID_DATE: string;
|
|
4182
|
+
/**
|
|
4183
|
+
* Invalid function option error
|
|
4184
|
+
*
|
|
4185
|
+
* @remarks
|
|
4186
|
+
* Thrown when an option expecting a function is given a value of another type: {@link ZipWriterConstructorOptions#encodeText},
|
|
4187
|
+
* {@link GetEntriesOptions#decodeText}, {@link ZipWriterConstructorOptions#createTempStream},
|
|
4188
|
+
* {@link ZipWriterCloseOptions#signCentralDirectory} and {@link GetEntriesOptions#decryptCentralDirectory}. It is also
|
|
4189
|
+
* thrown by {@link configure} for {@link Configuration#createWorker}, {@link Configuration#CompressionStream},
|
|
4190
|
+
* {@link Configuration#DecompressionStream}, {@link Configuration#CompressionStreamFallback} and
|
|
4191
|
+
* {@link Configuration#DecompressionStreamFallback}. A falsy value keeps meaning "use the default".
|
|
4192
|
+
*/
|
|
4193
|
+
export const ERR_INVALID_FUNCTION_OPTION: string;
|
|
4194
|
+
/**
|
|
4195
|
+
* Invalid signal error
|
|
4196
|
+
*
|
|
4197
|
+
* @remarks
|
|
4198
|
+
* Thrown when the `signal` option is not an `AbortSignal`. Any object exposing `addEventListener()` and a boolean `aborted`
|
|
4199
|
+
* property is accepted, so a signal coming from another realm keeps working.
|
|
4200
|
+
*/
|
|
4201
|
+
export const ERR_INVALID_SIGNAL: string;
|
|
4202
|
+
/**
|
|
4203
|
+
* Invalid maxWorkers error
|
|
4204
|
+
*
|
|
4205
|
+
* @remarks
|
|
4206
|
+
* Thrown by {@link configure} when {@link Configuration#maxWorkers} is not an integer greater than 0. A value lower than 1
|
|
4207
|
+
* used to deadlock {@link ZipWriter#add} for ever, since no entry could start and none could release the next one. Pass
|
|
4208
|
+
* {@link Configuration#useWebWorkers} set to `false` to compress and decompress data in the main thread instead.
|
|
4209
|
+
*/
|
|
4210
|
+
export const ERR_INVALID_MAX_WORKERS: string;
|
|
3654
4211
|
/**
|
|
3655
4212
|
* Invalid version error
|
|
3656
4213
|
*/
|
|
3657
4214
|
export const ERR_INVALID_VERSION: string;
|
|
4215
|
+
/**
|
|
4216
|
+
* Invalid extra field error
|
|
4217
|
+
*/
|
|
4218
|
+
export const ERR_INVALID_EXTRAFIELD: string;
|
|
3658
4219
|
/**
|
|
3659
4220
|
* Invalid extra field type error
|
|
3660
4221
|
*/
|
|
3661
4222
|
export const ERR_INVALID_EXTRAFIELD_TYPE: string;
|
|
4223
|
+
/**
|
|
4224
|
+
* Invalid extra field data type error
|
|
4225
|
+
*/
|
|
4226
|
+
export const ERR_INVALID_EXTRAFIELD_DATA_TYPE: string;
|
|
3662
4227
|
/**
|
|
3663
4228
|
* Invalid extra field data error
|
|
3664
4229
|
*/
|
|
@@ -3685,12 +4250,29 @@ export const ERR_UNSUPPORTED_FORMAT: string;
|
|
|
3685
4250
|
export const ERR_SPLIT_ZIP_FILE: string;
|
|
3686
4251
|
/**
|
|
3687
4252
|
* Overlapping entry error
|
|
4253
|
+
*
|
|
4254
|
+
* @remarks Thrown by {@link FileEntry#getData} when {@link ZipReaderOptions#checkOverlappingEntry} is set and the
|
|
4255
|
+
* data of the entry overlaps the data of an entry already read. The thrown error carries the other entry in its
|
|
4256
|
+
* `overlappingEntry` property.
|
|
3688
4257
|
*/
|
|
3689
4258
|
export const ERR_OVERLAPPING_ENTRY: string;
|
|
4259
|
+
/**
|
|
4260
|
+
* Entry data out of bounds error
|
|
4261
|
+
*
|
|
4262
|
+
* @remarks Thrown by {@link FileEntry#getData} when the declared extent of the entry data (i.e. its offset plus its compressed size) ends past the end of the zip file.
|
|
4263
|
+
*/
|
|
4264
|
+
export const ERR_ENTRY_DATA_OUT_OF_BOUNDS: string;
|
|
3690
4265
|
/**
|
|
3691
4266
|
* Ambiguous archive error
|
|
3692
4267
|
*
|
|
3693
|
-
* @remarks The thrown error carries a `reason` property describing the ambiguity: `"appended data"`,
|
|
4268
|
+
* @remarks The thrown error carries a `reason` property describing the ambiguity: `"appended data"`,
|
|
4269
|
+
* `"prepended data"`, `"trailing central directory data"`, `"multiple end of central directory records"`,
|
|
4270
|
+
* `"mismatched zip64 end of central directory record"`, `"duplicate filename"`, or, when
|
|
4271
|
+
* {@link ZipReaderOptions#checkLocalDirectory} compares the local header of an entry with its central
|
|
4272
|
+
* directory record, `"mismatched local file header (filename)"`,
|
|
4273
|
+
* `"mismatched local file header (general purpose bit flag)"`,
|
|
4274
|
+
* `"mismatched local file header (compression method)"` or
|
|
4275
|
+
* `"mismatched local file header (crc32 or sizes)"`.
|
|
3694
4276
|
*/
|
|
3695
4277
|
export const ERR_AMBIGUOUS_ARCHIVE: string;
|
|
3696
4278
|
/**
|
|
@@ -3785,7 +4367,9 @@ export const ERR_INVALID_LEVEL: string;
|
|
|
3785
4367
|
* Invalid password error (thrown when the `password` option is not a string, or the `rawPassword` option is not a `Uint8Array`)
|
|
3786
4368
|
*
|
|
3787
4369
|
* @remarks A value of another type would silently produce an unencrypted archive, and a `rawPassword` passed as a string
|
|
3788
|
-
* would produce an archive that cannot be opened with the equivalent {@link ZipWriterConstructorOptions#password}.
|
|
4370
|
+
* would produce an archive that cannot be opened with the equivalent {@link ZipWriterConstructorOptions#password}. The
|
|
4371
|
+
* reader applies the same check, where a value of another type used to fail with the unrelated {@link ERR_ENCRYPTED} or
|
|
4372
|
+
* {@link ERR_INVALID_PASSWORD}.
|
|
3789
4373
|
*/
|
|
3790
4374
|
export const ERR_INVALID_PASSWORD_TYPE: string;
|
|
3791
4375
|
/**
|
|
@@ -3798,6 +4382,16 @@ export const ERR_INVALID_PASSWORD_TYPE: string;
|
|
|
3798
4382
|
* or set the {@link ZipWriterAddDataOptions#uncompressedSize} option of each entry holding compressed data.
|
|
3799
4383
|
*/
|
|
3800
4384
|
export const ERR_INVALID_PASS_THROUGH: string;
|
|
4385
|
+
/**
|
|
4386
|
+
* Invalid readerOptions error (thrown by `{@link ZipDirectoryEntry}#export*()`,
|
|
4387
|
+
* {@link ZipDirectoryEntry#getExportedSize} and {@link ZipDirectoryEntry#exportFileSystemHandle} when the
|
|
4388
|
+
* {@link ZipDirectoryEntryExportOptions#readerOptions} option is neither an object nor unset)
|
|
4389
|
+
*
|
|
4390
|
+
* @remarks A value of another type was silently ignored: a password passed as a string instead of an object failed
|
|
4391
|
+
* with the unrelated {@link ERR_ENCRYPTED}, while the other options were dropped without any error. Note that an
|
|
4392
|
+
* unknown property of a `readerOptions` object is still ignored, as everywhere else in the API.
|
|
4393
|
+
*/
|
|
4394
|
+
export const ERR_INVALID_READER_OPTIONS: string;
|
|
3801
4395
|
/**
|
|
3802
4396
|
* Entry already exists error (thrown by the filesystem API when adding an entry whose filename already exists)
|
|
3803
4397
|
*/
|