@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-native.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$1 = "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",
|
|
@@ -4847,7 +4853,7 @@
|
|
|
4847
4853
|
constructor(reader, options = {}) {
|
|
4848
4854
|
Object.assign(this, {
|
|
4849
4855
|
reader: new GenericReader(reader),
|
|
4850
|
-
options,
|
|
4856
|
+
options: options || {},
|
|
4851
4857
|
readRanges: { indexes: new Set(), sortedRanges: [], pendingRanges: [] },
|
|
4852
4858
|
entriesMissingZip64ExtraField: new WeakSet()
|
|
4853
4859
|
});
|
|
@@ -6867,6 +6873,7 @@
|
|
|
6867
6873
|
async function appendZipEntries(zipWriter, reader, options = {}) {
|
|
6868
6874
|
const { pendingAddFileCalls, filenames, fileEntries } = zipWriter;
|
|
6869
6875
|
const filter = checkFunctionOption(options.filter);
|
|
6876
|
+
const readerOptions = checkReaderOptionsObject(options.readerOptions);
|
|
6870
6877
|
while (pendingAddFileCalls.size) {
|
|
6871
6878
|
await Promise.allSettled(Array.from(pendingAddFileCalls));
|
|
6872
6879
|
}
|
|
@@ -6883,15 +6890,19 @@
|
|
|
6883
6890
|
await initStream(reader);
|
|
6884
6891
|
}
|
|
6885
6892
|
const { ZipReader, getEntryDataDescriptorLength } = await Promise.resolve().then(function () { return zipReader; });
|
|
6886
|
-
const zipReader$1 = new ZipReader(reader);
|
|
6887
|
-
const entries = await zipReader$1.getEntries();
|
|
6893
|
+
const zipReader$1 = new ZipReader(reader, readerOptions);
|
|
6888
6894
|
const keptEntries = [];
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6895
|
+
let entries;
|
|
6896
|
+
try {
|
|
6897
|
+
entries = await zipReader$1.getEntries();
|
|
6898
|
+
for (const entry of entries) {
|
|
6899
|
+
if (!filter || await filter(entry, getExistingEntry(fileEntries, entry.filename))) {
|
|
6900
|
+
keptEntries.push(entry);
|
|
6901
|
+
}
|
|
6892
6902
|
}
|
|
6903
|
+
} finally {
|
|
6904
|
+
await zipReader$1.close();
|
|
6893
6905
|
}
|
|
6894
|
-
await zipReader$1.close();
|
|
6895
6906
|
await initStream(zipWriter.writer);
|
|
6896
6907
|
const { directoryOffset, entriesMissingZip64ExtraField } = zipReader$1;
|
|
6897
6908
|
keptEntries.forEach(entry => {
|
|
@@ -6961,7 +6972,7 @@
|
|
|
6961
6972
|
setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
|
|
6962
6973
|
}
|
|
6963
6974
|
const { offset, diskNumberStart } = entryPositions.get(entry);
|
|
6964
|
-
Object.assign(entry, {
|
|
6975
|
+
fileEntries.set(entry.filename, Object.assign({}, entry, {
|
|
6965
6976
|
zip64Enabled: true,
|
|
6966
6977
|
zip64UncompressedSize,
|
|
6967
6978
|
zip64CompressedSize,
|
|
@@ -6978,8 +6989,7 @@
|
|
|
6978
6989
|
rawCentralExtraField: EMPTY_UINT8_ARRAY,
|
|
6979
6990
|
headerArray,
|
|
6980
6991
|
headerView
|
|
6981
|
-
});
|
|
6982
|
-
fileEntries.set(entry.filename, entry);
|
|
6992
|
+
}));
|
|
6983
6993
|
});
|
|
6984
6994
|
} catch (error) {
|
|
6985
6995
|
appendedFilenames.forEach(filename => filenames.delete(filename));
|
|
@@ -6993,6 +7003,11 @@
|
|
|
6993
7003
|
}
|
|
6994
7004
|
}
|
|
6995
7005
|
|
|
7006
|
+
function getExistingEntry(fileEntries, filename) {
|
|
7007
|
+
const fileEntry = fileEntries.get(filename);
|
|
7008
|
+
return fileEntry ? new Entry(fileEntry) : UNDEFINED_VALUE;
|
|
7009
|
+
}
|
|
7010
|
+
|
|
6996
7011
|
async function prependZipEntries(zipWriter, reader) {
|
|
6997
7012
|
if (zipWriter.filenames.size) {
|
|
6998
7013
|
throw new Error(ERR_ZIP_NOT_EMPTY);
|
|
@@ -9235,7 +9250,7 @@
|
|
|
9235
9250
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9236
9251
|
*/
|
|
9237
9252
|
|
|
9238
|
-
const VERSION = "2.
|
|
9253
|
+
const VERSION = "2.22.0";
|
|
9239
9254
|
|
|
9240
9255
|
/*
|
|
9241
9256
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9764,7 +9779,6 @@
|
|
|
9764
9779
|
const DUPLICATES_KEEP_LAST = "keep-last";
|
|
9765
9780
|
const DUPLICATES_VALUES = new Set([DUPLICATES_THROW, DUPLICATES_KEEP_FIRST, DUPLICATES_KEEP_LAST]);
|
|
9766
9781
|
const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.passThrough or set uncompressedSize for each entry)";
|
|
9767
|
-
const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
|
|
9768
9782
|
const ERR_UNSUPPORTED_PASS_THROUGH_VALUE = "The 'compressed' passThrough option is only supported by Entry#getData() and ZipWriter#add()";
|
|
9769
9783
|
const ERR_INVALID_PASSWORDS = "Invalid passwords option (must be an array of strings)";
|
|
9770
9784
|
const ERR_INVALID_REQUEST_PASSWORD = "Invalid requestPassword option (must be a function returning a string or undefined)";
|
|
@@ -10690,9 +10704,7 @@
|
|
|
10690
10704
|
}
|
|
10691
10705
|
|
|
10692
10706
|
function checkReaderOptions(readerOptions) {
|
|
10693
|
-
|
|
10694
|
-
throw new Error(ERR_INVALID_READER_OPTIONS);
|
|
10695
|
-
}
|
|
10707
|
+
checkReaderOptionsObject(readerOptions);
|
|
10696
10708
|
if (readerOptions) {
|
|
10697
10709
|
checkPassThroughValue(readerOptions.passThrough);
|
|
10698
10710
|
checkPasswordCandidatesOptions(readerOptions);
|