@zip.js/zip.js 2.8.51 → 2.8.53
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 +8 -3
- package/deno.json +1 -1
- package/dist/zip-core-external.js +241 -95
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +243 -94
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +564 -199
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +551 -194
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +564 -199
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +567 -198
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +567 -198
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +243 -94
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +243 -94
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +243 -94
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +1 -1
- package/index-native.cjs +567 -198
- package/index-native.min.js +1 -1
- package/index.cjs +567 -198
- package/index.d.cts +551 -45
- package/index.d.ts +551 -45
- package/index.min.js +1 -1
- package/lib/core/codec-worker-web.js +13 -4
- package/lib/core/codec-worker.js +2 -0
- package/lib/core/constants.js +9 -0
- package/lib/core/io.js +43 -4
- package/lib/core/options.js +2 -0
- package/lib/core/util/compatible-streams.js +3 -8
- package/lib/core/zip-entry.js +16 -0
- package/lib/core/zip-fs.js +236 -107
- package/lib/core/zip-reader.js +106 -40
- package/lib/core/zip-writer.js +171 -41
- package/lib/zip-core-writer.js +3 -0
- package/package.json +9 -7
package/index.d.ts
CHANGED
|
@@ -272,7 +272,7 @@ export interface Configuration extends WorkerConfiguration {
|
|
|
272
272
|
/**
|
|
273
273
|
* The maximum number of web workers used to compress/decompress data simultaneously.
|
|
274
274
|
*
|
|
275
|
-
* @defaultValue `navigator.hardwareConcurrency
|
|
275
|
+
* @defaultValue `navigator.hardwareConcurrency`, or 2 when the environment does not provide it
|
|
276
276
|
*/
|
|
277
277
|
maxWorkers?: number;
|
|
278
278
|
/**
|
|
@@ -311,7 +311,7 @@ export interface Configuration extends WorkerConfiguration {
|
|
|
311
311
|
* });
|
|
312
312
|
* ```
|
|
313
313
|
*
|
|
314
|
-
* @defaultValue "./core/web-worker.js"
|
|
314
|
+
* @defaultValue "./core/web-worker-wasm.js", or "./core/web-worker-native.js" for the builds using the native implementations
|
|
315
315
|
*/
|
|
316
316
|
workerURI?: string;
|
|
317
317
|
/**
|
|
@@ -351,25 +351,25 @@ export interface Configuration extends WorkerConfiguration {
|
|
|
351
351
|
/**
|
|
352
352
|
* The stream implementation used to compress data when `useCompressionStream` is set to `true`.
|
|
353
353
|
*
|
|
354
|
-
* @defaultValue
|
|
354
|
+
* @defaultValue the global `CompressionStream`, or `false` when the environment does not provide it
|
|
355
355
|
*/
|
|
356
356
|
CompressionStream?: typeof TransformStreamLike;
|
|
357
357
|
/**
|
|
358
358
|
* The stream implementation used to decompress data when `useCompressionStream` is set to `true`.
|
|
359
359
|
*
|
|
360
|
-
* @defaultValue
|
|
360
|
+
* @defaultValue the global `DecompressionStream`, or `false` when the environment does not provide it
|
|
361
361
|
*/
|
|
362
362
|
DecompressionStream?: typeof TransformStreamLike;
|
|
363
363
|
/**
|
|
364
364
|
* The stream implementation used to compress data when `useCompressionStream` is set to `false`.
|
|
365
365
|
*
|
|
366
|
-
* @defaultValue
|
|
366
|
+
* @defaultValue the implementation embedded in the entry point that was imported, e.g. the WebAssembly one
|
|
367
367
|
*/
|
|
368
368
|
CompressionStreamFallback?: typeof TransformStreamLike;
|
|
369
369
|
/**
|
|
370
370
|
* The stream implementation used to decompress data when `useCompressionStream` is set to `false`.
|
|
371
371
|
*
|
|
372
|
-
* @defaultValue
|
|
372
|
+
* @defaultValue the implementation embedded in the entry point that was imported, e.g. the WebAssembly one
|
|
373
373
|
*/
|
|
374
374
|
DecompressionStreamFallback?: typeof TransformStreamLike;
|
|
375
375
|
/**
|
|
@@ -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;
|
|
@@ -722,7 +724,11 @@ export class Data64URIReader extends Reader<string> {}
|
|
|
722
724
|
export class Uint8ArrayReader extends Reader<Uint8Array> {}
|
|
723
725
|
|
|
724
726
|
/**
|
|
725
|
-
* Represents a {@link Reader} instance used to read data provided as an array of {@link
|
|
727
|
+
* Represents a {@link Reader} instance used to read data provided as an array of {@link Reader} instances,
|
|
728
|
+
* {@link ReadableReader} instances or `ReadableStream` instances (e.g. split zip files).
|
|
729
|
+
*
|
|
730
|
+
* @remarks Elements that only provide a `ReadableStream` are buffered when the reader is initialized, since
|
|
731
|
+
* mapping a global offset onto a disk requires the size of every disk.
|
|
726
732
|
*/
|
|
727
733
|
export class SplitDataReader extends Reader<
|
|
728
734
|
Reader<unknown>[] | ReadableReader[] | ReadableStream[]
|
|
@@ -781,7 +787,11 @@ export interface HttpOptions extends HttpRangeOptions {
|
|
|
781
787
|
* `true` to prevent using `HEAD` HTTP request in order the get the size of the content.
|
|
782
788
|
* `false` to explicitly use `HEAD`, this is useful in case of CORS where `Access-Control-Expose-Headers: Content-Range` is not returned by the server.
|
|
783
789
|
*
|
|
784
|
-
* @
|
|
790
|
+
* Leaving it unset is not the same as setting it to `false` when {@link HttpOptions#useRangeHeader} or
|
|
791
|
+
* {@link HttpOptions#forceRangeRequests} is set: the size is then read from a ranged `GET` request instead, and
|
|
792
|
+
* only an explicit `false` restores the `HEAD` request.
|
|
793
|
+
*
|
|
794
|
+
* @defaultValue false, and `true` when {@link HttpOptions#useRangeHeader} or {@link HttpOptions#forceRangeRequests} is set
|
|
785
795
|
*/
|
|
786
796
|
preventHeadRequest?: boolean;
|
|
787
797
|
/**
|
|
@@ -1152,6 +1162,12 @@ export class ZipReader<Type> {
|
|
|
1152
1162
|
): AsyncGenerator<Entry, boolean>;
|
|
1153
1163
|
/**
|
|
1154
1164
|
* Closes the zip file
|
|
1165
|
+
*
|
|
1166
|
+
* @remarks It cancels the `ReadableStream` instance passed to the constructor when nothing has been read
|
|
1167
|
+
* from it, which is the only resource a {@link ZipReader} instance can hold. It does nothing otherwise: the
|
|
1168
|
+
* stream is already consumed once {@link ZipReader#getEntries} has read the entries into memory, and the
|
|
1169
|
+
* {@link Reader} instances are never closed, they belong to the caller. The entries returned by
|
|
1170
|
+
* {@link ZipReader#getEntries} can therefore still be read after calling it.
|
|
1155
1171
|
*/
|
|
1156
1172
|
close(): Promise<void>;
|
|
1157
1173
|
}
|
|
@@ -1213,6 +1229,12 @@ export interface GetEntriesOptions {
|
|
|
1213
1229
|
* the content of an entry, it also validates the local file header against the central directory record (see
|
|
1214
1230
|
* {@link ZipReaderOptions#checkAmbiguity}).
|
|
1215
1231
|
*
|
|
1232
|
+
* This is the boolean form of {@link GetEntriesOptions#strictness}: `true` means `"strict"` and `false` means
|
|
1233
|
+
* any value but `"strict"`. When both options are set, the value passed to {@link ZipReader#getEntries} takes
|
|
1234
|
+
* precedence over the value passed to the constructor of {@link ZipReader}, and `strictness` takes precedence
|
|
1235
|
+
* over `checkAmbiguity` when both are set at the same level. `false` downgrades an inherited `"strict"` value
|
|
1236
|
+
* to `"balanced"` and leaves an inherited `"tolerant"` value unchanged.
|
|
1237
|
+
*
|
|
1216
1238
|
* @defaultValue false
|
|
1217
1239
|
*/
|
|
1218
1240
|
checkAmbiguity?: boolean;
|
|
@@ -1354,9 +1376,18 @@ export interface DirectoryEncryptionInfo {
|
|
|
1354
1376
|
export interface ZipReaderOptions {
|
|
1355
1377
|
/**
|
|
1356
1378
|
* How tolerant the reader should be when the local file header of an entry disagrees with its central
|
|
1357
|
-
* directory record.
|
|
1358
|
-
*
|
|
1359
|
-
*
|
|
1379
|
+
* directory record. Any difference throws an {@link ERR_AMBIGUOUS_ARCHIVE} error.
|
|
1380
|
+
*
|
|
1381
|
+
* - `"strict"`: compare the filename, the general purpose bit flag, the compression method, the CRC-32
|
|
1382
|
+
* checksum and the sizes.
|
|
1383
|
+
* - `"balanced"`: compare everything except the filename.
|
|
1384
|
+
* - `"tolerant"`: compare nothing and trust the central directory record.
|
|
1385
|
+
*
|
|
1386
|
+
* Every field except the filename is read from the local file header anyway, to locate the entry data, so
|
|
1387
|
+
* the comparison `"balanced"` performs reads no additional bytes. Comparing the filename reads the filename
|
|
1388
|
+
* bytes as well, which costs one extra read per entry whenever the local file header carries no extra field
|
|
1389
|
+
* — the common case in practice. Use {@link ZipReaderOptions#checkLocalDirectory} to request or suppress the
|
|
1390
|
+
* whole comparison explicitly.
|
|
1360
1391
|
*
|
|
1361
1392
|
* @defaultValue "balanced"
|
|
1362
1393
|
*/
|
|
@@ -1369,9 +1400,31 @@ export interface ZipReaderOptions {
|
|
|
1369
1400
|
* methods, CRC-32 checksums and sizes. The extra fields are not compared because the zip specification allows
|
|
1370
1401
|
* them to differ.
|
|
1371
1402
|
*
|
|
1403
|
+
* This is the boolean form of {@link ZipReaderOptions#strictness}: `true` means `"strict"` and `false` means
|
|
1404
|
+
* any value but `"strict"`. When both options are set, the value passed to {@link FileEntry#getData} takes
|
|
1405
|
+
* precedence over the value passed to the constructor of {@link ZipReader}, and `strictness` takes precedence
|
|
1406
|
+
* over `checkAmbiguity` when both are set at the same level. `false` downgrades an inherited `"strict"` value
|
|
1407
|
+
* to `"balanced"` and leaves an inherited `"tolerant"` value unchanged.
|
|
1408
|
+
*
|
|
1372
1409
|
* @defaultValue false
|
|
1373
1410
|
*/
|
|
1374
1411
|
checkAmbiguity?: boolean;
|
|
1412
|
+
/**
|
|
1413
|
+
* `true` to validate the local file header of the entry against its central directory record when calling
|
|
1414
|
+
* {@link FileEntry#getData}, `false` to skip that validation. This is the entry-level half of
|
|
1415
|
+
* {@link ZipReaderOptions#checkAmbiguity}, exposed on its own so it can be enabled without the archive-level
|
|
1416
|
+
* checks and disabled without giving up the rest of {@link ZipReaderOptions#strictness}. It is the only way to
|
|
1417
|
+
* validate the local file headers of a self-extracting archive, since
|
|
1418
|
+
* {@link GetEntriesOptions#checkAmbiguity} rejects prepended data outright.
|
|
1419
|
+
*
|
|
1420
|
+
* `true` compares the filename as well, like {@link ZipReaderOptions#strictness} set to `"strict"`; `false`
|
|
1421
|
+
* compares nothing, like `"tolerant"`. An explicit value takes precedence over the strictness default at
|
|
1422
|
+
* every level.
|
|
1423
|
+
*
|
|
1424
|
+
* @defaultValue `true` when {@link ZipReaderOptions#strictness} is `"strict"` or `"balanced"`, `false` when
|
|
1425
|
+
* it is `"tolerant"`.
|
|
1426
|
+
*/
|
|
1427
|
+
checkLocalDirectory?: boolean;
|
|
1375
1428
|
/**
|
|
1376
1429
|
* `true` to check only if the password is valid.
|
|
1377
1430
|
*
|
|
@@ -1435,7 +1488,12 @@ export interface ZipReaderOptions {
|
|
|
1435
1488
|
*/
|
|
1436
1489
|
signal?: AbortSignal;
|
|
1437
1490
|
/**
|
|
1438
|
-
* `true` to prevent closing of {@link
|
|
1491
|
+
* `true` to prevent closing of {@link WritableWriter#writable} when calling {@link FileEntry#getData}.
|
|
1492
|
+
*
|
|
1493
|
+
* @remarks
|
|
1494
|
+
* It only applies to the writable owned by the caller. It is ignored by the {@link Writer} instances
|
|
1495
|
+
* returning the written data, such as {@link BlobWriter} or {@link TextWriter}, whose writable is
|
|
1496
|
+
* created internally and must be closed for {@link Writer#getData} to resolve.
|
|
1439
1497
|
*
|
|
1440
1498
|
* @defaultValue false
|
|
1441
1499
|
*/
|
|
@@ -1490,9 +1548,14 @@ export interface EntryExtraFieldAES extends EntryExtraField {
|
|
|
1490
1548
|
*/
|
|
1491
1549
|
vendorId?: number;
|
|
1492
1550
|
/**
|
|
1493
|
-
* The compression method stored in the
|
|
1551
|
+
* The compression method stored in the header of the entry, i.e. `99` for a WinZip AES entry.
|
|
1494
1552
|
*/
|
|
1495
1553
|
originalCompressionMethod?: number;
|
|
1554
|
+
/**
|
|
1555
|
+
* The real compression method of the entry, stored in the AES extra field because the header carries `99`
|
|
1556
|
+
* instead. This is the value reported by {@link EntryMetaData#compressionMethod}.
|
|
1557
|
+
*/
|
|
1558
|
+
compressionMethod?: number;
|
|
1496
1559
|
}
|
|
1497
1560
|
/**
|
|
1498
1561
|
* Represents a Unix extra field record storing timestamps: the Info-ZIP Unix type 1 extra field (0x5855),
|
|
@@ -1526,7 +1589,149 @@ export interface EntryExtraFieldUnicode extends EntryExtraField {
|
|
|
1526
1589
|
* `true` if the extra field is consistent with the entry metadata.
|
|
1527
1590
|
*/
|
|
1528
1591
|
valid?: boolean;
|
|
1592
|
+
/**
|
|
1593
|
+
* The version of the extra field.
|
|
1594
|
+
*/
|
|
1595
|
+
version?: number;
|
|
1596
|
+
/**
|
|
1597
|
+
* The filename stored in the extra field, when it is a Unicode path extra field (0x7075).
|
|
1598
|
+
*/
|
|
1599
|
+
filename?: string;
|
|
1600
|
+
/**
|
|
1601
|
+
* The comment stored in the extra field, when it is a Unicode comment extra field (0x6375).
|
|
1602
|
+
*/
|
|
1603
|
+
comment?: string;
|
|
1529
1604
|
}
|
|
1605
|
+
/**
|
|
1606
|
+
* Represents the Zip64 extra field record of an entry. Each property is only defined when the matching field
|
|
1607
|
+
* of the header was set to its maximum value, i.e. when the real value had to be stored in the extra field.
|
|
1608
|
+
*/
|
|
1609
|
+
export interface EntryExtraFieldZip64 extends EntryExtraField {
|
|
1610
|
+
/**
|
|
1611
|
+
* The uncompressed size of the entry.
|
|
1612
|
+
*/
|
|
1613
|
+
uncompressedSize?: number;
|
|
1614
|
+
/**
|
|
1615
|
+
* The compressed size of the entry.
|
|
1616
|
+
*/
|
|
1617
|
+
compressedSize?: number;
|
|
1618
|
+
/**
|
|
1619
|
+
* The offset of the local file header of the entry.
|
|
1620
|
+
*/
|
|
1621
|
+
offset?: number;
|
|
1622
|
+
/**
|
|
1623
|
+
* The number of the disk where the entry data starts.
|
|
1624
|
+
*/
|
|
1625
|
+
diskNumberStart?: number;
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* Represents the NTFS extra field record of an entry (0x000a), storing the dates as Windows `FILETIME` values.
|
|
1629
|
+
*/
|
|
1630
|
+
export interface EntryExtraFieldNTFS extends EntryExtraField {
|
|
1631
|
+
/**
|
|
1632
|
+
* The last modification date.
|
|
1633
|
+
*/
|
|
1634
|
+
lastModDate?: Date;
|
|
1635
|
+
/**
|
|
1636
|
+
* The last access date.
|
|
1637
|
+
*/
|
|
1638
|
+
lastAccessDate?: Date;
|
|
1639
|
+
/**
|
|
1640
|
+
* The creation date.
|
|
1641
|
+
*/
|
|
1642
|
+
creationDate?: Date;
|
|
1643
|
+
/**
|
|
1644
|
+
* The last modification date (raw), as a Windows `FILETIME` value.
|
|
1645
|
+
*/
|
|
1646
|
+
rawLastModDate?: bigint;
|
|
1647
|
+
/**
|
|
1648
|
+
* The last access date (raw), as a Windows `FILETIME` value.
|
|
1649
|
+
*/
|
|
1650
|
+
rawLastAccessDate?: bigint;
|
|
1651
|
+
/**
|
|
1652
|
+
* The creation date (raw), as a Windows `FILETIME` value.
|
|
1653
|
+
*/
|
|
1654
|
+
rawCreationDate?: bigint;
|
|
1655
|
+
}
|
|
1656
|
+
/**
|
|
1657
|
+
* Represents the extended timestamp extra field record of an entry (0x5455), storing the dates as 32-bit Unix
|
|
1658
|
+
* times. The central directory record only carries the last modification date, the local file header carries
|
|
1659
|
+
* the dates selected by the flags of the extra field.
|
|
1660
|
+
*/
|
|
1661
|
+
export interface EntryExtraFieldExtendedTimestamp extends EntryExtraField {
|
|
1662
|
+
/**
|
|
1663
|
+
* The last modification date.
|
|
1664
|
+
*/
|
|
1665
|
+
lastModDate?: Date;
|
|
1666
|
+
/**
|
|
1667
|
+
* The last access date.
|
|
1668
|
+
*/
|
|
1669
|
+
lastAccessDate?: Date;
|
|
1670
|
+
/**
|
|
1671
|
+
* The creation date.
|
|
1672
|
+
*/
|
|
1673
|
+
creationDate?: Date;
|
|
1674
|
+
/**
|
|
1675
|
+
* The last modification date (raw), as a 32-bit Unix time.
|
|
1676
|
+
*/
|
|
1677
|
+
rawLastModDate?: number;
|
|
1678
|
+
/**
|
|
1679
|
+
* The last access date (raw), as a 32-bit Unix time.
|
|
1680
|
+
*/
|
|
1681
|
+
rawLastAccessDate?: number;
|
|
1682
|
+
/**
|
|
1683
|
+
* The creation date (raw), as a 32-bit Unix time.
|
|
1684
|
+
*/
|
|
1685
|
+
rawCreationDate?: number;
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* Represents a Unix extra field record storing ownership: the Info-ZIP "new" Unix extra field (0x7875), read
|
|
1689
|
+
* into {@link EntryMetaData#extraFieldInfoZip}, or the Info-ZIP "old" Unix extra field (0x7855), read into
|
|
1690
|
+
* {@link EntryMetaData#extraFieldUnix}.
|
|
1691
|
+
*/
|
|
1692
|
+
export interface EntryExtraFieldUnix extends EntryExtraField {
|
|
1693
|
+
/**
|
|
1694
|
+
* The version of the extra field, only defined for the Info-ZIP "new" Unix extra field (0x7875).
|
|
1695
|
+
*/
|
|
1696
|
+
version?: number;
|
|
1697
|
+
/**
|
|
1698
|
+
* The Unix user id.
|
|
1699
|
+
*/
|
|
1700
|
+
uid?: number;
|
|
1701
|
+
/**
|
|
1702
|
+
* The Unix group id.
|
|
1703
|
+
*/
|
|
1704
|
+
gid?: number;
|
|
1705
|
+
}
|
|
1706
|
+
/**
|
|
1707
|
+
* Represents the data descriptor record written after the content of an entry, when
|
|
1708
|
+
* {@link EntryBitFlag#dataDescriptor} is set.
|
|
1709
|
+
*/
|
|
1710
|
+
export interface LocalDataDescriptor {
|
|
1711
|
+
/**
|
|
1712
|
+
* `true` if the record is preceded by its optional signature.
|
|
1713
|
+
*
|
|
1714
|
+
* The signature is not part of the original format, it is a later convention writers are free to follow. It is
|
|
1715
|
+
* reported as absent when the values following it disagree with the central directory, since the record is then
|
|
1716
|
+
* read as starting at the first byte.
|
|
1717
|
+
*/
|
|
1718
|
+
signature: boolean;
|
|
1719
|
+
/**
|
|
1720
|
+
* The CRC-32 checksum stored in the record, which is allowed to differ from {@link EntryMetaData#crc32}.
|
|
1721
|
+
*/
|
|
1722
|
+
crc32: number;
|
|
1723
|
+
/**
|
|
1724
|
+
* The compressed size stored in the record, which is allowed to differ from
|
|
1725
|
+
* {@link EntryMetaData#compressedSize}.
|
|
1726
|
+
*/
|
|
1727
|
+
compressedSize: number;
|
|
1728
|
+
/**
|
|
1729
|
+
* The uncompressed size stored in the record, which is allowed to differ from
|
|
1730
|
+
* {@link EntryMetaData#uncompressedSize}.
|
|
1731
|
+
*/
|
|
1732
|
+
uncompressedSize: number;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1530
1735
|
/**
|
|
1531
1736
|
* Represents the local file header fields of an entry, read when getting the entry data.
|
|
1532
1737
|
*/
|
|
@@ -1571,6 +1776,23 @@ export interface LocalDirectory {
|
|
|
1571
1776
|
* The extra field.
|
|
1572
1777
|
*/
|
|
1573
1778
|
extraField?: Map<number, EntryExtraField>;
|
|
1779
|
+
/**
|
|
1780
|
+
* The filename of the entry stored in the local file header (raw), which is allowed to differ from
|
|
1781
|
+
* {@link EntryMetaData#rawFilename}.
|
|
1782
|
+
*
|
|
1783
|
+
* Only defined when the local filename has been read, i.e. when the {@link ZipReaderOptions#strictness} option
|
|
1784
|
+
* is set to `"strict"` or when the {@link ZipReaderOptions#checkLocalDirectory} option is set to `true`, since
|
|
1785
|
+
* reading it costs one read the central directory does not need.
|
|
1786
|
+
*/
|
|
1787
|
+
rawFilename?: Uint8Array;
|
|
1788
|
+
/**
|
|
1789
|
+
* The data descriptor record written after the content, when the entry has one.
|
|
1790
|
+
*
|
|
1791
|
+
* Only defined when the record has been read, i.e. when the {@link ZipReaderOptions#checkOverlappingEntry} or
|
|
1792
|
+
* the {@link ZipReaderOptions#checkOverlappingEntryOnly} option is set to `true`, since the sizes stored in the
|
|
1793
|
+
* central directory make it unnecessary to read it otherwise.
|
|
1794
|
+
*/
|
|
1795
|
+
dataDescriptor?: LocalDataDescriptor;
|
|
1574
1796
|
/**
|
|
1575
1797
|
* The CRC-32 checksum of the content.
|
|
1576
1798
|
*/
|
|
@@ -1596,7 +1818,7 @@ export interface LocalDirectory {
|
|
|
1596
1818
|
/**
|
|
1597
1819
|
* The Zip64 extra field.
|
|
1598
1820
|
*/
|
|
1599
|
-
extraFieldZip64?:
|
|
1821
|
+
extraFieldZip64?: EntryExtraFieldZip64;
|
|
1600
1822
|
/**
|
|
1601
1823
|
* The AES extra field.
|
|
1602
1824
|
*/
|
|
@@ -1604,15 +1826,18 @@ export interface LocalDirectory {
|
|
|
1604
1826
|
/**
|
|
1605
1827
|
* The NTFS extra field.
|
|
1606
1828
|
*/
|
|
1607
|
-
extraFieldNTFS?:
|
|
1829
|
+
extraFieldNTFS?: EntryExtraFieldNTFS;
|
|
1608
1830
|
/**
|
|
1609
|
-
* The Unix extra field.
|
|
1831
|
+
* The Info-ZIP Unix type 2 extra field (0x7855). Its uid/gid are stored in the local file header only, the
|
|
1832
|
+
* central directory version carries no data and merely flags their presence.
|
|
1610
1833
|
*/
|
|
1611
|
-
extraFieldUnix?:
|
|
1834
|
+
extraFieldUnix?: EntryExtraFieldUnix;
|
|
1612
1835
|
/**
|
|
1613
|
-
* The Info-ZIP Unix extra field.
|
|
1836
|
+
* The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers. It is read
|
|
1837
|
+
* whenever the type 2 extra field (0x7855) is absent or carries no ids, which is its usual state in the
|
|
1838
|
+
* central directory.
|
|
1614
1839
|
*/
|
|
1615
|
-
extraFieldInfoZip?:
|
|
1840
|
+
extraFieldInfoZip?: EntryExtraFieldUnix;
|
|
1616
1841
|
/**
|
|
1617
1842
|
* The Info-ZIP Unix type 1 extra field (0x5855).
|
|
1618
1843
|
*/
|
|
@@ -1624,7 +1849,7 @@ export interface LocalDirectory {
|
|
|
1624
1849
|
/**
|
|
1625
1850
|
* The extended timestamp extra field.
|
|
1626
1851
|
*/
|
|
1627
|
-
extraFieldExtendedTimestamp?:
|
|
1852
|
+
extraFieldExtendedTimestamp?: EntryExtraFieldExtendedTimestamp;
|
|
1628
1853
|
/**
|
|
1629
1854
|
* The Unicode path extra field.
|
|
1630
1855
|
*/
|
|
@@ -1694,8 +1919,26 @@ export interface EntryMetaData {
|
|
|
1694
1919
|
filenameUTF8: boolean;
|
|
1695
1920
|
/**
|
|
1696
1921
|
* `true` if the entry is an executable file
|
|
1922
|
+
*
|
|
1923
|
+
* Always `false` when {@link EntryMetaData#symlink} is `true`: the permissions of a symbolic link
|
|
1924
|
+
* are not meaningful, Unix systems store them as `0o777`.
|
|
1697
1925
|
*/
|
|
1698
1926
|
executable: boolean;
|
|
1927
|
+
/**
|
|
1928
|
+
* `true` if the entry is a symbolic link, i.e. if the Unix file type stored in
|
|
1929
|
+
* {@link EntryMetaData#externalFileAttributes} is `S_IFLNK` (`0o120000`).
|
|
1930
|
+
*
|
|
1931
|
+
* The target of the link is the content of the entry, stored as a path with no trailing NUL
|
|
1932
|
+
* character. It is read like any other entry, e.g. with `entry.getData(new TextWriter())`.
|
|
1933
|
+
*
|
|
1934
|
+
* The path is not validated: it can be absolute or escape the archive with `..` segments. It must
|
|
1935
|
+
* be checked before being used to resolve a file.
|
|
1936
|
+
*
|
|
1937
|
+
* There is no option to write a symbolic link. Set the file type in
|
|
1938
|
+
* {@link ZipWriterConstructorOptions#unixMode} instead, i.e. pass `0o120777` with the path of the
|
|
1939
|
+
* target as the content of the entry.
|
|
1940
|
+
*/
|
|
1941
|
+
symlink: boolean;
|
|
1699
1942
|
/**
|
|
1700
1943
|
* `true` if the content of the entry is encrypted.
|
|
1701
1944
|
*/
|
|
@@ -1725,15 +1968,19 @@ export interface EntryMetaData {
|
|
|
1725
1968
|
*/
|
|
1726
1969
|
creationDate?: Date;
|
|
1727
1970
|
/**
|
|
1728
|
-
* The last modification date (raw).
|
|
1971
|
+
* The last modification date (raw), as the MS-DOS date and time stored in the header. Unlike
|
|
1972
|
+
* {@link EntryMetaData#lastModDate}, it is not replaced by the value of the NTFS extra field when that field
|
|
1973
|
+
* is present; read {@link EntryMetaData#extraFieldNTFS} for the raw NTFS value.
|
|
1729
1974
|
*/
|
|
1730
1975
|
rawLastModDate: number | bigint;
|
|
1731
1976
|
/**
|
|
1732
|
-
* The last access date (raw).
|
|
1977
|
+
* The last access date (raw), as the Windows `FILETIME` value stored in the NTFS extra field. Only defined
|
|
1978
|
+
* when that extra field is present.
|
|
1733
1979
|
*/
|
|
1734
1980
|
rawLastAccessDate?: number | bigint;
|
|
1735
1981
|
/**
|
|
1736
|
-
* The creation date (raw).
|
|
1982
|
+
* The creation date (raw), as the Windows `FILETIME` value stored in the NTFS extra field. Only defined when
|
|
1983
|
+
* that extra field is present.
|
|
1737
1984
|
*/
|
|
1738
1985
|
rawCreationDate?: number | bigint;
|
|
1739
1986
|
/**
|
|
@@ -1819,10 +2066,21 @@ export interface EntryMetaData {
|
|
|
1819
2066
|
};
|
|
1820
2067
|
/**
|
|
1821
2068
|
* Unix owner id when available.
|
|
2069
|
+
*
|
|
2070
|
+
* The value is read from the central directory. The Info-ZIP Unix extra fields type 1 (0x5855) and type 2
|
|
2071
|
+
* (0x7855) store the ids in the local file header only, so entries carrying just these fields leave the
|
|
2072
|
+
* property undefined until the data has been read, at which point it is filled in from
|
|
2073
|
+
* {@link EntryMetaData#localDirectory}. The Info-ZIP New Unix extra field (0x7875) and the PKWARE Unix
|
|
2074
|
+
* extra field (0x000d) store the ids in both headers and are unaffected.
|
|
2075
|
+
*
|
|
2076
|
+
* @remarks A value read from the central directory is never overwritten by the local file header, since the
|
|
2077
|
+
* type 2 field truncates the ids to 16 bits while the New Unix field does not.
|
|
1822
2078
|
*/
|
|
1823
2079
|
uid?: number;
|
|
1824
2080
|
/**
|
|
1825
2081
|
* Unix group id when available.
|
|
2082
|
+
*
|
|
2083
|
+
* See {@link EntryMetaData#uid} for the fields storing the ids in the local file header only.
|
|
1826
2084
|
*/
|
|
1827
2085
|
gid?: number;
|
|
1828
2086
|
/**
|
|
@@ -1898,7 +2156,7 @@ export interface EntryMetaData {
|
|
|
1898
2156
|
/**
|
|
1899
2157
|
* The Zip64 extra field.
|
|
1900
2158
|
*/
|
|
1901
|
-
extraFieldZip64?:
|
|
2159
|
+
extraFieldZip64?: EntryExtraFieldZip64;
|
|
1902
2160
|
/**
|
|
1903
2161
|
* The AES extra field.
|
|
1904
2162
|
*/
|
|
@@ -1906,15 +2164,18 @@ export interface EntryMetaData {
|
|
|
1906
2164
|
/**
|
|
1907
2165
|
* The NTFS extra field.
|
|
1908
2166
|
*/
|
|
1909
|
-
extraFieldNTFS?:
|
|
2167
|
+
extraFieldNTFS?: EntryExtraFieldNTFS;
|
|
1910
2168
|
/**
|
|
1911
|
-
* The Unix extra field.
|
|
2169
|
+
* The Info-ZIP Unix type 2 extra field (0x7855). Its uid/gid are stored in the local file header only, the
|
|
2170
|
+
* central directory version carries no data and merely flags their presence.
|
|
1912
2171
|
*/
|
|
1913
|
-
extraFieldUnix?:
|
|
2172
|
+
extraFieldUnix?: EntryExtraFieldUnix;
|
|
1914
2173
|
/**
|
|
1915
|
-
* The Info-ZIP Unix extra field.
|
|
2174
|
+
* The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers. It is read
|
|
2175
|
+
* whenever the type 2 extra field (0x7855) is absent or carries no ids, which is its usual state in the
|
|
2176
|
+
* central directory.
|
|
1916
2177
|
*/
|
|
1917
|
-
extraFieldInfoZip?:
|
|
2178
|
+
extraFieldInfoZip?: EntryExtraFieldUnix;
|
|
1918
2179
|
/**
|
|
1919
2180
|
* The Info-ZIP Unix type 1 extra field (0x5855).
|
|
1920
2181
|
*/
|
|
@@ -1926,7 +2187,7 @@ export interface EntryMetaData {
|
|
|
1926
2187
|
/**
|
|
1927
2188
|
* The extended timestamp extra field.
|
|
1928
2189
|
*/
|
|
1929
|
-
extraFieldExtendedTimestamp?:
|
|
2190
|
+
extraFieldExtendedTimestamp?: EntryExtraFieldExtendedTimestamp;
|
|
1930
2191
|
/**
|
|
1931
2192
|
* The Unicode path extra field.
|
|
1932
2193
|
*/
|
|
@@ -1941,6 +2202,11 @@ export interface EntryMetaData {
|
|
|
1941
2202
|
extraFieldUSDZ?: EntryExtraField;
|
|
1942
2203
|
/**
|
|
1943
2204
|
* The local file header fields, set when the entry data has been read.
|
|
2205
|
+
*
|
|
2206
|
+
* The local file header is the only place where the Info-ZIP Unix extra fields type 1 (0x5855) and type 2
|
|
2207
|
+
* (0x7855) store the uid/gid, so this is where they are read for entries carrying just these fields, e.g.
|
|
2208
|
+
* with `entry.localDirectory.extraFieldUnixType1.uid`. The values are not merged into
|
|
2209
|
+
* {@link EntryMetaData#uid} and {@link EntryMetaData#gid}, which are read from the central directory.
|
|
1944
2210
|
*/
|
|
1945
2211
|
localDirectory?: LocalDirectory;
|
|
1946
2212
|
}
|
|
@@ -2312,6 +2578,12 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2312
2578
|
*
|
|
2313
2579
|
* The minimum value is 0 and means that no compression is applied. The maximum value is 9.
|
|
2314
2580
|
*
|
|
2581
|
+
* The native API `CompressionStream` does not support compression levels. Any value other than 6,
|
|
2582
|
+
* its de facto level, disables `useCompressionStream` and compresses the data with the embedded
|
|
2583
|
+
* implementation instead. Note that the compressed data produced at a given level can still vary
|
|
2584
|
+
* between platforms. Set `useCompressionStream` to `false` to get deterministic output across
|
|
2585
|
+
* platforms.
|
|
2586
|
+
*
|
|
2315
2587
|
* @defaultValue 6
|
|
2316
2588
|
*/
|
|
2317
2589
|
level?: number;
|
|
@@ -2331,6 +2603,13 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2331
2603
|
* 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
2604
|
*
|
|
2333
2605
|
* 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.
|
|
2606
|
+
*
|
|
2607
|
+
* @remarks The `readable` side is consumed only once the `writable` side has been closed, since the local
|
|
2608
|
+
* header written before it holds the size and the CRC-32 of the entry. The object must therefore be able to
|
|
2609
|
+
* hold a whole entry, either by buffering it like the default
|
|
2610
|
+
* `new TransformStream(undefined, undefined, { highWaterMark: Infinity })` does, or by draining it like the
|
|
2611
|
+
* three implementations above do. A factory returning `new TransformStream()` deadlocks instead, its default
|
|
2612
|
+
* queuing strategy holding a single chunk.
|
|
2334
2613
|
*/
|
|
2335
2614
|
createTempStream?: () => TempStream | Promise<TempStream>;
|
|
2336
2615
|
/**
|
|
@@ -2380,7 +2659,8 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2380
2659
|
*
|
|
2381
2660
|
* This option is ignored if the {@link ZipWriterConstructorOptions#extendedTimestamp} option is set to `false`.
|
|
2382
2661
|
*
|
|
2383
|
-
* @
|
|
2662
|
+
* Unlike {@link ZipWriterConstructorOptions#lastModDate}, it has no default: the date is written only when the
|
|
2663
|
+
* option is set, so that the entries do not carry a meaningless access time.
|
|
2384
2664
|
*/
|
|
2385
2665
|
lastAccessDate?: Date;
|
|
2386
2666
|
/**
|
|
@@ -2388,7 +2668,8 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2388
2668
|
*
|
|
2389
2669
|
* This option is ignored if the {@link ZipWriterConstructorOptions#extendedTimestamp} option is set to `false`.
|
|
2390
2670
|
*
|
|
2391
|
-
* @
|
|
2671
|
+
* Unlike {@link ZipWriterConstructorOptions#lastModDate}, it has no default: the date is written only when the
|
|
2672
|
+
* option is set, so that the entries do not carry a meaningless creation time.
|
|
2392
2673
|
*/
|
|
2393
2674
|
creationDate?: Date;
|
|
2394
2675
|
/**
|
|
@@ -2423,9 +2704,18 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2423
2704
|
*/
|
|
2424
2705
|
version?: number;
|
|
2425
2706
|
/**
|
|
2426
|
-
* The "Version made by" field
|
|
2707
|
+
* The "Version made by" field, whose upper byte is the platform and lower byte the version of the
|
|
2708
|
+
* specification.
|
|
2709
|
+
*
|
|
2710
|
+
* The platform is not taken from the value passed here. It is forced to Unix (`3`) when the entry carries Unix
|
|
2711
|
+
* metadata, i.e. when {@link ZipWriterConstructorOptions#uid}, {@link ZipWriterConstructorOptions#gid},
|
|
2712
|
+
* {@link ZipWriterConstructorOptions#unixMode} or {@link ZipWriterConstructorOptions#unixExtraFieldType} is set,
|
|
2713
|
+
* since Unix mode bits stored under another platform are ignored by the extractors. It is forced to MS-DOS (`0`)
|
|
2714
|
+
* when {@link ZipWriterConstructorOptions#msdosAttributes} or
|
|
2715
|
+
* {@link ZipWriterConstructorOptions#msdosAttributesRaw} is set. Only the lower byte of the value survives in
|
|
2716
|
+
* both cases.
|
|
2427
2717
|
*
|
|
2428
|
-
* @defaultValue 20
|
|
2718
|
+
* @defaultValue 768, i.e. `3 << 8`, or 20 when {@link ZipWriterConstructorOptions#msDosCompatible} is set to `true`
|
|
2429
2719
|
*/
|
|
2430
2720
|
versionMadeBy?: number;
|
|
2431
2721
|
/**
|
|
@@ -2455,6 +2745,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2455
2745
|
/**
|
|
2456
2746
|
* `true` to write {@link EntryMetaData#externalFileAttributes} in MS-DOS format for folder entries.
|
|
2457
2747
|
*
|
|
2748
|
+
* It also selects the MS-DOS platform for {@link ZipWriterConstructorOptions#versionMadeBy} and leaves the Unix
|
|
2749
|
+
* attributes out of the entries. Setting any Unix metadata option, e.g.
|
|
2750
|
+
* {@link ZipWriterConstructorOptions#unixMode}, turns it back off.
|
|
2751
|
+
*
|
|
2458
2752
|
* @defaultValue false
|
|
2459
2753
|
*/
|
|
2460
2754
|
msDosCompatible?: boolean;
|
|
@@ -2467,6 +2761,12 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2467
2761
|
* attribute for folder entries, Unix default permissions when `msDosCompatible` is `false`).
|
|
2468
2762
|
*/
|
|
2469
2763
|
externalFileAttributes?: number;
|
|
2764
|
+
/**
|
|
2765
|
+
* The external file attribute.
|
|
2766
|
+
*
|
|
2767
|
+
* @deprecated Use {@link ZipWriterConstructorOptions#externalFileAttributes} instead.
|
|
2768
|
+
*/
|
|
2769
|
+
externalFileAttribute?: number;
|
|
2470
2770
|
/**
|
|
2471
2771
|
* The Unix owner id to write in the Unix extra field or as part of the external attributes.
|
|
2472
2772
|
*/
|
|
@@ -2477,6 +2777,16 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2477
2777
|
gid?: number;
|
|
2478
2778
|
/**
|
|
2479
2779
|
* The Unix mode (st_mode bits) to use when writing external attributes.
|
|
2780
|
+
*
|
|
2781
|
+
* The value includes the Unix file type, so it is also how a symbolic link is written: pass
|
|
2782
|
+
* `0o120777` and use the path of the link target as the content of the entry. Extractors that
|
|
2783
|
+
* support symbolic links, e.g. Info-ZIP `unzip`, then restore the entry as a link.
|
|
2784
|
+
*
|
|
2785
|
+
* A folder entry is always written with `S_IFDIR` (`0o040000`), replacing any file type carried by the
|
|
2786
|
+
* value, so the same mode can be set once on the writer and reused for every entry. Any other entry keeps
|
|
2787
|
+
* the file type it is given, and is written with `S_IFREG` (`0o100000`) when the value carries none. Set
|
|
2788
|
+
* {@link ZipWriterConstructorOptions#externalFileAttributes} instead to write a mode with no
|
|
2789
|
+
* file type.
|
|
2480
2790
|
*/
|
|
2481
2791
|
unixMode?: number;
|
|
2482
2792
|
/**
|
|
@@ -2505,6 +2815,12 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2505
2815
|
* @defaultValue 0
|
|
2506
2816
|
*/
|
|
2507
2817
|
internalFileAttributes?: number;
|
|
2818
|
+
/**
|
|
2819
|
+
* The internal file attribute.
|
|
2820
|
+
*
|
|
2821
|
+
* @deprecated Use {@link ZipWriterConstructorOptions#internalFileAttributes} instead.
|
|
2822
|
+
*/
|
|
2823
|
+
internalFileAttribute?: number;
|
|
2508
2824
|
/**
|
|
2509
2825
|
* When provided, the low 8-bit MS-DOS attributes to write into external file attributes.
|
|
2510
2826
|
* Must be an integer between 0 and 255.
|
|
@@ -2537,6 +2853,16 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2537
2853
|
usdz?: boolean;
|
|
2538
2854
|
/**
|
|
2539
2855
|
* `true` to write the data as-is without compressing it and without crypting it.
|
|
2856
|
+
*
|
|
2857
|
+
* @remarks
|
|
2858
|
+
* The {@link ZipWriterConstructorOptions#level} and {@link ZipWriterAddDataOptions#compressionMethod} options
|
|
2859
|
+
* do not apply to data written as-is, and the entries with no content, e.g. the directories, ignore this
|
|
2860
|
+
* option entirely. Setting the {@link ZipWriterConstructorOptions#password} or the
|
|
2861
|
+
* {@link ZipWriterConstructorOptions#rawPassword} option throws an
|
|
2862
|
+
* {@link ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH} error, unless the
|
|
2863
|
+
* {@link ZipWriterConstructorOptions#encrypted} option is set to `true` to declare that the data is already
|
|
2864
|
+
* encrypted. In that case the password encrypts the other entries only, and the data written as-is keeps the
|
|
2865
|
+
* password it was encrypted with, which is not verified.
|
|
2540
2866
|
*/
|
|
2541
2867
|
passThrough?: boolean;
|
|
2542
2868
|
/**
|
|
@@ -2563,6 +2889,13 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2563
2889
|
|
|
2564
2890
|
/**
|
|
2565
2891
|
* Represents options passed to {@link FileEntry#getData}, {@link ZipWriter.add} and `{@link ZipDirectory}.export*`.
|
|
2892
|
+
*
|
|
2893
|
+
* @remarks
|
|
2894
|
+
* When passed to `{@link ZipDirectory}.export*`, these functions report the progress of the whole archive instead
|
|
2895
|
+
* of the progress of each entry: {@link EntryDataOnprogressOptions#onstart} and
|
|
2896
|
+
* {@link EntryDataOnprogressOptions#onend} are called once, and the total number of bytes is the sum of the sizes
|
|
2897
|
+
* of all the entries. Use {@link ZipDirectoryEntryExportOptions#onentryprogress} to be notified when each entry
|
|
2898
|
+
* is written.
|
|
2566
2899
|
*/
|
|
2567
2900
|
export interface EntryDataOnprogressOptions {
|
|
2568
2901
|
/**
|
|
@@ -2630,6 +2963,10 @@ declare class ZipEntry {
|
|
|
2630
2963
|
parent?: ZipEntry;
|
|
2631
2964
|
/**
|
|
2632
2965
|
* The uncompressed size of the content.
|
|
2966
|
+
*
|
|
2967
|
+
* @remarks It is the size of the raw compressed content when the entry has been imported with the
|
|
2968
|
+
* `passThrough` option set to `true`, since the entry holds the compressed data in that case. The
|
|
2969
|
+
* uncompressed size of the original entry remains available in {@link ZipEntry#data}.
|
|
2633
2970
|
*/
|
|
2634
2971
|
uncompressedSize: number;
|
|
2635
2972
|
/**
|
|
@@ -2932,6 +3269,10 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
2932
3269
|
/**
|
|
2933
3270
|
* Adds an entry with content provided via a `FileSystemEntry` instance
|
|
2934
3271
|
*
|
|
3272
|
+
* The options apply to every entry added, including the directories. The
|
|
3273
|
+
* {@link ZipWriterConstructorOptions#lastModDate} option replaces the last modification date of the
|
|
3274
|
+
* files, which is otherwise taken from each `FileSystemEntry` instance.
|
|
3275
|
+
*
|
|
2935
3276
|
* @param fileSystemEntry The `FileSystemEntry` instance.
|
|
2936
3277
|
* @param options The options.
|
|
2937
3278
|
* @returns A promise resolving to an array of {@link ZipFileEntry} or a {@link ZipDirectoryEntry} instances.
|
|
@@ -2947,6 +3288,10 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
2947
3288
|
* whose {@link EntryError#entryName} is the path of the handle that failed, relative to the parent
|
|
2948
3289
|
* of `fileSystemHandle`.
|
|
2949
3290
|
*
|
|
3291
|
+
* The options apply to every entry added, including the directories. The
|
|
3292
|
+
* {@link ZipWriterConstructorOptions#lastModDate} option replaces the last modification date of the
|
|
3293
|
+
* files, which is otherwise taken from each `FileSystemHandle` instance.
|
|
3294
|
+
*
|
|
2950
3295
|
* @param fileSystemHandle The `fileSystemHandle` instance.
|
|
2951
3296
|
* @param options The options.
|
|
2952
3297
|
* @returns A promise resolving to an array of {@link ZipFileEntry} or a {@link ZipDirectoryEntry} instances.
|
|
@@ -2960,6 +3305,9 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
2960
3305
|
*
|
|
2961
3306
|
* @param blob The `Blob` instance.
|
|
2962
3307
|
* @param options The options.
|
|
3308
|
+
*
|
|
3309
|
+
* @remarks Use {@link ZipDirectoryEntry#importZip} with a {@link ZipReader} instance to read the data of the
|
|
3310
|
+
* zip file itself, e.g. its {@link ZipReader#prependedData} or its {@link ZipReader#comment} property.
|
|
2963
3311
|
*/
|
|
2964
3312
|
importBlob(
|
|
2965
3313
|
blob: Blob,
|
|
@@ -2970,6 +3318,9 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
2970
3318
|
*
|
|
2971
3319
|
* @param dataURI The Data URI `string` encoded in Base64.
|
|
2972
3320
|
* @param options The options.
|
|
3321
|
+
*
|
|
3322
|
+
* @remarks Use {@link ZipDirectoryEntry#importZip} with a {@link ZipReader} instance to read the data of the
|
|
3323
|
+
* zip file itself, e.g. its {@link ZipReader#prependedData} or its {@link ZipReader#comment} property.
|
|
2973
3324
|
*/
|
|
2974
3325
|
importData64URI(
|
|
2975
3326
|
dataURI: string,
|
|
@@ -2980,6 +3331,9 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
2980
3331
|
*
|
|
2981
3332
|
* @param array The `Uint8Array` instance.
|
|
2982
3333
|
* @param options The options.
|
|
3334
|
+
*
|
|
3335
|
+
* @remarks Use {@link ZipDirectoryEntry#importZip} with a {@link ZipReader} instance to read the data of the
|
|
3336
|
+
* zip file itself, e.g. its {@link ZipReader#prependedData} or its {@link ZipReader#comment} property.
|
|
2983
3337
|
*/
|
|
2984
3338
|
importUint8Array(
|
|
2985
3339
|
array: Uint8Array,
|
|
@@ -2990,6 +3344,9 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
2990
3344
|
*
|
|
2991
3345
|
* @param url The URL.
|
|
2992
3346
|
* @param options The options.
|
|
3347
|
+
*
|
|
3348
|
+
* @remarks Use {@link ZipDirectoryEntry#importZip} with a {@link ZipReader} instance to read the data of the
|
|
3349
|
+
* zip file itself, e.g. its {@link ZipReader#prependedData} or its {@link ZipReader#comment} property.
|
|
2993
3350
|
*/
|
|
2994
3351
|
importHttpContent(
|
|
2995
3352
|
url: string,
|
|
@@ -3000,21 +3357,30 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3000
3357
|
*
|
|
3001
3358
|
* @param readable The `ReadableStream` instance.
|
|
3002
3359
|
* @param options The options.
|
|
3360
|
+
*
|
|
3361
|
+
* @remarks Use {@link ZipDirectoryEntry#importZip} with a {@link ZipReader} instance to read the data of the
|
|
3362
|
+
* zip file itself, e.g. its {@link ZipReader#prependedData} or its {@link ZipReader#comment} property.
|
|
3003
3363
|
*/
|
|
3004
3364
|
importReadable(
|
|
3005
3365
|
readable: ReadableStream,
|
|
3006
3366
|
options?: ZipReaderConstructorOptions
|
|
3007
3367
|
): Promise<[ZipEntry]>;
|
|
3008
3368
|
/**
|
|
3009
|
-
* Extracts a zip file provided via a custom {@link Reader} instance
|
|
3369
|
+
* Extracts a zip file provided via a custom {@link Reader} instance or a {@link ZipReader} instance into
|
|
3370
|
+
* the entry
|
|
3010
3371
|
*
|
|
3011
|
-
* @param reader The {@link Reader} instance.
|
|
3372
|
+
* @param reader The {@link Reader} instance or the {@link ZipReader} instance.
|
|
3012
3373
|
* @param options The options.
|
|
3013
3374
|
*
|
|
3014
3375
|
* @remarks The filename of each entry is split into path components to build the tree of entries. Empty
|
|
3015
3376
|
* components and `"."` components are ignored, so `"a//b.txt"`, `"./a/b.txt"` and `"a/./b.txt"` all produce
|
|
3016
3377
|
* the same `"a/b.txt"` entry. Filenames are normalized and validated beforehand, see
|
|
3017
3378
|
* {@link GetEntriesOptions#normalizeFilename} and {@link GetEntriesOptions#filenameValidation}.
|
|
3379
|
+
*
|
|
3380
|
+
* Passing a {@link ZipReader} instance is the way to read the data of the zip file itself, e.g. its
|
|
3381
|
+
* {@link ZipReader#prependedData} or its {@link ZipReader#comment} property, since the instance created
|
|
3382
|
+
* otherwise is not exposed. Its options are used as defaults for the options passed here, and it must not
|
|
3383
|
+
* have read its entries yet when it is created over a `ReadableStream` instance, which can only be read once.
|
|
3018
3384
|
*/
|
|
3019
3385
|
importZip(
|
|
3020
3386
|
reader:
|
|
@@ -3023,7 +3389,8 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3023
3389
|
| ReadableStream
|
|
3024
3390
|
| Reader<unknown>[]
|
|
3025
3391
|
| ReadableReader[]
|
|
3026
|
-
| ReadableStream[]
|
|
3392
|
+
| ReadableStream[]
|
|
3393
|
+
| ZipReader<unknown>,
|
|
3027
3394
|
options?: ZipReaderConstructorOptions
|
|
3028
3395
|
): Promise<[ZipEntry]>;
|
|
3029
3396
|
/**
|
|
@@ -3081,7 +3448,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3081
3448
|
* Running the same export again is the supported way to recover, since directories are merged and
|
|
3082
3449
|
* files are overwritten.
|
|
3083
3450
|
*
|
|
3084
|
-
* @remarks An entry flagged as a symbolic link by
|
|
3451
|
+
* @remarks An entry flagged as a symbolic link by {@link EntryMetaData#symlink} is written
|
|
3085
3452
|
* as a regular file whose content is the path of the link target, because the File System Access API cannot
|
|
3086
3453
|
* create symbolic links.
|
|
3087
3454
|
*
|
|
@@ -3108,6 +3475,34 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3108
3475
|
| AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream>,
|
|
3109
3476
|
options?: ZipDirectoryEntryExportOptions
|
|
3110
3477
|
): Promise<unknown>;
|
|
3478
|
+
/**
|
|
3479
|
+
* Computes the exact size in bytes of the zip file that `export*()` would produce for the entry
|
|
3480
|
+
* and its descendants, without reading or compressing any data.
|
|
3481
|
+
*
|
|
3482
|
+
* Pass the same options object that will be passed to the export method, otherwise the result
|
|
3483
|
+
* will not match. The size is only determinable when every descendant is stored (i.e. `level` is
|
|
3484
|
+
* set to 0) or passed through, and has a known size; {@link ERR_UNDETERMINED_SIZE} is thrown
|
|
3485
|
+
* otherwise. Encryption does not prevent it, the overhead of ZipCrypto and AES being fixed.
|
|
3486
|
+
*
|
|
3487
|
+
* The intended use is setting the `Content-Length` header of a zip file streamed over HTTP.
|
|
3488
|
+
*
|
|
3489
|
+
* @remarks Entries added with {@link ZipDirectoryEntry#addReadable} never have a known size, and
|
|
3490
|
+
* entries added with {@link ZipDirectoryEntry#addHttpContent} only get one once their content has
|
|
3491
|
+
* been read. The returned size assumes a single output file, it does not apply to split zip files.
|
|
3492
|
+
*
|
|
3493
|
+
* {@link ERR_UNDETERMINED_SIZE} is also thrown when the size depends on the order in which the
|
|
3494
|
+
* entries are physically written, which the buffered write path only determines at write time.
|
|
3495
|
+
* This happens when `usdz` is set, since the alignment padding depends on the offset of each
|
|
3496
|
+
* entry, and when the archive exceeds 4GB, since the offsets recorded in the central directory
|
|
3497
|
+
* are then extended to 64 bits. Passing `bufferedWrite: false` makes both determinable again,
|
|
3498
|
+
* as does exporting a directory whose children are all files. It is thrown as well when
|
|
3499
|
+
* `signCentralDirectory` is set, the length of the signature being unknown until it is computed.
|
|
3500
|
+
*
|
|
3501
|
+
* @param options The options.
|
|
3502
|
+
* @returns A promise resolving to the size in bytes.
|
|
3503
|
+
* @throws {@link ERR_UNDETERMINED_SIZE} if the size cannot be determined.
|
|
3504
|
+
*/
|
|
3505
|
+
getExportedSize(options?: ZipDirectoryEntryExportOptions): Promise<number>;
|
|
3111
3506
|
}
|
|
3112
3507
|
|
|
3113
3508
|
/**
|
|
@@ -3131,6 +3526,37 @@ export interface ZipDirectoryEntryGetChildrenOptions {
|
|
|
3131
3526
|
|
|
3132
3527
|
/**
|
|
3133
3528
|
* Represents the options passed to `{@link ZipDirectoryEntry}#export*()`.
|
|
3529
|
+
*
|
|
3530
|
+
* @remarks
|
|
3531
|
+
* The options set here apply to every entry of the exported zip file, including the entries imported
|
|
3532
|
+
* from a zip file: such an entry keeps the metadata of the entry it was imported from, e.g. its
|
|
3533
|
+
* {@link ZipWriterConstructorOptions#lastModDate} option, only when the option is not set here. The
|
|
3534
|
+
* options passed when adding an entry to the filesystem take precedence over the options set here, and
|
|
3535
|
+
* the options describing the data of the entries exported as-is, e.g.
|
|
3536
|
+
* {@link ZipWriterConstructorOptions#compressionMethod} and
|
|
3537
|
+
* {@link ZipWriterAddDataOptions#uncompressedSize}, are always the ones of the original entries.
|
|
3538
|
+
*
|
|
3539
|
+
* The {@link ZipWriterConstructorOptions#password} option encrypts the exported zip file. It never
|
|
3540
|
+
* decrypts the entries being exported: the password of an entry imported from an encrypted zip file
|
|
3541
|
+
* must be passed in the {@link ZipDirectoryEntryExportOptions#readerOptions} option instead.
|
|
3542
|
+
*
|
|
3543
|
+
* Likewise, the {@link ZipWriterConstructorOptions#passThrough} option describes the data returned
|
|
3544
|
+
* by the Reader instances. Exporting entries imported from a zip file as-is is done with the
|
|
3545
|
+
* {@link ZipReaderOptions#passThrough} option in the
|
|
3546
|
+
* {@link ZipDirectoryEntryExportOptions#readerOptions} option instead. Setting it here throws an
|
|
3547
|
+
* {@link ERR_INVALID_PASS_THROUGH} error, unless the {@link ZipWriterAddDataOptions#uncompressedSize}
|
|
3548
|
+
* option of every entry holding content is known.
|
|
3549
|
+
*
|
|
3550
|
+
* Exporting entries as-is and setting the {@link ZipWriterConstructorOptions#password} option throws an
|
|
3551
|
+
* {@link ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH} error, since the data of these entries is copied
|
|
3552
|
+
* verbatim and cannot be encrypted. Entries imported from an encrypted zip file are an exception: they
|
|
3553
|
+
* are exported as-is without error, and keep the password they were encrypted with.
|
|
3554
|
+
*
|
|
3555
|
+
* The {@link ZipWriterConstructorOptions#preventClose} option only applies when the caller owns the
|
|
3556
|
+
* writable, i.e. when a {@link WritableWriter} instance is passed to
|
|
3557
|
+
* {@link ZipDirectoryEntry#exportZip} or {@link ZipDirectoryEntry#exportWritable}. It is ignored by the
|
|
3558
|
+
* other `{@link ZipDirectoryEntry}#export*()` methods, whose Writer instance can only return its data
|
|
3559
|
+
* once its writable is closed.
|
|
3134
3560
|
*/
|
|
3135
3561
|
export interface ZipDirectoryEntryExportOptions
|
|
3136
3562
|
extends ZipWriterConstructorOptions,
|
|
@@ -3144,13 +3570,66 @@ export interface ZipDirectoryEntryExportOptions
|
|
|
3144
3570
|
*/
|
|
3145
3571
|
mimeType?: string;
|
|
3146
3572
|
/**
|
|
3147
|
-
* The
|
|
3573
|
+
* The function called each time an entry is written.
|
|
3574
|
+
*
|
|
3575
|
+
* @remarks
|
|
3576
|
+
* This function reports the entries whereas {@link EntryDataOnprogressOptions#onprogress} reports the
|
|
3577
|
+
* bytes. It is called once per entry, after the entry has been written, so `progress` reaches `total`
|
|
3578
|
+
* when the last entry is written.
|
|
3579
|
+
*
|
|
3580
|
+
* When {@link ZipWriterConstructorOptions#bufferedWrite} is enabled, the entries are written
|
|
3581
|
+
* concurrently: `progress` counts the entries written instead of giving the position of the entry in
|
|
3582
|
+
* the zip file.
|
|
3583
|
+
*
|
|
3584
|
+
* @param progress The number of entries written.
|
|
3585
|
+
* @param total The total number of entries.
|
|
3586
|
+
* @param entry The entry written.
|
|
3587
|
+
* @returns An empty promise or `undefined`.
|
|
3588
|
+
*/
|
|
3589
|
+
onentryprogress?(
|
|
3590
|
+
progress: number,
|
|
3591
|
+
total: number,
|
|
3592
|
+
entry: EntryMetaData
|
|
3593
|
+
): Promise<void> | void;
|
|
3594
|
+
/**
|
|
3595
|
+
* The global comment of the zip file, see {@link ZipWriter#close}.
|
|
3596
|
+
*
|
|
3597
|
+
* @remarks
|
|
3598
|
+
* The {@link ZipWriterAddDataOptions#comment} option is the comment of an entry: setting it here
|
|
3599
|
+
* comments every entry of the exported zip file instead of the zip file itself.
|
|
3600
|
+
*/
|
|
3601
|
+
globalComment?: Uint8Array;
|
|
3602
|
+
/**
|
|
3603
|
+
* The function called for signing the central directory, see
|
|
3604
|
+
* {@link ZipWriterCloseOptions#signCentralDirectory}.
|
|
3605
|
+
*
|
|
3606
|
+
* @param directory The raw data of the central directory records.
|
|
3607
|
+
* @returns The data of the digital signature record.
|
|
3608
|
+
*/
|
|
3609
|
+
signCentralDirectory?(
|
|
3610
|
+
directory: Uint8Array
|
|
3611
|
+
): Uint8Array | PromiseLike<Uint8Array>;
|
|
3612
|
+
/**
|
|
3613
|
+
* The options passed to the Reader instances.
|
|
3614
|
+
*
|
|
3615
|
+
* @remarks
|
|
3616
|
+
* The {@link ZipReaderOptions#password} option must be set here to export entries imported from an
|
|
3617
|
+
* encrypted zip file, since the {@link ZipDirectoryEntryExportOptions#password} option sets the
|
|
3618
|
+
* password used to encrypt the exported zip file instead.
|
|
3619
|
+
*
|
|
3620
|
+
* The {@link ZipReaderOptions#passThrough} option set here exports the entries imported from a zip
|
|
3621
|
+
* file as-is, without decompressing and decrypting them, exactly as importing them with this option
|
|
3622
|
+
* does. It is ignored by the entries added to the filesystem, which are compressed as usual.
|
|
3148
3623
|
*/
|
|
3149
3624
|
readerOptions?: ZipReaderConstructorOptions;
|
|
3150
3625
|
}
|
|
3151
3626
|
|
|
3152
3627
|
/**
|
|
3153
3628
|
* Represents the options passed to {@link ZipDirectoryEntry#exportFileSystemHandle} and {@link FS#exportFileSystemHandle}.
|
|
3629
|
+
*
|
|
3630
|
+
* @remarks
|
|
3631
|
+
* The {@link ZipReaderOptions#preventClose} option is ignored: the export owns the writable of each
|
|
3632
|
+
* file it creates and must close it for the data to be written.
|
|
3154
3633
|
*/
|
|
3155
3634
|
export interface ZipDirectoryEntryExportFileSystemHandleOptions
|
|
3156
3635
|
extends EntryGetDataOptions {
|
|
@@ -3165,6 +3644,15 @@ export interface ZipDirectoryEntryExportFileSystemHandleOptions
|
|
|
3165
3644
|
* @defaultValue false
|
|
3166
3645
|
*/
|
|
3167
3646
|
concurrent?: boolean;
|
|
3647
|
+
/**
|
|
3648
|
+
* The options passed to the Reader instances.
|
|
3649
|
+
*
|
|
3650
|
+
* @remarks
|
|
3651
|
+
* These options override the ones passed at the top level. The {@link ZipReaderOptions#password}
|
|
3652
|
+
* option can be set here or at the top level, unlike {@link ZipDirectoryEntryExportOptions} where
|
|
3653
|
+
* the top-level password encrypts the exported zip file instead.
|
|
3654
|
+
*/
|
|
3655
|
+
readerOptions?: ZipReaderConstructorOptions;
|
|
3168
3656
|
}
|
|
3169
3657
|
|
|
3170
3658
|
/**
|
|
@@ -3212,6 +3700,7 @@ export interface FS
|
|
|
3212
3700
|
| "exportWritable"
|
|
3213
3701
|
| "exportFileSystemHandle"
|
|
3214
3702
|
| "exportZip"
|
|
3703
|
+
| "getExportedSize"
|
|
3215
3704
|
| "isPasswordProtected"
|
|
3216
3705
|
| "checkPassword"
|
|
3217
3706
|
> {}
|
|
@@ -3264,20 +3753,14 @@ export class FS {
|
|
|
3264
3753
|
export const fs: {
|
|
3265
3754
|
/**
|
|
3266
3755
|
* The Filesystem constructor.
|
|
3267
|
-
*
|
|
3268
|
-
* @defaultValue {@link FS}
|
|
3269
3756
|
*/
|
|
3270
3757
|
FS: typeof FS;
|
|
3271
3758
|
/**
|
|
3272
3759
|
* The {@link ZipDirectoryEntry} constructor.
|
|
3273
|
-
*
|
|
3274
|
-
* @defaultValue {@link ZipDirectoryEntry}
|
|
3275
3760
|
*/
|
|
3276
3761
|
ZipDirectoryEntry: typeof ZipDirectoryEntry;
|
|
3277
3762
|
/**
|
|
3278
3763
|
* The {@link ZipFileEntry} constructor.
|
|
3279
|
-
*
|
|
3280
|
-
* @defaultValue {@link ZipFileEntry}
|
|
3281
3764
|
*/
|
|
3282
3765
|
ZipFileEntry: typeof ZipFileEntry;
|
|
3283
3766
|
};
|
|
@@ -3394,6 +3877,10 @@ export const ERR_DUPLICATED_NAME: string;
|
|
|
3394
3877
|
* Invalid comment error
|
|
3395
3878
|
*/
|
|
3396
3879
|
export const ERR_INVALID_COMMENT: string;
|
|
3880
|
+
/**
|
|
3881
|
+
* Invalid comment type error
|
|
3882
|
+
*/
|
|
3883
|
+
export const ERR_INVALID_COMMENT_TYPE: string;
|
|
3397
3884
|
/**
|
|
3398
3885
|
* Invalid entry name error
|
|
3399
3886
|
*/
|
|
@@ -3422,6 +3909,10 @@ export const ERR_INVALID_ENCRYPTION_STRENGTH: string;
|
|
|
3422
3909
|
* Unsupported encryption in USDZ files error
|
|
3423
3910
|
*/
|
|
3424
3911
|
export const ERR_UNSUPPORTED_ENCRYPTION_USDZ: string;
|
|
3912
|
+
/**
|
|
3913
|
+
* Unsupported encryption in pass-through entries error
|
|
3914
|
+
*/
|
|
3915
|
+
export const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH: string;
|
|
3425
3916
|
/**
|
|
3426
3917
|
* Invalid format error
|
|
3427
3918
|
*/
|
|
@@ -3475,8 +3966,13 @@ export const ERR_ITERATOR_COMPLETED_TOO_SOON: string;
|
|
|
3475
3966
|
* Undefined uncompressed size error
|
|
3476
3967
|
*/
|
|
3477
3968
|
export const ERR_UNDEFINED_UNCOMPRESSED_SIZE: string;
|
|
3969
|
+
export const ERR_UNDETERMINED_SIZE: string;
|
|
3478
3970
|
/**
|
|
3479
3971
|
* Undefined reader error
|
|
3972
|
+
*
|
|
3973
|
+
* @remarks Thrown when adding an entry with the {@link ZipWriterConstructorOptions#passThrough} option set to `true`
|
|
3974
|
+
* and no Reader instance: the headers of such an entry describe its content verbatim and would declare content that
|
|
3975
|
+
* is not there. Directory entries are exempt, they have no content to write as-is.
|
|
3480
3976
|
*/
|
|
3481
3977
|
export const ERR_UNDEFINED_READER: string;
|
|
3482
3978
|
/**
|
|
@@ -3530,6 +4026,16 @@ export const ERR_INVALID_LEVEL: string;
|
|
|
3530
4026
|
* would produce an archive that cannot be opened with the equivalent {@link ZipWriterConstructorOptions#password}.
|
|
3531
4027
|
*/
|
|
3532
4028
|
export const ERR_INVALID_PASSWORD_TYPE: string;
|
|
4029
|
+
/**
|
|
4030
|
+
* Invalid passThrough option error (thrown by `{@link ZipDirectoryEntry}#export*()` and
|
|
4031
|
+
* {@link ZipDirectoryEntry#getExportedSize} when an entry would be written as-is without a known uncompressed size)
|
|
4032
|
+
*
|
|
4033
|
+
* @remarks The {@link ZipWriterConstructorOptions#passThrough} option describes the data returned by the Reader
|
|
4034
|
+
* instances, which the filesystem API creates itself. Use the {@link ZipReaderOptions#passThrough} option in the
|
|
4035
|
+
* {@link ZipDirectoryEntryExportOptions#readerOptions} option to export the entries imported from a zip file as-is,
|
|
4036
|
+
* or set the {@link ZipWriterAddDataOptions#uncompressedSize} option of each entry holding compressed data.
|
|
4037
|
+
*/
|
|
4038
|
+
export const ERR_INVALID_PASS_THROUGH: string;
|
|
3533
4039
|
/**
|
|
3534
4040
|
* Entry already exists error (thrown by the filesystem API when adding an entry whose filename already exists)
|
|
3535
4041
|
*/
|