@zip.js/zip.js 2.8.51 → 2.8.52

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/index.d.ts CHANGED
@@ -395,6 +395,8 @@ export interface WorkerConfiguration {
395
395
  /**
396
396
  * `true` to use the native API `CompressionStream`/`DecompressionStream` to compress/decompress data.
397
397
  *
398
+ * When compressing, the native API is only used when `level` is undefined or equal to 6, see {@link ZipWriterConstructorOptions#level}.
399
+ *
398
400
  * @defaultValue true
399
401
  */
400
402
  useCompressionStream?: boolean;
@@ -1152,6 +1154,12 @@ export class ZipReader<Type> {
1152
1154
  ): AsyncGenerator<Entry, boolean>;
1153
1155
  /**
1154
1156
  * Closes the zip file
1157
+ *
1158
+ * @remarks It cancels the `ReadableStream` instance passed to the constructor when nothing has been read
1159
+ * from it, which is the only resource a {@link ZipReader} instance can hold. It does nothing otherwise: the
1160
+ * stream is already consumed once {@link ZipReader#getEntries} has read the entries into memory, and the
1161
+ * {@link Reader} instances are never closed, they belong to the caller. The entries returned by
1162
+ * {@link ZipReader#getEntries} can therefore still be read after calling it.
1155
1163
  */
1156
1164
  close(): Promise<void>;
1157
1165
  }
