@zip.js/zip.js 2.11.2 → 2.11.4
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 +80 -36
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +82 -36
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +87 -41
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +89 -41
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +87 -41
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +89 -41
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +89 -41
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +82 -36
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +82 -36
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +82 -36
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +88 -40
- package/index-native.min.js +1 -1
- package/index.cjs +88 -40
- package/index.d.cts +39 -2
- package/index.d.ts +39 -2
- package/index.min.js +1 -1
- package/lib/core/io.js +7 -5
- package/lib/core/options.js +13 -0
- package/lib/core/version.js +1 -1
- package/lib/core/zip-fs.js +5 -5
- package/lib/core/zip-reader.js +20 -17
- package/lib/core/zip-writer.js +50 -13
- package/lib/zip-core-writer.js +2 -0
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -211,6 +211,8 @@ const STRICTNESS_TOLERANT = "tolerant";
|
|
|
211
211
|
const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
|
|
212
212
|
const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
|
|
213
213
|
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
214
|
+
const ERR_ABORTED = "The operation was aborted";
|
|
215
|
+
const ABORT_ERROR_NAME = "AbortError";
|
|
214
216
|
|
|
215
217
|
function checkFunctionOption(value) {
|
|
216
218
|
if (value && typeof value != FUNCTION_TYPE) {
|
|
@@ -226,6 +228,12 @@ function checkSignalOption(signal) {
|
|
|
226
228
|
return signal || UNDEFINED_VALUE;
|
|
227
229
|
}
|
|
228
230
|
|
|
231
|
+
function throwIfAborted(signal) {
|
|
232
|
+
if (signal && signal.aborted) {
|
|
233
|
+
throw signal.reason === UNDEFINED_VALUE ? new DOMException(ERR_ABORTED, ABORT_ERROR_NAME) : signal.reason;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
229
237
|
function checkPasswordOption(password, rawPassword) {
|
|
230
238
|
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
231
239
|
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
@@ -3754,11 +3762,13 @@ class BlobReader extends Reader {
|
|
|
3754
3762
|
const reader = this;
|
|
3755
3763
|
const { sourceBlob, size } = reader;
|
|
3756
3764
|
const { offset = 0, size: readSize = size - offset } = options || {};
|
|
3757
|
-
if (
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3765
|
+
if (typeof sourceBlob.stream == FUNCTION_TYPE) {
|
|
3766
|
+
if (!offset && readSize >= size) {
|
|
3767
|
+
return toCompatibleReadable(sourceBlob.stream());
|
|
3768
|
+
}
|
|
3769
|
+
if (blobSliceReliable) {
|
|
3770
|
+
return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
|
|
3771
|
+
}
|
|
3762
3772
|
}
|
|
3763
3773
|
return super.createReadable(options);
|
|
3764
3774
|
}
|
|
@@ -5194,27 +5204,28 @@ class ZipReaderStream {
|
|
|
5194
5204
|
const { done, value } = await gen.next();
|
|
5195
5205
|
if (done)
|
|
5196
5206
|
return controller.close();
|
|
5197
|
-
const
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
return readable;
|
|
5204
|
-
}
|
|
5207
|
+
const entryReadable = (function () {
|
|
5208
|
+
const { readable, writable } = new TransformStream();
|
|
5209
|
+
if (value.getData) {
|
|
5210
|
+
getData();
|
|
5211
|
+
return readable;
|
|
5212
|
+
}
|
|
5205
5213
|
|
|
5206
|
-
|
|
5214
|
+
async function getData() {
|
|
5215
|
+
try {
|
|
5216
|
+
await value.getData(writable);
|
|
5217
|
+
} catch (error) {
|
|
5207
5218
|
try {
|
|
5208
|
-
await
|
|
5209
|
-
} catch
|
|
5210
|
-
|
|
5211
|
-
await writable.abort(error);
|
|
5212
|
-
} catch {
|
|
5213
|
-
// ignored
|
|
5214
|
-
}
|
|
5219
|
+
await writable.abort(error);
|
|
5220
|
+
} catch {
|
|
5221
|
+
// ignored
|
|
5215
5222
|
}
|
|
5216
5223
|
}
|
|
5217
|
-
}
|
|
5224
|
+
}
|
|
5225
|
+
})();
|
|
5226
|
+
const chunk = {
|
|
5227
|
+
...value,
|
|
5228
|
+
readable: entryReadable
|
|
5218
5229
|
};
|
|
5219
5230
|
delete chunk.getData;
|
|
5220
5231
|
controller.enqueue(chunk);
|
|
@@ -5360,6 +5371,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5360
5371
|
const size = compressedSize;
|
|
5361
5372
|
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5362
5373
|
const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
|
|
5374
|
+
throwIfAborted(signal);
|
|
5363
5375
|
const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
|
|
5364
5376
|
let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
|
|
5365
5377
|
const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
|
|
@@ -6266,6 +6278,7 @@ const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
|
|
|
6266
6278
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
6267
6279
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
6268
6280
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
6281
|
+
const ERR_UNSUPPORTED_SPLIT_USDZ = "Split zip files are not supported in USDZ files";
|
|
6269
6282
|
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
6270
6283
|
const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
|
|
6271
6284
|
const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
|
|
@@ -6280,6 +6293,7 @@ const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
|
6280
6293
|
const ERR_UNDEFINED_COMPRESSION_METHOD = "Undefined compression method";
|
|
6281
6294
|
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
6282
6295
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
6296
|
+
const ERR_INVALID_READER = "Invalid reader (must be a Reader instance, a ReadableStream instance, or an object with a 'readable' property)";
|
|
6283
6297
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
6284
6298
|
const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
|
|
6285
6299
|
const ERR_INVALID_GID = "Invalid gid (must be integer 0..2^32-1)";
|
|
@@ -6311,6 +6325,9 @@ class ZipWriter {
|
|
|
6311
6325
|
const addSplitZipSignature =
|
|
6312
6326
|
availableSize > 0 && availableSize !== INFINITY_VALUE &&
|
|
6313
6327
|
maxSize > 0 && maxSize !== INFINITY_VALUE;
|
|
6328
|
+
if (addSplitZipSignature && options[OPTION_USDZ]) {
|
|
6329
|
+
throw new Error(ERR_UNSUPPORTED_SPLIT_USDZ);
|
|
6330
|
+
}
|
|
6314
6331
|
Object.assign(this, {
|
|
6315
6332
|
writer,
|
|
6316
6333
|
addSplitZipSignature,
|
|
@@ -6426,6 +6443,7 @@ class ZipWriter {
|
|
|
6426
6443
|
}
|
|
6427
6444
|
const { offset, diskNumberStart } = entryPositions.get(entry);
|
|
6428
6445
|
Object.assign(entry, {
|
|
6446
|
+
zip64Enabled: true,
|
|
6429
6447
|
zip64UncompressedSize,
|
|
6430
6448
|
zip64CompressedSize,
|
|
6431
6449
|
offset,
|
|
@@ -6884,6 +6902,7 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6884
6902
|
const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
|
|
6885
6903
|
const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
|
|
6886
6904
|
const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
|
|
6905
|
+
throwIfAborted(signal);
|
|
6887
6906
|
const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
|
|
6888
6907
|
const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
|
|
6889
6908
|
const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
|
|
@@ -7001,6 +7020,9 @@ async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, op
|
|
|
7001
7020
|
if (reader) {
|
|
7002
7021
|
reader = new GenericReader(reader);
|
|
7003
7022
|
await initStream(reader);
|
|
7023
|
+
if (!reader.readable && !reader.readUint8Array) {
|
|
7024
|
+
throw new Error(ERR_INVALID_READER);
|
|
7025
|
+
}
|
|
7004
7026
|
({ size: contentSize } = reader);
|
|
7005
7027
|
}
|
|
7006
7028
|
return Object.assign({ reader }, resolveEntrySizes(zipWriter, Boolean(reader), contentSize, metadata, options));
|
|
@@ -7011,6 +7033,7 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
7011
7033
|
let { dataDescriptor, zip64, level, compressionMethod } = metadata;
|
|
7012
7034
|
let maximumCompressedSize = 0;
|
|
7013
7035
|
let uncompressedSize = 0;
|
|
7036
|
+
let unknownSize = false;
|
|
7014
7037
|
if (passThrough && hasContent) {
|
|
7015
7038
|
uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
|
|
7016
7039
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
@@ -7036,8 +7059,8 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
7036
7059
|
if (contentSize === UNDEFINED_VALUE) {
|
|
7037
7060
|
dataDescriptor = true;
|
|
7038
7061
|
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
7039
|
-
zip64 = true;
|
|
7040
|
-
|
|
7062
|
+
zip64 = unknownSize = true;
|
|
7063
|
+
maximumCompressedSize = MAX_32_BITS + 1;
|
|
7041
7064
|
}
|
|
7042
7065
|
} else {
|
|
7043
7066
|
options.uncompressedSize = uncompressedSize = contentSize;
|
|
@@ -7052,7 +7075,7 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
7052
7075
|
if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
|
|
7053
7076
|
dataDescriptor = false;
|
|
7054
7077
|
}
|
|
7055
|
-
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
7078
|
+
const zip64UncompressedSize = zip64Enabled || unknownSize || uncompressedSize >= MAX_32_BITS;
|
|
7056
7079
|
const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
|
|
7057
7080
|
if (zip64UncompressedSize || zip64CompressedSize) {
|
|
7058
7081
|
if (zip64 === false) {
|
|
@@ -7068,6 +7091,8 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
7068
7091
|
dataDescriptor,
|
|
7069
7092
|
emptyEntry,
|
|
7070
7093
|
zip64,
|
|
7094
|
+
zip64Enabled,
|
|
7095
|
+
unknownSize,
|
|
7071
7096
|
zip64UncompressedSize,
|
|
7072
7097
|
zip64CompressedSize,
|
|
7073
7098
|
uncompressedSize,
|
|
@@ -7141,7 +7166,7 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
7141
7166
|
if (layoutDependsOnWriteOrder && !writeOrderGuaranteed) {
|
|
7142
7167
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
7143
7168
|
}
|
|
7144
|
-
const directoryDataLength = createDirectoryRecords(files);
|
|
7169
|
+
const { directoryDataLength, zip64Entries } = createDirectoryRecords(files);
|
|
7145
7170
|
let zip64 = getOptionValue(zipWriter, writerOptions, PROPERTY_NAME_ZIP64);
|
|
7146
7171
|
if (offset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || files.size >= MAX_16_BITS) {
|
|
7147
7172
|
if (zip64 === false) {
|
|
@@ -7149,6 +7174,8 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
7149
7174
|
} else {
|
|
7150
7175
|
zip64 = true;
|
|
7151
7176
|
}
|
|
7177
|
+
} else if (zip64 === UNDEFINED_VALUE && zip64Entries) {
|
|
7178
|
+
zip64 = true;
|
|
7152
7179
|
}
|
|
7153
7180
|
return offset - initialOffset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
7154
7181
|
}
|
|
@@ -7341,6 +7368,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7341
7368
|
rawPassword,
|
|
7342
7369
|
level,
|
|
7343
7370
|
zip64,
|
|
7371
|
+
zip64Enabled,
|
|
7344
7372
|
zip64UncompressedSize,
|
|
7345
7373
|
zip64CompressedSize,
|
|
7346
7374
|
zipCrypto,
|
|
@@ -7381,6 +7409,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7381
7409
|
lockFileEntry,
|
|
7382
7410
|
versionMadeBy,
|
|
7383
7411
|
zip64,
|
|
7412
|
+
zip64Enabled,
|
|
7384
7413
|
directory: Boolean(directory),
|
|
7385
7414
|
executable: Boolean(executable),
|
|
7386
7415
|
filenameUTF8: true,
|
|
@@ -7524,13 +7553,14 @@ function getHeaderInfo(options) {
|
|
|
7524
7553
|
zip64UncompressedSize,
|
|
7525
7554
|
zip64CompressedSize,
|
|
7526
7555
|
uncompressedSize,
|
|
7556
|
+
unknownSize,
|
|
7527
7557
|
crc32
|
|
7528
7558
|
} = options;
|
|
7529
7559
|
let { version, compressionMethod } = options;
|
|
7530
7560
|
const compressed = !directory && isCompressed(compressionMethod, level);
|
|
7531
7561
|
let rawLocalExtraFieldZip64;
|
|
7532
7562
|
const uncompressedFile = passThrough || !compressed;
|
|
7533
|
-
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
|
|
7563
|
+
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || (uncompressedFile && !unknownSize)));
|
|
7534
7564
|
const writeLocalExtraFieldZip64 = zip64ExtraFieldComplete || (zip64 && dataDescriptor && (zip64UncompressedSize || zip64CompressedSize));
|
|
7535
7565
|
if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
|
|
7536
7566
|
const length = 4 + 16;
|
|
@@ -7664,6 +7694,10 @@ function getHeaderInfo(options) {
|
|
|
7664
7694
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7665
7695
|
}
|
|
7666
7696
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
7697
|
+
const clampedLastModDate = dosLastModDate < MIN_DATE ? MIN_DATE : dosLastModDate > MAX_DATE ? MAX_DATE : dosLastModDate;
|
|
7698
|
+
const storedLastModDate = getLength(rawExtraFieldExtendedTimestamp) ?
|
|
7699
|
+
new Date(getTimeUnix(lastModDate) * 1000) :
|
|
7700
|
+
getLength(rawExtraFieldNTFS) ? lastModDate : clampedLastModDate;
|
|
7667
7701
|
const {
|
|
7668
7702
|
headerArray,
|
|
7669
7703
|
headerView,
|
|
@@ -7673,7 +7707,7 @@ function getHeaderInfo(options) {
|
|
|
7673
7707
|
bitFlag: getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod),
|
|
7674
7708
|
compressionMethod,
|
|
7675
7709
|
uncompressedSize,
|
|
7676
|
-
lastModDate:
|
|
7710
|
+
lastModDate: clampedLastModDate,
|
|
7677
7711
|
rawLastModDate: rawLastModDateOption,
|
|
7678
7712
|
rawFilename,
|
|
7679
7713
|
zip64CompressedSize,
|
|
@@ -7708,7 +7742,7 @@ function getHeaderInfo(options) {
|
|
|
7708
7742
|
localHeaderView,
|
|
7709
7743
|
headerArray,
|
|
7710
7744
|
headerView,
|
|
7711
|
-
lastModDate,
|
|
7745
|
+
lastModDate: storedLastModDate,
|
|
7712
7746
|
rawLastModDate,
|
|
7713
7747
|
encrypted,
|
|
7714
7748
|
compressed,
|
|
@@ -7880,14 +7914,15 @@ function updateLocalHeader({
|
|
|
7880
7914
|
|
|
7881
7915
|
|
|
7882
7916
|
async function closeFile(zipWriter, comment, options) {
|
|
7883
|
-
const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
|
|
7917
|
+
const { directoryDataLength, zip64Entries } = createDirectoryRecords(zipWriter.fileEntries);
|
|
7884
7918
|
const { directoryStart, directoryEnd, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
|
|
7885
7919
|
const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
|
|
7886
|
-
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryEnd, directoryDataLength, signatureLength });
|
|
7920
|
+
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryEnd, directoryDataLength, signatureLength, zip64Entries });
|
|
7887
7921
|
}
|
|
7888
7922
|
|
|
7889
7923
|
function createDirectoryRecords(files) {
|
|
7890
7924
|
let directoryDataLength = 0;
|
|
7925
|
+
let zip64Entries = false;
|
|
7891
7926
|
for (const [, fileEntry] of files) {
|
|
7892
7927
|
const {
|
|
7893
7928
|
rawFilename,
|
|
@@ -7900,11 +7935,20 @@ function createDirectoryRecords(files) {
|
|
|
7900
7935
|
extendedTimestamp,
|
|
7901
7936
|
extraFieldExtendedTimestampFlag,
|
|
7902
7937
|
lastModDate,
|
|
7903
|
-
|
|
7904
|
-
zip64CompressedSize,
|
|
7938
|
+
zip64Enabled,
|
|
7905
7939
|
uncompressedSize,
|
|
7906
7940
|
compressedSize
|
|
7907
7941
|
} = fileEntry;
|
|
7942
|
+
let { zip64UncompressedSize, zip64CompressedSize } = fileEntry;
|
|
7943
|
+
if (!zip64Enabled) {
|
|
7944
|
+
if (zip64UncompressedSize && uncompressedSize < MAX_32_BITS) {
|
|
7945
|
+
zip64UncompressedSize = fileEntry.zip64UncompressedSize = false;
|
|
7946
|
+
}
|
|
7947
|
+
if (zip64CompressedSize && compressedSize < MAX_32_BITS) {
|
|
7948
|
+
zip64CompressedSize = fileEntry.zip64CompressedSize = false;
|
|
7949
|
+
}
|
|
7950
|
+
}
|
|
7951
|
+
zip64Entries = zip64Entries || zip64UncompressedSize || zip64CompressedSize;
|
|
7908
7952
|
const zip64Offset = fileEntry.offset >= MAX_32_BITS;
|
|
7909
7953
|
const zip64DiskNumberStart = fileEntry.diskNumberStart >= MAX_16_BITS;
|
|
7910
7954
|
let rawExtraFieldZip64;
|
|
@@ -7958,7 +8002,7 @@ function createDirectoryRecords(files) {
|
|
|
7958
8002
|
}
|
|
7959
8003
|
directoryDataLength += CENTRAL_FILE_HEADER_LENGTH + getLength(rawFilename, rawComment) + extraFieldLength;
|
|
7960
8004
|
}
|
|
7961
|
-
return directoryDataLength;
|
|
8005
|
+
return { directoryDataLength, zip64Entries };
|
|
7962
8006
|
}
|
|
7963
8007
|
|
|
7964
8008
|
async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
@@ -8078,7 +8122,7 @@ async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
|
|
|
8078
8122
|
|
|
8079
8123
|
async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
|
|
8080
8124
|
const { writer } = zipWriter;
|
|
8081
|
-
const { directoryStart, directoryEnd, signatureLength } = cdInfo;
|
|
8125
|
+
const { directoryStart, directoryEnd, signatureLength, zip64Entries } = cdInfo;
|
|
8082
8126
|
let { directoryDataLength } = cdInfo;
|
|
8083
8127
|
let fileEntriesLength = zipWriter.fileEntries.size;
|
|
8084
8128
|
let diskNumber = directoryStart.diskNumber;
|
|
@@ -8098,6 +8142,8 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
|
|
|
8098
8142
|
} else {
|
|
8099
8143
|
zip64 = true;
|
|
8100
8144
|
}
|
|
8145
|
+
} else if (zip64 === UNDEFINED_VALUE && zip64Entries) {
|
|
8146
|
+
zip64 = true;
|
|
8101
8147
|
}
|
|
8102
8148
|
const endOfdirectoryRecord = createRecordWriter(zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
8103
8149
|
if (exceedsAvailableSize(writer, getLength(endOfdirectoryRecord.array) + commentLength)) {
|
|
@@ -8601,7 +8647,7 @@ function formatSupported(StreamClass, format) {
|
|
|
8601
8647
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8602
8648
|
*/
|
|
8603
8649
|
|
|
8604
|
-
const VERSION = "2.11.
|
|
8650
|
+
const VERSION = "2.11.4";
|
|
8605
8651
|
|
|
8606
8652
|
/*
|
|
8607
8653
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9502,8 +9548,6 @@ const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.
|
|
|
9502
9548
|
const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
|
|
9503
9549
|
const ERR_ZIP_CRYPTO_LAST_MOD_DATE = "The last modification date of an entry encrypted with ZipCrypto cannot be changed when passThrough is set";
|
|
9504
9550
|
const ERR_ABORT_EXPORT = "zipjs-abort-export";
|
|
9505
|
-
const ERR_ABORTED = "The operation was aborted";
|
|
9506
|
-
const ABORT_ERROR_NAME = "AbortError";
|
|
9507
9551
|
const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
|
|
9508
9552
|
const INTERPRETED_EXTRA_FIELD_TYPES = new Set([
|
|
9509
9553
|
EXTRAFIELD_TYPE_ZIP64,
|
|
@@ -9997,12 +10041,14 @@ class ZipDirectoryEntry extends ZipEntry {
|
|
|
9997
10041
|
if (options.bufferedWrite === UNDEFINED_VALUE) {
|
|
9998
10042
|
options.bufferedWrite = true;
|
|
9999
10043
|
}
|
|
10000
|
-
const
|
|
10044
|
+
const children = zipEntry.getChildren({ recursive: true });
|
|
10045
|
+
const entries = children.filter(child => !isImplicitDirectory(child)).map(child => {
|
|
10001
10046
|
const { name, entryOptions } = getChildEntryOptions(child, zipEntry, options);
|
|
10002
10047
|
return { name, size: child.directory ? 0 : getDeterminedSize(child, isPassThrough(child, options)), options: entryOptions };
|
|
10003
10048
|
});
|
|
10004
10049
|
const writeOrderGuaranteed = !options.bufferedWrite ||
|
|
10005
|
-
(entries.every(entry => entry.options.keepOrder !== false) &&
|
|
10050
|
+
(entries.every(entry => entry.options.keepOrder !== false) &&
|
|
10051
|
+
children.every(child => isImplicitDirectory(child) || !child.children.length));
|
|
10006
10052
|
return getEntriesSize(options, entries, writeOrderGuaranteed, options.globalComment);
|
|
10007
10053
|
}
|
|
10008
10054
|
|
|
@@ -11031,6 +11077,7 @@ exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
|
|
|
11031
11077
|
exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
|
|
11032
11078
|
exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
|
|
11033
11079
|
exports.ERR_INVALID_PASS_THROUGH = ERR_INVALID_PASS_THROUGH;
|
|
11080
|
+
exports.ERR_INVALID_READER = ERR_INVALID_READER;
|
|
11034
11081
|
exports.ERR_INVALID_READER_OPTIONS = ERR_INVALID_READER_OPTIONS;
|
|
11035
11082
|
exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
|
|
11036
11083
|
exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
|
|
@@ -11059,6 +11106,7 @@ exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
|
|
|
11059
11106
|
exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
|
|
11060
11107
|
exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
|
|
11061
11108
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
11109
|
+
exports.ERR_UNSUPPORTED_SPLIT_USDZ = ERR_UNSUPPORTED_SPLIT_USDZ;
|
|
11062
11110
|
exports.ERR_UNSUPPORTED_UINT64 = ERR_UNSUPPORTED_UINT64;
|
|
11063
11111
|
exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
|
|
11064
11112
|
exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
|
package/index.d.cts
CHANGED
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
/**
|
|
162
162
|
* Represents the `FileSystemEntry` class.
|
|
163
163
|
*
|
|
164
|
-
* @see {@link https://wicg.github.io/entries-api/#api-entry
|
|
164
|
+
* @see {@link https://wicg.github.io/entries-api/#api-entry}
|
|
165
165
|
*/
|
|
166
166
|
// deno-lint-ignore no-empty-interface
|
|
167
167
|
interface FileSystemEntryLike {}
|
|
@@ -177,7 +177,7 @@ interface FileSystemHandleLike {}
|
|
|
177
177
|
/**
|
|
178
178
|
* Represents a generic `TransformStream` class.
|
|
179
179
|
*
|
|
180
|
-
* @see {@link https://streams.spec.whatwg.org/#generictransformstream
|
|
180
|
+
* @see {@link https://streams.spec.whatwg.org/#generictransformstream}
|
|
181
181
|
*/
|
|
182
182
|
declare class TransformStreamLike {
|
|
183
183
|
/**
|
|
@@ -1344,6 +1344,10 @@ export class ZipReaderStream<T> {
|
|
|
1344
1344
|
|
|
1345
1345
|
/**
|
|
1346
1346
|
* The readable stream.
|
|
1347
|
+
*
|
|
1348
|
+
* @remarks The properties deposited on an entry while its data is read, i.e.
|
|
1349
|
+
* {@link EntryMetaData#warnings} and {@link EntryMetaData#localDirectory}, are shared with the
|
|
1350
|
+
* chunk, so they are readable on it once its `readable` property has been consumed.
|
|
1347
1351
|
*/
|
|
1348
1352
|
readable: ReadableStream<
|
|
1349
1353
|
Omit<Entry, "getData"> & { readable?: ReadableStream<Uint8Array> }
|
|
@@ -1880,6 +1884,10 @@ export interface ZipReaderOptions {
|
|
|
1880
1884
|
rawPassword?: Uint8Array;
|
|
1881
1885
|
/**
|
|
1882
1886
|
* The `AbortSignal` instance used to cancel the decompression.
|
|
1887
|
+
*
|
|
1888
|
+
* A signal already aborted when the operation starts rejects it with {@link ERR_ABORTED} as the
|
|
1889
|
+
* reason of the `AbortError`, or with `signal.reason` when it is set, without relying on the
|
|
1890
|
+
* `signal` option of `pipeTo` that the oldest supported engines ignore.
|
|
1883
1891
|
*/
|
|
1884
1892
|
signal?: AbortSignal;
|
|
1885
1893
|
/**
|
|
@@ -3027,6 +3035,8 @@ export interface ZipWriterCloseOptions extends EntryOnprogressOptions {
|
|
|
3027
3035
|
/**
|
|
3028
3036
|
* `true` to use Zip64 to write the entries directory.
|
|
3029
3037
|
*
|
|
3038
|
+
* Zip64 is also used when the directory does not fit in the standard record, or when an entry is stored with Zip64.
|
|
3039
|
+
*
|
|
3030
3040
|
* @defaultValue false
|
|
3031
3041
|
*/
|
|
3032
3042
|
zip64?: boolean;
|
|
@@ -3059,6 +3069,8 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3059
3069
|
* `true` to use Zip64 to store the entry.
|
|
3060
3070
|
*
|
|
3061
3071
|
* `zip64` is automatically set to `true` when necessary (e.g. compressed data larger than 4GB or with unknown size).
|
|
3072
|
+
* An entry of unknown size is stored with Zip64 in its local header, because the size of the data descriptor must be
|
|
3073
|
+
* chosen before writing the data. Its central directory record drops Zip64 when the actual sizes fit in 32 bits.
|
|
3062
3074
|
*
|
|
3063
3075
|
* @defaultValue false
|
|
3064
3076
|
*/
|
|
@@ -3080,6 +3092,12 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3080
3092
|
* between platforms. Set `useCompressionStream` to `false` to get deterministic output across
|
|
3081
3093
|
* platforms.
|
|
3082
3094
|
*
|
|
3095
|
+
* When no deflate implementation is available at all, i.e. the environment provides no usable
|
|
3096
|
+
* `CompressionStream` and the embedded implementation cannot be loaded, the entry is stored
|
|
3097
|
+
* instead of being compressed rather than failing. The {@link EntryMetaData#compressionMethod} of
|
|
3098
|
+
* the entry returned by {@link ZipWriter#add} is `0` in that case, which is how the fallback is
|
|
3099
|
+
* detected.
|
|
3100
|
+
*
|
|
3083
3101
|
* @defaultValue 6
|
|
3084
3102
|
*/
|
|
3085
3103
|
level?: number;
|
|
@@ -3145,6 +3163,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3145
3163
|
encryptionStrength?: 1 | 2 | 3;
|
|
3146
3164
|
/**
|
|
3147
3165
|
* The `AbortSignal` instance used to cancel the compression.
|
|
3166
|
+
*
|
|
3167
|
+
* A signal already aborted when the operation starts rejects it with {@link ERR_ABORTED} as the
|
|
3168
|
+
* reason of the `AbortError`, or with `signal.reason` when it is set, without relying on the
|
|
3169
|
+
* `signal` option of `pipeTo` that the oldest supported engines ignore.
|
|
3148
3170
|
*/
|
|
3149
3171
|
signal?: AbortSignal;
|
|
3150
3172
|
/**
|
|
@@ -3389,6 +3411,8 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3389
3411
|
* boundaries and stored uncompressed unless the {@link ZipWriterConstructorOptions#level} or
|
|
3390
3412
|
* {@link ZipWriterAddDataOptions#compressionMethod} options are set explicitly. Setting the
|
|
3391
3413
|
* {@link ZipWriterConstructorOptions#password} option throws an {@link ERR_UNSUPPORTED_ENCRYPTION_USDZ} error.
|
|
3414
|
+
* Writing into a split zip file throws an {@link ERR_UNSUPPORTED_SPLIT_USDZ} error, since the 64-byte alignment
|
|
3415
|
+
* of an entry is invalidated when the disk it is written into rolls over.
|
|
3392
3416
|
*
|
|
3393
3417
|
* These constraints apply to the entries written with {@link ZipWriter#add} only. The entries copied with
|
|
3394
3418
|
* {@link ZipWriter#appendZip} keep the layout of the source zip file and are not checked, so appending a
|
|
@@ -4634,6 +4658,10 @@ export const ERR_INVALID_ENCRYPTION_STRENGTH: string;
|
|
|
4634
4658
|
* Unsupported encryption in USDZ files error
|
|
4635
4659
|
*/
|
|
4636
4660
|
export const ERR_UNSUPPORTED_ENCRYPTION_USDZ: string;
|
|
4661
|
+
/**
|
|
4662
|
+
* Unsupported split zip file in USDZ files error
|
|
4663
|
+
*/
|
|
4664
|
+
export const ERR_UNSUPPORTED_SPLIT_USDZ: string;
|
|
4637
4665
|
/**
|
|
4638
4666
|
* Unsupported encryption in pass-through entries error
|
|
4639
4667
|
*/
|
|
@@ -4728,6 +4756,15 @@ export const ERR_UNDETERMINED_SIZE: string;
|
|
|
4728
4756
|
* is not there. Directory entries are exempt, they have no content to write as-is.
|
|
4729
4757
|
*/
|
|
4730
4758
|
export const ERR_UNDEFINED_READER: string;
|
|
4759
|
+
/**
|
|
4760
|
+
* Invalid reader error
|
|
4761
|
+
*
|
|
4762
|
+
* @remarks Thrown when the second argument of {@link ZipWriter#add} is neither a {@link Reader} instance, a
|
|
4763
|
+
* `ReadableStream` instance, nor an object exposing a `readable` property. A `Blob`, a string or a
|
|
4764
|
+
* `Uint8Array` must be wrapped in the matching Reader class, e.g. {@link BlobReader}, {@link TextReader}
|
|
4765
|
+
* or {@link Uint8ArrayReader}.
|
|
4766
|
+
*/
|
|
4767
|
+
export const ERR_INVALID_READER: string;
|
|
4731
4768
|
/**
|
|
4732
4769
|
* Writer not initialized error
|
|
4733
4770
|
*/
|
package/index.d.ts
CHANGED
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
/**
|
|
162
162
|
* Represents the `FileSystemEntry` class.
|
|
163
163
|
*
|
|
164
|
-
* @see {@link https://wicg.github.io/entries-api/#api-entry
|
|
164
|
+
* @see {@link https://wicg.github.io/entries-api/#api-entry}
|
|
165
165
|
*/
|
|
166
166
|
// deno-lint-ignore no-empty-interface
|
|
167
167
|
interface FileSystemEntryLike {}
|
|
@@ -177,7 +177,7 @@ interface FileSystemHandleLike {}
|
|
|
177
177
|
/**
|
|
178
178
|
* Represents a generic `TransformStream` class.
|
|
179
179
|
*
|
|
180
|
-
* @see {@link https://streams.spec.whatwg.org/#generictransformstream
|
|
180
|
+
* @see {@link https://streams.spec.whatwg.org/#generictransformstream}
|
|
181
181
|
*/
|
|
182
182
|
declare class TransformStreamLike {
|
|
183
183
|
/**
|
|
@@ -1344,6 +1344,10 @@ export class ZipReaderStream<T> {
|
|
|
1344
1344
|
|
|
1345
1345
|
/**
|
|
1346
1346
|
* The readable stream.
|
|
1347
|
+
*
|
|
1348
|
+
* @remarks The properties deposited on an entry while its data is read, i.e.
|
|
1349
|
+
* {@link EntryMetaData#warnings} and {@link EntryMetaData#localDirectory}, are shared with the
|
|
1350
|
+
* chunk, so they are readable on it once its `readable` property has been consumed.
|
|
1347
1351
|
*/
|
|
1348
1352
|
readable: ReadableStream<
|
|
1349
1353
|
Omit<Entry, "getData"> & { readable?: ReadableStream<Uint8Array> }
|
|
@@ -1880,6 +1884,10 @@ export interface ZipReaderOptions {
|
|
|
1880
1884
|
rawPassword?: Uint8Array;
|
|
1881
1885
|
/**
|
|
1882
1886
|
* The `AbortSignal` instance used to cancel the decompression.
|
|
1887
|
+
*
|
|
1888
|
+
* A signal already aborted when the operation starts rejects it with {@link ERR_ABORTED} as the
|
|
1889
|
+
* reason of the `AbortError`, or with `signal.reason` when it is set, without relying on the
|
|
1890
|
+
* `signal` option of `pipeTo` that the oldest supported engines ignore.
|
|
1883
1891
|
*/
|
|
1884
1892
|
signal?: AbortSignal;
|
|
1885
1893
|
/**
|
|
@@ -3027,6 +3035,8 @@ export interface ZipWriterCloseOptions extends EntryOnprogressOptions {
|
|
|
3027
3035
|
/**
|
|
3028
3036
|
* `true` to use Zip64 to write the entries directory.
|
|
3029
3037
|
*
|
|
3038
|
+
* Zip64 is also used when the directory does not fit in the standard record, or when an entry is stored with Zip64.
|
|
3039
|
+
*
|
|
3030
3040
|
* @defaultValue false
|
|
3031
3041
|
*/
|
|
3032
3042
|
zip64?: boolean;
|
|
@@ -3059,6 +3069,8 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3059
3069
|
* `true` to use Zip64 to store the entry.
|
|
3060
3070
|
*
|
|
3061
3071
|
* `zip64` is automatically set to `true` when necessary (e.g. compressed data larger than 4GB or with unknown size).
|
|
3072
|
+
* An entry of unknown size is stored with Zip64 in its local header, because the size of the data descriptor must be
|
|
3073
|
+
* chosen before writing the data. Its central directory record drops Zip64 when the actual sizes fit in 32 bits.
|
|
3062
3074
|
*
|
|
3063
3075
|
* @defaultValue false
|
|
3064
3076
|
*/
|
|
@@ -3080,6 +3092,12 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3080
3092
|
* between platforms. Set `useCompressionStream` to `false` to get deterministic output across
|
|
3081
3093
|
* platforms.
|
|
3082
3094
|
*
|
|
3095
|
+
* When no deflate implementation is available at all, i.e. the environment provides no usable
|
|
3096
|
+
* `CompressionStream` and the embedded implementation cannot be loaded, the entry is stored
|
|
3097
|
+
* instead of being compressed rather than failing. The {@link EntryMetaData#compressionMethod} of
|
|
3098
|
+
* the entry returned by {@link ZipWriter#add} is `0` in that case, which is how the fallback is
|
|
3099
|
+
* detected.
|
|
3100
|
+
*
|
|
3083
3101
|
* @defaultValue 6
|
|
3084
3102
|
*/
|
|
3085
3103
|
level?: number;
|
|
@@ -3145,6 +3163,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3145
3163
|
encryptionStrength?: 1 | 2 | 3;
|
|
3146
3164
|
/**
|
|
3147
3165
|
* The `AbortSignal` instance used to cancel the compression.
|
|
3166
|
+
*
|
|
3167
|
+
* A signal already aborted when the operation starts rejects it with {@link ERR_ABORTED} as the
|
|
3168
|
+
* reason of the `AbortError`, or with `signal.reason` when it is set, without relying on the
|
|
3169
|
+
* `signal` option of `pipeTo` that the oldest supported engines ignore.
|
|
3148
3170
|
*/
|
|
3149
3171
|
signal?: AbortSignal;
|
|
3150
3172
|
/**
|
|
@@ -3389,6 +3411,8 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3389
3411
|
* boundaries and stored uncompressed unless the {@link ZipWriterConstructorOptions#level} or
|
|
3390
3412
|
* {@link ZipWriterAddDataOptions#compressionMethod} options are set explicitly. Setting the
|
|
3391
3413
|
* {@link ZipWriterConstructorOptions#password} option throws an {@link ERR_UNSUPPORTED_ENCRYPTION_USDZ} error.
|
|
3414
|
+
* Writing into a split zip file throws an {@link ERR_UNSUPPORTED_SPLIT_USDZ} error, since the 64-byte alignment
|
|
3415
|
+
* of an entry is invalidated when the disk it is written into rolls over.
|
|
3392
3416
|
*
|
|
3393
3417
|
* These constraints apply to the entries written with {@link ZipWriter#add} only. The entries copied with
|
|
3394
3418
|
* {@link ZipWriter#appendZip} keep the layout of the source zip file and are not checked, so appending a
|
|
@@ -4634,6 +4658,10 @@ export const ERR_INVALID_ENCRYPTION_STRENGTH: string;
|
|
|
4634
4658
|
* Unsupported encryption in USDZ files error
|
|
4635
4659
|
*/
|
|
4636
4660
|
export const ERR_UNSUPPORTED_ENCRYPTION_USDZ: string;
|
|
4661
|
+
/**
|
|
4662
|
+
* Unsupported split zip file in USDZ files error
|
|
4663
|
+
*/
|
|
4664
|
+
export const ERR_UNSUPPORTED_SPLIT_USDZ: string;
|
|
4637
4665
|
/**
|
|
4638
4666
|
* Unsupported encryption in pass-through entries error
|
|
4639
4667
|
*/
|
|
@@ -4728,6 +4756,15 @@ export const ERR_UNDETERMINED_SIZE: string;
|
|
|
4728
4756
|
* is not there. Directory entries are exempt, they have no content to write as-is.
|
|
4729
4757
|
*/
|
|
4730
4758
|
export const ERR_UNDEFINED_READER: string;
|
|
4759
|
+
/**
|
|
4760
|
+
* Invalid reader error
|
|
4761
|
+
*
|
|
4762
|
+
* @remarks Thrown when the second argument of {@link ZipWriter#add} is neither a {@link Reader} instance, a
|
|
4763
|
+
* `ReadableStream` instance, nor an object exposing a `readable` property. A `Blob`, a string or a
|
|
4764
|
+
* `Uint8Array` must be wrapped in the matching Reader class, e.g. {@link BlobReader}, {@link TextReader}
|
|
4765
|
+
* or {@link Uint8ArrayReader}.
|
|
4766
|
+
*/
|
|
4767
|
+
export const ERR_INVALID_READER: string;
|
|
4731
4768
|
/**
|
|
4732
4769
|
* Writer not initialized error
|
|
4733
4770
|
*/
|