@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.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
|
/*
|
|
@@ -6272,6 +6272,7 @@
|
|
|
6272
6272
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
6273
6273
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
6274
6274
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
6275
|
+
const ERR_UNSUPPORTED_SPLIT_USDZ = "Split zip files are not supported in USDZ files";
|
|
6275
6276
|
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
6276
6277
|
const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
|
|
6277
6278
|
const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
|
|
@@ -6286,6 +6287,7 @@
|
|
|
6286
6287
|
const ERR_UNDEFINED_COMPRESSION_METHOD = "Undefined compression method";
|
|
6287
6288
|
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
6288
6289
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
6290
|
+
const ERR_INVALID_READER = "Invalid reader (must be a Reader instance, a ReadableStream instance, or an object with a 'readable' property)";
|
|
6289
6291
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
6290
6292
|
const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
|
|
6291
6293
|
const ERR_INVALID_GID = "Invalid gid (must be integer 0..2^32-1)";
|
|
@@ -6317,6 +6319,9 @@
|
|
|
6317
6319
|
const addSplitZipSignature =
|
|
6318
6320
|
availableSize > 0 && availableSize !== INFINITY_VALUE &&
|
|
6319
6321
|
maxSize > 0 && maxSize !== INFINITY_VALUE;
|
|
6322
|
+
if (addSplitZipSignature && options[OPTION_USDZ]) {
|
|
6323
|
+
throw new Error(ERR_UNSUPPORTED_SPLIT_USDZ);
|
|
6324
|
+
}
|
|
6320
6325
|
Object.assign(this, {
|
|
6321
6326
|
writer,
|
|
6322
6327
|
addSplitZipSignature,
|
|
@@ -6432,6 +6437,7 @@
|
|
|
6432
6437
|
}
|
|
6433
6438
|
const { offset, diskNumberStart } = entryPositions.get(entry);
|
|
6434
6439
|
Object.assign(entry, {
|
|
6440
|
+
zip64Enabled: true,
|
|
6435
6441
|
zip64UncompressedSize,
|
|
6436
6442
|
zip64CompressedSize,
|
|
6437
6443
|
offset,
|
|
@@ -7007,6 +7013,9 @@
|
|
|
7007
7013
|
if (reader) {
|
|
7008
7014
|
reader = new GenericReader(reader);
|
|
7009
7015
|
await initStream(reader);
|
|
7016
|
+
if (!reader.readable && !reader.readUint8Array) {
|
|
7017
|
+
throw new Error(ERR_INVALID_READER);
|
|
7018
|
+
}
|
|
7010
7019
|
({ size: contentSize } = reader);
|
|
7011
7020
|
}
|
|
7012
7021
|
return Object.assign({ reader }, resolveEntrySizes(zipWriter, Boolean(reader), contentSize, metadata, options));
|
|
@@ -7017,6 +7026,7 @@
|
|
|
7017
7026
|
let { dataDescriptor, zip64, level, compressionMethod } = metadata;
|
|
7018
7027
|
let maximumCompressedSize = 0;
|
|
7019
7028
|
let uncompressedSize = 0;
|
|
7029
|
+
let unknownSize = false;
|
|
7020
7030
|
if (passThrough && hasContent) {
|
|
7021
7031
|
uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
|
|
7022
7032
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
@@ -7042,8 +7052,8 @@
|
|
|
7042
7052
|
if (contentSize === UNDEFINED_VALUE) {
|
|
7043
7053
|
dataDescriptor = true;
|
|
7044
7054
|
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
7045
|
-
zip64 = true;
|
|
7046
|
-
|
|
7055
|
+
zip64 = unknownSize = true;
|
|
7056
|
+
maximumCompressedSize = MAX_32_BITS + 1;
|
|
7047
7057
|
}
|
|
7048
7058
|
} else {
|
|
7049
7059
|
options.uncompressedSize = uncompressedSize = contentSize;
|
|
@@ -7058,7 +7068,7 @@
|
|
|
7058
7068
|
if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
|
|
7059
7069
|
dataDescriptor = false;
|
|
7060
7070
|
}
|
|
7061
|
-
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
7071
|
+
const zip64UncompressedSize = zip64Enabled || unknownSize || uncompressedSize >= MAX_32_BITS;
|
|
7062
7072
|
const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
|
|
7063
7073
|
if (zip64UncompressedSize || zip64CompressedSize) {
|
|
7064
7074
|
if (zip64 === false) {
|
|
@@ -7074,6 +7084,8 @@
|
|
|
7074
7084
|
dataDescriptor,
|
|
7075
7085
|
emptyEntry,
|
|
7076
7086
|
zip64,
|
|
7087
|
+
zip64Enabled,
|
|
7088
|
+
unknownSize,
|
|
7077
7089
|
zip64UncompressedSize,
|
|
7078
7090
|
zip64CompressedSize,
|
|
7079
7091
|
uncompressedSize,
|
|
@@ -7147,7 +7159,7 @@
|
|
|
7147
7159
|
if (layoutDependsOnWriteOrder && !writeOrderGuaranteed) {
|
|
7148
7160
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
7149
7161
|
}
|
|
7150
|
-
const directoryDataLength = createDirectoryRecords(files);
|
|
7162
|
+
const { directoryDataLength, zip64Entries } = createDirectoryRecords(files);
|
|
7151
7163
|
let zip64 = getOptionValue(zipWriter, writerOptions, PROPERTY_NAME_ZIP64);
|
|
7152
7164
|
if (offset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || files.size >= MAX_16_BITS) {
|
|
7153
7165
|
if (zip64 === false) {
|
|
@@ -7155,6 +7167,8 @@
|
|
|
7155
7167
|
} else {
|
|
7156
7168
|
zip64 = true;
|
|
7157
7169
|
}
|
|
7170
|
+
} else if (zip64 === UNDEFINED_VALUE && zip64Entries) {
|
|
7171
|
+
zip64 = true;
|
|
7158
7172
|
}
|
|
7159
7173
|
return offset - initialOffset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
7160
7174
|
}
|
|
@@ -7347,6 +7361,7 @@
|
|
|
7347
7361
|
rawPassword,
|
|
7348
7362
|
level,
|
|
7349
7363
|
zip64,
|
|
7364
|
+
zip64Enabled,
|
|
7350
7365
|
zip64UncompressedSize,
|
|
7351
7366
|
zip64CompressedSize,
|
|
7352
7367
|
zipCrypto,
|
|
@@ -7387,6 +7402,7 @@
|
|
|
7387
7402
|
lockFileEntry,
|
|
7388
7403
|
versionMadeBy,
|
|
7389
7404
|
zip64,
|
|
7405
|
+
zip64Enabled,
|
|
7390
7406
|
directory: Boolean(directory),
|
|
7391
7407
|
executable: Boolean(executable),
|
|
7392
7408
|
filenameUTF8: true,
|
|
@@ -7530,13 +7546,14 @@
|
|
|
7530
7546
|
zip64UncompressedSize,
|
|
7531
7547
|
zip64CompressedSize,
|
|
7532
7548
|
uncompressedSize,
|
|
7549
|
+
unknownSize,
|
|
7533
7550
|
crc32
|
|
7534
7551
|
} = options;
|
|
7535
7552
|
let { version, compressionMethod } = options;
|
|
7536
7553
|
const compressed = !directory && isCompressed(compressionMethod, level);
|
|
7537
7554
|
let rawLocalExtraFieldZip64;
|
|
7538
7555
|
const uncompressedFile = passThrough || !compressed;
|
|
7539
|
-
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
|
|
7556
|
+
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || (uncompressedFile && !unknownSize)));
|
|
7540
7557
|
const writeLocalExtraFieldZip64 = zip64ExtraFieldComplete || (zip64 && dataDescriptor && (zip64UncompressedSize || zip64CompressedSize));
|
|
7541
7558
|
if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
|
|
7542
7559
|
const length = 4 + 16;
|
|
@@ -7670,6 +7687,10 @@
|
|
|
7670
7687
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7671
7688
|
}
|
|
7672
7689
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
7690
|
+
const clampedLastModDate = dosLastModDate < MIN_DATE ? MIN_DATE : dosLastModDate > MAX_DATE ? MAX_DATE : dosLastModDate;
|
|
7691
|
+
const storedLastModDate = getLength(rawExtraFieldExtendedTimestamp) ?
|
|
7692
|
+
new Date(getTimeUnix(lastModDate) * 1000) :
|
|
7693
|
+
getLength(rawExtraFieldNTFS) ? lastModDate : clampedLastModDate;
|
|
7673
7694
|
const {
|
|
7674
7695
|
headerArray,
|
|
7675
7696
|
headerView,
|
|
@@ -7679,7 +7700,7 @@
|
|
|
7679
7700
|
bitFlag: getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod),
|
|
7680
7701
|
compressionMethod,
|
|
7681
7702
|
uncompressedSize,
|
|
7682
|
-
lastModDate:
|
|
7703
|
+
lastModDate: clampedLastModDate,
|
|
7683
7704
|
rawLastModDate: rawLastModDateOption,
|
|
7684
7705
|
rawFilename,
|
|
7685
7706
|
zip64CompressedSize,
|
|
@@ -7714,7 +7735,7 @@
|
|
|
7714
7735
|
localHeaderView,
|
|
7715
7736
|
headerArray,
|
|
7716
7737
|
headerView,
|
|
7717
|
-
lastModDate,
|
|
7738
|
+
lastModDate: storedLastModDate,
|
|
7718
7739
|
rawLastModDate,
|
|
7719
7740
|
encrypted,
|
|
7720
7741
|
compressed,
|
|
@@ -7886,14 +7907,15 @@
|
|
|
7886
7907
|
|
|
7887
7908
|
|
|
7888
7909
|
async function closeFile(zipWriter, comment, options) {
|
|
7889
|
-
const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
|
|
7910
|
+
const { directoryDataLength, zip64Entries } = createDirectoryRecords(zipWriter.fileEntries);
|
|
7890
7911
|
const { directoryStart, directoryEnd, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
|
|
7891
7912
|
const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
|
|
7892
|
-
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryEnd, directoryDataLength, signatureLength });
|
|
7913
|
+
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryEnd, directoryDataLength, signatureLength, zip64Entries });
|
|
7893
7914
|
}
|
|
7894
7915
|
|
|
7895
7916
|
function createDirectoryRecords(files) {
|
|
7896
7917
|
let directoryDataLength = 0;
|
|
7918
|
+
let zip64Entries = false;
|
|
7897
7919
|
for (const [, fileEntry] of files) {
|
|
7898
7920
|
const {
|
|
7899
7921
|
rawFilename,
|
|
@@ -7906,11 +7928,20 @@
|
|
|
7906
7928
|
extendedTimestamp,
|
|
7907
7929
|
extraFieldExtendedTimestampFlag,
|
|
7908
7930
|
lastModDate,
|
|
7909
|
-
|
|
7910
|
-
zip64CompressedSize,
|
|
7931
|
+
zip64Enabled,
|
|
7911
7932
|
uncompressedSize,
|
|
7912
7933
|
compressedSize
|
|
7913
7934
|
} = fileEntry;
|
|
7935
|
+
let { zip64UncompressedSize, zip64CompressedSize } = fileEntry;
|
|
7936
|
+
if (!zip64Enabled) {
|
|
7937
|
+
if (zip64UncompressedSize && uncompressedSize < MAX_32_BITS) {
|
|
7938
|
+
zip64UncompressedSize = fileEntry.zip64UncompressedSize = false;
|
|
7939
|
+
}
|
|
7940
|
+
if (zip64CompressedSize && compressedSize < MAX_32_BITS) {
|
|
7941
|
+
zip64CompressedSize = fileEntry.zip64CompressedSize = false;
|
|
7942
|
+
}
|
|
7943
|
+
}
|
|
7944
|
+
zip64Entries = zip64Entries || zip64UncompressedSize || zip64CompressedSize;
|
|
7914
7945
|
const zip64Offset = fileEntry.offset >= MAX_32_BITS;
|
|
7915
7946
|
const zip64DiskNumberStart = fileEntry.diskNumberStart >= MAX_16_BITS;
|
|
7916
7947
|
let rawExtraFieldZip64;
|
|
@@ -7964,7 +7995,7 @@
|
|
|
7964
7995
|
}
|
|
7965
7996
|
directoryDataLength += CENTRAL_FILE_HEADER_LENGTH + getLength(rawFilename, rawComment) + extraFieldLength;
|
|
7966
7997
|
}
|
|
7967
|
-
return directoryDataLength;
|
|
7998
|
+
return { directoryDataLength, zip64Entries };
|
|
7968
7999
|
}
|
|
7969
8000
|
|
|
7970
8001
|
async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
@@ -8084,7 +8115,7 @@
|
|
|
8084
8115
|
|
|
8085
8116
|
async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
|
|
8086
8117
|
const { writer } = zipWriter;
|
|
8087
|
-
const { directoryStart, directoryEnd, signatureLength } = cdInfo;
|
|
8118
|
+
const { directoryStart, directoryEnd, signatureLength, zip64Entries } = cdInfo;
|
|
8088
8119
|
let { directoryDataLength } = cdInfo;
|
|
8089
8120
|
let fileEntriesLength = zipWriter.fileEntries.size;
|
|
8090
8121
|
let diskNumber = directoryStart.diskNumber;
|
|
@@ -8104,6 +8135,8 @@
|
|
|
8104
8135
|
} else {
|
|
8105
8136
|
zip64 = true;
|
|
8106
8137
|
}
|
|
8138
|
+
} else if (zip64 === UNDEFINED_VALUE && zip64Entries) {
|
|
8139
|
+
zip64 = true;
|
|
8107
8140
|
}
|
|
8108
8141
|
const endOfdirectoryRecord = createRecordWriter(zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
8109
8142
|
if (exceedsAvailableSize(writer, getLength(endOfdirectoryRecord.array) + commentLength)) {
|
|
@@ -8607,7 +8640,7 @@
|
|
|
8607
8640
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8608
8641
|
*/
|
|
8609
8642
|
|
|
8610
|
-
const VERSION = "2.11.
|
|
8643
|
+
const VERSION = "2.11.3";
|
|
8611
8644
|
|
|
8612
8645
|
/*
|
|
8613
8646
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -10003,12 +10036,14 @@
|
|
|
10003
10036
|
if (options.bufferedWrite === UNDEFINED_VALUE) {
|
|
10004
10037
|
options.bufferedWrite = true;
|
|
10005
10038
|
}
|
|
10006
|
-
const
|
|
10039
|
+
const children = zipEntry.getChildren({ recursive: true });
|
|
10040
|
+
const entries = children.filter(child => !isImplicitDirectory(child)).map(child => {
|
|
10007
10041
|
const { name, entryOptions } = getChildEntryOptions(child, zipEntry, options);
|
|
10008
10042
|
return { name, size: child.directory ? 0 : getDeterminedSize(child, isPassThrough(child, options)), options: entryOptions };
|
|
10009
10043
|
});
|
|
10010
10044
|
const writeOrderGuaranteed = !options.bufferedWrite ||
|
|
10011
|
-
(entries.every(entry => entry.options.keepOrder !== false) &&
|
|
10045
|
+
(entries.every(entry => entry.options.keepOrder !== false) &&
|
|
10046
|
+
children.every(child => isImplicitDirectory(child) || !child.children.length));
|
|
10012
10047
|
return getEntriesSize(options, entries, writeOrderGuaranteed, options.globalComment);
|
|
10013
10048
|
}
|
|
10014
10049
|
|
|
@@ -11037,6 +11072,7 @@
|
|
|
11037
11072
|
exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
|
|
11038
11073
|
exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
|
|
11039
11074
|
exports.ERR_INVALID_PASS_THROUGH = ERR_INVALID_PASS_THROUGH;
|
|
11075
|
+
exports.ERR_INVALID_READER = ERR_INVALID_READER;
|
|
11040
11076
|
exports.ERR_INVALID_READER_OPTIONS = ERR_INVALID_READER_OPTIONS;
|
|
11041
11077
|
exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
|
|
11042
11078
|
exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
|
|
@@ -11065,6 +11101,7 @@
|
|
|
11065
11101
|
exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
|
|
11066
11102
|
exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
|
|
11067
11103
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
11104
|
+
exports.ERR_UNSUPPORTED_SPLIT_USDZ = ERR_UNSUPPORTED_SPLIT_USDZ;
|
|
11068
11105
|
exports.ERR_UNSUPPORTED_UINT64 = ERR_UNSUPPORTED_UINT64;
|
|
11069
11106
|
exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
|
|
11070
11107
|
exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
|