@zip.js/zip.js 2.18.2 → 2.20.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/BENCHMARKS.md +172 -144
- package/deno.json +1 -1
- package/dist/zip-core-external.js +192 -120
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +193 -119
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +192 -120
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +193 -119
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +192 -120
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +195 -121
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +194 -120
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +195 -121
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +195 -121
- package/dist/zip-native.min.js +1 -1
- package/dist/zip-web-worker-native.js +1 -1
- package/dist/zip-web-worker.js +1 -1
- package/dist/zip.js +194 -120
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +195 -121
- package/index-native.min.js +1 -1
- package/index.cjs +194 -120
- package/index.d.cts +95 -26
- package/index.d.ts +95 -26
- package/index.min.js +1 -1
- package/lib/core/codec-pool.js +1 -2
- package/lib/core/codec-worker-web.js +11 -39
- package/lib/core/codec-worker.js +1 -2
- package/lib/core/configuration.js +1 -1
- package/lib/core/options.js +0 -2
- package/lib/core/streams/codec-stream.js +1 -1
- package/lib/core/version.js +1 -1
- package/lib/core/web-worker-base.js +2 -3
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-reader.js +100 -40
- package/lib/core/zip-writer.js +75 -34
- package/lib/zip-core-reader.js +2 -0
- package/package.json +1 -1
- package/worker-message-property-names.js +1 -1
package/index.d.cts
CHANGED
|
@@ -569,7 +569,11 @@ export interface Configuration extends WorkerConfiguration {
|
|
|
569
569
|
* Values lower than 64 are raised to 64, and a value that is not an integer greater than 0 is replaced with the default
|
|
570
570
|
* value.
|
|
571
571
|
*
|
|
572
|
-
* @
|
|
572
|
+
* @remarks
|
|
573
|
+
* Every stage of the pipeline of an entry holds up to one chunk, and the data crosses the boundary of a web worker one
|
|
574
|
+
* chunk per message, so a larger value costs more memory per entry in progress and buys fewer messages.
|
|
575
|
+
*
|
|
576
|
+
* @defaultValue 262144
|
|
573
577
|
*/
|
|
574
578
|
chunkSize?: number;
|
|
575
579
|
/**
|
|
@@ -634,7 +638,8 @@ export interface WorkerConfiguration {
|
|
|
634
638
|
/**
|
|
635
639
|
* `true` to transfer stream ownership to web workers.
|
|
636
640
|
*
|
|
637
|
-
* @
|
|
641
|
+
* @deprecated The option is ignored whatever its value: the data always crosses the worker boundary chunk by
|
|
642
|
+
* chunk, transferring the streams instead was slower on every engine measured.
|
|
638
643
|
*/
|
|
639
644
|
transferStreams?: boolean;
|
|
640
645
|
}
|
|
@@ -919,7 +924,7 @@ export class Reader<Type> implements Initializable, ReadableReader {
|
|
|
919
924
|
*/
|
|
920
925
|
constructor(value: Type);
|
|
921
926
|
/**
|
|
922
|
-
* The `ReadableStream` instance.
|
|
927
|
+
* The `ReadableStream` instance, a new one reading the data from its start on each access.
|
|
923
928
|
*/
|
|
924
929
|
readable: ReadableStream;
|
|
925
930
|
/**
|
|
@@ -1538,9 +1543,12 @@ export class ZipReader<Type> {
|
|
|
1538
1543
|
* `strictness: "strict"` rejects with {@link ERR_AMBIGUOUS_ARCHIVE}: when the effective strictness tolerates
|
|
1539
1544
|
* one of them and the evidence is already in hand, the same reason string is deposited as a warning instead —
|
|
1540
1545
|
* {@link WARNING_APPENDED_DATA}, {@link WARNING_PREPENDED_DATA}, {@link WARNING_TRAILING_CENTRAL_DIRECTORY_DATA},
|
|
1541
|
-
* {@link
|
|
1546
|
+
* {@link WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET}, {@link WARNING_DUPLICATE_FILENAME} and
|
|
1547
|
+
* {@link WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY}.
|
|
1542
1548
|
* {@link WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY} is the one reason of that group which is never tolerated,
|
|
1543
|
-
* so it is only ever the reason of an error.
|
|
1549
|
+
* so it is only ever the reason of an error. {@link WARNING_MISSING_ZIP64_EXTRA_FIELD} is deposited when an
|
|
1550
|
+
* entry cannot be read because its central directory record lacks a Zip64 extra field, and `"strict"` throws
|
|
1551
|
+
* {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND} for it.
|
|
1544
1552
|
*
|
|
1545
1553
|
* The warnings related to the local file header of an entry are deposited on
|
|
1546
1554
|
* {@link EntryMetaData#warnings} when its data is read, not here.
|
|
@@ -1753,8 +1761,10 @@ export interface GetEntriesOptions {
|
|
|
1753
1761
|
* systems, and it also occurs as the trail byte of legitimate double-byte filenames (e.g. CP932) decoded with
|
|
1754
1762
|
* another charset.
|
|
1755
1763
|
*
|
|
1756
|
-
* Names are validated, never rewritten
|
|
1757
|
-
*
|
|
1764
|
+
* Names are validated, never rewritten: the filename reported for an entry is the one its central directory
|
|
1765
|
+
* record stores, decoded, or the one of its Unicode Path extra field when the entry carries a valid one (see
|
|
1766
|
+
* {@link EntryMetaData#extraFieldUnicodePath}), and the bytes of the record stay available in
|
|
1767
|
+
* {@link EntryMetaData#rawFilename}. The name validated is that final name.
|
|
1758
1768
|
*
|
|
1759
1769
|
* @defaultValue The value of {@link GetEntriesOptions#strictness}.
|
|
1760
1770
|
*/
|
|
@@ -1763,8 +1773,9 @@ export interface GetEntriesOptions {
|
|
|
1763
1773
|
* The function called for normalizing the filename of each entry, e.g. to repair the names rejected by
|
|
1764
1774
|
* {@link GetEntriesOptions#filenameValidation}.
|
|
1765
1775
|
*
|
|
1766
|
-
* It is called with the decoded filename, after {@link GetEntriesOptions#decodeText} and
|
|
1767
|
-
*
|
|
1776
|
+
* It is called with the decoded filename, after {@link GetEntriesOptions#decodeText} and after a valid Unicode
|
|
1777
|
+
* Path extra field (see {@link EntryMetaData#extraFieldUnicodePath}) has replaced the name, and before the name
|
|
1778
|
+
* is validated, so a name it fails to repair is still rejected. The returned name becomes the name of the entry:
|
|
1768
1779
|
* it is used to detect directory entries by their trailing `"/"`, and to detect duplicate filenames when
|
|
1769
1780
|
* {@link GetEntriesOptions#checkAmbiguity} is set, so two names normalized into the same name are reported as
|
|
1770
1781
|
* an {@link ERR_AMBIGUOUS_ARCHIVE} error instead of silently shadowing each other. The raw filename remains
|
|
@@ -2378,13 +2389,13 @@ export interface LocalDirectory {
|
|
|
2378
2389
|
extraFieldNTFS?: EntryExtraFieldNTFS;
|
|
2379
2390
|
/**
|
|
2380
2391
|
* The Info-ZIP Unix type 2 extra field (0x7855). Its uid/gid are stored in the local file header only, the
|
|
2381
|
-
* central directory version carries no data and merely flags their presence.
|
|
2392
|
+
* central directory version carries no data and merely flags their presence. Its ids are used when the
|
|
2393
|
+
* header holds no New Unix extra field (0x7875).
|
|
2382
2394
|
*/
|
|
2383
2395
|
extraFieldUnix?: EntryExtraFieldUnix;
|
|
2384
2396
|
/**
|
|
2385
|
-
* The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers. It
|
|
2386
|
-
*
|
|
2387
|
-
* central directory.
|
|
2397
|
+
* The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers. It takes
|
|
2398
|
+
* precedence over the type 2 extra field (0x7855) when a header carries both.
|
|
2388
2399
|
*/
|
|
2389
2400
|
extraFieldInfoZip?: EntryExtraFieldUnix;
|
|
2390
2401
|
/**
|
|
@@ -2514,7 +2525,9 @@ export interface EntryMetaData {
|
|
|
2514
2525
|
* `true` if the entry is an executable file
|
|
2515
2526
|
*
|
|
2516
2527
|
* Always `false` when {@link EntryMetaData#symlink} is `true`: the permissions of a symbolic link
|
|
2517
|
-
* are not meaningful, Unix systems store them as `0o777`.
|
|
2528
|
+
* are not meaningful, Unix systems store them as `0o777`. Always `false` when
|
|
2529
|
+
* {@link EntryMetaData#directory} is `true` too: the execute bits of a directory mean that it can be
|
|
2530
|
+
* searched, and every directory carries them; read {@link EntryMetaData#unixMode} for the bits themselves.
|
|
2518
2531
|
*/
|
|
2519
2532
|
executable: boolean;
|
|
2520
2533
|
/**
|
|
@@ -2562,8 +2575,9 @@ export interface EntryMetaData {
|
|
|
2562
2575
|
creationDate?: Date;
|
|
2563
2576
|
/**
|
|
2564
2577
|
* The last modification date (raw), as the MS-DOS date and time stored in the header. Unlike
|
|
2565
|
-
* {@link EntryMetaData#lastModDate}, it is not replaced by the value of the
|
|
2566
|
-
* is present
|
|
2578
|
+
* {@link EntryMetaData#lastModDate}, it is not replaced by the value of the extended timestamp or NTFS extra
|
|
2579
|
+
* field when one is present (the NTFS value wins over the extended timestamp one, being the finer of the two);
|
|
2580
|
+
* read {@link EntryMetaData#extraFieldNTFS} for the raw NTFS value.
|
|
2567
2581
|
*/
|
|
2568
2582
|
rawLastModDate: number | bigint;
|
|
2569
2583
|
/**
|
|
@@ -2747,13 +2761,13 @@ export interface EntryMetaData {
|
|
|
2747
2761
|
extraFieldNTFS?: EntryExtraFieldNTFS;
|
|
2748
2762
|
/**
|
|
2749
2763
|
* The Info-ZIP Unix type 2 extra field (0x7855). Its uid/gid are stored in the local file header only, the
|
|
2750
|
-
* central directory version carries no data and merely flags their presence.
|
|
2764
|
+
* central directory version carries no data and merely flags their presence. Its ids are used when the
|
|
2765
|
+
* header holds no New Unix extra field (0x7875).
|
|
2751
2766
|
*/
|
|
2752
2767
|
extraFieldUnix?: EntryExtraFieldUnix;
|
|
2753
2768
|
/**
|
|
2754
|
-
* The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers. It
|
|
2755
|
-
*
|
|
2756
|
-
* central directory.
|
|
2769
|
+
* The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers. It takes
|
|
2770
|
+
* precedence over the type 2 extra field (0x7855) when a header carries both.
|
|
2757
2771
|
*/
|
|
2758
2772
|
extraFieldInfoZip?: EntryExtraFieldUnix;
|
|
2759
2773
|
/**
|
|
@@ -2785,8 +2799,8 @@ export interface EntryMetaData {
|
|
|
2785
2799
|
*
|
|
2786
2800
|
* The local file header is the only place where the Info-ZIP Unix extra fields type 1 (0x5855) and type 2
|
|
2787
2801
|
* (0x7855) store the uid/gid, so this is where they are read for entries carrying just these fields, e.g.
|
|
2788
|
-
* with `entry.localDirectory.extraFieldUnixType1.uid`. The values
|
|
2789
|
-
* {@link EntryMetaData#
|
|
2802
|
+
* with `entry.localDirectory.extraFieldUnixType1.uid`. The values fill in {@link EntryMetaData#uid} and
|
|
2803
|
+
* {@link EntryMetaData#gid} only when the central directory gave none, see {@link EntryMetaData#uid}.
|
|
2790
2804
|
*/
|
|
2791
2805
|
localDirectory?: LocalDirectory;
|
|
2792
2806
|
/**
|
|
@@ -3072,7 +3086,13 @@ export class ZipWriter<Type> {
|
|
|
3072
3086
|
* The returned promise can safely be left un-awaited: {@link ZipWriter#close} waits for the copy
|
|
3073
3087
|
* and throws its error if it was not caught.
|
|
3074
3088
|
*
|
|
3089
|
+
* With the {@link ZipWriterAppendZipOptions#filter} option, only the entries the function keeps are copied.
|
|
3090
|
+
* Combined with {@link ZipWriter#add}, this edits an existing zip file into a new one without decompressing
|
|
3091
|
+
* its data: the entries to keep are copied as-is, the entries to delete or replace are left out, and the
|
|
3092
|
+
* replacements and additions are added afterwards.
|
|
3093
|
+
*
|
|
3075
3094
|
* @param reader The {@link Reader} instance used to read the content of the zip file.
|
|
3095
|
+
* @param options The options.
|
|
3076
3096
|
* @returns A promise resolving when the zip file has been added.
|
|
3077
3097
|
*/
|
|
3078
3098
|
appendZip<ReaderType>(
|
|
@@ -3082,7 +3102,8 @@ export class ZipWriter<Type> {
|
|
|
3082
3102
|
| ReadableStream
|
|
3083
3103
|
| Reader<unknown>[]
|
|
3084
3104
|
| ReadableReader[]
|
|
3085
|
-
| ReadableStream[]
|
|
3105
|
+
| ReadableStream[],
|
|
3106
|
+
options?: ZipWriterAppendZipOptions
|
|
3086
3107
|
): Promise<void>;
|
|
3087
3108
|
|
|
3088
3109
|
/**
|
|
@@ -3300,6 +3321,29 @@ export interface ZipWriterAddDataOptions
|
|
|
3300
3321
|
/**
|
|
3301
3322
|
* Represents the options passed to {@link ZipWriter#close}.
|
|
3302
3323
|
*/
|
|
3324
|
+
/**
|
|
3325
|
+
* Represents the options passed to {@link ZipWriter#appendZip}.
|
|
3326
|
+
*/
|
|
3327
|
+
export interface ZipWriterAppendZipOptions {
|
|
3328
|
+
/**
|
|
3329
|
+
* Selects the entries of the zip file to copy: the function is called once per entry, in the order of the
|
|
3330
|
+
* 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, the zip file is closed after the last call.
|
|
3332
|
+
*
|
|
3333
|
+
* @remarks
|
|
3334
|
+
* When the option is set, the data of the zip file is copied entry by entry and the entries left out leave no
|
|
3335
|
+
* 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 its entries, e.g. a self-extracting stub
|
|
3337
|
+
* before the first entry, are not copied either. Without the option, the data of the zip file is copied as a
|
|
3338
|
+
* whole. The duplicate filename check applies to the entries kept only, so an entry can be replaced by
|
|
3339
|
+
* leaving it out and adding its replacement with {@link ZipWriter#add}.
|
|
3340
|
+
*
|
|
3341
|
+
* @param entry The entry read from the zip file.
|
|
3342
|
+
* @returns `true` to copy the entry.
|
|
3343
|
+
*/
|
|
3344
|
+
filter?: (entry: Entry) => boolean | Promise<boolean>;
|
|
3345
|
+
}
|
|
3346
|
+
|
|
3303
3347
|
export interface ZipWriterCloseOptions extends EntryOnprogressOptions {
|
|
3304
3348
|
/**
|
|
3305
3349
|
* `true` to use Zip64 to write the entries directory.
|
|
@@ -3649,8 +3693,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3649
3693
|
* Which Unix extra field format to write when creating entries that include Unix metadata.
|
|
3650
3694
|
* - "infozip": Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid up to 32 bits.
|
|
3651
3695
|
* - "unix": Info-ZIP Unix extra field type 2 (0x7855), storing fixed 2-byte uid/gid (0..65535); a
|
|
3652
|
-
* larger uid or gid is rejected. The
|
|
3653
|
-
*
|
|
3696
|
+
* larger uid or gid is rejected. The ids are written in the local file header only, the central
|
|
3697
|
+
* directory copy is empty as Info-ZIP specifies, so a reader working from the central directory,
|
|
3698
|
+
* {@link ZipReader} included, reports them once the entry data has been read. The Unix mode is not
|
|
3699
|
+
* part of this field; it is written to the external file attributes.
|
|
3654
3700
|
*
|
|
3655
3701
|
* When {@link ZipFS} exports imported entries, their uid/gid are re-emitted as "infozip" regardless
|
|
3656
3702
|
* of the field type found in the imported zip file, unless this option is set explicitly.
|
|
@@ -4989,7 +5035,9 @@ export const ERR_BAD_FORMAT: string;
|
|
|
4989
5035
|
*/
|
|
4990
5036
|
export const ERR_EOCDR_NOT_FOUND: string;
|
|
4991
5037
|
/**
|
|
4992
|
-
* Zip64 End of Central Directory Locator not found error
|
|
5038
|
+
* Zip64 End of Central Directory Locator not found error: the end of central directory record holds a Zip64
|
|
5039
|
+
* sentinel in its offset, size or disk number field but no Zip64 locator precedes it, or the locator does not
|
|
5040
|
+
* point at a Zip64 end of central directory record
|
|
4993
5041
|
*/
|
|
4994
5042
|
export const ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: string;
|
|
4995
5043
|
/**
|
|
@@ -5588,6 +5636,27 @@ export const WARNING_PREPENDED_CENTRAL_DIRECTORY: string;
|
|
|
5588
5636
|
* the reason of {@link ERR_AMBIGUOUS_ARCHIVE} under `strictness: "strict"`
|
|
5589
5637
|
*/
|
|
5590
5638
|
export const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA: string;
|
|
5639
|
+
/**
|
|
5640
|
+
* Warning reason: the end of central directory record stores a central directory offset that points past the
|
|
5641
|
+
* central directory actually found before it, so the archive was read from the directory found rather than from
|
|
5642
|
+
* the stored offset (see {@link ZipReader#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} under
|
|
5643
|
+
* `strictness: "strict"`
|
|
5644
|
+
*
|
|
5645
|
+
* @remarks
|
|
5646
|
+
* 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. When the local file header of the first entry is found at
|
|
5648
|
+
* the same shifted position, the entries are read from the shifted positions; otherwise the offsets stored in
|
|
5649
|
+
* the central directory are used as they are.
|
|
5650
|
+
*/
|
|
5651
|
+
export const WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET: string;
|
|
5652
|
+
/**
|
|
5653
|
+
* Warning reason: a central directory record holds the Zip64 sentinel in a size, offset or disk number field
|
|
5654
|
+
* 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 throws {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND}; the
|
|
5656
|
+
* other entries are unaffected. Under `strictness: "strict"`, {@link ZipReader#getEntries} throws
|
|
5657
|
+
* {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND} instead.
|
|
5658
|
+
*/
|
|
5659
|
+
export const WARNING_MISSING_ZIP64_EXTRA_FIELD: string;
|
|
5591
5660
|
/**
|
|
5592
5661
|
* Warning reason: several entries share the same filename (see {@link ZipReader#warnings}); the reason of
|
|
5593
5662
|
* {@link ERR_AMBIGUOUS_ARCHIVE} under `strictness: "strict"`
|
package/index.d.ts
CHANGED
|
@@ -569,7 +569,11 @@ export interface Configuration extends WorkerConfiguration {
|
|
|
569
569
|
* Values lower than 64 are raised to 64, and a value that is not an integer greater than 0 is replaced with the default
|
|
570
570
|
* value.
|
|
571
571
|
*
|
|
572
|
-
* @
|
|
572
|
+
* @remarks
|
|
573
|
+
* Every stage of the pipeline of an entry holds up to one chunk, and the data crosses the boundary of a web worker one
|
|
574
|
+
* chunk per message, so a larger value costs more memory per entry in progress and buys fewer messages.
|
|
575
|
+
*
|
|
576
|
+
* @defaultValue 262144
|
|
573
577
|
*/
|
|
574
578
|
chunkSize?: number;
|
|
575
579
|
/**
|
|
@@ -634,7 +638,8 @@ export interface WorkerConfiguration {
|
|
|
634
638
|
/**
|
|
635
639
|
* `true` to transfer stream ownership to web workers.
|
|
636
640
|
*
|
|
637
|
-
* @
|
|
641
|
+
* @deprecated The option is ignored whatever its value: the data always crosses the worker boundary chunk by
|
|
642
|
+
* chunk, transferring the streams instead was slower on every engine measured.
|
|
638
643
|
*/
|
|
639
644
|
transferStreams?: boolean;
|
|
640
645
|
}
|
|
@@ -919,7 +924,7 @@ export class Reader<Type> implements Initializable, ReadableReader {
|
|
|
919
924
|
*/
|
|
920
925
|
constructor(value: Type);
|
|
921
926
|
/**
|
|
922
|
-
* The `ReadableStream` instance.
|
|
927
|
+
* The `ReadableStream` instance, a new one reading the data from its start on each access.
|
|
923
928
|
*/
|
|
924
929
|
readable: ReadableStream;
|
|
925
930
|
/**
|
|
@@ -1538,9 +1543,12 @@ export class ZipReader<Type> {
|
|
|
1538
1543
|
* `strictness: "strict"` rejects with {@link ERR_AMBIGUOUS_ARCHIVE}: when the effective strictness tolerates
|
|
1539
1544
|
* one of them and the evidence is already in hand, the same reason string is deposited as a warning instead —
|
|
1540
1545
|
* {@link WARNING_APPENDED_DATA}, {@link WARNING_PREPENDED_DATA}, {@link WARNING_TRAILING_CENTRAL_DIRECTORY_DATA},
|
|
1541
|
-
* {@link
|
|
1546
|
+
* {@link WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET}, {@link WARNING_DUPLICATE_FILENAME} and
|
|
1547
|
+
* {@link WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY}.
|
|
1542
1548
|
* {@link WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY} is the one reason of that group which is never tolerated,
|
|
1543
|
-
* so it is only ever the reason of an error.
|
|
1549
|
+
* so it is only ever the reason of an error. {@link WARNING_MISSING_ZIP64_EXTRA_FIELD} is deposited when an
|
|
1550
|
+
* entry cannot be read because its central directory record lacks a Zip64 extra field, and `"strict"` throws
|
|
1551
|
+
* {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND} for it.
|
|
1544
1552
|
*
|
|
1545
1553
|
* The warnings related to the local file header of an entry are deposited on
|
|
1546
1554
|
* {@link EntryMetaData#warnings} when its data is read, not here.
|
|
@@ -1753,8 +1761,10 @@ export interface GetEntriesOptions {
|
|
|
1753
1761
|
* systems, and it also occurs as the trail byte of legitimate double-byte filenames (e.g. CP932) decoded with
|
|
1754
1762
|
* another charset.
|
|
1755
1763
|
*
|
|
1756
|
-
* Names are validated, never rewritten
|
|
1757
|
-
*
|
|
1764
|
+
* Names are validated, never rewritten: the filename reported for an entry is the one its central directory
|
|
1765
|
+
* record stores, decoded, or the one of its Unicode Path extra field when the entry carries a valid one (see
|
|
1766
|
+
* {@link EntryMetaData#extraFieldUnicodePath}), and the bytes of the record stay available in
|
|
1767
|
+
* {@link EntryMetaData#rawFilename}. The name validated is that final name.
|
|
1758
1768
|
*
|
|
1759
1769
|
* @defaultValue The value of {@link GetEntriesOptions#strictness}.
|
|
1760
1770
|
*/
|
|
@@ -1763,8 +1773,9 @@ export interface GetEntriesOptions {
|
|
|
1763
1773
|
* The function called for normalizing the filename of each entry, e.g. to repair the names rejected by
|
|
1764
1774
|
* {@link GetEntriesOptions#filenameValidation}.
|
|
1765
1775
|
*
|
|
1766
|
-
* It is called with the decoded filename, after {@link GetEntriesOptions#decodeText} and
|
|
1767
|
-
*
|
|
1776
|
+
* It is called with the decoded filename, after {@link GetEntriesOptions#decodeText} and after a valid Unicode
|
|
1777
|
+
* Path extra field (see {@link EntryMetaData#extraFieldUnicodePath}) has replaced the name, and before the name
|
|
1778
|
+
* is validated, so a name it fails to repair is still rejected. The returned name becomes the name of the entry:
|
|
1768
1779
|
* it is used to detect directory entries by their trailing `"/"`, and to detect duplicate filenames when
|
|
1769
1780
|
* {@link GetEntriesOptions#checkAmbiguity} is set, so two names normalized into the same name are reported as
|
|
1770
1781
|
* an {@link ERR_AMBIGUOUS_ARCHIVE} error instead of silently shadowing each other. The raw filename remains
|
|
@@ -2378,13 +2389,13 @@ export interface LocalDirectory {
|
|
|
2378
2389
|
extraFieldNTFS?: EntryExtraFieldNTFS;
|
|
2379
2390
|
/**
|
|
2380
2391
|
* The Info-ZIP Unix type 2 extra field (0x7855). Its uid/gid are stored in the local file header only, the
|
|
2381
|
-
* central directory version carries no data and merely flags their presence.
|
|
2392
|
+
* central directory version carries no data and merely flags their presence. Its ids are used when the
|
|
2393
|
+
* header holds no New Unix extra field (0x7875).
|
|
2382
2394
|
*/
|
|
2383
2395
|
extraFieldUnix?: EntryExtraFieldUnix;
|
|
2384
2396
|
/**
|
|
2385
|
-
* The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers. It
|
|
2386
|
-
*
|
|
2387
|
-
* central directory.
|
|
2397
|
+
* The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers. It takes
|
|
2398
|
+
* precedence over the type 2 extra field (0x7855) when a header carries both.
|
|
2388
2399
|
*/
|
|
2389
2400
|
extraFieldInfoZip?: EntryExtraFieldUnix;
|
|
2390
2401
|
/**
|
|
@@ -2514,7 +2525,9 @@ export interface EntryMetaData {
|
|
|
2514
2525
|
* `true` if the entry is an executable file
|
|
2515
2526
|
*
|
|
2516
2527
|
* Always `false` when {@link EntryMetaData#symlink} is `true`: the permissions of a symbolic link
|
|
2517
|
-
* are not meaningful, Unix systems store them as `0o777`.
|
|
2528
|
+
* are not meaningful, Unix systems store them as `0o777`. Always `false` when
|
|
2529
|
+
* {@link EntryMetaData#directory} is `true` too: the execute bits of a directory mean that it can be
|
|
2530
|
+
* searched, and every directory carries them; read {@link EntryMetaData#unixMode} for the bits themselves.
|
|
2518
2531
|
*/
|
|
2519
2532
|
executable: boolean;
|
|
2520
2533
|
/**
|
|
@@ -2562,8 +2575,9 @@ export interface EntryMetaData {
|
|
|
2562
2575
|
creationDate?: Date;
|
|
2563
2576
|
/**
|
|
2564
2577
|
* The last modification date (raw), as the MS-DOS date and time stored in the header. Unlike
|
|
2565
|
-
* {@link EntryMetaData#lastModDate}, it is not replaced by the value of the
|
|
2566
|
-
* is present
|
|
2578
|
+
* {@link EntryMetaData#lastModDate}, it is not replaced by the value of the extended timestamp or NTFS extra
|
|
2579
|
+
* field when one is present (the NTFS value wins over the extended timestamp one, being the finer of the two);
|
|
2580
|
+
* read {@link EntryMetaData#extraFieldNTFS} for the raw NTFS value.
|
|
2567
2581
|
*/
|
|
2568
2582
|
rawLastModDate: number | bigint;
|
|
2569
2583
|
/**
|
|
@@ -2747,13 +2761,13 @@ export interface EntryMetaData {
|
|
|
2747
2761
|
extraFieldNTFS?: EntryExtraFieldNTFS;
|
|
2748
2762
|
/**
|
|
2749
2763
|
* The Info-ZIP Unix type 2 extra field (0x7855). Its uid/gid are stored in the local file header only, the
|
|
2750
|
-
* central directory version carries no data and merely flags their presence.
|
|
2764
|
+
* central directory version carries no data and merely flags their presence. Its ids are used when the
|
|
2765
|
+
* header holds no New Unix extra field (0x7875).
|
|
2751
2766
|
*/
|
|
2752
2767
|
extraFieldUnix?: EntryExtraFieldUnix;
|
|
2753
2768
|
/**
|
|
2754
|
-
* The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers. It
|
|
2755
|
-
*
|
|
2756
|
-
* central directory.
|
|
2769
|
+
* The Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid in both headers. It takes
|
|
2770
|
+
* precedence over the type 2 extra field (0x7855) when a header carries both.
|
|
2757
2771
|
*/
|
|
2758
2772
|
extraFieldInfoZip?: EntryExtraFieldUnix;
|
|
2759
2773
|
/**
|
|
@@ -2785,8 +2799,8 @@ export interface EntryMetaData {
|
|
|
2785
2799
|
*
|
|
2786
2800
|
* The local file header is the only place where the Info-ZIP Unix extra fields type 1 (0x5855) and type 2
|
|
2787
2801
|
* (0x7855) store the uid/gid, so this is where they are read for entries carrying just these fields, e.g.
|
|
2788
|
-
* with `entry.localDirectory.extraFieldUnixType1.uid`. The values
|
|
2789
|
-
* {@link EntryMetaData#
|
|
2802
|
+
* with `entry.localDirectory.extraFieldUnixType1.uid`. The values fill in {@link EntryMetaData#uid} and
|
|
2803
|
+
* {@link EntryMetaData#gid} only when the central directory gave none, see {@link EntryMetaData#uid}.
|
|
2790
2804
|
*/
|
|
2791
2805
|
localDirectory?: LocalDirectory;
|
|
2792
2806
|
/**
|
|
@@ -3072,7 +3086,13 @@ export class ZipWriter<Type> {
|
|
|
3072
3086
|
* The returned promise can safely be left un-awaited: {@link ZipWriter#close} waits for the copy
|
|
3073
3087
|
* and throws its error if it was not caught.
|
|
3074
3088
|
*
|
|
3089
|
+
* With the {@link ZipWriterAppendZipOptions#filter} option, only the entries the function keeps are copied.
|
|
3090
|
+
* Combined with {@link ZipWriter#add}, this edits an existing zip file into a new one without decompressing
|
|
3091
|
+
* its data: the entries to keep are copied as-is, the entries to delete or replace are left out, and the
|
|
3092
|
+
* replacements and additions are added afterwards.
|
|
3093
|
+
*
|
|
3075
3094
|
* @param reader The {@link Reader} instance used to read the content of the zip file.
|
|
3095
|
+
* @param options The options.
|
|
3076
3096
|
* @returns A promise resolving when the zip file has been added.
|
|
3077
3097
|
*/
|
|
3078
3098
|
appendZip<ReaderType>(
|
|
@@ -3082,7 +3102,8 @@ export class ZipWriter<Type> {
|
|
|
3082
3102
|
| ReadableStream
|
|
3083
3103
|
| Reader<unknown>[]
|
|
3084
3104
|
| ReadableReader[]
|
|
3085
|
-
| ReadableStream[]
|
|
3105
|
+
| ReadableStream[],
|
|
3106
|
+
options?: ZipWriterAppendZipOptions
|
|
3086
3107
|
): Promise<void>;
|
|
3087
3108
|
|
|
3088
3109
|
/**
|
|
@@ -3300,6 +3321,29 @@ export interface ZipWriterAddDataOptions
|
|
|
3300
3321
|
/**
|
|
3301
3322
|
* Represents the options passed to {@link ZipWriter#close}.
|
|
3302
3323
|
*/
|
|
3324
|
+
/**
|
|
3325
|
+
* Represents the options passed to {@link ZipWriter#appendZip}.
|
|
3326
|
+
*/
|
|
3327
|
+
export interface ZipWriterAppendZipOptions {
|
|
3328
|
+
/**
|
|
3329
|
+
* Selects the entries of the zip file to copy: the function is called once per entry, in the order of the
|
|
3330
|
+
* 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, the zip file is closed after the last call.
|
|
3332
|
+
*
|
|
3333
|
+
* @remarks
|
|
3334
|
+
* When the option is set, the data of the zip file is copied entry by entry and the entries left out leave no
|
|
3335
|
+
* 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 its entries, e.g. a self-extracting stub
|
|
3337
|
+
* before the first entry, are not copied either. Without the option, the data of the zip file is copied as a
|
|
3338
|
+
* whole. The duplicate filename check applies to the entries kept only, so an entry can be replaced by
|
|
3339
|
+
* leaving it out and adding its replacement with {@link ZipWriter#add}.
|
|
3340
|
+
*
|
|
3341
|
+
* @param entry The entry read from the zip file.
|
|
3342
|
+
* @returns `true` to copy the entry.
|
|
3343
|
+
*/
|
|
3344
|
+
filter?: (entry: Entry) => boolean | Promise<boolean>;
|
|
3345
|
+
}
|
|
3346
|
+
|
|
3303
3347
|
export interface ZipWriterCloseOptions extends EntryOnprogressOptions {
|
|
3304
3348
|
/**
|
|
3305
3349
|
* `true` to use Zip64 to write the entries directory.
|
|
@@ -3649,8 +3693,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3649
3693
|
* Which Unix extra field format to write when creating entries that include Unix metadata.
|
|
3650
3694
|
* - "infozip": Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid up to 32 bits.
|
|
3651
3695
|
* - "unix": Info-ZIP Unix extra field type 2 (0x7855), storing fixed 2-byte uid/gid (0..65535); a
|
|
3652
|
-
* larger uid or gid is rejected. The
|
|
3653
|
-
*
|
|
3696
|
+
* larger uid or gid is rejected. The ids are written in the local file header only, the central
|
|
3697
|
+
* directory copy is empty as Info-ZIP specifies, so a reader working from the central directory,
|
|
3698
|
+
* {@link ZipReader} included, reports them once the entry data has been read. The Unix mode is not
|
|
3699
|
+
* part of this field; it is written to the external file attributes.
|
|
3654
3700
|
*
|
|
3655
3701
|
* When {@link ZipFS} exports imported entries, their uid/gid are re-emitted as "infozip" regardless
|
|
3656
3702
|
* of the field type found in the imported zip file, unless this option is set explicitly.
|
|
@@ -4989,7 +5035,9 @@ export const ERR_BAD_FORMAT: string;
|
|
|
4989
5035
|
*/
|
|
4990
5036
|
export const ERR_EOCDR_NOT_FOUND: string;
|
|
4991
5037
|
/**
|
|
4992
|
-
* Zip64 End of Central Directory Locator not found error
|
|
5038
|
+
* Zip64 End of Central Directory Locator not found error: the end of central directory record holds a Zip64
|
|
5039
|
+
* sentinel in its offset, size or disk number field but no Zip64 locator precedes it, or the locator does not
|
|
5040
|
+
* point at a Zip64 end of central directory record
|
|
4993
5041
|
*/
|
|
4994
5042
|
export const ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: string;
|
|
4995
5043
|
/**
|
|
@@ -5588,6 +5636,27 @@ export const WARNING_PREPENDED_CENTRAL_DIRECTORY: string;
|
|
|
5588
5636
|
* the reason of {@link ERR_AMBIGUOUS_ARCHIVE} under `strictness: "strict"`
|
|
5589
5637
|
*/
|
|
5590
5638
|
export const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA: string;
|
|
5639
|
+
/**
|
|
5640
|
+
* Warning reason: the end of central directory record stores a central directory offset that points past the
|
|
5641
|
+
* central directory actually found before it, so the archive was read from the directory found rather than from
|
|
5642
|
+
* the stored offset (see {@link ZipReader#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} under
|
|
5643
|
+
* `strictness: "strict"`
|
|
5644
|
+
*
|
|
5645
|
+
* @remarks
|
|
5646
|
+
* 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. When the local file header of the first entry is found at
|
|
5648
|
+
* the same shifted position, the entries are read from the shifted positions; otherwise the offsets stored in
|
|
5649
|
+
* the central directory are used as they are.
|
|
5650
|
+
*/
|
|
5651
|
+
export const WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET: string;
|
|
5652
|
+
/**
|
|
5653
|
+
* Warning reason: a central directory record holds the Zip64 sentinel in a size, offset or disk number field
|
|
5654
|
+
* 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 throws {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND}; the
|
|
5656
|
+
* other entries are unaffected. Under `strictness: "strict"`, {@link ZipReader#getEntries} throws
|
|
5657
|
+
* {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND} instead.
|
|
5658
|
+
*/
|
|
5659
|
+
export const WARNING_MISSING_ZIP64_EXTRA_FIELD: string;
|
|
5591
5660
|
/**
|
|
5592
5661
|
* Warning reason: several entries share the same filename (see {@link ZipReader#warnings}); the reason of
|
|
5593
5662
|
* {@link ERR_AMBIGUOUS_ARCHIVE} under `strictness: "strict"`
|