zip-writer 1.0.1 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +427 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -0
- package/dist/constants.js.map +1 -1
- package/dist/{crc.d.ts → crc-browser.d.ts} +1 -1
- package/dist/crc-browser.d.ts.map +1 -0
- package/dist/{crc.js → crc-browser.js} +22 -2
- package/dist/crc-browser.js.map +1 -0
- package/dist/crc-node.d.ts +2 -0
- package/dist/crc-node.d.ts.map +1 -0
- package/dist/crc-node.js +3 -0
- package/dist/crc-node.js.map +1 -0
- package/dist/index.d.ts +44 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -11
- package/dist/index.js.map +1 -1
- package/dist/utils.d.ts +11 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +16 -0
- package/dist/utils.js.map +1 -1
- package/dist/write-central-directory.d.ts.map +1 -1
- package/dist/write-central-directory.js +157 -202
- package/dist/write-central-directory.js.map +1 -1
- package/dist/write-entry.d.ts +5 -1
- package/dist/write-entry.d.ts.map +1 -1
- package/dist/write-entry.js +54 -68
- package/dist/write-entry.js.map +1 -1
- package/package.json +21 -3
- package/dist/crc-lookup.d.ts +0 -6
- package/dist/crc-lookup.d.ts.map +0 -1
- package/dist/crc-lookup.js +0 -22
- package/dist/crc-lookup.js.map +0 -1
- package/dist/crc.d.ts.map +0 -1
- package/dist/crc.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
# zip-writable
|
|
2
|
+
|
|
3
|
+
A modern streaming ZIP archive writer for JavaScript that uses the
|
|
4
|
+
[Web Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API)
|
|
5
|
+
and
|
|
6
|
+
[Compression Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Compression_Streams_API).
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Streaming API** - Write ZIP archives using Web Streams
|
|
11
|
+
- **Memory efficient** - Process large files without loading them entirely into
|
|
12
|
+
memory
|
|
13
|
+
- **ZIP64 support** - Automatic handling of large files and archives
|
|
14
|
+
- **Modern JavaScript** - Built with TypeScript, uses native Web Streams API
|
|
15
|
+
- **Flexible** - Reorder, rename, or remove entries before finalizing
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install zip-writable
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Basic Usage
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { ZipWriter } from "zip-writable";
|
|
27
|
+
|
|
28
|
+
const zipWriter = new ZipWriter();
|
|
29
|
+
|
|
30
|
+
// Pipe the ZIP output somewhere
|
|
31
|
+
zipWriter.readable.pipeTo(writableStream);
|
|
32
|
+
|
|
33
|
+
// Add entries to the ZIP
|
|
34
|
+
const entryWriter = zipWriter.createEntryStream({ name: "hello.txt" });
|
|
35
|
+
const writer = entryWriter.writable.getWriter();
|
|
36
|
+
await writer.write(new TextEncoder().encode("Hello, World!"));
|
|
37
|
+
await writer.close();
|
|
38
|
+
|
|
39
|
+
// Get entry info after writing
|
|
40
|
+
const info = await entryWriter.getEntryInfo();
|
|
41
|
+
console.log(info);
|
|
42
|
+
|
|
43
|
+
// Finalize the ZIP archive
|
|
44
|
+
await zipWriter.finalize();
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## API Reference
|
|
48
|
+
|
|
49
|
+
### `ZipWriter`
|
|
50
|
+
|
|
51
|
+
The main class for creating ZIP archives.
|
|
52
|
+
|
|
53
|
+
#### Constructor
|
|
54
|
+
|
|
55
|
+
##### `new ZipWriter(options?)`
|
|
56
|
+
|
|
57
|
+
**Parameters:**
|
|
58
|
+
|
|
59
|
+
- `options.crc32?: (data: Uint8Array, value?: number) => number` - Optional
|
|
60
|
+
CRC32 function to use. Defaults to `zlib.crc32` on Node.js and a pure
|
|
61
|
+
JavaScript implementation in browsers.
|
|
62
|
+
|
|
63
|
+
#### Properties
|
|
64
|
+
|
|
65
|
+
##### `readable: ReadableStream<Uint8Array>`
|
|
66
|
+
|
|
67
|
+
The readable stream containing the ZIP archive data. Pipe this to a file, HTTP
|
|
68
|
+
response, or any other writable destination.
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
// Save to file (Node.js with fs/promises)
|
|
72
|
+
import { createWriteStream } from "fs";
|
|
73
|
+
import { Writable } from "stream";
|
|
74
|
+
|
|
75
|
+
zipWriter.readable.pipeTo(Writable.toWeb(createWriteStream("archive.zip")));
|
|
76
|
+
|
|
77
|
+
// Send as HTTP response (in a web server)
|
|
78
|
+
return new Response(zipWriter.readable, {
|
|
79
|
+
headers: {
|
|
80
|
+
"Content-Type": "application/zip",
|
|
81
|
+
"Content-Disposition": 'attachment; filename="archive.zip"',
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
##### `entries: ReadonlyArray<Readonly<EntryInfo>>`
|
|
87
|
+
|
|
88
|
+
Array of all entries that have been written to the archive. Each entry contains
|
|
89
|
+
metadata like size, CRC32, compression info, etc.
|
|
90
|
+
|
|
91
|
+
#### Methods
|
|
92
|
+
|
|
93
|
+
##### `createEntry(data: Uint8Array, options: EntryOptions): Promise<EntryInfo>`
|
|
94
|
+
|
|
95
|
+
Convenience method to add a buffer as an entry to the zip archive. Returns a
|
|
96
|
+
promise that resolves to the entry info once written. For more efficient
|
|
97
|
+
streaming writes, use `createEntryStream()`.
|
|
98
|
+
|
|
99
|
+
**Parameters:**
|
|
100
|
+
|
|
101
|
+
- `data: Uint8Array` - Entry data to write
|
|
102
|
+
- `options.name: string` - Entry name including internal path (required)
|
|
103
|
+
- `options.comment?: string` - Entry comment
|
|
104
|
+
- `options.date?: Date` - Entry date (defaults to current date)
|
|
105
|
+
- `options.mode?: number` - Entry permissions (Unix-style mode)
|
|
106
|
+
- `options.store?: boolean` - Set to `true` to disable compression (defaults to
|
|
107
|
+
`false`, using DEFLATE compression)
|
|
108
|
+
|
|
109
|
+
**Example:**
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
const data = new TextEncoder().encode("Hello, World!");
|
|
113
|
+
const entryInfo = await zipWriter.createEntry(data, { name: "hello.txt" });
|
|
114
|
+
console.log(entryInfo);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
##### `createEntryStream(options: EntryOptions): EntryWriter`
|
|
118
|
+
|
|
119
|
+
Create a new entry in the ZIP archive. Returns an `EntryWriter` that you can
|
|
120
|
+
write data to via streams.
|
|
121
|
+
|
|
122
|
+
**Parameters:**
|
|
123
|
+
|
|
124
|
+
- `options.name: string` - Entry name including internal path (required)
|
|
125
|
+
- `options.comment?: string` - Entry comment
|
|
126
|
+
- `options.date?: Date` - Entry date (defaults to current date)
|
|
127
|
+
- `options.mode?: number` - Entry permissions (Unix-style mode)
|
|
128
|
+
- `options.store?: boolean` - Set to `true` to disable compression (defaults to
|
|
129
|
+
`false`, using DEFLATE compression)
|
|
130
|
+
|
|
131
|
+
**Examples:**
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
// Simple text file
|
|
135
|
+
const entry = zipWriter.createEntryStream({ name: "readme.txt" });
|
|
136
|
+
const writer = entry.writable.getWriter();
|
|
137
|
+
await writer.write(new TextEncoder().encode("Hello!"));
|
|
138
|
+
await writer.close();
|
|
139
|
+
|
|
140
|
+
// Stream a fetch response
|
|
141
|
+
const response = await fetch(imageUrl);
|
|
142
|
+
response.body.pipeTo(
|
|
143
|
+
zipWriter.createEntryStream({ name: "images/photo.jpg" }).writable,
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
// With custom date and permissions
|
|
147
|
+
zipWriter.createEntryStream({
|
|
148
|
+
name: "script.sh",
|
|
149
|
+
date: new Date("2024-01-01"),
|
|
150
|
+
mode: 0o755, // executable
|
|
151
|
+
}).writable;
|
|
152
|
+
|
|
153
|
+
// Disable compression for already-compressed files
|
|
154
|
+
zipWriter.createEntryStream({
|
|
155
|
+
name: "video.mp4",
|
|
156
|
+
store: true, // no compression
|
|
157
|
+
}).writable;
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
##### `onceQueueEmpty(): Promise<void>`
|
|
161
|
+
|
|
162
|
+
Wait until all currently queued entries have been written. Useful when you need
|
|
163
|
+
to ensure entries are complete before continuing.
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
// Add multiple entries
|
|
167
|
+
zipWriter.createEntryStream({ name: "file1.txt" }).writable;
|
|
168
|
+
zipWriter.createEntryStream({ name: "file2.txt" }).writable;
|
|
169
|
+
|
|
170
|
+
// Wait for all to complete
|
|
171
|
+
await zipWriter.onceQueueEmpty();
|
|
172
|
+
console.log(`Wrote ${zipWriter.entries.length} entries`);
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
##### `finalize(options?): Promise<{ zip64: boolean, uncompressedEntriesSize: bigint, compressedEntriesSize: bigint, fileSize: bigint }>`
|
|
176
|
+
|
|
177
|
+
Finalize the ZIP archive by writing the central directory and end of central
|
|
178
|
+
directory records. This must be called after all entries have been added. This
|
|
179
|
+
will await any pending entries to finish writing before finalizing.
|
|
180
|
+
|
|
181
|
+
**Parameters:**
|
|
182
|
+
|
|
183
|
+
- `options.entries?: ReadonlyArray<Readonly<EntryInfo>>` - (Advanced) Override
|
|
184
|
+
the entries to write in the central directory. This can be used to reorder,
|
|
185
|
+
remove, or rename entries before finalizing the archive. You cannot change the
|
|
186
|
+
offset, CRC32, compressed size, or uncompressed size of entries - only the
|
|
187
|
+
name, comment, date, and order.
|
|
188
|
+
|
|
189
|
+
**Returns:**
|
|
190
|
+
|
|
191
|
+
- `zip64: boolean` - Whether the archive uses ZIP64 format
|
|
192
|
+
- `uncompressedEntriesSize: bigint` - Total uncompressed size of all entries
|
|
193
|
+
- `compressedEntriesSize: bigint` - Total compressed size of all entries
|
|
194
|
+
- `fileSize: bigint` - Total size of the ZIP file
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
const result = await zipWriter.finalize();
|
|
198
|
+
console.log(`Created ${result.zip64 ? "ZIP64" : "standard"} archive`);
|
|
199
|
+
console.log(`File size: ${result.fileSize} bytes`);
|
|
200
|
+
console.log(
|
|
201
|
+
`Compression ratio: ${Number(result.compressedEntriesSize) / Number(result.uncompressedEntriesSize)}`,
|
|
202
|
+
);
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**Example with entries option:**
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
// Wait for all entries to be written
|
|
209
|
+
await zipWriter.onceQueueEmpty();
|
|
210
|
+
|
|
211
|
+
// Get current entries and modify them
|
|
212
|
+
const entries = [...zipWriter.entries];
|
|
213
|
+
|
|
214
|
+
// Remove an entry
|
|
215
|
+
const filtered = entries.filter((e) => e.name !== "temp.txt");
|
|
216
|
+
|
|
217
|
+
// Rename entries
|
|
218
|
+
const renamed = entries.map((e) => ({
|
|
219
|
+
...e,
|
|
220
|
+
name: e.name.replace(/^old\//, "new/"),
|
|
221
|
+
}));
|
|
222
|
+
|
|
223
|
+
// Sort entries alphabetically
|
|
224
|
+
const sorted = [...entries].sort((a, b) => a.name.localeCompare(b.name));
|
|
225
|
+
|
|
226
|
+
// Finalize with modified entries
|
|
227
|
+
await zipWriter.finalize({ entries: sorted });
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### `EntryWriter`
|
|
231
|
+
|
|
232
|
+
Returned by `ZipWriter.createEntryStream()`. Provides a writable stream to write
|
|
233
|
+
entry data.
|
|
234
|
+
|
|
235
|
+
#### Properties
|
|
236
|
+
|
|
237
|
+
##### `writable: WritableStream<Uint8Array>`
|
|
238
|
+
|
|
239
|
+
The writable stream to write entry data to. Close this stream when done writing.
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
const entryWriter = zipWriter.createEntryStream({ name: "data.txt" });
|
|
243
|
+
|
|
244
|
+
// Using a writer
|
|
245
|
+
const writer = entryWriter.writable.getWriter();
|
|
246
|
+
await writer.write(new TextEncoder().encode("chunk 1"));
|
|
247
|
+
await writer.write(new TextEncoder().encode("chunk 2"));
|
|
248
|
+
await writer.close();
|
|
249
|
+
|
|
250
|
+
// Using pipeTo
|
|
251
|
+
someReadableStream.pipeTo(entryWriter.writable);
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
#### Methods
|
|
255
|
+
|
|
256
|
+
##### `getEntryInfo(): Promise<EntryInfo>`
|
|
257
|
+
|
|
258
|
+
Get entry info. Resolves once all data has been written to the ZIP stream.
|
|
259
|
+
|
|
260
|
+
**Returns `EntryInfo`:**
|
|
261
|
+
|
|
262
|
+
- `name: string` - Entry name
|
|
263
|
+
- `comment?: string` - Entry comment
|
|
264
|
+
- `date?: Date` - Entry date
|
|
265
|
+
- `mode?: number` - Entry permissions
|
|
266
|
+
- `store?: boolean` - Whether compression was disabled
|
|
267
|
+
- `startOffset: bigint | number` - Byte offset in the archive
|
|
268
|
+
- `crc32: number` - CRC32 checksum
|
|
269
|
+
- `uncompressedSize: bigint | number` - Uncompressed size in bytes
|
|
270
|
+
- `compressedSize: bigint | number` - Compressed size in bytes
|
|
271
|
+
- `zip64: boolean` - Whether this entry uses ZIP64 format
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
const entryWriter = zipWriter.createEntryStream({ name: "test.txt" });
|
|
275
|
+
await someStream.pipeTo(entryWriter.writable);
|
|
276
|
+
|
|
277
|
+
const info = await entryWriter.getEntryInfo();
|
|
278
|
+
console.log(
|
|
279
|
+
`Wrote ${info.name}: ${info.uncompressedSize} bytes (compressed to ${info.compressedSize})`,
|
|
280
|
+
);
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Complete Example
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
import { ZipWriter } from "zip-writable";
|
|
287
|
+
import { createWriteStream } from "fs";
|
|
288
|
+
import { Writable } from "stream";
|
|
289
|
+
|
|
290
|
+
async function createZip() {
|
|
291
|
+
const zipWriter = new ZipWriter();
|
|
292
|
+
|
|
293
|
+
// Pipe output to file
|
|
294
|
+
const fileStream = Writable.toWeb(createWriteStream("output.zip"));
|
|
295
|
+
zipWriter.readable.pipeTo(fileStream);
|
|
296
|
+
|
|
297
|
+
// Add a text file using createEntry
|
|
298
|
+
const data1 = new TextEncoder().encode("This is a readme");
|
|
299
|
+
await zipWriter.createEntry(data1, { name: "readme.txt" });
|
|
300
|
+
|
|
301
|
+
// Add files from URLs using createEntryStream
|
|
302
|
+
const imageResponse = await fetch("https://example.com/image.png");
|
|
303
|
+
await imageResponse.body.pipeTo(
|
|
304
|
+
zipWriter.createEntryStream({ name: "images/photo.png" }).writable,
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
// Add a JSON file using createEntry
|
|
308
|
+
const data = { hello: "world" };
|
|
309
|
+
const jsonData = new TextEncoder().encode(JSON.stringify(data, null, 2));
|
|
310
|
+
await zipWriter.createEntry(jsonData, { name: "data.json" });
|
|
311
|
+
|
|
312
|
+
// Wait for all entries and check results
|
|
313
|
+
await zipWriter.onceQueueEmpty();
|
|
314
|
+
console.log(`Added ${zipWriter.entries.length} entries`);
|
|
315
|
+
|
|
316
|
+
// Finalize the archive
|
|
317
|
+
const result = await zipWriter.finalize();
|
|
318
|
+
console.log(`Created archive: ${result.fileSize} bytes`);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
createZip().catch(console.error);
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Browser Usage
|
|
325
|
+
|
|
326
|
+
```ts
|
|
327
|
+
// Create a ZIP and trigger download
|
|
328
|
+
const zipWriter = new ZipWriter();
|
|
329
|
+
|
|
330
|
+
// Add entries...
|
|
331
|
+
const data = new TextEncoder().encode("Hello");
|
|
332
|
+
zipWriter
|
|
333
|
+
.createEntry(data, { name: "file.txt" })
|
|
334
|
+
.then(() => zipWriter.finalize());
|
|
335
|
+
|
|
336
|
+
// Create download link
|
|
337
|
+
const blob = await new Response(zipWriter.readable).blob();
|
|
338
|
+
const url = URL.createObjectURL(blob);
|
|
339
|
+
const a = document.createElement("a");
|
|
340
|
+
a.href = url;
|
|
341
|
+
a.download = "archive.zip";
|
|
342
|
+
a.click();
|
|
343
|
+
URL.revokeObjectURL(url);
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## Benchmarks
|
|
347
|
+
|
|
348
|
+
Run using `npm run bench`. On a MacBook Pro (M2 Pro, 2023), Node.js 20.19.0:
|
|
349
|
+
|
|
350
|
+
### Small files (10 × 10KB)
|
|
351
|
+
|
|
352
|
+
| Library | ops/sec | Relative Speed |
|
|
353
|
+
| ----------------------------- | ------- | -------------- |
|
|
354
|
+
| zip-writable (@node-rs/crc32) | 721.94 | **fastest** |
|
|
355
|
+
| zip-writable | 674.57 | 1.07x slower |
|
|
356
|
+
| zip-writable (js crc32) | 659.90 | 1.09x slower |
|
|
357
|
+
| fflate | 553.00 | 1.31x slower |
|
|
358
|
+
| archiver | 338.14 | 2.14x slower |
|
|
359
|
+
| @zip.js/zip.js | 279.19 | 2.59x slower |
|
|
360
|
+
|
|
361
|
+
### Medium files (100 × 100KB)
|
|
362
|
+
|
|
363
|
+
| Library | ops/sec | Relative Speed |
|
|
364
|
+
| ----------------------------- | ------- | -------------- |
|
|
365
|
+
| zip-writable | 23.91 | **fastest** |
|
|
366
|
+
| zip-writable (@node-rs/crc32) | 22.91 | 1.04x slower |
|
|
367
|
+
| zip-writable (js crc32) | 18.93 | 1.26x slower |
|
|
368
|
+
| archiver | 18.10 | 1.32x slower |
|
|
369
|
+
| @zip.js/zip.js | 11.65 | 2.05x slower |
|
|
370
|
+
| fflate | 10.27 | 2.33x slower |
|
|
371
|
+
|
|
372
|
+
### Large files (5 × 10MB)
|
|
373
|
+
|
|
374
|
+
| Library | ops/sec | Relative Speed |
|
|
375
|
+
| ----------------------------- | ------- | -------------- |
|
|
376
|
+
| zip-writable | 7.22 | **fastest** |
|
|
377
|
+
| zip-writable (@node-rs/crc32) | 6.78 | 1.06x slower |
|
|
378
|
+
| archiver | 5.65 | 1.28x slower |
|
|
379
|
+
| zip-writable (js crc32) | 4.82 | 1.50x slower |
|
|
380
|
+
| fflate | 4.20 | 1.72x slower |
|
|
381
|
+
| @zip.js/zip.js | 4.00 | 1.81x slower |
|
|
382
|
+
|
|
383
|
+
### Many files (1000 × 1KB)
|
|
384
|
+
|
|
385
|
+
| Library | ops/sec | Relative Speed |
|
|
386
|
+
| ----------------------------- | ------- | -------------- |
|
|
387
|
+
| fflate | 10.08 | **fastest** |
|
|
388
|
+
| zip-writable | 6.89 | 1.46x slower |
|
|
389
|
+
| zip-writable (@node-rs/crc32) | 5.94 | 1.70x slower |
|
|
390
|
+
| zip-writable (js crc32) | 5.63 | 1.79x slower |
|
|
391
|
+
| archiver | 4.98 | 2.02x slower |
|
|
392
|
+
| @zip.js/zip.js | 2.93 | 3.44x slower |
|
|
393
|
+
|
|
394
|
+
Note: These benchmarks vary quite a bit, and they aren't an indication that any
|
|
395
|
+
library is "better" than any other. For ZipWriter, these exist as a check to
|
|
396
|
+
ensure that performance isn't significantly worse than other libraries.
|
|
397
|
+
|
|
398
|
+
## ZIP64 Support
|
|
399
|
+
|
|
400
|
+
The library automatically uses ZIP64 format when needed:
|
|
401
|
+
|
|
402
|
+
- Archives with more than 65,535 entries
|
|
403
|
+
- Files larger than 4GB
|
|
404
|
+
- Central directory larger than 4GB
|
|
405
|
+
- Central directory offset greater than 4GB
|
|
406
|
+
|
|
407
|
+
No special configuration is needed - it's handled automatically.
|
|
408
|
+
|
|
409
|
+
## Error Handling
|
|
410
|
+
|
|
411
|
+
```ts
|
|
412
|
+
try {
|
|
413
|
+
const entryWriter = zipWriter.entry({ name: "test.txt" });
|
|
414
|
+
await someStream.pipeTo(entryWriter.writable);
|
|
415
|
+
await entryWriter.getEntryInfo();
|
|
416
|
+
} catch (error) {
|
|
417
|
+
console.error("Failed to write entry:", error);
|
|
418
|
+
// The ZIP stream is aborted on error - cannot add more entries
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
Once an error occurs during entry writing, the ZIP stream is corrupted and
|
|
423
|
+
cannot be recovered. You must create a new `ZipWriter` instance.
|
|
424
|
+
|
|
425
|
+
## License
|
|
426
|
+
|
|
427
|
+
MIT
|
package/dist/constants.d.ts
CHANGED
|
@@ -18,4 +18,8 @@ export declare const EOCD_SIZE = 22;
|
|
|
18
18
|
export declare const EOCD64_SIZE = 56;
|
|
19
19
|
export declare const EOCD64_LOCATOR_SIZE = 20;
|
|
20
20
|
export declare const ZIP64_LIMIT: bigint;
|
|
21
|
+
/** Little-endian for DataView methods */
|
|
22
|
+
export declare const LITTLE_ENDIAN = true;
|
|
23
|
+
/** Big-endian for DataView methods */
|
|
24
|
+
export declare const BIG_ENDIAN = false;
|
|
21
25
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,2BAA2B,aAAa,CAAC;AACtD,eAAO,MAAM,yBAAyB,aAAa,CAAC;AACpD,eAAO,MAAM,2BAA2B,aAAa,CAAC;AACtD,eAAO,MAAM,4BAA4B,aAAa,CAAC;AACvD,eAAO,MAAM,kCAAkC,aAAa,CAAC;AAC7D,eAAO,MAAM,0CAA0C,aAAa,CAAC;AAGrE,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAGvC,eAAO,MAAM,qBAAqB,OAAwB,CAAC;AAG3D,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAC1C,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAG5C,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAChD,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAGtC,eAAO,MAAM,WAAW,QAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,2BAA2B,aAAa,CAAC;AACtD,eAAO,MAAM,yBAAyB,aAAa,CAAC;AACpD,eAAO,MAAM,2BAA2B,aAAa,CAAC;AACtD,eAAO,MAAM,4BAA4B,aAAa,CAAC;AACvD,eAAO,MAAM,kCAAkC,aAAa,CAAC;AAC7D,eAAO,MAAM,0CAA0C,aAAa,CAAC;AAGrE,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAGvC,eAAO,MAAM,qBAAqB,OAAwB,CAAC;AAG3D,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAC1C,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAG5C,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAChD,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAGtC,eAAO,MAAM,WAAW,QAAqB,CAAC;AAE9C,yCAAyC;AACzC,eAAO,MAAM,aAAa,OAAO,CAAC;AAClC,sCAAsC;AACtC,eAAO,MAAM,UAAU,QAAQ,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -24,4 +24,8 @@ export const EOCD64_SIZE = 56;
|
|
|
24
24
|
export const EOCD64_LOCATOR_SIZE = 20;
|
|
25
25
|
// Limits
|
|
26
26
|
export const ZIP64_LIMIT = BigInt(0xffffffff);
|
|
27
|
+
/** Little-endian for DataView methods */
|
|
28
|
+
export const LITTLE_ENDIAN = true;
|
|
29
|
+
/** Big-endian for DataView methods */
|
|
30
|
+
export const BIG_ENDIAN = false;
|
|
27
31
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,MAAM,CAAC,MAAM,2BAA2B,GAAG,UAAU,CAAC,CAAC,eAAe;AACtE,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAAC,CAAC,eAAe;AACpE,MAAM,CAAC,MAAM,2BAA2B,GAAG,UAAU,CAAC,CAAC,eAAe;AACtE,MAAM,CAAC,MAAM,4BAA4B,GAAG,UAAU,CAAC,CAAC,eAAe;AACvE,MAAM,CAAC,MAAM,kCAAkC,GAAG,UAAU,CAAC,CAAC,eAAe;AAC7E,MAAM,CAAC,MAAM,0CAA0C,GAAG,UAAU,CAAC,CAAC,eAAe;AAErF,oBAAoB;AACpB,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC,CAAC,8BAA8B;AACjE,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC,CAAC,cAAc;AACzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC,CAAC,wBAAwB;AAEhE,QAAQ;AACR,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,CAAC,wCAAwC;AAEpG,sBAAsB;AACtB,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAE5C,iBAAiB;AACjB,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC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AAG,CAAC,CAAC;AAE5C,iBAAiB;AACjB,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AACzC,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAChD,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAC7C,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AAC5B,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAC9B,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC,SAAS;AACT,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAE9C,yCAAyC;AACzC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;AAClC,sCAAsC;AACtC,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crc-browser.d.ts","sourceRoot":"","sources":["../src/crc-browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AA8BH;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,EAC7B,KAAK,GAAE,MAAU,GAChB,MAAM,CAgCR"}
|
|
@@ -20,7 +20,27 @@
|
|
|
20
20
|
* misrepresented as being the original software.
|
|
21
21
|
* 3. This notice may not be removed or altered from any source distribution.
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* From https://github.com/holepunchto/crc-universal/blob/main/lookup.js
|
|
25
|
+
* Licensed under Apache-2.0
|
|
26
|
+
*/
|
|
27
|
+
const lookup = new Array(16);
|
|
28
|
+
for (let i = 0; i < 16; i++) {
|
|
29
|
+
lookup[i] = new Uint32Array(0x100);
|
|
30
|
+
}
|
|
31
|
+
for (let i = 0; i <= 0xff; i++) {
|
|
32
|
+
let crc = i;
|
|
33
|
+
for (let j = 0; j < 8; j++) {
|
|
34
|
+
crc = (crc >>> 1) ^ ((crc & 1) * 0xedb88320);
|
|
35
|
+
}
|
|
36
|
+
lookup[0][i] = crc;
|
|
37
|
+
}
|
|
38
|
+
for (let i = 0; i <= 0xff; i++) {
|
|
39
|
+
for (let j = 1; j < 16; j++) {
|
|
40
|
+
lookup[j][i] =
|
|
41
|
+
(lookup[j - 1][i] >>> 8) ^ lookup[0][lookup[j - 1][i] & 0xff];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
24
44
|
/**
|
|
25
45
|
* Computes a 32-bit Cyclic Redundancy Check checksum of data. If value is
|
|
26
46
|
* specified, it is used as the starting value of the checksum, otherwise, 0 is
|
|
@@ -59,4 +79,4 @@ export function crc32(data, value = 0) {
|
|
|
59
79
|
}
|
|
60
80
|
return ~crc >>> 0;
|
|
61
81
|
}
|
|
62
|
-
//# sourceMappingURL=crc.js.map
|
|
82
|
+
//# sourceMappingURL=crc-browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crc-browser.js","sourceRoot":"","sources":["../src/crc-browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;GAGG;AAEH,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,EAAE,CAA+B,CAAC;AAE3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;IAC5B,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;IAC/B,IAAI,GAAG,GAAG,CAAC,CAAC;IAEZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE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C,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crc-node.d.ts","sourceRoot":"","sources":["../src/crc-node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/crc-node.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crc-node.js","sourceRoot":"","sources":["../src/crc-node.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -28,16 +28,40 @@ export type EntryInfoStandard = {
|
|
|
28
28
|
export type EntryInfo = EntryInfoZip64 | EntryInfoStandard;
|
|
29
29
|
export declare class ZipWriter<TIsZip64 extends boolean = false> {
|
|
30
30
|
#private;
|
|
31
|
+
/**
|
|
32
|
+
* @param crc Optional CRC32 function to use. Defaults to zlib.crc32 on Node and a pure JS implementation in browsers.
|
|
33
|
+
*/
|
|
34
|
+
constructor({ crc32, }?: {
|
|
35
|
+
crc32?: (data: Uint8Array<ArrayBuffer>, value?: number) => number;
|
|
36
|
+
});
|
|
31
37
|
get readable(): ReadableStream<ArrayBufferView<ArrayBufferLike>>;
|
|
32
38
|
get entries(): ReadonlyArray<Readonly<EntryInfo>>;
|
|
33
39
|
/**
|
|
34
40
|
* Wait until all currently queued entries have been written.
|
|
35
41
|
*/
|
|
36
42
|
onceQueueEmpty(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Convenience wrapper around `createEntryStream` to write all data at once.
|
|
45
|
+
* Use `createEntryStream` for more efficient streaming writes. Calls to
|
|
46
|
+
* createEntry() will be queued internally and each will resolve once it's
|
|
47
|
+
* written to the archive.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const data = new TextEncoder().encode("Hello, World!");
|
|
52
|
+
* const entryInfo = await zipWriter.createEntry(data, { name: "hello.txt" });
|
|
53
|
+
* console.log(entryInfo);
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @param data Entry data
|
|
57
|
+
* @param options Entry filename, comment, compression method, etc.
|
|
58
|
+
* @returns Entry information once the entry has been written.
|
|
59
|
+
*/
|
|
60
|
+
createEntry(data: Uint8Array<ArrayBuffer>, options: EntryOptions): Promise<EntryInfo>;
|
|
37
61
|
/**
|
|
38
62
|
* Create a new entry in the Zip archive. Use the returned
|
|
39
63
|
* entryWriter.writable to write data to the entry. You can await
|
|
40
|
-
* entryWriter.
|
|
64
|
+
* entryWriter.getEntryInfo() to get the entry info once all data has been written.
|
|
41
65
|
*
|
|
42
66
|
* @example
|
|
43
67
|
* ```ts
|
|
@@ -55,20 +79,30 @@ export declare class ZipWriter<TIsZip64 extends boolean = false> {
|
|
|
55
79
|
* new TextEncoder().encode("Hello, World!")
|
|
56
80
|
* );
|
|
57
81
|
* await writer.close();
|
|
58
|
-
* console.log(await entryWriter.
|
|
82
|
+
* console.log(await entryWriter.getEntryInfo()); // Entry info
|
|
59
83
|
* ```
|
|
60
84
|
*
|
|
61
85
|
* @param options Entry options
|
|
62
86
|
*/
|
|
63
|
-
|
|
87
|
+
createEntryStream(options: EntryOptions): EntryWriter;
|
|
64
88
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
89
|
+
* Finalize the ZIP archive by writing the central directory and end of
|
|
90
|
+
* central directory records. You may not add any more entries after calling
|
|
91
|
+
* this method. This will await any pending entries to finish writing before
|
|
92
|
+
* finalizing.
|
|
93
|
+
*
|
|
94
|
+
* @param options.entries (Advanced) Optionally override the entries to write
|
|
95
|
+
* in the central directory. This can be used to reorder, remove, or rename
|
|
96
|
+
* entries before finalizing the archive, however you cannot add invalid
|
|
97
|
+
* entries, add additional entries, or modify their crc32, offsets or sizes.
|
|
98
|
+
* Use zipWriter.entries or entryWriter.getEntryInfo() to get the current
|
|
99
|
+
* entries for sorting or filtering.
|
|
67
100
|
*
|
|
68
|
-
* @
|
|
101
|
+
* @returns Information about the finalized archive.
|
|
69
102
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
103
|
+
finalize({ entries, }?: {
|
|
104
|
+
entries?: ReadonlyArray<Readonly<EntryInfo>>;
|
|
105
|
+
}): Promise<{
|
|
72
106
|
/** Does the archive use ZIP64 format? */
|
|
73
107
|
zip64: boolean;
|
|
74
108
|
/** Total uncompressed size of all entries */
|
|
@@ -94,11 +128,11 @@ declare class EntryWriter {
|
|
|
94
128
|
* .pipeTo(entryWriter.writable);
|
|
95
129
|
* ```
|
|
96
130
|
*/
|
|
97
|
-
get writable(): WritableStream<
|
|
131
|
+
get writable(): WritableStream<Uint8Array<ArrayBuffer>>;
|
|
98
132
|
/**
|
|
99
133
|
* Get entry info. Resolves once all data has been written to the Zip stream.
|
|
100
134
|
*/
|
|
101
|
-
|
|
135
|
+
getEntryInfo(): Promise<EntryInfo>;
|
|
102
136
|
}
|
|
103
137
|
export {};
|
|
104
138
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB;IACjB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,wBAAwB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,kEAAkE;IAClE,WAAW,EA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