@zip.js/zip.js 2.7.56 → 2.7.58
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/.github/workflows/publish.yml +17 -0
- package/deno.json +1 -1
- package/dist/zip-fs-full.js +46 -20
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +46 -20
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +46 -20
- 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 +46 -20
- package/dist/zip.min.js +1 -1
- package/index-fflate.js +2 -1
- package/index.cjs +46 -20
- package/index.d.ts +55 -47
- package/index.js +2 -1
- package/index.min.js +1 -1
- package/lib/core/constants.js +2 -0
- package/lib/core/io.js +10 -3
- package/lib/core/zip-entry.js +5 -1
- package/lib/core/zip-writer.js +38 -17
- package/package.json +7 -7
package/index.cjs
CHANGED
|
@@ -4278,6 +4278,7 @@ const BITFLAG_LANG_ENCODING_FLAG = 0x0800;
|
|
|
4278
4278
|
const FILE_ATTR_MSDOS_DIR_MASK = 0x10;
|
|
4279
4279
|
const FILE_ATTR_UNIX_DIR_MASK = 0x4000;
|
|
4280
4280
|
const FILE_ATTR_UNIX_EXECUTABLE_MASK = 0o111;
|
|
4281
|
+
const FILE_ATTR_UNIX_DEFAULT_MASK = 0o644;
|
|
4281
4282
|
|
|
4282
4283
|
const VERSION_DEFLATE = 0x14;
|
|
4283
4284
|
const VERSION_ZIP64 = 0x2D;
|
|
@@ -8399,6 +8400,7 @@ function createCodecClass(constructor, constructorOptions, registerDataHandler)
|
|
|
8399
8400
|
const ERR_HTTP_STATUS = "HTTP error ";
|
|
8400
8401
|
const ERR_HTTP_RANGE = "HTTP Range not supported";
|
|
8401
8402
|
const ERR_ITERATOR_COMPLETED_TOO_SOON = "Writer iterator completed too soon";
|
|
8403
|
+
const ERR_WRITER_NOT_INITIALIZED = "Writer not initialized";
|
|
8402
8404
|
|
|
8403
8405
|
const CONTENT_TYPE_TEXT_PLAIN = "text/plain";
|
|
8404
8406
|
const HTTP_HEADER_CONTENT_LENGTH = "Content-Length";
|
|
@@ -8436,8 +8438,10 @@ class Reader extends Stream {
|
|
|
8436
8438
|
async pull(controller) {
|
|
8437
8439
|
const { offset = 0, size, diskNumberStart } = readable;
|
|
8438
8440
|
const { chunkOffset } = this;
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
+
const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
|
|
8442
|
+
const data = await readUint8Array(reader, offset + chunkOffset, dataSize, diskNumberStart);
|
|
8443
|
+
controller.enqueue(data);
|
|
8444
|
+
if ((chunkOffset + chunkSize > size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
|
|
8441
8445
|
controller.close();
|
|
8442
8446
|
} else {
|
|
8443
8447
|
this.chunkOffset += chunkSize;
|
|
@@ -8455,6 +8459,9 @@ class Writer extends Stream {
|
|
|
8455
8459
|
const writer = this;
|
|
8456
8460
|
const writable = new WritableStream({
|
|
8457
8461
|
write(chunk) {
|
|
8462
|
+
if (!writer.initialized) {
|
|
8463
|
+
throw new Error(ERR_WRITER_NOT_INITIALIZED);
|
|
8464
|
+
}
|
|
8458
8465
|
return writer.writeUint8Array(chunk);
|
|
8459
8466
|
}
|
|
8460
8467
|
});
|
|
@@ -9217,12 +9224,14 @@ const PROPERTY_NAME_ENCRYPTED = "encrypted";
|
|
|
9217
9224
|
const PROPERTY_NAME_VERSION = "version";
|
|
9218
9225
|
const PROPERTY_NAME_VERSION_MADE_BY = "versionMadeBy";
|
|
9219
9226
|
const PROPERTY_NAME_ZIPCRYPTO = "zipCrypto";
|
|
9227
|
+
const PROPERTY_NAME_DIRECTORY = "directory";
|
|
9228
|
+
const PROPERTY_NAME_EXECUTABLE = "executable";
|
|
9220
9229
|
|
|
9221
9230
|
const PROPERTY_NAMES = [
|
|
9222
9231
|
PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, PROPERTY_NAME_COMPPRESSED_SIZE, PROPERTY_NAME_UNCOMPPRESSED_SIZE,
|
|
9223
9232
|
PROPERTY_NAME_LAST_MODIFICATION_DATE, PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT,
|
|
9224
9233
|
PROPERTY_NAME_LAST_ACCESS_DATE, PROPERTY_NAME_CREATION_DATE, PROPERTY_NAME_OFFSET, PROPERTY_NAME_DISK_NUMBER_START,
|
|
9225
|
-
PROPERTY_NAME_DISK_NUMBER_START, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_MS_DOS_COMPATIBLE, PROPERTY_NAME_ZIP64, PROPERTY_NAME_ENCRYPTED, PROPERTY_NAME_VERSION, PROPERTY_NAME_VERSION_MADE_BY, PROPERTY_NAME_ZIPCRYPTO,
|
|
9234
|
+
PROPERTY_NAME_DISK_NUMBER_START, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_MS_DOS_COMPATIBLE, PROPERTY_NAME_ZIP64, PROPERTY_NAME_ENCRYPTED, PROPERTY_NAME_VERSION, PROPERTY_NAME_VERSION_MADE_BY, PROPERTY_NAME_ZIPCRYPTO, PROPERTY_NAME_DIRECTORY, PROPERTY_NAME_EXECUTABLE, "bitFlag", "signature", "filenameUTF8", "commentUTF8", "compressionMethod", "extraField", "rawExtraField", "extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment", "extraFieldAES", "extraFieldNTFS", "extraFieldExtendedTimestamp"];
|
|
9226
9235
|
|
|
9227
9236
|
class Entry {
|
|
9228
9237
|
|
|
@@ -10067,10 +10076,37 @@ class ZipWriterStream {
|
|
|
10067
10076
|
|
|
10068
10077
|
async function addFile(zipWriter, name, reader, options) {
|
|
10069
10078
|
name = name.trim();
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10079
|
+
const msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
10080
|
+
const versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? 20 : 768);
|
|
10081
|
+
const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
|
|
10082
|
+
if (versionMadeBy > MAX_16_BITS) {
|
|
10083
|
+
throw new Error(ERR_INVALID_VERSION);
|
|
10084
|
+
}
|
|
10085
|
+
let externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, 0);
|
|
10086
|
+
if (externalFileAttributes === 0) {
|
|
10087
|
+
externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, 0);
|
|
10088
|
+
}
|
|
10089
|
+
if (!options.directory && name.endsWith(DIRECTORY_SIGNATURE)) {
|
|
10090
|
+
options.directory = true;
|
|
10091
|
+
}
|
|
10092
|
+
const directory = getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY);
|
|
10093
|
+
if (directory) {
|
|
10094
|
+
if (!name.endsWith(DIRECTORY_SIGNATURE)) {
|
|
10095
|
+
name += DIRECTORY_SIGNATURE;
|
|
10096
|
+
}
|
|
10097
|
+
if (externalFileAttributes === 0) {
|
|
10098
|
+
if (msDosCompatible) {
|
|
10099
|
+
externalFileAttributes = FILE_ATTR_MSDOS_DIR_MASK;
|
|
10100
|
+
} else {
|
|
10101
|
+
externalFileAttributes = FILE_ATTR_UNIX_DIR_MASK << 16;
|
|
10102
|
+
}
|
|
10103
|
+
}
|
|
10104
|
+
} else if (!msDosCompatible && externalFileAttributes === 0) {
|
|
10105
|
+
if (executable) {
|
|
10106
|
+
externalFileAttributes = (FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_DEFAULT_MASK) << 16;
|
|
10107
|
+
} else {
|
|
10108
|
+
externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
|
|
10109
|
+
}
|
|
10074
10110
|
}
|
|
10075
10111
|
const encode = getOptionValue(zipWriter, options, "encodeText", encodeText);
|
|
10076
10112
|
let rawFilename = encode(name);
|
|
@@ -10092,22 +10128,13 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
10092
10128
|
if (version > MAX_16_BITS) {
|
|
10093
10129
|
throw new Error(ERR_INVALID_VERSION);
|
|
10094
10130
|
}
|
|
10095
|
-
const versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, 20);
|
|
10096
|
-
if (versionMadeBy > MAX_16_BITS) {
|
|
10097
|
-
throw new Error(ERR_INVALID_VERSION);
|
|
10098
|
-
}
|
|
10099
10131
|
const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
|
|
10100
10132
|
const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
10101
10133
|
const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
10102
|
-
const msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE, true);
|
|
10103
10134
|
let internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, 0);
|
|
10104
10135
|
if (internalFileAttributes === 0) {
|
|
10105
10136
|
internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, 0);
|
|
10106
10137
|
}
|
|
10107
|
-
let externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, 0);
|
|
10108
|
-
if (externalFileAttributes === 0) {
|
|
10109
|
-
externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, 0);
|
|
10110
|
-
}
|
|
10111
10138
|
const passThrough = getOptionValue(zipWriter, options, "passThrough");
|
|
10112
10139
|
let password, rawPassword;
|
|
10113
10140
|
if (!passThrough) {
|
|
@@ -10430,6 +10457,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
10430
10457
|
zipCrypto,
|
|
10431
10458
|
dataDescriptor,
|
|
10432
10459
|
directory,
|
|
10460
|
+
executable,
|
|
10433
10461
|
versionMadeBy,
|
|
10434
10462
|
rawComment,
|
|
10435
10463
|
rawExtraField,
|
|
@@ -10451,6 +10479,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
10451
10479
|
versionMadeBy,
|
|
10452
10480
|
zip64,
|
|
10453
10481
|
directory: Boolean(directory),
|
|
10482
|
+
executable: Boolean(executable),
|
|
10454
10483
|
filenameUTF8: true,
|
|
10455
10484
|
rawFilename,
|
|
10456
10485
|
commentUTF8: true,
|
|
@@ -10911,13 +10940,11 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
10911
10940
|
rawComment,
|
|
10912
10941
|
versionMadeBy,
|
|
10913
10942
|
headerArray,
|
|
10914
|
-
directory,
|
|
10915
10943
|
zip64,
|
|
10916
10944
|
zip64UncompressedSize,
|
|
10917
10945
|
zip64CompressedSize,
|
|
10918
10946
|
zip64DiskNumberStart,
|
|
10919
10947
|
zip64Offset,
|
|
10920
|
-
msDosCompatible,
|
|
10921
10948
|
internalFileAttributes,
|
|
10922
10949
|
externalFileAttributes,
|
|
10923
10950
|
diskNumberStart,
|
|
@@ -10941,8 +10968,6 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
10941
10968
|
setUint16(directoryView, offset + 36, internalFileAttributes);
|
|
10942
10969
|
if (externalFileAttributes) {
|
|
10943
10970
|
setUint32(directoryView, offset + 38, externalFileAttributes);
|
|
10944
|
-
} else if (directory && msDosCompatible) {
|
|
10945
|
-
setUint8(directoryView, offset + 38, FILE_ATTR_MSDOS_DIR_MASK);
|
|
10946
10971
|
}
|
|
10947
10972
|
setUint32(directoryView, offset + 42, zip64 && zip64Offset ? MAX_32_BITS : fileEntryOffset);
|
|
10948
10973
|
arraySet(directoryArray, rawFilename, offset + 46);
|
|
@@ -12026,6 +12051,7 @@ exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
|
|
|
12026
12051
|
exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION;
|
|
12027
12052
|
exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
|
|
12028
12053
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
12054
|
+
exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
|
|
12029
12055
|
exports.HttpRangeReader = HttpRangeReader;
|
|
12030
12056
|
exports.HttpReader = HttpReader;
|
|
12031
12057
|
exports.Reader = Reader;
|
package/index.d.ts
CHANGED
|
@@ -175,7 +175,7 @@ export interface dataHandler {
|
|
|
175
175
|
/**
|
|
176
176
|
* @param data The processed chunk of data.
|
|
177
177
|
*/
|
|
178
|
-
(data: Uint8Array): void;
|
|
178
|
+
(data: Uint8Array<ArrayBuffer>): void;
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
/**
|
|
@@ -206,13 +206,13 @@ declare class EventBasedCodec {
|
|
|
206
206
|
*
|
|
207
207
|
* @param data The chunk of data to append.
|
|
208
208
|
*/
|
|
209
|
-
push(data: Uint8Array): void;
|
|
209
|
+
push(data: Uint8Array<ArrayBuffer>): void;
|
|
210
210
|
/**
|
|
211
211
|
* The function called when a chunk of data has been compressed/decompressed.
|
|
212
212
|
*
|
|
213
213
|
* @param data The chunk of compressed/decompressed data.
|
|
214
214
|
*/
|
|
215
|
-
ondata(data?: Uint8Array): void;
|
|
215
|
+
ondata(data?: Uint8Array<ArrayBuffer>): void;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
/**
|
|
@@ -240,7 +240,7 @@ declare class SyncCodec {
|
|
|
240
240
|
* @param data The chunk of decompressed data to append.
|
|
241
241
|
* @returns A chunk of compressed data.
|
|
242
242
|
*/
|
|
243
|
-
append(data: Uint8Array): Uint8Array
|
|
243
|
+
append(data: Uint8Array<ArrayBuffer>): Uint8Array<ArrayBuffer>;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
/**
|
|
@@ -252,7 +252,7 @@ declare class ZipDeflate extends SyncCodec {
|
|
|
252
252
|
*
|
|
253
253
|
* @returns A chunk of compressed data.
|
|
254
254
|
*/
|
|
255
|
-
flush(): Uint8Array
|
|
255
|
+
flush(): Uint8Array<ArrayBuffer>;
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
/**
|
|
@@ -355,7 +355,7 @@ export class Reader<Type> implements Initializable, ReadableReader {
|
|
|
355
355
|
* @param length The length of the data to read in bytes.
|
|
356
356
|
* @returns A promise resolving to a chunk of data.
|
|
357
357
|
*/
|
|
358
|
-
readUint8Array(index: number, length: number): Promise<Uint8Array
|
|
358
|
+
readUint8Array(index: number, length: number): Promise<Uint8Array<ArrayBuffer>>;
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
/**
|
|
@@ -376,7 +376,7 @@ export class Data64URIReader extends Reader<string> { }
|
|
|
376
376
|
/**
|
|
377
377
|
* Represents a {@link Reader} instance used to read data provided as a `Uint8Array` instance.
|
|
378
378
|
*/
|
|
379
|
-
export class Uint8ArrayReader extends Reader<Uint8Array
|
|
379
|
+
export class Uint8ArrayReader extends Reader<Uint8Array<ArrayBuffer>> { }
|
|
380
380
|
|
|
381
381
|
/**
|
|
382
382
|
* Represents a {@link Reader} instance used to read data provided as an array of {@link ReadableReader} instances (e.g. split zip files).
|
|
@@ -391,22 +391,17 @@ export class SplitZipReader extends SplitDataReader { }
|
|
|
391
391
|
export class SplitDataReader
|
|
392
392
|
extends Reader<Reader<unknown>[] | ReadableReader[] | ReadableStream[]> { }
|
|
393
393
|
|
|
394
|
-
/**
|
|
395
|
-
* Represents a URL stored into a `string`.
|
|
396
|
-
*/
|
|
397
|
-
interface URLString extends String { }
|
|
398
|
-
|
|
399
394
|
/**
|
|
400
395
|
* Represents a {@link Reader} instance used to fetch data from a URL.
|
|
401
396
|
*/
|
|
402
|
-
export class HttpReader extends Reader<
|
|
397
|
+
export class HttpReader extends Reader<string> {
|
|
403
398
|
/**
|
|
404
399
|
* Creates the {@link HttpReader} instance
|
|
405
400
|
*
|
|
406
401
|
* @param url The URL of the data.
|
|
407
402
|
* @param options The options.
|
|
408
403
|
*/
|
|
409
|
-
constructor(url:
|
|
404
|
+
constructor(url: string | URL, options?: HttpOptions);
|
|
410
405
|
}
|
|
411
406
|
|
|
412
407
|
/**
|
|
@@ -419,7 +414,7 @@ export class HttpRangeReader extends HttpReader {
|
|
|
419
414
|
* @param url The URL of the data.
|
|
420
415
|
* @param options The options.
|
|
421
416
|
*/
|
|
422
|
-
constructor(url:
|
|
417
|
+
constructor(url: string | URL, options?: HttpRangeOptions);
|
|
423
418
|
}
|
|
424
419
|
|
|
425
420
|
/**
|
|
@@ -526,7 +521,7 @@ export class Writer<Type> implements Initializable, WritableWriter {
|
|
|
526
521
|
*
|
|
527
522
|
* @virtual
|
|
528
523
|
*/
|
|
529
|
-
writeUint8Array(array: Uint8Array): Promise<void>;
|
|
524
|
+
writeUint8Array(array: Uint8Array<ArrayBuffer>): Promise<void>;
|
|
530
525
|
/**
|
|
531
526
|
* Retrieves all the written data
|
|
532
527
|
*
|
|
@@ -622,7 +617,7 @@ export class SplitDataWriter implements Initializable, WritableWriter {
|
|
|
622
617
|
/**
|
|
623
618
|
* Represents a {@link Writer} instance used to retrieve the written data as a `Uint8Array` instance.
|
|
624
619
|
*/
|
|
625
|
-
export class Uint8ArrayWriter extends Writer<Uint8Array
|
|
620
|
+
export class Uint8ArrayWriter extends Writer<Uint8Array<ArrayBuffer>> { }
|
|
626
621
|
|
|
627
622
|
/**
|
|
628
623
|
* Represents an instance used to create an unzipped stream.
|
|
@@ -657,7 +652,7 @@ export class ZipReaderStream<T> {
|
|
|
657
652
|
* The readable stream.
|
|
658
653
|
*/
|
|
659
654
|
readable: ReadableStream<
|
|
660
|
-
Omit<Entry, "getData"> & { readable?: ReadableStream<Uint8Array
|
|
655
|
+
Omit<Entry, "getData"> & { readable?: ReadableStream<Uint8Array<ArrayBuffer>> }
|
|
661
656
|
>;
|
|
662
657
|
|
|
663
658
|
/**
|
|
@@ -718,15 +713,15 @@ export class ZipReader<Type> {
|
|
|
718
713
|
/**
|
|
719
714
|
* The global comment of the zip file.
|
|
720
715
|
*/
|
|
721
|
-
comment: Uint8Array
|
|
716
|
+
comment: Uint8Array<ArrayBuffer>;
|
|
722
717
|
/**
|
|
723
718
|
* The data prepended before the zip file.
|
|
724
719
|
*/
|
|
725
|
-
prependedData?: Uint8Array
|
|
720
|
+
prependedData?: Uint8Array<ArrayBuffer>;
|
|
726
721
|
/**
|
|
727
722
|
* The data appended after the zip file.
|
|
728
723
|
*/
|
|
729
|
-
appendedData?: Uint8Array
|
|
724
|
+
appendedData?: Uint8Array<ArrayBuffer>;
|
|
730
725
|
/**
|
|
731
726
|
* Returns all the entries in the zip file
|
|
732
727
|
*
|
|
@@ -787,13 +782,13 @@ export interface GetEntriesOptions {
|
|
|
787
782
|
*/
|
|
788
783
|
commentEncoding?: string;
|
|
789
784
|
/**
|
|
790
|
-
*
|
|
791
|
-
*
|
|
785
|
+
* The function called for decoding the filename and the comment of the entry.
|
|
786
|
+
*
|
|
792
787
|
* @param value The raw text value.
|
|
793
788
|
* @param encoding The encoding of the text.
|
|
794
789
|
* @returns The decoded text value or `undefined` if the raw text value should be decoded by zip.js.
|
|
795
790
|
*/
|
|
796
|
-
decodeText?(value: Uint8Array
|
|
791
|
+
decodeText?(value: Uint8Array<ArrayBuffer>, encoding: string): string | undefined;
|
|
797
792
|
}
|
|
798
793
|
|
|
799
794
|
/**
|
|
@@ -823,7 +818,7 @@ export interface ZipReaderOptions {
|
|
|
823
818
|
/**
|
|
824
819
|
* The password used to encrypt the content of the entry (raw).
|
|
825
820
|
*/
|
|
826
|
-
rawPassword?: Uint8Array
|
|
821
|
+
rawPassword?: Uint8Array<ArrayBuffer>;
|
|
827
822
|
/**
|
|
828
823
|
* The `AbortSignal` instance used to cancel the decompression.
|
|
829
824
|
*/
|
|
@@ -857,7 +852,7 @@ export interface EntryMetaData {
|
|
|
857
852
|
/**
|
|
858
853
|
* The filename of the entry (raw).
|
|
859
854
|
*/
|
|
860
|
-
rawFilename: Uint8Array
|
|
855
|
+
rawFilename: Uint8Array<ArrayBuffer>;
|
|
861
856
|
/**
|
|
862
857
|
* `true` if the filename is encoded in UTF-8.
|
|
863
858
|
*/
|
|
@@ -917,7 +912,7 @@ export interface EntryMetaData {
|
|
|
917
912
|
/**
|
|
918
913
|
* The comment of the entry (raw).
|
|
919
914
|
*/
|
|
920
|
-
rawComment: Uint8Array
|
|
915
|
+
rawComment: Uint8Array<ArrayBuffer>;
|
|
921
916
|
/**
|
|
922
917
|
* `true` if the comment is encoded in UTF-8.
|
|
923
918
|
*/
|
|
@@ -929,11 +924,11 @@ export interface EntryMetaData {
|
|
|
929
924
|
/**
|
|
930
925
|
* The extra field.
|
|
931
926
|
*/
|
|
932
|
-
extraField?: Map<number, { type: number, data: Uint8Array }>;
|
|
927
|
+
extraField?: Map<number, { type: number, data: Uint8Array<ArrayBuffer> }>;
|
|
933
928
|
/**
|
|
934
929
|
* The extra field (raw).
|
|
935
930
|
*/
|
|
936
|
-
rawExtraField: Uint8Array
|
|
931
|
+
rawExtraField: Uint8Array<ArrayBuffer>;
|
|
937
932
|
/**
|
|
938
933
|
* `true` if the entry is using Zip64.
|
|
939
934
|
*/
|
|
@@ -1064,7 +1059,7 @@ export class ZipWriterStream {
|
|
|
1064
1059
|
/**
|
|
1065
1060
|
* The readable stream.
|
|
1066
1061
|
*/
|
|
1067
|
-
readable: ReadableStream<Uint8Array
|
|
1062
|
+
readable: ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
1068
1063
|
|
|
1069
1064
|
/**
|
|
1070
1065
|
* The ZipWriter property.
|
|
@@ -1097,7 +1092,7 @@ export class ZipWriterStream {
|
|
|
1097
1092
|
* @returns The content of the zip file.
|
|
1098
1093
|
*/
|
|
1099
1094
|
close(
|
|
1100
|
-
comment?: Uint8Array
|
|
1095
|
+
comment?: Uint8Array<ArrayBuffer>,
|
|
1101
1096
|
options?: ZipWriterCloseOptions,
|
|
1102
1097
|
): Promise<unknown>;
|
|
1103
1098
|
}
|
|
@@ -1170,7 +1165,7 @@ export class ZipWriter<Type> {
|
|
|
1170
1165
|
* @param options The options.
|
|
1171
1166
|
* @returns The content of the zip file.
|
|
1172
1167
|
*/
|
|
1173
|
-
close(comment?: Uint8Array
|
|
1168
|
+
close(comment?: Uint8Array<ArrayBuffer>, options?: ZipWriterCloseOptions): Promise<Type>;
|
|
1174
1169
|
}
|
|
1175
1170
|
|
|
1176
1171
|
/**
|
|
@@ -1187,6 +1182,12 @@ export interface ZipWriterAddDataOptions
|
|
|
1187
1182
|
* @defaultValue false
|
|
1188
1183
|
*/
|
|
1189
1184
|
directory?: boolean;
|
|
1185
|
+
/**
|
|
1186
|
+
* `true` if the entry is an executable file.
|
|
1187
|
+
*
|
|
1188
|
+
* @defaultValue false
|
|
1189
|
+
*/
|
|
1190
|
+
executable?: boolean;
|
|
1190
1191
|
/**
|
|
1191
1192
|
* The comment of the entry.
|
|
1192
1193
|
*/
|
|
@@ -1194,7 +1195,7 @@ export interface ZipWriterAddDataOptions
|
|
|
1194
1195
|
/**
|
|
1195
1196
|
* The extra field of the entry.
|
|
1196
1197
|
*/
|
|
1197
|
-
extraField?: Map<number, Uint8Array
|
|
1198
|
+
extraField?: Map<number, Uint8Array<ArrayBuffer>>;
|
|
1198
1199
|
/**
|
|
1199
1200
|
* The uncompressed size of the entry. This option is ignored if the {@link ZipWriterConstructorOptions#passThrough} option is not set to `true`.
|
|
1200
1201
|
*/
|
|
@@ -1273,9 +1274,12 @@ export interface ZipWriterConstructorOptions {
|
|
|
1273
1274
|
/**
|
|
1274
1275
|
* The password used to encrypt the content of the entry (raw).
|
|
1275
1276
|
*/
|
|
1276
|
-
rawPassword?: Uint8Array
|
|
1277
|
+
rawPassword?: Uint8Array<ArrayBuffer>;
|
|
1277
1278
|
/**
|
|
1278
|
-
* The encryption strength (AES)
|
|
1279
|
+
* The encryption strength (AES):
|
|
1280
|
+
* - 1: 128-bit encryption key
|
|
1281
|
+
* - 2: 192-bit encryption key
|
|
1282
|
+
* - 3: 256-bit encryption key
|
|
1279
1283
|
*
|
|
1280
1284
|
* @defaultValue 3
|
|
1281
1285
|
*/
|
|
@@ -1334,7 +1338,7 @@ export interface ZipWriterConstructorOptions {
|
|
|
1334
1338
|
versionMadeBy?: number;
|
|
1335
1339
|
/**
|
|
1336
1340
|
* `true` to mark the file names as UTF-8 setting the general purpose bit 11 in the header (see Appendix D - Language Encoding (EFS)), `false` to mark the names as compliant with the original IBM Code Page 437.
|
|
1337
|
-
*
|
|
1341
|
+
*
|
|
1338
1342
|
* Note that this does not ensure that the file names are in the correct encoding.
|
|
1339
1343
|
*
|
|
1340
1344
|
* @defaultValue true
|
|
@@ -1357,7 +1361,7 @@ export interface ZipWriterConstructorOptions {
|
|
|
1357
1361
|
/**
|
|
1358
1362
|
* `true` to write {@link EntryMetaData#externalFileAttributes} in MS-DOS format for folder entries.
|
|
1359
1363
|
*
|
|
1360
|
-
* @defaultValue
|
|
1364
|
+
* @defaultValue false
|
|
1361
1365
|
*/
|
|
1362
1366
|
msDosCompatible?: boolean;
|
|
1363
1367
|
/**
|
|
@@ -1401,12 +1405,12 @@ export interface ZipWriterConstructorOptions {
|
|
|
1401
1405
|
*/
|
|
1402
1406
|
compressionMethod?: number
|
|
1403
1407
|
/**
|
|
1404
|
-
*
|
|
1405
|
-
*
|
|
1408
|
+
* The function called for encoding the filename and the comment of the entry.
|
|
1409
|
+
*
|
|
1406
1410
|
* @param text The text to encode.
|
|
1407
1411
|
* @returns The encoded text or `undefined` if the text should be encoded by zip.js.
|
|
1408
1412
|
*/
|
|
1409
|
-
encodeText?(text: string): Uint8Array | undefined;
|
|
1413
|
+
encodeText?(text: string): Uint8Array<ArrayBuffer> | undefined;
|
|
1410
1414
|
}
|
|
1411
1415
|
|
|
1412
1416
|
/**
|
|
@@ -1582,7 +1586,7 @@ export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
|
|
|
1582
1586
|
* @param options The options.
|
|
1583
1587
|
* @returns A promise resolving to a `Uint8Array` instance.
|
|
1584
1588
|
*/
|
|
1585
|
-
getUint8Array(options?: EntryGetDataOptions): Promise<Uint8Array
|
|
1589
|
+
getUint8Array(options?: EntryGetDataOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
1586
1590
|
/**
|
|
1587
1591
|
* Retrieves the content of the entry via a `WritableStream` instance
|
|
1588
1592
|
*
|
|
@@ -1632,7 +1636,7 @@ export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
|
|
|
1632
1636
|
*
|
|
1633
1637
|
* @param array The `Uint8Array` instance.
|
|
1634
1638
|
*/
|
|
1635
|
-
replaceUint8Array(array: Uint8Array): void;
|
|
1639
|
+
replaceUint8Array(array: Uint8Array<ArrayBuffer>): void;
|
|
1636
1640
|
/**
|
|
1637
1641
|
* Replaces the content of the entry with a `ReadableStream` instance
|
|
1638
1642
|
*
|
|
@@ -1716,9 +1720,9 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
1716
1720
|
*/
|
|
1717
1721
|
addUint8Array(
|
|
1718
1722
|
name: string,
|
|
1719
|
-
array: Uint8Array
|
|
1723
|
+
array: Uint8Array<ArrayBuffer>,
|
|
1720
1724
|
options?: ZipWriterAddDataOptions,
|
|
1721
|
-
): ZipFileEntry<Uint8Array
|
|
1725
|
+
): ZipFileEntry<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
1722
1726
|
/**
|
|
1723
1727
|
* Adds an entry with content fetched from a URL
|
|
1724
1728
|
*
|
|
@@ -1805,7 +1809,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
1805
1809
|
* @param options The options.
|
|
1806
1810
|
*/
|
|
1807
1811
|
importUint8Array(
|
|
1808
|
-
array: Uint8Array
|
|
1812
|
+
array: Uint8Array<ArrayBuffer>,
|
|
1809
1813
|
options?: ZipReaderConstructorOptions,
|
|
1810
1814
|
): Promise<[ZipEntry]>;
|
|
1811
1815
|
/**
|
|
@@ -1866,7 +1870,7 @@ export class ZipDirectoryEntry extends ZipEntry {
|
|
|
1866
1870
|
*/
|
|
1867
1871
|
exportUint8Array(
|
|
1868
1872
|
options?: ZipDirectoryEntryExportOptions,
|
|
1869
|
-
): Promise<Uint8Array
|
|
1873
|
+
): Promise<Uint8Array<ArrayBuffer>>;
|
|
1870
1874
|
/**
|
|
1871
1875
|
* Creates a zip file via a `WritableStream` instance containing the entry and its descendants
|
|
1872
1876
|
*
|
|
@@ -2092,4 +2096,8 @@ export const ERR_ITERATOR_COMPLETED_TOO_SOON: string;
|
|
|
2092
2096
|
/**
|
|
2093
2097
|
* Undefined uncompressed size error
|
|
2094
2098
|
*/
|
|
2095
|
-
export const ERR_UNDEFINED_UNCOMPRESSED_SIZE: string
|
|
2099
|
+
export const ERR_UNDEFINED_UNCOMPRESSED_SIZE: string
|
|
2100
|
+
/**
|
|
2101
|
+
* Writer not initialized error
|
|
2102
|
+
*/
|
|
2103
|
+
export const ERR_WRITER_NOT_INITIALIZED: string;
|
package/index.js
CHANGED
|
@@ -83,6 +83,7 @@ export {
|
|
|
83
83
|
ERR_UNSUPPORTED_FORMAT,
|
|
84
84
|
ERR_UNDEFINED_UNCOMPRESSED_SIZE,
|
|
85
85
|
ERR_SPLIT_ZIP_FILE,
|
|
86
|
-
ERR_ITERATOR_COMPLETED_TOO_SOON
|
|
86
|
+
ERR_ITERATOR_COMPLETED_TOO_SOON,
|
|
87
|
+
ERR_WRITER_NOT_INITIALIZED
|
|
87
88
|
} from "./lib/zip-fs.js";
|
|
88
89
|
export { getMimeType, terminateWorkers };
|