@zip.js/zip.js 2.7.33 → 2.7.35
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 +1 -1
- package/dist/z-worker-fflate.js +1 -1
- package/dist/z-worker-pako.js +1 -1
- package/dist/z-worker.js +1 -1
- package/dist/zip-fs-full.js +171 -87
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +171 -87
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +168 -84
- package/dist/zip-full.min.js +1 -1
- package/dist/zip-no-worker-deflate.min.js +1 -1
- package/dist/zip-no-worker-inflate.min.js +1 -1
- package/dist/zip-no-worker.min.js +1 -1
- package/dist/zip.js +168 -84
- package/dist/zip.min.js +1 -1
- package/index.cjs +171 -87
- package/index.d.ts +131 -9
- package/index.js +5 -3
- package/index.min.js +1 -1
- package/lib/core/codec-pool.js +36 -28
- package/lib/core/codec-worker.js +4 -4
- package/lib/core/io.js +16 -15
- package/lib/core/streams/aes-crypto-stream.js +14 -8
- package/lib/core/streams/common-crypto.js +2 -1
- package/lib/core/util/encode-text.js +3 -1
- package/lib/core/util/stream-codec-shim.js +4 -2
- package/lib/core/zip-fs-core.js +2 -1
- package/lib/core/zip-reader.js +39 -7
- package/lib/core/zip-writer.js +52 -16
- package/lib/z-worker-bootstrap-fflate.js +2 -1
- package/lib/z-worker-inline.js +1 -1
- package/lib/zip-fflate-shim.js +3 -1
- package/lib/zip-fs.js +3 -3
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -242,7 +242,7 @@ declare class SyncCodec {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
/**
|
|
245
|
-
* Represents an
|
|
245
|
+
* Represents an instance used to compress data.
|
|
246
246
|
*/
|
|
247
247
|
declare class ZipDeflate extends SyncCodec {
|
|
248
248
|
/**
|
|
@@ -599,7 +599,7 @@ export class SplitDataWriter implements Initializable, WritableWriter {
|
|
|
599
599
|
/**
|
|
600
600
|
* Creates the {@link SplitDataWriter} instance
|
|
601
601
|
*
|
|
602
|
-
* @param writerGenerator A generator of Writer
|
|
602
|
+
* @param writerGenerator A generator of Writer instances.
|
|
603
603
|
* @param maxSize The maximum size of the data written into {@link Writer} instances (default: 4GB).
|
|
604
604
|
*/
|
|
605
605
|
constructor(
|
|
@@ -616,6 +616,40 @@ export class SplitDataWriter implements Initializable, WritableWriter {
|
|
|
616
616
|
*/
|
|
617
617
|
export class Uint8ArrayWriter extends Writer<Uint8Array> {}
|
|
618
618
|
|
|
619
|
+
/**
|
|
620
|
+
* Represents an instance used to create an unzipped stream.
|
|
621
|
+
*
|
|
622
|
+
* @example
|
|
623
|
+
* This example will take a zip file, decompress it and then recompress each file in it, saving it to disk.
|
|
624
|
+
* ```
|
|
625
|
+
* for await (const entry of (await fetch(urlToZippedFile)).body.pipeThrough(new ZipWriterStream()))
|
|
626
|
+
* if (entry.readable) {
|
|
627
|
+
* console.log(entry.filename)
|
|
628
|
+
* entry.readable
|
|
629
|
+
* .pipeThrough(ZipReaderStream().transform(entry.filename))
|
|
630
|
+
* .pipeTo((await Deno.create(entry.filename + '.zip')).writable)
|
|
631
|
+
* }
|
|
632
|
+
* ```
|
|
633
|
+
*/
|
|
634
|
+
export class ZipReaderStream<T> {
|
|
635
|
+
/**
|
|
636
|
+
* Creates the stream.
|
|
637
|
+
*
|
|
638
|
+
* @param options The options.
|
|
639
|
+
*/
|
|
640
|
+
constructor (options?: ZipReaderConstructorOptions);
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* The readable stream.
|
|
644
|
+
*/
|
|
645
|
+
readable: ReadableStream<Omit<Entry, 'getData'> & { readable?: ReadableStream<Uint8Array>; }>;
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* The writable stream.
|
|
649
|
+
*/
|
|
650
|
+
writable: WritableStream<T>;
|
|
651
|
+
}
|
|
652
|
+
|
|
619
653
|
/**
|
|
620
654
|
* Represents an instance used to read a zip file.
|
|
621
655
|
*
|
|
@@ -688,7 +722,7 @@ export class ZipReader<Type> {
|
|
|
688
722
|
* Returns a generator used to iterate on all the entries in the zip file
|
|
689
723
|
*
|
|
690
724
|
* @param options The options.
|
|
691
|
-
* @returns An
|
|
725
|
+
* @returns An asynchronous generator of {@link Entry} instances.
|
|
692
726
|
*/
|
|
693
727
|
getEntriesGenerator(
|
|
694
728
|
options?: ZipReaderGetEntriesOptions,
|
|
@@ -764,6 +798,10 @@ interface ZipReaderOptions {
|
|
|
764
798
|
* The password used to decrypt the content of the entry.
|
|
765
799
|
*/
|
|
766
800
|
password?: string;
|
|
801
|
+
/**
|
|
802
|
+
* The password used to encrypt the content of the entry (raw).
|
|
803
|
+
*/
|
|
804
|
+
rawPassword?: Uint8Array;
|
|
767
805
|
/**
|
|
768
806
|
* The `AbortSignal` instance used to cancel the decompression.
|
|
769
807
|
*/
|
|
@@ -943,6 +981,86 @@ interface EntryGetDataOptions
|
|
|
943
981
|
interface EntryGetDataCheckPasswordOptions
|
|
944
982
|
extends EntryGetDataOptions, ZipReaderCheckPasswordOptions {}
|
|
945
983
|
|
|
984
|
+
/**
|
|
985
|
+
* Represents an instance used to create a zipped stream.
|
|
986
|
+
*
|
|
987
|
+
* @example
|
|
988
|
+
* This example creates a zipped file called numbers.txt.zip containing the numbers 0 - 1000 each on their own line.
|
|
989
|
+
* ```
|
|
990
|
+
* const readable = ReadableStream.from((function* () {
|
|
991
|
+
* for (let i = 0; i < 1000; ++i)
|
|
992
|
+
* yield i + '\n'
|
|
993
|
+
* })())
|
|
994
|
+
*
|
|
995
|
+
* readable
|
|
996
|
+
* .pipeThrough(new ZipWriterStream().transform('numbers.txt'))
|
|
997
|
+
* .pipeTo((await Deno.create('numbers.txt.zip')).writable)
|
|
998
|
+
* ```
|
|
999
|
+
*
|
|
1000
|
+
* @example
|
|
1001
|
+
* This example creates a zipped file called Archive.zip containing two files called numbers.txt and letters.txt
|
|
1002
|
+
* ```
|
|
1003
|
+
* const readable1 = ReadableStream.from((function* () {
|
|
1004
|
+
* for (let i = 0; i < 1000; ++i)
|
|
1005
|
+
* yield i + '\n'
|
|
1006
|
+
* })())
|
|
1007
|
+
* const readable2 = ReadableStream.from((function* () {
|
|
1008
|
+
* const letters = 'abcdefghijklmnopqrstuvwxyz'.split('')
|
|
1009
|
+
* while (letters.length)
|
|
1010
|
+
* yield letters.shift() + '\n'
|
|
1011
|
+
* })())
|
|
1012
|
+
*
|
|
1013
|
+
* const zipper = new ZipWriterStream()
|
|
1014
|
+
* zipper.readable.pipeTo((await Deno.create('Archive.zip')).writable)
|
|
1015
|
+
* readable1.pipeTo(zipper.writable('numbers.txt'))
|
|
1016
|
+
* readable2.pipeTo(zipper.writable('letters.txt'))
|
|
1017
|
+
* zipper.close()
|
|
1018
|
+
* ```
|
|
1019
|
+
*/
|
|
1020
|
+
export class ZipWriterStream {
|
|
1021
|
+
/**
|
|
1022
|
+
* Creates the stream.
|
|
1023
|
+
*
|
|
1024
|
+
* @param options The options.
|
|
1025
|
+
*/
|
|
1026
|
+
constructor (options?: ZipWriterConstructorOptions);
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* The readable stream.
|
|
1030
|
+
*/
|
|
1031
|
+
readable: ReadableStream<Uint8Array>;
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* The ZipWriter property.
|
|
1035
|
+
*/
|
|
1036
|
+
zipWriter: ZipWriter<unknown>
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Returns an object containing a readable and writable property for the .pipeThrough method
|
|
1040
|
+
*
|
|
1041
|
+
* @param path The name of the stream when unzipped.
|
|
1042
|
+
* @returns An object containing readable and writable properties
|
|
1043
|
+
*/
|
|
1044
|
+
transform<T>(path: string): { readable: ReadableStream<T>, writable: WritableStream<T>; };
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* Returns a WritableStream for the .pipeTo method
|
|
1048
|
+
*
|
|
1049
|
+
* @param path The directory path of where the stream should exist in the zipped stream.
|
|
1050
|
+
* @returns A WritableStream.
|
|
1051
|
+
*/
|
|
1052
|
+
writable<T>(path: string): WritableStream<T>;
|
|
1053
|
+
|
|
1054
|
+
/**
|
|
1055
|
+
* Writes the entries directory, writes the global comment, and returns the content of the zipped file.
|
|
1056
|
+
*
|
|
1057
|
+
* @param comment The global comment of the zip file.
|
|
1058
|
+
* @param options The options.
|
|
1059
|
+
* @returns The content of the zip file.
|
|
1060
|
+
*/
|
|
1061
|
+
close(comment?: Uint8Array, options?: ZipWriterCloseOptions): Promise<unknown>;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
946
1064
|
/**
|
|
947
1065
|
* Represents an instance used to create a zip file.
|
|
948
1066
|
*
|
|
@@ -1103,6 +1221,10 @@ interface ZipWriterConstructorOptions {
|
|
|
1103
1221
|
* The password used to encrypt the content of the entry.
|
|
1104
1222
|
*/
|
|
1105
1223
|
password?: string;
|
|
1224
|
+
/**
|
|
1225
|
+
* The password used to encrypt the content of the entry (raw).
|
|
1226
|
+
*/
|
|
1227
|
+
rawPassword?: Uint8Array;
|
|
1106
1228
|
/**
|
|
1107
1229
|
* The encryption strength (AES).
|
|
1108
1230
|
*
|
|
@@ -1201,7 +1323,7 @@ interface ZipWriterConstructorOptions {
|
|
|
1201
1323
|
supportZip64SplitFile?: boolean;
|
|
1202
1324
|
/**
|
|
1203
1325
|
* `true`to produce zip files compatible with the USDZ specification.
|
|
1204
|
-
*
|
|
1326
|
+
*
|
|
1205
1327
|
* @defaultValue false
|
|
1206
1328
|
*/
|
|
1207
1329
|
usdz?: boolean;
|
|
@@ -1316,7 +1438,7 @@ declare class ZipEntry {
|
|
|
1316
1438
|
/**
|
|
1317
1439
|
* Set the name of the entry
|
|
1318
1440
|
*
|
|
1319
|
-
* @param name The new name of the
|
|
1441
|
+
* @param name The new name of the entry.
|
|
1320
1442
|
*/
|
|
1321
1443
|
rename(name: string): void;
|
|
1322
1444
|
}
|
|
@@ -1479,7 +1601,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
1479
1601
|
options?: ZipWriterAddDataOptions,
|
|
1480
1602
|
): ZipFileEntry<string, string>;
|
|
1481
1603
|
/**
|
|
1482
|
-
* Adds
|
|
1604
|
+
* Adds a entry entry with content provided as a `Blob` instance
|
|
1483
1605
|
*
|
|
1484
1606
|
* @param name The relative filename of the entry.
|
|
1485
1607
|
* @param blob The `Blob` instance.
|
|
@@ -1492,7 +1614,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
1492
1614
|
options?: ZipWriterAddDataOptions,
|
|
1493
1615
|
): ZipFileEntry<Blob, Blob>;
|
|
1494
1616
|
/**
|
|
1495
|
-
* Adds
|
|
1617
|
+
* Adds a entry entry with content provided as a Data URI `string` encoded in Base64
|
|
1496
1618
|
*
|
|
1497
1619
|
* @param name The relative filename of the entry.
|
|
1498
1620
|
* @param dataURI The Data URI `string` encoded in Base64.
|
|
@@ -1531,7 +1653,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
1531
1653
|
options?: HttpOptions & ZipWriterAddDataOptions,
|
|
1532
1654
|
): ZipFileEntry<string, void>;
|
|
1533
1655
|
/**
|
|
1534
|
-
* Adds
|
|
1656
|
+
* Adds a entry entry with content provided via a `ReadableStream` instance
|
|
1535
1657
|
*
|
|
1536
1658
|
* @param name The relative filename of the entry.
|
|
1537
1659
|
* @param readable The `ReadableStream` instance.
|
|
@@ -1573,7 +1695,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
1573
1695
|
* @returns A promise resolving to an array of {@link ZipFileEntry} or a {@link ZipDirectoryEntry} instances.
|
|
1574
1696
|
*/
|
|
1575
1697
|
addFileSystemHandle(
|
|
1576
|
-
|
|
1698
|
+
fileSystemHandle: FileSystemHandle,
|
|
1577
1699
|
options?: ZipWriterAddDataOptions,
|
|
1578
1700
|
): Promise<ZipEntry[]>;
|
|
1579
1701
|
/**
|
package/index.js
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
1. Redistributions of source code must retain the above copyright notice,
|
|
10
10
|
this list of conditions and the following disclaimer.
|
|
11
11
|
|
|
12
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
-
notice, this list of conditions and the following disclaimer in
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
notice, this list of conditions and the following disclaimer in
|
|
14
14
|
the documentation and/or other materials provided with the distribution.
|
|
15
15
|
|
|
16
16
|
3. The names of the authors may not be used to endorse or promote products
|
|
@@ -42,6 +42,8 @@ export {
|
|
|
42
42
|
initShimAsyncCodec,
|
|
43
43
|
ZipReader,
|
|
44
44
|
ZipWriter,
|
|
45
|
+
ZipReaderStream,
|
|
46
|
+
ZipWriterStream,
|
|
45
47
|
Reader,
|
|
46
48
|
Writer,
|
|
47
49
|
TextReader,
|
|
@@ -83,4 +85,4 @@ export {
|
|
|
83
85
|
ERR_SPLIT_ZIP_FILE,
|
|
84
86
|
ERR_ITERATOR_COMPLETED_TOO_SOON
|
|
85
87
|
} from "./lib/zip-fs.js";
|
|
86
|
-
export { getMimeType, terminateWorkers };
|
|
88
|
+
export { getMimeType, terminateWorkers };
|