@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-fs-core.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
|
/*
|
|
@@ -6266,6 +6266,7 @@
|
|
|
6266
6266
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
6267
6267
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
6268
6268
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
6269
|
+
const ERR_UNSUPPORTED_SPLIT_USDZ = "Split zip files are not supported in USDZ files";
|
|
6269
6270
|
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
6270
6271
|
const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
|
|
6271
6272
|
const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
|
|
@@ -6280,6 +6281,7 @@
|
|
|
6280
6281
|
const ERR_UNDEFINED_COMPRESSION_METHOD = "Undefined compression method";
|
|
6281
6282
|
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
6282
6283
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
6284
|
+
const ERR_INVALID_READER = "Invalid reader (must be a Reader instance, a ReadableStream instance, or an object with a 'readable' property)";
|
|
6283
6285
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
6284
6286
|
const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
|
|
6285
6287
|
const ERR_INVALID_GID = "Invalid gid (must be integer 0..2^32-1)";
|
|
@@ -6311,6 +6313,9 @@
|
|
|
6311
6313
|
const addSplitZipSignature =
|
|
6312
6314
|
availableSize > 0 && availableSize !== INFINITY_VALUE &&
|
|
6313
6315
|
maxSize > 0 && maxSize !== INFINITY_VALUE;
|
|
6316
|
+
if (addSplitZipSignature && options[OPTION_USDZ]) {
|
|
6317
|
+
throw new Error(ERR_UNSUPPORTED_SPLIT_USDZ);
|
|
6318
|
+
}
|
|
6314
6319
|
Object.assign(this, {
|
|
6315
6320
|
writer,
|
|
6316
6321
|
addSplitZipSignature,
|
|
@@ -6426,6 +6431,7 @@
|
|
|
6426
6431
|
}
|
|
6427
6432
|
const { offset, diskNumberStart } = entryPositions.get(entry);
|
|
6428
6433
|
Object.assign(entry, {
|
|
6434
|
+
zip64Enabled: true,
|
|
6429
6435
|
zip64UncompressedSize,
|
|
6430
6436
|
zip64CompressedSize,
|
|
6431
6437
|
offset,
|
|
@@ -7001,6 +7007,9 @@
|
|
|
7001
7007
|
if (reader) {
|
|
7002
7008
|
reader = new GenericReader(reader);
|
|
7003
7009
|
await initStream(reader);
|
|
7010
|
+
if (!reader.readable && !reader.readUint8Array) {
|
|
7011
|
+
throw new Error(ERR_INVALID_READER);
|
|
7012
|
+
}
|
|
7004
7013
|
({ size: contentSize } = reader);
|
|
7005
7014
|
}
|
|
7006
7015
|
return Object.assign({ reader }, resolveEntrySizes(zipWriter, Boolean(reader), contentSize, metadata, options));
|
|
@@ -7011,6 +7020,7 @@
|
|
|
7011
7020
|
let { dataDescriptor, zip64, level, compressionMethod } = metadata;
|
|
7012
7021
|
let maximumCompressedSize = 0;
|
|
7013
7022
|
let uncompressedSize = 0;
|
|
7023
|
+
let unknownSize = false;
|
|
7014
7024
|
if (passThrough && hasContent) {
|
|
7015
7025
|
uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
|
|
7016
7026
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
@@ -7036,8 +7046,8 @@
|
|
|
7036
7046
|
if (contentSize === UNDEFINED_VALUE) {
|
|
7037
7047
|
dataDescriptor = true;
|
|
7038
7048
|
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
7039
|
-
zip64 = true;
|
|
7040
|
-
|
|
7049
|
+
zip64 = unknownSize = true;
|
|
7050
|
+
maximumCompressedSize = MAX_32_BITS + 1;
|
|
7041
7051
|
}
|
|
7042
7052
|
} else {
|
|
7043
7053
|
options.uncompressedSize = uncompressedSize = contentSize;
|
|
@@ -7052,7 +7062,7 @@
|
|
|
7052
7062
|
if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
|
|
7053
7063
|
dataDescriptor = false;
|
|
7054
7064
|
}
|
|
7055
|
-
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
7065
|
+
const zip64UncompressedSize = zip64Enabled || unknownSize || uncompressedSize >= MAX_32_BITS;
|
|
7056
7066
|
const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
|
|
7057
7067
|
if (zip64UncompressedSize || zip64CompressedSize) {
|
|
7058
7068
|
if (zip64 === false) {
|
|
@@ -7068,6 +7078,8 @@
|
|
|
7068
7078
|
dataDescriptor,
|
|
7069
7079
|
emptyEntry,
|
|
7070
7080
|
zip64,
|
|
7081
|
+
zip64Enabled,
|
|
7082
|
+
unknownSize,
|
|
7071
7083
|
zip64UncompressedSize,
|
|
7072
7084
|
zip64CompressedSize,
|
|
7073
7085
|
uncompressedSize,
|
|
@@ -7141,7 +7153,7 @@
|
|
|
7141
7153
|
if (layoutDependsOnWriteOrder && !writeOrderGuaranteed) {
|
|
7142
7154
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
7143
7155
|
}
|
|
7144
|
-
const directoryDataLength = createDirectoryRecords(files);
|
|
7156
|
+
const { directoryDataLength, zip64Entries } = createDirectoryRecords(files);
|
|
7145
7157
|
let zip64 = getOptionValue(zipWriter, writerOptions, PROPERTY_NAME_ZIP64);
|
|
7146
7158
|
if (offset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || files.size >= MAX_16_BITS) {
|
|
7147
7159
|
if (zip64 === false) {
|
|
@@ -7149,6 +7161,8 @@
|
|
|
7149
7161
|
} else {
|
|
7150
7162
|
zip64 = true;
|
|
7151
7163
|
}
|
|
7164
|
+
} else if (zip64 === UNDEFINED_VALUE && zip64Entries) {
|
|
7165
|
+
zip64 = true;
|
|
7152
7166
|
}
|
|
7153
7167
|
return offset - initialOffset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
7154
7168
|
}
|
|
@@ -7341,6 +7355,7 @@
|
|
|
7341
7355
|
rawPassword,
|
|
7342
7356
|
level,
|
|
7343
7357
|
zip64,
|
|
7358
|
+
zip64Enabled,
|
|
7344
7359
|
zip64UncompressedSize,
|
|
7345
7360
|
zip64CompressedSize,
|
|
7346
7361
|
zipCrypto,
|
|
@@ -7381,6 +7396,7 @@
|
|
|
7381
7396
|
lockFileEntry,
|
|
7382
7397
|
versionMadeBy,
|
|
7383
7398
|
zip64,
|
|
7399
|
+
zip64Enabled,
|
|
7384
7400
|
directory: Boolean(directory),
|
|
7385
7401
|
executable: Boolean(executable),
|
|
7386
7402
|
filenameUTF8: true,
|
|
@@ -7524,13 +7540,14 @@
|
|
|
7524
7540
|
zip64UncompressedSize,
|
|
7525
7541
|
zip64CompressedSize,
|
|
7526
7542
|
uncompressedSize,
|
|
7543
|
+
unknownSize,
|
|
7527
7544
|
crc32
|
|
7528
7545
|
} = options;
|
|
7529
7546
|
let { version, compressionMethod } = options;
|
|
7530
7547
|
const compressed = !directory && isCompressed(compressionMethod, level);
|
|
7531
7548
|
let rawLocalExtraFieldZip64;
|
|
7532
7549
|
const uncompressedFile = passThrough || !compressed;
|
|
7533
|
-
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
|
|
7550
|
+
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || (uncompressedFile && !unknownSize)));
|
|
7534
7551
|
const writeLocalExtraFieldZip64 = zip64ExtraFieldComplete || (zip64 && dataDescriptor && (zip64UncompressedSize || zip64CompressedSize));
|
|
7535
7552
|
if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
|
|
7536
7553
|
const length = 4 + 16;
|
|
@@ -7664,6 +7681,10 @@
|
|
|
7664
7681
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7665
7682
|
}
|
|
7666
7683
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
7684
|
+
const clampedLastModDate = dosLastModDate < MIN_DATE ? MIN_DATE : dosLastModDate > MAX_DATE ? MAX_DATE : dosLastModDate;
|
|
7685
|
+
const storedLastModDate = getLength(rawExtraFieldExtendedTimestamp) ?
|
|
7686
|
+
new Date(getTimeUnix(lastModDate) * 1000) :
|
|
7687
|
+
getLength(rawExtraFieldNTFS) ? lastModDate : clampedLastModDate;
|
|
7667
7688
|
const {
|
|
7668
7689
|
headerArray,
|
|
7669
7690
|
headerView,
|
|
@@ -7673,7 +7694,7 @@
|
|
|
7673
7694
|
bitFlag: getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod),
|
|
7674
7695
|
compressionMethod,
|
|
7675
7696
|
uncompressedSize,
|
|
7676
|
-
lastModDate:
|
|
7697
|
+
lastModDate: clampedLastModDate,
|
|
7677
7698
|
rawLastModDate: rawLastModDateOption,
|
|
7678
7699
|
rawFilename,
|
|
7679
7700
|
zip64CompressedSize,
|
|
@@ -7708,7 +7729,7 @@
|
|
|
7708
7729
|
localHeaderView,
|
|
7709
7730
|
headerArray,
|
|
7710
7731
|
headerView,
|
|
7711
|
-
lastModDate,
|
|
7732
|
+
lastModDate: storedLastModDate,
|
|
7712
7733
|
rawLastModDate,
|
|
7713
7734
|
encrypted,
|
|
7714
7735
|
compressed,
|
|
@@ -7880,14 +7901,15 @@
|
|
|
7880
7901
|
|
|
7881
7902
|
|
|
7882
7903
|
async function closeFile(zipWriter, comment, options) {
|
|
7883
|
-
const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
|
|
7904
|
+
const { directoryDataLength, zip64Entries } = createDirectoryRecords(zipWriter.fileEntries);
|
|
7884
7905
|
const { directoryStart, directoryEnd, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
|
|
7885
7906
|
const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
|
|
7886
|
-
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryEnd, directoryDataLength, signatureLength });
|
|
7907
|
+
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryEnd, directoryDataLength, signatureLength, zip64Entries });
|
|
7887
7908
|
}
|
|
7888
7909
|
|
|
7889
7910
|
function createDirectoryRecords(files) {
|
|
7890
7911
|
let directoryDataLength = 0;
|
|
7912
|
+
let zip64Entries = false;
|
|
7891
7913
|
for (const [, fileEntry] of files) {
|
|
7892
7914
|
const {
|
|
7893
7915
|
rawFilename,
|
|
@@ -7900,11 +7922,20 @@
|
|
|
7900
7922
|
extendedTimestamp,
|
|
7901
7923
|
extraFieldExtendedTimestampFlag,
|
|
7902
7924
|
lastModDate,
|
|
7903
|
-
|
|
7904
|
-
zip64CompressedSize,
|
|
7925
|
+
zip64Enabled,
|
|
7905
7926
|
uncompressedSize,
|
|
7906
7927
|
compressedSize
|
|
7907
7928
|
} = fileEntry;
|
|
7929
|
+
let { zip64UncompressedSize, zip64CompressedSize } = fileEntry;
|
|
7930
|
+
if (!zip64Enabled) {
|
|
7931
|
+
if (zip64UncompressedSize && uncompressedSize < MAX_32_BITS) {
|
|
7932
|
+
zip64UncompressedSize = fileEntry.zip64UncompressedSize = false;
|
|
7933
|
+
}
|
|
7934
|
+
if (zip64CompressedSize && compressedSize < MAX_32_BITS) {
|
|
7935
|
+
zip64CompressedSize = fileEntry.zip64CompressedSize = false;
|
|
7936
|
+
}
|
|
7937
|
+
}
|
|
7938
|
+
zip64Entries = zip64Entries || zip64UncompressedSize || zip64CompressedSize;
|
|
7908
7939
|
const zip64Offset = fileEntry.offset >= MAX_32_BITS;
|
|
7909
7940
|
const zip64DiskNumberStart = fileEntry.diskNumberStart >= MAX_16_BITS;
|
|
7910
7941
|
let rawExtraFieldZip64;
|
|
@@ -7958,7 +7989,7 @@
|
|
|
7958
7989
|
}
|
|
7959
7990
|
directoryDataLength += CENTRAL_FILE_HEADER_LENGTH + getLength(rawFilename, rawComment) + extraFieldLength;
|
|
7960
7991
|
}
|
|
7961
|
-
return directoryDataLength;
|
|
7992
|
+
return { directoryDataLength, zip64Entries };
|
|
7962
7993
|
}
|
|
7963
7994
|
|
|
7964
7995
|
async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
@@ -8078,7 +8109,7 @@
|
|
|
8078
8109
|
|
|
8079
8110
|
async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
|
|
8080
8111
|
const { writer } = zipWriter;
|
|
8081
|
-
const { directoryStart, directoryEnd, signatureLength } = cdInfo;
|
|
8112
|
+
const { directoryStart, directoryEnd, signatureLength, zip64Entries } = cdInfo;
|
|
8082
8113
|
let { directoryDataLength } = cdInfo;
|
|
8083
8114
|
let fileEntriesLength = zipWriter.fileEntries.size;
|
|
8084
8115
|
let diskNumber = directoryStart.diskNumber;
|
|
@@ -8098,6 +8129,8 @@
|
|
|
8098
8129
|
} else {
|
|
8099
8130
|
zip64 = true;
|
|
8100
8131
|
}
|
|
8132
|
+
} else if (zip64 === UNDEFINED_VALUE && zip64Entries) {
|
|
8133
|
+
zip64 = true;
|
|
8101
8134
|
}
|
|
8102
8135
|
const endOfdirectoryRecord = createRecordWriter(zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
8103
8136
|
if (exceedsAvailableSize(writer, getLength(endOfdirectoryRecord.array) + commentLength)) {
|
|
@@ -8601,7 +8634,7 @@
|
|
|
8601
8634
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8602
8635
|
*/
|
|
8603
8636
|
|
|
8604
|
-
const VERSION = "2.11.
|
|
8637
|
+
const VERSION = "2.11.3";
|
|
8605
8638
|
|
|
8606
8639
|
/*
|
|
8607
8640
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9587,12 +9620,14 @@
|
|
|
9587
9620
|
if (options.bufferedWrite === UNDEFINED_VALUE) {
|
|
9588
9621
|
options.bufferedWrite = true;
|
|
9589
9622
|
}
|
|
9590
|
-
const
|
|
9623
|
+
const children = zipEntry.getChildren({ recursive: true });
|
|
9624
|
+
const entries = children.filter(child => !isImplicitDirectory(child)).map(child => {
|
|
9591
9625
|
const { name, entryOptions } = getChildEntryOptions(child, zipEntry, options);
|
|
9592
9626
|
return { name, size: child.directory ? 0 : getDeterminedSize(child, isPassThrough(child, options)), options: entryOptions };
|
|
9593
9627
|
});
|
|
9594
9628
|
const writeOrderGuaranteed = !options.bufferedWrite ||
|
|
9595
|
-
(entries.every(entry => entry.options.keepOrder !== false) &&
|
|
9629
|
+
(entries.every(entry => entry.options.keepOrder !== false) &&
|
|
9630
|
+
children.every(child => isImplicitDirectory(child) || !child.children.length));
|
|
9596
9631
|
return getEntriesSize(options, entries, writeOrderGuaranteed, options.globalComment);
|
|
9597
9632
|
}
|
|
9598
9633
|
|
|
@@ -10526,6 +10561,7 @@
|
|
|
10526
10561
|
exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
|
|
10527
10562
|
exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
|
|
10528
10563
|
exports.ERR_INVALID_PASS_THROUGH = ERR_INVALID_PASS_THROUGH;
|
|
10564
|
+
exports.ERR_INVALID_READER = ERR_INVALID_READER;
|
|
10529
10565
|
exports.ERR_INVALID_READER_OPTIONS = ERR_INVALID_READER_OPTIONS;
|
|
10530
10566
|
exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
|
|
10531
10567
|
exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
|
|
@@ -10554,6 +10590,7 @@
|
|
|
10554
10590
|
exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
|
|
10555
10591
|
exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
|
|
10556
10592
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
10593
|
+
exports.ERR_UNSUPPORTED_SPLIT_USDZ = ERR_UNSUPPORTED_SPLIT_USDZ;
|
|
10557
10594
|
exports.ERR_UNSUPPORTED_UINT64 = ERR_UNSUPPORTED_UINT64;
|
|
10558
10595
|
exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
|
|
10559
10596
|
exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
|