@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/index-native.cjs
CHANGED
|
@@ -6262,6 +6262,7 @@ const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
|
|
|
6262
6262
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
6263
6263
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
6264
6264
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
6265
|
+
const ERR_UNSUPPORTED_SPLIT_USDZ = "Split zip files are not supported in USDZ files";
|
|
6265
6266
|
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
6266
6267
|
const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
|
|
6267
6268
|
const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
|
|
@@ -6276,6 +6277,7 @@ const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
|
6276
6277
|
const ERR_UNDEFINED_COMPRESSION_METHOD = "Undefined compression method";
|
|
6277
6278
|
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
6278
6279
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
6280
|
+
const ERR_INVALID_READER = "Invalid reader (must be a Reader instance, a ReadableStream instance, or an object with a 'readable' property)";
|
|
6279
6281
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
6280
6282
|
const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
|
|
6281
6283
|
const ERR_INVALID_GID = "Invalid gid (must be integer 0..2^32-1)";
|
|
@@ -6307,6 +6309,9 @@ class ZipWriter {
|
|
|
6307
6309
|
const addSplitZipSignature =
|
|
6308
6310
|
availableSize > 0 && availableSize !== INFINITY_VALUE &&
|
|
6309
6311
|
maxSize > 0 && maxSize !== INFINITY_VALUE;
|
|
6312
|
+
if (addSplitZipSignature && options[OPTION_USDZ]) {
|
|
6313
|
+
throw new Error(ERR_UNSUPPORTED_SPLIT_USDZ);
|
|
6314
|
+
}
|
|
6310
6315
|
Object.assign(this, {
|
|
6311
6316
|
writer,
|
|
6312
6317
|
addSplitZipSignature,
|
|
@@ -6422,6 +6427,7 @@ class ZipWriter {
|
|
|
6422
6427
|
}
|
|
6423
6428
|
const { offset, diskNumberStart } = entryPositions.get(entry);
|
|
6424
6429
|
Object.assign(entry, {
|
|
6430
|
+
zip64Enabled: true,
|
|
6425
6431
|
zip64UncompressedSize,
|
|
6426
6432
|
zip64CompressedSize,
|
|
6427
6433
|
offset,
|
|
@@ -6997,6 +7003,9 @@ async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, op
|
|
|
6997
7003
|
if (reader) {
|
|
6998
7004
|
reader = new GenericReader(reader);
|
|
6999
7005
|
await initStream(reader);
|
|
7006
|
+
if (!reader.readable && !reader.readUint8Array) {
|
|
7007
|
+
throw new Error(ERR_INVALID_READER);
|
|
7008
|
+
}
|
|
7000
7009
|
({ size: contentSize } = reader);
|
|
7001
7010
|
}
|
|
7002
7011
|
return Object.assign({ reader }, resolveEntrySizes(zipWriter, Boolean(reader), contentSize, metadata, options));
|
|
@@ -7007,6 +7016,7 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
7007
7016
|
let { dataDescriptor, zip64, level, compressionMethod } = metadata;
|
|
7008
7017
|
let maximumCompressedSize = 0;
|
|
7009
7018
|
let uncompressedSize = 0;
|
|
7019
|
+
let unknownSize = false;
|
|
7010
7020
|
if (passThrough && hasContent) {
|
|
7011
7021
|
uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
|
|
7012
7022
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
@@ -7032,8 +7042,8 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
7032
7042
|
if (contentSize === UNDEFINED_VALUE) {
|
|
7033
7043
|
dataDescriptor = true;
|
|
7034
7044
|
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
7035
|
-
zip64 = true;
|
|
7036
|
-
|
|
7045
|
+
zip64 = unknownSize = true;
|
|
7046
|
+
maximumCompressedSize = MAX_32_BITS + 1;
|
|
7037
7047
|
}
|
|
7038
7048
|
} else {
|
|
7039
7049
|
options.uncompressedSize = uncompressedSize = contentSize;
|
|
@@ -7048,7 +7058,7 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
7048
7058
|
if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
|
|
7049
7059
|
dataDescriptor = false;
|
|
7050
7060
|
}
|
|
7051
|
-
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
7061
|
+
const zip64UncompressedSize = zip64Enabled || unknownSize || uncompressedSize >= MAX_32_BITS;
|
|
7052
7062
|
const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
|
|
7053
7063
|
if (zip64UncompressedSize || zip64CompressedSize) {
|
|
7054
7064
|
if (zip64 === false) {
|
|
@@ -7064,6 +7074,8 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
7064
7074
|
dataDescriptor,
|
|
7065
7075
|
emptyEntry,
|
|
7066
7076
|
zip64,
|
|
7077
|
+
zip64Enabled,
|
|
7078
|
+
unknownSize,
|
|
7067
7079
|
zip64UncompressedSize,
|
|
7068
7080
|
zip64CompressedSize,
|
|
7069
7081
|
uncompressedSize,
|
|
@@ -7137,7 +7149,7 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
7137
7149
|
if (layoutDependsOnWriteOrder && !writeOrderGuaranteed) {
|
|
7138
7150
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
7139
7151
|
}
|
|
7140
|
-
const directoryDataLength = createDirectoryRecords(files);
|
|
7152
|
+
const { directoryDataLength, zip64Entries } = createDirectoryRecords(files);
|
|
7141
7153
|
let zip64 = getOptionValue(zipWriter, writerOptions, PROPERTY_NAME_ZIP64);
|
|
7142
7154
|
if (offset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || files.size >= MAX_16_BITS) {
|
|
7143
7155
|
if (zip64 === false) {
|
|
@@ -7145,6 +7157,8 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
7145
7157
|
} else {
|
|
7146
7158
|
zip64 = true;
|
|
7147
7159
|
}
|
|
7160
|
+
} else if (zip64 === UNDEFINED_VALUE && zip64Entries) {
|
|
7161
|
+
zip64 = true;
|
|
7148
7162
|
}
|
|
7149
7163
|
return offset - initialOffset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
7150
7164
|
}
|
|
@@ -7337,6 +7351,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7337
7351
|
rawPassword,
|
|
7338
7352
|
level,
|
|
7339
7353
|
zip64,
|
|
7354
|
+
zip64Enabled,
|
|
7340
7355
|
zip64UncompressedSize,
|
|
7341
7356
|
zip64CompressedSize,
|
|
7342
7357
|
zipCrypto,
|
|
@@ -7377,6 +7392,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7377
7392
|
lockFileEntry,
|
|
7378
7393
|
versionMadeBy,
|
|
7379
7394
|
zip64,
|
|
7395
|
+
zip64Enabled,
|
|
7380
7396
|
directory: Boolean(directory),
|
|
7381
7397
|
executable: Boolean(executable),
|
|
7382
7398
|
filenameUTF8: true,
|
|
@@ -7520,13 +7536,14 @@ function getHeaderInfo(options) {
|
|
|
7520
7536
|
zip64UncompressedSize,
|
|
7521
7537
|
zip64CompressedSize,
|
|
7522
7538
|
uncompressedSize,
|
|
7539
|
+
unknownSize,
|
|
7523
7540
|
crc32
|
|
7524
7541
|
} = options;
|
|
7525
7542
|
let { version, compressionMethod } = options;
|
|
7526
7543
|
const compressed = !directory && isCompressed(compressionMethod, level);
|
|
7527
7544
|
let rawLocalExtraFieldZip64;
|
|
7528
7545
|
const uncompressedFile = passThrough || !compressed;
|
|
7529
|
-
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
|
|
7546
|
+
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || (uncompressedFile && !unknownSize)));
|
|
7530
7547
|
const writeLocalExtraFieldZip64 = zip64ExtraFieldComplete || (zip64 && dataDescriptor && (zip64UncompressedSize || zip64CompressedSize));
|
|
7531
7548
|
if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
|
|
7532
7549
|
const length = 4 + 16;
|
|
@@ -7660,6 +7677,10 @@ function getHeaderInfo(options) {
|
|
|
7660
7677
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7661
7678
|
}
|
|
7662
7679
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
7680
|
+
const clampedLastModDate = dosLastModDate < MIN_DATE ? MIN_DATE : dosLastModDate > MAX_DATE ? MAX_DATE : dosLastModDate;
|
|
7681
|
+
const storedLastModDate = getLength(rawExtraFieldExtendedTimestamp) ?
|
|
7682
|
+
new Date(getTimeUnix(lastModDate) * 1000) :
|
|
7683
|
+
getLength(rawExtraFieldNTFS) ? lastModDate : clampedLastModDate;
|
|
7663
7684
|
const {
|
|
7664
7685
|
headerArray,
|
|
7665
7686
|
headerView,
|
|
@@ -7669,7 +7690,7 @@ function getHeaderInfo(options) {
|
|
|
7669
7690
|
bitFlag: getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod),
|
|
7670
7691
|
compressionMethod,
|
|
7671
7692
|
uncompressedSize,
|
|
7672
|
-
lastModDate:
|
|
7693
|
+
lastModDate: clampedLastModDate,
|
|
7673
7694
|
rawLastModDate: rawLastModDateOption,
|
|
7674
7695
|
rawFilename,
|
|
7675
7696
|
zip64CompressedSize,
|
|
@@ -7704,7 +7725,7 @@ function getHeaderInfo(options) {
|
|
|
7704
7725
|
localHeaderView,
|
|
7705
7726
|
headerArray,
|
|
7706
7727
|
headerView,
|
|
7707
|
-
lastModDate,
|
|
7728
|
+
lastModDate: storedLastModDate,
|
|
7708
7729
|
rawLastModDate,
|
|
7709
7730
|
encrypted,
|
|
7710
7731
|
compressed,
|
|
@@ -7876,14 +7897,15 @@ function updateLocalHeader({
|
|
|
7876
7897
|
|
|
7877
7898
|
|
|
7878
7899
|
async function closeFile(zipWriter, comment, options) {
|
|
7879
|
-
const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
|
|
7900
|
+
const { directoryDataLength, zip64Entries } = createDirectoryRecords(zipWriter.fileEntries);
|
|
7880
7901
|
const { directoryStart, directoryEnd, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
|
|
7881
7902
|
const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
|
|
7882
|
-
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryEnd, directoryDataLength, signatureLength });
|
|
7903
|
+
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryEnd, directoryDataLength, signatureLength, zip64Entries });
|
|
7883
7904
|
}
|
|
7884
7905
|
|
|
7885
7906
|
function createDirectoryRecords(files) {
|
|
7886
7907
|
let directoryDataLength = 0;
|
|
7908
|
+
let zip64Entries = false;
|
|
7887
7909
|
for (const [, fileEntry] of files) {
|
|
7888
7910
|
const {
|
|
7889
7911
|
rawFilename,
|
|
@@ -7896,11 +7918,20 @@ function createDirectoryRecords(files) {
|
|
|
7896
7918
|
extendedTimestamp,
|
|
7897
7919
|
extraFieldExtendedTimestampFlag,
|
|
7898
7920
|
lastModDate,
|
|
7899
|
-
|
|
7900
|
-
zip64CompressedSize,
|
|
7921
|
+
zip64Enabled,
|
|
7901
7922
|
uncompressedSize,
|
|
7902
7923
|
compressedSize
|
|
7903
7924
|
} = fileEntry;
|
|
7925
|
+
let { zip64UncompressedSize, zip64CompressedSize } = fileEntry;
|
|
7926
|
+
if (!zip64Enabled) {
|
|
7927
|
+
if (zip64UncompressedSize && uncompressedSize < MAX_32_BITS) {
|
|
7928
|
+
zip64UncompressedSize = fileEntry.zip64UncompressedSize = false;
|
|
7929
|
+
}
|
|
7930
|
+
if (zip64CompressedSize && compressedSize < MAX_32_BITS) {
|
|
7931
|
+
zip64CompressedSize = fileEntry.zip64CompressedSize = false;
|
|
7932
|
+
}
|
|
7933
|
+
}
|
|
7934
|
+
zip64Entries = zip64Entries || zip64UncompressedSize || zip64CompressedSize;
|
|
7904
7935
|
const zip64Offset = fileEntry.offset >= MAX_32_BITS;
|
|
7905
7936
|
const zip64DiskNumberStart = fileEntry.diskNumberStart >= MAX_16_BITS;
|
|
7906
7937
|
let rawExtraFieldZip64;
|
|
@@ -7954,7 +7985,7 @@ function createDirectoryRecords(files) {
|
|
|
7954
7985
|
}
|
|
7955
7986
|
directoryDataLength += CENTRAL_FILE_HEADER_LENGTH + getLength(rawFilename, rawComment) + extraFieldLength;
|
|
7956
7987
|
}
|
|
7957
|
-
return directoryDataLength;
|
|
7988
|
+
return { directoryDataLength, zip64Entries };
|
|
7958
7989
|
}
|
|
7959
7990
|
|
|
7960
7991
|
async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
@@ -8074,7 +8105,7 @@ async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
|
|
|
8074
8105
|
|
|
8075
8106
|
async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
|
|
8076
8107
|
const { writer } = zipWriter;
|
|
8077
|
-
const { directoryStart, directoryEnd, signatureLength } = cdInfo;
|
|
8108
|
+
const { directoryStart, directoryEnd, signatureLength, zip64Entries } = cdInfo;
|
|
8078
8109
|
let { directoryDataLength } = cdInfo;
|
|
8079
8110
|
let fileEntriesLength = zipWriter.fileEntries.size;
|
|
8080
8111
|
let diskNumber = directoryStart.diskNumber;
|
|
@@ -8094,6 +8125,8 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
|
|
|
8094
8125
|
} else {
|
|
8095
8126
|
zip64 = true;
|
|
8096
8127
|
}
|
|
8128
|
+
} else if (zip64 === UNDEFINED_VALUE && zip64Entries) {
|
|
8129
|
+
zip64 = true;
|
|
8097
8130
|
}
|
|
8098
8131
|
const endOfdirectoryRecord = createRecordWriter(zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
8099
8132
|
if (exceedsAvailableSize(writer, getLength(endOfdirectoryRecord.array) + commentLength)) {
|
|
@@ -8597,7 +8630,7 @@ function formatSupported(StreamClass, format) {
|
|
|
8597
8630
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8598
8631
|
*/
|
|
8599
8632
|
|
|
8600
|
-
const VERSION = "2.11.
|
|
8633
|
+
const VERSION = "2.11.3";
|
|
8601
8634
|
|
|
8602
8635
|
/*
|
|
8603
8636
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9621,12 +9654,14 @@ class ZipDirectoryEntry extends ZipEntry {
|
|
|
9621
9654
|
if (options.bufferedWrite === UNDEFINED_VALUE) {
|
|
9622
9655
|
options.bufferedWrite = true;
|
|
9623
9656
|
}
|
|
9624
|
-
const
|
|
9657
|
+
const children = zipEntry.getChildren({ recursive: true });
|
|
9658
|
+
const entries = children.filter(child => !isImplicitDirectory(child)).map(child => {
|
|
9625
9659
|
const { name, entryOptions } = getChildEntryOptions(child, zipEntry, options);
|
|
9626
9660
|
return { name, size: child.directory ? 0 : getDeterminedSize(child, isPassThrough(child, options)), options: entryOptions };
|
|
9627
9661
|
});
|
|
9628
9662
|
const writeOrderGuaranteed = !options.bufferedWrite ||
|
|
9629
|
-
(entries.every(entry => entry.options.keepOrder !== false) &&
|
|
9663
|
+
(entries.every(entry => entry.options.keepOrder !== false) &&
|
|
9664
|
+
children.every(child => isImplicitDirectory(child) || !child.children.length));
|
|
9630
9665
|
return getEntriesSize(options, entries, writeOrderGuaranteed, options.globalComment);
|
|
9631
9666
|
}
|
|
9632
9667
|
|
|
@@ -10655,6 +10690,7 @@ exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
|
|
|
10655
10690
|
exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
|
|
10656
10691
|
exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
|
|
10657
10692
|
exports.ERR_INVALID_PASS_THROUGH = ERR_INVALID_PASS_THROUGH;
|
|
10693
|
+
exports.ERR_INVALID_READER = ERR_INVALID_READER;
|
|
10658
10694
|
exports.ERR_INVALID_READER_OPTIONS = ERR_INVALID_READER_OPTIONS;
|
|
10659
10695
|
exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
|
|
10660
10696
|
exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
|
|
@@ -10683,6 +10719,7 @@ exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
|
|
|
10683
10719
|
exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
|
|
10684
10720
|
exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
|
|
10685
10721
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
10722
|
+
exports.ERR_UNSUPPORTED_SPLIT_USDZ = ERR_UNSUPPORTED_SPLIT_USDZ;
|
|
10686
10723
|
exports.ERR_UNSUPPORTED_UINT64 = ERR_UNSUPPORTED_UINT64;
|
|
10687
10724
|
exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
|
|
10688
10725
|
exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
|