@zip.js/zip.js 2.8.53 → 2.8.55
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 +737 -491
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +745 -490
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +776 -525
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +738 -510
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +776 -525
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +790 -525
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +791 -526
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +746 -491
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +746 -491
- 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 +747 -492
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +1 -0
- package/index-native.cjs +790 -525
- package/index-native.min.js +1 -1
- package/index.cjs +791 -526
- package/index.d.cts +422 -49
- package/index.d.ts +422 -49
- package/index.min.js +1 -1
- package/lib/core/configuration.js +62 -21
- package/lib/core/constants.js +13 -1
- package/lib/core/io.js +33 -27
- package/lib/core/options.js +44 -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-fs.js +39 -32
- package/lib/core/zip-reader.js +100 -38
- package/lib/core/zip-writer.js +301 -177
- package/lib/core/zlib-streams-inline.js +1 -1
- 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 +8 -2
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,6 +357,8 @@ export interface Configuration extends WorkerConfiguration {
|
|
|
272
357
|
/**
|
|
273
358
|
* The maximum number of web workers used to compress/decompress data simultaneously.
|
|
274
359
|
*
|
|
360
|
+
* It must be an integer greater than 0, see {@link ERR_INVALID_MAX_WORKERS}.
|
|
361
|
+
*
|
|
275
362
|
* @defaultValue `navigator.hardwareConcurrency`, or 2 when the environment does not provide it
|
|
276
363
|
*/
|
|
277
364
|
maxWorkers?: number;
|
|
@@ -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,6 +405,9 @@ export interface Configuration extends WorkerConfiguration {
|
|
|
311
405
|
* });
|
|
312
406
|
* ```
|
|
313
407
|
*
|
|
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
|
+
*
|
|
314
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;
|
|
@@ -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,6 +457,9 @@ 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;
|
|
@@ -353,33 +468,33 @@ export interface Configuration extends WorkerConfiguration {
|
|
|
353
468
|
*
|
|
354
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
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
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
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
|
}
|
|
@@ -743,6 +855,10 @@ type URLString = string;
|
|
|
743
855
|
* Represents a {@link Reader} instance used to fetch data from a URL.
|
|
744
856
|
*/
|
|
745
857
|
export class HttpReader extends Reader<URLString> {
|
|
858
|
+
/**
|
|
859
|
+
* The URL of the data, as passed to the constructor.
|
|
860
|
+
*/
|
|
861
|
+
url: URLString | URL;
|
|
746
862
|
/**
|
|
747
863
|
* Creates the {@link HttpReader} instance
|
|
748
864
|
*
|
|
@@ -859,6 +975,12 @@ export interface WritableWriter {
|
|
|
859
975
|
* The `WritableStream` instance.
|
|
860
976
|
*/
|
|
861
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;
|
|
862
984
|
/**
|
|
863
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.
|
|
864
986
|
*/
|
|
@@ -895,6 +1017,10 @@ export class Writer<Type> implements Initializable, WritableWriter {
|
|
|
895
1017
|
* The `WritableStream` instance.
|
|
896
1018
|
*/
|
|
897
1019
|
writable: WritableStream;
|
|
1020
|
+
/**
|
|
1021
|
+
* The number of bytes written into the instance.
|
|
1022
|
+
*/
|
|
1023
|
+
size: number;
|
|
898
1024
|
/**
|
|
899
1025
|
* Initializes the instance asynchronously
|
|
900
1026
|
*
|
|
@@ -920,13 +1046,35 @@ export class Writer<Type> implements Initializable, WritableWriter {
|
|
|
920
1046
|
/**
|
|
921
1047
|
* Represents a {@link Writer} instance used to retrieve the written data as a `string`.
|
|
922
1048
|
*/
|
|
923
|
-
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>;
|
|
924
1066
|
/**
|
|
925
1067
|
* Creates the {@link TextWriter} instance
|
|
926
1068
|
*
|
|
927
1069
|
* @param encoding The encoding of the text.
|
|
928
1070
|
*/
|
|
929
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>;
|
|
930
1078
|
}
|
|
931
1079
|
|
|
932
1080
|
/**
|
|
@@ -937,6 +1085,15 @@ export class BlobWriter implements Initializable, WritableWriter {
|
|
|
937
1085
|
* The `WritableStream` instance.
|
|
938
1086
|
*/
|
|
939
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;
|
|
940
1097
|
/**
|
|
941
1098
|
* Initializes the instance asynchronously
|
|
942
1099
|
*/
|
|
@@ -959,6 +1116,11 @@ export class BlobWriter implements Initializable, WritableWriter {
|
|
|
959
1116
|
* Represents a {@link Writer} instance used to retrieve the written data as a Data URI `string` encoded in Base64.
|
|
960
1117
|
*/
|
|
961
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;
|
|
962
1124
|
/**
|
|
963
1125
|
* Creates the {@link Data64URIWriter} instance
|
|
964
1126
|
*
|
|
@@ -975,6 +1137,10 @@ export class SplitDataWriter implements Initializable, WritableWriter {
|
|
|
975
1137
|
* The `WritableStream` instance.
|
|
976
1138
|
*/
|
|
977
1139
|
writable: WritableStream;
|
|
1140
|
+
/**
|
|
1141
|
+
* The number of bytes written into the instance.
|
|
1142
|
+
*/
|
|
1143
|
+
size: number;
|
|
978
1144
|
/**
|
|
979
1145
|
* The number of the disk being written.
|
|
980
1146
|
*/
|
|
@@ -1029,6 +1195,11 @@ export class Uint8ArrayWriter extends Writer<Uint8Array<ArrayBuffer>> {
|
|
|
1029
1195
|
/**
|
|
1030
1196
|
* Represents an instance used to create an unzipped stream.
|
|
1031
1197
|
*
|
|
1198
|
+
* @remarks
|
|
1199
|
+
* The input is entirely read into a `Blob` before the first entry is emitted, because a zip file stores its
|
|
1200
|
+
* central directory at the end. This class is a convenience wrapper around {@link ZipReader} for stream
|
|
1201
|
+
* sources, it does not extract entries while the data is still arriving.
|
|
1202
|
+
*
|
|
1032
1203
|
* @example
|
|
1033
1204
|
* This example will take a zip file, decompress it and then save its files and directories to disk.
|
|
1034
1205
|
* ```
|
|
@@ -1119,6 +1290,13 @@ export class ZipReader<Type> {
|
|
|
1119
1290
|
);
|
|
1120
1291
|
/**
|
|
1121
1292
|
* The global comment of the zip file.
|
|
1293
|
+
*
|
|
1294
|
+
* @remarks
|
|
1295
|
+
* Unlike {@link EntryMetaData#comment}, it is exposed as raw bytes because the zip format defines no
|
|
1296
|
+
* way to record its encoding: section 4.4.26 of the zip specification says nothing about it, and the
|
|
1297
|
+
* end of central directory record has neither a general purpose bit flag nor an extra field, so the
|
|
1298
|
+
* language encoding flag (see Appendix D - Language Encoding (EFS)) cannot apply to it. Decode it with
|
|
1299
|
+
* the encoding agreed with the producer of the zip file.
|
|
1122
1300
|
*/
|
|
1123
1301
|
comment: Uint8Array;
|
|
1124
1302
|
/**
|
|
@@ -1131,9 +1309,13 @@ export class ZipReader<Type> {
|
|
|
1131
1309
|
appendedData?: Uint8Array;
|
|
1132
1310
|
/**
|
|
1133
1311
|
* The data of the digital signature record of the central directory (see
|
|
1134
|
-
* {@link ZipWriterCloseOptions#signCentralDirectory}), if the zip file contains one.
|
|
1135
|
-
*
|
|
1136
|
-
*
|
|
1312
|
+
* {@link ZipWriterCloseOptions#signCentralDirectory}), if the zip file contains one.
|
|
1313
|
+
*
|
|
1314
|
+
* @remarks
|
|
1315
|
+
* zip.js does not verify signatures. The signed data is the central directory records, read at
|
|
1316
|
+
* {@link ZipReader#directoryOffset}, and it never includes the digital signature record itself. Some writers
|
|
1317
|
+
* (e.g. SecureZIP) store that record inside {@link ZipReader#directoryLength}, so verifying the whole declared
|
|
1318
|
+
* range would always fail.
|
|
1137
1319
|
*/
|
|
1138
1320
|
digitalSignature?: Uint8Array;
|
|
1139
1321
|
/**
|
|
@@ -1141,7 +1323,9 @@ export class ZipReader<Type> {
|
|
|
1141
1323
|
*/
|
|
1142
1324
|
directoryOffset?: number;
|
|
1143
1325
|
/**
|
|
1144
|
-
* The length in bytes of the central directory as declared in the end of central directory record.
|
|
1326
|
+
* The length in bytes of the central directory as declared in the end of central directory record. Some
|
|
1327
|
+
* writers (e.g. SecureZIP) include the digital signature record in that length, so subtract
|
|
1328
|
+
* `6 + digitalSignature.length` from it when the record is stored inside the declared range.
|
|
1145
1329
|
*/
|
|
1146
1330
|
directoryLength?: number;
|
|
1147
1331
|
/**
|
|
@@ -1864,13 +2048,24 @@ export interface LocalDirectory {
|
|
|
1864
2048
|
extraFieldUSDZ?: EntryExtraField;
|
|
1865
2049
|
}
|
|
1866
2050
|
/**
|
|
1867
|
-
* Represents an error raised while processing an
|
|
2051
|
+
* Represents an error raised while processing an archive or one of its entries, decorated with context.
|
|
1868
2052
|
*/
|
|
1869
2053
|
export interface EntryError extends Error {
|
|
1870
2054
|
/**
|
|
1871
2055
|
* `true` if the zip file is corrupted because the entry data could not be written entirely.
|
|
1872
2056
|
*/
|
|
1873
2057
|
corruptedEntry?: boolean;
|
|
2058
|
+
/**
|
|
2059
|
+
* The entry whose data overlaps the data of the entry being read, set on the
|
|
2060
|
+
* {@link ERR_OVERLAPPING_ENTRY} error raised by {@link ZipReaderOptions#checkOverlappingEntry}.
|
|
2061
|
+
* It is the only way to identify the other entry of the pair.
|
|
2062
|
+
*/
|
|
2063
|
+
overlappingEntry?: Entry;
|
|
2064
|
+
/**
|
|
2065
|
+
* The ambiguity that was detected, set on the {@link ERR_AMBIGUOUS_ARCHIVE} error raised by
|
|
2066
|
+
* {@link GetEntriesOptions#strictness}. See {@link ERR_AMBIGUOUS_ARCHIVE} for the values it takes.
|
|
2067
|
+
*/
|
|
2068
|
+
reason?: string;
|
|
1874
2069
|
/**
|
|
1875
2070
|
* The id of the related {@link ZipEntry} (filesystem API).
|
|
1876
2071
|
*/
|
|
@@ -2418,6 +2613,10 @@ export class ZipWriter<Type> {
|
|
|
2418
2613
|
* Adds an existing zip file at the beginning of the current zip. This method
|
|
2419
2614
|
* cannot be called after the first call to {@link ZipWriter#add}.
|
|
2420
2615
|
*
|
|
2616
|
+
* @remarks The data of the zip file is copied, its central directory is rebuilt and its entries are relocated to
|
|
2617
|
+
* the positions they get in the output. The disks of a split zip file passed as input are therefore unrelated to
|
|
2618
|
+
* the disks of the output, which is a single zip file unless the writer is a split zip file writer.
|
|
2619
|
+
*
|
|
2421
2620
|
* @param reader The {@link Reader} instance used to read the content of the zip file.
|
|
2422
2621
|
* @returns A promise resolving when the zip file has been added.
|
|
2423
2622
|
*/
|
|
@@ -2466,6 +2665,10 @@ export class ZipWriter<Type> {
|
|
|
2466
2665
|
/**
|
|
2467
2666
|
* Writes the entries directory, writes the global comment, and returns the content of the zip file
|
|
2468
2667
|
*
|
|
2668
|
+
* @remarks
|
|
2669
|
+
* The global comment is passed as raw bytes and the comment of an entry
|
|
2670
|
+
* ({@link ZipWriterAddDataOptions#comment}) as a string on purpose, see {@link ZipReader#comment}.
|
|
2671
|
+
*
|
|
2469
2672
|
* @param comment The global comment of the zip file.
|
|
2470
2673
|
* @param options The options.
|
|
2471
2674
|
* @returns The content of the zip file.
|
|
@@ -2494,6 +2697,13 @@ export interface ZipWriterAddDataOptions
|
|
|
2494
2697
|
executable?: boolean;
|
|
2495
2698
|
/**
|
|
2496
2699
|
* The comment of the entry.
|
|
2700
|
+
*
|
|
2701
|
+
* @remarks
|
|
2702
|
+
* It is a string, unlike the global comment passed to {@link ZipWriter#close}, because the encoding of
|
|
2703
|
+
* the comment of an entry is recorded in the header by the general purpose bit 11 (see Appendix D -
|
|
2704
|
+
* Language Encoding (EFS)), set by {@link ZipWriterConstructorOptions#useUnicodeFileNames}. Passing raw
|
|
2705
|
+
* bytes here throws {@link ERR_INVALID_ENTRY_COMMENT_TYPE} instead of writing their textual
|
|
2706
|
+
* representation.
|
|
2497
2707
|
*/
|
|
2498
2708
|
comment?: string;
|
|
2499
2709
|
/**
|
|
@@ -2651,6 +2861,11 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2651
2861
|
/**
|
|
2652
2862
|
* The last modification date.
|
|
2653
2863
|
*
|
|
2864
|
+
* @remarks
|
|
2865
|
+
* This option and the two below must be `Date` instances: a timestamp expressed in milliseconds, e.g.
|
|
2866
|
+
* {@link File#lastModified}, and an invalid `Date` are both rejected with {@link ERR_INVALID_DATE}. An
|
|
2867
|
+
* invalid `Date` used to be written as an entry carrying no timestamp at all.
|
|
2868
|
+
*
|
|
2654
2869
|
* @defaultValue The current date.
|
|
2655
2870
|
*/
|
|
2656
2871
|
lastModDate?: Date;
|
|
@@ -2747,7 +2962,9 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2747
2962
|
*
|
|
2748
2963
|
* It also selects the MS-DOS platform for {@link ZipWriterConstructorOptions#versionMadeBy} and leaves the Unix
|
|
2749
2964
|
* attributes out of the entries. Setting any Unix metadata option, e.g.
|
|
2750
|
-
* {@link ZipWriterConstructorOptions#unixMode}, turns it back off
|
|
2965
|
+
* {@link ZipWriterConstructorOptions#unixMode} or {@link ZipWriterAddDataOptions#executable}, turns it back off, and setting
|
|
2966
|
+
* {@link ZipWriterConstructorOptions#msdosAttributesRaw} or {@link ZipWriterConstructorOptions#msdosAttributes}
|
|
2967
|
+
* turns it on, overriding an explicit `false`.
|
|
2751
2968
|
*
|
|
2752
2969
|
* @defaultValue false
|
|
2753
2970
|
*/
|
|
@@ -2824,10 +3041,28 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2824
3041
|
/**
|
|
2825
3042
|
* When provided, the low 8-bit MS-DOS attributes to write into external file attributes.
|
|
2826
3043
|
* Must be an integer between 0 and 255.
|
|
3044
|
+
*
|
|
3045
|
+
* @remarks
|
|
3046
|
+
* Setting this option or {@link ZipWriterConstructorOptions#msdosAttributes} selects the MS-DOS platform for
|
|
3047
|
+
* the entry exactly as {@link ZipWriterConstructorOptions#msDosCompatible} does, and overrides that option
|
|
3048
|
+
* when it is explicitly set to `false`. {@link EntryMetaData#versionMadeBy} then loses its Unix upper byte
|
|
3049
|
+
* and no Unix mode is written, so the `0o100644` of a file entry and the `0o040755` of a folder entry are
|
|
3050
|
+
* lost. What counts is that the option is provided, not its value: `0` and `{}` trigger it too.
|
|
3051
|
+
*
|
|
3052
|
+
* Setting any Unix metadata option, i.e. {@link ZipWriterConstructorOptions#uid},
|
|
3053
|
+
* {@link ZipWriterConstructorOptions#gid}, {@link ZipWriterConstructorOptions#unixMode},
|
|
3054
|
+
* {@link ZipWriterConstructorOptions#unixExtraFieldType} or {@link ZipWriterAddDataOptions#executable},
|
|
3055
|
+
* takes precedence and keeps the Unix attributes, with the MS-DOS attributes written into the low byte.
|
|
3056
|
+
* {@link ZipWriterConstructorOptions#externalFileAttributes} is preserved as well, although the entry still
|
|
3057
|
+
* declares the MS-DOS platform.
|
|
2827
3058
|
*/
|
|
2828
3059
|
msdosAttributesRaw?: number;
|
|
2829
3060
|
/**
|
|
2830
3061
|
* When provided, MS-DOS attribute flags (boolean object) to write into external file attributes low byte.
|
|
3062
|
+
*
|
|
3063
|
+
* @remarks
|
|
3064
|
+
* See {@link ZipWriterConstructorOptions#msdosAttributesRaw} for the platform this option selects and for
|
|
3065
|
+
* the Unix metadata it leaves out of the entry.
|
|
2831
3066
|
*/
|
|
2832
3067
|
msdosAttributes?: {
|
|
2833
3068
|
readOnly?: boolean;
|
|
@@ -2855,9 +3090,11 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2855
3090
|
* `true` to write the data as-is without compressing it and without crypting it.
|
|
2856
3091
|
*
|
|
2857
3092
|
* @remarks
|
|
2858
|
-
* The {@link ZipWriterConstructorOptions#level}
|
|
2859
|
-
*
|
|
2860
|
-
*
|
|
3093
|
+
* The data is never compressed, so the {@link ZipWriterConstructorOptions#level} option does not apply and is
|
|
3094
|
+
* ignored. The {@link ZipWriterAddDataOptions#compressionMethod} option selects no codec either, it declares
|
|
3095
|
+
* how the data is already compressed and is written as-is in the entry headers. It must be set, otherwise an
|
|
3096
|
+
* {@link ERR_UNDEFINED_COMPRESSION_METHOD} error is thrown. The entries with no content, e.g. the
|
|
3097
|
+
* directories, ignore this option entirely. Setting the {@link ZipWriterConstructorOptions#password} or the
|
|
2861
3098
|
* {@link ZipWriterConstructorOptions#rawPassword} option throws an
|
|
2862
3099
|
* {@link ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH} error, unless the
|
|
2863
3100
|
* {@link ZipWriterConstructorOptions#encrypted} option is set to `true` to declare that the data is already
|
|
@@ -2944,7 +3181,7 @@ export interface EntryOnprogressOptions {
|
|
|
2944
3181
|
/**
|
|
2945
3182
|
* Represents an entry in a zip file (Filesystem API).
|
|
2946
3183
|
*/
|
|
2947
|
-
|
|
3184
|
+
export class ZipEntry {
|
|
2948
3185
|
/**
|
|
2949
3186
|
* The relative filename of the entry.
|
|
2950
3187
|
*/
|
|
@@ -2973,6 +3210,15 @@ declare class ZipEntry {
|
|
|
2973
3210
|
* The children of the entry.
|
|
2974
3211
|
*/
|
|
2975
3212
|
children: ZipEntry[];
|
|
3213
|
+
/**
|
|
3214
|
+
* The options applied to the entry when the zip file is exported.
|
|
3215
|
+
*
|
|
3216
|
+
* @remarks
|
|
3217
|
+
* These are the options passed when the entry was added to the filesystem, updated by
|
|
3218
|
+
* {@link ZipEntry#setOptions}. An entry imported from a zip file has none until
|
|
3219
|
+
* {@link ZipEntry#setOptions} is called.
|
|
3220
|
+
*/
|
|
3221
|
+
readonly options?: ZipWriterAddDataOptions;
|
|
2976
3222
|
/**
|
|
2977
3223
|
* Clones the entry
|
|
2978
3224
|
*
|
|
@@ -3010,6 +3256,24 @@ declare class ZipEntry {
|
|
|
3010
3256
|
* @param name The new name of the entry.
|
|
3011
3257
|
*/
|
|
3012
3258
|
rename(name: string): void;
|
|
3259
|
+
/**
|
|
3260
|
+
* Sets the options applied to the entry when the zip file is exported
|
|
3261
|
+
*
|
|
3262
|
+
* @remarks
|
|
3263
|
+
* The options are merged into {@link ZipEntry#options}, and an option set to `undefined` is removed
|
|
3264
|
+
* from it instead of being stored. They take precedence over the options passed to
|
|
3265
|
+
* `{@link ZipDirectoryEntry}#export*()` and over the metadata of the entry they were imported from,
|
|
3266
|
+
* exactly like the options passed when adding an entry to the filesystem.
|
|
3267
|
+
*
|
|
3268
|
+
* The options describing the data of an entry exported as-is, e.g.
|
|
3269
|
+
* {@link ZipWriterConstructorOptions#compressionMethod} and
|
|
3270
|
+
* {@link ZipWriterAddDataOptions#uncompressedSize}, are ignored: they are always the ones of the
|
|
3271
|
+
* original entry. The {@link ZipWriterAddDataOptions#directory} option and the progress callbacks
|
|
3272
|
+
* are ignored as well. Invalid option values are reported when the zip file is exported.
|
|
3273
|
+
*
|
|
3274
|
+
* @param options The options.
|
|
3275
|
+
*/
|
|
3276
|
+
setOptions(options: ZipWriterAddDataOptions): void;
|
|
3013
3277
|
}
|
|
3014
3278
|
|
|
3015
3279
|
/**
|
|
@@ -3163,7 +3427,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3163
3427
|
* before the children of its subdirectories, like the result of `readdir(path, { recursive: true })` in
|
|
3164
3428
|
* Node.js. This is also the order in which `{@link ZipDirectoryEntry}#export*()` writes them.
|
|
3165
3429
|
*
|
|
3166
|
-
* Unlike {@link
|
|
3430
|
+
* Unlike {@link ZipFS#entries}, the directory itself is not included and removed entries leave no empty slot.
|
|
3167
3431
|
*
|
|
3168
3432
|
* @param options The options.
|
|
3169
3433
|
* @returns The array of {@link ZipEntry} instances.
|
|
@@ -3377,6 +3641,11 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3377
3641
|
* the same `"a/b.txt"` entry. Filenames are normalized and validated beforehand, see
|
|
3378
3642
|
* {@link GetEntriesOptions#normalizeFilename} and {@link GetEntriesOptions#filenameValidation}.
|
|
3379
3643
|
*
|
|
3644
|
+
* The directories created that way are navigable like any other entry but are not written back when the
|
|
3645
|
+
* tree is exported: only the directories carried by the source zip file and the ones created with
|
|
3646
|
+
* {@link ZipDirectoryEntry#addDirectory} are written. A zip file storing no directory entry therefore
|
|
3647
|
+
* round-trips to a zip file storing no directory entry, instead of gaining one entry per path component.
|
|
3648
|
+
*
|
|
3380
3649
|
* Passing a {@link ZipReader} instance is the way to read the data of the zip file itself, e.g. its
|
|
3381
3650
|
* {@link ZipReader#prependedData} or its {@link ZipReader#comment} property, since the instance created
|
|
3382
3651
|
* otherwise is not exposed. Its options are used as defaults for the options passed here, and it must not
|
|
@@ -3513,7 +3782,7 @@ export interface ZipDirectoryEntryImportHttpOptions
|
|
|
3513
3782
|
HttpOptions {}
|
|
3514
3783
|
|
|
3515
3784
|
/**
|
|
3516
|
-
* Represents the options passed to {@link ZipDirectoryEntry#getChildren} and {@link
|
|
3785
|
+
* Represents the options passed to {@link ZipDirectoryEntry#getChildren} and {@link ZipFS#getChildren}.
|
|
3517
3786
|
*/
|
|
3518
3787
|
export interface ZipDirectoryEntryGetChildrenOptions {
|
|
3519
3788
|
/**
|
|
@@ -3557,6 +3826,13 @@ export interface ZipDirectoryEntryGetChildrenOptions {
|
|
|
3557
3826
|
* {@link ZipDirectoryEntry#exportZip} or {@link ZipDirectoryEntry#exportWritable}. It is ignored by the
|
|
3558
3827
|
* other `{@link ZipDirectoryEntry}#export*()` methods, whose Writer instance can only return its data
|
|
3559
3828
|
* once its writable is closed.
|
|
3829
|
+
*
|
|
3830
|
+
* An entry added without a {@link ZipWriterAddDataOptions#lastModDate} option is dated with the moment
|
|
3831
|
+
* it was added, so exporting an unchanged tree twice produces the same bytes. That date is the weakest
|
|
3832
|
+
* one: it is replaced by the date of the entry the tree was imported from, which is itself replaced by
|
|
3833
|
+
* the {@link ZipWriterConstructorOptions#lastModDate} option passed here, which pins every date of the
|
|
3834
|
+
* exported zip file. Only a {@link ZipWriterAddDataOptions#lastModDate} option passed when the entry
|
|
3835
|
+
* was added takes precedence over all of them.
|
|
3560
3836
|
*/
|
|
3561
3837
|
export interface ZipDirectoryEntryExportOptions
|
|
3562
3838
|
extends ZipWriterConstructorOptions,
|
|
@@ -3620,12 +3896,14 @@ export interface ZipDirectoryEntryExportOptions
|
|
|
3620
3896
|
* The {@link ZipReaderOptions#passThrough} option set here exports the entries imported from a zip
|
|
3621
3897
|
* file as-is, without decompressing and decrypting them, exactly as importing them with this option
|
|
3622
3898
|
* does. It is ignored by the entries added to the filesystem, which are compressed as usual.
|
|
3899
|
+
*
|
|
3900
|
+
* A value which is neither an object nor unset throws an {@link ERR_INVALID_READER_OPTIONS} error.
|
|
3623
3901
|
*/
|
|
3624
3902
|
readerOptions?: ZipReaderConstructorOptions;
|
|
3625
3903
|
}
|
|
3626
3904
|
|
|
3627
3905
|
/**
|
|
3628
|
-
* Represents the options passed to {@link ZipDirectoryEntry#exportFileSystemHandle} and {@link
|
|
3906
|
+
* Represents the options passed to {@link ZipDirectoryEntry#exportFileSystemHandle} and {@link ZipFS#exportFileSystemHandle}.
|
|
3629
3907
|
*
|
|
3630
3908
|
* @remarks
|
|
3631
3909
|
* The {@link ZipReaderOptions#preventClose} option is ignored: the export owns the writable of each
|
|
@@ -3651,6 +3929,8 @@ export interface ZipDirectoryEntryExportFileSystemHandleOptions
|
|
|
3651
3929
|
* These options override the ones passed at the top level. The {@link ZipReaderOptions#password}
|
|
3652
3930
|
* option can be set here or at the top level, unlike {@link ZipDirectoryEntryExportOptions} where
|
|
3653
3931
|
* the top-level password encrypts the exported zip file instead.
|
|
3932
|
+
*
|
|
3933
|
+
* A value which is neither an object nor unset throws an {@link ERR_INVALID_READER_OPTIONS} error.
|
|
3654
3934
|
*/
|
|
3655
3935
|
readerOptions?: ZipReaderConstructorOptions;
|
|
3656
3936
|
}
|
|
@@ -3664,16 +3944,16 @@ export interface ZipDirectoryEntryExportFileSystemHandleOptions
|
|
|
3664
3944
|
* const TEXT_CONTENT = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.";
|
|
3665
3945
|
* const FILENAME = "lorem.txt";
|
|
3666
3946
|
* const BLOB = new Blob([TEXT_CONTENT], { type: zip.getMimeType(FILENAME) });
|
|
3667
|
-
* let zipFs = new zip.
|
|
3947
|
+
* let zipFs = new zip.ZipFS();
|
|
3668
3948
|
* zipFs.addBlob("lorem.txt", BLOB);
|
|
3669
3949
|
* const zippedBlob = await zipFs.exportBlob();
|
|
3670
|
-
* zipFs = new zip.
|
|
3950
|
+
* zipFs = new zip.ZipFS();
|
|
3671
3951
|
* await zipFs.importBlob(zippedBlob);
|
|
3672
3952
|
* const firstEntry = zipFs.children[0];
|
|
3673
3953
|
* const unzippedBlob = await firstEntry.getBlob(zip.getMimeType(firstEntry.name));
|
|
3674
3954
|
* ```
|
|
3675
3955
|
*/
|
|
3676
|
-
export interface
|
|
3956
|
+
export interface ZipFS
|
|
3677
3957
|
extends Pick<
|
|
3678
3958
|
ZipDirectoryEntry,
|
|
3679
3959
|
| "getChildByName"
|
|
@@ -3705,7 +3985,7 @@ export interface FS
|
|
|
3705
3985
|
| "checkPassword"
|
|
3706
3986
|
> {}
|
|
3707
3987
|
|
|
3708
|
-
export class
|
|
3988
|
+
export class ZipFS {
|
|
3709
3989
|
/**
|
|
3710
3990
|
* The root directory.
|
|
3711
3991
|
*/
|
|
@@ -3747,20 +4027,35 @@ export class FS {
|
|
|
3747
4027
|
getById(id: number): ZipEntry | undefined;
|
|
3748
4028
|
}
|
|
3749
4029
|
|
|
4030
|
+
/**
|
|
4031
|
+
* The type of the filesystem.
|
|
4032
|
+
*
|
|
4033
|
+
* @deprecated Use {@link ZipFS} instead.
|
|
4034
|
+
*/
|
|
4035
|
+
export type FS = ZipFS;
|
|
4036
|
+
|
|
3750
4037
|
/**
|
|
3751
4038
|
* The Filesystem API.
|
|
4039
|
+
*
|
|
4040
|
+
* @deprecated Use the {@link ZipFS}, {@link ZipDirectoryEntry} and {@link ZipFileEntry} exports instead.
|
|
3752
4041
|
*/
|
|
3753
4042
|
export const fs: {
|
|
3754
4043
|
/**
|
|
3755
4044
|
* The Filesystem constructor.
|
|
4045
|
+
*
|
|
4046
|
+
* @deprecated Use {@link ZipFS} instead.
|
|
3756
4047
|
*/
|
|
3757
|
-
FS: typeof
|
|
4048
|
+
FS: typeof ZipFS;
|
|
3758
4049
|
/**
|
|
3759
4050
|
* The {@link ZipDirectoryEntry} constructor.
|
|
4051
|
+
*
|
|
4052
|
+
* @deprecated Use the {@link ZipDirectoryEntry} export instead.
|
|
3760
4053
|
*/
|
|
3761
4054
|
ZipDirectoryEntry: typeof ZipDirectoryEntry;
|
|
3762
4055
|
/**
|
|
3763
4056
|
* The {@link ZipFileEntry} constructor.
|
|
4057
|
+
*
|
|
4058
|
+
* @deprecated Use the {@link ZipFileEntry} export instead.
|
|
3764
4059
|
*/
|
|
3765
4060
|
ZipFileEntry: typeof ZipFileEntry;
|
|
3766
4061
|
};
|
|
@@ -3889,14 +4184,59 @@ export const ERR_INVALID_ENTRY_NAME: string;
|
|
|
3889
4184
|
* Invalid entry comment error
|
|
3890
4185
|
*/
|
|
3891
4186
|
export const ERR_INVALID_ENTRY_COMMENT: string;
|
|
4187
|
+
/**
|
|
4188
|
+
* Invalid entry comment type error
|
|
4189
|
+
*/
|
|
4190
|
+
export const ERR_INVALID_ENTRY_COMMENT_TYPE: string;
|
|
4191
|
+
/**
|
|
4192
|
+
* Invalid date error
|
|
4193
|
+
*/
|
|
4194
|
+
export const ERR_INVALID_DATE: string;
|
|
4195
|
+
/**
|
|
4196
|
+
* Invalid function option error
|
|
4197
|
+
*
|
|
4198
|
+
* @remarks
|
|
4199
|
+
* Thrown when an option expecting a function is given a value of another type: {@link ZipWriterConstructorOptions#encodeText},
|
|
4200
|
+
* {@link GetEntriesOptions#decodeText}, {@link ZipWriterConstructorOptions#createTempStream},
|
|
4201
|
+
* {@link ZipWriterCloseOptions#signCentralDirectory} and {@link GetEntriesOptions#decryptCentralDirectory}. It is also
|
|
4202
|
+
* thrown by {@link configure} for {@link Configuration#createWorker}, {@link Configuration#CompressionStream},
|
|
4203
|
+
* {@link Configuration#DecompressionStream}, {@link Configuration#CompressionStreamFallback} and
|
|
4204
|
+
* {@link Configuration#DecompressionStreamFallback}. A falsy value keeps meaning "use the default".
|
|
4205
|
+
*/
|
|
4206
|
+
export const ERR_INVALID_FUNCTION_OPTION: string;
|
|
4207
|
+
/**
|
|
4208
|
+
* Invalid signal error
|
|
4209
|
+
*
|
|
4210
|
+
* @remarks
|
|
4211
|
+
* Thrown when the `signal` option is not an `AbortSignal`. Any object exposing `addEventListener()` and a boolean `aborted`
|
|
4212
|
+
* property is accepted, so a signal coming from another realm keeps working.
|
|
4213
|
+
*/
|
|
4214
|
+
export const ERR_INVALID_SIGNAL: string;
|
|
4215
|
+
/**
|
|
4216
|
+
* Invalid maxWorkers error
|
|
4217
|
+
*
|
|
4218
|
+
* @remarks
|
|
4219
|
+
* Thrown by {@link configure} when {@link Configuration#maxWorkers} is not an integer greater than 0. A value lower than 1
|
|
4220
|
+
* used to deadlock {@link ZipWriter#add} for ever, since no entry could start and none could release the next one. Pass
|
|
4221
|
+
* {@link Configuration#useWebWorkers} set to `false` to compress and decompress data in the main thread instead.
|
|
4222
|
+
*/
|
|
4223
|
+
export const ERR_INVALID_MAX_WORKERS: string;
|
|
3892
4224
|
/**
|
|
3893
4225
|
* Invalid version error
|
|
3894
4226
|
*/
|
|
3895
4227
|
export const ERR_INVALID_VERSION: string;
|
|
4228
|
+
/**
|
|
4229
|
+
* Invalid extra field error
|
|
4230
|
+
*/
|
|
4231
|
+
export const ERR_INVALID_EXTRAFIELD: string;
|
|
3896
4232
|
/**
|
|
3897
4233
|
* Invalid extra field type error
|
|
3898
4234
|
*/
|
|
3899
4235
|
export const ERR_INVALID_EXTRAFIELD_TYPE: string;
|
|
4236
|
+
/**
|
|
4237
|
+
* Invalid extra field data type error
|
|
4238
|
+
*/
|
|
4239
|
+
export const ERR_INVALID_EXTRAFIELD_DATA_TYPE: string;
|
|
3900
4240
|
/**
|
|
3901
4241
|
* Invalid extra field data error
|
|
3902
4242
|
*/
|
|
@@ -3923,12 +4263,29 @@ export const ERR_UNSUPPORTED_FORMAT: string;
|
|
|
3923
4263
|
export const ERR_SPLIT_ZIP_FILE: string;
|
|
3924
4264
|
/**
|
|
3925
4265
|
* Overlapping entry error
|
|
4266
|
+
*
|
|
4267
|
+
* @remarks Thrown by {@link FileEntry#getData} when {@link ZipReaderOptions#checkOverlappingEntry} is set and the
|
|
4268
|
+
* data of the entry overlaps the data of an entry already read. The thrown error carries the other entry in its
|
|
4269
|
+
* `overlappingEntry` property.
|
|
3926
4270
|
*/
|
|
3927
4271
|
export const ERR_OVERLAPPING_ENTRY: string;
|
|
4272
|
+
/**
|
|
4273
|
+
* Entry data out of bounds error
|
|
4274
|
+
*
|
|
4275
|
+
* @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.
|
|
4276
|
+
*/
|
|
4277
|
+
export const ERR_ENTRY_DATA_OUT_OF_BOUNDS: string;
|
|
3928
4278
|
/**
|
|
3929
4279
|
* Ambiguous archive error
|
|
3930
4280
|
*
|
|
3931
|
-
* @remarks The thrown error carries a `reason` property describing the ambiguity: `"appended data"`,
|
|
4281
|
+
* @remarks The thrown error carries a `reason` property describing the ambiguity: `"appended data"`,
|
|
4282
|
+
* `"prepended data"`, `"trailing central directory data"`, `"multiple end of central directory records"`,
|
|
4283
|
+
* `"mismatched zip64 end of central directory record"`, `"duplicate filename"`, or, when
|
|
4284
|
+
* {@link ZipReaderOptions#checkLocalDirectory} compares the local header of an entry with its central
|
|
4285
|
+
* directory record, `"mismatched local file header (filename)"`,
|
|
4286
|
+
* `"mismatched local file header (general purpose bit flag)"`,
|
|
4287
|
+
* `"mismatched local file header (compression method)"` or
|
|
4288
|
+
* `"mismatched local file header (crc32 or sizes)"`.
|
|
3932
4289
|
*/
|
|
3933
4290
|
export const ERR_AMBIGUOUS_ARCHIVE: string;
|
|
3934
4291
|
/**
|
|
@@ -3966,6 +4323,10 @@ export const ERR_ITERATOR_COMPLETED_TOO_SOON: string;
|
|
|
3966
4323
|
* Undefined uncompressed size error
|
|
3967
4324
|
*/
|
|
3968
4325
|
export const ERR_UNDEFINED_UNCOMPRESSED_SIZE: string;
|
|
4326
|
+
/**
|
|
4327
|
+
* Undefined compression method error
|
|
4328
|
+
*/
|
|
4329
|
+
export const ERR_UNDEFINED_COMPRESSION_METHOD: string;
|
|
3969
4330
|
export const ERR_UNDETERMINED_SIZE: string;
|
|
3970
4331
|
/**
|
|
3971
4332
|
* Undefined reader error
|
|
@@ -4023,7 +4384,9 @@ export const ERR_INVALID_LEVEL: string;
|
|
|
4023
4384
|
* Invalid password error (thrown when the `password` option is not a string, or the `rawPassword` option is not a `Uint8Array`)
|
|
4024
4385
|
*
|
|
4025
4386
|
* @remarks A value of another type would silently produce an unencrypted archive, and a `rawPassword` passed as a string
|
|
4026
|
-
* would produce an archive that cannot be opened with the equivalent {@link ZipWriterConstructorOptions#password}.
|
|
4387
|
+
* would produce an archive that cannot be opened with the equivalent {@link ZipWriterConstructorOptions#password}. The
|
|
4388
|
+
* reader applies the same check, where a value of another type used to fail with the unrelated {@link ERR_ENCRYPTED} or
|
|
4389
|
+
* {@link ERR_INVALID_PASSWORD}.
|
|
4027
4390
|
*/
|
|
4028
4391
|
export const ERR_INVALID_PASSWORD_TYPE: string;
|
|
4029
4392
|
/**
|
|
@@ -4036,6 +4399,16 @@ export const ERR_INVALID_PASSWORD_TYPE: string;
|
|
|
4036
4399
|
* or set the {@link ZipWriterAddDataOptions#uncompressedSize} option of each entry holding compressed data.
|
|
4037
4400
|
*/
|
|
4038
4401
|
export const ERR_INVALID_PASS_THROUGH: string;
|
|
4402
|
+
/**
|
|
4403
|
+
* Invalid readerOptions error (thrown by `{@link ZipDirectoryEntry}#export*()`,
|
|
4404
|
+
* {@link ZipDirectoryEntry#getExportedSize} and {@link ZipDirectoryEntry#exportFileSystemHandle} when the
|
|
4405
|
+
* {@link ZipDirectoryEntryExportOptions#readerOptions} option is neither an object nor unset)
|
|
4406
|
+
*
|
|
4407
|
+
* @remarks A value of another type was silently ignored: a password passed as a string instead of an object failed
|
|
4408
|
+
* with the unrelated {@link ERR_ENCRYPTED}, while the other options were dropped without any error. Note that an
|
|
4409
|
+
* unknown property of a `readerOptions` object is still ignored, as everywhere else in the API.
|
|
4410
|
+
*/
|
|
4411
|
+
export const ERR_INVALID_READER_OPTIONS: string;
|
|
4039
4412
|
/**
|
|
4040
4413
|
* Entry already exists error (thrown by the filesystem API when adding an entry whose filename already exists)
|
|
4041
4414
|
*/
|