@zip.js/zip.js 2.6.42 → 2.6.44
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/dist/zip-fs-full.js +64 -69
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +63 -68
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +63 -68
- package/dist/zip-full.min.js +1 -1
- package/dist/zip-no-worker-deflate.min.js +1 -1
- package/dist/zip-no-worker-inflate.min.js +1 -1
- package/dist/zip-no-worker.min.js +1 -1
- package/dist/zip.js +63 -68
- package/dist/zip.min.js +1 -1
- package/index-fflate.js +2 -0
- package/index.cjs +64 -69
- package/index.d.ts +24 -4
- package/index.js +3 -1
- package/lib/core/io.js +8 -2
- package/lib/core/zip-reader.js +2 -2
- package/lib/core/zip-writer.js +55 -66
- package/package.json +1 -1
- package/tests/all/test-http-split-zip.js +1 -1
- package/tests/all/test-split-data.js +37 -0
- package/tests/all/test-split-zip.js +2 -2
- package/tests/tests-data.js +2 -1
package/index.cjs
CHANGED
|
@@ -8103,7 +8103,7 @@ class Uint8ArrayWriter extends Writer {
|
|
|
8103
8103
|
}
|
|
8104
8104
|
}
|
|
8105
8105
|
|
|
8106
|
-
class
|
|
8106
|
+
class SplitDataReader extends Reader {
|
|
8107
8107
|
|
|
8108
8108
|
constructor(readers) {
|
|
8109
8109
|
super();
|
|
@@ -8149,7 +8149,7 @@ class SplitZipReader extends Reader {
|
|
|
8149
8149
|
}
|
|
8150
8150
|
}
|
|
8151
8151
|
|
|
8152
|
-
class
|
|
8152
|
+
class SplitDataWriter extends Stream {
|
|
8153
8153
|
|
|
8154
8154
|
constructor(writerGenerator, maxSize = 4294967296) {
|
|
8155
8155
|
super();
|
|
@@ -8170,6 +8170,7 @@ class SplitZipWriter extends Stream {
|
|
|
8170
8170
|
} else {
|
|
8171
8171
|
diskSourceWriter = value;
|
|
8172
8172
|
diskSourceWriter.size = 0;
|
|
8173
|
+
await initStream(diskSourceWriter);
|
|
8173
8174
|
diskWritable = value.writable;
|
|
8174
8175
|
diskWriter = diskWritable.getWriter();
|
|
8175
8176
|
}
|
|
@@ -8230,6 +8231,9 @@ function readUint8Array(reader, offset, size, diskNumber) {
|
|
|
8230
8231
|
return reader.readUint8Array(offset, size, diskNumber);
|
|
8231
8232
|
}
|
|
8232
8233
|
|
|
8234
|
+
const SplitZipReader = SplitDataReader;
|
|
8235
|
+
const SplitZipWriter = SplitDataWriter;
|
|
8236
|
+
|
|
8233
8237
|
/*
|
|
8234
8238
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
8235
8239
|
|
|
@@ -8456,7 +8460,7 @@ class ZipReader {
|
|
|
8456
8460
|
await initStream(reader);
|
|
8457
8461
|
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
8458
8462
|
if (Array.isArray(reader)) {
|
|
8459
|
-
reader = new
|
|
8463
|
+
reader = new SplitDataReader(reader);
|
|
8460
8464
|
} else {
|
|
8461
8465
|
reader = new BlobReader(await new Response(reader.readable).blob());
|
|
8462
8466
|
}
|
|
@@ -9034,7 +9038,7 @@ class ZipWriter {
|
|
|
9034
9038
|
|
|
9035
9039
|
constructor(writer, options = {}) {
|
|
9036
9040
|
if (writer.writable === UNDEFINED_VALUE && typeof writer.next == FUNCTION_TYPE$1) {
|
|
9037
|
-
writer = new
|
|
9041
|
+
writer = new SplitDataWriter(writer);
|
|
9038
9042
|
}
|
|
9039
9043
|
if (writer instanceof WritableStream) {
|
|
9040
9044
|
writer = { writable: writer };
|
|
@@ -9042,7 +9046,7 @@ class ZipWriter {
|
|
|
9042
9046
|
if (writer.writable.size === UNDEFINED_VALUE) {
|
|
9043
9047
|
writer.writable.size = 0;
|
|
9044
9048
|
}
|
|
9045
|
-
const splitZipFile = writer instanceof
|
|
9049
|
+
const splitZipFile = writer instanceof SplitDataWriter;
|
|
9046
9050
|
if (!splitZipFile) {
|
|
9047
9051
|
Object.assign(writer, {
|
|
9048
9052
|
diskNumber: 0,
|
|
@@ -9099,13 +9103,15 @@ class ZipWriter {
|
|
|
9099
9103
|
}
|
|
9100
9104
|
|
|
9101
9105
|
async close(comment = new Uint8Array(), options = {}) {
|
|
9106
|
+
const zipWriter = this;
|
|
9102
9107
|
const { pendingAddFileCalls, writer } = this;
|
|
9103
9108
|
const { writable } = writer;
|
|
9104
9109
|
while (pendingAddFileCalls.size) {
|
|
9105
9110
|
await Promise.all(Array.from(pendingAddFileCalls));
|
|
9106
9111
|
}
|
|
9107
9112
|
await closeFile(this, comment, options);
|
|
9108
|
-
|
|
9113
|
+
const preventClose = getOptionValue(zipWriter, options, "preventClose");
|
|
9114
|
+
if (!preventClose) {
|
|
9109
9115
|
await writable.close();
|
|
9110
9116
|
}
|
|
9111
9117
|
return writer.getData ? writer.getData() : writable;
|
|
@@ -9128,20 +9134,33 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
9128
9134
|
if (getLength(rawComment) > MAX_16_BITS) {
|
|
9129
9135
|
throw new Error(ERR_INVALID_ENTRY_COMMENT);
|
|
9130
9136
|
}
|
|
9131
|
-
const version = zipWriter
|
|
9137
|
+
const version = getOptionValue(zipWriter, options, "version", VERSION_DEFLATE);
|
|
9132
9138
|
if (version > MAX_16_BITS) {
|
|
9133
9139
|
throw new Error(ERR_INVALID_VERSION);
|
|
9134
9140
|
}
|
|
9135
|
-
const versionMadeBy = zipWriter
|
|
9141
|
+
const versionMadeBy = getOptionValue(zipWriter, options, "versionMadeBy", 20);
|
|
9136
9142
|
if (versionMadeBy > MAX_16_BITS) {
|
|
9137
9143
|
throw new Error(ERR_INVALID_VERSION);
|
|
9138
9144
|
}
|
|
9139
|
-
const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE
|
|
9145
|
+
const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
|
|
9140
9146
|
const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
9141
9147
|
const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
9148
|
+
const msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE, true);
|
|
9149
|
+
const internalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, 0);
|
|
9150
|
+
const externalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, 0);
|
|
9142
9151
|
const password = getOptionValue(zipWriter, options, "password");
|
|
9143
|
-
const encryptionStrength = getOptionValue(zipWriter, options, "encryptionStrength"
|
|
9152
|
+
const encryptionStrength = getOptionValue(zipWriter, options, "encryptionStrength", 3);
|
|
9144
9153
|
const zipCrypto = getOptionValue(zipWriter, options, "zipCrypto");
|
|
9154
|
+
const extendedTimestamp = getOptionValue(zipWriter, options, "extendedTimestamp", true);
|
|
9155
|
+
const keepOrder = getOptionValue(zipWriter, options, "keepOrder", true);
|
|
9156
|
+
const level = getOptionValue(zipWriter, options, "level");
|
|
9157
|
+
const useWebWorkers = getOptionValue(zipWriter, options, "useWebWorkers");
|
|
9158
|
+
const bufferedWrite = getOptionValue(zipWriter, options, "bufferedWrite");
|
|
9159
|
+
const dataDescriptorSignature = getOptionValue(zipWriter, options, "dataDescriptorSignature", false);
|
|
9160
|
+
const signal = getOptionValue(zipWriter, options, "signal");
|
|
9161
|
+
const useCompressionStream = getOptionValue(zipWriter, options, "useCompressionStream");
|
|
9162
|
+
let dataDescriptor = getOptionValue(zipWriter, options, "dataDescriptor", true);
|
|
9163
|
+
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
9145
9164
|
if (password !== UNDEFINED_VALUE && encryptionStrength !== UNDEFINED_VALUE && (encryptionStrength < 1 || encryptionStrength > 3)) {
|
|
9146
9165
|
throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
|
|
9147
9166
|
}
|
|
@@ -9165,24 +9184,9 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
9165
9184
|
offset += 4 + getLength(data);
|
|
9166
9185
|
});
|
|
9167
9186
|
}
|
|
9168
|
-
let extendedTimestamp = getOptionValue(zipWriter, options, "extendedTimestamp");
|
|
9169
|
-
if (extendedTimestamp === UNDEFINED_VALUE) {
|
|
9170
|
-
extendedTimestamp = true;
|
|
9171
|
-
}
|
|
9172
9187
|
let maximumCompressedSize = 0;
|
|
9173
9188
|
let maximumEntrySize = 0;
|
|
9174
|
-
let keepOrder = getOptionValue(zipWriter, options, "keepOrder");
|
|
9175
|
-
if (keepOrder === UNDEFINED_VALUE) {
|
|
9176
|
-
keepOrder = true;
|
|
9177
|
-
}
|
|
9178
9189
|
let uncompressedSize = 0;
|
|
9179
|
-
let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
9180
|
-
if (msDosCompatible === UNDEFINED_VALUE) {
|
|
9181
|
-
msDosCompatible = true;
|
|
9182
|
-
}
|
|
9183
|
-
const internalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE) || 0;
|
|
9184
|
-
const externalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE) || 0;
|
|
9185
|
-
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
9186
9190
|
if (reader) {
|
|
9187
9191
|
if (reader instanceof ReadableStream) {
|
|
9188
9192
|
reader = {
|
|
@@ -9191,7 +9195,7 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
9191
9195
|
}
|
|
9192
9196
|
await initStream(reader);
|
|
9193
9197
|
if (reader.size === UNDEFINED_VALUE) {
|
|
9194
|
-
|
|
9198
|
+
dataDescriptor = true;
|
|
9195
9199
|
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
9196
9200
|
zip64 = true;
|
|
9197
9201
|
maximumCompressedSize = MAX_32_BITS;
|
|
@@ -9201,10 +9205,11 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
9201
9205
|
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
|
|
9202
9206
|
}
|
|
9203
9207
|
}
|
|
9204
|
-
const { diskOffset } = zipWriter.writer;
|
|
9208
|
+
const { diskOffset, diskNumber } = zipWriter.writer;
|
|
9205
9209
|
if (zipWriter.offset + zipWriter.pendingEntriesSize - diskOffset >= MAX_32_BITS ||
|
|
9206
9210
|
uncompressedSize >= MAX_32_BITS ||
|
|
9207
|
-
maximumCompressedSize >= MAX_32_BITS
|
|
9211
|
+
maximumCompressedSize >= MAX_32_BITS ||
|
|
9212
|
+
diskNumber >= MAX_16_BITS) {
|
|
9208
9213
|
if (zip64 === false || !keepOrder) {
|
|
9209
9214
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
9210
9215
|
} else {
|
|
@@ -9212,19 +9217,6 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
9212
9217
|
}
|
|
9213
9218
|
}
|
|
9214
9219
|
zip64 = zip64 || false;
|
|
9215
|
-
const level = getOptionValue(zipWriter, options, "level");
|
|
9216
|
-
const useWebWorkers = getOptionValue(zipWriter, options, "useWebWorkers");
|
|
9217
|
-
const bufferedWrite = getOptionValue(zipWriter, options, "bufferedWrite");
|
|
9218
|
-
let dataDescriptor = getOptionValue(zipWriter, options, "dataDescriptor");
|
|
9219
|
-
let dataDescriptorSignature = getOptionValue(zipWriter, options, "dataDescriptorSignature");
|
|
9220
|
-
const signal = getOptionValue(zipWriter, options, "signal");
|
|
9221
|
-
const useCompressionStream = getOptionValue(zipWriter, options, "useCompressionStream");
|
|
9222
|
-
if (dataDescriptor === UNDEFINED_VALUE) {
|
|
9223
|
-
dataDescriptor = true;
|
|
9224
|
-
}
|
|
9225
|
-
if (dataDescriptor && dataDescriptorSignature === UNDEFINED_VALUE) {
|
|
9226
|
-
dataDescriptorSignature = false;
|
|
9227
|
-
}
|
|
9228
9220
|
options = Object.assign({}, options, {
|
|
9229
9221
|
rawFilename,
|
|
9230
9222
|
rawComment,
|
|
@@ -9258,12 +9250,8 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
9258
9250
|
let fileEntry;
|
|
9259
9251
|
try {
|
|
9260
9252
|
fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo }, options);
|
|
9253
|
+
} finally {
|
|
9261
9254
|
zipWriter.pendingEntriesSize -= maximumEntrySize;
|
|
9262
|
-
} catch (error) {
|
|
9263
|
-
if (!error.corruptedEntry) {
|
|
9264
|
-
zipWriter.pendingEntriesSize -= maximumEntrySize;
|
|
9265
|
-
}
|
|
9266
|
-
throw error;
|
|
9267
9255
|
}
|
|
9268
9256
|
Object.assign(fileEntry, { name, comment, extraField });
|
|
9269
9257
|
return new Entry(fileEntry);
|
|
@@ -9301,8 +9289,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
9301
9289
|
await initStream(writer);
|
|
9302
9290
|
} else {
|
|
9303
9291
|
fileWriter = writer;
|
|
9304
|
-
|
|
9305
|
-
releaseLockWriter = () => delete zipWriter.lockWriter;
|
|
9292
|
+
initLockWriter();
|
|
9306
9293
|
}
|
|
9307
9294
|
await initStream(fileWriter);
|
|
9308
9295
|
const { writable, diskNumber } = writer;
|
|
@@ -9331,7 +9318,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
9331
9318
|
await requestLockWriter();
|
|
9332
9319
|
writingBufferedEntryData = true;
|
|
9333
9320
|
if (!dataDescriptor) {
|
|
9334
|
-
blob = await
|
|
9321
|
+
blob = await writeMissingHeaderInfo(fileEntry, blob, writable, options);
|
|
9335
9322
|
}
|
|
9336
9323
|
fileEntry.diskNumberStart = writer.diskNumber;
|
|
9337
9324
|
diskOffset = writer.diskOffset;
|
|
@@ -9341,7 +9328,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
9341
9328
|
}
|
|
9342
9329
|
fileEntry.offset = zipWriter.offset - diskOffset;
|
|
9343
9330
|
if (fileEntry.zip64) {
|
|
9344
|
-
|
|
9331
|
+
setZip64OffsetInfo(fileEntry);
|
|
9345
9332
|
} else if (fileEntry.offset >= MAX_32_BITS) {
|
|
9346
9333
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
9347
9334
|
}
|
|
@@ -9374,6 +9361,11 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
9374
9361
|
fileEntry.lock = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
|
|
9375
9362
|
}
|
|
9376
9363
|
|
|
9364
|
+
function initLockWriter() {
|
|
9365
|
+
zipWriter.lockWriter = Promise.resolve();
|
|
9366
|
+
releaseLockWriter = () => delete zipWriter.lockWriter;
|
|
9367
|
+
}
|
|
9368
|
+
|
|
9377
9369
|
async function requestLockWriter() {
|
|
9378
9370
|
const { lockWriter } = zipWriter;
|
|
9379
9371
|
if (lockWriter) {
|
|
@@ -9532,6 +9524,7 @@ function getHeaderInfo(options) {
|
|
|
9532
9524
|
} = options;
|
|
9533
9525
|
const compressed = level !== 0 && !directory;
|
|
9534
9526
|
const encrypted = Boolean(password && getLength(password));
|
|
9527
|
+
let version = options.version;
|
|
9535
9528
|
let rawExtraFieldAES;
|
|
9536
9529
|
if (encrypted && !zipCrypto) {
|
|
9537
9530
|
rawExtraFieldAES = new Uint8Array(getLength(EXTRAFIELD_DATA_AES) + 2);
|
|
@@ -9583,7 +9576,6 @@ function getHeaderInfo(options) {
|
|
|
9583
9576
|
if (compressed) {
|
|
9584
9577
|
compressionMethod = COMPRESSION_METHOD_DEFLATE;
|
|
9585
9578
|
}
|
|
9586
|
-
let version = options.version || VERSION_DEFLATE;
|
|
9587
9579
|
if (zip64) {
|
|
9588
9580
|
version = version > VERSION_ZIP64 ? version : VERSION_ZIP64;
|
|
9589
9581
|
}
|
|
@@ -9717,7 +9709,7 @@ function setEntryInfo(entryInfo, options) {
|
|
|
9717
9709
|
}
|
|
9718
9710
|
}
|
|
9719
9711
|
|
|
9720
|
-
async function
|
|
9712
|
+
async function writeMissingHeaderInfo(fileEntry, entryData, writable, { zipCrypto }) {
|
|
9721
9713
|
const arrayBuffer = await sliceAsArrayBuffer(entryData, 0, 26);
|
|
9722
9714
|
const arrayBufferView = new DataView(arrayBuffer);
|
|
9723
9715
|
if (!fileEntry.encrypted || zipCrypto) {
|
|
@@ -9734,7 +9726,7 @@ async function setMissingInfo(fileEntry, entryData, writable, { zipCrypto }) {
|
|
|
9734
9726
|
return entryData.slice(arrayBuffer.byteLength);
|
|
9735
9727
|
}
|
|
9736
9728
|
|
|
9737
|
-
function
|
|
9729
|
+
function setZip64OffsetInfo(fileEntry) {
|
|
9738
9730
|
const { rawExtraFieldZip64, offset, diskNumberStart } = fileEntry;
|
|
9739
9731
|
const rawExtraFieldZip64View = getDataView(rawExtraFieldZip64);
|
|
9740
9732
|
setBigUint64(rawExtraFieldZip64View, 20, BigInt(offset));
|
|
@@ -9743,10 +9735,10 @@ function setZip64Info(fileEntry) {
|
|
|
9743
9735
|
|
|
9744
9736
|
async function closeFile(zipWriter, comment, options) {
|
|
9745
9737
|
const { files, writer } = zipWriter;
|
|
9746
|
-
let offset = 0;
|
|
9747
|
-
let directoryDataLength = 0;
|
|
9748
9738
|
const { diskOffset, writable } = writer;
|
|
9749
9739
|
let { diskNumber } = writer;
|
|
9740
|
+
let offset = 0;
|
|
9741
|
+
let directoryDataLength = 0;
|
|
9750
9742
|
let directoryOffset = zipWriter.offset - diskOffset;
|
|
9751
9743
|
let filesLength = files.size;
|
|
9752
9744
|
for (const [, {
|
|
@@ -9768,14 +9760,6 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
9768
9760
|
rawExtraFieldNTFS,
|
|
9769
9761
|
rawExtraField);
|
|
9770
9762
|
}
|
|
9771
|
-
let zip64 = options.zip64 || zipWriter.options.zip64 || false;
|
|
9772
|
-
if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS) {
|
|
9773
|
-
if (options.zip64 === false || zipWriter.options.zip64 === false) {
|
|
9774
|
-
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
9775
|
-
} else {
|
|
9776
|
-
zip64 = true;
|
|
9777
|
-
}
|
|
9778
|
-
}
|
|
9779
9763
|
const directoryArray = new Uint8Array(directoryDataLength);
|
|
9780
9764
|
const directoryView = getDataView(directoryArray);
|
|
9781
9765
|
for (const [indexFileEntry, fileEntry] of Array.from(files.values()).entries()) {
|
|
@@ -9841,13 +9825,21 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
9841
9825
|
}
|
|
9842
9826
|
await initStream(writer);
|
|
9843
9827
|
await writeData(writable, directoryArray);
|
|
9844
|
-
const endOfdirectoryArray = new Uint8Array(zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
9845
|
-
const endOfdirectoryView = getDataView(endOfdirectoryArray);
|
|
9846
9828
|
let lastDiskNumber = writer.diskNumber;
|
|
9847
9829
|
const { availableSize } = writer;
|
|
9848
|
-
if (availableSize <
|
|
9830
|
+
if (availableSize < END_OF_CENTRAL_DIR_LENGTH) {
|
|
9849
9831
|
lastDiskNumber++;
|
|
9850
9832
|
}
|
|
9833
|
+
let zip64 = getOptionValue(zipWriter, options, "zip64");
|
|
9834
|
+
if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS || lastDiskNumber >= MAX_16_BITS) {
|
|
9835
|
+
if (zip64 === false) {
|
|
9836
|
+
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
9837
|
+
} else {
|
|
9838
|
+
zip64 = true;
|
|
9839
|
+
}
|
|
9840
|
+
}
|
|
9841
|
+
const endOfdirectoryArray = new Uint8Array(zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
9842
|
+
const endOfdirectoryView = getDataView(endOfdirectoryArray);
|
|
9851
9843
|
offset = 0;
|
|
9852
9844
|
if (zip64) {
|
|
9853
9845
|
setUint32(endOfdirectoryView, 0, ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
|
|
@@ -9912,8 +9904,9 @@ function getTimeNTFS(date) {
|
|
|
9912
9904
|
}
|
|
9913
9905
|
}
|
|
9914
9906
|
|
|
9915
|
-
function getOptionValue(zipWriter, options, name) {
|
|
9916
|
-
|
|
9907
|
+
function getOptionValue(zipWriter, options, name, defaultValue) {
|
|
9908
|
+
const result = options[name] === UNDEFINED_VALUE ? zipWriter.options[name] : options[name];
|
|
9909
|
+
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
9917
9910
|
}
|
|
9918
9911
|
|
|
9919
9912
|
function getMaximumCompressedSize(uncompressedSize) {
|
|
@@ -10599,7 +10592,7 @@ try {
|
|
|
10599
10592
|
configure({ baseURL });
|
|
10600
10593
|
e(configure);
|
|
10601
10594
|
|
|
10602
|
-
/// <reference types="./index" />
|
|
10595
|
+
/// <reference types="./index.d.ts" />
|
|
10603
10596
|
|
|
10604
10597
|
configure({ Deflate: ZipDeflate, Inflate: ZipInflate });
|
|
10605
10598
|
|
|
@@ -10634,6 +10627,8 @@ exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
|
10634
10627
|
exports.HttpRangeReader = HttpRangeReader;
|
|
10635
10628
|
exports.HttpReader = HttpReader;
|
|
10636
10629
|
exports.Reader = Reader;
|
|
10630
|
+
exports.SplitDataReader = SplitDataReader;
|
|
10631
|
+
exports.SplitDataWriter = SplitDataWriter;
|
|
10637
10632
|
exports.SplitZipReader = SplitZipReader;
|
|
10638
10633
|
exports.SplitZipWriter = SplitZipWriter;
|
|
10639
10634
|
exports.TextReader = TextReader;
|
package/index.d.ts
CHANGED
|
@@ -365,10 +365,17 @@ export class Data64URIReader extends Reader<string> { }
|
|
|
365
365
|
*/
|
|
366
366
|
export class Uint8ArrayReader extends Reader<Uint8Array> { }
|
|
367
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Represents a `Reader` instance used to read data provided as an array of `Reader` instances (i.e. split zip files).
|
|
370
|
+
*
|
|
371
|
+
* @deprecated Use {@link SplitDataReader} instead.
|
|
372
|
+
*/
|
|
373
|
+
export class SplitZipReader extends SplitDataReader
|
|
374
|
+
|
|
368
375
|
/**
|
|
369
376
|
* Represents a `Reader` instance used to read data provided as an array of `Reader` instances (i.e. split zip files).
|
|
370
377
|
*/
|
|
371
|
-
export class
|
|
378
|
+
export class SplitDataReader extends Reader<Reader<unknown>[] | ReadableReader[] | ReadableStream[]> { }
|
|
372
379
|
|
|
373
380
|
/**
|
|
374
381
|
* Represents a URL stored into a `string`.
|
|
@@ -554,10 +561,17 @@ export class Data64URIWriter extends Writer<string> {
|
|
|
554
561
|
constructor(mimeString?: string)
|
|
555
562
|
}
|
|
556
563
|
|
|
564
|
+
/**
|
|
565
|
+
* Represents a `Writer` instance used to retrieve the written data from a generator of `Writer` instances (i.e. split zip files).
|
|
566
|
+
*
|
|
567
|
+
* @deprecated Use {@link SplitDataWriter} instead.
|
|
568
|
+
*/
|
|
569
|
+
export class SplitZipWriter extends SplitDataWriter
|
|
570
|
+
|
|
557
571
|
/**
|
|
558
572
|
* Represents a `Writer` instance used to retrieve the written data from a generator of `Writer` instances (i.e. split zip files).
|
|
559
573
|
*/
|
|
560
|
-
export class
|
|
574
|
+
export class SplitDataWriter implements Initializable, WritableWriter {
|
|
561
575
|
/**
|
|
562
576
|
* The `WritableStream` instance.
|
|
563
577
|
*/
|
|
@@ -567,7 +581,7 @@ export class SplitZipWriter implements Initializable, WritableWriter {
|
|
|
567
581
|
*/
|
|
568
582
|
init(): Promise<void>
|
|
569
583
|
/**
|
|
570
|
-
* Creates the `
|
|
584
|
+
* Creates the `SplitDataWriter` instance
|
|
571
585
|
*
|
|
572
586
|
* @param writerGenerator The MIME type of the content.
|
|
573
587
|
* @param maxSize The maximum size of the data written into `Writer` instances (default: 4GB).
|
|
@@ -875,7 +889,7 @@ export class ZipWriter<Type> {
|
|
|
875
889
|
* @param writer The `Writer` instance where the zip content will be written.
|
|
876
890
|
* @param options The options.
|
|
877
891
|
*/
|
|
878
|
-
constructor(writer: Writer<Type> | WritableWriter | WritableStream |
|
|
892
|
+
constructor(writer: Writer<Type> | WritableWriter | WritableStream | AsyncGenerator<Writer<unknown> | WritableWriter | WritableStream, boolean>, options?: ZipWriterConstructorOptions)
|
|
879
893
|
/**
|
|
880
894
|
* `true` if the zip contains at least one entry that has been partially written.
|
|
881
895
|
*/
|
|
@@ -949,6 +963,12 @@ interface ZipWriterConstructorOptions {
|
|
|
949
963
|
* @defaultValue false
|
|
950
964
|
*/
|
|
951
965
|
zip64?: boolean
|
|
966
|
+
/**
|
|
967
|
+
* `true` to prevent closing of `Writer#writable`.
|
|
968
|
+
*
|
|
969
|
+
* @defaultValue false
|
|
970
|
+
*/
|
|
971
|
+
preventClose?: boolean
|
|
952
972
|
/**
|
|
953
973
|
* The level of compression.
|
|
954
974
|
*
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/// <reference types="./index" />
|
|
1
|
+
/// <reference types="./index.d.ts" />
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
@@ -56,6 +56,8 @@ export {
|
|
|
56
56
|
Uint8ArrayReader,
|
|
57
57
|
SplitZipReader,
|
|
58
58
|
SplitZipWriter,
|
|
59
|
+
SplitDataReader,
|
|
60
|
+
SplitDataWriter,
|
|
59
61
|
ERR_HTTP_RANGE,
|
|
60
62
|
ERR_BAD_FORMAT,
|
|
61
63
|
ERR_EOCDR_NOT_FOUND,
|
package/lib/core/io.js
CHANGED
|
@@ -521,7 +521,7 @@ class Uint8ArrayWriter extends Writer {
|
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
523
|
|
|
524
|
-
class
|
|
524
|
+
class SplitDataReader extends Reader {
|
|
525
525
|
|
|
526
526
|
constructor(readers) {
|
|
527
527
|
super();
|
|
@@ -567,7 +567,7 @@ class SplitZipReader extends Reader {
|
|
|
567
567
|
}
|
|
568
568
|
}
|
|
569
569
|
|
|
570
|
-
class
|
|
570
|
+
class SplitDataWriter extends Stream {
|
|
571
571
|
|
|
572
572
|
constructor(writerGenerator, maxSize = 4294967296) {
|
|
573
573
|
super();
|
|
@@ -588,6 +588,7 @@ class SplitZipWriter extends Stream {
|
|
|
588
588
|
} else {
|
|
589
589
|
diskSourceWriter = value;
|
|
590
590
|
diskSourceWriter.size = 0;
|
|
591
|
+
await initStream(diskSourceWriter);
|
|
591
592
|
diskWritable = value.writable;
|
|
592
593
|
diskWriter = diskWritable.getWriter();
|
|
593
594
|
}
|
|
@@ -648,6 +649,9 @@ function readUint8Array(reader, offset, size, diskNumber) {
|
|
|
648
649
|
return reader.readUint8Array(offset, size, diskNumber);
|
|
649
650
|
}
|
|
650
651
|
|
|
652
|
+
const SplitZipReader = SplitDataReader;
|
|
653
|
+
const SplitZipWriter = SplitDataWriter;
|
|
654
|
+
|
|
651
655
|
export {
|
|
652
656
|
initStream,
|
|
653
657
|
readUint8Array,
|
|
@@ -665,6 +669,8 @@ export {
|
|
|
665
669
|
HttpRangeReader,
|
|
666
670
|
SplitZipReader,
|
|
667
671
|
SplitZipWriter,
|
|
672
|
+
SplitDataReader,
|
|
673
|
+
SplitDataWriter,
|
|
668
674
|
ERR_HTTP_RANGE,
|
|
669
675
|
ERR_ITERATOR_COMPLETED_TOO_SOON
|
|
670
676
|
};
|
package/lib/core/zip-reader.js
CHANGED
|
@@ -73,7 +73,7 @@ import {
|
|
|
73
73
|
initStream,
|
|
74
74
|
readUint8Array,
|
|
75
75
|
BlobReader,
|
|
76
|
-
|
|
76
|
+
SplitDataReader
|
|
77
77
|
} from "./io.js";
|
|
78
78
|
import { decodeText } from "./util/decode-text.js";
|
|
79
79
|
import { Crc32 } from "./streams/codecs/crc32.js";
|
|
@@ -147,7 +147,7 @@ class ZipReader {
|
|
|
147
147
|
await initStream(reader);
|
|
148
148
|
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
149
149
|
if (Array.isArray(reader)) {
|
|
150
|
-
reader = new
|
|
150
|
+
reader = new SplitDataReader(reader);
|
|
151
151
|
} else {
|
|
152
152
|
reader = new BlobReader(await new Response(reader.readable).blob());
|
|
153
153
|
}
|