@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-fs-external.js
CHANGED
|
@@ -216,6 +216,7 @@ const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
|
|
|
216
216
|
const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
|
|
217
217
|
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
218
218
|
const ERR_INVALID_PASS_THROUGH_VALUE = "Invalid passThrough option (must be a boolean or 'compressed')";
|
|
219
|
+
const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
|
|
219
220
|
const ERR_ABORTED = "The operation was aborted";
|
|
220
221
|
const ABORT_ERROR_NAME$1 = "AbortError";
|
|
221
222
|
|
|
@@ -226,6 +227,13 @@ function checkFunctionOption(value) {
|
|
|
226
227
|
return value;
|
|
227
228
|
}
|
|
228
229
|
|
|
230
|
+
function checkReaderOptionsObject(readerOptions) {
|
|
231
|
+
if (readerOptions && (typeof readerOptions != OBJECT_TYPE || Array.isArray(readerOptions))) {
|
|
232
|
+
throw new Error(ERR_INVALID_READER_OPTIONS);
|
|
233
|
+
}
|
|
234
|
+
return readerOptions;
|
|
235
|
+
}
|
|
236
|
+
|
|
229
237
|
function checkSignalOption(signal) {
|
|
230
238
|
if (signal && (typeof signal.addEventListener != FUNCTION_TYPE || typeof signal.aborted != BOOLEAN_TYPE)) {
|
|
231
239
|
throw new Error(ERR_INVALID_SIGNAL);
|
|
@@ -321,7 +329,6 @@ const DEFAULT_CONFIGURATION = {
|
|
|
321
329
|
workerStartupTimeout: 5000,
|
|
322
330
|
useWebWorkers: true,
|
|
323
331
|
useCompressionStream: true,
|
|
324
|
-
transferStreams: true,
|
|
325
332
|
CompressionStream: typeof CompressionStream != UNDEFINED_TYPE && CompressionStream,
|
|
326
333
|
DecompressionStream: typeof DecompressionStream != UNDEFINED_TYPE && DecompressionStream
|
|
327
334
|
};
|
|
@@ -335,8 +342,7 @@ const URI_PROPERTY_NAMES = [
|
|
|
335
342
|
];
|
|
336
343
|
const BOOLEAN_PROPERTY_NAMES = [
|
|
337
344
|
"useCompressionStream",
|
|
338
|
-
"useWebWorkers"
|
|
339
|
-
"transferStreams"
|
|
345
|
+
"useWebWorkers"
|
|
340
346
|
];
|
|
341
347
|
const NUMBER_PROPERTY_NAMES = [
|
|
342
348
|
"chunkSize",
|
|
@@ -4880,7 +4886,7 @@ class ZipReader {
|
|
|
4880
4886
|
constructor(reader, options = {}) {
|
|
4881
4887
|
Object.assign(this, {
|
|
4882
4888
|
reader: new GenericReader(reader),
|
|
4883
|
-
options,
|
|
4889
|
+
options: options || {},
|
|
4884
4890
|
readRanges: { indexes: new Set(), sortedRanges: [], pendingRanges: [] },
|
|
4885
4891
|
entriesMissingZip64ExtraField: new WeakSet()
|
|
4886
4892
|
});
|
|
@@ -6900,6 +6906,7 @@ function watchPromiseError(zipWriter, promise) {
|
|
|
6900
6906
|
async function appendZipEntries(zipWriter, reader, options = {}) {
|
|
6901
6907
|
const { pendingAddFileCalls, filenames, fileEntries } = zipWriter;
|
|
6902
6908
|
const filter = checkFunctionOption(options.filter);
|
|
6909
|
+
const readerOptions = checkReaderOptionsObject(options.readerOptions);
|
|
6903
6910
|
while (pendingAddFileCalls.size) {
|
|
6904
6911
|
await Promise.allSettled(Array.from(pendingAddFileCalls));
|
|
6905
6912
|
}
|
|
@@ -6916,15 +6923,19 @@ async function appendZipEntries(zipWriter, reader, options = {}) {
|
|
|
6916
6923
|
await initStream(reader);
|
|
6917
6924
|
}
|
|
6918
6925
|
const { ZipReader, getEntryDataDescriptorLength } = await Promise.resolve().then(function () { return zipReader; });
|
|
6919
|
-
const zipReader$1 = new ZipReader(reader);
|
|
6920
|
-
const entries = await zipReader$1.getEntries();
|
|
6926
|
+
const zipReader$1 = new ZipReader(reader, readerOptions);
|
|
6921
6927
|
const keptEntries = [];
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6928
|
+
let entries;
|
|
6929
|
+
try {
|
|
6930
|
+
entries = await zipReader$1.getEntries();
|
|
6931
|
+
for (const entry of entries) {
|
|
6932
|
+
if (!filter || await filter(entry, getExistingEntry(fileEntries, entry.filename))) {
|
|
6933
|
+
keptEntries.push(entry);
|
|
6934
|
+
}
|
|
6925
6935
|
}
|
|
6936
|
+
} finally {
|
|
6937
|
+
await zipReader$1.close();
|
|
6926
6938
|
}
|
|
6927
|
-
await zipReader$1.close();
|
|
6928
6939
|
await initStream(zipWriter.writer);
|
|
6929
6940
|
const { directoryOffset, entriesMissingZip64ExtraField } = zipReader$1;
|
|
6930
6941
|
keptEntries.forEach(entry => {
|
|
@@ -6994,7 +7005,7 @@ async function appendZipEntries(zipWriter, reader, options = {}) {
|
|
|
6994
7005
|
setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
|
|
6995
7006
|
}
|
|
6996
7007
|
const { offset, diskNumberStart } = entryPositions.get(entry);
|
|
6997
|
-
Object.assign(entry, {
|
|
7008
|
+
fileEntries.set(entry.filename, Object.assign({}, entry, {
|
|
6998
7009
|
zip64Enabled: true,
|
|
6999
7010
|
zip64UncompressedSize,
|
|
7000
7011
|
zip64CompressedSize,
|
|
@@ -7011,8 +7022,7 @@ async function appendZipEntries(zipWriter, reader, options = {}) {
|
|
|
7011
7022
|
rawCentralExtraField: EMPTY_UINT8_ARRAY,
|
|
7012
7023
|
headerArray,
|
|
7013
7024
|
headerView
|
|
7014
|
-
});
|
|
7015
|
-
fileEntries.set(entry.filename, entry);
|
|
7025
|
+
}));
|
|
7016
7026
|
});
|
|
7017
7027
|
} catch (error) {
|
|
7018
7028
|
appendedFilenames.forEach(filename => filenames.delete(filename));
|
|
@@ -7026,6 +7036,11 @@ async function appendZipEntries(zipWriter, reader, options = {}) {
|
|
|
7026
7036
|
}
|
|
7027
7037
|
}
|
|
7028
7038
|
|
|
7039
|
+
function getExistingEntry(fileEntries, filename) {
|
|
7040
|
+
const fileEntry = fileEntries.get(filename);
|
|
7041
|
+
return fileEntry ? new Entry(fileEntry) : UNDEFINED_VALUE;
|
|
7042
|
+
}
|
|
7043
|
+
|
|
7029
7044
|
async function prependZipEntries(zipWriter, reader) {
|
|
7030
7045
|
if (zipWriter.filenames.size) {
|
|
7031
7046
|
throw new Error(ERR_ZIP_NOT_EMPTY);
|
|
@@ -9268,7 +9283,7 @@ function formatSupported(StreamClass, format) {
|
|
|
9268
9283
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9269
9284
|
*/
|
|
9270
9285
|
|
|
9271
|
-
const VERSION = "2.
|
|
9286
|
+
const VERSION = "2.22.0";
|
|
9272
9287
|
|
|
9273
9288
|
/*
|
|
9274
9289
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -10315,7 +10330,6 @@ const DUPLICATES_KEEP_FIRST = "keep-first";
|
|
|
10315
10330
|
const DUPLICATES_KEEP_LAST = "keep-last";
|
|
10316
10331
|
const DUPLICATES_VALUES = new Set([DUPLICATES_THROW, DUPLICATES_KEEP_FIRST, DUPLICATES_KEEP_LAST]);
|
|
10317
10332
|
const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.passThrough or set uncompressedSize for each entry)";
|
|
10318
|
-
const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
|
|
10319
10333
|
const ERR_UNSUPPORTED_PASS_THROUGH_VALUE = "The 'compressed' passThrough option is only supported by Entry#getData() and ZipWriter#add()";
|
|
10320
10334
|
const ERR_INVALID_PASSWORDS = "Invalid passwords option (must be an array of strings)";
|
|
10321
10335
|
const ERR_INVALID_REQUEST_PASSWORD = "Invalid requestPassword option (must be a function returning a string or undefined)";
|
|
@@ -11241,9 +11255,7 @@ function getDeterminedSize(child, passThrough) {
|
|
|
11241
11255
|
}
|
|
11242
11256
|
|
|
11243
11257
|
function checkReaderOptions(readerOptions) {
|
|
11244
|
-
|
|
11245
|
-
throw new Error(ERR_INVALID_READER_OPTIONS);
|
|
11246
|
-
}
|
|
11258
|
+
checkReaderOptionsObject(readerOptions);
|
|
11247
11259
|
if (readerOptions) {
|
|
11248
11260
|
checkPassThroughValue(readerOptions.passThrough);
|
|
11249
11261
|
checkPasswordCandidatesOptions(readerOptions);
|