@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-core.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",
|
|
@@ -4845,7 +4851,7 @@
|
|
|
4845
4851
|
constructor(reader, options = {}) {
|
|
4846
4852
|
Object.assign(this, {
|
|
4847
4853
|
reader: new GenericReader(reader),
|
|
4848
|
-
options,
|
|
4854
|
+
options: options || {},
|
|
4849
4855
|
readRanges: { indexes: new Set(), sortedRanges: [], pendingRanges: [] },
|
|
4850
4856
|
entriesMissingZip64ExtraField: new WeakSet()
|
|
4851
4857
|
});
|
|
@@ -6865,6 +6871,7 @@
|
|
|
6865
6871
|
async function appendZipEntries(zipWriter, reader, options = {}) {
|
|
6866
6872
|
const { pendingAddFileCalls, filenames, fileEntries } = zipWriter;
|
|
6867
6873
|
const filter = checkFunctionOption(options.filter);
|
|
6874
|
+
const readerOptions = checkReaderOptionsObject(options.readerOptions);
|
|
6868
6875
|
while (pendingAddFileCalls.size) {
|
|
6869
6876
|
await Promise.allSettled(Array.from(pendingAddFileCalls));
|
|
6870
6877
|
}
|
|
@@ -6881,15 +6888,19 @@
|
|
|
6881
6888
|
await initStream(reader);
|
|
6882
6889
|
}
|
|
6883
6890
|
const { ZipReader, getEntryDataDescriptorLength } = await Promise.resolve().then(function () { return zipReader; });
|
|
6884
|
-
const zipReader$1 = new ZipReader(reader);
|
|
6885
|
-
const entries = await zipReader$1.getEntries();
|
|
6891
|
+
const zipReader$1 = new ZipReader(reader, readerOptions);
|
|
6886
6892
|
const keptEntries = [];
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6893
|
+
let entries;
|
|
6894
|
+
try {
|
|
6895
|
+
entries = await zipReader$1.getEntries();
|
|
6896
|
+
for (const entry of entries) {
|
|
6897
|
+
if (!filter || await filter(entry, getExistingEntry(fileEntries, entry.filename))) {
|
|
6898
|
+
keptEntries.push(entry);
|
|
6899
|
+
}
|
|
6890
6900
|
}
|
|
6901
|
+
} finally {
|
|
6902
|
+
await zipReader$1.close();
|
|
6891
6903
|
}
|
|
6892
|
-
await zipReader$1.close();
|
|
6893
6904
|
await initStream(zipWriter.writer);
|
|
6894
6905
|
const { directoryOffset, entriesMissingZip64ExtraField } = zipReader$1;
|
|
6895
6906
|
keptEntries.forEach(entry => {
|
|
@@ -6959,7 +6970,7 @@
|
|
|
6959
6970
|
setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
|
|
6960
6971
|
}
|
|
6961
6972
|
const { offset, diskNumberStart } = entryPositions.get(entry);
|
|
6962
|
-
Object.assign(entry, {
|
|
6973
|
+
fileEntries.set(entry.filename, Object.assign({}, entry, {
|
|
6963
6974
|
zip64Enabled: true,
|
|
6964
6975
|
zip64UncompressedSize,
|
|
6965
6976
|
zip64CompressedSize,
|
|
@@ -6976,8 +6987,7 @@
|
|
|
6976
6987
|
rawCentralExtraField: EMPTY_UINT8_ARRAY,
|
|
6977
6988
|
headerArray,
|
|
6978
6989
|
headerView
|
|
6979
|
-
});
|
|
6980
|
-
fileEntries.set(entry.filename, entry);
|
|
6990
|
+
}));
|
|
6981
6991
|
});
|
|
6982
6992
|
} catch (error) {
|
|
6983
6993
|
appendedFilenames.forEach(filename => filenames.delete(filename));
|
|
@@ -6991,6 +7001,11 @@
|
|
|
6991
7001
|
}
|
|
6992
7002
|
}
|
|
6993
7003
|
|
|
7004
|
+
function getExistingEntry(fileEntries, filename) {
|
|
7005
|
+
const fileEntry = fileEntries.get(filename);
|
|
7006
|
+
return fileEntry ? new Entry(fileEntry) : UNDEFINED_VALUE;
|
|
7007
|
+
}
|
|
7008
|
+
|
|
6994
7009
|
async function prependZipEntries(zipWriter, reader) {
|
|
6995
7010
|
if (zipWriter.filenames.size) {
|
|
6996
7011
|
throw new Error(ERR_ZIP_NOT_EMPTY);
|
|
@@ -9233,7 +9248,7 @@
|
|
|
9233
9248
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9234
9249
|
*/
|
|
9235
9250
|
|
|
9236
|
-
const VERSION = "2.
|
|
9251
|
+
const VERSION = "2.22.0";
|
|
9237
9252
|
|
|
9238
9253
|
/*
|
|
9239
9254
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9724,7 +9739,6 @@
|
|
|
9724
9739
|
const DUPLICATES_KEEP_LAST = "keep-last";
|
|
9725
9740
|
const DUPLICATES_VALUES = new Set([DUPLICATES_THROW, DUPLICATES_KEEP_FIRST, DUPLICATES_KEEP_LAST]);
|
|
9726
9741
|
const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.passThrough or set uncompressedSize for each entry)";
|
|
9727
|
-
const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
|
|
9728
9742
|
const ERR_UNSUPPORTED_PASS_THROUGH_VALUE = "The 'compressed' passThrough option is only supported by Entry#getData() and ZipWriter#add()";
|
|
9729
9743
|
const ERR_INVALID_PASSWORDS = "Invalid passwords option (must be an array of strings)";
|
|
9730
9744
|
const ERR_INVALID_REQUEST_PASSWORD = "Invalid requestPassword option (must be a function returning a string or undefined)";
|
|
@@ -10650,9 +10664,7 @@
|
|
|
10650
10664
|
}
|
|
10651
10665
|
|
|
10652
10666
|
function checkReaderOptions(readerOptions) {
|
|
10653
|
-
|
|
10654
|
-
throw new Error(ERR_INVALID_READER_OPTIONS);
|
|
10655
|
-
}
|
|
10667
|
+
checkReaderOptionsObject(readerOptions);
|
|
10656
10668
|
if (readerOptions) {
|
|
10657
10669
|
checkPassThroughValue(readerOptions.passThrough);
|
|
10658
10670
|
checkPasswordCandidatesOptions(readerOptions);
|