@@ -1435,7 +1443,12 @@ export interface ZipReaderOptions {
1435
1443
  */
1436
1444
  signal?: AbortSignal;
1437
1445
  /**
1438
- * `true` to prevent closing of {@link Writer#writable} when calling {@link FileEntry#getData}.
1446
+ * `true` to prevent closing of {@link WritableWriter#writable} when calling {@link FileEntry#getData}.
1447
+ *
1448
+ * @remarks
1449
+ * It only applies to the writable owned by the caller. It is ignored by the {@link Writer} instances
1450
+ * returning the written data, such as {@link BlobWriter} or {@link TextWriter}, whose writable is
1451
+ * created internally and must be closed for {@link Writer#getData} to resolve.
1439
1452
  *
1440
1453
  * @defaultValue false
1441
1454
  */
@@ -1606,11 +1619,12 @@ export interface LocalDirectory {
1606
1619
  */
1607
1620
  extraFieldNTFS?: EntryExtraField;
1608
1621
  /**
1609
- * The Unix extra field.
1622
+ * The Info-ZIP Unix type 2 extra field (0x7855). Its uid/gid are stored in the local file header only, the
1623
+ * central directory version carries no data and merely flags their presence.
1610
1624
  */
1611
1625
  extraFieldUnix?: EntryExtraField;
1612
1626
  /**
1613
- * The Info-ZIP Unix extra field.
1627
+ * The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers.
1614
1628
  */
1615
1629
  extraFieldInfoZip?: EntryExtraField;
1616
1630
  /**
@@ -1694,8 +1708,22 @@ export interface EntryMetaData {
1694
1708
  filenameUTF8: boolean;
1695
1709
  /**
1696
1710
  * `true` if the entry is an executable file
1711
+ *
1712
+ * Always `false` when {@link EntryMetaData#symlink} is `true`: the permissions of a symbolic link
1713
+ * are not meaningful, Unix systems store them as `0o777`.
1697
1714
  */
1698
1715
  executable: boolean;
1716
+ /**
1717
+ * `true` if the entry is a symbolic link, i.e. if the Unix file type stored in
1718
+ * {@link EntryMetaData#externalFileAttributes} is `S_IFLNK` (`0o120000`).
1719
+ *
1720
+ * The target of the link is the content of the entry, stored as a path with no trailing NUL
1721
+ * character. It is read like any other entry, e.g. with `entry.getData(new TextWriter())`.
1722
+ *
1723
+ * The path is not validated: it can be absolute or escape the archive with `..` segments. It must
1724
+ * be checked before being used to resolve a file.
1725
+ */
1726
+ symlink: boolean;
1699
1727
  /**
1700
1728
  * `true` if the content of the entry is encrypted.
1701
1729
  */
@@ -1819,10 +1847,18 @@ export interface EntryMetaData {
1819
1847
  };
1820
1848
  /**
1821
1849
  * Unix owner id when available.
1850
+ *
1851
+ * The value is read from the central directory. The Info-ZIP Unix extra fields type 1 (0x5855) and type 2
1852
+ * (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; the ids are then available in
1854
+ * {@link EntryMetaData#localDirectory}. The Info-ZIP New Unix extra field (0x7875) and the PKWARE Unix
1855
+ * extra field (0x000d) store the ids in both headers and are unaffected.
1822
1856
  */
1823
1857
  uid?: number;
1824
1858
  /**
1825
1859
  * Unix group id when available.
1860
+ *
1861
+ * See {@link EntryMetaData#uid} for the fields storing the ids in the local file header only.
1826
1862
  */
1827
1863
  gid?: number;
1828
1864
  /**
@@ -1908,11 +1944,12 @@ export interface EntryMetaData {
1908
1944
  */
1909
1945
  extraFieldNTFS?: EntryExtraField;
1910
1946
  /**
1911
- * The Unix extra field.
1947
+ * The Info-ZIP Unix type 2 extra field (0x7855). Its uid/gid are stored in the local file header only, the
1948
+ * central directory version carries no data and merely flags their presence.
1912
1949
  */
1913
1950
  extraFieldUnix?: EntryExtraField;
1914
1951
  /**
1915
- * The Info-ZIP Unix extra field.
1952
+ * The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers.
1916
1953
  */
1917
1954
  extraFieldInfoZip?: EntryExtraField;
1918
1955
  /**
@@ -1941,6 +1978,11 @@ export interface EntryMetaData {
1941
1978
  extraFieldUSDZ?: EntryExtraField;
1942
1979
  /**
1943
1980
  * The local file header fields, set when the entry data has been read.
1981
+ *
1982
+ * The local file header is the only place where the Info-ZIP Unix extra fields type 1 (0x5855) and type 2
1983
+ * (0x7855) store the uid/gid, so this is where they are read for entries carrying just these fields, e.g.
1984
+ * with `entry.localDirectory.extraFieldUnixType1.uid`. The values are not merged into
1985
+ * {@link EntryMetaData#uid} and {@link EntryMetaData#gid}, which are read from the central directory.
1944
1986
  */
1945
1987
  localDirectory?: LocalDirectory;
1946
1988
  }
@@ -2312,6 +2354,12 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
2312
2354
  *
2313
2355
  * The minimum value is 0 and means that no compression is applied. The maximum value is 9.
2314
2356
  *
2357
+ * The native API `CompressionStream` does not support compression levels. Any value other than 6,
2358
+ * its de facto level, disables `useCompressionStream` and compresses the data with the embedded
2359
+ * implementation instead. Note that the compressed data produced at a given level can still vary
2360
+ * between platforms. Set `useCompressionStream` to `false` to get deterministic output across
2361
+ * platforms.
2362
+ *
2315
2363
  * @defaultValue 6
2316
2364
  */
2317
2365
  level?: number;
@@ -2331,6 +2379,13 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
2331
2379
  * The optional `dispose` method is called once the entry has been processed (on success, error, or abort) so a resource-backed buffer can release its resource.
2332
2380
  *
2333
2381
  * See {@link createOPFSTempStream} for a ready-made OPFS-backed implementation, {@link createSyncAccessHandleTempStream} for a faster worker-only variant, and {@link createBlobTempStream} for a `Blob`-backed one.
2382
+ *
2383
+ * @remarks The `readable` side is consumed only once the `writable` side has been closed, since the local
2384
+ * header written before it holds the size and the CRC-32 of the entry. The object must therefore be able to
2385
+ * hold a whole entry, either by buffering it like the default
2386
+ * `new TransformStream(undefined, undefined, { highWaterMark: Infinity })` does, or by draining it like the
2387
+ * three implementations above do. A factory returning `new TransformStream()` deadlocks instead, its default
2388
+ * queuing strategy holding a single chunk.
2334
2389
  */
2335
2390
  createTempStream?: () => TempStream | Promise<TempStream>;
2336
2391
  /**
@@ -2467,6 +2522,12 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
2467
2522
  * attribute for folder entries, Unix default permissions when `msDosCompatible` is `false`).
2468
2523
  */
2469
2524
  externalFileAttributes?: number;
2525
+ /**
2526
+ * The external file attribute.
2527
+ *
2528
+ * @deprecated Use {@link ZipWriterConstructorOptions#externalFileAttributes} instead.
2529
+ */
2530
+ externalFileAttribute?: number;
2470
2531
  /**
2471
2532
  * The Unix owner id to write in the Unix extra field or as part of the external attributes.
2472
2533
  */
@@ -2477,6 +2538,15 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
2477
2538
  gid?: number;
2478
2539
  /**
2479
2540
  * The Unix mode (st_mode bits) to use when writing external attributes.
2541
+ *
2542
+ * The value includes the Unix file type, so it is also how a symbolic link is written: pass
2543
+ * `0o120777` and use the path of the link target as the content of the entry. Extractors that
2544
+ * support symbolic links, e.g. Info-ZIP `unzip`, then restore the entry as a link.
2545
+ *
2546
+ * When the value carries no file type, the type of the entry is added: `S_IFDIR` (`0o040000`)
2547
+ * for a folder entry, `S_IFREG` (`0o100000`) otherwise. Set
2548
+ * {@link ZipWriterConstructorOptions#externalFileAttributes} instead to write a mode with no
2549
+ * file type.
2480
2550
  */
2481
2551
  unixMode?: number;
2482
2552
  /**
@@ -2505,6 +2575,12 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
2505
2575
  * @defaultValue 0
2506
2576
  */
2507
2577
  internalFileAttributes?: number;
2578
+ /**
2579
+ * The internal file attribute.
2580
+ *
2581
+ * @deprecated Use {@link ZipWriterConstructorOptions#internalFileAttributes} instead.
2582
+ */
2583
+ internalFileAttribute?: number;
2508
2584
  /**
2509
2585
  * When provided, the low 8-bit MS-DOS attributes to write into external file attributes.
2510
2586
  * Must be an integer between 0 and 255.
@@ -2537,6 +2613,16 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
2537
2613
  usdz?: boolean;
2538
2614
  /**
2539
2615
  * `true` to write the data as-is without compressing it and without crypting it.
2616
+ *
2617
+ * @remarks
2618
+ * The {@link ZipWriterConstructorOptions#level} and {@link ZipWriterAddDataOptions#compressionMethod} options
2619
+ * do not apply to data written as-is, and the entries with no content, e.g. the directories, ignore this
2620
+ * option entirely. Setting the {@link ZipWriterConstructorOptions#password} or the
2621
+ * {@link ZipWriterConstructorOptions#rawPassword} option throws an
2622
+ * {@link ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH} error, unless the
2623
+ * {@link ZipWriterConstructorOptions#encrypted} option is set to `true` to declare that the data is already
2624
+ * encrypted. In that case the password encrypts the other entries only, and the data written as-is keeps the
2625
+ * password it was encrypted with, which is not verified.
2540
2626
  */
2541
2627
  passThrough?: boolean;
2542
2628
  /**
@@ -2563,6 +2649,13 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
2563
2649
 
2564
2650
  /**
2565
2651
  * Represents options passed to {@link FileEntry#getData}, {@link ZipWriter.add} and `{@link ZipDirectory}.export*`.
2652
+ *
2653
+ * @remarks
2654
+ * When passed to `{@link ZipDirectory}.export*`, these functions report the progress of the whole archive instead
2655
+ * of the progress of each entry: {@link EntryDataOnprogressOptions#onstart} and
2656
+ * {@link EntryDataOnprogressOptions#onend} are called once, and the total number of bytes is the sum of the sizes
2657
+ * of all the entries. Use {@link ZipDirectoryEntryExportOptions#onentryprogress} to be notified when each entry
2658
+ * is written.
2566
2659
  */
2567
2660
  export interface EntryDataOnprogressOptions {
2568
2661
  /**
@@ -2630,6 +2723,10 @@ declare class ZipEntry {
2630
2723
  parent?: ZipEntry;
2631
2724
  /**
2632
2725
  * The uncompressed size of the content.
2726
+ *
2727
+ * @remarks It is the size of the raw compressed content when the entry has been imported with the
2728
+ * `passThrough` option set to `true`, since the entry holds the compressed data in that case. The
2729
+ * uncompressed size of the original entry remains available in {@link ZipEntry#data}.
2633
2730
  */
2634
2731
  uncompressedSize: number;
2635
2732
  /**
@@ -2932,6 +3029,10 @@ export class ZipDirectoryEntry extends ZipEntry {
2932
3029
  /**
2933
3030
  * Adds an entry with content provided via a `FileSystemEntry` instance
2934
3031
  *
3032
+ * The options apply to every entry added, including the directories. The
3033
+ * {@link ZipWriterConstructorOptions#lastModDate} option replaces the last modification date of the
3034
+ * files, which is otherwise taken from each `FileSystemEntry` instance.
3035
+ *
2935
3036
  * @param fileSystemEntry The `FileSystemEntry` instance.
2936
3037
  * @param options The options.
2937
3038
  * @returns A promise resolving to an array of {@link ZipFileEntry} or a {@link ZipDirectoryEntry} instances.
@@ -2947,6 +3048,10 @@ export class ZipDirectoryEntry extends ZipEntry {
2947
3048
  * whose {@link EntryError#entryName} is the path of the handle that failed, relative to the parent
2948
3049
  * of `fileSystemHandle`.
2949
3050
  *
3051
+ * The options apply to every entry added, including the directories. The
3052
+ * {@link ZipWriterConstructorOptions#lastModDate} option replaces the last modification date of the
3053
+ * files, which is otherwise taken from each `FileSystemHandle` instance.
3054
+ *
2950
3055
  * @param fileSystemHandle The `fileSystemHandle` instance.
2951
3056
  * @param options The options.
2952
3057
  * @returns A promise resolving to an array of {@link ZipFileEntry} or a {@link ZipDirectoryEntry} instances.
@@ -2960,6 +3065,9 @@ export class ZipDirectoryEntry extends ZipEntry {
2960
3065
  *
2961
3066
  * @param blob The `Blob` instance.
2962
3067
  * @param options The options.
3068
+ *
3069
+ * @remarks Use {@link ZipDirectoryEntry#importZip} with a {@link ZipReader} instance to read the data of the
3070
+ * zip file itself, e.g. its {@link ZipReader#prependedData} or its {@link ZipReader#comment} property.
2963
3071
  */
2964
3072
  importBlob(
2965
3073
  blob: Blob,
@@ -2970,6 +3078,9 @@ export class ZipDirectoryEntry extends ZipEntry {
2970
3078
  *
2971
3079
  * @param dataURI The Data URI `string` encoded in Base64.
2972
3080
  * @param options The options.
3081
+ *
3082
+ * @remarks Use {@link ZipDirectoryEntry#importZip} with a {@link ZipReader} instance to read the data of the
3083
+ * zip file itself, e.g. its {@link ZipReader#prependedData} or its {@link ZipReader#comment} property.
2973
3084
  */
2974
3085
  importData64URI(
2975
3086
  dataURI: string,
@@ -2980,6 +3091,9 @@ export class ZipDirectoryEntry extends ZipEntry {
2980
3091
  *
2981
3092
  * @param array The `Uint8Array` instance.
2982
3093
  * @param options The options.
3094
+ *
3095
+ * @remarks Use {@link ZipDirectoryEntry#importZip} with a {@link ZipReader} instance to read the data of the
3096
+ * zip file itself, e.g. its {@link ZipReader#prependedData} or its {@link ZipReader#comment} property.
2983
3097
  */
2984
3098
  importUint8Array(
2985
3099
  array: Uint8Array,
@@ -2990,6 +3104,9 @@ export class ZipDirectoryEntry extends ZipEntry {
2990
3104
  *
2991
3105
  * @param url The URL.
2992
3106
  * @param options The options.
3107
+ *
3108
+ * @remarks Use {@link ZipDirectoryEntry#importZip} with a {@link ZipReader} instance to read the data of the
3109
+ * zip file itself, e.g. its {@link ZipReader#prependedData} or its {@link ZipReader#comment} property.
2993
3110
  */
2994
3111
  importHttpContent(
2995
3112
  url: string,
@@ -3000,21 +3117,30 @@ export class ZipDirectoryEntry extends ZipEntry {
3000
3117
  *
3001
3118
  * @param readable The `ReadableStream` instance.
3002
3119
  * @param options The options.
3120
+ *
3121
+ * @remarks Use {@link ZipDirectoryEntry#importZip} with a {@link ZipReader} instance to read the data of the
3122
+ * zip file itself, e.g. its {@link ZipReader#prependedData} or its {@link ZipReader#comment} property.
3003
3123
  */
3004
3124
  importReadable(
3005
3125
  readable: ReadableStream,
3006
3126
  options?: ZipReaderConstructorOptions
3007
3127
  ): Promise<[ZipEntry]>;
3008
3128
  /**
3009
- * Extracts a zip file provided via a custom {@link Reader} instance into the entry
3129
+ * Extracts a zip file provided via a custom {@link Reader} instance or a {@link ZipReader} instance into
3130
+ * the entry
3010
3131
  *
3011
- * @param reader The {@link Reader} instance.
3132
+ * @param reader The {@link Reader} instance or the {@link ZipReader} instance.
3012
3133
  * @param options The options.
3013
3134
  *
3014
3135
  * @remarks The filename of each entry is split into path components to build the tree of entries. Empty
3015
3136
  * components and `"."` components are ignored, so `"a//b.txt"`, `"./a/b.txt"` and `"a/./b.txt"` all produce
3016
3137
  * the same `"a/b.txt"` entry. Filenames are normalized and validated beforehand, see
3017
3138
  * {@link GetEntriesOptions#normalizeFilename} and {@link GetEntriesOptions#filenameValidation}.
3139
+ *
3140
+ * Passing a {@link ZipReader} instance is the way to read the data of the zip file itself, e.g. its
3141
+ * {@link ZipReader#prependedData} or its {@link ZipReader#comment} property, since the instance created
3142
+ * otherwise is not exposed. Its options are used as defaults for the options passed here, and it must not
3143
+ * have read its entries yet when it is created over a `ReadableStream` instance, which can only be read once.
3018
3144
  */
3019
3145
  importZip(
3020
3146
  reader:
@@ -3023,7 +3149,8 @@ export class ZipDirectoryEntry extends ZipEntry {
3023
3149
  | ReadableStream
3024
3150
  | Reader<unknown>[]
3025
3151
  | ReadableReader[]
3026
- | ReadableStream[],
3152
+ | ReadableStream[]
3153
+ | ZipReader<unknown>,
3027
3154
  options?: ZipReaderConstructorOptions
3028
3155
  ): Promise<[ZipEntry]>;
3029
3156
  /**
@@ -3081,7 +3208,7 @@ export class ZipDirectoryEntry extends ZipEntry {
3081
3208
  * Running the same export again is the supported way to recover, since directories are merged and
3082
3209
  * files are overwritten.
3083
3210
  *
3084
- * @remarks An entry flagged as a symbolic link by its {@link EntryMetaData#externalFileAttributes} is written
3211
+ * @remarks An entry flagged as a symbolic link by {@link EntryMetaData#symlink} is written
3085
3212
  * as a regular file whose content is the path of the link target, because the File System Access API cannot
3086
3213
  * create symbolic links.
3087
3214
  *
@@ -3108,6 +3235,34 @@ export class ZipDirectoryEntry extends ZipEntry {
3108
3235
  | AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream>,
3109
3236
  options?: ZipDirectoryEntryExportOptions
3110
3237
  ): Promise<unknown>;
3238
+ /**
3239
+ * Computes the exact size in bytes of the zip file that `export*()` would produce for the entry
3240
+ * and its descendants, without reading or compressing any data.
3241
+ *
3242
+ * Pass the same options object that will be passed to the export method, otherwise the result
3243
+ * will not match. The size is only determinable when every descendant is stored (i.e. `level` is
3244
+ * set to 0) or passed through, and has a known size; {@link ERR_UNDETERMINED_SIZE} is thrown
3245
+ * otherwise. Encryption does not prevent it, the overhead of ZipCrypto and AES being fixed.
3246
+ *
3247
+ * The intended use is setting the `Content-Length` header of a zip file streamed over HTTP.
3248
+ *
3249
+ * @remarks Entries added with {@link ZipDirectoryEntry#addReadable} never have a known size, and
3250
+ * entries added with {@link ZipDirectoryEntry#addHttpContent} only get one once their content has
3251
+ * been read. The returned size assumes a single output file, it does not apply to split zip files.
3252
+ *
3253
+ * {@link ERR_UNDETERMINED_SIZE} is also thrown when the size depends on the order in which the
3254
+ * entries are physically written, which the buffered write path only determines at write time.
3255
+ * This happens when `usdz` is set, since the alignment padding depends on the offset of each
3256
+ * entry, and when the archive exceeds 4GB, since the offsets recorded in the central directory
3257
+ * are then extended to 64 bits. Passing `bufferedWrite: false` makes both determinable again,
3258
+ * as does exporting a directory whose children are all files. It is thrown as well when
3259
+ * `signCentralDirectory` is set, the length of the signature being unknown until it is computed.
3260
+ *
3261
+ * @param options The options.
3262
+ * @returns A promise resolving to the size in bytes.
3263
+ * @throws {@link ERR_UNDETERMINED_SIZE} if the size cannot be determined.
3264
+ */
3265
+ getExportedSize(options?: ZipDirectoryEntryExportOptions): Promise<number>;
3111
3266
  }
3112
3267
 
3113
3268
  /**
@@ -3131,6 +3286,37 @@ export interface ZipDirectoryEntryGetChildrenOptions {
3131
3286
 
3132
3287
  /**
3133
3288
  * Represents the options passed to `{@link ZipDirectoryEntry}#export*()`.
3289
+ *
3290
+ * @remarks
3291
+ * The options set here apply to every entry of the exported zip file, including the entries imported
3292
+ * from a zip file: such an entry keeps the metadata of the entry it was imported from, e.g. its
3293
+ * {@link ZipWriterConstructorOptions#lastModDate} option, only when the option is not set here. The
3294
+ * options passed when adding an entry to the filesystem take precedence over the options set here, and
3295
+ * the options describing the data of the entries exported as-is, e.g.
3296
+ * {@link ZipWriterConstructorOptions#compressionMethod} and
3297
+ * {@link ZipWriterAddDataOptions#uncompressedSize}, are always the ones of the original entries.
3298
+ *
3299
+ * The {@link ZipWriterConstructorOptions#password} option encrypts the exported zip file. It never
3300
+ * decrypts the entries being exported: the password of an entry imported from an encrypted zip file
3301
+ * must be passed in the {@link ZipDirectoryEntryExportOptions#readerOptions} option instead.
3302
+ *
3303
+ * Likewise, the {@link ZipWriterConstructorOptions#passThrough} option describes the data returned
3304
+ * by the Reader instances. Exporting entries imported from a zip file as-is is done with the
3305
+ * {@link ZipReaderOptions#passThrough} option in the
3306
+ * {@link ZipDirectoryEntryExportOptions#readerOptions} option instead. Setting it here throws an
3307
+ * {@link ERR_INVALID_PASS_THROUGH} error, unless the {@link ZipWriterAddDataOptions#uncompressedSize}
3308
+ * option of every entry holding content is known.
3309
+ *
3310
+ * Exporting entries as-is and setting the {@link ZipWriterConstructorOptions#password} option throws an
3311
+ * {@link ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH} error, since the data of these entries is copied
3312
+ * verbatim and cannot be encrypted. Entries imported from an encrypted zip file are an exception: they
3313
+ * are exported as-is without error, and keep the password they were encrypted with.
3314
+ *
3315
+ * The {@link ZipWriterConstructorOptions#preventClose} option only applies when the caller owns the
3316
+ * writable, i.e. when a {@link WritableWriter} instance is passed to
3317
+ * {@link ZipDirectoryEntry#exportZip} or {@link ZipDirectoryEntry#exportWritable}. It is ignored by the
3318
+ * other `{@link ZipDirectoryEntry}#export*()` methods, whose Writer instance can only return its data
3319
+ * once its writable is closed.
3134
3320
  */
3135
3321
  export interface ZipDirectoryEntryExportOptions
3136
3322
  extends ZipWriterConstructorOptions,
@@ -3144,13 +3330,66 @@ export interface ZipDirectoryEntryExportOptions
3144
3330
  */
3145
3331
  mimeType?: string;
3146
3332
  /**
3147
- * The options passed to the Reader instances
3333
+ * The function called each time an entry is written.
3334
+ *
3335
+ * @remarks
3336
+ * This function reports the entries whereas {@link EntryDataOnprogressOptions#onprogress} reports the
3337
+ * bytes. It is called once per entry, after the entry has been written, so `progress` reaches `total`
3338
+ * when the last entry is written.
3339
+ *
3340
+ * When {@link ZipWriterConstructorOptions#bufferedWrite} is enabled, the entries are written
3341
+ * concurrently: `progress` counts the entries written instead of giving the position of the entry in
3342
+ * the zip file.
3343
+ *
3344
+ * @param progress The number of entries written.
3345
+ * @param total The total number of entries.
3346
+ * @param entry The entry written.
3347
+ * @returns An empty promise or `undefined`.
3348
+ */
3349
+ onentryprogress?(
3350
+ progress: number,
3351
+ total: number,
3352
+ entry: EntryMetaData
3353
+ ): Promise<void> | void;
3354
+ /**
3355
+ * The global comment of the zip file, see {@link ZipWriter#close}.
3356
+ *
3357
+ * @remarks
3358
+ * The {@link ZipWriterAddDataOptions#comment} option is the comment of an entry: setting it here
3359
+ * comments every entry of the exported zip file instead of the zip file itself.
3360
+ */
3361
+ globalComment?: Uint8Array;
3362
+ /**
3363
+ * The function called for signing the central directory, see
3364
+ * {@link ZipWriterCloseOptions#signCentralDirectory}.
3365
+ *
3366
+ * @param directory The raw data of the central directory records.
3367
+ * @returns The data of the digital signature record.
3368
+ */
3369
+ signCentralDirectory?(
3370
+ directory: Uint8Array
3371
+ ): Uint8Array | PromiseLike<Uint8Array>;
3372
+ /**
3373
+ * The options passed to the Reader instances.
3374
+ *
3375
+ * @remarks
3376
+ * The {@link ZipReaderOptions#password} option must be set here to export entries imported from an
3377
+ * encrypted zip file, since the {@link ZipDirectoryEntryExportOptions#password} option sets the
3378
+ * password used to encrypt the exported zip file instead.
3379
+ *
3380
+ * The {@link ZipReaderOptions#passThrough} option set here exports the entries imported from a zip
3381
+ * file as-is, without decompressing and decrypting them, exactly as importing them with this option
3382
+ * does. It is ignored by the entries added to the filesystem, which are compressed as usual.
3148
3383
  */
3149
3384
  readerOptions?: ZipReaderConstructorOptions;
3150
3385
  }
3151
3386
 
3152
3387
  /**
3153
3388
  * Represents the options passed to {@link ZipDirectoryEntry#exportFileSystemHandle} and {@link FS#exportFileSystemHandle}.
3389
+ *
3390
+ * @remarks
3391
+ * The {@link ZipReaderOptions#preventClose} option is ignored: the export owns the writable of each
3392
+ * file it creates and must close it for the data to be written.
3154
3393
  */
3155
3394
  export interface ZipDirectoryEntryExportFileSystemHandleOptions
3156
3395
  extends EntryGetDataOptions {
@@ -3165,6 +3404,15 @@ export interface ZipDirectoryEntryExportFileSystemHandleOptions
3165
3404
  * @defaultValue false
3166
3405
  */
3167
3406
  concurrent?: boolean;
3407
+ /**
3408
+ * The options passed to the Reader instances.
3409
+ *
3410
+ * @remarks
3411
+ * These options override the ones passed at the top level. The {@link ZipReaderOptions#password}
3412
+ * option can be set here or at the top level, unlike {@link ZipDirectoryEntryExportOptions} where
3413
+ * the top-level password encrypts the exported zip file instead.
3414
+ */
3415
+ readerOptions?: ZipReaderConstructorOptions;
3168
3416
  }
3169
3417
 
3170
3418
  /**
@@ -3212,6 +3460,7 @@ export interface FS
3212
3460
  | "exportWritable"
3213
3461
  | "exportFileSystemHandle"
3214
3462
  | "exportZip"
3463
+ | "getExportedSize"
3215
3464
  | "isPasswordProtected"
3216
3465
  | "checkPassword"
3217
3466
  > {}
@@ -3422,6 +3671,10 @@ export const ERR_INVALID_ENCRYPTION_STRENGTH: string;
3422
3671
  * Unsupported encryption in USDZ files error
3423
3672
  */
3424
3673
  export const ERR_UNSUPPORTED_ENCRYPTION_USDZ: string;
3674
+ /**
3675
+ * Unsupported encryption in pass-through entries error
3676
+ */
3677
+ export const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH: string;
3425
3678
  /**
3426
3679
  * Invalid format error
3427
3680
  */
@@ -3475,8 +3728,13 @@ export const ERR_ITERATOR_COMPLETED_TOO_SOON: string;
3475
3728
  * Undefined uncompressed size error
3476
3729
  */
3477
3730
  export const ERR_UNDEFINED_UNCOMPRESSED_SIZE: string;
3731
+ export const ERR_UNDETERMINED_SIZE: string;
3478
3732
  /**
3479
3733
  * Undefined reader error
3734
+ *
3735
+ * @remarks Thrown when adding an entry with the {@link ZipWriterConstructorOptions#passThrough} option set to `true`
3736
+ * and no Reader instance: the headers of such an entry describe its content verbatim and would declare content that
3737
+ * is not there. Directory entries are exempt, they have no content to write as-is.
3480
3738
  */
3481
3739
  export const ERR_UNDEFINED_READER: string;
3482
3740
  /**
@@ -3530,6 +3788,16 @@ export const ERR_INVALID_LEVEL: string;
3530
3788
  * would produce an archive that cannot be opened with the equivalent {@link ZipWriterConstructorOptions#password}.
3531
3789
  */
3532
3790
  export const ERR_INVALID_PASSWORD_TYPE: string;
3791
+ /**
3792
+ * Invalid passThrough option error (thrown by `{@link ZipDirectoryEntry}#export*()` and
3793
+ * {@link ZipDirectoryEntry#getExportedSize} when an entry would be written as-is without a known uncompressed size)
3794
+ *
3795
+ * @remarks The {@link ZipWriterConstructorOptions#passThrough} option describes the data returned by the Reader
3796
+ * instances, which the filesystem API creates itself. Use the {@link ZipReaderOptions#passThrough} option in the
3797
+ * {@link ZipDirectoryEntryExportOptions#readerOptions} option to export the entries imported from a zip file as-is,
3798
+ * or set the {@link ZipWriterAddDataOptions#uncompressedSize} option of each entry holding compressed data.
3799
+ */
3800
+ export const ERR_INVALID_PASS_THROUGH: string;
3533
3801
  /**
3534
3802
  * Entry already exists error (thrown by the filesystem API when adding an entry whose filename already exists)
3535
3803
  */