@zip.js/zip.js 2.11.2 → 2.11.3
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/BENCHMARKS.md +146 -38
- package/deno.json +1 -1
- package/dist/zip-core-external.js +45 -14
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +47 -14
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +52 -17
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +54 -17
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +52 -17
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +54 -17
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +54 -17
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +47 -14
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +47 -14
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +47 -14
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +53 -16
- package/index-native.min.js +1 -1
- package/index.cjs +53 -16
- package/index.d.cts +27 -2
- package/index.d.ts +27 -2
- package/index.min.js +1 -1
- package/lib/core/version.js +1 -1
- package/lib/core/zip-fs.js +4 -2
- package/lib/core/zip-writer.js +48 -13
- package/lib/zip-core-writer.js +2 -0
- package/package.json +1 -1
package/dist/zip.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.zip = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
const { Array, Object, String, Number, BigInt, Math, Date, Map, Set, Response, URL, Error, Uint8Array, Uint16Array, Uint32Array, DataView, Blob, Promise, TextEncoder, TextDecoder, document, crypto, btoa, TransformStream, ReadableStream, WritableStream, CompressionStream, DecompressionStream, navigator, Worker, Symbol, setTimeout, clearTimeout, structuredClone } = typeof globalThis !== 'undefined' ? globalThis :
|
|
7
|
+
const { Array, Object, String, Number, BigInt, Math, Date, Map, Set, Response, URL, Error, Uint8Array, Uint16Array, Uint32Array, DataView, Blob, Promise, TextEncoder, TextDecoder, document, crypto, btoa, TransformStream, ReadableStream, WritableStream, CompressionStream, DecompressionStream, navigator, Worker, Symbol, setTimeout, clearTimeout, structuredClone } = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
8
8
|
|
|
9
9
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
10
10
|
/*
|
|
@@ -6252,6 +6252,7 @@
|
|
|
6252
6252
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
6253
6253
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
6254
6254
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
6255
|
+
const ERR_UNSUPPORTED_SPLIT_USDZ = "Split zip files are not supported in USDZ files";
|
|
6255
6256
|
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
6256
6257
|
const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
|
|
6257
6258
|
const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
|
|
@@ -6266,6 +6267,7 @@
|
|
|
6266
6267
|
const ERR_UNDEFINED_COMPRESSION_METHOD = "Undefined compression method";
|
|
6267
6268
|
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
6268
6269
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
6270
|
+
const ERR_INVALID_READER = "Invalid reader (must be a Reader instance, a ReadableStream instance, or an object with a 'readable' property)";
|
|
6269
6271
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
6270
6272
|
const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
|
|
6271
6273
|
const ERR_INVALID_GID = "Invalid gid (must be integer 0..2^32-1)";
|
|
@@ -6297,6 +6299,9 @@
|
|
|
6297
6299
|
const addSplitZipSignature =
|
|
6298
6300
|
availableSize > 0 && availableSize !== INFINITY_VALUE &&
|
|
6299
6301
|
maxSize > 0 && maxSize !== INFINITY_VALUE;
|
|
6302
|
+
if (addSplitZipSignature && options[OPTION_USDZ]) {
|
|
6303
|
+
throw new Error(ERR_UNSUPPORTED_SPLIT_USDZ);
|
|
6304
|
+
}
|
|
6300
6305
|
Object.assign(this, {
|
|
6301
6306
|
writer,
|
|
6302
6307
|
addSplitZipSignature,
|
|
@@ -6412,6 +6417,7 @@
|
|
|
6412
6417
|
}
|
|
6413
6418
|
const { offset, diskNumberStart } = entryPositions.get(entry);
|
|
6414
6419
|
Object.assign(entry, {
|
|
6420
|
+
zip64Enabled: true,
|
|
6415
6421
|
zip64UncompressedSize,
|
|
6416
6422
|
zip64CompressedSize,
|
|
6417
6423
|
offset,
|
|
@@ -6987,6 +6993,9 @@
|
|
|
6987
6993
|
if (reader) {
|
|
6988
6994
|
reader = new GenericReader(reader);
|
|
6989
6995
|
await initStream(reader);
|
|
6996
|
+
if (!reader.readable && !reader.readUint8Array) {
|
|
6997
|
+
throw new Error(ERR_INVALID_READER);
|
|
6998
|
+
}
|
|
6990
6999
|
({ size: contentSize } = reader);
|
|
6991
7000
|
}
|
|
6992
7001
|
return Object.assign({ reader }, resolveEntrySizes(zipWriter, Boolean(reader), contentSize, metadata, options));
|
|
@@ -6997,6 +7006,7 @@
|
|
|
6997
7006
|
let { dataDescriptor, zip64, level, compressionMethod } = metadata;
|
|
6998
7007
|
let maximumCompressedSize = 0;
|
|
6999
7008
|
let uncompressedSize = 0;
|
|
7009
|
+
let unknownSize = false;
|
|
7000
7010
|
if (passThrough && hasContent) {
|
|
7001
7011
|
uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
|
|
7002
7012
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
@@ -7022,8 +7032,8 @@
|
|
|
7022
7032
|
if (contentSize === UNDEFINED_VALUE) {
|
|
7023
7033
|
dataDescriptor = true;
|
|
7024
7034
|
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
7025
|
-
zip64 = true;
|
|
7026
|
-
|
|
7035
|
+
zip64 = unknownSize = true;
|
|
7036
|
+
maximumCompressedSize = MAX_32_BITS + 1;
|
|
7027
7037
|
}
|
|
7028
7038
|
} else {
|
|
7029
7039
|
options.uncompressedSize = uncompressedSize = contentSize;
|
|
@@ -7038,7 +7048,7 @@
|
|
|
7038
7048
|
if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
|
|
7039
7049
|
dataDescriptor = false;
|
|
7040
7050
|
}
|
|
7041
|
-
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
7051
|
+
const zip64UncompressedSize = zip64Enabled || unknownSize || uncompressedSize >= MAX_32_BITS;
|
|
7042
7052
|
const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
|
|
7043
7053
|
if (zip64UncompressedSize || zip64CompressedSize) {
|
|
7044
7054
|
if (zip64 === false) {
|
|
@@ -7054,6 +7064,8 @@
|
|
|
7054
7064
|
dataDescriptor,
|
|
7055
7065
|
emptyEntry,
|
|
7056
7066
|
zip64,
|
|
7067
|
+
zip64Enabled,
|
|
7068
|
+
unknownSize,
|
|
7057
7069
|
zip64UncompressedSize,
|
|
7058
7070
|
zip64CompressedSize,
|
|
7059
7071
|
uncompressedSize,
|
|
@@ -7252,6 +7264,7 @@
|
|
|
7252
7264
|
rawPassword,
|
|
7253
7265
|
level,
|
|
7254
7266
|
zip64,
|
|
7267
|
+
zip64Enabled,
|
|
7255
7268
|
zip64UncompressedSize,
|
|
7256
7269
|
zip64CompressedSize,
|
|
7257
7270
|
zipCrypto,
|
|
@@ -7292,6 +7305,7 @@
|
|
|
7292
7305
|
lockFileEntry,
|
|
7293
7306
|
versionMadeBy,
|
|
7294
7307
|
zip64,
|
|
7308
|
+
zip64Enabled,
|
|
7295
7309
|
directory: Boolean(directory),
|
|
7296
7310
|
executable: Boolean(executable),
|
|
7297
7311
|
filenameUTF8: true,
|
|
@@ -7435,13 +7449,14 @@
|
|
|
7435
7449
|
zip64UncompressedSize,
|
|
7436
7450
|
zip64CompressedSize,
|
|
7437
7451
|
uncompressedSize,
|
|
7452
|
+
unknownSize,
|
|
7438
7453
|
crc32
|
|
7439
7454
|
} = options;
|
|
7440
7455
|
let { version, compressionMethod } = options;
|
|
7441
7456
|
const compressed = !directory && isCompressed(compressionMethod, level);
|
|
7442
7457
|
let rawLocalExtraFieldZip64;
|
|
7443
7458
|
const uncompressedFile = passThrough || !compressed;
|
|
7444
|
-
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
|
|
7459
|
+
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || (uncompressedFile && !unknownSize)));
|
|
7445
7460
|
const writeLocalExtraFieldZip64 = zip64ExtraFieldComplete || (zip64 && dataDescriptor && (zip64UncompressedSize || zip64CompressedSize));
|
|
7446
7461
|
if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
|
|
7447
7462
|
const length = 4 + 16;
|
|
@@ -7575,6 +7590,10 @@
|
|
|
7575
7590
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7576
7591
|
}
|
|
7577
7592
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
7593
|
+
const clampedLastModDate = dosLastModDate < MIN_DATE ? MIN_DATE : dosLastModDate > MAX_DATE ? MAX_DATE : dosLastModDate;
|
|
7594
|
+
const storedLastModDate = getLength(rawExtraFieldExtendedTimestamp) ?
|
|
7595
|
+
new Date(getTimeUnix(lastModDate) * 1000) :
|
|
7596
|
+
getLength(rawExtraFieldNTFS) ? lastModDate : clampedLastModDate;
|
|
7578
7597
|
const {
|
|
7579
7598
|
headerArray,
|
|
7580
7599
|
headerView,
|
|
@@ -7584,7 +7603,7 @@
|
|
|
7584
7603
|
bitFlag: getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod),
|
|
7585
7604
|
compressionMethod,
|
|
7586
7605
|
uncompressedSize,
|
|
7587
|
-
lastModDate:
|
|
7606
|
+
lastModDate: clampedLastModDate,
|
|
7588
7607
|
rawLastModDate: rawLastModDateOption,
|
|
7589
7608
|
rawFilename,
|
|
7590
7609
|
zip64CompressedSize,
|
|
@@ -7619,7 +7638,7 @@
|
|
|
7619
7638
|
localHeaderView,
|
|
7620
7639
|
headerArray,
|
|
7621
7640
|
headerView,
|
|
7622
|
-
lastModDate,
|
|
7641
|
+
lastModDate: storedLastModDate,
|
|
7623
7642
|
rawLastModDate,
|
|
7624
7643
|
encrypted,
|
|
7625
7644
|
compressed,
|
|
@@ -7791,14 +7810,15 @@
|
|
|
7791
7810
|
|
|
7792
7811
|
|
|
7793
7812
|
async function closeFile(zipWriter, comment, options) {
|
|
7794
|
-
const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
|
|
7813
|
+
const { directoryDataLength, zip64Entries } = createDirectoryRecords(zipWriter.fileEntries);
|
|
7795
7814
|
const { directoryStart, directoryEnd, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
|
|
7796
7815
|
const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
|
|
7797
|
-
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryEnd, directoryDataLength, signatureLength });
|
|
7816
|
+
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryEnd, directoryDataLength, signatureLength, zip64Entries });
|
|
7798
7817
|
}
|
|
7799
7818
|
|
|
7800
7819
|
function createDirectoryRecords(files) {
|
|
7801
7820
|
let directoryDataLength = 0;
|
|
7821
|
+
let zip64Entries = false;
|
|
7802
7822
|
for (const [, fileEntry] of files) {
|
|
7803
7823
|
const {
|
|
7804
7824
|
rawFilename,
|
|
@@ -7811,11 +7831,20 @@
|
|
|
7811
7831
|
extendedTimestamp,
|
|
7812
7832
|
extraFieldExtendedTimestampFlag,
|
|
7813
7833
|
lastModDate,
|
|
7814
|
-
|
|
7815
|
-
zip64CompressedSize,
|
|
7834
|
+
zip64Enabled,
|
|
7816
7835
|
uncompressedSize,
|
|
7817
7836
|
compressedSize
|
|
7818
7837
|
} = fileEntry;
|
|
7838
|
+
let { zip64UncompressedSize, zip64CompressedSize } = fileEntry;
|
|
7839
|
+
if (!zip64Enabled) {
|
|
7840
|
+
if (zip64UncompressedSize && uncompressedSize < MAX_32_BITS) {
|
|
7841
|
+
zip64UncompressedSize = fileEntry.zip64UncompressedSize = false;
|
|
7842
|
+
}
|
|
7843
|
+
if (zip64CompressedSize && compressedSize < MAX_32_BITS) {
|
|
7844
|
+
zip64CompressedSize = fileEntry.zip64CompressedSize = false;
|
|
7845
|
+
}
|
|
7846
|
+
}
|
|
7847
|
+
zip64Entries = zip64Entries || zip64UncompressedSize || zip64CompressedSize;
|
|
7819
7848
|
const zip64Offset = fileEntry.offset >= MAX_32_BITS;
|
|
7820
7849
|
const zip64DiskNumberStart = fileEntry.diskNumberStart >= MAX_16_BITS;
|
|
7821
7850
|
let rawExtraFieldZip64;
|
|
@@ -7869,7 +7898,7 @@
|
|
|
7869
7898
|
}
|
|
7870
7899
|
directoryDataLength += CENTRAL_FILE_HEADER_LENGTH + getLength(rawFilename, rawComment) + extraFieldLength;
|
|
7871
7900
|
}
|
|
7872
|
-
return directoryDataLength;
|
|
7901
|
+
return { directoryDataLength, zip64Entries };
|
|
7873
7902
|
}
|
|
7874
7903
|
|
|
7875
7904
|
async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
@@ -7989,7 +8018,7 @@
|
|
|
7989
8018
|
|
|
7990
8019
|
async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
|
|
7991
8020
|
const { writer } = zipWriter;
|
|
7992
|
-
const { directoryStart, directoryEnd, signatureLength } = cdInfo;
|
|
8021
|
+
const { directoryStart, directoryEnd, signatureLength, zip64Entries } = cdInfo;
|
|
7993
8022
|
let { directoryDataLength } = cdInfo;
|
|
7994
8023
|
let fileEntriesLength = zipWriter.fileEntries.size;
|
|
7995
8024
|
let diskNumber = directoryStart.diskNumber;
|
|
@@ -8009,6 +8038,8 @@
|
|
|
8009
8038
|
} else {
|
|
8010
8039
|
zip64 = true;
|
|
8011
8040
|
}
|
|
8041
|
+
} else if (zip64 === UNDEFINED_VALUE && zip64Entries) {
|
|
8042
|
+
zip64 = true;
|
|
8012
8043
|
}
|
|
8013
8044
|
const endOfdirectoryRecord = createRecordWriter(zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
8014
8045
|
if (exceedsAvailableSize(writer, getLength(endOfdirectoryRecord.array) + commentLength)) {
|
|
@@ -8512,7 +8543,7 @@
|
|
|
8512
8543
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8513
8544
|
*/
|
|
8514
8545
|
|
|
8515
|
-
const VERSION = "2.11.
|
|
8546
|
+
const VERSION = "2.11.3";
|
|
8516
8547
|
|
|
8517
8548
|
/*
|
|
8518
8549
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9444,6 +9475,7 @@
|
|
|
9444
9475
|
exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
|
|
9445
9476
|
exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
|
|
9446
9477
|
exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
|
|
9478
|
+
exports.ERR_INVALID_READER = ERR_INVALID_READER;
|
|
9447
9479
|
exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
|
|
9448
9480
|
exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
|
|
9449
9481
|
exports.ERR_INVALID_STRICTNESS = ERR_INVALID_STRICTNESS;
|
|
@@ -9470,6 +9502,7 @@
|
|
|
9470
9502
|
exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
|
|
9471
9503
|
exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
|
|
9472
9504
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
9505
|
+
exports.ERR_UNSUPPORTED_SPLIT_USDZ = ERR_UNSUPPORTED_SPLIT_USDZ;
|
|
9473
9506
|
exports.ERR_UNSUPPORTED_UINT64 = ERR_UNSUPPORTED_UINT64;
|
|
9474
9507
|
exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
|
|
9475
9508
|
exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
|