@zip.js/zip.js 2.9.0 → 2.11.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/README.md +40 -0
- package/deno.json +1 -1
- package/dist/zip-core-external.js +17 -46
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +16 -46
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +170 -88
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +171 -88
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +170 -88
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +174 -91
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +175 -92
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +18 -48
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-module.wasm +0 -0
- package/dist/zip-native.js +19 -49
- 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 +20 -50
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +174 -91
- package/index-native.min.js +1 -1
- package/index.cjs +175 -92
- package/index.d.cts +92 -44
- package/index.d.ts +92 -44
- package/index.min.js +1 -1
- package/lib/core/codec-pool.js +0 -2
- package/lib/core/codec-registry.js +2 -0
- package/lib/core/streams/codec-stream.js +0 -2
- package/lib/core/streams/common-crypto.js +1 -3
- package/lib/core/streams/zip-entry-stream.js +2 -5
- package/lib/core/streams/zlib-js/zlib-streams.min.js +1 -1
- package/lib/core/streams/zlib-wasm/zlib-streams.js +1 -1
- package/lib/core/streams/zlib-wasm/zlib-streams.wasm +0 -0
- package/lib/core/util/decode-cp437.js +4 -11
- package/lib/core/version.js +1 -1
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-entry.js +0 -6
- package/lib/core/zip-fs.js +155 -44
- package/lib/core/zip-reader.js +1 -6
- package/lib/core/zip-writer.js +4 -19
- package/lib/core/zlib-streams-inline.js +1 -1
- package/lib/zip-core-reader.js +0 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -1594,10 +1594,17 @@ export interface ZipReaderGetEntriesOptions
|
|
|
1594
1594
|
export interface GetEntriesOptions {
|
|
1595
1595
|
/**
|
|
1596
1596
|
* The encoding of the filename of the entry.
|
|
1597
|
+
*
|
|
1598
|
+
* The option is ignored when the general purpose bit 11 is set in the header of the entry: such a
|
|
1599
|
+
* filename is always decoded as UTF-8. It is only read when the bit is not set, and the filename is
|
|
1600
|
+
* then decoded as IBM Code Page 437 when the option is not set either.
|
|
1597
1601
|
*/
|
|
1598
1602
|
filenameEncoding?: string;
|
|
1599
1603
|
/**
|
|
1600
1604
|
* The encoding of the comment of the entry.
|
|
1605
|
+
*
|
|
1606
|
+
* The option is ignored when the general purpose bit 11 is set in the header of the entry, see
|
|
1607
|
+
* {@link GetEntriesOptions#filenameEncoding}.
|
|
1601
1608
|
*/
|
|
1602
1609
|
commentEncoding?: string;
|
|
1603
1610
|
/**
|
|
@@ -2521,16 +2528,6 @@ export interface EntryMetaData {
|
|
|
2521
2528
|
* The upper 16-bit portion of {@link EntryMetaData#externalFileAttributes} when it represents Unix mode bits.
|
|
2522
2529
|
*/
|
|
2523
2530
|
unixExternalUpper?: number;
|
|
2524
|
-
/**
|
|
2525
|
-
* The internal file attribute (raw).
|
|
2526
|
-
* @deprecated Use {@link EntryMetaData#internalFileAttributes} instead.
|
|
2527
|
-
*/
|
|
2528
|
-
internalFileAttribute: number;
|
|
2529
|
-
/**
|
|
2530
|
-
* The external file attribute (raw).
|
|
2531
|
-
* @deprecated Use {@link EntryMetaData#externalFileAttributes} instead.
|
|
2532
|
-
*/
|
|
2533
|
-
externalFileAttribute: number;
|
|
2534
2531
|
/**
|
|
2535
2532
|
* The number of the disk where the entry data starts.
|
|
2536
2533
|
*/
|
|
@@ -3114,7 +3111,11 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3114
3111
|
/**
|
|
3115
3112
|
* `true` to keep the order of the entry physically in the zip file.
|
|
3116
3113
|
*
|
|
3117
|
-
*
|
|
3114
|
+
* @remarks
|
|
3115
|
+
* The entries are then written one after another, so concurrent calls to {@link ZipWriter#add} compress one
|
|
3116
|
+
* entry at a time and use a single web worker. Set {@link ZipWriterConstructorOptions#bufferedWrite} to `true`
|
|
3117
|
+
* to compress them concurrently while still keeping the order, at the cost of buffering each entry until the
|
|
3118
|
+
* previous ones are written.
|
|
3118
3119
|
*
|
|
3119
3120
|
* @defaultValue true
|
|
3120
3121
|
*/
|
|
@@ -3244,6 +3245,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3244
3245
|
* Note that this option only sets the flag, it does not ensure that the file names are in the correct
|
|
3245
3246
|
* encoding: when it is set to `false`, the names are still encoded in UTF-8 unless the
|
|
3246
3247
|
* {@link ZipWriterConstructorOptions#encodeText} option is also set to encode them in the intended code page.
|
|
3248
|
+
* Setting it to `false` alone therefore produces an archive whose file names are mislabeled, holding UTF-8
|
|
3249
|
+
* bytes announced as Code Page 437: the names holding characters outside of ASCII are decoded incorrectly
|
|
3250
|
+
* by the readers honoring the flag, including {@link ZipReader} unless
|
|
3251
|
+
* {@link GetEntriesOptions#filenameEncoding} is set to `"utf-8"`.
|
|
3247
3252
|
*
|
|
3248
3253
|
* @defaultValue true
|
|
3249
3254
|
*/
|
|
@@ -3290,12 +3295,6 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3290
3295
|
* attribute for folder entries, Unix default permissions when `msDosCompatible` is `false`).
|
|
3291
3296
|
*/
|
|
3292
3297
|
externalFileAttributes?: number;
|
|
3293
|
-
/**
|
|
3294
|
-
* The external file attribute.
|
|
3295
|
-
*
|
|
3296
|
-
* @deprecated Use {@link ZipWriterConstructorOptions#externalFileAttributes} instead.
|
|
3297
|
-
*/
|
|
3298
|
-
externalFileAttribute?: number;
|
|
3299
3298
|
/**
|
|
3300
3299
|
* The Unix owner id to write in the Unix extra field or as part of the external attributes.
|
|
3301
3300
|
*/
|
|
@@ -3347,12 +3346,6 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3347
3346
|
* @defaultValue 0
|
|
3348
3347
|
*/
|
|
3349
3348
|
internalFileAttributes?: number;
|
|
3350
|
-
/**
|
|
3351
|
-
* The internal file attribute.
|
|
3352
|
-
*
|
|
3353
|
-
* @deprecated Use {@link ZipWriterConstructorOptions#internalFileAttributes} instead.
|
|
3354
|
-
*/
|
|
3355
|
-
internalFileAttribute?: number;
|
|
3356
3349
|
/**
|
|
3357
3350
|
* When provided, the low 8-bit MS-DOS attributes to write into external file attributes.
|
|
3358
3351
|
* Must be an integer between 0 and 255.
|
|
@@ -3458,6 +3451,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3458
3451
|
/**
|
|
3459
3452
|
* The function called for encoding the filename and the comment of the entry.
|
|
3460
3453
|
*
|
|
3454
|
+
* zip.js encodes them in UTF-8 when the option is not set, so it must be set to write them in another
|
|
3455
|
+
* code page, together with {@link ZipWriterConstructorOptions#useUnicodeFileNames} set to `false` to
|
|
3456
|
+
* announce them as Code Page 437 instead of UTF-8.
|
|
3457
|
+
*
|
|
3461
3458
|
* @param text The text to encode.
|
|
3462
3459
|
* @param type The type of the encoded text, `"filename"` or `"comment"`.
|
|
3463
3460
|
* @returns The encoded text or `undefined` if the text should be encoded by zip.js.
|
|
@@ -3545,6 +3542,9 @@ export class ZipEntry {
|
|
|
3545
3542
|
* @remarks It is the size of the raw compressed content when the entry has been imported with the
|
|
3546
3543
|
* `passThrough` option set to `true`, since the entry holds the compressed data in that case. The
|
|
3547
3544
|
* uncompressed size of the original entry remains available in {@link ZipEntry#data}.
|
|
3545
|
+
*
|
|
3546
|
+
* It is updated by the `{@link ZipFileEntry}#replace*()` methods, and it is `0` for an entry holding
|
|
3547
|
+
* a `ReadableStream` instance, whose size is only known once the entry has been read.
|
|
3548
3548
|
*/
|
|
3549
3549
|
uncompressedSize: number;
|
|
3550
3550
|
/**
|
|
@@ -3594,6 +3594,12 @@ export class ZipEntry {
|
|
|
3594
3594
|
/**
|
|
3595
3595
|
* Set the name of the entry
|
|
3596
3596
|
*
|
|
3597
|
+
* @remarks A name holding `"/"` is split into path components, like the name passed to a
|
|
3598
|
+
* `{@link ZipDirectoryEntry}#add*()` method, so it moves the entry into the directories it names,
|
|
3599
|
+
* creating them when they do not exist. Renaming an entry to the name it already has does nothing.
|
|
3600
|
+
* Renaming it onto an existing sibling throws an {@link ERR_ENTRY_EXISTS} error, and renaming it
|
|
3601
|
+
* into itself or into one of its descendants throws.
|
|
3602
|
+
*
|
|
3597
3603
|
* @param name The new name of the entry.
|
|
3598
3604
|
*/
|
|
3599
3605
|
rename(name: string): void;
|
|
@@ -3619,6 +3625,11 @@ export class ZipEntry {
|
|
|
3619
3625
|
|
|
3620
3626
|
/**
|
|
3621
3627
|
* Represents a file entry in the zip (Filesystem API).
|
|
3628
|
+
*
|
|
3629
|
+
* @remarks A `{@link ZipFileEntry}#replace*()` method describes the entry with the content it is
|
|
3630
|
+
* given: it updates {@link ZipEntry#uncompressedSize} and clears the pass-through state of an entry
|
|
3631
|
+
* imported with the {@link ZipReaderOptions#passThrough} option, since the bytes copied verbatim are
|
|
3632
|
+
* gone. Replacing the content of an entry therefore keeps {@link ZipFS#getExportedSize} exact.
|
|
3622
3633
|
*/
|
|
3623
3634
|
export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
|
|
3624
3635
|
/**
|
|
@@ -3737,6 +3748,10 @@ export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
|
|
|
3737
3748
|
/**
|
|
3738
3749
|
* Replaces the content of the entry with a `ReadableStream` instance
|
|
3739
3750
|
*
|
|
3751
|
+
* @remarks The size of a `ReadableStream` instance is unknown, so the entry reports an undetermined
|
|
3752
|
+
* size, like an entry added with {@link ZipDirectoryEntry#addReadable}. {@link ZipFS#getExportedSize}
|
|
3753
|
+
* then throws an {@link ERR_UNDETERMINED_SIZE} error instead of returning a size it cannot predict.
|
|
3754
|
+
*
|
|
3740
3755
|
* @param readable The `ReadableStream` instance.
|
|
3741
3756
|
*/
|
|
3742
3757
|
replaceReadable(readable: ReadableStream): void;
|
|
@@ -3744,6 +3759,13 @@ export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
|
|
|
3744
3759
|
|
|
3745
3760
|
/**
|
|
3746
3761
|
* Represents a directory entry in the zip (Filesystem API).
|
|
3762
|
+
*
|
|
3763
|
+
* @remarks The `name` passed to an `{@link ZipDirectoryEntry}#add*()` method is split into path
|
|
3764
|
+
* components, exactly like the filename of an imported entry, so `addText("a/b.txt", text)` adds
|
|
3765
|
+
* `"b.txt"` to the `"a"` directory and creates that directory when it does not exist. Empty
|
|
3766
|
+
* components and `"."` components are ignored. The directories created that way are navigable like
|
|
3767
|
+
* any other entry but are not written when the tree is exported, so the zip file holds the same
|
|
3768
|
+
* entries whichever way the path was built.
|
|
3747
3769
|
*/
|
|
3748
3770
|
export class ZipDirectoryEntry extends ZipEntry {
|
|
3749
3771
|
/**
|
|
@@ -3916,7 +3938,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3916
3938
|
*/
|
|
3917
3939
|
importBlob(
|
|
3918
3940
|
blob: Blob,
|
|
3919
|
-
options?:
|
|
3941
|
+
options?: ZipDirectoryEntryImportOptions
|
|
3920
3942
|
): Promise<[ZipEntry]>;
|
|
3921
3943
|
/**
|
|
3922
3944
|
* Extracts a zip file provided as a Data URI `string` encoded in Base64 into the entry
|
|
@@ -3929,7 +3951,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3929
3951
|
*/
|
|
3930
3952
|
importData64URI(
|
|
3931
3953
|
dataURI: string,
|
|
3932
|
-
options?:
|
|
3954
|
+
options?: ZipDirectoryEntryImportOptions
|
|
3933
3955
|
): Promise<[ZipEntry]>;
|
|
3934
3956
|
/**
|
|
3935
3957
|
* Extracts a zip file provided as a `Uint8Array` instance into the entry
|
|
@@ -3942,7 +3964,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3942
3964
|
*/
|
|
3943
3965
|
importUint8Array(
|
|
3944
3966
|
array: Uint8Array,
|
|
3945
|
-
options?:
|
|
3967
|
+
options?: ZipDirectoryEntryImportOptions
|
|
3946
3968
|
): Promise<[ZipEntry]>;
|
|
3947
3969
|
/**
|
|
3948
3970
|
* Extracts a zip file fetched from a URL into the entry
|
|
@@ -3972,7 +3994,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3972
3994
|
*/
|
|
3973
3995
|
importReadable(
|
|
3974
3996
|
readable: ReadableStream,
|
|
3975
|
-
options?:
|
|
3997
|
+
options?: ZipDirectoryEntryImportOptions
|
|
3976
3998
|
): Promise<[ZipEntry]>;
|
|
3977
3999
|
/**
|
|
3978
4000
|
* Extracts a zip file provided via a custom {@link Reader} instance or a {@link ZipReader} instance into
|
|
@@ -4008,7 +4030,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
4008
4030
|
| ReadableReader[]
|
|
4009
4031
|
| ReadableStream[]
|
|
4010
4032
|
| ZipReader<unknown>,
|
|
4011
|
-
options?:
|
|
4033
|
+
options?: ZipDirectoryEntryImportOptions
|
|
4012
4034
|
): Promise<[ZipEntry]>;
|
|
4013
4035
|
/**
|
|
4014
4036
|
* Returns a `Blob` instance containing a zip file of the entry and its descendants
|
|
@@ -4112,7 +4134,9 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
4112
4134
|
* This happens when `usdz` is set, since the alignment padding depends on the offset of each
|
|
4113
4135
|
* entry, and when the archive exceeds 4GB, since the offsets recorded in the central directory
|
|
4114
4136
|
* are then extended to 64 bits. Passing `bufferedWrite: false` makes both determinable again,
|
|
4115
|
-
* as does exporting a directory whose children are all files.
|
|
4137
|
+
* as does exporting a directory whose children are all files. A name holding `"/"` creates the
|
|
4138
|
+
* directories it names, so `addText("a/b.txt", text)` builds a tree whose children are not all
|
|
4139
|
+
* files, even though the directories created that way are not written. It is thrown as well when
|
|
4116
4140
|
* `signCentralDirectory` is set, the length of the signature being unknown until it is computed.
|
|
4117
4141
|
*
|
|
4118
4142
|
* @param options The options.
|
|
@@ -4122,11 +4146,39 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
4122
4146
|
getExportedSize(options?: ZipDirectoryEntryExportOptions): Promise<number>;
|
|
4123
4147
|
}
|
|
4124
4148
|
|
|
4149
|
+
/**
|
|
4150
|
+
* Represents the options passed to `{@link ZipDirectoryEntry}#import*()`.
|
|
4151
|
+
*/
|
|
4152
|
+
export interface ZipDirectoryEntryImportOptions
|
|
4153
|
+
extends ZipReaderConstructorOptions {
|
|
4154
|
+
/**
|
|
4155
|
+
* The policy applied when two entries of the imported zip file claim the same node of the tree
|
|
4156
|
+
*
|
|
4157
|
+
* @remarks
|
|
4158
|
+
* The tree indexes the entries by path, whereas a zip file stores a flat list of filenames, so two
|
|
4159
|
+
* entries can claim one node: they can hold the same filename, hold filenames differing only by the
|
|
4160
|
+
* path components ignored when building the tree (e.g. `"a/b.txt"` and `"./a/b.txt"`), or one can be
|
|
4161
|
+
* a file and the other a directory holding it (e.g. `"a"` and `"a/b.txt"`).
|
|
4162
|
+
*
|
|
4163
|
+
* `"throw"` refuses the zip file with an {@link ERR_DUPLICATE_IMPORTED_ENTRY} error, whose `cause`
|
|
4164
|
+
* property holds the {@link EntryMetaData} instance of the entry that could not be imported. The
|
|
4165
|
+
* filesystem is left unchanged, i.e. the entries imported before the error are removed and the
|
|
4166
|
+
* content held before the import is restored.
|
|
4167
|
+
*
|
|
4168
|
+
* `"keep-first"` ignores the entry claiming a node already taken, and `"keep-last"` replaces the
|
|
4169
|
+
* entry holding the node, which is the behavior of most zip tools. The entries that do not collide
|
|
4170
|
+
* are imported in both cases.
|
|
4171
|
+
*
|
|
4172
|
+
* @defaultValue "throw"
|
|
4173
|
+
*/
|
|
4174
|
+
duplicates?: "throw" | "keep-first" | "keep-last";
|
|
4175
|
+
}
|
|
4176
|
+
|
|
4125
4177
|
/**
|
|
4126
4178
|
* Represents the options passed to {@link ZipDirectoryEntry#importHttpContent}.
|
|
4127
4179
|
*/
|
|
4128
4180
|
export interface ZipDirectoryEntryImportHttpOptions
|
|
4129
|
-
extends
|
|
4181
|
+
extends ZipDirectoryEntryImportOptions,
|
|
4130
4182
|
HttpOptions {}
|
|
4131
4183
|
|
|
4132
4184
|
/**
|
|
@@ -4468,27 +4520,13 @@ export const ERR_INVALID_CODEC_MODULE: string;
|
|
|
4468
4520
|
/**
|
|
4469
4521
|
* Invalid CRC-32 checksum error, thrown when the {@link ZipReaderOptions#checkCrc32} option is set and the CRC-32
|
|
4470
4522
|
* checksum of an entry does not match the value stored in the zip file.
|
|
4471
|
-
*
|
|
4472
|
-
* @remarks
|
|
4473
|
-
* This constant and {@link ERR_INVALID_AUTHENTICATION_CODE} share the same value as {@link ERR_INVALID_SIGNATURE}
|
|
4474
|
-
* for backward compatibility. They will become distinct strings in the next minor version.
|
|
4475
4523
|
*/
|
|
4476
4524
|
export const ERR_INVALID_CRC32: string;
|
|
4477
4525
|
/**
|
|
4478
4526
|
* Invalid authentication code error, thrown when the authentication code of an entry encrypted with AES does not
|
|
4479
4527
|
* match the encrypted data, e.g. when the data was tampered or corrupted after the encryption.
|
|
4480
|
-
*
|
|
4481
|
-
* @remarks
|
|
4482
|
-
* This constant and {@link ERR_INVALID_CRC32} share the same value as {@link ERR_INVALID_SIGNATURE} for backward
|
|
4483
|
-
* compatibility. They will become distinct strings in the next minor version.
|
|
4484
4528
|
*/
|
|
4485
4529
|
export const ERR_INVALID_AUTHENTICATION_CODE: string;
|
|
4486
|
-
/**
|
|
4487
|
-
* Invalid signature error
|
|
4488
|
-
*
|
|
4489
|
-
* @deprecated Use {@link ERR_INVALID_CRC32} or {@link ERR_INVALID_AUTHENTICATION_CODE} instead.
|
|
4490
|
-
*/
|
|
4491
|
-
export const ERR_INVALID_SIGNATURE: string;
|
|
4492
4530
|
/**
|
|
4493
4531
|
* Invalid uncompressed size error
|
|
4494
4532
|
*/
|
|
@@ -4779,6 +4817,16 @@ export const ERR_ZIP_CRYPTO_LAST_MOD_DATE: string;
|
|
|
4779
4817
|
* Entry already exists error (thrown by the filesystem API when adding an entry whose filename already exists)
|
|
4780
4818
|
*/
|
|
4781
4819
|
export const ERR_ENTRY_EXISTS: string;
|
|
4820
|
+
/**
|
|
4821
|
+
* Duplicate imported entry error (thrown by `{@link ZipDirectoryEntry}#import*()` when two entries of the
|
|
4822
|
+
* zip file claim the same node of the tree and the {@link ZipDirectoryEntryImportOptions#duplicates} option
|
|
4823
|
+
* is set to `"throw"`)
|
|
4824
|
+
*/
|
|
4825
|
+
export const ERR_DUPLICATE_IMPORTED_ENTRY: string;
|
|
4826
|
+
/**
|
|
4827
|
+
* Invalid duplicates option error
|
|
4828
|
+
*/
|
|
4829
|
+
export const ERR_INVALID_DUPLICATES: string;
|
|
4782
4830
|
/**
|
|
4783
4831
|
* Readable stream already consumed error (thrown by the filesystem API when a readable stream is read more than once)
|
|
4784
4832
|
*/
|
package/index.d.ts
CHANGED
|
@@ -1594,10 +1594,17 @@ export interface ZipReaderGetEntriesOptions
|
|
|
1594
1594
|
export interface GetEntriesOptions {
|
|
1595
1595
|
/**
|
|
1596
1596
|
* The encoding of the filename of the entry.
|
|
1597
|
+
*
|
|
1598
|
+
* The option is ignored when the general purpose bit 11 is set in the header of the entry: such a
|
|
1599
|
+
* filename is always decoded as UTF-8. It is only read when the bit is not set, and the filename is
|
|
1600
|
+
* then decoded as IBM Code Page 437 when the option is not set either.
|
|
1597
1601
|
*/
|
|
1598
1602
|
filenameEncoding?: string;
|
|
1599
1603
|
/**
|
|
1600
1604
|
* The encoding of the comment of the entry.
|
|
1605
|
+
*
|
|
1606
|
+
* The option is ignored when the general purpose bit 11 is set in the header of the entry, see
|
|
1607
|
+
* {@link GetEntriesOptions#filenameEncoding}.
|
|
1601
1608
|
*/
|
|
1602
1609
|
commentEncoding?: string;
|
|
1603
1610
|
/**
|
|
@@ -2521,16 +2528,6 @@ export interface EntryMetaData {
|
|
|
2521
2528
|
* The upper 16-bit portion of {@link EntryMetaData#externalFileAttributes} when it represents Unix mode bits.
|
|
2522
2529
|
*/
|
|
2523
2530
|
unixExternalUpper?: number;
|
|
2524
|
-
/**
|
|
2525
|
-
* The internal file attribute (raw).
|
|
2526
|
-
* @deprecated Use {@link EntryMetaData#internalFileAttributes} instead.
|
|
2527
|
-
*/
|
|
2528
|
-
internalFileAttribute: number;
|
|
2529
|
-
/**
|
|
2530
|
-
* The external file attribute (raw).
|
|
2531
|
-
* @deprecated Use {@link EntryMetaData#externalFileAttributes} instead.
|
|
2532
|
-
*/
|
|
2533
|
-
externalFileAttribute: number;
|
|
2534
2531
|
/**
|
|
2535
2532
|
* The number of the disk where the entry data starts.
|
|
2536
2533
|
*/
|
|
@@ -3114,7 +3111,11 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3114
3111
|
/**
|
|
3115
3112
|
* `true` to keep the order of the entry physically in the zip file.
|
|
3116
3113
|
*
|
|
3117
|
-
*
|
|
3114
|
+
* @remarks
|
|
3115
|
+
* The entries are then written one after another, so concurrent calls to {@link ZipWriter#add} compress one
|
|
3116
|
+
* entry at a time and use a single web worker. Set {@link ZipWriterConstructorOptions#bufferedWrite} to `true`
|
|
3117
|
+
* to compress them concurrently while still keeping the order, at the cost of buffering each entry until the
|
|
3118
|
+
* previous ones are written.
|
|
3118
3119
|
*
|
|
3119
3120
|
* @defaultValue true
|
|
3120
3121
|
*/
|
|
@@ -3244,6 +3245,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3244
3245
|
* Note that this option only sets the flag, it does not ensure that the file names are in the correct
|
|
3245
3246
|
* encoding: when it is set to `false`, the names are still encoded in UTF-8 unless the
|
|
3246
3247
|
* {@link ZipWriterConstructorOptions#encodeText} option is also set to encode them in the intended code page.
|
|
3248
|
+
* Setting it to `false` alone therefore produces an archive whose file names are mislabeled, holding UTF-8
|
|
3249
|
+
* bytes announced as Code Page 437: the names holding characters outside of ASCII are decoded incorrectly
|
|
3250
|
+
* by the readers honoring the flag, including {@link ZipReader} unless
|
|
3251
|
+
* {@link GetEntriesOptions#filenameEncoding} is set to `"utf-8"`.
|
|
3247
3252
|
*
|
|
3248
3253
|
* @defaultValue true
|
|
3249
3254
|
*/
|
|
@@ -3290,12 +3295,6 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3290
3295
|
* attribute for folder entries, Unix default permissions when `msDosCompatible` is `false`).
|
|
3291
3296
|
*/
|
|
3292
3297
|
externalFileAttributes?: number;
|
|
3293
|
-
/**
|
|
3294
|
-
* The external file attribute.
|
|
3295
|
-
*
|
|
3296
|
-
* @deprecated Use {@link ZipWriterConstructorOptions#externalFileAttributes} instead.
|
|
3297
|
-
*/
|
|
3298
|
-
externalFileAttribute?: number;
|
|
3299
3298
|
/**
|
|
3300
3299
|
* The Unix owner id to write in the Unix extra field or as part of the external attributes.
|
|
3301
3300
|
*/
|
|
@@ -3347,12 +3346,6 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3347
3346
|
* @defaultValue 0
|
|
3348
3347
|
*/
|
|
3349
3348
|
internalFileAttributes?: number;
|
|
3350
|
-
/**
|
|
3351
|
-
* The internal file attribute.
|
|
3352
|
-
*
|
|
3353
|
-
* @deprecated Use {@link ZipWriterConstructorOptions#internalFileAttributes} instead.
|
|
3354
|
-
*/
|
|
3355
|
-
internalFileAttribute?: number;
|
|
3356
3349
|
/**
|
|
3357
3350
|
* When provided, the low 8-bit MS-DOS attributes to write into external file attributes.
|
|
3358
3351
|
* Must be an integer between 0 and 255.
|
|
@@ -3458,6 +3451,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3458
3451
|
/**
|
|
3459
3452
|
* The function called for encoding the filename and the comment of the entry.
|
|
3460
3453
|
*
|
|
3454
|
+
* zip.js encodes them in UTF-8 when the option is not set, so it must be set to write them in another
|
|
3455
|
+
* code page, together with {@link ZipWriterConstructorOptions#useUnicodeFileNames} set to `false` to
|
|
3456
|
+
* announce them as Code Page 437 instead of UTF-8.
|
|
3457
|
+
*
|
|
3461
3458
|
* @param text The text to encode.
|
|
3462
3459
|
* @param type The type of the encoded text, `"filename"` or `"comment"`.
|
|
3463
3460
|
* @returns The encoded text or `undefined` if the text should be encoded by zip.js.
|
|
@@ -3545,6 +3542,9 @@ export class ZipEntry {
|
|
|
3545
3542
|
* @remarks It is the size of the raw compressed content when the entry has been imported with the
|
|
3546
3543
|
* `passThrough` option set to `true`, since the entry holds the compressed data in that case. The
|
|
3547
3544
|
* uncompressed size of the original entry remains available in {@link ZipEntry#data}.
|
|
3545
|
+
*
|
|
3546
|
+
* It is updated by the `{@link ZipFileEntry}#replace*()` methods, and it is `0` for an entry holding
|
|
3547
|
+
* a `ReadableStream` instance, whose size is only known once the entry has been read.
|
|
3548
3548
|
*/
|
|
3549
3549
|
uncompressedSize: number;
|
|
3550
3550
|
/**
|
|
@@ -3594,6 +3594,12 @@ export class ZipEntry {
|
|
|
3594
3594
|
/**
|
|
3595
3595
|
* Set the name of the entry
|
|
3596
3596
|
*
|
|
3597
|
+
* @remarks A name holding `"/"` is split into path components, like the name passed to a
|
|
3598
|
+
* `{@link ZipDirectoryEntry}#add*()` method, so it moves the entry into the directories it names,
|
|
3599
|
+
* creating them when they do not exist. Renaming an entry to the name it already has does nothing.
|
|
3600
|
+
* Renaming it onto an existing sibling throws an {@link ERR_ENTRY_EXISTS} error, and renaming it
|
|
3601
|
+
* into itself or into one of its descendants throws.
|
|
3602
|
+
*
|
|
3597
3603
|
* @param name The new name of the entry.
|
|
3598
3604
|
*/
|
|
3599
3605
|
rename(name: string): void;
|
|
@@ -3619,6 +3625,11 @@ export class ZipEntry {
|
|
|
3619
3625
|
|
|
3620
3626
|
/**
|
|
3621
3627
|
* Represents a file entry in the zip (Filesystem API).
|
|
3628
|
+
*
|
|
3629
|
+
* @remarks A `{@link ZipFileEntry}#replace*()` method describes the entry with the content it is
|
|
3630
|
+
* given: it updates {@link ZipEntry#uncompressedSize} and clears the pass-through state of an entry
|
|
3631
|
+
* imported with the {@link ZipReaderOptions#passThrough} option, since the bytes copied verbatim are
|
|
3632
|
+
* gone. Replacing the content of an entry therefore keeps {@link ZipFS#getExportedSize} exact.
|
|
3622
3633
|
*/
|
|
3623
3634
|
export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
|
|
3624
3635
|
/**
|
|
@@ -3737,6 +3748,10 @@ export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
|
|
|
3737
3748
|
/**
|
|
3738
3749
|
* Replaces the content of the entry with a `ReadableStream` instance
|
|
3739
3750
|
*
|
|
3751
|
+
* @remarks The size of a `ReadableStream` instance is unknown, so the entry reports an undetermined
|
|
3752
|
+
* size, like an entry added with {@link ZipDirectoryEntry#addReadable}. {@link ZipFS#getExportedSize}
|
|
3753
|
+
* then throws an {@link ERR_UNDETERMINED_SIZE} error instead of returning a size it cannot predict.
|
|
3754
|
+
*
|
|
3740
3755
|
* @param readable The `ReadableStream` instance.
|
|
3741
3756
|
*/
|
|
3742
3757
|
replaceReadable(readable: ReadableStream): void;
|
|
@@ -3744,6 +3759,13 @@ export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
|
|
|
3744
3759
|
|
|
3745
3760
|
/**
|
|
3746
3761
|
* Represents a directory entry in the zip (Filesystem API).
|
|
3762
|
+
*
|
|
3763
|
+
* @remarks The `name` passed to an `{@link ZipDirectoryEntry}#add*()` method is split into path
|
|
3764
|
+
* components, exactly like the filename of an imported entry, so `addText("a/b.txt", text)` adds
|
|
3765
|
+
* `"b.txt"` to the `"a"` directory and creates that directory when it does not exist. Empty
|
|
3766
|
+
* components and `"."` components are ignored. The directories created that way are navigable like
|
|
3767
|
+
* any other entry but are not written when the tree is exported, so the zip file holds the same
|
|
3768
|
+
* entries whichever way the path was built.
|
|
3747
3769
|
*/
|
|
3748
3770
|
export class ZipDirectoryEntry extends ZipEntry {
|
|
3749
3771
|
/**
|
|
@@ -3916,7 +3938,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3916
3938
|
*/
|
|
3917
3939
|
importBlob(
|
|
3918
3940
|
blob: Blob,
|
|
3919
|
-
options?:
|
|
3941
|
+
options?: ZipDirectoryEntryImportOptions
|
|
3920
3942
|
): Promise<[ZipEntry]>;
|
|
3921
3943
|
/**
|
|
3922
3944
|
* Extracts a zip file provided as a Data URI `string` encoded in Base64 into the entry
|
|
@@ -3929,7 +3951,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3929
3951
|
*/
|
|
3930
3952
|
importData64URI(
|
|
3931
3953
|
dataURI: string,
|
|
3932
|
-
options?:
|
|
3954
|
+
options?: ZipDirectoryEntryImportOptions
|
|
3933
3955
|
): Promise<[ZipEntry]>;
|
|
3934
3956
|
/**
|
|
3935
3957
|
* Extracts a zip file provided as a `Uint8Array` instance into the entry
|
|
@@ -3942,7 +3964,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3942
3964
|
*/
|
|
3943
3965
|
importUint8Array(
|
|
3944
3966
|
array: Uint8Array,
|
|
3945
|
-
options?:
|
|
3967
|
+
options?: ZipDirectoryEntryImportOptions
|
|
3946
3968
|
): Promise<[ZipEntry]>;
|
|
3947
3969
|
/**
|
|
3948
3970
|
* Extracts a zip file fetched from a URL into the entry
|
|
@@ -3972,7 +3994,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
3972
3994
|
*/
|
|
3973
3995
|
importReadable(
|
|
3974
3996
|
readable: ReadableStream,
|
|
3975
|
-
options?:
|
|
3997
|
+
options?: ZipDirectoryEntryImportOptions
|
|
3976
3998
|
): Promise<[ZipEntry]>;
|
|
3977
3999
|
/**
|
|
3978
4000
|
* Extracts a zip file provided via a custom {@link Reader} instance or a {@link ZipReader} instance into
|
|
@@ -4008,7 +4030,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
4008
4030
|
| ReadableReader[]
|
|
4009
4031
|
| ReadableStream[]
|
|
4010
4032
|
| ZipReader<unknown>,
|
|
4011
|
-
options?:
|
|
4033
|
+
options?: ZipDirectoryEntryImportOptions
|
|
4012
4034
|
): Promise<[ZipEntry]>;
|
|
4013
4035
|
/**
|
|
4014
4036
|
* Returns a `Blob` instance containing a zip file of the entry and its descendants
|
|
@@ -4112,7 +4134,9 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
4112
4134
|
* This happens when `usdz` is set, since the alignment padding depends on the offset of each
|
|
4113
4135
|
* entry, and when the archive exceeds 4GB, since the offsets recorded in the central directory
|
|
4114
4136
|
* are then extended to 64 bits. Passing `bufferedWrite: false` makes both determinable again,
|
|
4115
|
-
* as does exporting a directory whose children are all files.
|
|
4137
|
+
* as does exporting a directory whose children are all files. A name holding `"/"` creates the
|
|
4138
|
+
* directories it names, so `addText("a/b.txt", text)` builds a tree whose children are not all
|
|
4139
|
+
* files, even though the directories created that way are not written. It is thrown as well when
|
|
4116
4140
|
* `signCentralDirectory` is set, the length of the signature being unknown until it is computed.
|
|
4117
4141
|
*
|
|
4118
4142
|
* @param options The options.
|
|
@@ -4122,11 +4146,39 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
4122
4146
|
getExportedSize(options?: ZipDirectoryEntryExportOptions): Promise<number>;
|
|
4123
4147
|
}
|
|
4124
4148
|
|
|
4149
|
+
/**
|
|
4150
|
+
* Represents the options passed to `{@link ZipDirectoryEntry}#import*()`.
|
|
4151
|
+
*/
|
|
4152
|
+
export interface ZipDirectoryEntryImportOptions
|
|
4153
|
+
extends ZipReaderConstructorOptions {
|
|
4154
|
+
/**
|
|
4155
|
+
* The policy applied when two entries of the imported zip file claim the same node of the tree
|
|
4156
|
+
*
|
|
4157
|
+
* @remarks
|
|
4158
|
+
* The tree indexes the entries by path, whereas a zip file stores a flat list of filenames, so two
|
|
4159
|
+
* entries can claim one node: they can hold the same filename, hold filenames differing only by the
|
|
4160
|
+
* path components ignored when building the tree (e.g. `"a/b.txt"` and `"./a/b.txt"`), or one can be
|
|
4161
|
+
* a file and the other a directory holding it (e.g. `"a"` and `"a/b.txt"`).
|
|
4162
|
+
*
|
|
4163
|
+
* `"throw"` refuses the zip file with an {@link ERR_DUPLICATE_IMPORTED_ENTRY} error, whose `cause`
|
|
4164
|
+
* property holds the {@link EntryMetaData} instance of the entry that could not be imported. The
|
|
4165
|
+
* filesystem is left unchanged, i.e. the entries imported before the error are removed and the
|
|
4166
|
+
* content held before the import is restored.
|
|
4167
|
+
*
|
|
4168
|
+
* `"keep-first"` ignores the entry claiming a node already taken, and `"keep-last"` replaces the
|
|
4169
|
+
* entry holding the node, which is the behavior of most zip tools. The entries that do not collide
|
|
4170
|
+
* are imported in both cases.
|
|
4171
|
+
*
|
|
4172
|
+
* @defaultValue "throw"
|
|
4173
|
+
*/
|
|
4174
|
+
duplicates?: "throw" | "keep-first" | "keep-last";
|
|
4175
|
+
}
|
|
4176
|
+
|
|
4125
4177
|
/**
|
|
4126
4178
|
* Represents the options passed to {@link ZipDirectoryEntry#importHttpContent}.
|
|
4127
4179
|
*/
|
|
4128
4180
|
export interface ZipDirectoryEntryImportHttpOptions
|
|
4129
|
-
extends
|
|
4181
|
+
extends ZipDirectoryEntryImportOptions,
|
|
4130
4182
|
HttpOptions {}
|
|
4131
4183
|
|
|
4132
4184
|
/**
|
|
@@ -4468,27 +4520,13 @@ export const ERR_INVALID_CODEC_MODULE: string;
|
|
|
4468
4520
|
/**
|
|
4469
4521
|
* Invalid CRC-32 checksum error, thrown when the {@link ZipReaderOptions#checkCrc32} option is set and the CRC-32
|
|
4470
4522
|
* checksum of an entry does not match the value stored in the zip file.
|
|
4471
|
-
*
|
|
4472
|
-
* @remarks
|
|
4473
|
-
* This constant and {@link ERR_INVALID_AUTHENTICATION_CODE} share the same value as {@link ERR_INVALID_SIGNATURE}
|
|
4474
|
-
* for backward compatibility. They will become distinct strings in the next minor version.
|
|
4475
4523
|
*/
|
|
4476
4524
|
export const ERR_INVALID_CRC32: string;
|
|
4477
4525
|
/**
|
|
4478
4526
|
* Invalid authentication code error, thrown when the authentication code of an entry encrypted with AES does not
|
|
4479
4527
|
* match the encrypted data, e.g. when the data was tampered or corrupted after the encryption.
|
|
4480
|
-
*
|
|
4481
|
-
* @remarks
|
|
4482
|
-
* This constant and {@link ERR_INVALID_CRC32} share the same value as {@link ERR_INVALID_SIGNATURE} for backward
|
|
4483
|
-
* compatibility. They will become distinct strings in the next minor version.
|
|
4484
4528
|
*/
|
|
4485
4529
|
export const ERR_INVALID_AUTHENTICATION_CODE: string;
|
|
4486
|
-
/**
|
|
4487
|
-
* Invalid signature error
|
|
4488
|
-
*
|
|
4489
|
-
* @deprecated Use {@link ERR_INVALID_CRC32} or {@link ERR_INVALID_AUTHENTICATION_CODE} instead.
|
|
4490
|
-
*/
|
|
4491
|
-
export const ERR_INVALID_SIGNATURE: string;
|
|
4492
4530
|
/**
|
|
4493
4531
|
* Invalid uncompressed size error
|
|
4494
4532
|
*/
|
|
@@ -4779,6 +4817,16 @@ export const ERR_ZIP_CRYPTO_LAST_MOD_DATE: string;
|
|
|
4779
4817
|
* Entry already exists error (thrown by the filesystem API when adding an entry whose filename already exists)
|
|
4780
4818
|
*/
|
|
4781
4819
|
export const ERR_ENTRY_EXISTS: string;
|
|
4820
|
+
/**
|
|
4821
|
+
* Duplicate imported entry error (thrown by `{@link ZipDirectoryEntry}#import*()` when two entries of the
|
|
4822
|
+
* zip file claim the same node of the tree and the {@link ZipDirectoryEntryImportOptions#duplicates} option
|
|
4823
|
+
* is set to `"throw"`)
|
|
4824
|
+
*/
|
|
4825
|
+
export const ERR_DUPLICATE_IMPORTED_ENTRY: string;
|
|
4826
|
+
/**
|
|
4827
|
+
* Invalid duplicates option error
|
|
4828
|
+
*/
|
|
4829
|
+
export const ERR_INVALID_DUPLICATES: string;
|
|
4782
4830
|
/**
|
|
4783
4831
|
* Readable stream already consumed error (thrown by the filesystem API when a readable stream is read more than once)
|
|
4784
4832
|
*/
|