@zip.js/zip.js 2.8.58 → 2.8.60
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 +295 -57
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +286 -40
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +295 -58
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +5867 -4360
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +295 -58
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +288 -43
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +313 -58
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +288 -42
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +288 -42
- 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 +313 -57
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +288 -43
- package/index-native.min.js +1 -1
- package/index.cjs +313 -58
- package/index.d.cts +318 -2
- package/index.d.ts +318 -2
- 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/constants.js +2 -0
- package/lib/core/options.js +2 -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-reader.js +143 -33
- package/lib/core/zip-writer.js +14 -6
- package/lib/zip-core-base.js +7 -0
- package/lib/zip-core-reader.js +16 -1
- package/lib/zip-fs-core.js +32 -0
- package/package.json +3 -3
- package/sync-versions.js +26 -0
|
@@ -74,6 +74,7 @@ const BITFLAG_LEVEL_MAX_MASK = 0b010;
|
|
|
74
74
|
const BITFLAG_LEVEL_FAST_MASK = 0b100;
|
|
75
75
|
const BITFLAG_LEVEL_SUPER_FAST_MASK = 0b110;
|
|
76
76
|
const BITFLAG_DATA_DESCRIPTOR = 0b1000;
|
|
77
|
+
const BITFLAG_COMPRESSED_PATCHED_DATA = 0b100000;
|
|
77
78
|
const BITFLAG_STRONG_ENCRYPTION = 0b1000000;
|
|
78
79
|
const BITFLAG_LANG_ENCODING_FLAG = 0b100000000000;
|
|
79
80
|
const BITFLAG_MASKED_LOCAL_HEADERS = 0b10000000000000;
|
|
@@ -191,6 +192,7 @@ const OPTION_OFFSET = "offset";
|
|
|
191
192
|
const OPTION_USDZ = "usdz";
|
|
192
193
|
const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
|
|
193
194
|
const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
|
|
195
|
+
const OPTION_CENTRAL_EXTRA_FIELD = "centralExtraField";
|
|
194
196
|
const OPTION_STRICTNESS = "strictness";
|
|
195
197
|
const OPTION_FILENAME_VALIDATION = "filenameValidation";
|
|
196
198
|
const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
|
|
@@ -2107,6 +2109,10 @@ function getRegisteredCodec(compressionMethod) {
|
|
|
2107
2109
|
return registeredCodecs.get(compressionMethod);
|
|
2108
2110
|
}
|
|
2109
2111
|
|
|
2112
|
+
function getRegisteredCodecs() {
|
|
2113
|
+
return Array.from(registeredCodecs.values(), codec => Object.assign({}, codec, codecStreams.get(codec.format)));
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2110
2116
|
function getCodecStreams(format) {
|
|
2111
2117
|
return codecStreams.get(format);
|
|
2112
2118
|
}
|
|
@@ -2158,9 +2164,9 @@ const ERR_INVALID_UNCOMPRESSED_SIZE = "Invalid uncompressed size";
|
|
|
2158
2164
|
const ERR_INVALID_COMPRESSED_DATA = "Invalid compressed data";
|
|
2159
2165
|
const ERR_INVALID_CRC32 = ERR_INVALID_SIGNATURE;
|
|
2160
2166
|
const ERR_UNSUPPORTED_COMPRESSION$2 = "Compression method not supported";
|
|
2161
|
-
const FORMAT_DEFLATE_RAW = "deflate-raw";
|
|
2162
|
-
const FORMAT_DEFLATE64_RAW = "deflate64-raw";
|
|
2163
|
-
const FORMAT_GZIP = "gzip";
|
|
2167
|
+
const FORMAT_DEFLATE_RAW$1 = "deflate-raw";
|
|
2168
|
+
const FORMAT_DEFLATE64_RAW$1 = "deflate64-raw";
|
|
2169
|
+
const FORMAT_GZIP$1 = "gzip";
|
|
2164
2170
|
const GZIP_HEADER_LENGTH = 10;
|
|
2165
2171
|
const GZIP_TRAILER_LENGTH = 8;
|
|
2166
2172
|
const GZIP_HEADER_BYTES = [0x1f, 0x8b, 0x08];
|
|
@@ -2170,7 +2176,7 @@ class DeflateStream extends TransformStream {
|
|
|
2170
2176
|
|
|
2171
2177
|
constructor(options, { chunkSize, CompressionStreamFallback, CompressionStream }) {
|
|
2172
2178
|
super({});
|
|
2173
|
-
const { compressed, encrypted, useCompressionStream, zipCrypto, computeCrc32, level, deflate64, format, compressionMethod } = options;
|
|
2179
|
+
const { compressed, encrypted, useCompressionStream, zipCrypto, computeCrc32, level, deflate64, format, compressionMethod, inputSize } = options;
|
|
2174
2180
|
const stream = this;
|
|
2175
2181
|
let crc32Stream, encryptionStream, gzipCrc32Stream;
|
|
2176
2182
|
let readable = super.readable;
|
|
@@ -2183,10 +2189,10 @@ class DeflateStream extends TransformStream {
|
|
|
2183
2189
|
}
|
|
2184
2190
|
if (compressed) {
|
|
2185
2191
|
if (codecStreams) {
|
|
2186
|
-
readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.CompressionStream, format, { level, chunkSize, compressionMethod }));
|
|
2192
|
+
readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.CompressionStream, format, { level, chunkSize, compressionMethod, uncompressedSize: inputSize }));
|
|
2187
2193
|
} else if (useGzipCrc32) {
|
|
2188
2194
|
gzipCrc32Stream = new GzipToRawDeflateStream();
|
|
2189
|
-
readable = pipeThroughBackpressured(readable, new CompressionStream(FORMAT_GZIP));
|
|
2195
|
+
readable = pipeThroughBackpressured(readable, new CompressionStream(FORMAT_GZIP$1));
|
|
2190
2196
|
readable = pipeThrough(readable, gzipCrc32Stream);
|
|
2191
2197
|
} else {
|
|
2192
2198
|
try {
|
|
@@ -2194,7 +2200,7 @@ class DeflateStream extends TransformStream {
|
|
|
2194
2200
|
} catch (error) {
|
|
2195
2201
|
let gzipStream;
|
|
2196
2202
|
try {
|
|
2197
|
-
gzipStream = new CompressionStream(FORMAT_GZIP);
|
|
2203
|
+
gzipStream = new CompressionStream(FORMAT_GZIP$1);
|
|
2198
2204
|
} catch {
|
|
2199
2205
|
throw error;
|
|
2200
2206
|
}
|
|
@@ -2358,7 +2364,7 @@ class InflateStream extends TransformStream {
|
|
|
2358
2364
|
}
|
|
2359
2365
|
let gzipStream;
|
|
2360
2366
|
try {
|
|
2361
|
-
gzipStream = new DecompressionStream(FORMAT_GZIP);
|
|
2367
|
+
gzipStream = new DecompressionStream(FORMAT_GZIP$1);
|
|
2362
2368
|
} catch {
|
|
2363
2369
|
throw error;
|
|
2364
2370
|
}
|
|
@@ -2407,11 +2413,11 @@ function supportsFormat(StreamClass, format) {
|
|
|
2407
2413
|
}
|
|
2408
2414
|
|
|
2409
2415
|
function supportsDeflateRaw(StreamClass) {
|
|
2410
|
-
return supportsFormat(StreamClass, FORMAT_DEFLATE_RAW);
|
|
2416
|
+
return supportsFormat(StreamClass, FORMAT_DEFLATE_RAW$1);
|
|
2411
2417
|
}
|
|
2412
2418
|
|
|
2413
2419
|
function supportsGzip(StreamClass) {
|
|
2414
|
-
return supportsFormat(StreamClass, FORMAT_GZIP);
|
|
2420
|
+
return supportsFormat(StreamClass, FORMAT_GZIP$1);
|
|
2415
2421
|
}
|
|
2416
2422
|
|
|
2417
2423
|
function setReadable(stream, readable, flush) {
|
|
@@ -2434,7 +2440,7 @@ function pipeThroughCompressionStream(readable, useCompressionStream, options, C
|
|
|
2434
2440
|
const Stream = useCompressionStream && CompressionStreamNative ?
|
|
2435
2441
|
CompressionStreamNative :
|
|
2436
2442
|
CompressionStreamFallback || CompressionStreamNative;
|
|
2437
|
-
const format = options.deflate64 ? FORMAT_DEFLATE64_RAW : FORMAT_DEFLATE_RAW;
|
|
2443
|
+
const format = options.deflate64 ? FORMAT_DEFLATE64_RAW$1 : FORMAT_DEFLATE_RAW$1;
|
|
2438
2444
|
let codecStream;
|
|
2439
2445
|
try {
|
|
2440
2446
|
codecStream = new Stream(format, options);
|
|
@@ -4740,6 +4746,21 @@ const ERR_INVALID_STRICTNESS = "Invalid strictness (must be 'strict', 'balanced'
|
|
|
4740
4746
|
const ERR_INVALID_FILENAME_VALIDATION = "Invalid filenameValidation (must be 'strict', 'balanced' or 'tolerant')";
|
|
4741
4747
|
const ERR_INVALID_MAX_APPENDED_DATA_SIZE = "Invalid maxAppendedDataSize (must be a number greater than or equal to 0)";
|
|
4742
4748
|
const ERR_UNSUPPORTED_UINT64 = "64-bit value exceeds Number.MAX_SAFE_INTEGER";
|
|
4749
|
+
const WARNING_UNSORTED_CENTRAL_DIRECTORY = "unsorted central directory";
|
|
4750
|
+
const WARNING_UNKNOWN_VERSION = "unknown version needed to extract";
|
|
4751
|
+
const WARNING_COMPRESSED_PATCHED_DATA = "compressed patched data";
|
|
4752
|
+
const WARNING_MALFORMED_EXTRA_FIELD = "malformed extra field";
|
|
4753
|
+
const WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA = "unknown zip64 extensible data";
|
|
4754
|
+
const WARNING_WRAPPED_ENTRIES_COUNT = "wrapped entries count";
|
|
4755
|
+
const WARNING_APPENDED_DATA = "appended data";
|
|
4756
|
+
const WARNING_PREPENDED_DATA = "prepended data";
|
|
4757
|
+
const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA = "trailing central directory data";
|
|
4758
|
+
const WARNING_DUPLICATE_FILENAME = "duplicate filename";
|
|
4759
|
+
const WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY = "mismatched zip64 end of central directory record";
|
|
4760
|
+
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG = "mismatched local file header (general purpose bit flag)";
|
|
4761
|
+
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD = "mismatched local file header (compression method)";
|
|
4762
|
+
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES = "mismatched local file header (crc32 or sizes)";
|
|
4763
|
+
const MAX_KNOWN_VERSION = 63;
|
|
4743
4764
|
const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
|
|
4744
4765
|
const CHARSET_UTF8 = "utf-8";
|
|
4745
4766
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
@@ -4790,6 +4811,7 @@ class ZipReader {
|
|
|
4790
4811
|
if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
|
|
4791
4812
|
throw new Error(ERR_BAD_FORMAT);
|
|
4792
4813
|
}
|
|
4814
|
+
const warnings = zipReader.warnings = [];
|
|
4793
4815
|
const strictness = getStrictness(options, zipReader.options);
|
|
4794
4816
|
const checkAmbiguity = strictness == STRICTNESS_STRICT;
|
|
4795
4817
|
const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
|
|
@@ -4813,8 +4835,12 @@ class ZipReader {
|
|
|
4813
4835
|
const commentOffset = endOfDirectoryInfo.offset;
|
|
4814
4836
|
const commentLength = getUint16$1(endOfDirectoryView, 20);
|
|
4815
4837
|
const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
|
|
4816
|
-
|
|
4817
|
-
|
|
4838
|
+
const appendedDataLength = reader.size - appendedDataOffset;
|
|
4839
|
+
if (appendedDataLength > maxAppendedDataSize) {
|
|
4840
|
+
throwAmbiguousArchive(WARNING_APPENDED_DATA);
|
|
4841
|
+
}
|
|
4842
|
+
if (appendedDataLength > 0) {
|
|
4843
|
+
addWarning(warnings, WARNING_APPENDED_DATA);
|
|
4818
4844
|
}
|
|
4819
4845
|
let lastDiskNumber = getUint16$1(endOfDirectoryView, 4);
|
|
4820
4846
|
const expectedLastDiskNumber = reader.lastDiskNumber || 0;
|
|
@@ -4868,23 +4894,23 @@ class ZipReader {
|
|
|
4868
4894
|
}
|
|
4869
4895
|
if (lastDiskNumber == MAX_16_BITS) {
|
|
4870
4896
|
lastDiskNumber = getUint32$1(endOfDirectoryView, 16);
|
|
4871
|
-
} else if (
|
|
4872
|
-
|
|
4897
|
+
} else if (lastDiskNumber != getUint32$1(endOfDirectoryView, 16)) {
|
|
4898
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY);
|
|
4873
4899
|
}
|
|
4874
4900
|
if (diskNumber == MAX_16_BITS) {
|
|
4875
4901
|
diskNumber = getUint32$1(endOfDirectoryView, 20);
|
|
4876
|
-
} else if (
|
|
4877
|
-
|
|
4902
|
+
} else if (diskNumber != getUint32$1(endOfDirectoryView, 20)) {
|
|
4903
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY);
|
|
4878
4904
|
}
|
|
4879
4905
|
if (filesLength == MAX_16_BITS) {
|
|
4880
4906
|
filesLength = getBigUint64(endOfDirectoryView, 32);
|
|
4881
|
-
} else if (
|
|
4882
|
-
|
|
4907
|
+
} else if (filesLength != getBigUint64(endOfDirectoryView, 32)) {
|
|
4908
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY);
|
|
4883
4909
|
}
|
|
4884
4910
|
if (directoryDataLength == MAX_32_BITS) {
|
|
4885
4911
|
directoryDataLength = getBigUint64(endOfDirectoryView, 40);
|
|
4886
|
-
} else if (
|
|
4887
|
-
|
|
4912
|
+
} else if (directoryDataLength != getBigUint64(endOfDirectoryView, 40)) {
|
|
4913
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY);
|
|
4888
4914
|
}
|
|
4889
4915
|
directoryDataOffset = getDiskOffset$1(reader, diskNumber) + getBigUint64(endOfDirectoryView, 48) + prependedDataLength;
|
|
4890
4916
|
}
|
|
@@ -4953,14 +4979,22 @@ class ZipReader {
|
|
|
4953
4979
|
declaredDirectoryDataLength = directoryArray.length;
|
|
4954
4980
|
decryptedDirectory = true;
|
|
4955
4981
|
}
|
|
4982
|
+
if (directoryEncryptionInfo && !decryptedDirectory &&
|
|
4983
|
+
(directoryArray.length < 4 || getUint32$1(directoryView, 0) == CENTRAL_FILE_HEADER_SIGNATURE)) {
|
|
4984
|
+
addWarning(warnings, WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA);
|
|
4985
|
+
}
|
|
4956
4986
|
startOffset = directoryDataOffset;
|
|
4957
4987
|
const filenameEncoding = getOptionValue$1(zipReader, options, OPTION_FILENAME_ENCODING);
|
|
4958
4988
|
const commentEncoding = getOptionValue$1(zipReader, options, OPTION_COMMENT_ENCODING);
|
|
4959
|
-
const filenames =
|
|
4989
|
+
const filenames = new Set();
|
|
4960
4990
|
let duplicateFilename;
|
|
4991
|
+
let previousEntryPosition = -1;
|
|
4961
4992
|
const recoverWrappedFilesLength = !checkAmbiguity && !zip64EndOfDirectory;
|
|
4962
4993
|
if (!filesLength && recoverWrappedFilesLength) {
|
|
4963
4994
|
filesLength = getWrappedFilesLength(directoryView, directoryArray, offset);
|
|
4995
|
+
if (filesLength) {
|
|
4996
|
+
addWarning(warnings, WARNING_WRAPPED_ENTRIES_COUNT);
|
|
4997
|
+
}
|
|
4964
4998
|
}
|
|
4965
4999
|
for (let indexFile = 0; indexFile < filesLength; indexFile++) {
|
|
4966
5000
|
const fileEntry = new ZipEntry(reader, zipReader.options);
|
|
@@ -5039,15 +5073,26 @@ class ZipReader {
|
|
|
5039
5073
|
filename,
|
|
5040
5074
|
comment
|
|
5041
5075
|
});
|
|
5042
|
-
readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6)
|
|
5076
|
+
if (readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6)) {
|
|
5077
|
+
addWarning(warnings, WARNING_MALFORMED_EXTRA_FIELD, filename);
|
|
5078
|
+
}
|
|
5043
5079
|
fileEntry.offset += prependedDataLength;
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5080
|
+
const entryPosition = getDiskOffset$1(reader, fileEntry.diskNumberStart) + fileEntry.offset;
|
|
5081
|
+
startOffset = Math.min(entryPosition, startOffset);
|
|
5082
|
+
if (entryPosition < previousEntryPosition) {
|
|
5083
|
+
addWarning(warnings, WARNING_UNSORTED_CENTRAL_DIRECTORY, filename);
|
|
5084
|
+
}
|
|
5085
|
+
previousEntryPosition = entryPosition;
|
|
5086
|
+
if ((fileEntry.version & MAX_8_BITS) > MAX_KNOWN_VERSION) {
|
|
5087
|
+
addWarning(warnings, WARNING_UNKNOWN_VERSION, filename);
|
|
5050
5088
|
}
|
|
5089
|
+
if ((fileEntry.rawBitFlag & BITFLAG_COMPRESSED_PATCHED_DATA) == BITFLAG_COMPRESSED_PATCHED_DATA) {
|
|
5090
|
+
addWarning(warnings, WARNING_COMPRESSED_PATCHED_DATA, filename);
|
|
5091
|
+
}
|
|
5092
|
+
if (filenames.has(fileEntry.filename)) {
|
|
5093
|
+
duplicateFilename = true;
|
|
5094
|
+
}
|
|
5095
|
+
filenames.add(fileEntry.filename);
|
|
5051
5096
|
const unixExternalUpper = (fileEntry.externalFileAttributes >> 16) & MAX_16_BITS;
|
|
5052
5097
|
if (fileEntry.unixMode === UNDEFINED_VALUE && (unixExternalUpper & (FILE_ATTR_UNIX_DEFAULT_MASK | FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_TYPE_DIR)) != 0) {
|
|
5053
5098
|
fileEntry.unixMode = unixExternalUpper;
|
|
@@ -5085,7 +5130,11 @@ class ZipReader {
|
|
|
5085
5130
|
};
|
|
5086
5131
|
offset = endOffset;
|
|
5087
5132
|
if (indexFile == filesLength - 1 && recoverWrappedFilesLength) {
|
|
5088
|
-
|
|
5133
|
+
const wrappedFilesLength = getWrappedFilesLength(directoryView, directoryArray, offset);
|
|
5134
|
+
if (wrappedFilesLength) {
|
|
5135
|
+
filesLength += wrappedFilesLength;
|
|
5136
|
+
addWarning(warnings, WARNING_WRAPPED_ENTRIES_COUNT);
|
|
5137
|
+
}
|
|
5089
5138
|
}
|
|
5090
5139
|
const { onprogress } = options;
|
|
5091
5140
|
if (onprogress) {
|
|
@@ -5111,18 +5160,22 @@ class ZipReader {
|
|
|
5111
5160
|
zipReader.digitalSignature = digitalSignature;
|
|
5112
5161
|
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
5113
5162
|
}
|
|
5114
|
-
if (
|
|
5115
|
-
|
|
5163
|
+
if ((offset != declaredDirectoryDataLength && offsetAfterSignature != declaredDirectoryDataLength) ||
|
|
5164
|
+
(!decryptedDirectory && offset != directoryDataLength && offsetAfterSignature != directoryDataLength)) {
|
|
5165
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_TRAILING_CENTRAL_DIRECTORY_DATA);
|
|
5116
5166
|
}
|
|
5117
5167
|
if (duplicateFilename) {
|
|
5118
|
-
|
|
5168
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_DUPLICATE_FILENAME);
|
|
5119
5169
|
}
|
|
5120
5170
|
const extractPrependedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_PREPENDED_DATA);
|
|
5121
5171
|
const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
|
|
5122
5172
|
const splitZipSignatureLength = (checkAmbiguity || extractPrependedData) && filesLength &&
|
|
5123
5173
|
startOffset == SPLIT_ZIP_FILE_SIGNATURE_LENGTH && await startsWithSplitZipMarker(reader) ? SPLIT_ZIP_FILE_SIGNATURE_LENGTH : 0;
|
|
5124
5174
|
if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > splitZipSignatureLength))) {
|
|
5125
|
-
throwAmbiguousArchive(
|
|
5175
|
+
throwAmbiguousArchive(WARNING_PREPENDED_DATA);
|
|
5176
|
+
}
|
|
5177
|
+
if (prependedDataLength || (filesLength && startOffset > SPLIT_ZIP_FILE_SIGNATURE_LENGTH)) {
|
|
5178
|
+
addWarning(warnings, WARNING_PREPENDED_DATA);
|
|
5126
5179
|
}
|
|
5127
5180
|
if (extractPrependedData) {
|
|
5128
5181
|
zipReader.prependedData = startOffset > splitZipSignatureLength ?
|
|
@@ -5192,6 +5245,28 @@ class ZipReaderStream {
|
|
|
5192
5245
|
}
|
|
5193
5246
|
}
|
|
5194
5247
|
|
|
5248
|
+
async function isZipFile(reader, options = {}) {
|
|
5249
|
+
reader = new GenericReader(reader);
|
|
5250
|
+
await initStream(reader);
|
|
5251
|
+
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
5252
|
+
reader = new BlobReader(await streamToBlob(reader.readable));
|
|
5253
|
+
await initStream(reader);
|
|
5254
|
+
}
|
|
5255
|
+
if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
|
|
5256
|
+
return false;
|
|
5257
|
+
}
|
|
5258
|
+
const strictness = getStrictness(options, {});
|
|
5259
|
+
const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
|
|
5260
|
+
const maxAppendedDataSize = getMaxAppendedDataSize(options[OPTION_MAX_APPENDED_DATA_SIZE], strictness);
|
|
5261
|
+
const { endOfDirectoryInfo, endOfDirectoryReachingEndCount } = await findEndOfCentralDirectory(reader, rejectAmbiguousEndOfDirectory, maxAppendedDataSize);
|
|
5262
|
+
if (!endOfDirectoryInfo || (strictness == STRICTNESS_STRICT && endOfDirectoryReachingEndCount > 1)) {
|
|
5263
|
+
return false;
|
|
5264
|
+
}
|
|
5265
|
+
const commentLength = getUint16$1(getDataView(endOfDirectoryInfo), 20);
|
|
5266
|
+
const appendedDataOffset = endOfDirectoryInfo.offset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
|
|
5267
|
+
return reader.size - appendedDataOffset <= maxAppendedDataSize;
|
|
5268
|
+
}
|
|
5269
|
+
|
|
5195
5270
|
class ZipEntry {
|
|
5196
5271
|
|
|
5197
5272
|
constructor(reader, options) {
|
|
@@ -5223,6 +5298,7 @@ class ZipEntry {
|
|
|
5223
5298
|
dataDescriptor
|
|
5224
5299
|
} = bitFlag;
|
|
5225
5300
|
const localDirectory = fileEntry.localDirectory = {};
|
|
5301
|
+
const warnings = fileEntry.warnings = [];
|
|
5226
5302
|
const localHeaderOffset = getDiskOffset$1(reader, diskNumberStart) + offset;
|
|
5227
5303
|
const dataArray = await readUint8Array(reader, localHeaderOffset, HEADER_SIZE);
|
|
5228
5304
|
const dataView = getDataView(dataArray);
|
|
@@ -5263,10 +5339,10 @@ class ZipEntry {
|
|
|
5263
5339
|
if (checkLocalFilename) {
|
|
5264
5340
|
localDirectory.rawFilename = rawLocalFilename;
|
|
5265
5341
|
}
|
|
5266
|
-
readCommonFooter(zipEntry, localDirectory, dataView, 4, true)
|
|
5267
|
-
|
|
5268
|
-
validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename);
|
|
5342
|
+
if (readCommonFooter(zipEntry, localDirectory, dataView, 4, true)) {
|
|
5343
|
+
addWarning(warnings, WARNING_MALFORMED_EXTRA_FIELD);
|
|
5269
5344
|
}
|
|
5345
|
+
validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename, checkLocalDirectory ? UNDEFINED_VALUE : warnings);
|
|
5270
5346
|
const { lastAccessDate, creationDate, uid, gid } = localDirectory;
|
|
5271
5347
|
if (lastAccessDate) {
|
|
5272
5348
|
fileEntry.lastAccessDate = lastAccessDate;
|
|
@@ -5492,6 +5568,7 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5492
5568
|
const extraField = directory.extraField = new Map();
|
|
5493
5569
|
const rawExtraFieldView = getDataView(rawExtraField);
|
|
5494
5570
|
let offsetExtraField = 0;
|
|
5571
|
+
let malformedExtraField = false;
|
|
5495
5572
|
try {
|
|
5496
5573
|
while (offsetExtraField < rawExtraField.length) {
|
|
5497
5574
|
const type = getUint16$1(rawExtraFieldView, offsetExtraField);
|
|
@@ -5503,7 +5580,10 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5503
5580
|
offsetExtraField += 4 + size;
|
|
5504
5581
|
}
|
|
5505
5582
|
} catch {
|
|
5506
|
-
|
|
5583
|
+
malformedExtraField = true;
|
|
5584
|
+
}
|
|
5585
|
+
if (offsetExtraField > rawExtraField.length) {
|
|
5586
|
+
malformedExtraField = true;
|
|
5507
5587
|
}
|
|
5508
5588
|
const compressionMethod = getUint16$1(dataView, offset + 4);
|
|
5509
5589
|
Object.assign(directory, {
|
|
@@ -5571,6 +5651,7 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5571
5651
|
if (extraFieldUSDZ) {
|
|
5572
5652
|
directory.extraFieldUSDZ = extraFieldUSDZ;
|
|
5573
5653
|
}
|
|
5654
|
+
return malformedExtraField;
|
|
5574
5655
|
}
|
|
5575
5656
|
|
|
5576
5657
|
function readExtraFieldZip64(extraFieldZip64, directory) {
|
|
@@ -6032,27 +6113,46 @@ async function readSignature(reader, view, anchoredOffset, signatureOffset, size
|
|
|
6032
6113
|
return UNDEFINED_VALUE;
|
|
6033
6114
|
}
|
|
6034
6115
|
|
|
6035
|
-
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
|
|
6116
|
+
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename, warnings) {
|
|
6036
6117
|
const { rawFilename } = zipEntry;
|
|
6118
|
+
const reject = !warnings;
|
|
6037
6119
|
const maskedLocalDirectory = zipEntry.decryptedDirectory &&
|
|
6038
6120
|
(localDirectory.rawBitFlag & BITFLAG_MASKED_LOCAL_HEADERS) == BITFLAG_MASKED_LOCAL_HEADERS;
|
|
6039
6121
|
if (checkLocalFilename && !maskedLocalDirectory &&
|
|
6040
6122
|
(rawLocalFilename.length != rawFilename.length ||
|
|
6041
6123
|
rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
|
|
6042
|
-
|
|
6124
|
+
reportAmbiguity(reject, warnings, "mismatched local file header (filename)");
|
|
6043
6125
|
}
|
|
6044
6126
|
if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
|
|
6045
|
-
|
|
6127
|
+
reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG);
|
|
6046
6128
|
}
|
|
6047
6129
|
if (localDirectory.compressionMethod != zipEntry.compressionMethod) {
|
|
6048
|
-
|
|
6130
|
+
reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD);
|
|
6049
6131
|
}
|
|
6050
6132
|
if (!localDirectory.bitFlag.dataDescriptor && !maskedLocalDirectory &&
|
|
6051
6133
|
(localDirectory.crc32 || localDirectory.compressedSize || localDirectory.uncompressedSize) &&
|
|
6052
6134
|
(localDirectory.crc32 != zipEntry.crc32 ||
|
|
6053
6135
|
localDirectory.compressedSize != zipEntry.compressedSize ||
|
|
6054
6136
|
localDirectory.uncompressedSize != zipEntry.uncompressedSize)) {
|
|
6055
|
-
|
|
6137
|
+
reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES);
|
|
6138
|
+
}
|
|
6139
|
+
}
|
|
6140
|
+
|
|
6141
|
+
function reportAmbiguity(reject, warnings, reason) {
|
|
6142
|
+
if (reject) {
|
|
6143
|
+
throwAmbiguousArchive(reason);
|
|
6144
|
+
} else {
|
|
6145
|
+
addWarning(warnings, reason);
|
|
6146
|
+
}
|
|
6147
|
+
}
|
|
6148
|
+
|
|
6149
|
+
function addWarning(warnings, reason, filename) {
|
|
6150
|
+
if (!warnings.some(warning => warning.reason == reason)) {
|
|
6151
|
+
const warning = { reason };
|
|
6152
|
+
if (filename !== UNDEFINED_VALUE) {
|
|
6153
|
+
warning.filename = filename;
|
|
6154
|
+
}
|
|
6155
|
+
warnings.push(warning);
|
|
6056
6156
|
}
|
|
6057
6157
|
}
|
|
6058
6158
|
|
|
@@ -6129,8 +6229,23 @@ var zipReader = /*#__PURE__*/Object.freeze({
|
|
|
6129
6229
|
ERR_UNSUPPORTED_ENCRYPTION: ERR_UNSUPPORTED_ENCRYPTION,
|
|
6130
6230
|
ERR_UNSUPPORTED_UINT64: ERR_UNSUPPORTED_UINT64,
|
|
6131
6231
|
ERR_WORKER_STARTUP_TIMEOUT: ERR_WORKER_STARTUP_TIMEOUT,
|
|
6232
|
+
WARNING_APPENDED_DATA: WARNING_APPENDED_DATA,
|
|
6233
|
+
WARNING_COMPRESSED_PATCHED_DATA: WARNING_COMPRESSED_PATCHED_DATA,
|
|
6234
|
+
WARNING_DUPLICATE_FILENAME: WARNING_DUPLICATE_FILENAME,
|
|
6235
|
+
WARNING_MALFORMED_EXTRA_FIELD: WARNING_MALFORMED_EXTRA_FIELD,
|
|
6236
|
+
WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG: WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG,
|
|
6237
|
+
WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD: WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD,
|
|
6238
|
+
WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES: WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES,
|
|
6239
|
+
WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY: WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY,
|
|
6240
|
+
WARNING_PREPENDED_DATA: WARNING_PREPENDED_DATA,
|
|
6241
|
+
WARNING_TRAILING_CENTRAL_DIRECTORY_DATA: WARNING_TRAILING_CENTRAL_DIRECTORY_DATA,
|
|
6242
|
+
WARNING_UNKNOWN_VERSION: WARNING_UNKNOWN_VERSION,
|
|
6243
|
+
WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA: WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA,
|
|
6244
|
+
WARNING_UNSORTED_CENTRAL_DIRECTORY: WARNING_UNSORTED_CENTRAL_DIRECTORY,
|
|
6245
|
+
WARNING_WRAPPED_ENTRIES_COUNT: WARNING_WRAPPED_ENTRIES_COUNT,
|
|
6132
6246
|
ZipReader: ZipReader,
|
|
6133
|
-
ZipReaderStream: ZipReaderStream
|
|
6247
|
+
ZipReaderStream: ZipReaderStream,
|
|
6248
|
+
isZipFile: isZipFile
|
|
6134
6249
|
});
|
|
6135
6250
|
|
|
6136
6251
|
/*
|
|
@@ -6343,6 +6458,7 @@ class ZipWriter {
|
|
|
6343
6458
|
rawExtraFieldNTFS: EMPTY_UINT8_ARRAY,
|
|
6344
6459
|
rawExtraFieldUnix: EMPTY_UINT8_ARRAY,
|
|
6345
6460
|
rawExtraField,
|
|
6461
|
+
rawCentralExtraField: EMPTY_UINT8_ARRAY,
|
|
6346
6462
|
extendedTimestamp: false,
|
|
6347
6463
|
headerArray,
|
|
6348
6464
|
headerView
|
|
@@ -6516,7 +6632,6 @@ async function prependZipEntries(zipWriter, reader) {
|
|
|
6516
6632
|
|
|
6517
6633
|
async function addFileEntry(zipWriter, name, reader, options) {
|
|
6518
6634
|
options = Object.assign({}, options);
|
|
6519
|
-
name = name.trim();
|
|
6520
6635
|
if (getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY) && !name.endsWith(DIRECTORY_SIGNATURE)) {
|
|
6521
6636
|
name += DIRECTORY_SIGNATURE;
|
|
6522
6637
|
}
|
|
@@ -6607,7 +6722,6 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6607
6722
|
}
|
|
6608
6723
|
|
|
6609
6724
|
function resolveAttributes(zipWriter, name, options) {
|
|
6610
|
-
name = name.trim();
|
|
6611
6725
|
let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
6612
6726
|
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? VERSION_MADE_BY_MSDOS : VERSION_MADE_BY_UNIX);
|
|
6613
6727
|
const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
|
|
@@ -6812,6 +6926,7 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6812
6926
|
}
|
|
6813
6927
|
const rawExtraField = serializeExtraField(options[PROPERTY_NAME_EXTRA_FIELD]);
|
|
6814
6928
|
const rawLocalExtraField = serializeExtraField(options[OPTION_LOCAL_EXTRA_FIELD]);
|
|
6929
|
+
const rawCentralExtraField = serializeExtraField(options[OPTION_CENTRAL_EXTRA_FIELD]);
|
|
6815
6930
|
return {
|
|
6816
6931
|
comment,
|
|
6817
6932
|
resolvedOptions: {
|
|
@@ -6847,7 +6962,8 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6847
6962
|
dataDescriptor,
|
|
6848
6963
|
zip64,
|
|
6849
6964
|
rawExtraField,
|
|
6850
|
-
rawLocalExtraField
|
|
6965
|
+
rawLocalExtraField,
|
|
6966
|
+
rawCentralExtraField
|
|
6851
6967
|
}
|
|
6852
6968
|
};
|
|
6853
6969
|
}
|
|
@@ -7166,6 +7282,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7166
7282
|
versionMadeBy,
|
|
7167
7283
|
rawComment,
|
|
7168
7284
|
rawExtraField,
|
|
7285
|
+
rawCentralExtraField,
|
|
7169
7286
|
useWebWorkers,
|
|
7170
7287
|
transferStreams,
|
|
7171
7288
|
onstart,
|
|
@@ -7209,6 +7326,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7209
7326
|
rawExtraFieldUnix,
|
|
7210
7327
|
rawExtraFieldAES,
|
|
7211
7328
|
rawExtraField,
|
|
7329
|
+
rawCentralExtraField,
|
|
7212
7330
|
extendedTimestamp,
|
|
7213
7331
|
msDosCompatible,
|
|
7214
7332
|
internalFileAttributes,
|
|
@@ -7240,6 +7358,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7240
7358
|
const workerOptions = {
|
|
7241
7359
|
options: {
|
|
7242
7360
|
codecType: CODEC_DEFLATE,
|
|
7361
|
+
inputSize: size,
|
|
7243
7362
|
level,
|
|
7244
7363
|
rawPassword,
|
|
7245
7364
|
password,
|
|
@@ -7709,6 +7828,7 @@ function createDirectoryRecords(files) {
|
|
|
7709
7828
|
rawExtraFieldNTFS,
|
|
7710
7829
|
rawExtraFieldUnix,
|
|
7711
7830
|
rawExtraField,
|
|
7831
|
+
rawCentralExtraField,
|
|
7712
7832
|
extendedTimestamp,
|
|
7713
7833
|
extraFieldExtendedTimestampFlag,
|
|
7714
7834
|
lastModDate,
|
|
@@ -7763,7 +7883,8 @@ function createDirectoryRecords(files) {
|
|
|
7763
7883
|
rawExtraFieldNTFS,
|
|
7764
7884
|
rawExtraFieldUnix,
|
|
7765
7885
|
rawExtraFieldTimestamp,
|
|
7766
|
-
rawExtraField
|
|
7886
|
+
rawExtraField,
|
|
7887
|
+
rawCentralExtraField);
|
|
7767
7888
|
if (extraFieldLength > MAX_16_BITS) {
|
|
7768
7889
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7769
7890
|
}
|
|
@@ -7791,6 +7912,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
7791
7912
|
rawExtraFieldNTFS,
|
|
7792
7913
|
rawExtraFieldUnix,
|
|
7793
7914
|
rawExtraField,
|
|
7915
|
+
rawCentralExtraField,
|
|
7794
7916
|
rawComment,
|
|
7795
7917
|
versionMadeBy,
|
|
7796
7918
|
headerArray,
|
|
@@ -7805,7 +7927,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
7805
7927
|
uncompressedSize,
|
|
7806
7928
|
compressedSize
|
|
7807
7929
|
} = fileEntry;
|
|
7808
|
-
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
|
|
7930
|
+
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawCentralExtraField);
|
|
7809
7931
|
const directoryRecordLength = CENTRAL_FILE_HEADER_LENGTH + getLength(rawFilename, rawComment) + extraFieldLength;
|
|
7810
7932
|
if (exceedsAvailableSize(writer, offset + directoryRecordLength - directoryDiskOffset)) {
|
|
7811
7933
|
await writeData(writer, directoryArray.slice(directoryDiskOffset, offset));
|
|
@@ -7843,6 +7965,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
7843
7965
|
directoryRecord.writeBytes(rawExtraFieldNTFS);
|
|
7844
7966
|
directoryRecord.writeBytes(rawExtraFieldUnix);
|
|
7845
7967
|
directoryRecord.writeBytes(rawExtraField);
|
|
7968
|
+
directoryRecord.writeBytes(rawCentralExtraField);
|
|
7846
7969
|
directoryRecord.writeBytes(rawComment);
|
|
7847
7970
|
arraySet(directoryArray, directoryRecord.array, offset);
|
|
7848
7971
|
offset += directoryRecordLength;
|
|
@@ -8346,6 +8469,111 @@ function getMimeType() {
|
|
|
8346
8469
|
*/
|
|
8347
8470
|
|
|
8348
8471
|
|
|
8472
|
+
function getSupportedCompressionMethods() {
|
|
8473
|
+
const { CompressionStream, DecompressionStream, CompressionStreamFallback, DecompressionStreamFallback } = getConfiguration();
|
|
8474
|
+
const supportedMethods = [{
|
|
8475
|
+
compressionMethod: COMPRESSION_METHOD_STORE,
|
|
8476
|
+
compression: true,
|
|
8477
|
+
decompression: true,
|
|
8478
|
+
registered: false
|
|
8479
|
+
}, {
|
|
8480
|
+
compressionMethod: COMPRESSION_METHOD_DEFLATE,
|
|
8481
|
+
compression: formatSupported(CompressionStreamFallback, FORMAT_DEFLATE_RAW$1) ||
|
|
8482
|
+
formatSupported(CompressionStream, FORMAT_DEFLATE_RAW$1) || formatSupported(CompressionStream, FORMAT_GZIP$1),
|
|
8483
|
+
decompression: formatSupported(DecompressionStreamFallback, FORMAT_DEFLATE_RAW$1) ||
|
|
8484
|
+
formatSupported(DecompressionStream, FORMAT_DEFLATE_RAW$1) || formatSupported(DecompressionStream, FORMAT_GZIP$1),
|
|
8485
|
+
registered: false
|
|
8486
|
+
}, {
|
|
8487
|
+
compressionMethod: COMPRESSION_METHOD_DEFLATE_64,
|
|
8488
|
+
compression: false,
|
|
8489
|
+
decompression: formatSupported(DecompressionStreamFallback, FORMAT_DEFLATE64_RAW$1) ||
|
|
8490
|
+
formatSupported(DecompressionStream, FORMAT_DEFLATE64_RAW$1),
|
|
8491
|
+
registered: false
|
|
8492
|
+
}];
|
|
8493
|
+
for (const codec of getRegisteredCodecs()) {
|
|
8494
|
+
const codecStreams = getCodecStreams(codec.format);
|
|
8495
|
+
supportedMethods.push({
|
|
8496
|
+
compressionMethod: codec.compressionMethod,
|
|
8497
|
+
// deno-lint-ignore valid-typeof
|
|
8498
|
+
compression: codecStreams ? typeof codecStreams.CompressionStream == FUNCTION_TYPE : UNDEFINED_VALUE,
|
|
8499
|
+
// deno-lint-ignore valid-typeof
|
|
8500
|
+
decompression: codecStreams ? typeof codecStreams.DecompressionStream == FUNCTION_TYPE : UNDEFINED_VALUE,
|
|
8501
|
+
registered: true
|
|
8502
|
+
});
|
|
8503
|
+
}
|
|
8504
|
+
return supportedMethods;
|
|
8505
|
+
}
|
|
8506
|
+
|
|
8507
|
+
function formatSupported(StreamClass, format) {
|
|
8508
|
+
if (!StreamClass) {
|
|
8509
|
+
return false;
|
|
8510
|
+
}
|
|
8511
|
+
const { supportedFormats } = StreamClass;
|
|
8512
|
+
if (supportedFormats) {
|
|
8513
|
+
return supportedFormats.includes(format);
|
|
8514
|
+
}
|
|
8515
|
+
return supportsFormat(StreamClass, format);
|
|
8516
|
+
}
|
|
8517
|
+
|
|
8518
|
+
/*
|
|
8519
|
+
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
8520
|
+
|
|
8521
|
+
Redistribution and use in source and binary forms, with or without
|
|
8522
|
+
modification, are permitted provided that the following conditions are met:
|
|
8523
|
+
|
|
8524
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
8525
|
+
this list of conditions and the following disclaimer.
|
|
8526
|
+
|
|
8527
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
8528
|
+
notice, this list of conditions and the following disclaimer in
|
|
8529
|
+
the documentation and/or other materials provided with the distribution.
|
|
8530
|
+
|
|
8531
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
8532
|
+
derived from this software without specific prior written permission.
|
|
8533
|
+
|
|
8534
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
8535
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
8536
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
8537
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
8538
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
8539
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
8540
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
8541
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
8542
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
8543
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8544
|
+
*/
|
|
8545
|
+
|
|
8546
|
+
const VERSION = "2.8.60";
|
|
8547
|
+
|
|
8548
|
+
/*
|
|
8549
|
+
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
8550
|
+
|
|
8551
|
+
Redistribution and use in source and binary forms, with or without
|
|
8552
|
+
modification, are permitted provided that the following conditions are met:
|
|
8553
|
+
|
|
8554
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
8555
|
+
this list of conditions and the following disclaimer.
|
|
8556
|
+
|
|
8557
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
8558
|
+
notice, this list of conditions and the following disclaimer in
|
|
8559
|
+
the documentation and/or other materials provided with the distribution.
|
|
8560
|
+
|
|
8561
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
8562
|
+
derived from this software without specific prior written permission.
|
|
8563
|
+
|
|
8564
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
8565
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
8566
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
8567
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
8568
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
8569
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
8570
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
8571
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
8572
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
8573
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8574
|
+
*/
|
|
8575
|
+
|
|
8576
|
+
|
|
8349
8577
|
const DEFAULT_THRESHOLD$2 = 1024 * 1024;
|
|
8350
8578
|
const DEFAULT_DIRECTORY_NAME$1 = ".zip.js-temp";
|
|
8351
8579
|
|
|
@@ -8794,6 +9022,11 @@ try {
|
|
|
8794
9022
|
|
|
8795
9023
|
/* global TransformStream */
|
|
8796
9024
|
|
|
9025
|
+
const FORMAT_DEFLATE = "deflate";
|
|
9026
|
+
const FORMAT_DEFLATE_RAW = "deflate-raw";
|
|
9027
|
+
const FORMAT_DEFLATE64_RAW = "deflate64-raw";
|
|
9028
|
+
const FORMAT_GZIP = "gzip";
|
|
9029
|
+
|
|
8797
9030
|
let wasm, malloc, free, memory, initError;
|
|
8798
9031
|
|
|
8799
9032
|
function setWasmExports(wasmAPI) {
|
|
@@ -8839,15 +9072,15 @@ function _make(isCompress, type, options = {}) {
|
|
|
8839
9072
|
this._last_consumed = wasm.deflate_last_consumed;
|
|
8840
9073
|
this._end = wasm.deflate_end;
|
|
8841
9074
|
this.streamHandle = wasm.deflate_new();
|
|
8842
|
-
if (type ===
|
|
9075
|
+
if (type === FORMAT_GZIP) {
|
|
8843
9076
|
result = wasm.deflate_init_gzip(this.streamHandle, level);
|
|
8844
|
-
} else if (type ===
|
|
9077
|
+
} else if (type === FORMAT_DEFLATE_RAW) {
|
|
8845
9078
|
result = wasm.deflate_init_raw(this.streamHandle, level);
|
|
8846
9079
|
} else {
|
|
8847
9080
|
result = wasm.deflate_init(this.streamHandle, level);
|
|
8848
9081
|
}
|
|
8849
9082
|
} else {
|
|
8850
|
-
if (type ===
|
|
9083
|
+
if (type === FORMAT_DEFLATE64_RAW) {
|
|
8851
9084
|
this._process = wasm.inflate9_process;
|
|
8852
9085
|
this._last_consumed = wasm.inflate9_last_consumed;
|
|
8853
9086
|
this._end = wasm.inflate9_end;
|
|
@@ -8858,9 +9091,9 @@ function _make(isCompress, type, options = {}) {
|
|
|
8858
9091
|
this._last_consumed = wasm.inflate_last_consumed;
|
|
8859
9092
|
this._end = wasm.inflate_end;
|
|
8860
9093
|
this.streamHandle = wasm.inflate_new();
|
|
8861
|
-
if (type ===
|
|
9094
|
+
if (type === FORMAT_DEFLATE_RAW) {
|
|
8862
9095
|
result = wasm.inflate_init_raw(this.streamHandle);
|
|
8863
|
-
} else if (type ===
|
|
9096
|
+
} else if (type === FORMAT_GZIP) {
|
|
8864
9097
|
result = wasm.inflate_init_gzip(this.streamHandle);
|
|
8865
9098
|
} else {
|
|
8866
9099
|
result = wasm.inflate_init(this.streamHandle);
|
|
@@ -8981,12 +9214,12 @@ function _make(isCompress, type, options = {}) {
|
|
|
8981
9214
|
}
|
|
8982
9215
|
|
|
8983
9216
|
class CompressionStreamZlib {
|
|
8984
|
-
constructor(type =
|
|
9217
|
+
constructor(type = FORMAT_DEFLATE, options) {
|
|
8985
9218
|
return _make(true, type, options);
|
|
8986
9219
|
}
|
|
8987
9220
|
}
|
|
8988
9221
|
class DecompressionStreamZlib {
|
|
8989
|
-
constructor(type =
|
|
9222
|
+
constructor(type = FORMAT_DEFLATE, options) {
|
|
8990
9223
|
return _make(false, type, options);
|
|
8991
9224
|
}
|
|
8992
9225
|
}
|
|
@@ -8995,6 +9228,11 @@ class DecompressionStreamZlib {
|
|
|
8995
9228
|
// module fails to load, rather than discarding a self-contained codec supplied through config.
|
|
8996
9229
|
CompressionStreamZlib.requiresModule = true;
|
|
8997
9230
|
DecompressionStreamZlib.requiresModule = true;
|
|
9231
|
+
// Constructing these classes before the module is loaded throws, so capability probes cannot rely
|
|
9232
|
+
// on trying the constructor; the formats are declared instead, next to the branches implementing
|
|
9233
|
+
// them in _make().
|
|
9234
|
+
CompressionStreamZlib.supportedFormats = [FORMAT_DEFLATE, FORMAT_DEFLATE_RAW, FORMAT_GZIP];
|
|
9235
|
+
DecompressionStreamZlib.supportedFormats = [FORMAT_DEFLATE, FORMAT_DEFLATE_RAW, FORMAT_GZIP, FORMAT_DEFLATE64_RAW];
|
|
8998
9236
|
|
|
8999
9237
|
/*
|
|
9000
9238
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9139,4 +9377,4 @@ function terminateWorkersAndModule() {
|
|
|
9139
9377
|
|
|
9140
9378
|
configureExternalAssets();
|
|
9141
9379
|
|
|
9142
|
-
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_DATA_OUT_OF_BOUNDS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMMENT_TYPE, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_DATE, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_COMMENT_TYPE, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_DATA_TYPE, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_FUNCTION_OPTION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MAX_WORKERS, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_SIGNAL, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_COMPRESSION_METHOD, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_UNSUPPORTED_UINT64, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|
|
9380
|
+
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_DATA_OUT_OF_BOUNDS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMMENT_TYPE, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_DATE, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_COMMENT_TYPE, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_DATA_TYPE, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_FUNCTION_OPTION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MAX_WORKERS, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_SIGNAL, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_COMPRESSION_METHOD, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_UNSUPPORTED_UINT64, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, VERSION, WARNING_APPENDED_DATA, WARNING_COMPRESSED_PATCHED_DATA, WARNING_DUPLICATE_FILENAME, WARNING_MALFORMED_EXTRA_FIELD, WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG, WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD, WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY, WARNING_PREPENDED_DATA, WARNING_TRAILING_CENTRAL_DIRECTORY_DATA, WARNING_UNKNOWN_VERSION, WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA, WARNING_UNSORTED_CENTRAL_DIRECTORY, WARNING_WRAPPED_ENTRIES_COUNT, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, getMimeType, getRegisteredCodecs, getSupportedCompressionMethods, isZipFile, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|