@zip.js/zip.js 2.8.57 → 2.8.58
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/deno.json +1 -1
- package/dist/zip-core-external.js +303 -163
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +303 -163
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +327 -164
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +344 -157
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +327 -164
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +329 -165
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +330 -166
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +305 -165
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +305 -165
- 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 +306 -166
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +329 -165
- package/index-native.min.js +1 -1
- package/index.cjs +330 -166
- package/index.d.cts +113 -9
- package/index.d.ts +113 -9
- package/index.min.js +1 -1
- package/lib/core/constants.js +2 -0
- 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 +27 -1
- package/lib/core/zip-reader.js +26 -6
- package/lib/core/zip-writer.js +278 -156
- package/lib/core/zlib-streams-inline.js +1 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -983,7 +983,8 @@ export interface WritableWriter {
|
|
|
983
983
|
/**
|
|
984
984
|
* The number of bytes written into the instance. It is set to 0 before the first write and
|
|
985
985
|
* updated as the data is written, so a writer needing the value (e.g. to compute the offset of a
|
|
986
|
-
* disk) can read it.
|
|
986
|
+
* disk) can read it. A value set before the first write is kept and used as the starting offset
|
|
987
|
+
* instead of being reset to 0.
|
|
987
988
|
*/
|
|
988
989
|
size?: number;
|
|
989
990
|
/**
|
|
@@ -1280,6 +1281,13 @@ export class ZipReader<Type> {
|
|
|
1280
1281
|
/**
|
|
1281
1282
|
* Creates the instance
|
|
1282
1283
|
*
|
|
1284
|
+
* @remarks
|
|
1285
|
+
* Reading a zip file requires random access because the central directory located at the end of the
|
|
1286
|
+
* file is read first. A `ReadableStream` instance, or an object providing only a `readable` property
|
|
1287
|
+
* (e.g. a file handle), is therefore buffered entirely in memory when the instance is initialized. To
|
|
1288
|
+
* read a large seekable resource without buffering it, pass a custom {@link Reader} implementation
|
|
1289
|
+
* that reads the requested byte ranges directly.
|
|
1290
|
+
*
|
|
1283
1291
|
* @param reader The {@link Reader} instance used to read data.
|
|
1284
1292
|
* @param options The options.
|
|
1285
1293
|
*/
|
|
@@ -1957,6 +1965,12 @@ export interface LocalDirectory {
|
|
|
1957
1965
|
* The length of the extra field in bytes.
|
|
1958
1966
|
*/
|
|
1959
1967
|
extraFieldLength: number;
|
|
1968
|
+
/**
|
|
1969
|
+
* The byte offset of the entry data, i.e. {@link EntryMetaData#offset} plus the size of the local file header,
|
|
1970
|
+
* of the filename and of the extra field. It can be used with {@link Reader#createReadable} to read the stored
|
|
1971
|
+
* data directly, e.g. to serve ranged requests into an entry compressed with the `"store"` method.
|
|
1972
|
+
*/
|
|
1973
|
+
dataOffset: number;
|
|
1960
1974
|
/**
|
|
1961
1975
|
* The extra field (raw).
|
|
1962
1976
|
*/
|
|
@@ -2316,9 +2330,6 @@ export interface EntryMetaData {
|
|
|
2316
2330
|
* The upper 16-bit portion of {@link EntryMetaData#externalFileAttributes} when it represents Unix mode bits.
|
|
2317
2331
|
*/
|
|
2318
2332
|
unixExternalUpper?: number;
|
|
2319
|
-
/**
|
|
2320
|
-
* The number of the disk where the entry data starts.
|
|
2321
|
-
*/
|
|
2322
2333
|
/**
|
|
2323
2334
|
* The internal file attribute (raw).
|
|
2324
2335
|
* @deprecated Use {@link EntryMetaData#internalFileAttributes} instead.
|
|
@@ -2561,6 +2572,11 @@ export class ZipWriterStream {
|
|
|
2561
2572
|
/**
|
|
2562
2573
|
* Writes the entries directory, writes the global comment, and returns the content of the zipped file.
|
|
2563
2574
|
*
|
|
2575
|
+
* @remarks
|
|
2576
|
+
* If an entry could not be written, this method aborts the zipped stream with the error — the
|
|
2577
|
+
* readable side of the stream fails instead of ending — and throws it. The `entryErrors` property
|
|
2578
|
+
* of the thrown error contains the errors of all the failed entries.
|
|
2579
|
+
*
|
|
2564
2580
|
* @param comment The global comment of the zip file.
|
|
2565
2581
|
* @param options The options.
|
|
2566
2582
|
* @returns The content of the zip file.
|
|
@@ -2614,13 +2630,45 @@ export class ZipWriter<Type> {
|
|
|
2614
2630
|
*/
|
|
2615
2631
|
readonly hasCorruptedEntries?: boolean;
|
|
2616
2632
|
|
|
2633
|
+
/**
|
|
2634
|
+
* Adds the entries of an existing zip file into the current zip. This method can be called at any
|
|
2635
|
+
* time, including between calls to {@link ZipWriter#add} and repeatedly to merge several zip files.
|
|
2636
|
+
*
|
|
2637
|
+
* @remarks
|
|
2638
|
+
* The data of the zip file is copied, its central directory is rebuilt and its entries are relocated to
|
|
2639
|
+
* the positions they get in the output. The disks of a split zip file passed as input are therefore unrelated to
|
|
2640
|
+
* the disks of the output, which is a single zip file unless the writer is a split zip file writer. The data of
|
|
2641
|
+
* the entries is copied as-is; in particular, the constraints set by {@link ZipWriterConstructorOptions#usdz}
|
|
2642
|
+
* are not applied to the copied entries.
|
|
2643
|
+
*
|
|
2644
|
+
* Pending {@link ZipWriter#add} calls are completed before the data is copied, and add() calls made
|
|
2645
|
+
* while the copy is in progress are written after it. If an entry of the zip file has the same
|
|
2646
|
+
* filename as an entry of the current zip, the method throws with the `ERR_DUPLICATED_NAME` error
|
|
2647
|
+
* message and leaves the current zip unchanged; call {@link ZipWriter#remove} beforehand to resolve
|
|
2648
|
+
* the conflicts.
|
|
2649
|
+
*
|
|
2650
|
+
* The returned promise can safely be left un-awaited: {@link ZipWriter#close} waits for the copy
|
|
2651
|
+
* and throws its error if it was not caught.
|
|
2652
|
+
*
|
|
2653
|
+
* @param reader The {@link Reader} instance used to read the content of the zip file.
|
|
2654
|
+
* @returns A promise resolving when the zip file has been added.
|
|
2655
|
+
*/
|
|
2656
|
+
appendZip<ReaderType>(
|
|
2657
|
+
reader:
|
|
2658
|
+
| Reader<ReaderType>
|
|
2659
|
+
| ReadableReader
|
|
2660
|
+
| ReadableStream
|
|
2661
|
+
| Reader<unknown>[]
|
|
2662
|
+
| ReadableReader[]
|
|
2663
|
+
| ReadableStream[]
|
|
2664
|
+
): Promise<void>;
|
|
2665
|
+
|
|
2617
2666
|
/**
|
|
2618
2667
|
* Adds an existing zip file at the beginning of the current zip. This method
|
|
2619
2668
|
* cannot be called after the first call to {@link ZipWriter#add}.
|
|
2620
2669
|
*
|
|
2621
|
-
* @
|
|
2622
|
-
*
|
|
2623
|
-
* the disks of the output, which is a single zip file unless the writer is a split zip file writer.
|
|
2670
|
+
* @deprecated Use {@link ZipWriter#appendZip} instead, which is equivalent when the zip file is
|
|
2671
|
+
* empty and can also be called after entries have been added.
|
|
2624
2672
|
*
|
|
2625
2673
|
* @param reader The {@link Reader} instance used to read the content of the zip file.
|
|
2626
2674
|
* @returns A promise resolving when the zip file has been added.
|
|
@@ -2638,6 +2686,10 @@ export class ZipWriter<Type> {
|
|
|
2638
2686
|
/**
|
|
2639
2687
|
* Adds an entry into the zip file
|
|
2640
2688
|
*
|
|
2689
|
+
* @remarks
|
|
2690
|
+
* The returned promise can safely be left un-awaited: {@link ZipWriter#close} waits for the entry
|
|
2691
|
+
* and throws its error if it was not caught.
|
|
2692
|
+
*
|
|
2641
2693
|
* @param filename The filename of the entry. Paths must use forward slashes ("/") as separator,
|
|
2642
2694
|
* as required by section 4.4.17.1 of the zip specification. The value is stored as-is; in
|
|
2643
2695
|
* particular, Windows path separators ("\\") are not converted and become part of the filename,
|
|
@@ -2674,6 +2726,14 @@ export class ZipWriter<Type> {
|
|
|
2674
2726
|
* The global comment is passed as raw bytes and the comment of an entry
|
|
2675
2727
|
* ({@link ZipWriterAddDataOptions#comment}) as a string on purpose, see {@link ZipReader#comment}.
|
|
2676
2728
|
*
|
|
2729
|
+
* If {@link ZipWriter#add} or {@link ZipWriter#appendZip} calls failed and their rejection was
|
|
2730
|
+
* never handled — e.g. the returned promise was not awaited — this method throws the first of
|
|
2731
|
+
* these errors instead of finalizing the zip file. The `entryErrors` property of the thrown error
|
|
2732
|
+
* contains all of them. Errors already caught by the caller do not resurface here, so entries can
|
|
2733
|
+
* still be skipped by awaiting {@link ZipWriter#add} and catching the error. Throwing the errors
|
|
2734
|
+
* counts as reporting them: catching the error of this method and calling it again finalizes the
|
|
2735
|
+
* zip file without the failed entries.
|
|
2736
|
+
*
|
|
2677
2737
|
* @param comment The global comment of the zip file.
|
|
2678
2738
|
* @param options The options.
|
|
2679
2739
|
* @returns The content of the zip file.
|
|
@@ -2874,6 +2934,17 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2874
2934
|
* @defaultValue The current date.
|
|
2875
2935
|
*/
|
|
2876
2936
|
lastModDate?: Date;
|
|
2937
|
+
/**
|
|
2938
|
+
* The last modification date, as its raw 32-bit MS-DOS date and time value.
|
|
2939
|
+
*
|
|
2940
|
+
* @remarks
|
|
2941
|
+
* The value is written verbatim into the local and central directory headers and takes precedence over
|
|
2942
|
+
* {@link ZipWriterConstructorOptions#lastModDate}, which still fills the extended timestamp and NTFS extra
|
|
2943
|
+
* fields. The filesystem API sets it when exporting entries with {@link ZipReaderOptions#passThrough} set in
|
|
2944
|
+
* {@link ZipDirectoryEntryExportOptions#readerOptions}, so that the entries copied as-is keep the exact date
|
|
2945
|
+
* and time of the source zip file.
|
|
2946
|
+
*/
|
|
2947
|
+
rawLastModDate?: number;
|
|
2877
2948
|
/**
|
|
2878
2949
|
* The last access date.
|
|
2879
2950
|
*
|
|
@@ -2920,7 +2991,11 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2920
2991
|
*/
|
|
2921
2992
|
zipCrypto?: boolean;
|
|
2922
2993
|
/**
|
|
2923
|
-
* The "Version" field.
|
|
2994
|
+
* The "Version" field, i.e. the minimum version needed to extract the entry.
|
|
2995
|
+
*
|
|
2996
|
+
* @defaultValue the minimum version required by the features of the entry: 10 for entries stored without
|
|
2997
|
+
* compression or encryption, 20 for deflated, folder or ZipCrypto-encrypted entries, raised to 45 for Zip64
|
|
2998
|
+
* entries and 51 for AES-encrypted entries.
|
|
2924
2999
|
*/
|
|
2925
3000
|
version?: number;
|
|
2926
3001
|
/**
|
|
@@ -2942,7 +3017,9 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2942
3017
|
* `true` to mark the file names as UTF-8 setting the general purpose bit 11 in the header (see Appendix D -
|
|
2943
3018
|
* Language Encoding (EFS)), `false` to mark the names as compliant with the original IBM Code Page 437.
|
|
2944
3019
|
*
|
|
2945
|
-
* Note that this does not ensure that the file names are in the correct
|
|
3020
|
+
* Note that this option only sets the flag, it does not ensure that the file names are in the correct
|
|
3021
|
+
* encoding: when it is set to `false`, the names are still encoded in UTF-8 unless the
|
|
3022
|
+
* {@link ZipWriterConstructorOptions#encodeText} option is also set to encode them in the intended code page.
|
|
2946
3023
|
*
|
|
2947
3024
|
* @defaultValue true
|
|
2948
3025
|
*/
|
|
@@ -2973,6 +3050,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2973
3050
|
* {@link ZipWriterConstructorOptions#msdosAttributesRaw} or {@link ZipWriterConstructorOptions#msdosAttributes}
|
|
2974
3051
|
* turns it on, overriding an explicit `false`.
|
|
2975
3052
|
*
|
|
3053
|
+
* MS-DOS era extractors, e.g. PKUNZIP 2.04g, only honor the directory attribute of entries declaring the
|
|
3054
|
+
* MS-DOS platform. Without this option, they extract folder entries as zero-length files, which can then
|
|
3055
|
+
* prevent extracting the files stored below the folders.
|
|
3056
|
+
*
|
|
2976
3057
|
* @defaultValue false
|
|
2977
3058
|
*/
|
|
2978
3059
|
msDosCompatible?: boolean;
|
|
@@ -3093,6 +3174,11 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3093
3174
|
* {@link ZipWriterAddDataOptions#compressionMethod} options are set explicitly. Setting the
|
|
3094
3175
|
* {@link ZipWriterConstructorOptions#password} option throws an {@link ERR_UNSUPPORTED_ENCRYPTION_USDZ} error.
|
|
3095
3176
|
*
|
|
3177
|
+
* These constraints apply to the entries written with {@link ZipWriter#add} only. The entries copied with
|
|
3178
|
+
* {@link ZipWriter#appendZip} keep the layout of the source zip file and are not checked, so appending a
|
|
3179
|
+
* zip file that does not comply with the USDZ specification, or appending it when the size of the output
|
|
3180
|
+
* is not a multiple of 64 bytes, silently produces a non-compliant file.
|
|
3181
|
+
*
|
|
3096
3182
|
* @defaultValue false
|
|
3097
3183
|
*/
|
|
3098
3184
|
usdz?: boolean;
|
|
@@ -3110,6 +3196,13 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3110
3196
|
* {@link ZipWriterConstructorOptions#encrypted} option is set to `true` to declare that the data is already
|
|
3111
3197
|
* encrypted. In that case the password encrypts the other entries only, and the data written as-is keeps the
|
|
3112
3198
|
* password it was encrypted with, which is not verified.
|
|
3199
|
+
*
|
|
3200
|
+
* When the data was encrypted with ZipCrypto, the verification byte stored in the encrypted data depends on
|
|
3201
|
+
* the last modification date of the source entry if the data descriptor is used. The
|
|
3202
|
+
* {@link ZipWriterConstructorOptions#dataDescriptor} and {@link ZipWriterConstructorOptions#rawLastModDate}
|
|
3203
|
+
* values of the source entry must then be forwarded, otherwise reading the copied entry fails with an
|
|
3204
|
+
* {@link ERR_INVALID_PASSWORD} error. The filesystem API forwards them when exporting entries and throws an
|
|
3205
|
+
* {@link ERR_ZIP_CRYPTO_LAST_MOD_DATE} error if the date is overridden.
|
|
3113
3206
|
*/
|
|
3114
3207
|
passThrough?: boolean;
|
|
3115
3208
|
/**
|
|
@@ -4426,6 +4519,17 @@ export const ERR_INVALID_PASS_THROUGH: string;
|
|
|
4426
4519
|
* unknown property of a `readerOptions` object is still ignored, as everywhere else in the API.
|
|
4427
4520
|
*/
|
|
4428
4521
|
export const ERR_INVALID_READER_OPTIONS: string;
|
|
4522
|
+
/**
|
|
4523
|
+
* Locked last modification date error (thrown by `{@link ZipDirectoryEntry}#export*()` and
|
|
4524
|
+
* {@link ZipDirectoryEntry#getExportedSize} when the date of an entry encrypted with ZipCrypto and exported with
|
|
4525
|
+
* {@link ZipReaderOptions#passThrough} set in {@link ZipDirectoryEntryExportOptions#readerOptions} is changed)
|
|
4526
|
+
*
|
|
4527
|
+
* @remarks The ZipCrypto encryption header embeds a password verification byte derived from the time of the
|
|
4528
|
+
* entry: the encrypted data, copied as-is, only decrypts when the time in the rewritten headers still matches.
|
|
4529
|
+
* The error is thrown when the new date would prevent the entry from being decrypted; changes which keep the
|
|
4530
|
+
* verification byte intact, e.g. a change of the day only, are written normally.
|
|
4531
|
+
*/
|
|
4532
|
+
export const ERR_ZIP_CRYPTO_LAST_MOD_DATE: string;
|
|
4429
4533
|
/**
|
|
4430
4534
|
* Entry already exists error (thrown by the filesystem API when adding an entry whose filename already exists)
|
|
4431
4535
|
*/
|
package/index.d.ts
CHANGED
|
@@ -983,7 +983,8 @@ export interface WritableWriter {
|
|
|
983
983
|
/**
|
|
984
984
|
* The number of bytes written into the instance. It is set to 0 before the first write and
|
|
985
985
|
* updated as the data is written, so a writer needing the value (e.g. to compute the offset of a
|
|
986
|
-
* disk) can read it.
|
|
986
|
+
* disk) can read it. A value set before the first write is kept and used as the starting offset
|
|
987
|
+
* instead of being reset to 0.
|
|
987
988
|
*/
|
|
988
989
|
size?: number;
|
|
989
990
|
/**
|
|
@@ -1280,6 +1281,13 @@ export class ZipReader<Type> {
|
|
|
1280
1281
|
/**
|
|
1281
1282
|
* Creates the instance
|
|
1282
1283
|
*
|
|
1284
|
+
* @remarks
|
|
1285
|
+
* Reading a zip file requires random access because the central directory located at the end of the
|
|
1286
|
+
* file is read first. A `ReadableStream` instance, or an object providing only a `readable` property
|
|
1287
|
+
* (e.g. a file handle), is therefore buffered entirely in memory when the instance is initialized. To
|
|
1288
|
+
* read a large seekable resource without buffering it, pass a custom {@link Reader} implementation
|
|
1289
|
+
* that reads the requested byte ranges directly.
|
|
1290
|
+
*
|
|
1283
1291
|
* @param reader The {@link Reader} instance used to read data.
|
|
1284
1292
|
* @param options The options.
|
|
1285
1293
|
*/
|
|
@@ -1957,6 +1965,12 @@ export interface LocalDirectory {
|
|
|
1957
1965
|
* The length of the extra field in bytes.
|
|
1958
1966
|
*/
|
|
1959
1967
|
extraFieldLength: number;
|
|
1968
|
+
/**
|
|
1969
|
+
* The byte offset of the entry data, i.e. {@link EntryMetaData#offset} plus the size of the local file header,
|
|
1970
|
+
* of the filename and of the extra field. It can be used with {@link Reader#createReadable} to read the stored
|
|
1971
|
+
* data directly, e.g. to serve ranged requests into an entry compressed with the `"store"` method.
|
|
1972
|
+
*/
|
|
1973
|
+
dataOffset: number;
|
|
1960
1974
|
/**
|
|
1961
1975
|
* The extra field (raw).
|
|
1962
1976
|
*/
|
|
@@ -2316,9 +2330,6 @@ export interface EntryMetaData {
|
|
|
2316
2330
|
* The upper 16-bit portion of {@link EntryMetaData#externalFileAttributes} when it represents Unix mode bits.
|
|
2317
2331
|
*/
|
|
2318
2332
|
unixExternalUpper?: number;
|
|
2319
|
-
/**
|
|
2320
|
-
* The number of the disk where the entry data starts.
|
|
2321
|
-
*/
|
|
2322
2333
|
/**
|
|
2323
2334
|
* The internal file attribute (raw).
|
|
2324
2335
|
* @deprecated Use {@link EntryMetaData#internalFileAttributes} instead.
|
|
@@ -2561,6 +2572,11 @@ export class ZipWriterStream {
|
|
|
2561
2572
|
/**
|
|
2562
2573
|
* Writes the entries directory, writes the global comment, and returns the content of the zipped file.
|
|
2563
2574
|
*
|
|
2575
|
+
* @remarks
|
|
2576
|
+
* If an entry could not be written, this method aborts the zipped stream with the error — the
|
|
2577
|
+
* readable side of the stream fails instead of ending — and throws it. The `entryErrors` property
|
|
2578
|
+
* of the thrown error contains the errors of all the failed entries.
|
|
2579
|
+
*
|
|
2564
2580
|
* @param comment The global comment of the zip file.
|
|
2565
2581
|
* @param options The options.
|
|
2566
2582
|
* @returns The content of the zip file.
|
|
@@ -2614,13 +2630,45 @@ export class ZipWriter<Type> {
|
|
|
2614
2630
|
*/
|
|
2615
2631
|
readonly hasCorruptedEntries?: boolean;
|
|
2616
2632
|
|
|
2633
|
+
/**
|
|
2634
|
+
* Adds the entries of an existing zip file into the current zip. This method can be called at any
|
|
2635
|
+
* time, including between calls to {@link ZipWriter#add} and repeatedly to merge several zip files.
|
|
2636
|
+
*
|
|
2637
|
+
* @remarks
|
|
2638
|
+
* The data of the zip file is copied, its central directory is rebuilt and its entries are relocated to
|
|
2639
|
+
* the positions they get in the output. The disks of a split zip file passed as input are therefore unrelated to
|
|
2640
|
+
* the disks of the output, which is a single zip file unless the writer is a split zip file writer. The data of
|
|
2641
|
+
* the entries is copied as-is; in particular, the constraints set by {@link ZipWriterConstructorOptions#usdz}
|
|
2642
|
+
* are not applied to the copied entries.
|
|
2643
|
+
*
|
|
2644
|
+
* Pending {@link ZipWriter#add} calls are completed before the data is copied, and add() calls made
|
|
2645
|
+
* while the copy is in progress are written after it. If an entry of the zip file has the same
|
|
2646
|
+
* filename as an entry of the current zip, the method throws with the `ERR_DUPLICATED_NAME` error
|
|
2647
|
+
* message and leaves the current zip unchanged; call {@link ZipWriter#remove} beforehand to resolve
|
|
2648
|
+
* the conflicts.
|
|
2649
|
+
*
|
|
2650
|
+
* The returned promise can safely be left un-awaited: {@link ZipWriter#close} waits for the copy
|
|
2651
|
+
* and throws its error if it was not caught.
|
|
2652
|
+
*
|
|
2653
|
+
* @param reader The {@link Reader} instance used to read the content of the zip file.
|
|
2654
|
+
* @returns A promise resolving when the zip file has been added.
|
|
2655
|
+
*/
|
|
2656
|
+
appendZip<ReaderType>(
|
|
2657
|
+
reader:
|
|
2658
|
+
| Reader<ReaderType>
|
|
2659
|
+
| ReadableReader
|
|
2660
|
+
| ReadableStream
|
|
2661
|
+
| Reader<unknown>[]
|
|
2662
|
+
| ReadableReader[]
|
|
2663
|
+
| ReadableStream[]
|
|
2664
|
+
): Promise<void>;
|
|
2665
|
+
|
|
2617
2666
|
/**
|
|
2618
2667
|
* Adds an existing zip file at the beginning of the current zip. This method
|
|
2619
2668
|
* cannot be called after the first call to {@link ZipWriter#add}.
|
|
2620
2669
|
*
|
|
2621
|
-
* @
|
|
2622
|
-
*
|
|
2623
|
-
* the disks of the output, which is a single zip file unless the writer is a split zip file writer.
|
|
2670
|
+
* @deprecated Use {@link ZipWriter#appendZip} instead, which is equivalent when the zip file is
|
|
2671
|
+
* empty and can also be called after entries have been added.
|
|
2624
2672
|
*
|
|
2625
2673
|
* @param reader The {@link Reader} instance used to read the content of the zip file.
|
|
2626
2674
|
* @returns A promise resolving when the zip file has been added.
|
|
@@ -2638,6 +2686,10 @@ export class ZipWriter<Type> {
|
|
|
2638
2686
|
/**
|
|
2639
2687
|
* Adds an entry into the zip file
|
|
2640
2688
|
*
|
|
2689
|
+
* @remarks
|
|
2690
|
+
* The returned promise can safely be left un-awaited: {@link ZipWriter#close} waits for the entry
|
|
2691
|
+
* and throws its error if it was not caught.
|
|
2692
|
+
*
|
|
2641
2693
|
* @param filename The filename of the entry. Paths must use forward slashes ("/") as separator,
|
|
2642
2694
|
* as required by section 4.4.17.1 of the zip specification. The value is stored as-is; in
|
|
2643
2695
|
* particular, Windows path separators ("\\") are not converted and become part of the filename,
|
|
@@ -2674,6 +2726,14 @@ export class ZipWriter<Type> {
|
|
|
2674
2726
|
* The global comment is passed as raw bytes and the comment of an entry
|
|
2675
2727
|
* ({@link ZipWriterAddDataOptions#comment}) as a string on purpose, see {@link ZipReader#comment}.
|
|
2676
2728
|
*
|
|
2729
|
+
* If {@link ZipWriter#add} or {@link ZipWriter#appendZip} calls failed and their rejection was
|
|
2730
|
+
* never handled — e.g. the returned promise was not awaited — this method throws the first of
|
|
2731
|
+
* these errors instead of finalizing the zip file. The `entryErrors` property of the thrown error
|
|
2732
|
+
* contains all of them. Errors already caught by the caller do not resurface here, so entries can
|
|
2733
|
+
* still be skipped by awaiting {@link ZipWriter#add} and catching the error. Throwing the errors
|
|
2734
|
+
* counts as reporting them: catching the error of this method and calling it again finalizes the
|
|
2735
|
+
* zip file without the failed entries.
|
|
2736
|
+
*
|
|
2677
2737
|
* @param comment The global comment of the zip file.
|
|
2678
2738
|
* @param options The options.
|
|
2679
2739
|
* @returns The content of the zip file.
|
|
@@ -2874,6 +2934,17 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2874
2934
|
* @defaultValue The current date.
|
|
2875
2935
|
*/
|
|
2876
2936
|
lastModDate?: Date;
|
|
2937
|
+
/**
|
|
2938
|
+
* The last modification date, as its raw 32-bit MS-DOS date and time value.
|
|
2939
|
+
*
|
|
2940
|
+
* @remarks
|
|
2941
|
+
* The value is written verbatim into the local and central directory headers and takes precedence over
|
|
2942
|
+
* {@link ZipWriterConstructorOptions#lastModDate}, which still fills the extended timestamp and NTFS extra
|
|
2943
|
+
* fields. The filesystem API sets it when exporting entries with {@link ZipReaderOptions#passThrough} set in
|
|
2944
|
+
* {@link ZipDirectoryEntryExportOptions#readerOptions}, so that the entries copied as-is keep the exact date
|
|
2945
|
+
* and time of the source zip file.
|
|
2946
|
+
*/
|
|
2947
|
+
rawLastModDate?: number;
|
|
2877
2948
|
/**
|
|
2878
2949
|
* The last access date.
|
|
2879
2950
|
*
|
|
@@ -2920,7 +2991,11 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2920
2991
|
*/
|
|
2921
2992
|
zipCrypto?: boolean;
|
|
2922
2993
|
/**
|
|
2923
|
-
* The "Version" field.
|
|
2994
|
+
* The "Version" field, i.e. the minimum version needed to extract the entry.
|
|
2995
|
+
*
|
|
2996
|
+
* @defaultValue the minimum version required by the features of the entry: 10 for entries stored without
|
|
2997
|
+
* compression or encryption, 20 for deflated, folder or ZipCrypto-encrypted entries, raised to 45 for Zip64
|
|
2998
|
+
* entries and 51 for AES-encrypted entries.
|
|
2924
2999
|
*/
|
|
2925
3000
|
version?: number;
|
|
2926
3001
|
/**
|
|
@@ -2942,7 +3017,9 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2942
3017
|
* `true` to mark the file names as UTF-8 setting the general purpose bit 11 in the header (see Appendix D -
|
|
2943
3018
|
* Language Encoding (EFS)), `false` to mark the names as compliant with the original IBM Code Page 437.
|
|
2944
3019
|
*
|
|
2945
|
-
* Note that this does not ensure that the file names are in the correct
|
|
3020
|
+
* Note that this option only sets the flag, it does not ensure that the file names are in the correct
|
|
3021
|
+
* encoding: when it is set to `false`, the names are still encoded in UTF-8 unless the
|
|
3022
|
+
* {@link ZipWriterConstructorOptions#encodeText} option is also set to encode them in the intended code page.
|
|
2946
3023
|
*
|
|
2947
3024
|
* @defaultValue true
|
|
2948
3025
|
*/
|
|
@@ -2973,6 +3050,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2973
3050
|
* {@link ZipWriterConstructorOptions#msdosAttributesRaw} or {@link ZipWriterConstructorOptions#msdosAttributes}
|
|
2974
3051
|
* turns it on, overriding an explicit `false`.
|
|
2975
3052
|
*
|
|
3053
|
+
* MS-DOS era extractors, e.g. PKUNZIP 2.04g, only honor the directory attribute of entries declaring the
|
|
3054
|
+
* MS-DOS platform. Without this option, they extract folder entries as zero-length files, which can then
|
|
3055
|
+
* prevent extracting the files stored below the folders.
|
|
3056
|
+
*
|
|
2976
3057
|
* @defaultValue false
|
|
2977
3058
|
*/
|
|
2978
3059
|
msDosCompatible?: boolean;
|
|
@@ -3093,6 +3174,11 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3093
3174
|
* {@link ZipWriterAddDataOptions#compressionMethod} options are set explicitly. Setting the
|
|
3094
3175
|
* {@link ZipWriterConstructorOptions#password} option throws an {@link ERR_UNSUPPORTED_ENCRYPTION_USDZ} error.
|
|
3095
3176
|
*
|
|
3177
|
+
* These constraints apply to the entries written with {@link ZipWriter#add} only. The entries copied with
|
|
3178
|
+
* {@link ZipWriter#appendZip} keep the layout of the source zip file and are not checked, so appending a
|
|
3179
|
+
* zip file that does not comply with the USDZ specification, or appending it when the size of the output
|
|
3180
|
+
* is not a multiple of 64 bytes, silently produces a non-compliant file.
|
|
3181
|
+
*
|
|
3096
3182
|
* @defaultValue false
|
|
3097
3183
|
*/
|
|
3098
3184
|
usdz?: boolean;
|
|
@@ -3110,6 +3196,13 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3110
3196
|
* {@link ZipWriterConstructorOptions#encrypted} option is set to `true` to declare that the data is already
|
|
3111
3197
|
* encrypted. In that case the password encrypts the other entries only, and the data written as-is keeps the
|
|
3112
3198
|
* password it was encrypted with, which is not verified.
|
|
3199
|
+
*
|
|
3200
|
+
* When the data was encrypted with ZipCrypto, the verification byte stored in the encrypted data depends on
|
|
3201
|
+
* the last modification date of the source entry if the data descriptor is used. The
|
|
3202
|
+
* {@link ZipWriterConstructorOptions#dataDescriptor} and {@link ZipWriterConstructorOptions#rawLastModDate}
|
|
3203
|
+
* values of the source entry must then be forwarded, otherwise reading the copied entry fails with an
|
|
3204
|
+
* {@link ERR_INVALID_PASSWORD} error. The filesystem API forwards them when exporting entries and throws an
|
|
3205
|
+
* {@link ERR_ZIP_CRYPTO_LAST_MOD_DATE} error if the date is overridden.
|
|
3113
3206
|
*/
|
|
3114
3207
|
passThrough?: boolean;
|
|
3115
3208
|
/**
|
|
@@ -4426,6 +4519,17 @@ export const ERR_INVALID_PASS_THROUGH: string;
|
|
|
4426
4519
|
* unknown property of a `readerOptions` object is still ignored, as everywhere else in the API.
|
|
4427
4520
|
*/
|
|
4428
4521
|
export const ERR_INVALID_READER_OPTIONS: string;
|
|
4522
|
+
/**
|
|
4523
|
+
* Locked last modification date error (thrown by `{@link ZipDirectoryEntry}#export*()` and
|
|
4524
|
+
* {@link ZipDirectoryEntry#getExportedSize} when the date of an entry encrypted with ZipCrypto and exported with
|
|
4525
|
+
* {@link ZipReaderOptions#passThrough} set in {@link ZipDirectoryEntryExportOptions#readerOptions} is changed)
|
|
4526
|
+
*
|
|
4527
|
+
* @remarks The ZipCrypto encryption header embeds a password verification byte derived from the time of the
|
|
4528
|
+
* entry: the encrypted data, copied as-is, only decrypts when the time in the rewritten headers still matches.
|
|
4529
|
+
* The error is thrown when the new date would prevent the entry from being decrypted; changes which keep the
|
|
4530
|
+
* verification byte intact, e.g. a change of the day only, are written normally.
|
|
4531
|
+
*/
|
|
4532
|
+
export const ERR_ZIP_CRYPTO_LAST_MOD_DATE: string;
|
|
4429
4533
|
/**
|
|
4430
4534
|
* Entry already exists error (thrown by the filesystem API when adding an entry whose filename already exists)
|
|
4431
4535
|
*/
|