@zip.js/zip.js 2.21.0 → 2.22.0
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/deno.json +1 -1
- package/dist/zip-core-external.js +30 -15
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +30 -14
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +30 -18
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +30 -18
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +30 -18
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +30 -18
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +30 -18
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +30 -14
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +30 -14
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +30 -14
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +30 -18
- package/index-native.min.js +1 -1
- package/index.cjs +30 -18
- package/index.d.cts +36 -14
- package/index.d.ts +36 -14
- package/index.min.js +1 -1
- package/lib/core/configuration.js +1 -3
- package/lib/core/options.js +11 -0
- package/lib/core/version.js +1 -1
- package/lib/core/zip-fs.js +2 -6
- package/lib/core/zip-reader.js +1 -1
- package/lib/core/zip-writer.js +19 -9
- package/lib/zip-core-base.js +1 -0
- package/package.json +1 -1
package/dist/zip.js
CHANGED
|
@@ -225,6 +225,7 @@
|
|
|
225
225
|
const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
|
|
226
226
|
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
227
227
|
const ERR_INVALID_PASS_THROUGH_VALUE = "Invalid passThrough option (must be a boolean or 'compressed')";
|
|
228
|
+
const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
|
|
228
229
|
const ERR_ABORTED = "The operation was aborted";
|
|
229
230
|
const ABORT_ERROR_NAME = "AbortError";
|
|
230
231
|
|
|
@@ -235,6 +236,13 @@
|
|
|
235
236
|
return value;
|
|
236
237
|
}
|
|
237
238
|
|
|
239
|
+
function checkReaderOptionsObject(readerOptions) {
|
|
240
|
+
if (readerOptions && (typeof readerOptions != OBJECT_TYPE || Array.isArray(readerOptions))) {
|
|
241
|
+
throw new Error(ERR_INVALID_READER_OPTIONS);
|
|
242
|
+
}
|
|
243
|
+
return readerOptions;
|
|
244
|
+
}
|
|
245
|
+
|
|
238
246
|
function checkSignalOption(signal) {
|
|
239
247
|
if (signal && (typeof signal.addEventListener != FUNCTION_TYPE || typeof signal.aborted != BOOLEAN_TYPE)) {
|
|
240
248
|
throw new Error(ERR_INVALID_SIGNAL);
|
|
@@ -330,7 +338,6 @@
|
|
|
330
338
|
workerStartupTimeout: 5000,
|
|
331
339
|
useWebWorkers: true,
|
|
332
340
|
useCompressionStream: true,
|
|
333
|
-
transferStreams: true,
|
|
334
341
|
CompressionStream: typeof CompressionStream != UNDEFINED_TYPE && CompressionStream,
|
|
335
342
|
DecompressionStream: typeof DecompressionStream != UNDEFINED_TYPE && DecompressionStream
|
|
336
343
|
};
|
|
@@ -344,8 +351,7 @@
|
|
|
344
351
|
];
|
|
345
352
|
const BOOLEAN_PROPERTY_NAMES = [
|
|
346
353
|
"useCompressionStream",
|
|
347
|
-
"useWebWorkers"
|
|
348
|
-
"transferStreams"
|
|
354
|
+
"useWebWorkers"
|
|
349
355
|
];
|
|
350
356
|
const NUMBER_PROPERTY_NAMES = [
|
|
351
357
|
"chunkSize",
|
|
@@ -4835,7 +4841,7 @@
|
|
|
4835
4841
|
constructor(reader, options = {}) {
|
|
4836
4842
|
Object.assign(this, {
|
|
4837
4843
|
reader: new GenericReader(reader),
|
|
4838
|
-
options,
|
|
4844
|
+
options: options || {},
|
|
4839
4845
|
readRanges: { indexes: new Set(), sortedRanges: [], pendingRanges: [] },
|
|
4840
4846
|
entriesMissingZip64ExtraField: new WeakSet()
|
|
4841
4847
|
});
|
|
@@ -6855,6 +6861,7 @@
|
|
|
6855
6861
|
async function appendZipEntries(zipWriter, reader, options = {}) {
|
|
6856
6862
|
const { pendingAddFileCalls, filenames, fileEntries } = zipWriter;
|
|
6857
6863
|
const filter = checkFunctionOption(options.filter);
|
|
6864
|
+
const readerOptions = checkReaderOptionsObject(options.readerOptions);
|
|
6858
6865
|
while (pendingAddFileCalls.size) {
|
|
6859
6866
|
await Promise.allSettled(Array.from(pendingAddFileCalls));
|
|
6860
6867
|
}
|
|
@@ -6871,15 +6878,19 @@
|
|
|
6871
6878
|
await initStream(reader);
|
|
6872
6879
|
}
|
|
6873
6880
|
const { ZipReader, getEntryDataDescriptorLength } = await Promise.resolve().then(function () { return zipReader; });
|
|
6874
|
-
const zipReader$1 = new ZipReader(reader);
|
|
6875
|
-
const entries = await zipReader$1.getEntries();
|
|
6881
|
+
const zipReader$1 = new ZipReader(reader, readerOptions);
|
|
6876
6882
|
const keptEntries = [];
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6883
|
+
let entries;
|
|
6884
|
+
try {
|
|
6885
|
+
entries = await zipReader$1.getEntries();
|
|
6886
|
+
for (const entry of entries) {
|
|
6887
|
+
if (!filter || await filter(entry, getExistingEntry(fileEntries, entry.filename))) {
|
|
6888
|
+
keptEntries.push(entry);
|
|
6889
|
+
}
|
|
6880
6890
|
}
|
|
6891
|
+
} finally {
|
|
6892
|
+
await zipReader$1.close();
|
|
6881
6893
|
}
|
|
6882
|
-
await zipReader$1.close();
|
|
6883
6894
|
await initStream(zipWriter.writer);
|
|
6884
6895
|
const { directoryOffset, entriesMissingZip64ExtraField } = zipReader$1;
|
|
6885
6896
|
keptEntries.forEach(entry => {
|
|
@@ -6949,7 +6960,7 @@
|
|
|
6949
6960
|
setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
|
|
6950
6961
|
}
|
|
6951
6962
|
const { offset, diskNumberStart } = entryPositions.get(entry);
|
|
6952
|
-
Object.assign(entry, {
|
|
6963
|
+
fileEntries.set(entry.filename, Object.assign({}, entry, {
|
|
6953
6964
|
zip64Enabled: true,
|
|
6954
6965
|
zip64UncompressedSize,
|
|
6955
6966
|
zip64CompressedSize,
|
|
@@ -6966,8 +6977,7 @@
|
|
|
6966
6977
|
rawCentralExtraField: EMPTY_UINT8_ARRAY,
|
|
6967
6978
|
headerArray,
|
|
6968
6979
|
headerView
|
|
6969
|
-
});
|
|
6970
|
-
fileEntries.set(entry.filename, entry);
|
|
6980
|
+
}));
|
|
6971
6981
|
});
|
|
6972
6982
|
} catch (error) {
|
|
6973
6983
|
appendedFilenames.forEach(filename => filenames.delete(filename));
|
|
@@ -6981,6 +6991,11 @@
|
|
|
6981
6991
|
}
|
|
6982
6992
|
}
|
|
6983
6993
|
|
|
6994
|
+
function getExistingEntry(fileEntries, filename) {
|
|
6995
|
+
const fileEntry = fileEntries.get(filename);
|
|
6996
|
+
return fileEntry ? new Entry(fileEntry) : UNDEFINED_VALUE;
|
|
6997
|
+
}
|
|
6998
|
+
|
|
6984
6999
|
async function prependZipEntries(zipWriter, reader) {
|
|
6985
7000
|
if (zipWriter.filenames.size) {
|
|
6986
7001
|
throw new Error(ERR_ZIP_NOT_EMPTY);
|
|
@@ -9125,7 +9140,7 @@
|
|
|
9125
9140
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9126
9141
|
*/
|
|
9127
9142
|
|
|
9128
|
-
const VERSION = "2.
|
|
9143
|
+
const VERSION = "2.22.0";
|
|
9129
9144
|
|
|
9130
9145
|
/*
|
|
9131
9146
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -10238,6 +10253,7 @@
|
|
|
10238
10253
|
exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
|
|
10239
10254
|
exports.ERR_INVALID_PASS_THROUGH_VALUE = ERR_INVALID_PASS_THROUGH_VALUE;
|
|
10240
10255
|
exports.ERR_INVALID_READER = ERR_INVALID_READER;
|
|
10256
|
+
exports.ERR_INVALID_READER_OPTIONS = ERR_INVALID_READER_OPTIONS;
|
|
10241
10257
|
exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
|
|
10242
10258
|
exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
|
|
10243
10259
|
exports.ERR_INVALID_STRICTNESS = ERR_INVALID_STRICTNESS;
|