@zip.js/zip.js 2.8.30 → 2.8.31
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 +5 -4
- package/dist/zip-core.js +133 -334
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core.js +115 -277
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-native.js +170 -373
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +169 -372
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +138 -339
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-module.wasm +0 -0
- package/dist/zip-native.js +141 -342
- 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 +140 -341
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +170 -373
- package/index-native.min.js +1 -1
- package/index.cjs +169 -372
- package/index.d.cts +2814 -0
- package/index.d.ts +238 -0
- package/index.min.js +1 -1
- package/lib/core/codec-worker.js +0 -10
- package/lib/core/configuration.js +21 -33
- package/lib/core/constants.js +3 -0
- package/lib/core/io.js +11 -19
- package/lib/core/streams/aes-crypto-stream.js +16 -20
- package/lib/core/streams/common-crypto.js +0 -2
- package/lib/core/streams/zip-crypto-stream.js +12 -16
- package/lib/core/streams/zip-entry-stream.js +2 -32
- package/lib/core/streams/zlib-js/zlib-streams.min.js +1 -1
- package/lib/core/streams/zlib-wasm/zlib-streams-loader.js +1 -3
- package/lib/core/streams/zlib-wasm/zlib-streams.wasm +0 -0
- package/lib/core/util/base64.js +68 -0
- package/lib/core/util/decode-text.js +0 -1
- package/lib/core/util/default-mime-type.js +0 -3
- package/lib/core/util/inflate.js +194 -0
- package/lib/core/util/mime-type.js +26 -22
- package/lib/core/util/opfs-temp-stream.js +1 -37
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-template-native.js +5 -5
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-fs.js +6 -13
- package/lib/core/zip-reader.js +48 -127
- package/lib/core/zip-writer.js +27 -45
- package/lib/core/zlib-streams-inline-template.js +3 -2
- package/lib/core/zlib-streams-inline.js +1 -1
- package/lib/zip-core-base.js +3 -1
- package/package.json +9 -6
- package/reserved-property-names.js +50 -0
- package/lib/core/util/mini-lz.js +0 -198
package/index.d.cts
ADDED
|
@@ -0,0 +1,2814 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zip.js is a JavaScript open-source library (BSD-3-Clause license) for
|
|
3
|
+
* compressing and decompressing zip files. It has been designed to handle large amounts
|
|
4
|
+
* of data. It supports notably multi-core compression, native compression with
|
|
5
|
+
* compression streams, archives larger than 4GB with Zip64, split zip files, data
|
|
6
|
+
* encryption, and Deflate64 decompression.
|
|
7
|
+
*
|
|
8
|
+
* @author Gildas Lormeau
|
|
9
|
+
* @license BSD-3-Clause
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* Hello world
|
|
13
|
+
* ```js
|
|
14
|
+
* import {
|
|
15
|
+
* BlobReader,
|
|
16
|
+
* BlobWriter,
|
|
17
|
+
* TextReader,
|
|
18
|
+
* TextWriter,
|
|
19
|
+
* ZipReader,
|
|
20
|
+
* ZipWriter,
|
|
21
|
+
* } from from "@zip-js/zip-js";
|
|
22
|
+
*
|
|
23
|
+
* // ----
|
|
24
|
+
* // Write the zip file
|
|
25
|
+
* // ----
|
|
26
|
+
*
|
|
27
|
+
* // Creates a BlobWriter object where the zip content will be written.
|
|
28
|
+
* const zipFileWriter = new BlobWriter();
|
|
29
|
+
*
|
|
30
|
+
* // Creates a TextReader object storing the text of the entry to add in the zip
|
|
31
|
+
* // (i.e. "Hello world!").
|
|
32
|
+
* const helloWorldReader = new TextReader("Hello world!");
|
|
33
|
+
*
|
|
34
|
+
* // Creates a ZipWriter object writing data via `zipFileWriter`, adds the entry
|
|
35
|
+
* // "hello.txt" containing the text "Hello world!" via `helloWorldReader`, and
|
|
36
|
+
* // closes the writer.
|
|
37
|
+
* const zipWriter = new ZipWriter(zipFileWriter);
|
|
38
|
+
* await zipWriter.add("hello.txt", helloWorldReader);
|
|
39
|
+
* await zipWriter.close();
|
|
40
|
+
*
|
|
41
|
+
* // Retrieves the Blob object containing the zip content into `zipFileBlob`. It
|
|
42
|
+
* // is also returned by zipWriter.close() for more convenience.
|
|
43
|
+
* const zipFileBlob = await zipFileWriter.getData();
|
|
44
|
+
*
|
|
45
|
+
* // ----
|
|
46
|
+
* // Read the zip file
|
|
47
|
+
* // ----
|
|
48
|
+
*
|
|
49
|
+
* // Creates a BlobReader object used to read `zipFileBlob`.
|
|
50
|
+
* const zipFileReader = new BlobReader(zipFileBlob);
|
|
51
|
+
* // Creates a TextWriter object where the content of the first entry in the zip
|
|
52
|
+
* // will be written.
|
|
53
|
+
* const helloWorldWriter = new TextWriter();
|
|
54
|
+
*
|
|
55
|
+
* // Creates a ZipReader object reading the zip content via `zipFileReader`,
|
|
56
|
+
* // retrieves metadata (name, dates, etc.) of the first entry, retrieves its
|
|
57
|
+
* // content via `helloWorldWriter`, and closes the reader.
|
|
58
|
+
* const zipReader = new ZipReader(zipFileReader);
|
|
59
|
+
* const firstEntry = (await zipReader.getEntries()).shift();
|
|
60
|
+
* const helloWorldText = await firstEntry.getData(helloWorldWriter);
|
|
61
|
+
* await zipReader.close();
|
|
62
|
+
*
|
|
63
|
+
* // Displays "Hello world!".
|
|
64
|
+
* console.log(helloWorldText);
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* Hello world with Streams
|
|
69
|
+
* ```js
|
|
70
|
+
* import {
|
|
71
|
+
* BlobReader,
|
|
72
|
+
* ZipReader,
|
|
73
|
+
* ZipWriter,
|
|
74
|
+
* } from "@zip-js/zip-js";
|
|
75
|
+
*
|
|
76
|
+
* // ----
|
|
77
|
+
* // Write the zip file
|
|
78
|
+
* // ----
|
|
79
|
+
*
|
|
80
|
+
* // Creates a TransformStream object, the zip content will be written in the
|
|
81
|
+
* // `writable` property.
|
|
82
|
+
* const zipFileStream = new TransformStream();
|
|
83
|
+
* // Creates a Promise object resolved to the zip content returned as a Blob
|
|
84
|
+
* // object retrieved from `zipFileStream.readable`.
|
|
85
|
+
* const zipFileBlobPromise = new Response(zipFileStream.readable).blob();
|
|
86
|
+
* // Creates a ReadableStream object storing the text of the entry to add in the
|
|
87
|
+
* // zip (i.e. "Hello world!").
|
|
88
|
+
* const helloWorldReadable = new Blob(["Hello world!"]).stream();
|
|
89
|
+
*
|
|
90
|
+
* // Creates a ZipWriter object writing data into `zipFileStream.writable`, adds
|
|
91
|
+
* // the entry "hello.txt" containing the text "Hello world!" retrieved from
|
|
92
|
+
* // `helloWorldReadable`, and closes the writer.
|
|
93
|
+
* const zipWriter = new ZipWriter(zipFileStream.writable);
|
|
94
|
+
* await zipWriter.add("hello.txt", helloWorldReadable);
|
|
95
|
+
* await zipWriter.close();
|
|
96
|
+
*
|
|
97
|
+
* // Retrieves the Blob object containing the zip content into `zipFileBlob`.
|
|
98
|
+
* const zipFileBlob = await zipFileBlobPromise;
|
|
99
|
+
*
|
|
100
|
+
* // ----
|
|
101
|
+
* // Read the zip file
|
|
102
|
+
* // ----
|
|
103
|
+
*
|
|
104
|
+
* // Creates a BlobReader object used to read `zipFileBlob`.
|
|
105
|
+
* const zipFileReader = new BlobReader(zipFileBlob);
|
|
106
|
+
* // Creates a TransformStream object, the content of the first entry in the zip
|
|
107
|
+
* // will be written in the `writable` property.
|
|
108
|
+
* const helloWorldStream = new TransformStream();
|
|
109
|
+
* // Creates a Promise object resolved to the content of the first entry returned
|
|
110
|
+
* // as text from `helloWorldStream.readable`.
|
|
111
|
+
* const helloWorldTextPromise = new Response(helloWorldStream.readable).text();
|
|
112
|
+
*
|
|
113
|
+
* // Creates a ZipReader object reading the zip content via `zipFileReader`,
|
|
114
|
+
* // retrieves metadata (name, dates, etc.) of the first entry, retrieves its
|
|
115
|
+
* // content into `helloWorldStream.writable`, and closes the reader.
|
|
116
|
+
* const zipReader = new ZipReader(zipFileReader);
|
|
117
|
+
* const firstEntry = (await zipReader.getEntries()).shift();
|
|
118
|
+
* await firstEntry.getData(helloWorldStream.writable);
|
|
119
|
+
* await zipReader.close();
|
|
120
|
+
*
|
|
121
|
+
* // Displays "Hello world!".
|
|
122
|
+
* const helloWorldText = await helloWorldTextPromise;
|
|
123
|
+
* console.log(helloWorldText);
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* Adding concurrently multiple entries in a zip file
|
|
128
|
+
* ```js
|
|
129
|
+
* import {
|
|
130
|
+
* BlobWriter,
|
|
131
|
+
* HttpReader,
|
|
132
|
+
* TextReader,
|
|
133
|
+
* ZipWriter,
|
|
134
|
+
* } from "@zip-js/zip-js";
|
|
135
|
+
*
|
|
136
|
+
* const README_URL = "https://unpkg.com/@zip.js/zip.js/README.md";
|
|
137
|
+
* getZipFileBlob()
|
|
138
|
+
* .then(downloadFile);
|
|
139
|
+
*
|
|
140
|
+
* async function getZipFileBlob() {
|
|
141
|
+
* const zipWriter = new ZipWriter(new BlobWriter("application/zip"));
|
|
142
|
+
* await Promise.all([
|
|
143
|
+
* zipWriter.add("hello.txt", new TextReader("Hello world!")),
|
|
144
|
+
* zipWriter.add("README.md", new HttpReader(README_URL)),
|
|
145
|
+
* ]);
|
|
146
|
+
* return zipWriter.close();
|
|
147
|
+
* }
|
|
148
|
+
*
|
|
149
|
+
* function downloadFile(blob) {
|
|
150
|
+
* document.body.appendChild(Object.assign(document.createElement("a"), {
|
|
151
|
+
* download: "hello.zip",
|
|
152
|
+
* href: URL.createObjectURL(blob),
|
|
153
|
+
* textContent: "Download zip file",
|
|
154
|
+
* }));
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @module
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Represents the `FileSystemEntry` class.
|
|
163
|
+
*
|
|
164
|
+
* @see {@link https://wicg.github.io/entries-api/#api-entry|specification}
|
|
165
|
+
*/
|
|
166
|
+
// deno-lint-ignore no-empty-interface
|
|
167
|
+
interface FileSystemEntryLike {}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Represents the `FileSystemHandle` class.
|
|
171
|
+
*
|
|
172
|
+
* @see {@link https://fs.spec.whatwg.org/#api-filesystemhandle}
|
|
173
|
+
*/
|
|
174
|
+
// deno-lint-ignore no-empty-interface
|
|
175
|
+
interface FileSystemHandleLike {}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Represents a generic `TransformStream` class.
|
|
179
|
+
*
|
|
180
|
+
* @see {@link https://streams.spec.whatwg.org/#generictransformstream|specification}
|
|
181
|
+
*/
|
|
182
|
+
declare class TransformStreamLike {
|
|
183
|
+
/**
|
|
184
|
+
* The readable stream.
|
|
185
|
+
*/
|
|
186
|
+
readable: ReadableStream;
|
|
187
|
+
/**
|
|
188
|
+
* The writable stream.
|
|
189
|
+
*/
|
|
190
|
+
writable: WritableStream;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Configures zip.js
|
|
195
|
+
*
|
|
196
|
+
* @param configuration The configuration.
|
|
197
|
+
*/
|
|
198
|
+
export function configure(configuration: Configuration): void;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Represents the configuration passed to {@link configure}.
|
|
202
|
+
*/
|
|
203
|
+
export interface Configuration extends WorkerConfiguration {
|
|
204
|
+
/**
|
|
205
|
+
* The maximum number of web workers used to compress/decompress data simultaneously.
|
|
206
|
+
*
|
|
207
|
+
* @defaultValue `navigator.hardwareConcurrency`
|
|
208
|
+
*/
|
|
209
|
+
maxWorkers?: number;
|
|
210
|
+
/**
|
|
211
|
+
* The delay in milliseconds before idle web workers are automatically terminated. You can call `terminateWorkers()` to terminate idle workers.
|
|
212
|
+
*
|
|
213
|
+
* @defaultValue 5000
|
|
214
|
+
*/
|
|
215
|
+
terminateWorkerTimeout?: number;
|
|
216
|
+
/**
|
|
217
|
+
* The delay in milliseconds after which the oldest pending compression/decompression task is run without a web worker when no task completes.
|
|
218
|
+
*
|
|
219
|
+
* It prevents deadlocks when entries read from a `ZipReader` are added concurrently into a `ZipWriter` and all the web workers are waiting for data.
|
|
220
|
+
*
|
|
221
|
+
* @defaultValue 5000
|
|
222
|
+
*/
|
|
223
|
+
workerStarvationTimeout?: number;
|
|
224
|
+
/**
|
|
225
|
+
* The URI of the web worker.
|
|
226
|
+
*
|
|
227
|
+
* It allows using alternative deflate implementations or specifying a URL to the worker script if the CSP of the page blocks scripts imported from a Data URI.
|
|
228
|
+
*
|
|
229
|
+
* Here is an example to import the worker module as a URL (see `?url`) and avoid CSP issues:
|
|
230
|
+
* ```
|
|
231
|
+
* import workerURI from "@zip.js/zip.js/dist/zip-web-worker.js?url";
|
|
232
|
+
*
|
|
233
|
+
* configure({
|
|
234
|
+
* workerURI
|
|
235
|
+
* });
|
|
236
|
+
* ```
|
|
237
|
+
*
|
|
238
|
+
* @defaultValue "./core/web-worker.js"
|
|
239
|
+
*/
|
|
240
|
+
workerURI?: string;
|
|
241
|
+
/**
|
|
242
|
+
* The URI of the WebAssembly module used by default implementations to compress/decompress data. It is ignored if `useCompressionStream` is set to `true` and `CompressionStream`/`DecompressionStream` are supported by the environment.
|
|
243
|
+
*
|
|
244
|
+
* Here is an example to import the WASM module as a URL (see `?url`) and avoid CSP issues:
|
|
245
|
+
* ```
|
|
246
|
+
* import wasmURI from "@zip.js/zip.js/dist/zip-module.wasm?url";
|
|
247
|
+
*
|
|
248
|
+
* configure({
|
|
249
|
+
* wasmURI
|
|
250
|
+
* });
|
|
251
|
+
* ```
|
|
252
|
+
*
|
|
253
|
+
* @defaultValue "./core/streams/zlib-wasm/zlib-streams.wasm"
|
|
254
|
+
*/
|
|
255
|
+
wasmURI?: string;
|
|
256
|
+
/**
|
|
257
|
+
* The size of the chunks in bytes during data compression/decompression.
|
|
258
|
+
*
|
|
259
|
+
* @defaultValue 65536
|
|
260
|
+
*/
|
|
261
|
+
chunkSize?: number;
|
|
262
|
+
/**
|
|
263
|
+
* The stream implementation used to compress data when `useCompressionStream` is set to `true`.
|
|
264
|
+
*
|
|
265
|
+
* @defaultValue {@link CodecStream}
|
|
266
|
+
*/
|
|
267
|
+
CompressionStream?: typeof TransformStreamLike;
|
|
268
|
+
/**
|
|
269
|
+
* The stream implementation used to decompress data when `useCompressionStream` is set to `true`.
|
|
270
|
+
*
|
|
271
|
+
* @defaultValue {@link CodecStream}
|
|
272
|
+
*/
|
|
273
|
+
DecompressionStream?: typeof TransformStreamLike;
|
|
274
|
+
/**
|
|
275
|
+
* The stream implementation used to compress data when `useCompressionStream` is set to `false`.
|
|
276
|
+
*
|
|
277
|
+
* @defaultValue {@link CodecStream}
|
|
278
|
+
*/
|
|
279
|
+
CompressionStreamZlib?: typeof TransformStreamLike;
|
|
280
|
+
/**
|
|
281
|
+
* The stream implementation used to decompress data when `useCompressionStream` is set to `false`.
|
|
282
|
+
*
|
|
283
|
+
* @defaultValue {@link CodecStream}
|
|
284
|
+
*/
|
|
285
|
+
DecompressionStreamZlib?: typeof TransformStreamLike;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Represents configuration passed to {@link configure}, the constructor of {@link ZipReader}, {@link FileEntry#getData}, the constructor of {@link ZipWriter}, and {@link ZipWriter#add}.
|
|
290
|
+
*/
|
|
291
|
+
export interface WorkerConfiguration {
|
|
292
|
+
/**
|
|
293
|
+
* `true` to use web workers to compress/decompress data in non-blocking background processes.
|
|
294
|
+
*
|
|
295
|
+
* @defaultValue true
|
|
296
|
+
*/
|
|
297
|
+
useWebWorkers?: boolean;
|
|
298
|
+
/**
|
|
299
|
+
* `true` to use the native API `CompressionStream`/`DecompressionStream` to compress/decompress data.
|
|
300
|
+
*
|
|
301
|
+
* @defaultValue true
|
|
302
|
+
*/
|
|
303
|
+
useCompressionStream?: boolean;
|
|
304
|
+
/**
|
|
305
|
+
* `true` to transfer stream ownership to web workers.
|
|
306
|
+
*
|
|
307
|
+
* @defaultValue true
|
|
308
|
+
*/
|
|
309
|
+
transferStreams?: boolean;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Terminates all the web workers
|
|
314
|
+
*/
|
|
315
|
+
export function terminateWorkers(): Promise<void>;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Represents a class implementing `CompressionStream` or `DecompressionStream` interfaces.
|
|
319
|
+
*/
|
|
320
|
+
declare class CodecStream extends TransformStream {}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Returns the MIME type corresponding to a filename extension.
|
|
324
|
+
*
|
|
325
|
+
* @param fileExtension the extension of the filename.
|
|
326
|
+
* @returns The corresponding MIME type.
|
|
327
|
+
*/
|
|
328
|
+
export function getMimeType(fileExtension: string): string;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* A `TransformStream`-like temporary buffer returned by a {@link ZipWriterConstructorOptions.createTempStream} factory.
|
|
332
|
+
*/
|
|
333
|
+
export interface TempStream {
|
|
334
|
+
/**
|
|
335
|
+
* The writable side, receiving the compressed data of a buffered entry.
|
|
336
|
+
*/
|
|
337
|
+
writable: WritableStream;
|
|
338
|
+
/**
|
|
339
|
+
* The readable side, replayed into the final zip stream once the entry is ready.
|
|
340
|
+
*/
|
|
341
|
+
readable: ReadableStream;
|
|
342
|
+
/**
|
|
343
|
+
* Optional cleanup, called once the entry has been processed (on success, error, or abort) to release any backing resource.
|
|
344
|
+
*/
|
|
345
|
+
dispose?: () => void | Promise<void>;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Options for {@link createOPFSTempStream}.
|
|
350
|
+
*/
|
|
351
|
+
export interface OPFSTempStreamOptions {
|
|
352
|
+
/**
|
|
353
|
+
* Spill a buffered entry to a file once its buffered data exceeds this size, in bytes. Smaller entries stay in memory.
|
|
354
|
+
*
|
|
355
|
+
* @defaultValue 1048576
|
|
356
|
+
*/
|
|
357
|
+
thresholdBytes?: number;
|
|
358
|
+
/**
|
|
359
|
+
* Name of the OPFS sub-directory holding the temporary files.
|
|
360
|
+
*
|
|
361
|
+
* @defaultValue ".zip.js-temp"
|
|
362
|
+
*/
|
|
363
|
+
directoryName?: string;
|
|
364
|
+
/**
|
|
365
|
+
* Returns (or resolves to) the root `FileSystemDirectoryHandle`. Defaults to `navigator.storage.getDirectory()`.
|
|
366
|
+
*
|
|
367
|
+
* Provide it to run inside a worker with a pre-obtained handle, or to test against a mock.
|
|
368
|
+
*/
|
|
369
|
+
getDirectory?: () => FileSystemDirectoryHandle | Promise<FileSystemDirectoryHandle>;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Builds a {@link ZipWriterConstructorOptions.createTempStream} factory that spills the data of buffered entries to the Origin Private File System (OPFS) instead of keeping it in memory.
|
|
374
|
+
*
|
|
375
|
+
* An entry stays in memory until it exceeds `thresholdBytes`, then spills to a temporary OPFS file that is streamed back and deleted afterwards, so peak memory stays bounded on large buffered entries.
|
|
376
|
+
*
|
|
377
|
+
* OPFS is a browser/worker feature; feature-detect `navigator.storage.getDirectory` (or pass `getDirectory`) before using it, and let the writer use its in-memory default elsewhere.
|
|
378
|
+
*
|
|
379
|
+
* @param options The options.
|
|
380
|
+
* @returns A factory suitable for {@link ZipWriterConstructorOptions.createTempStream}.
|
|
381
|
+
*/
|
|
382
|
+
export function createOPFSTempStream(options?: OPFSTempStreamOptions): () => Promise<TempStream>;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Represents an instance used to read or write unknown type of data.
|
|
386
|
+
*
|
|
387
|
+
* zip.js can handle multiple types of data thanks to a generic API. This feature is based on 2 abstract constructors: {@link Reader} and {@link Writer}.
|
|
388
|
+
* The classes inheriting from {@link Reader} help to read data from a source of data. The classes inheriting from {@link Writer} help to write data into a destination.
|
|
389
|
+
*/
|
|
390
|
+
export interface Initializable {
|
|
391
|
+
/**
|
|
392
|
+
* Initializes the instance asynchronously
|
|
393
|
+
*/
|
|
394
|
+
init?(): Promise<void>;
|
|
395
|
+
/**
|
|
396
|
+
* `true` if the instance is initialized.
|
|
397
|
+
*/
|
|
398
|
+
initialized?: boolean;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Represents an instance used to read data from a `ReadableStream` instance.
|
|
403
|
+
*/
|
|
404
|
+
export interface ReadableReader {
|
|
405
|
+
/**
|
|
406
|
+
* The `ReadableStream` instance.
|
|
407
|
+
*/
|
|
408
|
+
readable: ReadableStream;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Represents an instance used to read unknown type of data.
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* Here is an example of custom {@link Reader} class used to read binary strings:
|
|
416
|
+
* ```
|
|
417
|
+
* class BinaryStringReader extends Reader {
|
|
418
|
+
*
|
|
419
|
+
* constructor(binaryString) {
|
|
420
|
+
* super();
|
|
421
|
+
* this.binaryString = binaryString;
|
|
422
|
+
* }
|
|
423
|
+
*
|
|
424
|
+
* init() {
|
|
425
|
+
* super.init();
|
|
426
|
+
* this.size = this.binaryString.length;
|
|
427
|
+
* }
|
|
428
|
+
*
|
|
429
|
+
* readUint8Array(offset, length) {
|
|
430
|
+
* const result = new Uint8Array(length);
|
|
431
|
+
* for (let indexCharacter = 0; indexCharacter < length; indexCharacter++) {
|
|
432
|
+
* result[indexCharacter] = this.binaryString.charCodeAt(indexCharacter + offset) & 0xFF;
|
|
433
|
+
* }
|
|
434
|
+
* return result;
|
|
435
|
+
* }
|
|
436
|
+
* }
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
439
|
+
export class Reader<Type> implements Initializable, ReadableReader {
|
|
440
|
+
/**
|
|
441
|
+
* Creates the {@link Reader} instance
|
|
442
|
+
*
|
|
443
|
+
* @param value The data to read.
|
|
444
|
+
*/
|
|
445
|
+
constructor(value: Type);
|
|
446
|
+
/**
|
|
447
|
+
* The `ReadableStream` instance.
|
|
448
|
+
*/
|
|
449
|
+
readable: ReadableStream;
|
|
450
|
+
/**
|
|
451
|
+
* The total size of the data in bytes.
|
|
452
|
+
*/
|
|
453
|
+
size: number;
|
|
454
|
+
/**
|
|
455
|
+
* Initializes the instance asynchronously
|
|
456
|
+
*/
|
|
457
|
+
init?(): Promise<void>;
|
|
458
|
+
/**
|
|
459
|
+
* Reads a chunk of data
|
|
460
|
+
*
|
|
461
|
+
* @param index The byte index of the data to read.
|
|
462
|
+
* @param length The length of the data to read in bytes.
|
|
463
|
+
* @returns A promise resolving to a chunk of data. The data must be trucated to the remaining size if the requested length is larger than the remaining size.
|
|
464
|
+
*/
|
|
465
|
+
readUint8Array(index: number, length: number): Promise<Uint8Array>;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Represents a {@link Reader} instance used to read data provided as a `string`.
|
|
470
|
+
*/
|
|
471
|
+
export class TextReader extends Reader<string> {}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Represents a {@link Reader} instance used to read data provided as a `Blob` instance.
|
|
475
|
+
*/
|
|
476
|
+
export class BlobReader extends Reader<Blob> {}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Represents a {@link Reader} instance used to read data provided as a Data URI `string` encoded in Base64.
|
|
480
|
+
*/
|
|
481
|
+
export class Data64URIReader extends Reader<string> {}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Represents a {@link Reader} instance used to read data provided as a `Uint8Array` instance.
|
|
485
|
+
*/
|
|
486
|
+
export class Uint8ArrayReader extends Reader<Uint8Array> {}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Represents a {@link Reader} instance used to read data provided as an array of {@link ReadableReader} instances (e.g. split zip files).
|
|
490
|
+
*/
|
|
491
|
+
export class SplitDataReader extends Reader<
|
|
492
|
+
Reader<unknown>[] | ReadableReader[] | ReadableStream[]
|
|
493
|
+
> {}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Represents a URL stored into a `string`.
|
|
497
|
+
*/
|
|
498
|
+
type URLString = string;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Represents a {@link Reader} instance used to fetch data from a URL.
|
|
502
|
+
*/
|
|
503
|
+
export class HttpReader extends Reader<URLString> {
|
|
504
|
+
/**
|
|
505
|
+
* Creates the {@link HttpReader} instance
|
|
506
|
+
*
|
|
507
|
+
* @param url The URL of the data.
|
|
508
|
+
* @param options The options.
|
|
509
|
+
*/
|
|
510
|
+
constructor(url: URLString | URL, options?: HttpOptions);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Represents a {@link Reader} instance used to fetch data from servers returning `Accept-Ranges` headers.
|
|
515
|
+
*/
|
|
516
|
+
export class HttpRangeReader extends HttpReader {
|
|
517
|
+
/**
|
|
518
|
+
* Creates the {@link HttpRangeReader} instance. It is particularly useful for reading ZIP files via HTTP.
|
|
519
|
+
* If you just want to add content retrieved via HTTP to a ZIP file, you can simply use
|
|
520
|
+
* `Response#body` {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/body} instead.
|
|
521
|
+
*
|
|
522
|
+
* @param url The URL of the data.
|
|
523
|
+
* @param options The options.
|
|
524
|
+
*/
|
|
525
|
+
constructor(url: URLString | URL, options?: HttpRangeOptions);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Represents the options passed to the constructor of {@link HttpReader}.
|
|
530
|
+
*/
|
|
531
|
+
export interface HttpOptions extends HttpRangeOptions {
|
|
532
|
+
/**
|
|
533
|
+
* `true` to use `Range` headers when fetching data from servers returning `Accept-Ranges` headers.
|
|
534
|
+
*
|
|
535
|
+
* @defaultValue false
|
|
536
|
+
*/
|
|
537
|
+
useRangeHeader?: boolean;
|
|
538
|
+
/**
|
|
539
|
+
* `true` to always use `Range` headers when fetching data.
|
|
540
|
+
*
|
|
541
|
+
* @defaultValue false
|
|
542
|
+
*/
|
|
543
|
+
forceRangeRequests?: boolean;
|
|
544
|
+
/**
|
|
545
|
+
* `true` to prevent using `HEAD` HTTP request in order the get the size of the content.
|
|
546
|
+
* `false` to explicitly use `HEAD`, this is useful in case of CORS where `Access-Control-Expose-Headers: Content-Range` is not returned by the server.
|
|
547
|
+
*
|
|
548
|
+
* @defaultValue false
|
|
549
|
+
*/
|
|
550
|
+
preventHeadRequest?: boolean;
|
|
551
|
+
/**
|
|
552
|
+
* `true` to use `Range: bytes=-22` on the first request and cache the EOCD, make sure beforehand that the server supports a suffix range request.
|
|
553
|
+
*
|
|
554
|
+
* @defaultValue false
|
|
555
|
+
*/
|
|
556
|
+
combineSizeEocd?: boolean;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Represents options passed to the constructor of {@link HttpRangeReader} and {@link HttpReader}.
|
|
561
|
+
*/
|
|
562
|
+
export interface HttpRangeOptions {
|
|
563
|
+
/**
|
|
564
|
+
* `true` to rely `XMLHttpRequest` instead of `fetch` to fetch data.
|
|
565
|
+
*
|
|
566
|
+
* @defaultValue false
|
|
567
|
+
*/
|
|
568
|
+
useXHR?: boolean;
|
|
569
|
+
/**
|
|
570
|
+
* The function used to fetch the data. It takes precedence over {@link HttpRangeOptions#useXHR}
|
|
571
|
+
* when set. The returned object must expose the `status`, `statusText` and `headers` properties,
|
|
572
|
+
* and the `arrayBuffer()` method of the `Response` class.
|
|
573
|
+
*
|
|
574
|
+
* @defaultValue `fetch`
|
|
575
|
+
*/
|
|
576
|
+
fetch?(input: string, init?: RequestInit): Promise<Response>;
|
|
577
|
+
/**
|
|
578
|
+
* The HTTP headers.
|
|
579
|
+
*/
|
|
580
|
+
headers?: Iterable<[string, string]> | Map<string, string>;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Represents an instance used to write data into a `WritableStream` instance.
|
|
585
|
+
*/
|
|
586
|
+
export interface WritableWriter {
|
|
587
|
+
/**
|
|
588
|
+
* The `WritableStream` instance.
|
|
589
|
+
*/
|
|
590
|
+
writable: WritableStream;
|
|
591
|
+
/**
|
|
592
|
+
* The maximum size of split data when creating a {@link ZipWriter} instance or when calling {@link FileEntry#getData} with a generator of {@link WritableWriter} instances.
|
|
593
|
+
*/
|
|
594
|
+
maxSize?: number;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Represents an instance used to write unknown type of data.
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* Here is an example of custom {@link Writer} class used to write binary strings:
|
|
602
|
+
* ```
|
|
603
|
+
* class BinaryStringWriter extends Writer {
|
|
604
|
+
*
|
|
605
|
+
* constructor() {
|
|
606
|
+
* super();
|
|
607
|
+
* this.binaryString = "";
|
|
608
|
+
* }
|
|
609
|
+
*
|
|
610
|
+
* writeUint8Array(array) {
|
|
611
|
+
* for (let indexCharacter = 0; indexCharacter < array.length; indexCharacter++) {
|
|
612
|
+
* this.binaryString += String.fromCharCode(array[indexCharacter]);
|
|
613
|
+
* }
|
|
614
|
+
* }
|
|
615
|
+
*
|
|
616
|
+
* getData() {
|
|
617
|
+
* return this.binaryString;
|
|
618
|
+
* }
|
|
619
|
+
* }
|
|
620
|
+
* ```
|
|
621
|
+
*/
|
|
622
|
+
export class Writer<Type> implements Initializable, WritableWriter {
|
|
623
|
+
/**
|
|
624
|
+
* The `WritableStream` instance.
|
|
625
|
+
*/
|
|
626
|
+
writable: WritableStream;
|
|
627
|
+
/**
|
|
628
|
+
* Initializes the instance asynchronously
|
|
629
|
+
*
|
|
630
|
+
* @param size the total size of the written data in bytes.
|
|
631
|
+
*/
|
|
632
|
+
init?(size?: number): Promise<void>;
|
|
633
|
+
/**
|
|
634
|
+
* Appends a chunk of data
|
|
635
|
+
*
|
|
636
|
+
* @param array The chunk data to append.
|
|
637
|
+
*
|
|
638
|
+
* @virtual
|
|
639
|
+
*/
|
|
640
|
+
writeUint8Array(array: Uint8Array): Promise<void>;
|
|
641
|
+
/**
|
|
642
|
+
* Retrieves all the written data
|
|
643
|
+
*
|
|
644
|
+
* @returns A promise resolving to the written data.
|
|
645
|
+
*/
|
|
646
|
+
getData(): Promise<Type>;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Represents a {@link Writer} instance used to retrieve the written data as a `string`.
|
|
651
|
+
*/
|
|
652
|
+
export class TextWriter extends Writer<string> {
|
|
653
|
+
/**
|
|
654
|
+
* Creates the {@link TextWriter} instance
|
|
655
|
+
*
|
|
656
|
+
* @param encoding The encoding of the text.
|
|
657
|
+
*/
|
|
658
|
+
constructor(encoding?: string);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Represents a {@link WritableWriter} instance used to retrieve the written data as a `Blob` instance.
|
|
663
|
+
*/
|
|
664
|
+
export class BlobWriter implements Initializable, WritableWriter {
|
|
665
|
+
/**
|
|
666
|
+
* The `WritableStream` instance.
|
|
667
|
+
*/
|
|
668
|
+
writable: WritableStream;
|
|
669
|
+
/**
|
|
670
|
+
* Initializes the instance asynchronously
|
|
671
|
+
*/
|
|
672
|
+
init(): Promise<void>;
|
|
673
|
+
/**
|
|
674
|
+
* Creates the {@link BlobWriter} instance
|
|
675
|
+
*
|
|
676
|
+
* @param mimeString The MIME type of the content.
|
|
677
|
+
*/
|
|
678
|
+
constructor(mimeString?: string);
|
|
679
|
+
/**
|
|
680
|
+
* Retrieves all the written data
|
|
681
|
+
*
|
|
682
|
+
* @returns A promise resolving to the written data.
|
|
683
|
+
*/
|
|
684
|
+
getData(): Promise<Blob>;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Represents a {@link Writer} instance used to retrieve the written data as a Data URI `string` encoded in Base64.
|
|
689
|
+
*/
|
|
690
|
+
export class Data64URIWriter extends Writer<string> {
|
|
691
|
+
/**
|
|
692
|
+
* Creates the {@link Data64URIWriter} instance
|
|
693
|
+
*
|
|
694
|
+
* @param mimeString The MIME type of the content.
|
|
695
|
+
*/
|
|
696
|
+
constructor(mimeString?: string);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Represents a {@link Writer} instance used to retrieve the written data from a generator of {@link WritableWriter} instances (i.e. split zip files).
|
|
701
|
+
*/
|
|
702
|
+
export class SplitDataWriter implements Initializable, WritableWriter {
|
|
703
|
+
/**
|
|
704
|
+
* The `WritableStream` instance.
|
|
705
|
+
*/
|
|
706
|
+
writable: WritableStream;
|
|
707
|
+
/**
|
|
708
|
+
* The number of the disk being written.
|
|
709
|
+
*/
|
|
710
|
+
diskNumber: number;
|
|
711
|
+
/**
|
|
712
|
+
* The byte offset of the disk being written.
|
|
713
|
+
*/
|
|
714
|
+
diskOffset: number;
|
|
715
|
+
/**
|
|
716
|
+
* The maximum size of each disk in bytes.
|
|
717
|
+
*/
|
|
718
|
+
maxSize: number;
|
|
719
|
+
/**
|
|
720
|
+
* The number of bytes still available on the disk being written.
|
|
721
|
+
*/
|
|
722
|
+
availableSize: number;
|
|
723
|
+
/**
|
|
724
|
+
* Initializes the instance asynchronously
|
|
725
|
+
*/
|
|
726
|
+
init(): Promise<void>;
|
|
727
|
+
/**
|
|
728
|
+
* Creates the {@link SplitDataWriter} instance
|
|
729
|
+
*
|
|
730
|
+
* @param writerGenerator A generator of Writer instances.
|
|
731
|
+
* @param maxSize The maximum size of the data written into {@link Writer} instances (default: 4GB).
|
|
732
|
+
*/
|
|
733
|
+
constructor(
|
|
734
|
+
writerGenerator: AsyncGenerator<
|
|
735
|
+
Writer<unknown> | WritableWriter | WritableStream,
|
|
736
|
+
boolean
|
|
737
|
+
>,
|
|
738
|
+
maxSize?: number
|
|
739
|
+
);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Represents a {@link Writer} instance used to retrieve the written data as a `Uint8Array` instance.
|
|
744
|
+
*/
|
|
745
|
+
export class Uint8ArrayWriter extends Writer<Uint8Array<ArrayBuffer>> {
|
|
746
|
+
/**
|
|
747
|
+
* Creates the {@link Uint8ArrayWriter} instance
|
|
748
|
+
*
|
|
749
|
+
* @param defaultBufferSize The initial size of the internal buffer (default: 256KB).
|
|
750
|
+
*/
|
|
751
|
+
constructor(defaultBufferSize?: number);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Represents an instance used to create an unzipped stream.
|
|
756
|
+
*
|
|
757
|
+
* @example
|
|
758
|
+
* This example will take a zip file, decompress it and then save its files and directories to disk.
|
|
759
|
+
* ```
|
|
760
|
+
* import {resolve} from "https://deno.land/std/path/mod.ts";
|
|
761
|
+
* import {ensureDir, ensureFile} from "https://deno.land/std/fs/mod.ts";
|
|
762
|
+
*
|
|
763
|
+
* for await (const entry of (await fetch(urlToZippedFile)).body.pipeThrough(new ZipReaderStream())) {
|
|
764
|
+
* const fullPath = resolve(destination, entry.filename);
|
|
765
|
+
* if (entry.directory) {
|
|
766
|
+
* await ensureDir(fullPath);
|
|
767
|
+
* continue;
|
|
768
|
+
* }
|
|
769
|
+
*
|
|
770
|
+
* await ensureFile(fullPath);
|
|
771
|
+
* await entry.readable?.pipeTo((await Deno.create(fullPath)).writable);
|
|
772
|
+
* }
|
|
773
|
+
* ```
|
|
774
|
+
*/
|
|
775
|
+
export class ZipReaderStream<T> {
|
|
776
|
+
/**
|
|
777
|
+
* Creates the stream.
|
|
778
|
+
*
|
|
779
|
+
* @param options The options.
|
|
780
|
+
*/
|
|
781
|
+
constructor(options?: ZipReaderConstructorOptions);
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* The readable stream.
|
|
785
|
+
*/
|
|
786
|
+
readable: ReadableStream<
|
|
787
|
+
Omit<Entry, "getData"> & { readable?: ReadableStream<Uint8Array> }
|
|
788
|
+
>;
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* The writable stream.
|
|
792
|
+
*/
|
|
793
|
+
writable: WritableStream<T>;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Represents an instance used to read a zip file.
|
|
798
|
+
*
|
|
799
|
+
* @example
|
|
800
|
+
* Here is an example showing how to read the text data of the first entry from a zip file:
|
|
801
|
+
* ```
|
|
802
|
+
* // create a BlobReader to read with a ZipReader the zip from a Blob object
|
|
803
|
+
* const reader = new zip.ZipReader(new zip.BlobReader(blob));
|
|
804
|
+
*
|
|
805
|
+
* // get all entries from the zip
|
|
806
|
+
* const entries = await reader.getEntries();
|
|
807
|
+
* if (entries.length) {
|
|
808
|
+
*
|
|
809
|
+
* // get first entry content as text by using a TextWriter
|
|
810
|
+
* const text = await entries[0].getData(
|
|
811
|
+
* // writer
|
|
812
|
+
* new zip.TextWriter(),
|
|
813
|
+
* // options
|
|
814
|
+
* {
|
|
815
|
+
* onprogress: (index, max) => {
|
|
816
|
+
* // onprogress callback
|
|
817
|
+
* }
|
|
818
|
+
* }
|
|
819
|
+
* );
|
|
820
|
+
* // text contains the entry data as a String
|
|
821
|
+
* console.log(text);
|
|
822
|
+
* }
|
|
823
|
+
*
|
|
824
|
+
* // close the ZipReader
|
|
825
|
+
* await reader.close();
|
|
826
|
+
* ```
|
|
827
|
+
*/
|
|
828
|
+
export class ZipReader<Type> {
|
|
829
|
+
/**
|
|
830
|
+
* Creates the instance
|
|
831
|
+
*
|
|
832
|
+
* @param reader The {@link Reader} instance used to read data.
|
|
833
|
+
* @param options The options.
|
|
834
|
+
*/
|
|
835
|
+
constructor(
|
|
836
|
+
reader:
|
|
837
|
+
| Reader<Type>
|
|
838
|
+
| ReadableReader
|
|
839
|
+
| ReadableStream
|
|
840
|
+
| Reader<unknown>[]
|
|
841
|
+
| ReadableReader[]
|
|
842
|
+
| ReadableStream[],
|
|
843
|
+
options?: ZipReaderConstructorOptions
|
|
844
|
+
);
|
|
845
|
+
/**
|
|
846
|
+
* The global comment of the zip file.
|
|
847
|
+
*/
|
|
848
|
+
comment: Uint8Array;
|
|
849
|
+
/**
|
|
850
|
+
* The data prepended before the zip file.
|
|
851
|
+
*/
|
|
852
|
+
prependedData?: Uint8Array;
|
|
853
|
+
/**
|
|
854
|
+
* The data appended after the zip file.
|
|
855
|
+
*/
|
|
856
|
+
appendedData?: Uint8Array;
|
|
857
|
+
/**
|
|
858
|
+
* Returns all the entries in the zip file
|
|
859
|
+
*
|
|
860
|
+
* @param options The options.
|
|
861
|
+
* @returns A promise resolving to an `array` of {@link Entry} instances.
|
|
862
|
+
*/
|
|
863
|
+
getEntries(options?: ZipReaderGetEntriesOptions): Promise<Entry[]>;
|
|
864
|
+
/**
|
|
865
|
+
* Returns a generator used to iterate on all the entries in the zip file
|
|
866
|
+
*
|
|
867
|
+
* @param options The options.
|
|
868
|
+
* @returns An asynchronous generator of {@link Entry} instances.
|
|
869
|
+
*/
|
|
870
|
+
getEntriesGenerator(
|
|
871
|
+
options?: ZipReaderGetEntriesOptions
|
|
872
|
+
): AsyncGenerator<Entry, boolean>;
|
|
873
|
+
/**
|
|
874
|
+
* Closes the zip file
|
|
875
|
+
*/
|
|
876
|
+
close(): Promise<void>;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Represents the options passed to the constructor of {@link ZipReader}, and `{@link ZipDirectory}#import*`.
|
|
881
|
+
*/
|
|
882
|
+
export interface ZipReaderConstructorOptions
|
|
883
|
+
extends ZipReaderOptions,
|
|
884
|
+
GetEntriesOptions,
|
|
885
|
+
WorkerConfiguration {
|
|
886
|
+
/**
|
|
887
|
+
* `true` to extract the prepended data into {@link ZipReader#prependedData}.
|
|
888
|
+
*
|
|
889
|
+
* @defaultValue false
|
|
890
|
+
*/
|
|
891
|
+
extractPrependedData?: boolean;
|
|
892
|
+
/**
|
|
893
|
+
* `true` to extract the appended data into {@link ZipReader#appendedData}.
|
|
894
|
+
*
|
|
895
|
+
* @defaultValue false
|
|
896
|
+
*/
|
|
897
|
+
extractAppendedData?: boolean;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* Represents the options passed to {@link ZipReader#getEntries} and {@link ZipReader#getEntriesGenerator}.
|
|
902
|
+
*/
|
|
903
|
+
export interface ZipReaderGetEntriesOptions
|
|
904
|
+
extends GetEntriesOptions,
|
|
905
|
+
EntryOnprogressOptions {}
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Represents options passed to the constructor of {@link ZipReader}, {@link ZipReader#getEntries} and {@link ZipReader#getEntriesGenerator}.
|
|
909
|
+
*/
|
|
910
|
+
export interface GetEntriesOptions {
|
|
911
|
+
/**
|
|
912
|
+
* The encoding of the filename of the entry.
|
|
913
|
+
*/
|
|
914
|
+
filenameEncoding?: string;
|
|
915
|
+
/**
|
|
916
|
+
* The encoding of the comment of the entry.
|
|
917
|
+
*/
|
|
918
|
+
commentEncoding?: string;
|
|
919
|
+
/**
|
|
920
|
+
* The function called for decoding the filename and the comment of the entry.
|
|
921
|
+
*
|
|
922
|
+
* @param value The raw text value.
|
|
923
|
+
* @param encoding The encoding of the text.
|
|
924
|
+
* @returns The decoded text value or `undefined` if the raw text value should be decoded by zip.js.
|
|
925
|
+
*/
|
|
926
|
+
decodeText?(value: Uint8Array, encoding: string): string | undefined;
|
|
927
|
+
/**
|
|
928
|
+
* `true` to throw an {@link ERR_AMBIGUOUS_ARCHIVE} error when the archive could be parsed differently by other
|
|
929
|
+
* tools. This detects data before or after the zip structure (e.g. a self-extracting archive stub or a
|
|
930
|
+
* concatenated archive), central directory records not accounted for by the end of central directory record, an
|
|
931
|
+
* end of central directory record disagreeing with its zip64 counterpart, and duplicate filenames. When reading
|
|
932
|
+
* the content of an entry, it also validates the local file header against the central directory record (see
|
|
933
|
+
* {@link ZipReaderOptions#checkAmbiguity}).
|
|
934
|
+
*
|
|
935
|
+
* @defaultValue false
|
|
936
|
+
*/
|
|
937
|
+
checkAmbiguity?: boolean;
|
|
938
|
+
/**
|
|
939
|
+
* How tolerant the reader should be when the archive can be parsed in more than one way.
|
|
940
|
+
*
|
|
941
|
+
* - `"strict"`: reject anything another tool could interpret differently. The end of central directory
|
|
942
|
+
* record must sit exactly at the end of the file, no data may precede the zip structure, and the local file
|
|
943
|
+
* headers must agree with the central directory records. Equivalent to {@link GetEntriesOptions#checkAmbiguity}
|
|
944
|
+
* set to `true`.
|
|
945
|
+
* - `"balanced"`: select the last end of central directory record whose comment reaches the end of the file
|
|
946
|
+
* and that points to a central directory, ignore stale records left by in-place updates as well as records
|
|
947
|
+
* forged inside a comment, and tolerate a self-extracting stub or up to
|
|
948
|
+
* {@link GetEntriesOptions#maxAppendedDataSize} bytes of appended data. Throw an {@link ERR_AMBIGUOUS_ARCHIVE}
|
|
949
|
+
* error only when two or more records reach the end of the file and each points to a central directory, which
|
|
950
|
+
* cannot be disambiguated. A record that reaches the end of the file but points to no central directory (an
|
|
951
|
+
* empty archive) is only selected when no record points to one.
|
|
952
|
+
* - `"tolerant"`: never reject a parseable archive, except when {@link GetEntriesOptions#maxAppendedDataSize}
|
|
953
|
+
* is set explicitly and exceeded; recover by selecting the last end of central directory record that reaches
|
|
954
|
+
* the end of the file and points to a central directory (or, failing that, the last one that reaches the end
|
|
955
|
+
* of the file).
|
|
956
|
+
*
|
|
957
|
+
* @defaultValue "balanced"
|
|
958
|
+
*/
|
|
959
|
+
strictness?: "strict" | "balanced" | "tolerant";
|
|
960
|
+
/**
|
|
961
|
+
* The maximum number of bytes tolerated after the zip structure before the archive is rejected. Defaults to
|
|
962
|
+
* `0` when {@link GetEntriesOptions#strictness} is `"strict"`, `65535` when it is `"balanced"`, and `Infinity`
|
|
963
|
+
* when it is `"tolerant"`.
|
|
964
|
+
*
|
|
965
|
+
* An explicit value takes precedence over the strictness default at every level, so it can loosen `"strict"`
|
|
966
|
+
* or reintroduce a rejection under `"tolerant"`. It also bounds how far back the end of central directory
|
|
967
|
+
* record is searched for, so a value smaller than the amount of data actually appended surfaces an
|
|
968
|
+
* {@link ERR_EOCDR_NOT_FOUND} error when the record lies beyond the searched region and an
|
|
969
|
+
* {@link ERR_AMBIGUOUS_ARCHIVE} error otherwise.
|
|
970
|
+
*/
|
|
971
|
+
maxAppendedDataSize?: number;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* Represents options passed to the constructor of {@link ZipReader} and {@link FileEntry#getData}.
|
|
976
|
+
*/
|
|
977
|
+
export interface ZipReaderOptions {
|
|
978
|
+
/**
|
|
979
|
+
* How tolerant the reader should be when the local file header of an entry disagrees with its central
|
|
980
|
+
* directory record. `"strict"` throws an {@link ERR_AMBIGUOUS_ARCHIVE} error (equivalent to
|
|
981
|
+
* {@link ZipReaderOptions#checkAmbiguity} set to `true`); `"balanced"` and `"tolerant"` trust the central
|
|
982
|
+
* directory record.
|
|
983
|
+
*
|
|
984
|
+
* @defaultValue "balanced"
|
|
985
|
+
*/
|
|
986
|
+
strictness?: "strict" | "balanced" | "tolerant";
|
|
987
|
+
/**
|
|
988
|
+
* `true` to throw an {@link ERR_AMBIGUOUS_ARCHIVE} error when calling {@link FileEntry#getData} if the local
|
|
989
|
+
* file header of the entry disagrees with its central directory record in a way that could make other tools
|
|
990
|
+
* (e.g. streaming readers based on local file headers) interpret the entry differently. This detects mismatched
|
|
991
|
+
* filenames, general purpose bit flags (encryption, data descriptor and language encoding flags), compression
|
|
992
|
+
* methods, signatures and sizes. The extra fields are not compared because the zip specification allows them
|
|
993
|
+
* to differ.
|
|
994
|
+
*
|
|
995
|
+
* @defaultValue false
|
|
996
|
+
*/
|
|
997
|
+
checkAmbiguity?: boolean;
|
|
998
|
+
/**
|
|
999
|
+
* `true` to check only if the password is valid.
|
|
1000
|
+
*
|
|
1001
|
+
* @defaultValue false
|
|
1002
|
+
*/
|
|
1003
|
+
checkPasswordOnly?: boolean;
|
|
1004
|
+
/**
|
|
1005
|
+
* `true` to check the signature of the entry.
|
|
1006
|
+
*
|
|
1007
|
+
* @defaultValue false
|
|
1008
|
+
*/
|
|
1009
|
+
checkSignature?: boolean;
|
|
1010
|
+
/**
|
|
1011
|
+
* `true` to throw an {@link ERR_OVERLAPPING_ENTRY} error when calling {@link FileEntry#getData} if the entry
|
|
1012
|
+
* overlaps with another entry on which {@link FileEntry#getData} has already been called (with the option
|
|
1013
|
+
* `checkOverlappingEntry` or `checkOverlappingEntryOnly` set to `true`).
|
|
1014
|
+
*
|
|
1015
|
+
* @defaultValue false
|
|
1016
|
+
*/
|
|
1017
|
+
checkOverlappingEntry?: boolean;
|
|
1018
|
+
/**
|
|
1019
|
+
* `true` to throw an {@link ERR_OVERLAPPING_ENTRY} error when calling {@link FileEntry#getData} if the entry
|
|
1020
|
+
* overlaps with another entry on which {@link FileEntry#getData} has already been called (with the option
|
|
1021
|
+
* `checkOverlappingEntry` or `checkOverlappingEntryOnly` set to `true`) without trying to read the content of the
|
|
1022
|
+
* entry.
|
|
1023
|
+
*
|
|
1024
|
+
* @defaultValue false
|
|
1025
|
+
*/
|
|
1026
|
+
checkOverlappingEntryOnly?: boolean;
|
|
1027
|
+
/**
|
|
1028
|
+
* The password used to decrypt the content of the entry.
|
|
1029
|
+
*/
|
|
1030
|
+
password?: string;
|
|
1031
|
+
/**
|
|
1032
|
+
* `true` to read the data as-is without decompressing it and without decrypting it.
|
|
1033
|
+
*/
|
|
1034
|
+
passThrough?: boolean;
|
|
1035
|
+
/**
|
|
1036
|
+
* The password used to encrypt the content of the entry (raw).
|
|
1037
|
+
*/
|
|
1038
|
+
rawPassword?: Uint8Array;
|
|
1039
|
+
/**
|
|
1040
|
+
* The `AbortSignal` instance used to cancel the decompression.
|
|
1041
|
+
*/
|
|
1042
|
+
signal?: AbortSignal;
|
|
1043
|
+
/**
|
|
1044
|
+
* `true` to prevent closing of {@link Writer#writable} when calling {@link FileEntry#getData}.
|
|
1045
|
+
*
|
|
1046
|
+
* @defaultValue false
|
|
1047
|
+
*/
|
|
1048
|
+
preventClose?: boolean;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* Represents the parsed general purpose bit flag of an entry.
|
|
1053
|
+
*/
|
|
1054
|
+
export interface EntryBitFlag {
|
|
1055
|
+
/**
|
|
1056
|
+
* The compression option bits.
|
|
1057
|
+
*/
|
|
1058
|
+
level: number;
|
|
1059
|
+
/**
|
|
1060
|
+
* `true` if the entry data is followed by a data descriptor.
|
|
1061
|
+
*/
|
|
1062
|
+
dataDescriptor: boolean;
|
|
1063
|
+
/**
|
|
1064
|
+
* `true` if the filename and the comment are encoded in UTF-8 (EFS).
|
|
1065
|
+
*/
|
|
1066
|
+
languageEncodingFlag: boolean;
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Represents an extra field record of an entry.
|
|
1070
|
+
*/
|
|
1071
|
+
export interface EntryExtraField {
|
|
1072
|
+
/**
|
|
1073
|
+
* The type (header id) of the extra field.
|
|
1074
|
+
*/
|
|
1075
|
+
type: number;
|
|
1076
|
+
/**
|
|
1077
|
+
* The data of the extra field.
|
|
1078
|
+
*/
|
|
1079
|
+
data: Uint8Array;
|
|
1080
|
+
}
|
|
1081
|
+
/**
|
|
1082
|
+
* Represents the AES extra field record of an entry.
|
|
1083
|
+
*/
|
|
1084
|
+
export interface EntryExtraFieldAES extends EntryExtraField {
|
|
1085
|
+
/**
|
|
1086
|
+
* The encryption strength (1, 2 or 3).
|
|
1087
|
+
*/
|
|
1088
|
+
strength?: number;
|
|
1089
|
+
/**
|
|
1090
|
+
* The compression method stored in the AES extra field.
|
|
1091
|
+
*/
|
|
1092
|
+
originalCompressionMethod?: number;
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Represents a Unicode path or comment extra field record of an entry.
|
|
1096
|
+
*/
|
|
1097
|
+
export interface EntryExtraFieldUnicode extends EntryExtraField {
|
|
1098
|
+
/**
|
|
1099
|
+
* `true` if the extra field is consistent with the entry metadata.
|
|
1100
|
+
*/
|
|
1101
|
+
valid?: boolean;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Represents the local file header fields of an entry, read when getting the entry data.
|
|
1105
|
+
*/
|
|
1106
|
+
export interface LocalDirectory {
|
|
1107
|
+
/**
|
|
1108
|
+
* The "Version" field.
|
|
1109
|
+
*/
|
|
1110
|
+
version: number;
|
|
1111
|
+
/**
|
|
1112
|
+
* `true` if the entry is encrypted.
|
|
1113
|
+
*/
|
|
1114
|
+
encrypted: boolean;
|
|
1115
|
+
/**
|
|
1116
|
+
* The general purpose bit flag (raw).
|
|
1117
|
+
*/
|
|
1118
|
+
rawBitFlag: number;
|
|
1119
|
+
/**
|
|
1120
|
+
* The general purpose bit flag.
|
|
1121
|
+
*/
|
|
1122
|
+
bitFlag: EntryBitFlag;
|
|
1123
|
+
/**
|
|
1124
|
+
* The last modification date (raw).
|
|
1125
|
+
*/
|
|
1126
|
+
rawLastModDate: number;
|
|
1127
|
+
/**
|
|
1128
|
+
* The last modification date.
|
|
1129
|
+
*/
|
|
1130
|
+
lastModDate: Date;
|
|
1131
|
+
/**
|
|
1132
|
+
* The length of the filename in bytes.
|
|
1133
|
+
*/
|
|
1134
|
+
filenameLength: number;
|
|
1135
|
+
/**
|
|
1136
|
+
* The length of the extra field in bytes.
|
|
1137
|
+
*/
|
|
1138
|
+
extraFieldLength: number;
|
|
1139
|
+
/**
|
|
1140
|
+
* The extra field (raw).
|
|
1141
|
+
*/
|
|
1142
|
+
rawExtraField: Uint8Array;
|
|
1143
|
+
/**
|
|
1144
|
+
* The extra field.
|
|
1145
|
+
*/
|
|
1146
|
+
extraField?: Map<number, EntryExtraField>;
|
|
1147
|
+
/**
|
|
1148
|
+
* The signature (CRC32 checksum) of the content.
|
|
1149
|
+
*/
|
|
1150
|
+
signature?: number;
|
|
1151
|
+
/**
|
|
1152
|
+
* The compressed size of the content.
|
|
1153
|
+
*/
|
|
1154
|
+
compressedSize?: number;
|
|
1155
|
+
/**
|
|
1156
|
+
* The uncompressed size of the content.
|
|
1157
|
+
*/
|
|
1158
|
+
uncompressedSize?: number;
|
|
1159
|
+
/**
|
|
1160
|
+
* The compression method.
|
|
1161
|
+
*/
|
|
1162
|
+
compressionMethod?: number;
|
|
1163
|
+
/**
|
|
1164
|
+
* The Zip64 extra field.
|
|
1165
|
+
*/
|
|
1166
|
+
extraFieldZip64?: EntryExtraField;
|
|
1167
|
+
/**
|
|
1168
|
+
* The AES extra field.
|
|
1169
|
+
*/
|
|
1170
|
+
extraFieldAES?: EntryExtraFieldAES;
|
|
1171
|
+
/**
|
|
1172
|
+
* The NTFS extra field.
|
|
1173
|
+
*/
|
|
1174
|
+
extraFieldNTFS?: EntryExtraField;
|
|
1175
|
+
/**
|
|
1176
|
+
* The Unix extra field.
|
|
1177
|
+
*/
|
|
1178
|
+
extraFieldUnix?: EntryExtraField;
|
|
1179
|
+
/**
|
|
1180
|
+
* The Info-ZIP Unix extra field.
|
|
1181
|
+
*/
|
|
1182
|
+
extraFieldInfoZip?: EntryExtraField;
|
|
1183
|
+
/**
|
|
1184
|
+
* The extended timestamp extra field.
|
|
1185
|
+
*/
|
|
1186
|
+
extraFieldExtendedTimestamp?: EntryExtraField;
|
|
1187
|
+
/**
|
|
1188
|
+
* The Unicode path extra field.
|
|
1189
|
+
*/
|
|
1190
|
+
extraFieldUnicodePath?: EntryExtraFieldUnicode;
|
|
1191
|
+
/**
|
|
1192
|
+
* The Unicode comment extra field.
|
|
1193
|
+
*/
|
|
1194
|
+
extraFieldUnicodeComment?: EntryExtraFieldUnicode;
|
|
1195
|
+
/**
|
|
1196
|
+
* The USDZ extra field.
|
|
1197
|
+
*/
|
|
1198
|
+
extraFieldUSDZ?: EntryExtraField;
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Represents an error raised while processing an entry, decorated with entry context.
|
|
1202
|
+
*/
|
|
1203
|
+
export interface EntryError extends Error {
|
|
1204
|
+
/**
|
|
1205
|
+
* `true` if the zip file is corrupted because the entry data could not be written entirely.
|
|
1206
|
+
*/
|
|
1207
|
+
corruptedEntry?: boolean;
|
|
1208
|
+
/**
|
|
1209
|
+
* The id of the related {@link ZipEntry} (filesystem API).
|
|
1210
|
+
*/
|
|
1211
|
+
entryId?: number;
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Represents the metadata of an entry in a zip file (Core API).
|
|
1215
|
+
*/
|
|
1216
|
+
export interface EntryMetaData {
|
|
1217
|
+
/**
|
|
1218
|
+
* The byte offset of the entry.
|
|
1219
|
+
*/
|
|
1220
|
+
offset: number;
|
|
1221
|
+
/**
|
|
1222
|
+
* The filename of the entry.
|
|
1223
|
+
*/
|
|
1224
|
+
filename: string;
|
|
1225
|
+
/**
|
|
1226
|
+
* The filename of the entry (raw).
|
|
1227
|
+
*/
|
|
1228
|
+
rawFilename: Uint8Array;
|
|
1229
|
+
/**
|
|
1230
|
+
* `true` if the filename is encoded in UTF-8.
|
|
1231
|
+
*/
|
|
1232
|
+
filenameUTF8: boolean;
|
|
1233
|
+
/**
|
|
1234
|
+
* `true` if the entry is an executable file
|
|
1235
|
+
*/
|
|
1236
|
+
executable: boolean;
|
|
1237
|
+
/**
|
|
1238
|
+
* `true` if the content of the entry is encrypted.
|
|
1239
|
+
*/
|
|
1240
|
+
encrypted: boolean;
|
|
1241
|
+
/**
|
|
1242
|
+
* `true` if the content of the entry is encrypted with the ZipCrypto algorithm.
|
|
1243
|
+
*/
|
|
1244
|
+
zipCrypto: boolean;
|
|
1245
|
+
/**
|
|
1246
|
+
* The size of the compressed data in bytes.
|
|
1247
|
+
*/
|
|
1248
|
+
compressedSize: number;
|
|
1249
|
+
/**
|
|
1250
|
+
* The size of the decompressed data in bytes.
|
|
1251
|
+
*/
|
|
1252
|
+
uncompressedSize: number;
|
|
1253
|
+
/**
|
|
1254
|
+
* The last modification date.
|
|
1255
|
+
*/
|
|
1256
|
+
lastModDate: Date;
|
|
1257
|
+
/**
|
|
1258
|
+
* The last access date.
|
|
1259
|
+
*/
|
|
1260
|
+
lastAccessDate?: Date;
|
|
1261
|
+
/**
|
|
1262
|
+
* The creation date.
|
|
1263
|
+
*/
|
|
1264
|
+
creationDate?: Date;
|
|
1265
|
+
/**
|
|
1266
|
+
* The last modification date (raw).
|
|
1267
|
+
*/
|
|
1268
|
+
rawLastModDate: number | bigint;
|
|
1269
|
+
/**
|
|
1270
|
+
* The last access date (raw).
|
|
1271
|
+
*/
|
|
1272
|
+
rawLastAccessDate?: number | bigint;
|
|
1273
|
+
/**
|
|
1274
|
+
* The creation date (raw).
|
|
1275
|
+
*/
|
|
1276
|
+
rawCreationDate?: number | bigint;
|
|
1277
|
+
/**
|
|
1278
|
+
* The comment of the entry.
|
|
1279
|
+
*/
|
|
1280
|
+
comment: string;
|
|
1281
|
+
/**
|
|
1282
|
+
* The comment of the entry (raw).
|
|
1283
|
+
*/
|
|
1284
|
+
rawComment: Uint8Array;
|
|
1285
|
+
/**
|
|
1286
|
+
* `true` if the comment is encoded in UTF-8.
|
|
1287
|
+
*/
|
|
1288
|
+
commentUTF8: boolean;
|
|
1289
|
+
/**
|
|
1290
|
+
* The signature (CRC32 checksum) of the content.
|
|
1291
|
+
*/
|
|
1292
|
+
signature: number;
|
|
1293
|
+
/**
|
|
1294
|
+
* The extra field.
|
|
1295
|
+
*/
|
|
1296
|
+
extraField?: Map<number, { type: number; data: Uint8Array }>;
|
|
1297
|
+
/**
|
|
1298
|
+
* The extra field (raw).
|
|
1299
|
+
*/
|
|
1300
|
+
rawExtraField: Uint8Array;
|
|
1301
|
+
/**
|
|
1302
|
+
* `true` if the entry is using Zip64.
|
|
1303
|
+
*/
|
|
1304
|
+
zip64: boolean;
|
|
1305
|
+
/**
|
|
1306
|
+
* The "Version" field.
|
|
1307
|
+
*/
|
|
1308
|
+
version: number;
|
|
1309
|
+
/**
|
|
1310
|
+
* The "Version made by" field.
|
|
1311
|
+
*/
|
|
1312
|
+
versionMadeBy: number;
|
|
1313
|
+
/**
|
|
1314
|
+
* `true` if `internalFileAttributes` and `externalFileAttributes` are compatible with MS-DOS format.
|
|
1315
|
+
*/
|
|
1316
|
+
msDosCompatible: boolean;
|
|
1317
|
+
/**
|
|
1318
|
+
* Note (MS-DOS / Unix attributes):
|
|
1319
|
+
*
|
|
1320
|
+
* - The single source of truth for on-disk metadata is the 32-bit `externalFileAttributes` value stored in
|
|
1321
|
+
* the ZIP headers. The upper 16 bits are commonly used for Unix `st_mode` (type/permissions/special bits)
|
|
1322
|
+
* and the low 8 bits for MS-DOS attribute flags.
|
|
1323
|
+
*
|
|
1324
|
+
* - Writer vs Reader:
|
|
1325
|
+
* - The writer composes `externalFileAttributes` from the provided options (`externalFileAttributes`,
|
|
1326
|
+
* `unixMode`/special flags, `msdosAttributesRaw`/`msdosAttributes`).
|
|
1327
|
+
* - The reader decodes the stored `externalFileAttributes` and exposes convenience fields such as
|
|
1328
|
+
* `msdosAttributesRaw`, `msdosAttributes`, `unixExternalUpper`, and `unixMode`.
|
|
1329
|
+
*
|
|
1330
|
+
* - Practical rule: treat `externalFileAttributes` as authoritative; other fields are conveniences derived
|
|
1331
|
+
* from it. If you need a specific on-disk value, set `externalFileAttributes` explicitly.
|
|
1332
|
+
*/
|
|
1333
|
+
/**
|
|
1334
|
+
* The MS-DOS attributes low byte (raw).
|
|
1335
|
+
* This is the low 8 bits of {@link EntryMetaData#externalFileAttributes} when present.
|
|
1336
|
+
*/
|
|
1337
|
+
msdosAttributesRaw?: number;
|
|
1338
|
+
/**
|
|
1339
|
+
* The MS-DOS attribute flags exposed as booleans.
|
|
1340
|
+
*/
|
|
1341
|
+
msdosAttributes?: {
|
|
1342
|
+
readOnly: boolean;
|
|
1343
|
+
hidden: boolean;
|
|
1344
|
+
system: boolean;
|
|
1345
|
+
directory: boolean;
|
|
1346
|
+
archive: boolean;
|
|
1347
|
+
};
|
|
1348
|
+
/**
|
|
1349
|
+
* Unix owner id when available.
|
|
1350
|
+
*/
|
|
1351
|
+
uid?: number;
|
|
1352
|
+
/**
|
|
1353
|
+
* Unix group id when available.
|
|
1354
|
+
*/
|
|
1355
|
+
gid?: number;
|
|
1356
|
+
/**
|
|
1357
|
+
* Unix mode (st_mode) when available.
|
|
1358
|
+
*/
|
|
1359
|
+
unixMode?: number;
|
|
1360
|
+
/**
|
|
1361
|
+
* `true` if the setuid bit is set on the entry.
|
|
1362
|
+
*/
|
|
1363
|
+
setuid?: boolean;
|
|
1364
|
+
/**
|
|
1365
|
+
* `true` if the setgid bit is set on the entry.
|
|
1366
|
+
*/
|
|
1367
|
+
setgid?: boolean;
|
|
1368
|
+
/**
|
|
1369
|
+
* `true` if the sticky bit is set on the entry.
|
|
1370
|
+
*/
|
|
1371
|
+
sticky?: boolean;
|
|
1372
|
+
/**
|
|
1373
|
+
* The internal file attributes (raw).
|
|
1374
|
+
*/
|
|
1375
|
+
internalFileAttributes: number;
|
|
1376
|
+
/**
|
|
1377
|
+
* The 32-bit `externalFileAttributes` field is the authoritative on-disk metadata for each entry.
|
|
1378
|
+
* - Upper 16 bits: Unix mode/type (e.g., permissions, file type)
|
|
1379
|
+
* - Low 8 bits: MS-DOS file attributes (e.g., directory, read-only)
|
|
1380
|
+
*
|
|
1381
|
+
* When writing, all provided options are merged into this field. When reading, convenience fields are decoded from it.
|
|
1382
|
+
* For most use cases, prefer the high-level options and fields; only advanced users need to manipulate the raw value directly.
|
|
1383
|
+
*/
|
|
1384
|
+
externalFileAttributes: number;
|
|
1385
|
+
/**
|
|
1386
|
+
* The upper 16-bit portion of {@link EntryMetaData#externalFileAttributes} when it represents Unix mode bits.
|
|
1387
|
+
*/
|
|
1388
|
+
unixExternalUpper?: number;
|
|
1389
|
+
/**
|
|
1390
|
+
* The number of the disk where the entry data starts.
|
|
1391
|
+
*/
|
|
1392
|
+
/**
|
|
1393
|
+
* The internal file attribute (raw).
|
|
1394
|
+
* @deprecated Use {@link EntryMetaData#internalFileAttributes} instead.
|
|
1395
|
+
*/
|
|
1396
|
+
internalFileAttribute: number;
|
|
1397
|
+
/**
|
|
1398
|
+
* The external file attribute (raw).
|
|
1399
|
+
* @deprecated Use {@link EntryMetaData#externalFileAttributes} instead.
|
|
1400
|
+
*/
|
|
1401
|
+
externalFileAttribute: number;
|
|
1402
|
+
/**
|
|
1403
|
+
* The number of the disk where the entry data starts.
|
|
1404
|
+
*/
|
|
1405
|
+
diskNumberStart: number;
|
|
1406
|
+
/**
|
|
1407
|
+
* The compression method.
|
|
1408
|
+
*/
|
|
1409
|
+
compressionMethod: number;
|
|
1410
|
+
/**
|
|
1411
|
+
* The general purpose bit flag (raw).
|
|
1412
|
+
*/
|
|
1413
|
+
rawBitFlag?: number;
|
|
1414
|
+
/**
|
|
1415
|
+
* The general purpose bit flag.
|
|
1416
|
+
*/
|
|
1417
|
+
bitFlag?: EntryBitFlag;
|
|
1418
|
+
/**
|
|
1419
|
+
* The length of the filename in bytes.
|
|
1420
|
+
*/
|
|
1421
|
+
filenameLength?: number;
|
|
1422
|
+
/**
|
|
1423
|
+
* The length of the extra field in bytes.
|
|
1424
|
+
*/
|
|
1425
|
+
extraFieldLength?: number;
|
|
1426
|
+
/**
|
|
1427
|
+
* The Zip64 extra field.
|
|
1428
|
+
*/
|
|
1429
|
+
extraFieldZip64?: EntryExtraField;
|
|
1430
|
+
/**
|
|
1431
|
+
* The AES extra field.
|
|
1432
|
+
*/
|
|
1433
|
+
extraFieldAES?: EntryExtraFieldAES;
|
|
1434
|
+
/**
|
|
1435
|
+
* The NTFS extra field.
|
|
1436
|
+
*/
|
|
1437
|
+
extraFieldNTFS?: EntryExtraField;
|
|
1438
|
+
/**
|
|
1439
|
+
* The Unix extra field.
|
|
1440
|
+
*/
|
|
1441
|
+
extraFieldUnix?: EntryExtraField;
|
|
1442
|
+
/**
|
|
1443
|
+
* The Info-ZIP Unix extra field.
|
|
1444
|
+
*/
|
|
1445
|
+
extraFieldInfoZip?: EntryExtraField;
|
|
1446
|
+
/**
|
|
1447
|
+
* The extended timestamp extra field.
|
|
1448
|
+
*/
|
|
1449
|
+
extraFieldExtendedTimestamp?: EntryExtraField;
|
|
1450
|
+
/**
|
|
1451
|
+
* The Unicode path extra field.
|
|
1452
|
+
*/
|
|
1453
|
+
extraFieldUnicodePath?: EntryExtraFieldUnicode;
|
|
1454
|
+
/**
|
|
1455
|
+
* The Unicode comment extra field.
|
|
1456
|
+
*/
|
|
1457
|
+
extraFieldUnicodeComment?: EntryExtraFieldUnicode;
|
|
1458
|
+
/**
|
|
1459
|
+
* The USDZ extra field.
|
|
1460
|
+
*/
|
|
1461
|
+
extraFieldUSDZ?: EntryExtraField;
|
|
1462
|
+
/**
|
|
1463
|
+
* The local file header fields, set when the entry data has been read.
|
|
1464
|
+
*/
|
|
1465
|
+
localDirectory?: LocalDirectory;
|
|
1466
|
+
}
|
|
1467
|
+
export interface DirectoryEntry extends EntryMetaData {
|
|
1468
|
+
/**
|
|
1469
|
+
* `true` if the entry is a directory.
|
|
1470
|
+
*/
|
|
1471
|
+
directory: true;
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
export interface FileEntry extends EntryMetaData {
|
|
1475
|
+
/**
|
|
1476
|
+
* `false` if the entry is a file.
|
|
1477
|
+
*/
|
|
1478
|
+
directory: false;
|
|
1479
|
+
/**
|
|
1480
|
+
* Returns the content of the entry
|
|
1481
|
+
*
|
|
1482
|
+
* @param writer The {@link Writer} instance used to write the content of the entry.
|
|
1483
|
+
* @param options The options.
|
|
1484
|
+
* @returns A promise resolving to the type to data associated to `writer`.
|
|
1485
|
+
*/
|
|
1486
|
+
getData<Type>(
|
|
1487
|
+
writer:
|
|
1488
|
+
| Writer<Type>
|
|
1489
|
+
| WritableWriter
|
|
1490
|
+
| WritableStream
|
|
1491
|
+
| AsyncGenerator<
|
|
1492
|
+
Writer<unknown> | WritableWriter | WritableStream,
|
|
1493
|
+
boolean
|
|
1494
|
+
>,
|
|
1495
|
+
options?: EntryGetDataCheckPasswordOptions
|
|
1496
|
+
): Promise<Type>;
|
|
1497
|
+
/**
|
|
1498
|
+
* Retrieves the content of the entry as an `ArrayBuffer` instance
|
|
1499
|
+
*
|
|
1500
|
+
* @param options The options.
|
|
1501
|
+
* @returns A promise resolving to an `ArrayBuffer` instance.
|
|
1502
|
+
*/
|
|
1503
|
+
arrayBuffer(options?: EntryGetDataOptions): Promise<ArrayBuffer>;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* Represents an entry with its data and metadata in a zip file (Core API).
|
|
1508
|
+
* This is a union type of {@link DirectoryEntry} and {@link FileEntry}.
|
|
1509
|
+
*
|
|
1510
|
+
* Before using getData, you should check if the entry is a file.
|
|
1511
|
+
*
|
|
1512
|
+
* @example
|
|
1513
|
+
*
|
|
1514
|
+
* ```ts
|
|
1515
|
+
* for await (const entry of reader.getEntriesGenerator()) {
|
|
1516
|
+
* if (entry.directory) continue;
|
|
1517
|
+
*
|
|
1518
|
+
* // entry is a FileEntry
|
|
1519
|
+
* const plainTextData = await entry.getData(new TextWriter());
|
|
1520
|
+
*
|
|
1521
|
+
* // Do something with the plainTextData
|
|
1522
|
+
* }
|
|
1523
|
+
* ```
|
|
1524
|
+
*/
|
|
1525
|
+
export type Entry = DirectoryEntry | FileEntry;
|
|
1526
|
+
|
|
1527
|
+
/**
|
|
1528
|
+
* Represents the options passed to {@link FileEntry#getData} and `{@link ZipFileEntry}.get*`.
|
|
1529
|
+
*/
|
|
1530
|
+
export interface EntryGetDataOptions
|
|
1531
|
+
extends EntryDataOnprogressOptions,
|
|
1532
|
+
ZipReaderOptions,
|
|
1533
|
+
WorkerConfiguration {}
|
|
1534
|
+
|
|
1535
|
+
/**
|
|
1536
|
+
* Represents the options passed to {@link FileEntry#getData} and `{@link ZipFileEntry}.get*`.
|
|
1537
|
+
*/
|
|
1538
|
+
export interface EntryGetDataCheckPasswordOptions extends EntryGetDataOptions {}
|
|
1539
|
+
|
|
1540
|
+
/**
|
|
1541
|
+
* Represents an instance used to create a zipped stream.
|
|
1542
|
+
*
|
|
1543
|
+
* @example
|
|
1544
|
+
* This example creates a zipped file called numbers.txt.zip containing the numbers 0 - 1000 each on their own line.
|
|
1545
|
+
* ```
|
|
1546
|
+
* const readable = ReadableStream.from((function* () {
|
|
1547
|
+
* for (let i = 0; i < 1000; ++i)
|
|
1548
|
+
* yield i + '\n'
|
|
1549
|
+
* })())
|
|
1550
|
+
*
|
|
1551
|
+
* readable
|
|
1552
|
+
* .pipeThrough(new ZipWriterStream().transform('numbers.txt'))
|
|
1553
|
+
* .pipeTo((await Deno.create('numbers.txt.zip')).writable)
|
|
1554
|
+
* ```
|
|
1555
|
+
*
|
|
1556
|
+
* @example
|
|
1557
|
+
* This example creates a zipped file called Archive.zip containing two files called numbers.txt and letters.txt
|
|
1558
|
+
* ```
|
|
1559
|
+
* const readable1 = ReadableStream.from((function* () {
|
|
1560
|
+
* for (let i = 0; i < 1000; ++i)
|
|
1561
|
+
* yield i + '\n'
|
|
1562
|
+
* })())
|
|
1563
|
+
* const readable2 = ReadableStream.from((function* () {
|
|
1564
|
+
* const letters = 'abcdefghijklmnopqrstuvwxyz'.split('')
|
|
1565
|
+
* while (letters.length)
|
|
1566
|
+
* yield letters.shift() + '\n'
|
|
1567
|
+
* })())
|
|
1568
|
+
*
|
|
1569
|
+
* const zipper = new ZipWriterStream()
|
|
1570
|
+
* zipper.readable.pipeTo((await Deno.create('Archive.zip')).writable)
|
|
1571
|
+
* readable1.pipeTo(zipper.writable('numbers.txt'))
|
|
1572
|
+
* readable2.pipeTo(zipper.writable('letters.txt'))
|
|
1573
|
+
* zipper.close()
|
|
1574
|
+
* ```
|
|
1575
|
+
*/
|
|
1576
|
+
export class ZipWriterStream {
|
|
1577
|
+
/**
|
|
1578
|
+
* Creates the stream.
|
|
1579
|
+
*
|
|
1580
|
+
* @param options The options.
|
|
1581
|
+
*/
|
|
1582
|
+
constructor(options?: ZipWriterConstructorOptions);
|
|
1583
|
+
|
|
1584
|
+
/**
|
|
1585
|
+
* The readable stream.
|
|
1586
|
+
*/
|
|
1587
|
+
readable: ReadableStream<Uint8Array>;
|
|
1588
|
+
|
|
1589
|
+
/**
|
|
1590
|
+
* The ZipWriter property.
|
|
1591
|
+
*/
|
|
1592
|
+
zipWriter: ZipWriter<unknown>;
|
|
1593
|
+
|
|
1594
|
+
/**
|
|
1595
|
+
* Returns an object containing a readable and writable property for the .pipeThrough method
|
|
1596
|
+
*
|
|
1597
|
+
* @param path The name of the stream when unzipped. Paths must use forward slashes ("/") as
|
|
1598
|
+
* separator (see {@link ZipWriter#add}).
|
|
1599
|
+
* @returns An object containing readable and writable properties
|
|
1600
|
+
*/
|
|
1601
|
+
transform<T>(path: string): {
|
|
1602
|
+
readable: ReadableStream<T>;
|
|
1603
|
+
writable: WritableStream<T>;
|
|
1604
|
+
};
|
|
1605
|
+
|
|
1606
|
+
/**
|
|
1607
|
+
* Returns a WritableStream for the .pipeTo method
|
|
1608
|
+
*
|
|
1609
|
+
* @param path The directory path of where the stream should exist in the zipped stream. Paths
|
|
1610
|
+
* must use forward slashes ("/") as separator (see {@link ZipWriter#add}).
|
|
1611
|
+
* @returns A WritableStream.
|
|
1612
|
+
*/
|
|
1613
|
+
writable<T>(path: string): WritableStream<T>;
|
|
1614
|
+
|
|
1615
|
+
/**
|
|
1616
|
+
* Writes the entries directory, writes the global comment, and returns the content of the zipped file.
|
|
1617
|
+
*
|
|
1618
|
+
* @param comment The global comment of the zip file.
|
|
1619
|
+
* @param options The options.
|
|
1620
|
+
* @returns The content of the zip file.
|
|
1621
|
+
*/
|
|
1622
|
+
close(
|
|
1623
|
+
comment?: Uint8Array,
|
|
1624
|
+
options?: ZipWriterCloseOptions
|
|
1625
|
+
): Promise<unknown>;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
/**
|
|
1629
|
+
* Represents an instance used to create a zip file.
|
|
1630
|
+
*
|
|
1631
|
+
* @example
|
|
1632
|
+
* Here is an example showing how to create a zip file containing a compressed text file:
|
|
1633
|
+
* ```
|
|
1634
|
+
* // use a BlobWriter to store with a ZipWriter the zip into a Blob object
|
|
1635
|
+
* const blobWriter = new zip.BlobWriter("application/zip");
|
|
1636
|
+
* const writer = new zip.ZipWriter(blobWriter);
|
|
1637
|
+
*
|
|
1638
|
+
* // use a TextReader to read the String to add
|
|
1639
|
+
* await writer.add("filename.txt", new zip.TextReader("test!"));
|
|
1640
|
+
*
|
|
1641
|
+
* // close the ZipReader
|
|
1642
|
+
* await writer.close();
|
|
1643
|
+
*
|
|
1644
|
+
* // get the zip file as a Blob
|
|
1645
|
+
* const blob = await blobWriter.getData();
|
|
1646
|
+
* ```
|
|
1647
|
+
*/
|
|
1648
|
+
export class ZipWriter<Type> {
|
|
1649
|
+
/**
|
|
1650
|
+
* Creates the {@link ZipWriter} instance
|
|
1651
|
+
*
|
|
1652
|
+
* @param writer The {@link Writer} instance where the zip content will be written.
|
|
1653
|
+
* @param options The options.
|
|
1654
|
+
*/
|
|
1655
|
+
constructor(
|
|
1656
|
+
writer:
|
|
1657
|
+
| Writer<Type>
|
|
1658
|
+
| WritableWriter
|
|
1659
|
+
| WritableStream
|
|
1660
|
+
| AsyncGenerator<
|
|
1661
|
+
Writer<unknown> | WritableWriter | WritableStream,
|
|
1662
|
+
boolean
|
|
1663
|
+
>,
|
|
1664
|
+
options?: ZipWriterConstructorOptions
|
|
1665
|
+
);
|
|
1666
|
+
/**
|
|
1667
|
+
* `true` if the zip contains at least one entry that has been partially written.
|
|
1668
|
+
*/
|
|
1669
|
+
readonly hasCorruptedEntries?: boolean;
|
|
1670
|
+
|
|
1671
|
+
/**
|
|
1672
|
+
* Adds an existing zip file at the beginning of the current zip. This method
|
|
1673
|
+
* cannot be called after the first call to {@link ZipWriter#add}.
|
|
1674
|
+
*
|
|
1675
|
+
* @param reader The {@link Reader} instance used to read the content of the zip file.
|
|
1676
|
+
* @returns A promise resolving when the zip file has been added.
|
|
1677
|
+
*/
|
|
1678
|
+
prependZip<ReaderType>(
|
|
1679
|
+
reader:
|
|
1680
|
+
| Reader<ReaderType>
|
|
1681
|
+
| ReadableReader
|
|
1682
|
+
| ReadableStream
|
|
1683
|
+
| Reader<unknown>[]
|
|
1684
|
+
| ReadableReader[]
|
|
1685
|
+
| ReadableStream[]
|
|
1686
|
+
): Promise<void>;
|
|
1687
|
+
|
|
1688
|
+
/**
|
|
1689
|
+
* Adds an entry into the zip file
|
|
1690
|
+
*
|
|
1691
|
+
* @param filename The filename of the entry. Paths must use forward slashes ("/") as separator,
|
|
1692
|
+
* as required by section 4.4.17.1 of the zip specification. The value is stored as-is; in
|
|
1693
|
+
* particular, Windows path separators ("\\") are not converted and become part of the filename,
|
|
1694
|
+
* which is interpreted inconsistently by zip tools.
|
|
1695
|
+
* @param reader The {@link Reader} instance used to read the content of the entry.
|
|
1696
|
+
* @param options The options.
|
|
1697
|
+
* @returns A promise resolving to an {@link EntryMetaData} instance.
|
|
1698
|
+
*/
|
|
1699
|
+
add<ReaderType>(
|
|
1700
|
+
filename: string,
|
|
1701
|
+
reader?:
|
|
1702
|
+
| Reader<ReaderType>
|
|
1703
|
+
| ReadableReader
|
|
1704
|
+
| ReadableStream
|
|
1705
|
+
| Reader<unknown>[]
|
|
1706
|
+
| ReadableReader[]
|
|
1707
|
+
| ReadableStream[],
|
|
1708
|
+
options?: ZipWriterAddDataOptions
|
|
1709
|
+
): Promise<EntryMetaData>;
|
|
1710
|
+
|
|
1711
|
+
/**
|
|
1712
|
+
* Removes an entry from the central directory that will be written for the zip file. The entry
|
|
1713
|
+
* data itself cannot be removed because it has already been streamed to the output.
|
|
1714
|
+
*
|
|
1715
|
+
* @param entry The entry to remove. This can be an {@link Entry} instance or the filename of the entry.
|
|
1716
|
+
* @returns `true` if the entry has been removed, `false` otherwise.
|
|
1717
|
+
*/
|
|
1718
|
+
remove(entry: Entry | string): boolean;
|
|
1719
|
+
|
|
1720
|
+
/**
|
|
1721
|
+
* Writes the entries directory, writes the global comment, and returns the content of the zip file
|
|
1722
|
+
*
|
|
1723
|
+
* @param comment The global comment of the zip file.
|
|
1724
|
+
* @param options The options.
|
|
1725
|
+
* @returns The content of the zip file.
|
|
1726
|
+
*/
|
|
1727
|
+
close(comment?: Uint8Array, options?: ZipWriterCloseOptions): Promise<Type>;
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
/**
|
|
1731
|
+
* Represents the options passed to {@link ZipWriter#add}.
|
|
1732
|
+
*/
|
|
1733
|
+
export interface ZipWriterAddDataOptions
|
|
1734
|
+
extends ZipWriterConstructorOptions,
|
|
1735
|
+
EntryDataOnprogressOptions,
|
|
1736
|
+
WorkerConfiguration {
|
|
1737
|
+
/**
|
|
1738
|
+
* `true` if the entry is a directory.
|
|
1739
|
+
*
|
|
1740
|
+
* @defaultValue false
|
|
1741
|
+
*/
|
|
1742
|
+
directory?: boolean;
|
|
1743
|
+
/**
|
|
1744
|
+
* `true` if the entry is an executable file.
|
|
1745
|
+
*
|
|
1746
|
+
* @defaultValue false
|
|
1747
|
+
*/
|
|
1748
|
+
executable?: boolean;
|
|
1749
|
+
/**
|
|
1750
|
+
* The comment of the entry.
|
|
1751
|
+
*/
|
|
1752
|
+
comment?: string;
|
|
1753
|
+
/**
|
|
1754
|
+
* The extra field of the entry.
|
|
1755
|
+
*/
|
|
1756
|
+
extraField?: Map<number, Uint8Array>;
|
|
1757
|
+
/**
|
|
1758
|
+
* The uncompressed size of the entry. This option is ignored if the {@link ZipWriterConstructorOptions#passThrough} option is not set to `true`.
|
|
1759
|
+
*/
|
|
1760
|
+
uncompressedSize?: number;
|
|
1761
|
+
/**
|
|
1762
|
+
* The signature (CRC32 checksum) of the content. This option is ignored if the {@link ZipWriterConstructorOptions#passThrough} option is not set to `true`.
|
|
1763
|
+
*/
|
|
1764
|
+
signature?: number;
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
/**
|
|
1768
|
+
* Represents the options passed to {@link ZipWriter#close}.
|
|
1769
|
+
*/
|
|
1770
|
+
export interface ZipWriterCloseOptions extends EntryOnprogressOptions {
|
|
1771
|
+
/**
|
|
1772
|
+
* `true` to use Zip64 to write the entries directory.
|
|
1773
|
+
*
|
|
1774
|
+
* @defaultValue false
|
|
1775
|
+
*/
|
|
1776
|
+
zip64?: boolean;
|
|
1777
|
+
/**
|
|
1778
|
+
* `true` to prevent closing of {@link WritableWriter#writable}.
|
|
1779
|
+
*
|
|
1780
|
+
* @defaultValue false
|
|
1781
|
+
*/
|
|
1782
|
+
preventClose?: boolean;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
/**
|
|
1786
|
+
* Represents options passed to the constructor of {@link ZipWriter}, {@link ZipWriter#add} and `{@link ZipDirectoryEntry}#export*`.
|
|
1787
|
+
*/
|
|
1788
|
+
export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
1789
|
+
/**
|
|
1790
|
+
* `true` to use Zip64 to store the entry.
|
|
1791
|
+
*
|
|
1792
|
+
* `zip64` is automatically set to `true` when necessary (e.g. compressed data larger than 4GB or with unknown size).
|
|
1793
|
+
*
|
|
1794
|
+
* @defaultValue false
|
|
1795
|
+
*/
|
|
1796
|
+
zip64?: boolean;
|
|
1797
|
+
/**
|
|
1798
|
+
* `true` to prevent closing of {@link WritableWriter#writable}.
|
|
1799
|
+
*
|
|
1800
|
+
* @defaultValue false
|
|
1801
|
+
*/
|
|
1802
|
+
preventClose?: boolean;
|
|
1803
|
+
/**
|
|
1804
|
+
* The level of compression.
|
|
1805
|
+
*
|
|
1806
|
+
* The minimum value is 0 and means that no compression is applied. The maximum value is 9.
|
|
1807
|
+
*
|
|
1808
|
+
* @defaultValue 6
|
|
1809
|
+
*/
|
|
1810
|
+
level?: number;
|
|
1811
|
+
/**
|
|
1812
|
+
* `true` to write entry data in a buffer before appending it to the zip file.
|
|
1813
|
+
*
|
|
1814
|
+
* `bufferedWrite` is automatically set to `true` when compressing more than one entry in parallel.
|
|
1815
|
+
*
|
|
1816
|
+
* @defaultValue false
|
|
1817
|
+
*/
|
|
1818
|
+
bufferedWrite?: boolean;
|
|
1819
|
+
/**
|
|
1820
|
+
* An async factory function that returns a `TransformStream`-like object (`{ writable, readable }`) used as a temporary buffer when entries are written in parallel.
|
|
1821
|
+
*
|
|
1822
|
+
* When provided, this replaces the default in-memory `TransformStream` buffer, allowing data to be stored externally (e.g. filesystem, OPFS, network).
|
|
1823
|
+
* The `writable` side receives compressed entry data. The `readable` side is consumed when the entry is replayed into the final zip stream.
|
|
1824
|
+
* The optional `dispose` method is called once the entry has been processed (on success, error, or abort) so a resource-backed buffer can release its resource.
|
|
1825
|
+
*
|
|
1826
|
+
* See {@link createOPFSTempStream} for a ready-made OPFS-backed implementation.
|
|
1827
|
+
*/
|
|
1828
|
+
createTempStream?: () => TempStream | Promise<TempStream>;
|
|
1829
|
+
/**
|
|
1830
|
+
* `true` to keep the order of the entry physically in the zip file.
|
|
1831
|
+
*
|
|
1832
|
+
* When set to `true`, the use of web workers will be improved.
|
|
1833
|
+
*
|
|
1834
|
+
* @defaultValue true
|
|
1835
|
+
*/
|
|
1836
|
+
keepOrder?: boolean;
|
|
1837
|
+
/**
|
|
1838
|
+
* The password used to encrypt the content of the entry.
|
|
1839
|
+
*/
|
|
1840
|
+
password?: string;
|
|
1841
|
+
/**
|
|
1842
|
+
* The password used to encrypt the content of the entry (raw).
|
|
1843
|
+
*/
|
|
1844
|
+
rawPassword?: Uint8Array;
|
|
1845
|
+
/**
|
|
1846
|
+
* The encryption strength (AES):
|
|
1847
|
+
* - 1: 128-bit encryption key
|
|
1848
|
+
* - 2: 192-bit encryption key
|
|
1849
|
+
* - 3: 256-bit encryption key
|
|
1850
|
+
*
|
|
1851
|
+
* @defaultValue 3
|
|
1852
|
+
*/
|
|
1853
|
+
encryptionStrength?: 1 | 2 | 3;
|
|
1854
|
+
/**
|
|
1855
|
+
* The `AbortSignal` instance used to cancel the compression.
|
|
1856
|
+
*/
|
|
1857
|
+
signal?: AbortSignal;
|
|
1858
|
+
/**
|
|
1859
|
+
* The last modification date.
|
|
1860
|
+
*
|
|
1861
|
+
* @defaultValue The current date.
|
|
1862
|
+
*/
|
|
1863
|
+
lastModDate?: Date;
|
|
1864
|
+
/**
|
|
1865
|
+
* The last access date.
|
|
1866
|
+
*
|
|
1867
|
+
* This option is ignored if the {@link ZipWriterConstructorOptions#extendedTimestamp} option is set to `false`.
|
|
1868
|
+
*
|
|
1869
|
+
* @defaultValue The current date.
|
|
1870
|
+
*/
|
|
1871
|
+
lastAccessDate?: Date;
|
|
1872
|
+
/**
|
|
1873
|
+
* The creation date.
|
|
1874
|
+
*
|
|
1875
|
+
* This option is ignored if the {@link ZipWriterConstructorOptions#extendedTimestamp} option is set to `false`.
|
|
1876
|
+
*
|
|
1877
|
+
* @defaultValue The current date.
|
|
1878
|
+
*/
|
|
1879
|
+
creationDate?: Date;
|
|
1880
|
+
/**
|
|
1881
|
+
* `true` to store extended timestamp extra fields.
|
|
1882
|
+
*
|
|
1883
|
+
* When set to `false`, the maximum last modification date cannot exceed November 31, 2107 and the maximum accuracy is 2 seconds.
|
|
1884
|
+
*
|
|
1885
|
+
* @defaultValue true
|
|
1886
|
+
*/
|
|
1887
|
+
extendedTimestamp?: boolean;
|
|
1888
|
+
/**
|
|
1889
|
+
* `true` to use the ZipCrypto algorithm to encrypt the content of the entry. Setting it to `true` will also
|
|
1890
|
+
* set the {@link ZipWriterConstructorOptions#dataDescriptor} to `true`.
|
|
1891
|
+
*
|
|
1892
|
+
* It is not recommended to set `zipCrypto` to `true` because the ZipCrypto encryption can be easily broken.
|
|
1893
|
+
*
|
|
1894
|
+
* @defaultValue false
|
|
1895
|
+
*/
|
|
1896
|
+
zipCrypto?: boolean;
|
|
1897
|
+
/**
|
|
1898
|
+
* The "Version" field.
|
|
1899
|
+
*/
|
|
1900
|
+
version?: number;
|
|
1901
|
+
/**
|
|
1902
|
+
* The "Version made by" field.
|
|
1903
|
+
*
|
|
1904
|
+
* @defaultValue 20
|
|
1905
|
+
*/
|
|
1906
|
+
versionMadeBy?: number;
|
|
1907
|
+
/**
|
|
1908
|
+
* `true` to mark the file names as UTF-8 setting the general purpose bit 11 in the header (see Appendix D -
|
|
1909
|
+
* Language Encoding (EFS)), `false` to mark the names as compliant with the original IBM Code Page 437.
|
|
1910
|
+
*
|
|
1911
|
+
* Note that this does not ensure that the file names are in the correct encoding.
|
|
1912
|
+
*
|
|
1913
|
+
* @defaultValue true
|
|
1914
|
+
*/
|
|
1915
|
+
useUnicodeFileNames?: boolean;
|
|
1916
|
+
/**
|
|
1917
|
+
* `true` to add a data descriptor.
|
|
1918
|
+
*
|
|
1919
|
+
* When set to `false`, the {@link ZipWriterConstructorOptions#bufferedWrite} option will automatically be
|
|
1920
|
+
* set to `true`. It will be automatically set to `false` when it is `undefined` and the
|
|
1921
|
+
* {@link ZipWriterConstructorOptions#bufferedWrite} option is set to `true`, or when the
|
|
1922
|
+
* {@link ZipWriterConstructorOptions#zipCrypto} option is set to `true`. Otherwise, the default value is `true`.
|
|
1923
|
+
*/
|
|
1924
|
+
dataDescriptor?: boolean;
|
|
1925
|
+
/**
|
|
1926
|
+
* `true` to add the signature of the data descriptor.
|
|
1927
|
+
*
|
|
1928
|
+
* @defaultValue true
|
|
1929
|
+
*/
|
|
1930
|
+
dataDescriptorSignature?: boolean;
|
|
1931
|
+
/**
|
|
1932
|
+
* `true` to write {@link EntryMetaData#externalFileAttributes} in MS-DOS format for folder entries.
|
|
1933
|
+
*
|
|
1934
|
+
* @defaultValue false
|
|
1935
|
+
*/
|
|
1936
|
+
msDosCompatible?: boolean;
|
|
1937
|
+
/**
|
|
1938
|
+
* The external file attribute.
|
|
1939
|
+
*
|
|
1940
|
+
* @defaultValue 0
|
|
1941
|
+
*/
|
|
1942
|
+
externalFileAttributes?: number;
|
|
1943
|
+
/**
|
|
1944
|
+
* The Unix owner id to write in the Unix extra field or as part of the external attributes.
|
|
1945
|
+
*/
|
|
1946
|
+
uid?: number;
|
|
1947
|
+
/**
|
|
1948
|
+
* The Unix group id to write in the Unix extra field or as part of the external attributes.
|
|
1949
|
+
*/
|
|
1950
|
+
gid?: number;
|
|
1951
|
+
/**
|
|
1952
|
+
* The Unix mode (st_mode bits) to use when writing external attributes.
|
|
1953
|
+
*/
|
|
1954
|
+
unixMode?: number;
|
|
1955
|
+
/**
|
|
1956
|
+
* `true` to set the setuid bit when writing the Unix mode.
|
|
1957
|
+
*/
|
|
1958
|
+
setuid?: boolean;
|
|
1959
|
+
/**
|
|
1960
|
+
* `true` to set the setgid bit when writing the Unix mode.
|
|
1961
|
+
*/
|
|
1962
|
+
setgid?: boolean;
|
|
1963
|
+
/**
|
|
1964
|
+
* `true` to set the sticky bit when writing the Unix mode.
|
|
1965
|
+
*/
|
|
1966
|
+
sticky?: boolean;
|
|
1967
|
+
/**
|
|
1968
|
+
* Which Unix extra field format to write when creating entries that include Unix metadata.
|
|
1969
|
+
* - "infozip": Info-ZIP New Unix extra field (0x7875), storing variable-length uid/gid up to 32 bits.
|
|
1970
|
+
* - "unix": Info-ZIP Unix extra field type 2 (0x7855), storing fixed 2-byte uid/gid (0..65535); a
|
|
1971
|
+
* larger uid or gid is rejected. The Unix mode is not part of this field; it is written to the
|
|
1972
|
+
* external file attributes.
|
|
1973
|
+
*/
|
|
1974
|
+
unixExtraFieldType?: "infozip" | "unix";
|
|
1975
|
+
/**
|
|
1976
|
+
* The internal file attribute.
|
|
1977
|
+
*
|
|
1978
|
+
* @defaultValue 0
|
|
1979
|
+
*/
|
|
1980
|
+
internalFileAttributes?: number;
|
|
1981
|
+
/**
|
|
1982
|
+
* When provided, the low 8-bit MS-DOS attributes to write into external file attributes.
|
|
1983
|
+
* Must be an integer between 0 and 255.
|
|
1984
|
+
*/
|
|
1985
|
+
msdosAttributesRaw?: number;
|
|
1986
|
+
/**
|
|
1987
|
+
* When provided, MS-DOS attribute flags (boolean object) to write into external file attributes low byte.
|
|
1988
|
+
*/
|
|
1989
|
+
msdosAttributes?: {
|
|
1990
|
+
readOnly?: boolean;
|
|
1991
|
+
hidden?: boolean;
|
|
1992
|
+
system?: boolean;
|
|
1993
|
+
directory?: boolean;
|
|
1994
|
+
archive?: boolean;
|
|
1995
|
+
};
|
|
1996
|
+
/**
|
|
1997
|
+
* `false` to never write disk numbers in zip64 data.
|
|
1998
|
+
*
|
|
1999
|
+
* @defaultValue true
|
|
2000
|
+
*/
|
|
2001
|
+
supportZip64SplitFile?: boolean;
|
|
2002
|
+
/**
|
|
2003
|
+
* `true`to produce zip files compatible with the USDZ specification.
|
|
2004
|
+
*
|
|
2005
|
+
* @defaultValue false
|
|
2006
|
+
*/
|
|
2007
|
+
usdz?: boolean;
|
|
2008
|
+
/**
|
|
2009
|
+
* `true` to write the data as-is without compressing it and without crypting it.
|
|
2010
|
+
*/
|
|
2011
|
+
passThrough?: boolean;
|
|
2012
|
+
/**
|
|
2013
|
+
* `true` to write encrypted data when `passThrough` is set to `true`.
|
|
2014
|
+
*/
|
|
2015
|
+
encrypted?: boolean;
|
|
2016
|
+
/**
|
|
2017
|
+
* The offset of the first entry in the zip file.
|
|
2018
|
+
*/
|
|
2019
|
+
offset?: number;
|
|
2020
|
+
/**
|
|
2021
|
+
* The compression method (e.g. 8 for DEFLATE, 0 for STORE).
|
|
2022
|
+
*/
|
|
2023
|
+
compressionMethod?: number;
|
|
2024
|
+
/**
|
|
2025
|
+
* The function called for encoding the filename and the comment of the entry.
|
|
2026
|
+
*
|
|
2027
|
+
* @param text The text to encode.
|
|
2028
|
+
* @returns The encoded text or `undefined` if the text should be encoded by zip.js.
|
|
2029
|
+
*/
|
|
2030
|
+
encodeText?(text: string): Uint8Array | undefined;
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
/**
|
|
2034
|
+
* Represents options passed to {@link FileEntry#getData}, {@link ZipWriter.add} and `{@link ZipDirectory}.export*`.
|
|
2035
|
+
*/
|
|
2036
|
+
export interface EntryDataOnprogressOptions {
|
|
2037
|
+
/**
|
|
2038
|
+
* The function called when starting compression/decompression.
|
|
2039
|
+
*
|
|
2040
|
+
* @param total The total number of bytes.
|
|
2041
|
+
* @returns An empty promise or `undefined`.
|
|
2042
|
+
*/
|
|
2043
|
+
onstart?(total: number): Promise<void> | void;
|
|
2044
|
+
/**
|
|
2045
|
+
* The function called during compression/decompression.
|
|
2046
|
+
*
|
|
2047
|
+
* @param progress The current progress in bytes.
|
|
2048
|
+
* @param total The total number of bytes.
|
|
2049
|
+
* @returns An empty promise or `undefined`.
|
|
2050
|
+
*/
|
|
2051
|
+
onprogress?(progress: number, total: number): Promise<void> | void;
|
|
2052
|
+
/**
|
|
2053
|
+
* The function called when ending compression/decompression.
|
|
2054
|
+
*
|
|
2055
|
+
* @param computedSize The total number of bytes (computed).
|
|
2056
|
+
* @returns An empty promise or `undefined`.
|
|
2057
|
+
*/
|
|
2058
|
+
onend?(computedSize: number): Promise<void> | void;
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
/**
|
|
2062
|
+
* Represents options passed to {@link ZipReader#getEntries}, {@link ZipReader#getEntriesGenerator}, and {@link ZipWriter#close}.
|
|
2063
|
+
*/
|
|
2064
|
+
export interface EntryOnprogressOptions {
|
|
2065
|
+
/**
|
|
2066
|
+
* The function called each time an entry is read/written.
|
|
2067
|
+
*
|
|
2068
|
+
* @param progress The entry index.
|
|
2069
|
+
* @param total The total number of entries.
|
|
2070
|
+
* @param entry The entry being read/written.
|
|
2071
|
+
* @returns An empty promise or `undefined`.
|
|
2072
|
+
*/
|
|
2073
|
+
onprogress?(
|
|
2074
|
+
progress: number,
|
|
2075
|
+
total: number,
|
|
2076
|
+
entry: EntryMetaData
|
|
2077
|
+
): Promise<void> | void;
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
/**
|
|
2081
|
+
* Represents an entry in a zip file (Filesystem API).
|
|
2082
|
+
*/
|
|
2083
|
+
declare class ZipEntry {
|
|
2084
|
+
/**
|
|
2085
|
+
* The relative filename of the entry.
|
|
2086
|
+
*/
|
|
2087
|
+
name: string;
|
|
2088
|
+
/**
|
|
2089
|
+
* The underlying {@link EntryMetaData} instance.
|
|
2090
|
+
*/
|
|
2091
|
+
data?: EntryMetaData;
|
|
2092
|
+
/**
|
|
2093
|
+
* The ID of the instance.
|
|
2094
|
+
*/
|
|
2095
|
+
id: number;
|
|
2096
|
+
/**
|
|
2097
|
+
* The parent directory of the entry.
|
|
2098
|
+
*/
|
|
2099
|
+
parent?: ZipEntry;
|
|
2100
|
+
/**
|
|
2101
|
+
* The uncompressed size of the content.
|
|
2102
|
+
*/
|
|
2103
|
+
uncompressedSize: number;
|
|
2104
|
+
/**
|
|
2105
|
+
* The children of the entry.
|
|
2106
|
+
*/
|
|
2107
|
+
children: ZipEntry[];
|
|
2108
|
+
/**
|
|
2109
|
+
* Clones the entry
|
|
2110
|
+
*
|
|
2111
|
+
* @param deepClone `true` to clone all the descendants.
|
|
2112
|
+
*/
|
|
2113
|
+
clone(deepClone?: boolean): ZipEntry;
|
|
2114
|
+
/**
|
|
2115
|
+
* Returns the full filename of the entry
|
|
2116
|
+
*/
|
|
2117
|
+
getFullname(): string;
|
|
2118
|
+
/**
|
|
2119
|
+
* Returns the filename of the entry relative to a parent directory
|
|
2120
|
+
*/
|
|
2121
|
+
getRelativeName(ancestor: ZipDirectoryEntry): string;
|
|
2122
|
+
/**
|
|
2123
|
+
* Tests if a {@link ZipDirectoryEntry} instance is an ancestor of the entry
|
|
2124
|
+
*
|
|
2125
|
+
* @param ancestor The {@link ZipDirectoryEntry} instance.
|
|
2126
|
+
*/
|
|
2127
|
+
isDescendantOf(ancestor: ZipDirectoryEntry): boolean;
|
|
2128
|
+
/**
|
|
2129
|
+
* Tests if the entry or any of its children is password protected
|
|
2130
|
+
*/
|
|
2131
|
+
isPasswordProtected(): boolean;
|
|
2132
|
+
/**
|
|
2133
|
+
* Tests the password on the entry and all children if any, returns `true` if the entry is not password protected
|
|
2134
|
+
*/
|
|
2135
|
+
checkPassword(
|
|
2136
|
+
password: string,
|
|
2137
|
+
options?: EntryGetDataOptions
|
|
2138
|
+
): Promise<boolean>;
|
|
2139
|
+
/**
|
|
2140
|
+
* Set the name of the entry
|
|
2141
|
+
*
|
|
2142
|
+
* @param name The new name of the entry.
|
|
2143
|
+
*/
|
|
2144
|
+
rename(name: string): void;
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
/**
|
|
2148
|
+
* Represents a file entry in the zip (Filesystem API).
|
|
2149
|
+
*/
|
|
2150
|
+
export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
|
|
2151
|
+
/**
|
|
2152
|
+
* `void` for {@link ZipFileEntry} instances.
|
|
2153
|
+
*/
|
|
2154
|
+
directory: void;
|
|
2155
|
+
/**
|
|
2156
|
+
* The {@link Reader} instance used to read the content of the entry.
|
|
2157
|
+
*/
|
|
2158
|
+
reader:
|
|
2159
|
+
| Reader<ReaderType>
|
|
2160
|
+
| ReadableReader
|
|
2161
|
+
| ReadableStream
|
|
2162
|
+
| Reader<unknown>[]
|
|
2163
|
+
| ReadableReader[]
|
|
2164
|
+
| ReadableStream[];
|
|
2165
|
+
/**
|
|
2166
|
+
* The {@link Writer} instance used to write the content of the entry.
|
|
2167
|
+
*/
|
|
2168
|
+
writer:
|
|
2169
|
+
| Writer<WriterType>
|
|
2170
|
+
| WritableWriter
|
|
2171
|
+
| WritableStream
|
|
2172
|
+
| AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream>;
|
|
2173
|
+
/**
|
|
2174
|
+
* Retrieves the text content of the entry as a `string`
|
|
2175
|
+
*
|
|
2176
|
+
* @param encoding The encoding of the text.
|
|
2177
|
+
* @param options The options.
|
|
2178
|
+
* @returns A promise resolving to a `string`.
|
|
2179
|
+
*/
|
|
2180
|
+
getText(encoding?: string, options?: EntryGetDataOptions): Promise<string>;
|
|
2181
|
+
/**
|
|
2182
|
+
* Retrieves the content of the entry as a `Blob` instance
|
|
2183
|
+
*
|
|
2184
|
+
* @param mimeType The MIME type of the content.
|
|
2185
|
+
* @param options The options.
|
|
2186
|
+
* @returns A promise resolving to a `Blob` instance.
|
|
2187
|
+
*/
|
|
2188
|
+
getBlob(mimeType?: string, options?: EntryGetDataOptions): Promise<Blob>;
|
|
2189
|
+
/**
|
|
2190
|
+
* Retrieves the content of the entry as as a Data URI `string` encoded in Base64
|
|
2191
|
+
*
|
|
2192
|
+
* @param mimeType The MIME type of the content.
|
|
2193
|
+
* @param options The options.
|
|
2194
|
+
* @returns A promise resolving to a Data URI `string` encoded in Base64.
|
|
2195
|
+
*/
|
|
2196
|
+
getData64URI(
|
|
2197
|
+
mimeType?: string,
|
|
2198
|
+
options?: EntryGetDataOptions
|
|
2199
|
+
): Promise<string>;
|
|
2200
|
+
/**
|
|
2201
|
+
* Retrieves the content of the entry as a `Uint8Array` instance
|
|
2202
|
+
*
|
|
2203
|
+
* @param options The options.
|
|
2204
|
+
* @returns A promise resolving to a `Uint8Array` instance.
|
|
2205
|
+
*/
|
|
2206
|
+
getUint8Array(options?: EntryGetDataOptions): Promise<Uint8Array>;
|
|
2207
|
+
/**
|
|
2208
|
+
* Retrieves the content of the entry via a `WritableStream` instance
|
|
2209
|
+
*
|
|
2210
|
+
* @param writable The `WritableStream` instance.
|
|
2211
|
+
* @param options The options.
|
|
2212
|
+
* @returns A promise resolving to the `WritableStream` instance.
|
|
2213
|
+
*/
|
|
2214
|
+
getWritable(
|
|
2215
|
+
writable?: WritableStream,
|
|
2216
|
+
options?: EntryGetDataOptions
|
|
2217
|
+
): Promise<WritableStream>;
|
|
2218
|
+
/**
|
|
2219
|
+
* Retrieves the content of the entry via a {@link Writer} instance
|
|
2220
|
+
*
|
|
2221
|
+
* @param writer The {@link Writer} instance.
|
|
2222
|
+
* @param options The options.
|
|
2223
|
+
* @returns A promise resolving to data associated to the {@link Writer} instance.
|
|
2224
|
+
*/
|
|
2225
|
+
getData<Type>(
|
|
2226
|
+
writer:
|
|
2227
|
+
| Writer<unknown>
|
|
2228
|
+
| WritableWriter
|
|
2229
|
+
| WritableStream
|
|
2230
|
+
| AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream>,
|
|
2231
|
+
options?: EntryGetDataOptions
|
|
2232
|
+
): Promise<Type>;
|
|
2233
|
+
/**
|
|
2234
|
+
* Retrieves the content of the entry as an `ArrayBuffer` instance
|
|
2235
|
+
*
|
|
2236
|
+
* @param options The options.
|
|
2237
|
+
* @returns A promise resolving to an `ArrayBuffer` instance.
|
|
2238
|
+
*/
|
|
2239
|
+
getArrayBuffer(options?: EntryGetDataOptions): Promise<ArrayBuffer>;
|
|
2240
|
+
/**
|
|
2241
|
+
* Replaces the content of the entry with a `Blob` instance
|
|
2242
|
+
*
|
|
2243
|
+
* @param blob The `Blob` instance.
|
|
2244
|
+
*/
|
|
2245
|
+
replaceBlob(blob: Blob): void;
|
|
2246
|
+
/**
|
|
2247
|
+
* Replaces the content of the entry with a `string`
|
|
2248
|
+
*
|
|
2249
|
+
* @param text The `string`.
|
|
2250
|
+
*/
|
|
2251
|
+
replaceText(text: string): void;
|
|
2252
|
+
/**
|
|
2253
|
+
* Replaces the content of the entry with a Data URI `string` encoded in Base64
|
|
2254
|
+
*
|
|
2255
|
+
* @param dataURI The Data URI `string` encoded in Base64.
|
|
2256
|
+
*/
|
|
2257
|
+
replaceData64URI(dataURI: string): void;
|
|
2258
|
+
/**
|
|
2259
|
+
* Replaces the content of the entry with a `Uint8Array` instance
|
|
2260
|
+
*
|
|
2261
|
+
* @param array The `Uint8Array` instance.
|
|
2262
|
+
*/
|
|
2263
|
+
replaceUint8Array(array: Uint8Array): void;
|
|
2264
|
+
/**
|
|
2265
|
+
* Replaces the content of the entry with a `ReadableStream` instance
|
|
2266
|
+
*
|
|
2267
|
+
* @param readable The `ReadableStream` instance.
|
|
2268
|
+
*/
|
|
2269
|
+
replaceReadable(readable: ReadableStream): void;
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
/**
|
|
2273
|
+
* Represents a directory entry in the zip (Filesystem API).
|
|
2274
|
+
*/
|
|
2275
|
+
export class ZipDirectoryEntry extends ZipEntry {
|
|
2276
|
+
/**
|
|
2277
|
+
* `true` for {@link ZipDirectoryEntry} instances.
|
|
2278
|
+
*/
|
|
2279
|
+
directory: true;
|
|
2280
|
+
/**
|
|
2281
|
+
* Gets a {@link ZipEntry} child instance from its relative filename
|
|
2282
|
+
*
|
|
2283
|
+
* @param name The relative filename.
|
|
2284
|
+
* @returns A {@link ZipFileEntry} or a {@link ZipDirectoryEntry} instance (use the {@link ZipFileEntry#directory} and {@link ZipDirectoryEntry#directory} properties to differentiate entries).
|
|
2285
|
+
*/
|
|
2286
|
+
getChildByName(name: string): ZipEntry | undefined;
|
|
2287
|
+
/**
|
|
2288
|
+
* Adds a directory
|
|
2289
|
+
*
|
|
2290
|
+
* @param name The relative filename of the directory.
|
|
2291
|
+
* @param options The options.
|
|
2292
|
+
* @returns A {@link ZipDirectoryEntry} instance.
|
|
2293
|
+
*/
|
|
2294
|
+
addDirectory(
|
|
2295
|
+
name: string,
|
|
2296
|
+
options?: ZipWriterAddDataOptions
|
|
2297
|
+
): ZipDirectoryEntry;
|
|
2298
|
+
/**
|
|
2299
|
+
* Adds an entry with content provided as text
|
|
2300
|
+
*
|
|
2301
|
+
* @param name The relative filename of the entry.
|
|
2302
|
+
* @param text The text.
|
|
2303
|
+
* @param options The options.
|
|
2304
|
+
* @returns A {@link ZipFileEntry} instance.
|
|
2305
|
+
*/
|
|
2306
|
+
addText(
|
|
2307
|
+
name: string,
|
|
2308
|
+
text: string,
|
|
2309
|
+
options?: ZipWriterAddDataOptions
|
|
2310
|
+
): ZipFileEntry<string, string>;
|
|
2311
|
+
/**
|
|
2312
|
+
* Adds a entry entry with content provided as a `Blob` instance
|
|
2313
|
+
*
|
|
2314
|
+
* @param name The relative filename of the entry.
|
|
2315
|
+
* @param blob The `Blob` instance.
|
|
2316
|
+
* @param options The options.
|
|
2317
|
+
* @returns A {@link ZipFileEntry} instance.
|
|
2318
|
+
*/
|
|
2319
|
+
addBlob(
|
|
2320
|
+
name: string,
|
|
2321
|
+
blob: Blob,
|
|
2322
|
+
options?: ZipWriterAddDataOptions
|
|
2323
|
+
): ZipFileEntry<Blob, Blob>;
|
|
2324
|
+
/**
|
|
2325
|
+
* Adds a entry entry with content provided as a Data URI `string` encoded in Base64
|
|
2326
|
+
*
|
|
2327
|
+
* @param name The relative filename of the entry.
|
|
2328
|
+
* @param dataURI The Data URI `string` encoded in Base64.
|
|
2329
|
+
* @param options The options.
|
|
2330
|
+
* @returns A {@link ZipFileEntry} instance.
|
|
2331
|
+
*/
|
|
2332
|
+
addData64URI(
|
|
2333
|
+
name: string,
|
|
2334
|
+
dataURI: string,
|
|
2335
|
+
options?: ZipWriterAddDataOptions
|
|
2336
|
+
): ZipFileEntry<string, string>;
|
|
2337
|
+
/**
|
|
2338
|
+
* Adds an entry with content provided as a `Uint8Array` instance
|
|
2339
|
+
*
|
|
2340
|
+
* @param name The relative filename of the entry.
|
|
2341
|
+
* @param array The `Uint8Array` instance.
|
|
2342
|
+
* @param options The options.
|
|
2343
|
+
* @returns A {@link ZipFileEntry} instance.
|
|
2344
|
+
*/
|
|
2345
|
+
addUint8Array(
|
|
2346
|
+
name: string,
|
|
2347
|
+
array: Uint8Array,
|
|
2348
|
+
options?: ZipWriterAddDataOptions
|
|
2349
|
+
): ZipFileEntry<Uint8Array, Uint8Array>;
|
|
2350
|
+
/**
|
|
2351
|
+
* Adds an entry with content fetched from a URL
|
|
2352
|
+
*
|
|
2353
|
+
* @param name The relative filename of the entry.
|
|
2354
|
+
* @param url The URL.
|
|
2355
|
+
* @param options The options.
|
|
2356
|
+
* @returns A {@link ZipFileEntry} instance.
|
|
2357
|
+
*/
|
|
2358
|
+
addHttpContent(
|
|
2359
|
+
name: string,
|
|
2360
|
+
url: string,
|
|
2361
|
+
options?: HttpOptions & ZipWriterAddDataOptions
|
|
2362
|
+
): ZipFileEntry<string, void>;
|
|
2363
|
+
/**
|
|
2364
|
+
* Adds a entry entry with content provided via a `ReadableStream` instance
|
|
2365
|
+
*
|
|
2366
|
+
* @param name The relative filename of the entry.
|
|
2367
|
+
* @param readable The `ReadableStream` instance.
|
|
2368
|
+
* @param options The options.
|
|
2369
|
+
* @returns A {@link ZipFileEntry} instance.
|
|
2370
|
+
*/
|
|
2371
|
+
addReadable(
|
|
2372
|
+
name: string,
|
|
2373
|
+
readable: ReadableStream,
|
|
2374
|
+
options?: ZipWriterAddDataOptions
|
|
2375
|
+
): ZipFileEntry<ReadableStream, void>;
|
|
2376
|
+
/**
|
|
2377
|
+
* Adds an entry with content provided via a `File` instance
|
|
2378
|
+
*
|
|
2379
|
+
* @param file The `File` instance.
|
|
2380
|
+
* @param options The options.
|
|
2381
|
+
* @returns A promise resolving to a {@link ZipFileEntry} or a {@link ZipDirectoryEntry} instance.
|
|
2382
|
+
*/
|
|
2383
|
+
addFile(file: File, options?: ZipWriterAddDataOptions): Promise<ZipEntry>;
|
|
2384
|
+
/**
|
|
2385
|
+
* Adds an entry with content provided via a `FileSystemEntry` instance
|
|
2386
|
+
*
|
|
2387
|
+
* @param fileSystemEntry The `FileSystemEntry` instance.
|
|
2388
|
+
* @param options The options.
|
|
2389
|
+
* @returns A promise resolving to an array of {@link ZipFileEntry} or a {@link ZipDirectoryEntry} instances.
|
|
2390
|
+
*/
|
|
2391
|
+
addFileSystemEntry(
|
|
2392
|
+
fileSystemEntry: FileSystemEntryLike,
|
|
2393
|
+
options?: ZipWriterAddDataOptions
|
|
2394
|
+
): Promise<ZipEntry[]>;
|
|
2395
|
+
/**
|
|
2396
|
+
* Adds an entry with content provided via a `FileSystemHandle` instance
|
|
2397
|
+
*
|
|
2398
|
+
* @param fileSystemHandle The `fileSystemHandle` instance.
|
|
2399
|
+
* @param options The options.
|
|
2400
|
+
* @returns A promise resolving to an array of {@link ZipFileEntry} or a {@link ZipDirectoryEntry} instances.
|
|
2401
|
+
*/
|
|
2402
|
+
addFileSystemHandle(
|
|
2403
|
+
fileSystemHandle: FileSystemHandleLike,
|
|
2404
|
+
options?: ZipWriterAddDataOptions
|
|
2405
|
+
): Promise<ZipEntry[]>;
|
|
2406
|
+
/**
|
|
2407
|
+
* Extracts a zip file provided as a `Blob` instance into the entry
|
|
2408
|
+
*
|
|
2409
|
+
* @param blob The `Blob` instance.
|
|
2410
|
+
* @param options The options.
|
|
2411
|
+
*/
|
|
2412
|
+
importBlob(
|
|
2413
|
+
blob: Blob,
|
|
2414
|
+
options?: ZipReaderConstructorOptions
|
|
2415
|
+
): Promise<[ZipEntry]>;
|
|
2416
|
+
/**
|
|
2417
|
+
* Extracts a zip file provided as a Data URI `string` encoded in Base64 into the entry
|
|
2418
|
+
*
|
|
2419
|
+
* @param dataURI The Data URI `string` encoded in Base64.
|
|
2420
|
+
* @param options The options.
|
|
2421
|
+
*/
|
|
2422
|
+
importData64URI(
|
|
2423
|
+
dataURI: string,
|
|
2424
|
+
options?: ZipReaderConstructorOptions
|
|
2425
|
+
): Promise<[ZipEntry]>;
|
|
2426
|
+
/**
|
|
2427
|
+
* Extracts a zip file provided as a `Uint8Array` instance into the entry
|
|
2428
|
+
*
|
|
2429
|
+
* @param array The `Uint8Array` instance.
|
|
2430
|
+
* @param options The options.
|
|
2431
|
+
*/
|
|
2432
|
+
importUint8Array(
|
|
2433
|
+
array: Uint8Array,
|
|
2434
|
+
options?: ZipReaderConstructorOptions
|
|
2435
|
+
): Promise<[ZipEntry]>;
|
|
2436
|
+
/**
|
|
2437
|
+
* Extracts a zip file fetched from a URL into the entry
|
|
2438
|
+
*
|
|
2439
|
+
* @param url The URL.
|
|
2440
|
+
* @param options The options.
|
|
2441
|
+
*/
|
|
2442
|
+
importHttpContent(
|
|
2443
|
+
url: string,
|
|
2444
|
+
options?: ZipDirectoryEntryImportHttpOptions
|
|
2445
|
+
): Promise<[ZipEntry]>;
|
|
2446
|
+
/**
|
|
2447
|
+
* Extracts a zip file provided via a `ReadableStream` instance into the entry
|
|
2448
|
+
*
|
|
2449
|
+
* @param readable The `ReadableStream` instance.
|
|
2450
|
+
* @param options The options.
|
|
2451
|
+
*/
|
|
2452
|
+
importReadable(
|
|
2453
|
+
readable: ReadableStream,
|
|
2454
|
+
options?: ZipReaderConstructorOptions
|
|
2455
|
+
): Promise<[ZipEntry]>;
|
|
2456
|
+
/**
|
|
2457
|
+
* Extracts a zip file provided via a custom {@link Reader} instance into the entry
|
|
2458
|
+
*
|
|
2459
|
+
* @param reader The {@link Reader} instance.
|
|
2460
|
+
* @param options The options.
|
|
2461
|
+
*/
|
|
2462
|
+
importZip(
|
|
2463
|
+
reader:
|
|
2464
|
+
| Reader<unknown>
|
|
2465
|
+
| ReadableReader
|
|
2466
|
+
| ReadableStream
|
|
2467
|
+
| Reader<unknown>[]
|
|
2468
|
+
| ReadableReader[]
|
|
2469
|
+
| ReadableStream[],
|
|
2470
|
+
options?: ZipReaderConstructorOptions
|
|
2471
|
+
): Promise<[ZipEntry]>;
|
|
2472
|
+
/**
|
|
2473
|
+
* Returns a `Blob` instance containing a zip file of the entry and its descendants
|
|
2474
|
+
*
|
|
2475
|
+
* @param options The options.
|
|
2476
|
+
* @returns A promise resolving to the `Blob` instance.
|
|
2477
|
+
*/
|
|
2478
|
+
exportBlob(options?: ZipDirectoryEntryExportOptions): Promise<Blob>;
|
|
2479
|
+
/**
|
|
2480
|
+
* Returns a Data URI `string` encoded in Base64 containing a zip file of the entry and its descendants
|
|
2481
|
+
*
|
|
2482
|
+
* @param options The options.
|
|
2483
|
+
* @returns A promise resolving to the Data URI `string` encoded in Base64.
|
|
2484
|
+
*/
|
|
2485
|
+
exportData64URI(options?: ZipDirectoryEntryExportOptions): Promise<string>;
|
|
2486
|
+
/**
|
|
2487
|
+
* Returns a `Uint8Array` instance containing a zip file of the entry and its descendants
|
|
2488
|
+
*
|
|
2489
|
+
* @param options The options.
|
|
2490
|
+
* @returns A promise resolving to the `Uint8Array` instance.
|
|
2491
|
+
*/
|
|
2492
|
+
exportUint8Array(
|
|
2493
|
+
options?: ZipDirectoryEntryExportOptions
|
|
2494
|
+
): Promise<Uint8Array>;
|
|
2495
|
+
/**
|
|
2496
|
+
* Creates a zip file via a `WritableStream` instance containing the entry and its descendants
|
|
2497
|
+
*
|
|
2498
|
+
* @param writable The `WritableStream` instance.
|
|
2499
|
+
* @param options The options.
|
|
2500
|
+
* @returns A promise resolving to the `Uint8Array` instance.
|
|
2501
|
+
*/
|
|
2502
|
+
exportWritable(
|
|
2503
|
+
writable?: WritableStream,
|
|
2504
|
+
options?: ZipDirectoryEntryExportOptions
|
|
2505
|
+
): Promise<WritableStream>;
|
|
2506
|
+
/**
|
|
2507
|
+
* Writes the entry and its descendants into a directory as files and sub-directories via the File System Access API (e.g. the Origin Private File System). Files are streamed and directories are merged into the target; colliding files are overwritten. This is the inverse of {@link ZipDirectoryEntry#addFileSystemHandle}.
|
|
2508
|
+
*
|
|
2509
|
+
* @param directoryHandle The target `FileSystemDirectoryHandle` instance.
|
|
2510
|
+
* @param options The options.
|
|
2511
|
+
* @returns A promise resolving to the target `FileSystemDirectoryHandle` instance.
|
|
2512
|
+
*/
|
|
2513
|
+
exportFileSystemHandle(
|
|
2514
|
+
directoryHandle: FileSystemDirectoryHandle,
|
|
2515
|
+
options?: ZipDirectoryEntryExportFileSystemHandleOptions
|
|
2516
|
+
): Promise<FileSystemDirectoryHandle>;
|
|
2517
|
+
/**
|
|
2518
|
+
* Creates a zip file via a custom {@link Writer} instance containing the entry and its descendants
|
|
2519
|
+
*
|
|
2520
|
+
* @param writer The {@link Writer} instance.
|
|
2521
|
+
* @param options The options.
|
|
2522
|
+
* @returns A promise resolving to the data.
|
|
2523
|
+
*/
|
|
2524
|
+
exportZip(
|
|
2525
|
+
writer:
|
|
2526
|
+
| Writer<unknown>
|
|
2527
|
+
| WritableWriter
|
|
2528
|
+
| WritableStream
|
|
2529
|
+
| AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream>,
|
|
2530
|
+
options?: ZipDirectoryEntryExportOptions
|
|
2531
|
+
): Promise<unknown>;
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
/**
|
|
2535
|
+
* Represents the options passed to {@link ZipDirectoryEntry#importHttpContent}.
|
|
2536
|
+
*/
|
|
2537
|
+
export interface ZipDirectoryEntryImportHttpOptions
|
|
2538
|
+
extends ZipReaderConstructorOptions,
|
|
2539
|
+
HttpOptions {}
|
|
2540
|
+
|
|
2541
|
+
/**
|
|
2542
|
+
* Represents the options passed to `{@link ZipDirectoryEntry}#export*()`.
|
|
2543
|
+
*/
|
|
2544
|
+
export interface ZipDirectoryEntryExportOptions
|
|
2545
|
+
extends ZipWriterConstructorOptions,
|
|
2546
|
+
EntryDataOnprogressOptions {
|
|
2547
|
+
/**
|
|
2548
|
+
* `true` to use filenames relative to the entry instead of full filenames.
|
|
2549
|
+
*/
|
|
2550
|
+
relativePath?: boolean;
|
|
2551
|
+
/**
|
|
2552
|
+
* The MIME type of the exported data when relevant.
|
|
2553
|
+
*/
|
|
2554
|
+
mimeType?: string;
|
|
2555
|
+
/**
|
|
2556
|
+
* The options passed to the Reader instances
|
|
2557
|
+
*/
|
|
2558
|
+
readerOptions?: ZipReaderConstructorOptions;
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2561
|
+
/**
|
|
2562
|
+
* Represents the options passed to {@link ZipDirectoryEntry#exportFileSystemHandle} and {@link FS#exportFileSystemHandle}.
|
|
2563
|
+
*/
|
|
2564
|
+
export interface ZipDirectoryEntryExportFileSystemHandleOptions
|
|
2565
|
+
extends EntryGetDataOptions {
|
|
2566
|
+
/**
|
|
2567
|
+
* `true` to write independent files concurrently instead of one after another.
|
|
2568
|
+
*
|
|
2569
|
+
* @defaultValue false
|
|
2570
|
+
*/
|
|
2571
|
+
concurrent?: boolean;
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
/**
|
|
2575
|
+
* Represents a Filesystem instance.
|
|
2576
|
+
*
|
|
2577
|
+
* @example
|
|
2578
|
+
* Here is an example showing how to create and read a zip file containing a compressed text file:
|
|
2579
|
+
* ```
|
|
2580
|
+
* const TEXT_CONTENT = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.";
|
|
2581
|
+
* const FILENAME = "lorem.txt";
|
|
2582
|
+
* const BLOB = new Blob([TEXT_CONTENT], { type: zip.getMimeType(FILENAME) });
|
|
2583
|
+
* let zipFs = new zip.fs.FS();
|
|
2584
|
+
* zipFs.addBlob("lorem.txt", BLOB);
|
|
2585
|
+
* const zippedBlob = await zipFs.exportBlob();
|
|
2586
|
+
* zipFs = new zip.fs.FS();
|
|
2587
|
+
* await zipFs.importBlob(zippedBlob);
|
|
2588
|
+
* const firstEntry = zipFs.children[0];
|
|
2589
|
+
* const unzippedBlob = await firstEntry.getBlob(zip.getMimeType(firstEntry.name));
|
|
2590
|
+
* ```
|
|
2591
|
+
*/
|
|
2592
|
+
export interface FS
|
|
2593
|
+
extends Pick<
|
|
2594
|
+
ZipDirectoryEntry,
|
|
2595
|
+
| "getChildByName"
|
|
2596
|
+
| "addDirectory"
|
|
2597
|
+
| "addText"
|
|
2598
|
+
| "addBlob"
|
|
2599
|
+
| "addData64URI"
|
|
2600
|
+
| "addUint8Array"
|
|
2601
|
+
| "addHttpContent"
|
|
2602
|
+
| "addReadable"
|
|
2603
|
+
| "addFile"
|
|
2604
|
+
| "addFileSystemEntry"
|
|
2605
|
+
| "addFileSystemHandle"
|
|
2606
|
+
| "importBlob"
|
|
2607
|
+
| "importData64URI"
|
|
2608
|
+
| "importUint8Array"
|
|
2609
|
+
| "importHttpContent"
|
|
2610
|
+
| "importReadable"
|
|
2611
|
+
| "importZip"
|
|
2612
|
+
| "exportBlob"
|
|
2613
|
+
| "exportData64URI"
|
|
2614
|
+
| "exportUint8Array"
|
|
2615
|
+
| "exportWritable"
|
|
2616
|
+
| "exportFileSystemHandle"
|
|
2617
|
+
| "exportZip"
|
|
2618
|
+
| "isPasswordProtected"
|
|
2619
|
+
| "checkPassword"
|
|
2620
|
+
> {}
|
|
2621
|
+
|
|
2622
|
+
export class FS {
|
|
2623
|
+
/**
|
|
2624
|
+
* The root directory.
|
|
2625
|
+
*/
|
|
2626
|
+
root: ZipDirectoryEntry;
|
|
2627
|
+
/**
|
|
2628
|
+
* The array of all the {@link ZipEntry} instances indexed by {@link ZipEntry#id}.
|
|
2629
|
+
*/
|
|
2630
|
+
entries: (ZipEntry | null)[];
|
|
2631
|
+
/**
|
|
2632
|
+
* The children of the root directory.
|
|
2633
|
+
*/
|
|
2634
|
+
readonly children: ZipEntry[];
|
|
2635
|
+
/**
|
|
2636
|
+
* Removes a {@link ZipEntry} instance and its children
|
|
2637
|
+
*
|
|
2638
|
+
* @param entry The {@link ZipEntry} instance to remove.
|
|
2639
|
+
*/
|
|
2640
|
+
remove(entry: ZipEntry): void;
|
|
2641
|
+
/**
|
|
2642
|
+
* Moves a {@link ZipEntry} instance and its children into a {@link ZipDirectoryEntry} instance
|
|
2643
|
+
*
|
|
2644
|
+
* @param entry The {@link ZipEntry} instance to move.
|
|
2645
|
+
* @param destination The {@link ZipDirectoryEntry} instance.
|
|
2646
|
+
*/
|
|
2647
|
+
move(entry: ZipEntry, destination: ZipDirectoryEntry): void;
|
|
2648
|
+
/**
|
|
2649
|
+
* Returns a {@link ZipEntry} instance from its full filename
|
|
2650
|
+
*
|
|
2651
|
+
* @param fullname The full filename.
|
|
2652
|
+
* @returns The {@link ZipEntry} instance.
|
|
2653
|
+
*/
|
|
2654
|
+
find(fullname: string): ZipEntry | undefined;
|
|
2655
|
+
/**
|
|
2656
|
+
* Returns a {@link ZipEntry} instance from the value of {@link ZipEntry#id}
|
|
2657
|
+
*
|
|
2658
|
+
* @param id The id of the {@link ZipEntry} instance.
|
|
2659
|
+
* @returns The {@link ZipEntry} instance.
|
|
2660
|
+
*/
|
|
2661
|
+
getById(id: number): ZipEntry | undefined;
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
/**
|
|
2665
|
+
* The Filesystem API.
|
|
2666
|
+
*/
|
|
2667
|
+
export const fs: {
|
|
2668
|
+
/**
|
|
2669
|
+
* The Filesystem constructor.
|
|
2670
|
+
*
|
|
2671
|
+
* @defaultValue {@link FS}
|
|
2672
|
+
*/
|
|
2673
|
+
FS: typeof FS;
|
|
2674
|
+
/**
|
|
2675
|
+
* The {@link ZipDirectoryEntry} constructor.
|
|
2676
|
+
*
|
|
2677
|
+
* @defaultValue {@link ZipDirectoryEntry}
|
|
2678
|
+
*/
|
|
2679
|
+
ZipDirectoryEntry: typeof ZipDirectoryEntry;
|
|
2680
|
+
/**
|
|
2681
|
+
* The {@link ZipFileEntry} constructor.
|
|
2682
|
+
*
|
|
2683
|
+
* @defaultValue {@link ZipFileEntry}
|
|
2684
|
+
*/
|
|
2685
|
+
ZipFileEntry: typeof ZipFileEntry;
|
|
2686
|
+
};
|
|
2687
|
+
|
|
2688
|
+
// The error messages.
|
|
2689
|
+
/**
|
|
2690
|
+
* HTTP range error
|
|
2691
|
+
*/
|
|
2692
|
+
export const ERR_HTTP_RANGE: string;
|
|
2693
|
+
/**
|
|
2694
|
+
* Zip format error
|
|
2695
|
+
*/
|
|
2696
|
+
export const ERR_BAD_FORMAT: string;
|
|
2697
|
+
/**
|
|
2698
|
+
* End of Central Directory Record not found error
|
|
2699
|
+
*/
|
|
2700
|
+
export const ERR_EOCDR_NOT_FOUND: string;
|
|
2701
|
+
/**
|
|
2702
|
+
* Zip64 End of Central Directory Locator not found error
|
|
2703
|
+
*/
|
|
2704
|
+
export const ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: string;
|
|
2705
|
+
/**
|
|
2706
|
+
* Central Directory not found error
|
|
2707
|
+
*/
|
|
2708
|
+
export const ERR_CENTRAL_DIRECTORY_NOT_FOUND: string;
|
|
2709
|
+
/**
|
|
2710
|
+
* Local file header not found error
|
|
2711
|
+
*/
|
|
2712
|
+
export const ERR_LOCAL_FILE_HEADER_NOT_FOUND: string;
|
|
2713
|
+
/**
|
|
2714
|
+
* Extra field Zip64 not found error
|
|
2715
|
+
*/
|
|
2716
|
+
export const ERR_EXTRAFIELD_ZIP64_NOT_FOUND: string;
|
|
2717
|
+
/**
|
|
2718
|
+
* Encrypted entry error
|
|
2719
|
+
*/
|
|
2720
|
+
export const ERR_ENCRYPTED: string;
|
|
2721
|
+
/**
|
|
2722
|
+
* Unsupported encryption error
|
|
2723
|
+
*/
|
|
2724
|
+
export const ERR_UNSUPPORTED_ENCRYPTION: string;
|
|
2725
|
+
/**
|
|
2726
|
+
* Unsupported compression error
|
|
2727
|
+
*/
|
|
2728
|
+
export const ERR_UNSUPPORTED_COMPRESSION: string;
|
|
2729
|
+
/**
|
|
2730
|
+
* Invalid signature error
|
|
2731
|
+
*/
|
|
2732
|
+
export const ERR_INVALID_SIGNATURE: string;
|
|
2733
|
+
/**
|
|
2734
|
+
* Invalid uncompressed size error
|
|
2735
|
+
*/
|
|
2736
|
+
export const ERR_INVALID_UNCOMPRESSED_SIZE: string;
|
|
2737
|
+
/**
|
|
2738
|
+
* Invalid compressed data error
|
|
2739
|
+
*/
|
|
2740
|
+
export const ERR_INVALID_COMPRESSED_DATA: string;
|
|
2741
|
+
/**
|
|
2742
|
+
* Invalid password error
|
|
2743
|
+
*/
|
|
2744
|
+
export const ERR_INVALID_PASSWORD: string;
|
|
2745
|
+
/**
|
|
2746
|
+
* Duplicate entry error
|
|
2747
|
+
*/
|
|
2748
|
+
export const ERR_DUPLICATED_NAME: string;
|
|
2749
|
+
/**
|
|
2750
|
+
* Invalid comment error
|
|
2751
|
+
*/
|
|
2752
|
+
export const ERR_INVALID_COMMENT: string;
|
|
2753
|
+
/**
|
|
2754
|
+
* Invalid entry name error
|
|
2755
|
+
*/
|
|
2756
|
+
export const ERR_INVALID_ENTRY_NAME: string;
|
|
2757
|
+
/**
|
|
2758
|
+
* Invalid entry comment error
|
|
2759
|
+
*/
|
|
2760
|
+
export const ERR_INVALID_ENTRY_COMMENT: string;
|
|
2761
|
+
/**
|
|
2762
|
+
* Invalid version error
|
|
2763
|
+
*/
|
|
2764
|
+
export const ERR_INVALID_VERSION: string;
|
|
2765
|
+
/**
|
|
2766
|
+
* Invalid extra field type error
|
|
2767
|
+
*/
|
|
2768
|
+
export const ERR_INVALID_EXTRAFIELD_TYPE: string;
|
|
2769
|
+
/**
|
|
2770
|
+
* Invalid extra field data error
|
|
2771
|
+
*/
|
|
2772
|
+
export const ERR_INVALID_EXTRAFIELD_DATA: string;
|
|
2773
|
+
/**
|
|
2774
|
+
* Invalid encryption strength error
|
|
2775
|
+
*/
|
|
2776
|
+
export const ERR_INVALID_ENCRYPTION_STRENGTH: string;
|
|
2777
|
+
/**
|
|
2778
|
+
* Invalid format error
|
|
2779
|
+
*/
|
|
2780
|
+
export const ERR_UNSUPPORTED_FORMAT: string;
|
|
2781
|
+
/**
|
|
2782
|
+
* Split zip file error
|
|
2783
|
+
*/
|
|
2784
|
+
export const ERR_SPLIT_ZIP_FILE: string;
|
|
2785
|
+
/**
|
|
2786
|
+
* Overlapping entry error
|
|
2787
|
+
*/
|
|
2788
|
+
export const ERR_OVERLAPPING_ENTRY: string;
|
|
2789
|
+
/**
|
|
2790
|
+
* Ambiguous archive error
|
|
2791
|
+
*
|
|
2792
|
+
* @remarks The thrown error carries a `reason` property describing the ambiguity: `"appended data"`, `"prepended data"`, `"trailing central directory data"`, `"mismatched zip64 end of central directory record"`, or `"duplicate filename"`.
|
|
2793
|
+
*/
|
|
2794
|
+
export const ERR_AMBIGUOUS_ARCHIVE: string;
|
|
2795
|
+
/**
|
|
2796
|
+
* Iteration completed too soon error
|
|
2797
|
+
*/
|
|
2798
|
+
export const ERR_ITERATOR_COMPLETED_TOO_SOON: string;
|
|
2799
|
+
/**
|
|
2800
|
+
* Undefined uncompressed size error
|
|
2801
|
+
*/
|
|
2802
|
+
export const ERR_UNDEFINED_UNCOMPRESSED_SIZE: string;
|
|
2803
|
+
/**
|
|
2804
|
+
* Undefined reader error
|
|
2805
|
+
*/
|
|
2806
|
+
export const ERR_UNDEFINED_READER: string;
|
|
2807
|
+
/**
|
|
2808
|
+
* Writer not initialized error
|
|
2809
|
+
*/
|
|
2810
|
+
export const ERR_WRITER_NOT_INITIALIZED: string;
|
|
2811
|
+
/**
|
|
2812
|
+
* Zip file not empty error
|
|
2813
|
+
*/
|
|
2814
|
+
export const ERR_ZIP_NOT_EMPTY: string;
|