@zip.js/zip.js 2.8.59 → 2.8.61
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 +2 -2
- package/dist/zip-core-external.js +167 -37
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +143 -20
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +173 -45
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +5326 -3928
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +173 -45
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +151 -30
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +176 -45
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +145 -22
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +145 -22
- package/dist/zip-native.min.js +1 -1
- package/dist/zip-web-worker-native.js +1 -1
- package/dist/zip-web-worker.js +1 -1
- package/dist/zip.js +170 -37
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +151 -30
- package/index-native.min.js +1 -1
- package/index.cjs +176 -45
- package/index.d.cts +134 -1
- package/index.d.ts +134 -1
- package/index.min.js +1 -1
- package/lib/core/codec-registry.js +5 -0
- package/lib/core/compression-methods.js +93 -0
- package/lib/core/streams/zip-entry-stream.js +7 -3
- package/lib/core/streams/zlib-wasm/zlib-streams.js +18 -8
- package/lib/core/version.js +31 -0
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-fs.js +5 -4
- package/lib/core/zip-writer.js +38 -31
- package/lib/zip-core-base.js +7 -0
- package/lib/zip-fs-core.js +32 -0
- package/package.json +4 -3
- package/release.sh +47 -0
- package/sync-versions.js +26 -0
package/dist/zip-core.js
CHANGED
|
@@ -2082,6 +2082,10 @@
|
|
|
2082
2082
|
return registeredCodecs.get(compressionMethod);
|
|
2083
2083
|
}
|
|
2084
2084
|
|
|
2085
|
+
function getRegisteredCodecs() {
|
|
2086
|
+
return Array.from(registeredCodecs.values(), codec => Object.assign({}, codec, codecStreams.get(codec.format)));
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2085
2089
|
function getCodecStreams(format) {
|
|
2086
2090
|
return codecStreams.get(format);
|
|
2087
2091
|
}
|
|
@@ -2145,7 +2149,7 @@
|
|
|
2145
2149
|
|
|
2146
2150
|
constructor(options, { chunkSize, CompressionStreamFallback, CompressionStream }) {
|
|
2147
2151
|
super({});
|
|
2148
|
-
const { compressed, encrypted, useCompressionStream, zipCrypto, computeCrc32, level, deflate64, format, compressionMethod } = options;
|
|
2152
|
+
const { compressed, encrypted, useCompressionStream, zipCrypto, computeCrc32, level, deflate64, format, compressionMethod, inputSize } = options;
|
|
2149
2153
|
const stream = this;
|
|
2150
2154
|
let crc32Stream, encryptionStream, gzipCrc32Stream;
|
|
2151
2155
|
let readable = super.readable;
|
|
@@ -2158,7 +2162,7 @@
|
|
|
2158
2162
|
}
|
|
2159
2163
|
if (compressed) {
|
|
2160
2164
|
if (codecStreams) {
|
|
2161
|
-
readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.CompressionStream, format, { level, chunkSize, compressionMethod }));
|
|
2165
|
+
readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.CompressionStream, format, { level, chunkSize, compressionMethod, uncompressedSize: inputSize }));
|
|
2162
2166
|
} else if (useGzipCrc32) {
|
|
2163
2167
|
gzipCrc32Stream = new GzipToRawDeflateStream();
|
|
2164
2168
|
readable = pipeThroughBackpressured(readable, new CompressionStream(FORMAT_GZIP));
|
|
@@ -6650,6 +6654,13 @@
|
|
|
6650
6654
|
const { comment } = metadataInfo;
|
|
6651
6655
|
const extraField = options[PROPERTY_NAME_EXTRA_FIELD];
|
|
6652
6656
|
zipWriter.fileEntries.set(name, UNDEFINED_VALUE);
|
|
6657
|
+
const previousFileEntry = zipWriter.lastFileEntry;
|
|
6658
|
+
const pendingFileEntry = {};
|
|
6659
|
+
let releaseLockFileEntry;
|
|
6660
|
+
if (metadataInfo.resolvedOptions.keepOrder) {
|
|
6661
|
+
pendingFileEntry.lockFileEntry = new Promise(resolve => releaseLockFileEntry = resolve);
|
|
6662
|
+
}
|
|
6663
|
+
zipWriter.lastFileEntry = pendingFileEntry;
|
|
6653
6664
|
let fileEntry;
|
|
6654
6665
|
try {
|
|
6655
6666
|
const { resolvedOptions } = metadataInfo;
|
|
@@ -6671,10 +6682,21 @@
|
|
|
6671
6682
|
const headerInfo = getHeaderInfo(options);
|
|
6672
6683
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
6673
6684
|
const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
|
|
6674
|
-
fileEntry = await getFileEntry(zipWriter, name, reader, {
|
|
6685
|
+
fileEntry = await getFileEntry(zipWriter, name, reader, {
|
|
6686
|
+
headerInfo,
|
|
6687
|
+
dataDescriptorInfo,
|
|
6688
|
+
metadataSize,
|
|
6689
|
+
fileEntry: pendingFileEntry,
|
|
6690
|
+
previousFileEntry,
|
|
6691
|
+
releaseLockFileEntry
|
|
6692
|
+
}, options);
|
|
6675
6693
|
} catch (error) {
|
|
6676
6694
|
zipWriter.fileEntries.delete(name);
|
|
6677
6695
|
throw error;
|
|
6696
|
+
} finally {
|
|
6697
|
+
if (releaseLockFileEntry) {
|
|
6698
|
+
releaseLockFileEntry(previousFileEntry && previousFileEntry.lockFileEntry);
|
|
6699
|
+
}
|
|
6678
6700
|
}
|
|
6679
6701
|
Object.assign(fileEntry, {
|
|
6680
6702
|
name,
|
|
@@ -7060,27 +7082,23 @@
|
|
|
7060
7082
|
signal
|
|
7061
7083
|
} = options;
|
|
7062
7084
|
const {
|
|
7063
|
-
headerInfo
|
|
7085
|
+
headerInfo,
|
|
7086
|
+
fileEntry: pendingFileEntry,
|
|
7087
|
+
previousFileEntry,
|
|
7088
|
+
releaseLockFileEntry
|
|
7064
7089
|
} = entryInfo;
|
|
7065
7090
|
const usdz = zipWriter.options[OPTION_USDZ];
|
|
7066
|
-
|
|
7067
|
-
let fileEntry = {};
|
|
7091
|
+
let fileEntry = pendingFileEntry;
|
|
7068
7092
|
let bufferedWrite;
|
|
7069
7093
|
let releaseLockWriter;
|
|
7070
|
-
let releaseLockCurrentFileEntry;
|
|
7071
7094
|
let writingBufferedEntryData;
|
|
7072
7095
|
let writingEntryData;
|
|
7073
7096
|
let writerSizeBeforeEntry;
|
|
7074
7097
|
let flushedBufferedSize = 0;
|
|
7075
7098
|
let fileWriter;
|
|
7099
|
+
const lockPreviousFileEntry = keepOrder && previousFileEntry ? previousFileEntry.lockFileEntry : UNDEFINED_VALUE;
|
|
7076
7100
|
fileEntries.set(name, fileEntry);
|
|
7077
|
-
zipWriter.lastFileEntry = fileEntry;
|
|
7078
7101
|
try {
|
|
7079
|
-
let lockPreviousFileEntry;
|
|
7080
|
-
if (keepOrder) {
|
|
7081
|
-
lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
|
|
7082
|
-
requestLockCurrentFileEntry();
|
|
7083
|
-
}
|
|
7084
7102
|
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || (!dataDescriptor && !emptyEntry)) {
|
|
7085
7103
|
bufferedWrite = true;
|
|
7086
7104
|
zipWriter.bufferedWrites++;
|
|
@@ -7093,6 +7111,7 @@
|
|
|
7093
7111
|
await initStream(writer);
|
|
7094
7112
|
} else {
|
|
7095
7113
|
fileWriter = writer;
|
|
7114
|
+
await lockPreviousFileEntry;
|
|
7096
7115
|
await requestLockWriter();
|
|
7097
7116
|
}
|
|
7098
7117
|
await initStream(fileWriter);
|
|
@@ -7105,7 +7124,6 @@
|
|
|
7105
7124
|
}
|
|
7106
7125
|
const { localHeaderArray } = headerInfo;
|
|
7107
7126
|
if (!bufferedWrite) {
|
|
7108
|
-
await lockPreviousFileEntry;
|
|
7109
7127
|
await skipDiskIfNeeded();
|
|
7110
7128
|
}
|
|
7111
7129
|
const diskNumberStart = getDiskNumber(writer);
|
|
@@ -7170,8 +7188,8 @@
|
|
|
7170
7188
|
if (bufferedWrite) {
|
|
7171
7189
|
zipWriter.bufferedWrites--;
|
|
7172
7190
|
}
|
|
7173
|
-
if (
|
|
7174
|
-
|
|
7191
|
+
if (releaseLockFileEntry) {
|
|
7192
|
+
releaseLockFileEntry(lockPreviousFileEntry);
|
|
7175
7193
|
}
|
|
7176
7194
|
if (releaseLockWriter) {
|
|
7177
7195
|
releaseLockWriter();
|
|
@@ -7185,10 +7203,6 @@
|
|
|
7185
7203
|
}
|
|
7186
7204
|
}
|
|
7187
7205
|
|
|
7188
|
-
function requestLockCurrentFileEntry() {
|
|
7189
|
-
fileEntry.lockFileEntry = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
|
|
7190
|
-
}
|
|
7191
|
-
|
|
7192
7206
|
async function requestLockWriter() {
|
|
7193
7207
|
zipWriter.writerLocked = true;
|
|
7194
7208
|
const { lockWriter } = zipWriter;
|
|
@@ -7323,6 +7337,7 @@
|
|
|
7323
7337
|
const workerOptions = {
|
|
7324
7338
|
options: {
|
|
7325
7339
|
codecType: CODEC_DEFLATE,
|
|
7340
|
+
inputSize: size,
|
|
7326
7341
|
level,
|
|
7327
7342
|
rawPassword,
|
|
7328
7343
|
password,
|
|
@@ -8433,6 +8448,111 @@
|
|
|
8433
8448
|
*/
|
|
8434
8449
|
|
|
8435
8450
|
|
|
8451
|
+
function getSupportedCompressionMethods() {
|
|
8452
|
+
const { CompressionStream, DecompressionStream, CompressionStreamFallback, DecompressionStreamFallback } = getConfiguration();
|
|
8453
|
+
const supportedMethods = [{
|
|
8454
|
+
compressionMethod: COMPRESSION_METHOD_STORE,
|
|
8455
|
+
compression: true,
|
|
8456
|
+
decompression: true,
|
|
8457
|
+
registered: false
|
|
8458
|
+
}, {
|
|
8459
|
+
compressionMethod: COMPRESSION_METHOD_DEFLATE,
|
|
8460
|
+
compression: formatSupported(CompressionStreamFallback, FORMAT_DEFLATE_RAW) ||
|
|
8461
|
+
formatSupported(CompressionStream, FORMAT_DEFLATE_RAW) || formatSupported(CompressionStream, FORMAT_GZIP),
|
|
8462
|
+
decompression: formatSupported(DecompressionStreamFallback, FORMAT_DEFLATE_RAW) ||
|
|
8463
|
+
formatSupported(DecompressionStream, FORMAT_DEFLATE_RAW) || formatSupported(DecompressionStream, FORMAT_GZIP),
|
|
8464
|
+
registered: false
|
|
8465
|
+
}, {
|
|
8466
|
+
compressionMethod: COMPRESSION_METHOD_DEFLATE_64,
|
|
8467
|
+
compression: false,
|
|
8468
|
+
decompression: formatSupported(DecompressionStreamFallback, FORMAT_DEFLATE64_RAW) ||
|
|
8469
|
+
formatSupported(DecompressionStream, FORMAT_DEFLATE64_RAW),
|
|
8470
|
+
registered: false
|
|
8471
|
+
}];
|
|
8472
|
+
for (const codec of getRegisteredCodecs()) {
|
|
8473
|
+
const codecStreams = getCodecStreams(codec.format);
|
|
8474
|
+
supportedMethods.push({
|
|
8475
|
+
compressionMethod: codec.compressionMethod,
|
|
8476
|
+
// deno-lint-ignore valid-typeof
|
|
8477
|
+
compression: codecStreams ? typeof codecStreams.CompressionStream == FUNCTION_TYPE : UNDEFINED_VALUE,
|
|
8478
|
+
// deno-lint-ignore valid-typeof
|
|
8479
|
+
decompression: codecStreams ? typeof codecStreams.DecompressionStream == FUNCTION_TYPE : UNDEFINED_VALUE,
|
|
8480
|
+
registered: true
|
|
8481
|
+
});
|
|
8482
|
+
}
|
|
8483
|
+
return supportedMethods;
|
|
8484
|
+
}
|
|
8485
|
+
|
|
8486
|
+
function formatSupported(StreamClass, format) {
|
|
8487
|
+
if (!StreamClass) {
|
|
8488
|
+
return false;
|
|
8489
|
+
}
|
|
8490
|
+
const { supportedFormats } = StreamClass;
|
|
8491
|
+
if (supportedFormats) {
|
|
8492
|
+
return supportedFormats.includes(format);
|
|
8493
|
+
}
|
|
8494
|
+
return supportsFormat(StreamClass, format);
|
|
8495
|
+
}
|
|
8496
|
+
|
|
8497
|
+
/*
|
|
8498
|
+
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
8499
|
+
|
|
8500
|
+
Redistribution and use in source and binary forms, with or without
|
|
8501
|
+
modification, are permitted provided that the following conditions are met:
|
|
8502
|
+
|
|
8503
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
8504
|
+
this list of conditions and the following disclaimer.
|
|
8505
|
+
|
|
8506
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
8507
|
+
notice, this list of conditions and the following disclaimer in
|
|
8508
|
+
the documentation and/or other materials provided with the distribution.
|
|
8509
|
+
|
|
8510
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
8511
|
+
derived from this software without specific prior written permission.
|
|
8512
|
+
|
|
8513
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
8514
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
8515
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
8516
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
8517
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
8518
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
8519
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
8520
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
8521
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
8522
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8523
|
+
*/
|
|
8524
|
+
|
|
8525
|
+
const VERSION = "2.8.61";
|
|
8526
|
+
|
|
8527
|
+
/*
|
|
8528
|
+
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
8529
|
+
|
|
8530
|
+
Redistribution and use in source and binary forms, with or without
|
|
8531
|
+
modification, are permitted provided that the following conditions are met:
|
|
8532
|
+
|
|
8533
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
8534
|
+
this list of conditions and the following disclaimer.
|
|
8535
|
+
|
|
8536
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
8537
|
+
notice, this list of conditions and the following disclaimer in
|
|
8538
|
+
the documentation and/or other materials provided with the distribution.
|
|
8539
|
+
|
|
8540
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
8541
|
+
derived from this software without specific prior written permission.
|
|
8542
|
+
|
|
8543
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
8544
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
8545
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
8546
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
8547
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
8548
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
8549
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
8550
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
8551
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
8552
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8553
|
+
*/
|
|
8554
|
+
|
|
8555
|
+
|
|
8436
8556
|
const DEFAULT_THRESHOLD$2 = 1024 * 1024;
|
|
8437
8557
|
const DEFAULT_DIRECTORY_NAME$1 = ".zip.js-temp";
|
|
8438
8558
|
|
|
@@ -8933,6 +9053,7 @@
|
|
|
8933
9053
|
exports.TextWriter = TextWriter;
|
|
8934
9054
|
exports.Uint8ArrayReader = Uint8ArrayReader;
|
|
8935
9055
|
exports.Uint8ArrayWriter = Uint8ArrayWriter;
|
|
9056
|
+
exports.VERSION = VERSION;
|
|
8936
9057
|
exports.WARNING_APPENDED_DATA = WARNING_APPENDED_DATA;
|
|
8937
9058
|
exports.WARNING_COMPRESSED_PATCHED_DATA = WARNING_COMPRESSED_PATCHED_DATA;
|
|
8938
9059
|
exports.WARNING_DUPLICATE_FILENAME = WARNING_DUPLICATE_FILENAME;
|
|
@@ -8957,6 +9078,8 @@
|
|
|
8957
9078
|
exports.createOPFSTempStream = createOPFSTempStream;
|
|
8958
9079
|
exports.createSyncAccessHandleTempStream = createSyncAccessHandleTempStream;
|
|
8959
9080
|
exports.getMimeType = getMimeType;
|
|
9081
|
+
exports.getRegisteredCodecs = getRegisteredCodecs;
|
|
9082
|
+
exports.getSupportedCompressionMethods = getSupportedCompressionMethods;
|
|
8960
9083
|
exports.isZipFile = isZipFile;
|
|
8961
9084
|
exports.registerCodec = registerCodec;
|
|
8962
9085
|
exports.resetConfiguration = resetConfiguration;
|