@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);
|
|
@@ -4760,6 +4766,21 @@ const ERR_INVALID_STRICTNESS = "Invalid strictness (must be 'strict', 'balanced'
|
|
|
4760
4766
|
const ERR_INVALID_FILENAME_VALIDATION = "Invalid filenameValidation (must be 'strict', 'balanced' or 'tolerant')";
|
|
4761
4767
|
const ERR_INVALID_MAX_APPENDED_DATA_SIZE = "Invalid maxAppendedDataSize (must be a number greater than or equal to 0)";
|
|
4762
4768
|
const ERR_UNSUPPORTED_UINT64 = "64-bit value exceeds Number.MAX_SAFE_INTEGER";
|
|
4769
|
+
const WARNING_UNSORTED_CENTRAL_DIRECTORY = "unsorted central directory";
|
|
4770
|
+
const WARNING_UNKNOWN_VERSION = "unknown version needed to extract";
|
|
4771
|
+
const WARNING_COMPRESSED_PATCHED_DATA = "compressed patched data";
|
|
4772
|
+
const WARNING_MALFORMED_EXTRA_FIELD = "malformed extra field";
|
|
4773
|
+
const WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA = "unknown zip64 extensible data";
|
|
4774
|
+
const WARNING_WRAPPED_ENTRIES_COUNT = "wrapped entries count";
|
|
4775
|
+
const WARNING_APPENDED_DATA = "appended data";
|
|
4776
|
+
const WARNING_PREPENDED_DATA = "prepended data";
|
|
4777
|
+
const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA = "trailing central directory data";
|
|
4778
|
+
const WARNING_DUPLICATE_FILENAME = "duplicate filename";
|
|
4779
|
+
const WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY = "mismatched zip64 end of central directory record";
|
|
4780
|
+
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG = "mismatched local file header (general purpose bit flag)";
|
|
4781
|
+
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD = "mismatched local file header (compression method)";
|
|
4782
|
+
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES = "mismatched local file header (crc32 or sizes)";
|
|
4783
|
+
const MAX_KNOWN_VERSION = 63;
|
|
4763
4784
|
const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
|
|
4764
4785
|
const CHARSET_UTF8 = "utf-8";
|
|
4765
4786
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
@@ -4810,6 +4831,7 @@ class ZipReader {
|
|
|
4810
4831
|
if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
|
|
4811
4832
|
throw new Error(ERR_BAD_FORMAT);
|
|
4812
4833
|
}
|
|
4834
|
+
const warnings = zipReader.warnings = [];
|
|
4813
4835
|
const strictness = getStrictness(options, zipReader.options);
|
|
4814
4836
|
const checkAmbiguity = strictness == STRICTNESS_STRICT;
|
|
4815
4837
|
const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
|
|
@@ -4833,8 +4855,12 @@ class ZipReader {
|
|
|
4833
4855
|
const commentOffset = endOfDirectoryInfo.offset;
|
|
4834
4856
|
const commentLength = getUint16$1(endOfDirectoryView, 20);
|
|
4835
4857
|
const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
|
|
4836
|
-
|
|
4837
|
-
|
|
4858
|
+
const appendedDataLength = reader.size - appendedDataOffset;
|
|
4859
|
+
if (appendedDataLength > maxAppendedDataSize) {
|
|
4860
|
+
throwAmbiguousArchive(WARNING_APPENDED_DATA);
|
|
4861
|
+
}
|
|
4862
|
+
if (appendedDataLength > 0) {
|
|
4863
|
+
addWarning(warnings, WARNING_APPENDED_DATA);
|
|
4838
4864
|
}
|
|
4839
4865
|
let lastDiskNumber = getUint16$1(endOfDirectoryView, 4);
|
|
4840
4866
|
const expectedLastDiskNumber = reader.lastDiskNumber || 0;
|
|
@@ -4888,23 +4914,23 @@ class ZipReader {
|
|
|
4888
4914
|
}
|
|
4889
4915
|
if (lastDiskNumber == MAX_16_BITS) {
|
|
4890
4916
|
lastDiskNumber = getUint32$1(endOfDirectoryView, 16);
|
|
4891
|
-
} else if (
|
|
4892
|
-
|
|
4917
|
+
} else if (lastDiskNumber != getUint32$1(endOfDirectoryView, 16)) {
|
|
4918
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY);
|
|
4893
4919
|
}
|
|
4894
4920
|
if (diskNumber == MAX_16_BITS) {
|
|
4895
4921
|
diskNumber = getUint32$1(endOfDirectoryView, 20);
|
|
4896
|
-
} else if (
|
|
4897
|
-
|
|
4922
|
+
} else if (diskNumber != getUint32$1(endOfDirectoryView, 20)) {
|
|
4923
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY);
|
|
4898
4924
|
}
|
|
4899
4925
|
if (filesLength == MAX_16_BITS) {
|
|
4900
4926
|
filesLength = getBigUint64(endOfDirectoryView, 32);
|
|
4901
|
-
} else if (
|
|
4902
|
-
|
|
4927
|
+
} else if (filesLength != getBigUint64(endOfDirectoryView, 32)) {
|
|
4928
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY);
|
|
4903
4929
|
}
|
|
4904
4930
|
if (directoryDataLength == MAX_32_BITS) {
|
|
4905
4931
|
directoryDataLength = getBigUint64(endOfDirectoryView, 40);
|
|
4906
|
-
} else if (
|
|
4907
|
-
|
|
4932
|
+
} else if (directoryDataLength != getBigUint64(endOfDirectoryView, 40)) {
|
|
4933
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY);
|
|
4908
4934
|
}
|
|
4909
4935
|
directoryDataOffset = getDiskOffset$1(reader, diskNumber) + getBigUint64(endOfDirectoryView, 48) + prependedDataLength;
|
|
4910
4936
|
}
|
|
@@ -4973,14 +4999,22 @@ class ZipReader {
|
|
|
4973
4999
|
declaredDirectoryDataLength = directoryArray.length;
|
|
4974
5000
|
decryptedDirectory = true;
|
|
4975
5001
|
}
|
|
5002
|
+
if (directoryEncryptionInfo && !decryptedDirectory &&
|
|
5003
|
+
(directoryArray.length < 4 || getUint32$1(directoryView, 0) == CENTRAL_FILE_HEADER_SIGNATURE)) {
|
|
5004
|
+
addWarning(warnings, WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA);
|
|
5005
|
+
}
|
|
4976
5006
|
startOffset = directoryDataOffset;
|
|
4977
5007
|
const filenameEncoding = getOptionValue$1(zipReader, options, OPTION_FILENAME_ENCODING);
|
|
4978
5008
|
const commentEncoding = getOptionValue$1(zipReader, options, OPTION_COMMENT_ENCODING);
|
|
4979
|
-
const filenames =
|
|
5009
|
+
const filenames = new Set();
|
|
4980
5010
|
let duplicateFilename;
|
|
5011
|
+
let previousEntryPosition = -1;
|
|
4981
5012
|
const recoverWrappedFilesLength = !checkAmbiguity && !zip64EndOfDirectory;
|
|
4982
5013
|
if (!filesLength && recoverWrappedFilesLength) {
|
|
4983
5014
|
filesLength = getWrappedFilesLength(directoryView, directoryArray, offset);
|
|
5015
|
+
if (filesLength) {
|
|
5016
|
+
addWarning(warnings, WARNING_WRAPPED_ENTRIES_COUNT);
|
|
5017
|
+
}
|
|
4984
5018
|
}
|
|
4985
5019
|
for (let indexFile = 0; indexFile < filesLength; indexFile++) {
|
|
4986
5020
|
const fileEntry = new ZipEntry$1(reader, zipReader.options);
|
|
@@ -5059,15 +5093,26 @@ class ZipReader {
|
|
|
5059
5093
|
filename,
|
|
5060
5094
|
comment
|
|
5061
5095
|
});
|
|
5062
|
-
readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6)
|
|
5096
|
+
if (readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6)) {
|
|
5097
|
+
addWarning(warnings, WARNING_MALFORMED_EXTRA_FIELD, filename);
|
|
5098
|
+
}
|
|
5063
5099
|
fileEntry.offset += prependedDataLength;
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5100
|
+
const entryPosition = getDiskOffset$1(reader, fileEntry.diskNumberStart) + fileEntry.offset;
|
|
5101
|
+
startOffset = Math.min(entryPosition, startOffset);
|
|
5102
|
+
if (entryPosition < previousEntryPosition) {
|
|
5103
|
+
addWarning(warnings, WARNING_UNSORTED_CENTRAL_DIRECTORY, filename);
|
|
5104
|
+
}
|
|
5105
|
+
previousEntryPosition = entryPosition;
|
|
5106
|
+
if ((fileEntry.version & MAX_8_BITS) > MAX_KNOWN_VERSION) {
|
|
5107
|
+
addWarning(warnings, WARNING_UNKNOWN_VERSION, filename);
|
|
5070
5108
|
}
|
|
5109
|
+
if ((fileEntry.rawBitFlag & BITFLAG_COMPRESSED_PATCHED_DATA) == BITFLAG_COMPRESSED_PATCHED_DATA) {
|
|
5110
|
+
addWarning(warnings, WARNING_COMPRESSED_PATCHED_DATA, filename);
|
|
5111
|
+
}
|
|
5112
|
+
if (filenames.has(fileEntry.filename)) {
|
|
5113
|
+
duplicateFilename = true;
|
|
5114
|
+
}
|
|
5115
|
+
filenames.add(fileEntry.filename);
|
|
5071
5116
|
const unixExternalUpper = (fileEntry.externalFileAttributes >> 16) & MAX_16_BITS;
|
|
5072
5117
|
if (fileEntry.unixMode === UNDEFINED_VALUE && (unixExternalUpper & (FILE_ATTR_UNIX_DEFAULT_MASK | FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_TYPE_DIR)) != 0) {
|
|
5073
5118
|
fileEntry.unixMode = unixExternalUpper;
|
|
@@ -5105,7 +5150,11 @@ class ZipReader {
|
|
|
5105
5150
|
};
|
|
5106
5151
|
offset = endOffset;
|
|
5107
5152
|
if (indexFile == filesLength - 1 && recoverWrappedFilesLength) {
|
|
5108
|
-
|
|
5153
|
+
const wrappedFilesLength = getWrappedFilesLength(directoryView, directoryArray, offset);
|
|
5154
|
+
if (wrappedFilesLength) {
|
|
5155
|
+
filesLength += wrappedFilesLength;
|
|
5156
|
+
addWarning(warnings, WARNING_WRAPPED_ENTRIES_COUNT);
|
|
5157
|
+
}
|
|
5109
5158
|
}
|
|
5110
5159
|
const { onprogress } = options;
|
|
5111
5160
|
if (onprogress) {
|
|
@@ -5131,18 +5180,22 @@ class ZipReader {
|
|
|
5131
5180
|
zipReader.digitalSignature = digitalSignature;
|
|
5132
5181
|
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
5133
5182
|
}
|
|
5134
|
-
if (
|
|
5135
|
-
|
|
5183
|
+
if ((offset != declaredDirectoryDataLength && offsetAfterSignature != declaredDirectoryDataLength) ||
|
|
5184
|
+
(!decryptedDirectory && offset != directoryDataLength && offsetAfterSignature != directoryDataLength)) {
|
|
5185
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_TRAILING_CENTRAL_DIRECTORY_DATA);
|
|
5136
5186
|
}
|
|
5137
5187
|
if (duplicateFilename) {
|
|
5138
|
-
|
|
5188
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_DUPLICATE_FILENAME);
|
|
5139
5189
|
}
|
|
5140
5190
|
const extractPrependedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_PREPENDED_DATA);
|
|
5141
5191
|
const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
|
|
5142
5192
|
const splitZipSignatureLength = (checkAmbiguity || extractPrependedData) && filesLength &&
|
|
5143
5193
|
startOffset == SPLIT_ZIP_FILE_SIGNATURE_LENGTH && await startsWithSplitZipMarker(reader) ? SPLIT_ZIP_FILE_SIGNATURE_LENGTH : 0;
|
|
5144
5194
|
if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > splitZipSignatureLength))) {
|
|
5145
|
-
throwAmbiguousArchive(
|
|
5195
|
+
throwAmbiguousArchive(WARNING_PREPENDED_DATA);
|
|
5196
|
+
}
|
|
5197
|
+
if (prependedDataLength || (filesLength && startOffset > SPLIT_ZIP_FILE_SIGNATURE_LENGTH)) {
|
|
5198
|
+
addWarning(warnings, WARNING_PREPENDED_DATA);
|
|
5146
5199
|
}
|
|
5147
5200
|
if (extractPrependedData) {
|
|
5148
5201
|
zipReader.prependedData = startOffset > splitZipSignatureLength ?
|
|
@@ -5212,6 +5265,28 @@ class ZipReaderStream {
|
|
|
5212
5265
|
}
|
|
5213
5266
|
}
|
|
5214
5267
|
|
|
5268
|
+
async function isZipFile(reader, options = {}) {
|
|
5269
|
+
reader = new GenericReader(reader);
|
|
5270
|
+
await initStream(reader);
|
|
5271
|
+
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
5272
|
+
reader = new BlobReader(await streamToBlob(reader.readable));
|
|
5273
|
+
await initStream(reader);
|
|
5274
|
+
}
|
|
5275
|
+
if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
|
|
5276
|
+
return false;
|
|
5277
|
+
}
|
|
5278
|
+
const strictness = getStrictness(options, {});
|
|
5279
|
+
const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
|
|
5280
|
+
const maxAppendedDataSize = getMaxAppendedDataSize(options[OPTION_MAX_APPENDED_DATA_SIZE], strictness);
|
|
5281
|
+
const { endOfDirectoryInfo, endOfDirectoryReachingEndCount } = await findEndOfCentralDirectory(reader, rejectAmbiguousEndOfDirectory, maxAppendedDataSize);
|
|
5282
|
+
if (!endOfDirectoryInfo || (strictness == STRICTNESS_STRICT && endOfDirectoryReachingEndCount > 1)) {
|
|
5283
|
+
return false;
|
|
5284
|
+
}
|
|
5285
|
+
const commentLength = getUint16$1(getDataView(endOfDirectoryInfo), 20);
|
|
5286
|
+
const appendedDataOffset = endOfDirectoryInfo.offset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
|
|
5287
|
+
return reader.size - appendedDataOffset <= maxAppendedDataSize;
|
|
5288
|
+
}
|
|
5289
|
+
|
|
5215
5290
|
let ZipEntry$1 = class ZipEntry {
|
|
5216
5291
|
|
|
5217
5292
|
constructor(reader, options) {
|
|
@@ -5243,6 +5318,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5243
5318
|
dataDescriptor
|
|
5244
5319
|
} = bitFlag;
|
|
5245
5320
|
const localDirectory = fileEntry.localDirectory = {};
|
|
5321
|
+
const warnings = fileEntry.warnings = [];
|
|
5246
5322
|
const localHeaderOffset = getDiskOffset$1(reader, diskNumberStart) + offset;
|
|
5247
5323
|
const dataArray = await readUint8Array(reader, localHeaderOffset, HEADER_SIZE);
|
|
5248
5324
|
const dataView = getDataView(dataArray);
|
|
@@ -5283,10 +5359,10 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5283
5359
|
if (checkLocalFilename) {
|
|
5284
5360
|
localDirectory.rawFilename = rawLocalFilename;
|
|
5285
5361
|
}
|
|
5286
|
-
readCommonFooter(zipEntry, localDirectory, dataView, 4, true)
|
|
5287
|
-
|
|
5288
|
-
validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename);
|
|
5362
|
+
if (readCommonFooter(zipEntry, localDirectory, dataView, 4, true)) {
|
|
5363
|
+
addWarning(warnings, WARNING_MALFORMED_EXTRA_FIELD);
|
|
5289
5364
|
}
|
|
5365
|
+
validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename, checkLocalDirectory ? UNDEFINED_VALUE : warnings);
|
|
5290
5366
|
const { lastAccessDate, creationDate, uid, gid } = localDirectory;
|
|
5291
5367
|
if (lastAccessDate) {
|
|
5292
5368
|
fileEntry.lastAccessDate = lastAccessDate;
|
|
@@ -5512,6 +5588,7 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5512
5588
|
const extraField = directory.extraField = new Map();
|
|
5513
5589
|
const rawExtraFieldView = getDataView(rawExtraField);
|
|
5514
5590
|
let offsetExtraField = 0;
|
|
5591
|
+
let malformedExtraField = false;
|
|
5515
5592
|
try {
|
|
5516
5593
|
while (offsetExtraField < rawExtraField.length) {
|
|
5517
5594
|
const type = getUint16$1(rawExtraFieldView, offsetExtraField);
|
|
@@ -5523,7 +5600,10 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5523
5600
|
offsetExtraField += 4 + size;
|
|
5524
5601
|
}
|
|
5525
5602
|
} catch {
|
|
5526
|
-
|
|
5603
|
+
malformedExtraField = true;
|
|
5604
|
+
}
|
|
5605
|
+
if (offsetExtraField > rawExtraField.length) {
|
|
5606
|
+
malformedExtraField = true;
|
|
5527
5607
|
}
|
|
5528
5608
|
const compressionMethod = getUint16$1(dataView, offset + 4);
|
|
5529
5609
|
Object.assign(directory, {
|
|
@@ -5591,6 +5671,7 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5591
5671
|
if (extraFieldUSDZ) {
|
|
5592
5672
|
directory.extraFieldUSDZ = extraFieldUSDZ;
|
|
5593
5673
|
}
|
|
5674
|
+
return malformedExtraField;
|
|
5594
5675
|
}
|
|
5595
5676
|
|
|
5596
5677
|
function readExtraFieldZip64(extraFieldZip64, directory) {
|
|
@@ -6052,27 +6133,46 @@ async function readSignature(reader, view, anchoredOffset, signatureOffset, size
|
|
|
6052
6133
|
return UNDEFINED_VALUE;
|
|
6053
6134
|
}
|
|
6054
6135
|
|
|
6055
|
-
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
|
|
6136
|
+
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename, warnings) {
|
|
6056
6137
|
const { rawFilename } = zipEntry;
|
|
6138
|
+
const reject = !warnings;
|
|
6057
6139
|
const maskedLocalDirectory = zipEntry.decryptedDirectory &&
|
|
6058
6140
|
(localDirectory.rawBitFlag & BITFLAG_MASKED_LOCAL_HEADERS) == BITFLAG_MASKED_LOCAL_HEADERS;
|
|
6059
6141
|
if (checkLocalFilename && !maskedLocalDirectory &&
|
|
6060
6142
|
(rawLocalFilename.length != rawFilename.length ||
|
|
6061
6143
|
rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
|
|
6062
|
-
|
|
6144
|
+
reportAmbiguity(reject, warnings, "mismatched local file header (filename)");
|
|
6063
6145
|
}
|
|
6064
6146
|
if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
|
|
6065
|
-
|
|
6147
|
+
reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG);
|
|
6066
6148
|
}
|
|
6067
6149
|
if (localDirectory.compressionMethod != zipEntry.compressionMethod) {
|
|
6068
|
-
|
|
6150
|
+
reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD);
|
|
6069
6151
|
}
|
|
6070
6152
|
if (!localDirectory.bitFlag.dataDescriptor && !maskedLocalDirectory &&
|
|
6071
6153
|
(localDirectory.crc32 || localDirectory.compressedSize || localDirectory.uncompressedSize) &&
|
|
6072
6154
|
(localDirectory.crc32 != zipEntry.crc32 ||
|
|
6073
6155
|
localDirectory.compressedSize != zipEntry.compressedSize ||
|
|
6074
6156
|
localDirectory.uncompressedSize != zipEntry.uncompressedSize)) {
|
|
6075
|
-
|
|
6157
|
+
reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES);
|
|
6158
|
+
}
|
|
6159
|
+
}
|
|
6160
|
+
|
|
6161
|
+
function reportAmbiguity(reject, warnings, reason) {
|
|
6162
|
+
if (reject) {
|
|
6163
|
+
throwAmbiguousArchive(reason);
|
|
6164
|
+
} else {
|
|
6165
|
+
addWarning(warnings, reason);
|
|
6166
|
+
}
|
|
6167
|
+
}
|
|
6168
|
+
|
|
6169
|
+
function addWarning(warnings, reason, filename) {
|
|
6170
|
+
if (!warnings.some(warning => warning.reason == reason)) {
|
|
6171
|
+
const warning = { reason };
|
|
6172
|
+
if (filename !== UNDEFINED_VALUE) {
|
|
6173
|
+
warning.filename = filename;
|
|
6174
|
+
}
|
|
6175
|
+
warnings.push(warning);
|
|
6076
6176
|
}
|
|
6077
6177
|
}
|
|
6078
6178
|
|
|
@@ -6149,8 +6249,23 @@ var zipReader = /*#__PURE__*/Object.freeze({
|
|
|
6149
6249
|
ERR_UNSUPPORTED_ENCRYPTION: ERR_UNSUPPORTED_ENCRYPTION,
|
|
6150
6250
|
ERR_UNSUPPORTED_UINT64: ERR_UNSUPPORTED_UINT64,
|
|
6151
6251
|
ERR_WORKER_STARTUP_TIMEOUT: ERR_WORKER_STARTUP_TIMEOUT,
|
|
6252
|
+
WARNING_APPENDED_DATA: WARNING_APPENDED_DATA,
|
|
6253
|
+
WARNING_COMPRESSED_PATCHED_DATA: WARNING_COMPRESSED_PATCHED_DATA,
|
|
6254
|
+
WARNING_DUPLICATE_FILENAME: WARNING_DUPLICATE_FILENAME,
|
|
6255
|
+
WARNING_MALFORMED_EXTRA_FIELD: WARNING_MALFORMED_EXTRA_FIELD,
|
|
6256
|
+
WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG: WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG,
|
|
6257
|
+
WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD: WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD,
|
|
6258
|
+
WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES: WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES,
|
|
6259
|
+
WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY: WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY,
|
|
6260
|
+
WARNING_PREPENDED_DATA: WARNING_PREPENDED_DATA,
|
|
6261
|
+
WARNING_TRAILING_CENTRAL_DIRECTORY_DATA: WARNING_TRAILING_CENTRAL_DIRECTORY_DATA,
|
|
6262
|
+
WARNING_UNKNOWN_VERSION: WARNING_UNKNOWN_VERSION,
|
|
6263
|
+
WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA: WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA,
|
|
6264
|
+
WARNING_UNSORTED_CENTRAL_DIRECTORY: WARNING_UNSORTED_CENTRAL_DIRECTORY,
|
|
6265
|
+
WARNING_WRAPPED_ENTRIES_COUNT: WARNING_WRAPPED_ENTRIES_COUNT,
|
|
6152
6266
|
ZipReader: ZipReader,
|
|
6153
|
-
ZipReaderStream: ZipReaderStream
|
|
6267
|
+
ZipReaderStream: ZipReaderStream,
|
|
6268
|
+
isZipFile: isZipFile
|
|
6154
6269
|
});
|
|
6155
6270
|
|
|
6156
6271
|
/*
|
|
@@ -6363,6 +6478,7 @@ class ZipWriter {
|
|
|
6363
6478
|
rawExtraFieldNTFS: EMPTY_UINT8_ARRAY,
|
|
6364
6479
|
rawExtraFieldUnix: EMPTY_UINT8_ARRAY,
|
|
6365
6480
|
rawExtraField,
|
|
6481
|
+
rawCentralExtraField: EMPTY_UINT8_ARRAY,
|
|
6366
6482
|
extendedTimestamp: false,
|
|
6367
6483
|
headerArray,
|
|
6368
6484
|
headerView
|
|
@@ -6536,7 +6652,6 @@ async function prependZipEntries(zipWriter, reader) {
|
|
|
6536
6652
|
|
|
6537
6653
|
async function addFileEntry(zipWriter, name, reader, options) {
|
|
6538
6654
|
options = Object.assign({}, options);
|
|
6539
|
-
name = name.trim();
|
|
6540
6655
|
if (getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY) && !name.endsWith(DIRECTORY_SIGNATURE)) {
|
|
6541
6656
|
name += DIRECTORY_SIGNATURE;
|
|
6542
6657
|
}
|
|
@@ -6627,7 +6742,6 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6627
6742
|
}
|
|
6628
6743
|
|
|
6629
6744
|
function resolveAttributes(zipWriter, name, options) {
|
|
6630
|
-
name = name.trim();
|
|
6631
6745
|
let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
6632
6746
|
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? VERSION_MADE_BY_MSDOS : VERSION_MADE_BY_UNIX);
|
|
6633
6747
|
const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
|
|
@@ -6832,6 +6946,7 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6832
6946
|
}
|
|
6833
6947
|
const rawExtraField = serializeExtraField(options[PROPERTY_NAME_EXTRA_FIELD]);
|
|
6834
6948
|
const rawLocalExtraField = serializeExtraField(options[OPTION_LOCAL_EXTRA_FIELD]);
|
|
6949
|
+
const rawCentralExtraField = serializeExtraField(options[OPTION_CENTRAL_EXTRA_FIELD]);
|
|
6835
6950
|
return {
|
|
6836
6951
|
comment,
|
|
6837
6952
|
resolvedOptions: {
|
|
@@ -6867,7 +6982,8 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6867
6982
|
dataDescriptor,
|
|
6868
6983
|
zip64,
|
|
6869
6984
|
rawExtraField,
|
|
6870
|
-
rawLocalExtraField
|
|
6985
|
+
rawLocalExtraField,
|
|
6986
|
+
rawCentralExtraField
|
|
6871
6987
|
}
|
|
6872
6988
|
};
|
|
6873
6989
|
}
|
|
@@ -7009,7 +7125,6 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
7009
7125
|
let { name } = entry;
|
|
7010
7126
|
const { size } = entry;
|
|
7011
7127
|
const options = Object.assign({}, entry.options);
|
|
7012
|
-
name = name.trim();
|
|
7013
7128
|
if (getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY) && !name.endsWith(DIRECTORY_SIGNATURE)) {
|
|
7014
7129
|
name += DIRECTORY_SIGNATURE;
|
|
7015
7130
|
}
|
|
@@ -7265,6 +7380,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7265
7380
|
versionMadeBy,
|
|
7266
7381
|
rawComment,
|
|
7267
7382
|
rawExtraField,
|
|
7383
|
+
rawCentralExtraField,
|
|
7268
7384
|
useWebWorkers,
|
|
7269
7385
|
transferStreams,
|
|
7270
7386
|
onstart,
|
|
@@ -7308,6 +7424,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7308
7424
|
rawExtraFieldUnix,
|
|
7309
7425
|
rawExtraFieldAES,
|
|
7310
7426
|
rawExtraField,
|
|
7427
|
+
rawCentralExtraField,
|
|
7311
7428
|
extendedTimestamp,
|
|
7312
7429
|
msDosCompatible,
|
|
7313
7430
|
internalFileAttributes,
|
|
@@ -7339,6 +7456,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7339
7456
|
const workerOptions = {
|
|
7340
7457
|
options: {
|
|
7341
7458
|
codecType: CODEC_DEFLATE,
|
|
7459
|
+
inputSize: size,
|
|
7342
7460
|
level,
|
|
7343
7461
|
rawPassword,
|
|
7344
7462
|
password,
|
|
@@ -7808,6 +7926,7 @@ function createDirectoryRecords(files) {
|
|
|
7808
7926
|
rawExtraFieldNTFS,
|
|
7809
7927
|
rawExtraFieldUnix,
|
|
7810
7928
|
rawExtraField,
|
|
7929
|
+
rawCentralExtraField,
|
|
7811
7930
|
extendedTimestamp,
|
|
7812
7931
|
extraFieldExtendedTimestampFlag,
|
|
7813
7932
|
lastModDate,
|
|
@@ -7862,7 +7981,8 @@ function createDirectoryRecords(files) {
|
|
|
7862
7981
|
rawExtraFieldNTFS,
|
|
7863
7982
|
rawExtraFieldUnix,
|
|
7864
7983
|
rawExtraFieldTimestamp,
|
|
7865
|
-
rawExtraField
|
|
7984
|
+
rawExtraField,
|
|
7985
|
+
rawCentralExtraField);
|
|
7866
7986
|
if (extraFieldLength > MAX_16_BITS) {
|
|
7867
7987
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7868
7988
|
}
|
|
@@ -7890,6 +8010,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
7890
8010
|
rawExtraFieldNTFS,
|
|
7891
8011
|
rawExtraFieldUnix,
|
|
7892
8012
|
rawExtraField,
|
|
8013
|
+
rawCentralExtraField,
|
|
7893
8014
|
rawComment,
|
|
7894
8015
|
versionMadeBy,
|
|
7895
8016
|
headerArray,
|
|
@@ -7904,7 +8025,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
7904
8025
|
uncompressedSize,
|
|
7905
8026
|
compressedSize
|
|
7906
8027
|
} = fileEntry;
|
|
7907
|
-
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
|
|
8028
|
+
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawCentralExtraField);
|
|
7908
8029
|
const directoryRecordLength = CENTRAL_FILE_HEADER_LENGTH + getLength(rawFilename, rawComment) + extraFieldLength;
|
|
7909
8030
|
if (exceedsAvailableSize(writer, offset + directoryRecordLength - directoryDiskOffset)) {
|
|
7910
8031
|
await writeData(writer, directoryArray.slice(directoryDiskOffset, offset));
|
|
@@ -7942,6 +8063,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
7942
8063
|
directoryRecord.writeBytes(rawExtraFieldNTFS);
|
|
7943
8064
|
directoryRecord.writeBytes(rawExtraFieldUnix);
|
|
7944
8065
|
directoryRecord.writeBytes(rawExtraField);
|
|
8066
|
+
directoryRecord.writeBytes(rawCentralExtraField);
|
|
7945
8067
|
directoryRecord.writeBytes(rawComment);
|
|
7946
8068
|
arraySet(directoryArray, directoryRecord.array, offset);
|
|
7947
8069
|
offset += directoryRecordLength;
|
|
@@ -8445,6 +8567,111 @@ function getMimeType() {
|
|
|
8445
8567
|
*/
|
|
8446
8568
|
|
|
8447
8569
|
|
|
8570
|
+
function getSupportedCompressionMethods() {
|
|
8571
|
+
const { CompressionStream, DecompressionStream, CompressionStreamFallback, DecompressionStreamFallback } = getConfiguration();
|
|
8572
|
+
const supportedMethods = [{
|
|
8573
|
+
compressionMethod: COMPRESSION_METHOD_STORE,
|
|
8574
|
+
compression: true,
|
|
8575
|
+
decompression: true,
|
|
8576
|
+
registered: false
|
|
8577
|
+
}, {
|
|
8578
|
+
compressionMethod: COMPRESSION_METHOD_DEFLATE,
|
|
8579
|
+
compression: formatSupported(CompressionStreamFallback, FORMAT_DEFLATE_RAW$1) ||
|
|
8580
|
+
formatSupported(CompressionStream, FORMAT_DEFLATE_RAW$1) || formatSupported(CompressionStream, FORMAT_GZIP$1),
|
|
8581
|
+
decompression: formatSupported(DecompressionStreamFallback, FORMAT_DEFLATE_RAW$1) ||
|
|
8582
|
+
formatSupported(DecompressionStream, FORMAT_DEFLATE_RAW$1) || formatSupported(DecompressionStream, FORMAT_GZIP$1),
|
|
8583
|
+
registered: false
|
|
8584
|
+
}, {
|
|
8585
|
+
compressionMethod: COMPRESSION_METHOD_DEFLATE_64,
|
|
8586
|
+
compression: false,
|
|
8587
|
+
decompression: formatSupported(DecompressionStreamFallback, FORMAT_DEFLATE64_RAW$1) ||
|
|
8588
|
+
formatSupported(DecompressionStream, FORMAT_DEFLATE64_RAW$1),
|
|
8589
|
+
registered: false
|
|
8590
|
+
}];
|
|
8591
|
+
for (const codec of getRegisteredCodecs()) {
|
|
8592
|
+
const codecStreams = getCodecStreams(codec.format);
|
|
8593
|
+
supportedMethods.push({
|
|
8594
|
+
compressionMethod: codec.compressionMethod,
|
|
8595
|
+
// deno-lint-ignore valid-typeof
|
|
8596
|
+
compression: codecStreams ? typeof codecStreams.CompressionStream == FUNCTION_TYPE : UNDEFINED_VALUE,
|
|
8597
|
+
// deno-lint-ignore valid-typeof
|
|
8598
|
+
decompression: codecStreams ? typeof codecStreams.DecompressionStream == FUNCTION_TYPE : UNDEFINED_VALUE,
|
|
8599
|
+
registered: true
|
|
8600
|
+
});
|
|
8601
|
+
}
|
|
8602
|
+
return supportedMethods;
|
|
8603
|
+
}
|
|
8604
|
+
|
|
8605
|
+
function formatSupported(StreamClass, format) {
|
|
8606
|
+
if (!StreamClass) {
|
|
8607
|
+
return false;
|
|
8608
|
+
}
|
|
8609
|
+
const { supportedFormats } = StreamClass;
|
|
8610
|
+
if (supportedFormats) {
|
|
8611
|
+
return supportedFormats.includes(format);
|
|
8612
|
+
}
|
|
8613
|
+
return supportsFormat(StreamClass, format);
|
|
8614
|
+
}
|
|
8615
|
+
|
|
8616
|
+
/*
|
|
8617
|
+
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
8618
|
+
|
|
8619
|
+
Redistribution and use in source and binary forms, with or without
|
|
8620
|
+
modification, are permitted provided that the following conditions are met:
|
|
8621
|
+
|
|
8622
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
8623
|
+
this list of conditions and the following disclaimer.
|
|
8624
|
+
|
|
8625
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
8626
|
+
notice, this list of conditions and the following disclaimer in
|
|
8627
|
+
the documentation and/or other materials provided with the distribution.
|
|
8628
|
+
|
|
8629
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
8630
|
+
derived from this software without specific prior written permission.
|
|
8631
|
+
|
|
8632
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
8633
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
8634
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
8635
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
8636
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
8637
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
8638
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
8639
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
8640
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
8641
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8642
|
+
*/
|
|
8643
|
+
|
|
8644
|
+
const VERSION = "2.8.60";
|
|
8645
|
+
|
|
8646
|
+
/*
|
|
8647
|
+
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
8648
|
+
|
|
8649
|
+
Redistribution and use in source and binary forms, with or without
|
|
8650
|
+
modification, are permitted provided that the following conditions are met:
|
|
8651
|
+
|
|
8652
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
8653
|
+
this list of conditions and the following disclaimer.
|
|
8654
|
+
|
|
8655
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
8656
|
+
notice, this list of conditions and the following disclaimer in
|
|
8657
|
+
the documentation and/or other materials provided with the distribution.
|
|
8658
|
+
|
|
8659
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
8660
|
+
derived from this software without specific prior written permission.
|
|
8661
|
+
|
|
8662
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
8663
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
8664
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
8665
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
8666
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
8667
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
8668
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
8669
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
8670
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
8671
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8672
|
+
*/
|
|
8673
|
+
|
|
8674
|
+
|
|
8448
8675
|
const DEFAULT_THRESHOLD$2 = 1024 * 1024;
|
|
8449
8676
|
const DEFAULT_DIRECTORY_NAME$1 = ".zip.js-temp";
|
|
8450
8677
|
|
|
@@ -8893,6 +9120,11 @@ try {
|
|
|
8893
9120
|
|
|
8894
9121
|
/* global TransformStream */
|
|
8895
9122
|
|
|
9123
|
+
const FORMAT_DEFLATE = "deflate";
|
|
9124
|
+
const FORMAT_DEFLATE_RAW = "deflate-raw";
|
|
9125
|
+
const FORMAT_DEFLATE64_RAW = "deflate64-raw";
|
|
9126
|
+
const FORMAT_GZIP = "gzip";
|
|
9127
|
+
|
|
8896
9128
|
let wasm, malloc, free, memory, initError;
|
|
8897
9129
|
|
|
8898
9130
|
function setWasmExports(wasmAPI) {
|
|
@@ -8938,15 +9170,15 @@ function _make(isCompress, type, options = {}) {
|
|
|
8938
9170
|
this._last_consumed = wasm.deflate_last_consumed;
|
|
8939
9171
|
this._end = wasm.deflate_end;
|
|
8940
9172
|
this.streamHandle = wasm.deflate_new();
|
|
8941
|
-
if (type ===
|
|
9173
|
+
if (type === FORMAT_GZIP) {
|
|
8942
9174
|
result = wasm.deflate_init_gzip(this.streamHandle, level);
|
|
8943
|
-
} else if (type ===
|
|
9175
|
+
} else if (type === FORMAT_DEFLATE_RAW) {
|
|
8944
9176
|
result = wasm.deflate_init_raw(this.streamHandle, level);
|
|
8945
9177
|
} else {
|
|
8946
9178
|
result = wasm.deflate_init(this.streamHandle, level);
|
|
8947
9179
|
}
|
|
8948
9180
|
} else {
|
|
8949
|
-
if (type ===
|
|
9181
|
+
if (type === FORMAT_DEFLATE64_RAW) {
|
|
8950
9182
|
this._process = wasm.inflate9_process;
|
|
8951
9183
|
this._last_consumed = wasm.inflate9_last_consumed;
|
|
8952
9184
|
this._end = wasm.inflate9_end;
|
|
@@ -8957,9 +9189,9 @@ function _make(isCompress, type, options = {}) {
|
|
|
8957
9189
|
this._last_consumed = wasm.inflate_last_consumed;
|
|
8958
9190
|
this._end = wasm.inflate_end;
|
|
8959
9191
|
this.streamHandle = wasm.inflate_new();
|
|
8960
|
-
if (type ===
|
|
9192
|
+
if (type === FORMAT_DEFLATE_RAW) {
|
|
8961
9193
|
result = wasm.inflate_init_raw(this.streamHandle);
|
|
8962
|
-
} else if (type ===
|
|
9194
|
+
} else if (type === FORMAT_GZIP) {
|
|
8963
9195
|
result = wasm.inflate_init_gzip(this.streamHandle);
|
|
8964
9196
|
} else {
|
|
8965
9197
|
result = wasm.inflate_init(this.streamHandle);
|
|
@@ -9080,12 +9312,12 @@ function _make(isCompress, type, options = {}) {
|
|
|
9080
9312
|
}
|
|
9081
9313
|
|
|
9082
9314
|
class CompressionStreamZlib {
|
|
9083
|
-
constructor(type =
|
|
9315
|
+
constructor(type = FORMAT_DEFLATE, options) {
|
|
9084
9316
|
return _make(true, type, options);
|
|
9085
9317
|
}
|
|
9086
9318
|
}
|
|
9087
9319
|
class DecompressionStreamZlib {
|
|
9088
|
-
constructor(type =
|
|
9320
|
+
constructor(type = FORMAT_DEFLATE, options) {
|
|
9089
9321
|
return _make(false, type, options);
|
|
9090
9322
|
}
|
|
9091
9323
|
}
|
|
@@ -9094,6 +9326,11 @@ class DecompressionStreamZlib {
|
|
|
9094
9326
|
// module fails to load, rather than discarding a self-contained codec supplied through config.
|
|
9095
9327
|
CompressionStreamZlib.requiresModule = true;
|
|
9096
9328
|
DecompressionStreamZlib.requiresModule = true;
|
|
9329
|
+
// Constructing these classes before the module is loaded throws, so capability probes cannot rely
|
|
9330
|
+
// on trying the constructor; the formats are declared instead, next to the branches implementing
|
|
9331
|
+
// them in _make().
|
|
9332
|
+
CompressionStreamZlib.supportedFormats = [FORMAT_DEFLATE, FORMAT_DEFLATE_RAW, FORMAT_GZIP];
|
|
9333
|
+
DecompressionStreamZlib.supportedFormats = [FORMAT_DEFLATE, FORMAT_DEFLATE_RAW, FORMAT_GZIP, FORMAT_DEFLATE64_RAW];
|
|
9097
9334
|
|
|
9098
9335
|
/*
|
|
9099
9336
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -10555,4 +10792,4 @@ function addChild(parent, name, params, directory) {
|
|
|
10555
10792
|
}
|
|
10556
10793
|
}
|
|
10557
10794
|
|
|
10558
|
-
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, 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_ENTRY_EXISTS, 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_PASS_THROUGH, ERR_INVALID_READER_OPTIONS, 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_READABLE_CONSUMED, 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_CRYPTO_LAST_MOD_DATE, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipDirectoryEntry, ZipEntry, ZipFS, ZipFileEntry, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|
|
10795
|
+
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, 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_ENTRY_EXISTS, 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_PASS_THROUGH, ERR_INVALID_READER_OPTIONS, 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_READABLE_CONSUMED, 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_CRYPTO_LAST_MOD_DATE, 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, ZipDirectoryEntry, ZipEntry, ZipFS, ZipFileEntry, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, getRegisteredCodecs, getSupportedCompressionMethods, isZipFile, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|