@zip.js/zip.js 2.20.0 → 2.21.0
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 +327 -211
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +327 -211
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +327 -211
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +327 -211
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +327 -211
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +327 -211
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +327 -211
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +327 -211
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +327 -211
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +327 -211
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +327 -211
- package/index-native.min.js +1 -1
- package/index.cjs +327 -211
- package/index.d.cts +62 -29
- package/index.d.ts +62 -29
- package/index.min.js +1 -1
- package/lib/core/constants.js +7 -0
- package/lib/core/version.js +1 -1
- package/lib/core/zip-reader.js +156 -69
- package/lib/core/zip-writer.js +172 -142
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -1545,8 +1545,9 @@ export class ZipReader<Type> {
|
|
|
1545
1545
|
* {@link WARNING_APPENDED_DATA}, {@link WARNING_PREPENDED_DATA}, {@link WARNING_TRAILING_CENTRAL_DIRECTORY_DATA},
|
|
1546
1546
|
* {@link WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET}, {@link WARNING_DUPLICATE_FILENAME} and
|
|
1547
1547
|
* {@link WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY}.
|
|
1548
|
-
* {@link WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY} is
|
|
1549
|
-
*
|
|
1548
|
+
* {@link WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY} is never deposited as a warning: `"balanced"` rejects it
|
|
1549
|
+
* like `"strict"`, and `"tolerant"` reads the last record and reports the stale one as
|
|
1550
|
+
* {@link WARNING_TRAILING_CENTRAL_DIRECTORY_DATA}. {@link WARNING_MISSING_ZIP64_EXTRA_FIELD} is deposited when an
|
|
1550
1551
|
* entry cannot be read because its central directory record lacks a Zip64 extra field, and `"strict"` throws
|
|
1551
1552
|
* {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND} for it.
|
|
1552
1553
|
*
|
|
@@ -1889,7 +1890,10 @@ export interface ZipReaderOptions {
|
|
|
1889
1890
|
* (e.g. streaming readers based on local file headers) interpret the entry differently. This detects mismatched
|
|
1890
1891
|
* filenames, general purpose bit flags (encryption, data descriptor and language encoding flags), compression
|
|
1891
1892
|
* methods, CRC-32 checksums and sizes. The extra fields are not compared because the zip specification allows
|
|
1892
|
-
* them to differ.
|
|
1893
|
+
* them to differ. A local file header whose CRC-32 checksum and sizes are all zero without the data descriptor
|
|
1894
|
+
* flag is tolerated, because some streaming writers leave these fields blank. When the entry has a data
|
|
1895
|
+
* descriptor, its CRC-32 checksum and sizes are compared with the central directory record instead, provided
|
|
1896
|
+
* the descriptor is read, i.e. when {@link ZipReaderOptions#checkOverlappingEntry} is set.
|
|
1893
1897
|
*
|
|
1894
1898
|
* This is the boolean form of {@link ZipReaderOptions#strictness}: `true` means `"strict"` and `false` means
|
|
1895
1899
|
* any value but `"strict"`. When both options are set, the value passed to {@link FileEntry#getData} takes
|
|
@@ -2566,11 +2570,13 @@ export interface EntryMetaData {
|
|
|
2566
2570
|
*/
|
|
2567
2571
|
lastModDate: Date;
|
|
2568
2572
|
/**
|
|
2569
|
-
* The last access date
|
|
2573
|
+
* The last access date, read from the extra fields of the central directory record or, when it holds none, from
|
|
2574
|
+
* the extra fields of the local file header once the data of the entry has been read.
|
|
2570
2575
|
*/
|
|
2571
2576
|
lastAccessDate?: Date;
|
|
2572
2577
|
/**
|
|
2573
|
-
* The creation date
|
|
2578
|
+
* The creation date, read from the extra fields of the central directory record or, when it holds none, from
|
|
2579
|
+
* the extra fields of the local file header once the data of the entry has been read.
|
|
2574
2580
|
*/
|
|
2575
2581
|
creationDate?: Date;
|
|
2576
2582
|
/**
|
|
@@ -3073,15 +3079,21 @@ export class ZipWriter<Type> {
|
|
|
3073
3079
|
* @remarks
|
|
3074
3080
|
* The data of the zip file is copied, its central directory is rebuilt and its entries are relocated to
|
|
3075
3081
|
* the positions they get in the output. The disks of a split zip file passed as input are therefore unrelated to
|
|
3076
|
-
* the disks of the output, which is a single zip file unless the writer is a split zip file writer.
|
|
3082
|
+
* the disks of the output, which is a single zip file unless the writer is a split zip file writer. In that case,
|
|
3083
|
+
* the bytes before the first entry (e.g. a self-extracting stub) are copied after the split zip file signature of
|
|
3084
|
+
* the first disk, where no system runs them; use the {@link ZipWriterAppendZipOptions#filter} option to drop them. The data of
|
|
3077
3085
|
* the entries is copied as-is; in particular, the constraints set by {@link ZipWriterConstructorOptions#usdz}
|
|
3078
|
-
* are not applied to the copied entries.
|
|
3086
|
+
* are not applied to the copied entries. The comment and the digital signature of the zip file are not copied,
|
|
3087
|
+
* since its central directory is rebuilt: pass them to {@link ZipWriter#close}.
|
|
3079
3088
|
*
|
|
3080
3089
|
* Pending {@link ZipWriter#add} calls are completed before the data is copied, and add() calls made
|
|
3081
3090
|
* while the copy is in progress are written after it. If an entry of the zip file has the same
|
|
3082
3091
|
* filename as an entry of the current zip, the method throws with the `ERR_DUPLICATED_NAME` error
|
|
3083
3092
|
* message and leaves the current zip unchanged; call {@link ZipWriter#remove} beforehand to resolve
|
|
3084
|
-
* the conflicts.
|
|
3093
|
+
* the conflicts. An entry whose sizes or offset are unusable because its Zip64 extra field is missing (see
|
|
3094
|
+
* {@link WARNING_MISSING_ZIP64_EXTRA_FIELD}) cannot be copied: the method throws
|
|
3095
|
+
* {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND} and leaves the current zip unchanged, unless the
|
|
3096
|
+
* {@link ZipWriterAppendZipOptions#filter} option leaves the entry out.
|
|
3085
3097
|
*
|
|
3086
3098
|
* The returned promise can safely be left un-awaited: {@link ZipWriter#close} waits for the copy
|
|
3087
3099
|
* and throws its error if it was not caught.
|
|
@@ -3328,15 +3340,24 @@ export interface ZipWriterAppendZipOptions {
|
|
|
3328
3340
|
/**
|
|
3329
3341
|
* Selects the entries of the zip file to copy: the function is called once per entry, in the order of the
|
|
3330
3342
|
* central directory, and the entry is copied when it returns (or resolves to) `true`. The function can read
|
|
3331
|
-
* the data of the entry with {@link Entry#getData} to decide
|
|
3343
|
+
* the data of the entry with {@link Entry#getData} to decide: every call completes before any data is copied.
|
|
3332
3344
|
*
|
|
3333
3345
|
* @remarks
|
|
3334
3346
|
* When the option is set, the data of the zip file is copied entry by entry and the entries left out leave no
|
|
3335
3347
|
* bytes behind in the output, unlike {@link ZipWriter#remove}, which drops an entry from the central directory
|
|
3336
|
-
* after its data has been written. The bytes of the zip file outside
|
|
3337
|
-
*
|
|
3338
|
-
*
|
|
3339
|
-
*
|
|
3348
|
+
* after its data has been written. The bytes of the zip file outside the entries kept are not copied either:
|
|
3349
|
+
* a self-extracting stub, the data of entries removed earlier and the padding between entries, so a zip file
|
|
3350
|
+
* aligned with {@link ZipWriterConstructorOptions#usdz} is not aligned any more once filtered. Without the
|
|
3351
|
+
* option, the data of the zip file is copied as a whole. The duplicate filename check applies to the entries
|
|
3352
|
+
* kept only, so an entry can be replaced by leaving it out and adding its replacement with {@link ZipWriter#add}.
|
|
3353
|
+
*
|
|
3354
|
+
* An entry is copied from its local file header to the end of its data or, when it has one, of its data
|
|
3355
|
+
* descriptor, whose layout is read back from the zip file; when no layout matches, the entry is copied up to
|
|
3356
|
+
* the next entry or to the central directory. Before anything is written, each kept entry is checked to start
|
|
3357
|
+
* with a local file header and to end before the next entry or the central directory; otherwise the method
|
|
3358
|
+
* throws {@link ERR_LOCAL_FILE_HEADER_NOT_FOUND} or {@link ERR_OVERLAPPING_ENTRY} and leaves the current zip
|
|
3359
|
+
* unchanged. The same checks apply when the output is a split zip file, whose entries are copied one by one
|
|
3360
|
+
* as well.
|
|
3340
3361
|
*
|
|
3341
3362
|
* @param entry The entry read from the zip file.
|
|
3342
3363
|
* @returns `true` to copy the entry.
|
|
@@ -5046,6 +5067,9 @@ export const ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: string;
|
|
|
5046
5067
|
export const ERR_CENTRAL_DIRECTORY_NOT_FOUND: string;
|
|
5047
5068
|
/**
|
|
5048
5069
|
* Local file header not found error
|
|
5070
|
+
*
|
|
5071
|
+
* @remarks Also thrown by {@link ZipWriter#appendZip} when a copied entry does not point at a local file header
|
|
5072
|
+
* (see {@link ZipWriterAppendZipOptions#filter}).
|
|
5049
5073
|
*/
|
|
5050
5074
|
export const ERR_LOCAL_FILE_HEADER_NOT_FOUND: string;
|
|
5051
5075
|
/**
|
|
@@ -5059,7 +5083,8 @@ export const ERR_LOCAL_FILE_HEADER_NOT_FOUND: string;
|
|
|
5059
5083
|
* {@link WARNING_MALFORMED_EXTRA_FIELD} on {@link EntryMetaData#warnings}, and an entry without a data descriptor
|
|
5060
5084
|
* keeps the sentinels as its local sizes, which the local file header check reports as
|
|
5061
5085
|
* {@link WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES}, an error or a warning depending on
|
|
5062
|
-
* {@link ZipReaderOptions#strictness}.
|
|
5086
|
+
* {@link ZipReaderOptions#strictness}. Also thrown by {@link ZipWriter#appendZip}, before anything is written,
|
|
5087
|
+
* when an entry to copy lacks the field (see {@link WARNING_MISSING_ZIP64_EXTRA_FIELD}).
|
|
5063
5088
|
*/
|
|
5064
5089
|
export const ERR_EXTRAFIELD_ZIP64_NOT_FOUND: string;
|
|
5065
5090
|
/**
|
|
@@ -5281,13 +5306,16 @@ export const ERR_SPLIT_ZIP_FILE: string;
|
|
|
5281
5306
|
*
|
|
5282
5307
|
* @remarks Thrown by {@link FileEntry#getData} when {@link ZipReaderOptions#checkOverlappingEntry} is set and the
|
|
5283
5308
|
* data of the entry overlaps the data of an entry already read. The thrown error carries the other entry in its
|
|
5284
|
-
* `overlappingEntry` property.
|
|
5309
|
+
* `overlappingEntry` property. Also thrown by {@link ZipWriter#appendZip} when the data of a copied entry runs
|
|
5310
|
+
* into the next entry or into the central directory (see {@link ZipWriterAppendZipOptions#filter}).
|
|
5285
5311
|
*/
|
|
5286
5312
|
export const ERR_OVERLAPPING_ENTRY: string;
|
|
5287
5313
|
/**
|
|
5288
5314
|
* Entry data out of bounds error
|
|
5289
5315
|
*
|
|
5290
|
-
* @remarks Thrown by {@link FileEntry#getData} when the declared extent of the entry data (i.e. its offset plus
|
|
5316
|
+
* @remarks Thrown by {@link FileEntry#getData} when the declared extent of the entry data (i.e. its offset plus
|
|
5317
|
+
* its compressed size) ends past the central directory or past the end of the zip file, whatever
|
|
5318
|
+
* {@link ZipReaderOptions#strictness} and {@link ZipReaderOptions#checkOverlappingEntry} are set to.
|
|
5291
5319
|
*/
|
|
5292
5320
|
export const ERR_ENTRY_DATA_OUT_OF_BOUNDS: string;
|
|
5293
5321
|
/**
|
|
@@ -5295,7 +5323,8 @@ export const ERR_ENTRY_DATA_OUT_OF_BOUNDS: string;
|
|
|
5295
5323
|
*
|
|
5296
5324
|
* @remarks The thrown error carries a `reason` property describing the ambiguity: `"appended data"`,
|
|
5297
5325
|
* `"prepended data"`, `"trailing central directory data"`, `"multiple end of central directory records"`,
|
|
5298
|
-
* `"mismatched zip64 end of central directory record"`,
|
|
5326
|
+
* `"mismatched central directory offset"`, `"mismatched zip64 end of central directory record"`,
|
|
5327
|
+
* `"duplicate filename"`, or, when
|
|
5299
5328
|
* {@link ZipReaderOptions#checkLocalDirectory} compares the local header of an entry with its central
|
|
5300
5329
|
* directory record, `"mismatched local file header (filename)"`,
|
|
5301
5330
|
* `"mismatched local file header (general purpose bit flag)"`,
|
|
@@ -5637,24 +5666,26 @@ export const WARNING_PREPENDED_CENTRAL_DIRECTORY: string;
|
|
|
5637
5666
|
*/
|
|
5638
5667
|
export const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA: string;
|
|
5639
5668
|
/**
|
|
5640
|
-
* Warning reason: the end of central directory record stores a central directory offset that
|
|
5641
|
-
* central directory actually found before it, so the archive was read from the directory found rather than
|
|
5642
|
-
* the stored offset (see {@link ZipReader#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} under
|
|
5669
|
+
* Warning reason: the end of central directory record stores a central directory offset that does not point at
|
|
5670
|
+
* the central directory actually found before it, so the archive was read from the directory found rather than
|
|
5671
|
+
* from the stored offset (see {@link ZipReader#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} under
|
|
5643
5672
|
* `strictness: "strict"`
|
|
5644
5673
|
*
|
|
5645
5674
|
* @remarks
|
|
5646
5675
|
* Such an archive is typically one written with absolute offsets for a prefix that is no longer there, e.g. a
|
|
5647
|
-
* self-extracting archive whose stub was removed
|
|
5648
|
-
* the
|
|
5649
|
-
* the central directory are used as they are.
|
|
5676
|
+
* self-extracting archive whose stub was removed, or one whose end of central directory record was damaged.
|
|
5677
|
+
* When the local file header of the first entry is found at the same shifted position only, the entries are
|
|
5678
|
+
* read from the shifted positions; otherwise the offsets stored in the central directory are used as they are.
|
|
5679
|
+
* A stored offset short of the directory whose entries are found at the shifted positions is diagnosed as
|
|
5680
|
+
* {@link WARNING_PREPENDED_DATA} instead.
|
|
5650
5681
|
*/
|
|
5651
5682
|
export const WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET: string;
|
|
5652
5683
|
/**
|
|
5653
5684
|
* Warning reason: a central directory record holds the Zip64 sentinel in a size, offset or disk number field
|
|
5654
5685
|
* but carries no Zip64 extra field resolving it (see {@link ZipReader#warnings}). The entry is listed, its
|
|
5655
|
-
* sizes and offset are unusable, and reading its data
|
|
5656
|
-
* other entries are unaffected. Under `strictness: "strict"`,
|
|
5657
|
-
* {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND} instead.
|
|
5686
|
+
* sizes and offset are unusable, and reading its data or copying it with {@link ZipWriter#appendZip} throws
|
|
5687
|
+
* {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND}; the other entries are unaffected. Under `strictness: "strict"`,
|
|
5688
|
+
* {@link ZipReader#getEntries} throws {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND} instead.
|
|
5658
5689
|
*/
|
|
5659
5690
|
export const WARNING_MISSING_ZIP64_EXTRA_FIELD: string;
|
|
5660
5691
|
/**
|
|
@@ -5669,8 +5700,9 @@ export const WARNING_DUPLICATE_FILENAME: string;
|
|
|
5669
5700
|
export const WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY: string;
|
|
5670
5701
|
/**
|
|
5671
5702
|
* Warning reason: more than one end of central directory record reaches the end of the file, so another reader
|
|
5672
|
-
* may select a different one and list different entries; the reason of {@link ERR_AMBIGUOUS_ARCHIVE}
|
|
5673
|
-
*
|
|
5703
|
+
* may select a different one and list different entries; the reason of {@link ERR_AMBIGUOUS_ARCHIVE} under
|
|
5704
|
+
* `strictness: "strict"` and `"balanced"`. It is never deposited as a warning: `"tolerant"` reads the last
|
|
5705
|
+
* record and reports the stale one as {@link WARNING_TRAILING_CENTRAL_DIRECTORY_DATA}.
|
|
5674
5706
|
*/
|
|
5675
5707
|
export const WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY: string;
|
|
5676
5708
|
/**
|
|
@@ -5694,7 +5726,8 @@ export const WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG: string;
|
|
|
5694
5726
|
*/
|
|
5695
5727
|
export const WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD: string;
|
|
5696
5728
|
/**
|
|
5697
|
-
* Warning reason: the crc32 or the sizes of the local file header
|
|
5729
|
+
* Warning reason: the crc32 or the sizes of the local file header, or of the data descriptor when it is read
|
|
5730
|
+
* (see {@link ZipReaderOptions#checkOverlappingEntry}), contradict the central directory
|
|
5698
5731
|
* (see {@link EntryMetaData#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} when
|
|
5699
5732
|
* {@link ZipReaderOptions#checkLocalDirectory} is enabled
|
|
5700
5733
|
*/
|
package/index.d.ts
CHANGED
|
@@ -1545,8 +1545,9 @@ export class ZipReader<Type> {
|
|
|
1545
1545
|
* {@link WARNING_APPENDED_DATA}, {@link WARNING_PREPENDED_DATA}, {@link WARNING_TRAILING_CENTRAL_DIRECTORY_DATA},
|
|
1546
1546
|
* {@link WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET}, {@link WARNING_DUPLICATE_FILENAME} and
|
|
1547
1547
|
* {@link WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY}.
|
|
1548
|
-
* {@link WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY} is
|
|
1549
|
-
*
|
|
1548
|
+
* {@link WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY} is never deposited as a warning: `"balanced"` rejects it
|
|
1549
|
+
* like `"strict"`, and `"tolerant"` reads the last record and reports the stale one as
|
|
1550
|
+
* {@link WARNING_TRAILING_CENTRAL_DIRECTORY_DATA}. {@link WARNING_MISSING_ZIP64_EXTRA_FIELD} is deposited when an
|
|
1550
1551
|
* entry cannot be read because its central directory record lacks a Zip64 extra field, and `"strict"` throws
|
|
1551
1552
|
* {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND} for it.
|
|
1552
1553
|
*
|
|
@@ -1889,7 +1890,10 @@ export interface ZipReaderOptions {
|
|
|
1889
1890
|
* (e.g. streaming readers based on local file headers) interpret the entry differently. This detects mismatched
|
|
1890
1891
|
* filenames, general purpose bit flags (encryption, data descriptor and language encoding flags), compression
|
|
1891
1892
|
* methods, CRC-32 checksums and sizes. The extra fields are not compared because the zip specification allows
|
|
1892
|
-
* them to differ.
|
|
1893
|
+
* them to differ. A local file header whose CRC-32 checksum and sizes are all zero without the data descriptor
|
|
1894
|
+
* flag is tolerated, because some streaming writers leave these fields blank. When the entry has a data
|
|
1895
|
+
* descriptor, its CRC-32 checksum and sizes are compared with the central directory record instead, provided
|
|
1896
|
+
* the descriptor is read, i.e. when {@link ZipReaderOptions#checkOverlappingEntry} is set.
|
|
1893
1897
|
*
|
|
1894
1898
|
* This is the boolean form of {@link ZipReaderOptions#strictness}: `true` means `"strict"` and `false` means
|
|
1895
1899
|
* any value but `"strict"`. When both options are set, the value passed to {@link FileEntry#getData} takes
|
|
@@ -2566,11 +2570,13 @@ export interface EntryMetaData {
|
|
|
2566
2570
|
*/
|
|
2567
2571
|
lastModDate: Date;
|
|
2568
2572
|
/**
|
|
2569
|
-
* The last access date
|
|
2573
|
+
* The last access date, read from the extra fields of the central directory record or, when it holds none, from
|
|
2574
|
+
* the extra fields of the local file header once the data of the entry has been read.
|
|
2570
2575
|
*/
|
|
2571
2576
|
lastAccessDate?: Date;
|
|
2572
2577
|
/**
|
|
2573
|
-
* The creation date
|
|
2578
|
+
* The creation date, read from the extra fields of the central directory record or, when it holds none, from
|
|
2579
|
+
* the extra fields of the local file header once the data of the entry has been read.
|
|
2574
2580
|
*/
|
|
2575
2581
|
creationDate?: Date;
|
|
2576
2582
|
/**
|
|
@@ -3073,15 +3079,21 @@ export class ZipWriter<Type> {
|
|
|
3073
3079
|
* @remarks
|
|
3074
3080
|
* The data of the zip file is copied, its central directory is rebuilt and its entries are relocated to
|
|
3075
3081
|
* the positions they get in the output. The disks of a split zip file passed as input are therefore unrelated to
|
|
3076
|
-
* the disks of the output, which is a single zip file unless the writer is a split zip file writer.
|
|
3082
|
+
* the disks of the output, which is a single zip file unless the writer is a split zip file writer. In that case,
|
|
3083
|
+
* the bytes before the first entry (e.g. a self-extracting stub) are copied after the split zip file signature of
|
|
3084
|
+
* the first disk, where no system runs them; use the {@link ZipWriterAppendZipOptions#filter} option to drop them. The data of
|
|
3077
3085
|
* the entries is copied as-is; in particular, the constraints set by {@link ZipWriterConstructorOptions#usdz}
|
|
3078
|
-
* are not applied to the copied entries.
|
|
3086
|
+
* are not applied to the copied entries. The comment and the digital signature of the zip file are not copied,
|
|
3087
|
+
* since its central directory is rebuilt: pass them to {@link ZipWriter#close}.
|
|
3079
3088
|
*
|
|
3080
3089
|
* Pending {@link ZipWriter#add} calls are completed before the data is copied, and add() calls made
|
|
3081
3090
|
* while the copy is in progress are written after it. If an entry of the zip file has the same
|
|
3082
3091
|
* filename as an entry of the current zip, the method throws with the `ERR_DUPLICATED_NAME` error
|
|
3083
3092
|
* message and leaves the current zip unchanged; call {@link ZipWriter#remove} beforehand to resolve
|
|
3084
|
-
* the conflicts.
|
|
3093
|
+
* the conflicts. An entry whose sizes or offset are unusable because its Zip64 extra field is missing (see
|
|
3094
|
+
* {@link WARNING_MISSING_ZIP64_EXTRA_FIELD}) cannot be copied: the method throws
|
|
3095
|
+
* {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND} and leaves the current zip unchanged, unless the
|
|
3096
|
+
* {@link ZipWriterAppendZipOptions#filter} option leaves the entry out.
|
|
3085
3097
|
*
|
|
3086
3098
|
* The returned promise can safely be left un-awaited: {@link ZipWriter#close} waits for the copy
|
|
3087
3099
|
* and throws its error if it was not caught.
|
|
@@ -3328,15 +3340,24 @@ export interface ZipWriterAppendZipOptions {
|
|
|
3328
3340
|
/**
|
|
3329
3341
|
* Selects the entries of the zip file to copy: the function is called once per entry, in the order of the
|
|
3330
3342
|
* central directory, and the entry is copied when it returns (or resolves to) `true`. The function can read
|
|
3331
|
-
* the data of the entry with {@link Entry#getData} to decide
|
|
3343
|
+
* the data of the entry with {@link Entry#getData} to decide: every call completes before any data is copied.
|
|
3332
3344
|
*
|
|
3333
3345
|
* @remarks
|
|
3334
3346
|
* When the option is set, the data of the zip file is copied entry by entry and the entries left out leave no
|
|
3335
3347
|
* bytes behind in the output, unlike {@link ZipWriter#remove}, which drops an entry from the central directory
|
|
3336
|
-
* after its data has been written. The bytes of the zip file outside
|
|
3337
|
-
*
|
|
3338
|
-
*
|
|
3339
|
-
*
|
|
3348
|
+
* after its data has been written. The bytes of the zip file outside the entries kept are not copied either:
|
|
3349
|
+
* a self-extracting stub, the data of entries removed earlier and the padding between entries, so a zip file
|
|
3350
|
+
* aligned with {@link ZipWriterConstructorOptions#usdz} is not aligned any more once filtered. Without the
|
|
3351
|
+
* option, the data of the zip file is copied as a whole. The duplicate filename check applies to the entries
|
|
3352
|
+
* kept only, so an entry can be replaced by leaving it out and adding its replacement with {@link ZipWriter#add}.
|
|
3353
|
+
*
|
|
3354
|
+
* An entry is copied from its local file header to the end of its data or, when it has one, of its data
|
|
3355
|
+
* descriptor, whose layout is read back from the zip file; when no layout matches, the entry is copied up to
|
|
3356
|
+
* the next entry or to the central directory. Before anything is written, each kept entry is checked to start
|
|
3357
|
+
* with a local file header and to end before the next entry or the central directory; otherwise the method
|
|
3358
|
+
* throws {@link ERR_LOCAL_FILE_HEADER_NOT_FOUND} or {@link ERR_OVERLAPPING_ENTRY} and leaves the current zip
|
|
3359
|
+
* unchanged. The same checks apply when the output is a split zip file, whose entries are copied one by one
|
|
3360
|
+
* as well.
|
|
3340
3361
|
*
|
|
3341
3362
|
* @param entry The entry read from the zip file.
|
|
3342
3363
|
* @returns `true` to copy the entry.
|
|
@@ -5046,6 +5067,9 @@ export const ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: string;
|
|
|
5046
5067
|
export const ERR_CENTRAL_DIRECTORY_NOT_FOUND: string;
|
|
5047
5068
|
/**
|
|
5048
5069
|
* Local file header not found error
|
|
5070
|
+
*
|
|
5071
|
+
* @remarks Also thrown by {@link ZipWriter#appendZip} when a copied entry does not point at a local file header
|
|
5072
|
+
* (see {@link ZipWriterAppendZipOptions#filter}).
|
|
5049
5073
|
*/
|
|
5050
5074
|
export const ERR_LOCAL_FILE_HEADER_NOT_FOUND: string;
|
|
5051
5075
|
/**
|
|
@@ -5059,7 +5083,8 @@ export const ERR_LOCAL_FILE_HEADER_NOT_FOUND: string;
|
|
|
5059
5083
|
* {@link WARNING_MALFORMED_EXTRA_FIELD} on {@link EntryMetaData#warnings}, and an entry without a data descriptor
|
|
5060
5084
|
* keeps the sentinels as its local sizes, which the local file header check reports as
|
|
5061
5085
|
* {@link WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES}, an error or a warning depending on
|
|
5062
|
-
* {@link ZipReaderOptions#strictness}.
|
|
5086
|
+
* {@link ZipReaderOptions#strictness}. Also thrown by {@link ZipWriter#appendZip}, before anything is written,
|
|
5087
|
+
* when an entry to copy lacks the field (see {@link WARNING_MISSING_ZIP64_EXTRA_FIELD}).
|
|
5063
5088
|
*/
|
|
5064
5089
|
export const ERR_EXTRAFIELD_ZIP64_NOT_FOUND: string;
|
|
5065
5090
|
/**
|
|
@@ -5281,13 +5306,16 @@ export const ERR_SPLIT_ZIP_FILE: string;
|
|
|
5281
5306
|
*
|
|
5282
5307
|
* @remarks Thrown by {@link FileEntry#getData} when {@link ZipReaderOptions#checkOverlappingEntry} is set and the
|
|
5283
5308
|
* data of the entry overlaps the data of an entry already read. The thrown error carries the other entry in its
|
|
5284
|
-
* `overlappingEntry` property.
|
|
5309
|
+
* `overlappingEntry` property. Also thrown by {@link ZipWriter#appendZip} when the data of a copied entry runs
|
|
5310
|
+
* into the next entry or into the central directory (see {@link ZipWriterAppendZipOptions#filter}).
|
|
5285
5311
|
*/
|
|
5286
5312
|
export const ERR_OVERLAPPING_ENTRY: string;
|
|
5287
5313
|
/**
|
|
5288
5314
|
* Entry data out of bounds error
|
|
5289
5315
|
*
|
|
5290
|
-
* @remarks Thrown by {@link FileEntry#getData} when the declared extent of the entry data (i.e. its offset plus
|
|
5316
|
+
* @remarks Thrown by {@link FileEntry#getData} when the declared extent of the entry data (i.e. its offset plus
|
|
5317
|
+
* its compressed size) ends past the central directory or past the end of the zip file, whatever
|
|
5318
|
+
* {@link ZipReaderOptions#strictness} and {@link ZipReaderOptions#checkOverlappingEntry} are set to.
|
|
5291
5319
|
*/
|
|
5292
5320
|
export const ERR_ENTRY_DATA_OUT_OF_BOUNDS: string;
|
|
5293
5321
|
/**
|
|
@@ -5295,7 +5323,8 @@ export const ERR_ENTRY_DATA_OUT_OF_BOUNDS: string;
|
|
|
5295
5323
|
*
|
|
5296
5324
|
* @remarks The thrown error carries a `reason` property describing the ambiguity: `"appended data"`,
|
|
5297
5325
|
* `"prepended data"`, `"trailing central directory data"`, `"multiple end of central directory records"`,
|
|
5298
|
-
* `"mismatched zip64 end of central directory record"`,
|
|
5326
|
+
* `"mismatched central directory offset"`, `"mismatched zip64 end of central directory record"`,
|
|
5327
|
+
* `"duplicate filename"`, or, when
|
|
5299
5328
|
* {@link ZipReaderOptions#checkLocalDirectory} compares the local header of an entry with its central
|
|
5300
5329
|
* directory record, `"mismatched local file header (filename)"`,
|
|
5301
5330
|
* `"mismatched local file header (general purpose bit flag)"`,
|
|
@@ -5637,24 +5666,26 @@ export const WARNING_PREPENDED_CENTRAL_DIRECTORY: string;
|
|
|
5637
5666
|
*/
|
|
5638
5667
|
export const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA: string;
|
|
5639
5668
|
/**
|
|
5640
|
-
* Warning reason: the end of central directory record stores a central directory offset that
|
|
5641
|
-
* central directory actually found before it, so the archive was read from the directory found rather than
|
|
5642
|
-
* the stored offset (see {@link ZipReader#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} under
|
|
5669
|
+
* Warning reason: the end of central directory record stores a central directory offset that does not point at
|
|
5670
|
+
* the central directory actually found before it, so the archive was read from the directory found rather than
|
|
5671
|
+
* from the stored offset (see {@link ZipReader#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} under
|
|
5643
5672
|
* `strictness: "strict"`
|
|
5644
5673
|
*
|
|
5645
5674
|
* @remarks
|
|
5646
5675
|
* Such an archive is typically one written with absolute offsets for a prefix that is no longer there, e.g. a
|
|
5647
|
-
* self-extracting archive whose stub was removed
|
|
5648
|
-
* the
|
|
5649
|
-
* the central directory are used as they are.
|
|
5676
|
+
* self-extracting archive whose stub was removed, or one whose end of central directory record was damaged.
|
|
5677
|
+
* When the local file header of the first entry is found at the same shifted position only, the entries are
|
|
5678
|
+
* read from the shifted positions; otherwise the offsets stored in the central directory are used as they are.
|
|
5679
|
+
* A stored offset short of the directory whose entries are found at the shifted positions is diagnosed as
|
|
5680
|
+
* {@link WARNING_PREPENDED_DATA} instead.
|
|
5650
5681
|
*/
|
|
5651
5682
|
export const WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET: string;
|
|
5652
5683
|
/**
|
|
5653
5684
|
* Warning reason: a central directory record holds the Zip64 sentinel in a size, offset or disk number field
|
|
5654
5685
|
* but carries no Zip64 extra field resolving it (see {@link ZipReader#warnings}). The entry is listed, its
|
|
5655
|
-
* sizes and offset are unusable, and reading its data
|
|
5656
|
-
* other entries are unaffected. Under `strictness: "strict"`,
|
|
5657
|
-
* {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND} instead.
|
|
5686
|
+
* sizes and offset are unusable, and reading its data or copying it with {@link ZipWriter#appendZip} throws
|
|
5687
|
+
* {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND}; the other entries are unaffected. Under `strictness: "strict"`,
|
|
5688
|
+
* {@link ZipReader#getEntries} throws {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND} instead.
|
|
5658
5689
|
*/
|
|
5659
5690
|
export const WARNING_MISSING_ZIP64_EXTRA_FIELD: string;
|
|
5660
5691
|
/**
|
|
@@ -5669,8 +5700,9 @@ export const WARNING_DUPLICATE_FILENAME: string;
|
|
|
5669
5700
|
export const WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY: string;
|
|
5670
5701
|
/**
|
|
5671
5702
|
* Warning reason: more than one end of central directory record reaches the end of the file, so another reader
|
|
5672
|
-
* may select a different one and list different entries; the reason of {@link ERR_AMBIGUOUS_ARCHIVE}
|
|
5673
|
-
*
|
|
5703
|
+
* may select a different one and list different entries; the reason of {@link ERR_AMBIGUOUS_ARCHIVE} under
|
|
5704
|
+
* `strictness: "strict"` and `"balanced"`. It is never deposited as a warning: `"tolerant"` reads the last
|
|
5705
|
+
* record and reports the stale one as {@link WARNING_TRAILING_CENTRAL_DIRECTORY_DATA}.
|
|
5674
5706
|
*/
|
|
5675
5707
|
export const WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY: string;
|
|
5676
5708
|
/**
|
|
@@ -5694,7 +5726,8 @@ export const WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG: string;
|
|
|
5694
5726
|
*/
|
|
5695
5727
|
export const WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD: string;
|
|
5696
5728
|
/**
|
|
5697
|
-
* Warning reason: the crc32 or the sizes of the local file header
|
|
5729
|
+
* Warning reason: the crc32 or the sizes of the local file header, or of the data descriptor when it is read
|
|
5730
|
+
* (see {@link ZipReaderOptions#checkOverlappingEntry}), contradict the central directory
|
|
5698
5731
|
* (see {@link EntryMetaData#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} when
|
|
5699
5732
|
* {@link ZipReaderOptions#checkLocalDirectory} is enabled
|
|
5700
5733
|
*/
|