@zip.js/zip.js 2.18.2 → 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BENCHMARKS.md +172 -144
- package/deno.json +1 -1
- package/dist/zip-core-external.js +192 -120
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +193 -119
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +192 -120
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +193 -119
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +192 -120
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +195 -121
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +194 -120
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +195 -121
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +195 -121
- 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 +194 -120
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +195 -121
- package/index-native.min.js +1 -1
- package/index.cjs +194 -120
- package/index.d.cts +95 -26
- package/index.d.ts +95 -26
- package/index.min.js +1 -1
- package/lib/core/codec-pool.js +1 -2
- package/lib/core/codec-worker-web.js +11 -39
- package/lib/core/codec-worker.js +1 -2
- package/lib/core/configuration.js +1 -1
- package/lib/core/options.js +0 -2
- package/lib/core/streams/codec-stream.js +1 -1
- package/lib/core/version.js +1 -1
- package/lib/core/web-worker-base.js +2 -3
- 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 +100 -40
- package/lib/core/zip-writer.js +75 -34
- package/lib/zip-core-reader.js +2 -0
- package/package.json +1 -1
- package/worker-message-property-names.js +1 -1
|
@@ -176,7 +176,6 @@ const OPTION_CHECK_CRC32 = "checkCrc32";
|
|
|
176
176
|
const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
|
|
177
177
|
const OPTION_USE_WEB_WORKERS = "useWebWorkers";
|
|
178
178
|
const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
|
|
179
|
-
const OPTION_TRANSFER_STREAMS = "transferStreams";
|
|
180
179
|
const OPTION_PREVENT_CLOSE = "preventClose";
|
|
181
180
|
const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
|
|
182
181
|
const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
|
|
@@ -294,7 +293,7 @@ function toNumber(value) {
|
|
|
294
293
|
*/
|
|
295
294
|
|
|
296
295
|
|
|
297
|
-
const DEFAULT_CHUNK_SIZE$1 =
|
|
296
|
+
const DEFAULT_CHUNK_SIZE$1 = 256 * 1024;
|
|
298
297
|
const MINIMUM_CHUNK_SIZE = 64;
|
|
299
298
|
const MINIMUM_PROPERTY_VALUE = 1;
|
|
300
299
|
const ERR_INVALID_MAX_WORKERS = "Invalid maxWorkers (must be an integer greater than 0)";
|
|
@@ -2423,7 +2422,7 @@ function mapInflateStreamError(readable, sourceErrors) {
|
|
|
2423
2422
|
*/
|
|
2424
2423
|
|
|
2425
2424
|
|
|
2426
|
-
const DEFAULT_CHUNK_SIZE =
|
|
2425
|
+
const DEFAULT_CHUNK_SIZE = 256 * 1024;
|
|
2427
2426
|
const MESSAGE_EVENT_TYPE = "message";
|
|
2428
2427
|
const MESSAGE_START = "start";
|
|
2429
2428
|
const MESSAGE_PULL = "pull";
|
|
@@ -2633,7 +2632,7 @@ function disableWebWorker(workerData) {
|
|
|
2633
2632
|
class CodecWorker {
|
|
2634
2633
|
|
|
2635
2634
|
constructor(workerData, { readable, writable }, workerOptions, onTaskFinished) {
|
|
2636
|
-
const { options, config, streamOptions, useWebWorkers,
|
|
2635
|
+
const { options, config, streamOptions, useWebWorkers, workerURI } = workerOptions;
|
|
2637
2636
|
let { createWorker } = workerOptions;
|
|
2638
2637
|
const { signal } = streamOptions;
|
|
2639
2638
|
if (createWorkerFailed) {
|
|
@@ -2650,7 +2649,6 @@ class CodecWorker {
|
|
|
2650
2649
|
workerOptions,
|
|
2651
2650
|
workerURI,
|
|
2652
2651
|
createWorker,
|
|
2653
|
-
transferStreams,
|
|
2654
2652
|
terminate() {
|
|
2655
2653
|
return new Promise(resolve => {
|
|
2656
2654
|
const { worker, busy } = workerData;
|
|
@@ -2828,12 +2826,6 @@ const MESSAGE_ERROR_EVENT_TYPE = "messageerror";
|
|
|
2828
2826
|
const ABORT_EVENT_TYPE = "abort";
|
|
2829
2827
|
|
|
2830
2828
|
let webWorkerSource, webWorkerURI, webWorkerOptions;
|
|
2831
|
-
let transferStreamsSupported = true;
|
|
2832
|
-
try {
|
|
2833
|
-
transferStreamsSupported = typeof structuredClone == FUNCTION_TYPE && structuredClone(new DOMException("", "AbortError")).code !== UNDEFINED_VALUE;
|
|
2834
|
-
} catch {
|
|
2835
|
-
// ignored
|
|
2836
|
-
}
|
|
2837
2829
|
|
|
2838
2830
|
setWebWorkerBackend(createWebWorkerInterface);
|
|
2839
2831
|
|
|
@@ -2920,14 +2912,11 @@ async function runWebWorker(workerData, config) {
|
|
|
2920
2912
|
});
|
|
2921
2913
|
const { readable, options } = workerData;
|
|
2922
2914
|
const { writable, closed, abortPipe } = watchClosedStream(workerData.writable, workerData);
|
|
2923
|
-
let streamsTransferred;
|
|
2924
2915
|
try {
|
|
2925
|
-
|
|
2916
|
+
sendMessage({
|
|
2926
2917
|
type: MESSAGE_START,
|
|
2927
2918
|
options,
|
|
2928
|
-
config
|
|
2929
|
-
readable,
|
|
2930
|
-
writable
|
|
2919
|
+
config
|
|
2931
2920
|
}, workerData);
|
|
2932
2921
|
} catch (error) {
|
|
2933
2922
|
abortPipe();
|
|
@@ -2939,12 +2928,10 @@ async function runWebWorker(workerData, config) {
|
|
|
2939
2928
|
workerData.onTaskFinished();
|
|
2940
2929
|
throw error;
|
|
2941
2930
|
}
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
});
|
|
2947
|
-
}
|
|
2931
|
+
Object.assign(workerData, {
|
|
2932
|
+
reader: readable.getReader(),
|
|
2933
|
+
writer: writable.getWriter()
|
|
2934
|
+
});
|
|
2948
2935
|
const { workerStartupTimeout } = config;
|
|
2949
2936
|
if (!workerData.workerAlive && Number.isFinite(workerStartupTimeout) && workerStartupTimeout >= 0) {
|
|
2950
2937
|
workerData.startupTimeout = setTimeout(() => onStartupTimeout(workerData), workerStartupTimeout);
|
|
@@ -2977,7 +2964,7 @@ async function runWebWorker(workerData, config) {
|
|
|
2977
2964
|
}
|
|
2978
2965
|
|
|
2979
2966
|
async function closeWritable() {
|
|
2980
|
-
if (!
|
|
2967
|
+
if (!writable.locked) {
|
|
2981
2968
|
try {
|
|
2982
2969
|
await writable.getWriter().close();
|
|
2983
2970
|
} catch {
|
|
@@ -3168,31 +3155,14 @@ function onWorkerError(event, workerData) {
|
|
|
3168
3155
|
}
|
|
3169
3156
|
}
|
|
3170
3157
|
|
|
3171
|
-
function sendMessage(message, { worker, writer
|
|
3158
|
+
function sendMessage(message, { worker, writer }) {
|
|
3172
3159
|
try {
|
|
3173
|
-
const { value
|
|
3174
|
-
const transferables = [];
|
|
3160
|
+
const { value } = message;
|
|
3175
3161
|
if (value) {
|
|
3176
3162
|
message.value = toExactUint8Array(value);
|
|
3177
|
-
transferables.push(message.value.buffer);
|
|
3178
|
-
}
|
|
3179
|
-
if (transferStreams && transferStreamsSupported && workerAlive) {
|
|
3180
|
-
if (readable) {
|
|
3181
|
-
transferables.push(readable);
|
|
3182
|
-
}
|
|
3183
|
-
if (writable) {
|
|
3184
|
-
transferables.push(writable);
|
|
3185
|
-
}
|
|
3186
|
-
} else {
|
|
3187
|
-
message.readable = message.writable = null;
|
|
3188
|
-
}
|
|
3189
|
-
if (transferables.length) {
|
|
3190
3163
|
try {
|
|
3191
|
-
worker.postMessage(message,
|
|
3192
|
-
return true;
|
|
3164
|
+
worker.postMessage(message, [message.value.buffer]);
|
|
3193
3165
|
} catch {
|
|
3194
|
-
transferStreamsSupported = false;
|
|
3195
|
-
message.readable = message.writable = null;
|
|
3196
3166
|
worker.postMessage(message);
|
|
3197
3167
|
}
|
|
3198
3168
|
} else {
|
|
@@ -3341,7 +3311,7 @@ let indexWorker = 0;
|
|
|
3341
3311
|
|
|
3342
3312
|
async function runWorker(stream, workerOptions) {
|
|
3343
3313
|
const { options, config } = workerOptions;
|
|
3344
|
-
const {
|
|
3314
|
+
const { useWebWorkers, useCompressionStream, compressed, checkCrc32, computeCrc32, encrypted, format, codecURI } = options;
|
|
3345
3315
|
const { workerURI, createWorker, maxWorkers } = config;
|
|
3346
3316
|
if (format) {
|
|
3347
3317
|
if (codecURI) {
|
|
@@ -3349,7 +3319,6 @@ async function runWorker(stream, workerOptions) {
|
|
|
3349
3319
|
}
|
|
3350
3320
|
await ensureCodecStreams(format, options.codecURI);
|
|
3351
3321
|
}
|
|
3352
|
-
workerOptions.transferStreams = !format && (transferStreams || (transferStreams === UNDEFINED_VALUE && config.transferStreams));
|
|
3353
3322
|
const streamCopy = !compressed && !checkCrc32 && !computeCrc32 && !encrypted;
|
|
3354
3323
|
const workerSupported = format === UNDEFINED_VALUE || Boolean(options.codecURI);
|
|
3355
3324
|
workerOptions.useWebWorkers = !streamCopy && workerSupported && (useWebWorkers || (useWebWorkers === UNDEFINED_VALUE && config.useWebWorkers));
|
|
@@ -4845,6 +4814,8 @@ const WARNING_APPENDED_DATA = "appended data";
|
|
|
4845
4814
|
const WARNING_PREPENDED_DATA = "prepended data";
|
|
4846
4815
|
const WARNING_PREPENDED_CENTRAL_DIRECTORY = "prepended central directory";
|
|
4847
4816
|
const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA = "trailing central directory data";
|
|
4817
|
+
const WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET = "mismatched central directory offset";
|
|
4818
|
+
const WARNING_MISSING_ZIP64_EXTRA_FIELD = "missing zip64 extra field";
|
|
4848
4819
|
const WARNING_DUPLICATE_FILENAME = "duplicate filename";
|
|
4849
4820
|
const WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY = "mismatched zip64 end of central directory record";
|
|
4850
4821
|
const WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY = "multiple end of central directory records";
|
|
@@ -5007,6 +4978,8 @@ class ZipReader {
|
|
|
5007
4978
|
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY);
|
|
5008
4979
|
}
|
|
5009
4980
|
directoryDataOffset = getDiskOffset$1(reader, diskNumber) + getBigUint64(endOfDirectoryView, 48) + prependedDataLength;
|
|
4981
|
+
} else if (directoryDataOffset == MAX_32_BITS || directoryDataLength == MAX_32_BITS || diskNumber == MAX_16_BITS) {
|
|
4982
|
+
throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
|
|
5010
4983
|
}
|
|
5011
4984
|
}
|
|
5012
4985
|
let declaredDirectoryDataLength = directoryDataLength;
|
|
@@ -5029,25 +5002,44 @@ class ZipReader {
|
|
|
5029
5002
|
if (directoryArray.length < 4) {
|
|
5030
5003
|
throw new Error(ERR_BAD_FORMAT);
|
|
5031
5004
|
}
|
|
5032
|
-
|
|
5005
|
+
let expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
|
|
5033
5006
|
if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
|
|
5034
5007
|
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE ||
|
|
5035
5008
|
Boolean(directoryEncryptionInfo && directoryEncryptionInfo.compressedSize) ||
|
|
5036
5009
|
detectEncryptedCentralDirectory(directoryView);
|
|
5037
5010
|
let reconcile = !storedPointsAtDirectory;
|
|
5038
|
-
if (
|
|
5039
|
-
const
|
|
5040
|
-
|
|
5011
|
+
if (expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
|
|
5012
|
+
const expectedPointsAtDirectory = await pointsAtDirectory(reader, expectedDirectoryDataOffset);
|
|
5013
|
+
if (storedPointsAtDirectory) {
|
|
5014
|
+
reconcile = expectedPointsAtDirectory;
|
|
5015
|
+
} else if (!expectedPointsAtDirectory) {
|
|
5016
|
+
const signatureRecordOffset = await findDigitalSignatureRecordOffset(reader, centralDirectoryEndOffset);
|
|
5017
|
+
const signedDirectoryDataOffset = signatureRecordOffset - directoryDataLength;
|
|
5018
|
+
if (signatureRecordOffset !== UNDEFINED_VALUE && signedDirectoryDataOffset >= 0 &&
|
|
5019
|
+
await pointsAtDirectory(reader, signedDirectoryDataOffset)) {
|
|
5020
|
+
expectedDirectoryDataOffset = signedDirectoryDataOffset;
|
|
5021
|
+
}
|
|
5022
|
+
}
|
|
5041
5023
|
}
|
|
5042
5024
|
if (reconcile) {
|
|
5043
5025
|
const originalDirectoryDataOffset = directoryDataOffset;
|
|
5044
5026
|
directoryDataOffset = expectedDirectoryDataOffset;
|
|
5027
|
+
directoryArray = await readUint8Array(reader, directoryDataOffset, directoryDataLength);
|
|
5028
|
+
directoryView = getDataView(directoryArray);
|
|
5045
5029
|
if (directoryDataOffset > originalDirectoryDataOffset) {
|
|
5046
5030
|
prependedDataLength += directoryDataOffset - originalDirectoryDataOffset;
|
|
5047
5031
|
prependedCentralDirectory = storedPointsAtDirectory;
|
|
5032
|
+
} else {
|
|
5033
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET);
|
|
5034
|
+
const offsetDelta = directoryDataOffset - originalDirectoryDataOffset;
|
|
5035
|
+
if (directoryArray.length >= CENTRAL_FILE_HEADER_LENGTH) {
|
|
5036
|
+
const localHeaderOffset = getUint32$1(directoryView, 42);
|
|
5037
|
+
if (!await startsWithSignature(reader, localHeaderOffset, LOCAL_FILE_HEADER_SIGNATURE) &&
|
|
5038
|
+
await startsWithSignature(reader, localHeaderOffset + offsetDelta, LOCAL_FILE_HEADER_SIGNATURE)) {
|
|
5039
|
+
prependedDataLength += offsetDelta;
|
|
5040
|
+
}
|
|
5041
|
+
}
|
|
5048
5042
|
}
|
|
5049
|
-
directoryArray = await readUint8Array(reader, directoryDataOffset, directoryDataLength);
|
|
5050
|
-
directoryView = getDataView(directoryArray);
|
|
5051
5043
|
}
|
|
5052
5044
|
}
|
|
5053
5045
|
}
|
|
@@ -5131,17 +5123,6 @@ class ZipReader {
|
|
|
5131
5123
|
if (filename === UNDEFINED_VALUE) {
|
|
5132
5124
|
filename = decodeText(rawFilename, rawFilenameEncoding);
|
|
5133
5125
|
}
|
|
5134
|
-
if (normalizeFilename) {
|
|
5135
|
-
const normalizedFilename = normalizeFilename(filename);
|
|
5136
|
-
if (normalizedFilename !== UNDEFINED_VALUE) {
|
|
5137
|
-
filename = normalizedFilename;
|
|
5138
|
-
}
|
|
5139
|
-
}
|
|
5140
|
-
if (isUnsafeFilename(filename, filenameValidation)) {
|
|
5141
|
-
const error = new Error(ERR_UNSAFE_FILENAME);
|
|
5142
|
-
error.filename = filename;
|
|
5143
|
-
throw error;
|
|
5144
|
-
}
|
|
5145
5126
|
let comment = decode(rawComment, rawCommentEncoding, TEXT_TYPE_COMMENT);
|
|
5146
5127
|
if (comment === UNDEFINED_VALUE) {
|
|
5147
5128
|
comment = decodeText(rawComment, rawCommentEncoding);
|
|
@@ -5169,7 +5150,29 @@ class ZipReader {
|
|
|
5169
5150
|
filename,
|
|
5170
5151
|
comment
|
|
5171
5152
|
});
|
|
5172
|
-
|
|
5153
|
+
let malformedExtraField;
|
|
5154
|
+
try {
|
|
5155
|
+
malformedExtraField = readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6);
|
|
5156
|
+
} catch (error) {
|
|
5157
|
+
if (checkAmbiguity || error.message != ERR_EXTRAFIELD_ZIP64_NOT_FOUND) {
|
|
5158
|
+
throw error;
|
|
5159
|
+
}
|
|
5160
|
+
fileEntry.zip64ExtraFieldMissing = true;
|
|
5161
|
+
addWarning(warnings, WARNING_MISSING_ZIP64_EXTRA_FIELD, fileEntry.filename);
|
|
5162
|
+
}
|
|
5163
|
+
filename = fileEntry.filename;
|
|
5164
|
+
if (normalizeFilename) {
|
|
5165
|
+
const normalizedFilename = normalizeFilename(filename);
|
|
5166
|
+
if (normalizedFilename !== UNDEFINED_VALUE) {
|
|
5167
|
+
filename = fileEntry.filename = normalizedFilename;
|
|
5168
|
+
}
|
|
5169
|
+
}
|
|
5170
|
+
if (isUnsafeFilename(filename, filenameValidation)) {
|
|
5171
|
+
const error = new Error(ERR_UNSAFE_FILENAME);
|
|
5172
|
+
error.filename = filename;
|
|
5173
|
+
throw error;
|
|
5174
|
+
}
|
|
5175
|
+
if (malformedExtraField) {
|
|
5173
5176
|
addWarning(warnings, WARNING_MALFORMED_EXTRA_FIELD, filename);
|
|
5174
5177
|
}
|
|
5175
5178
|
fileEntry.offset += prependedDataLength;
|
|
@@ -5198,11 +5201,12 @@ class ZipReader {
|
|
|
5198
5201
|
const sticky = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_STICKY_MASK);
|
|
5199
5202
|
const unixType = fileEntry.unixMode === UNDEFINED_VALUE ? unixExternalUpper : fileEntry.unixMode;
|
|
5200
5203
|
const symlink = (unixType & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK;
|
|
5201
|
-
const executable = !symlink && ((fileEntry.unixMode !== UNDEFINED_VALUE)
|
|
5202
|
-
? ((fileEntry.unixMode & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)
|
|
5203
|
-
: (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)));
|
|
5204
5204
|
const modeIsDir = fileEntry.unixMode !== UNDEFINED_VALUE && ((fileEntry.unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
|
|
5205
5205
|
const upperIsDir = ((unixExternalUpper & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
|
|
5206
|
+
const directory = modeIsDir || upperIsDir || (msDosCompatible && msdosAttributes.directory) || fileEntry.filename.endsWith(DIRECTORY_SIGNATURE);
|
|
5207
|
+
const executable = !symlink && !directory && ((fileEntry.unixMode !== UNDEFINED_VALUE)
|
|
5208
|
+
? ((fileEntry.unixMode & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)
|
|
5209
|
+
: (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)));
|
|
5206
5210
|
Object.assign(fileEntry, {
|
|
5207
5211
|
setuid,
|
|
5208
5212
|
setgid,
|
|
@@ -5210,7 +5214,7 @@ class ZipReader {
|
|
|
5210
5214
|
symlink,
|
|
5211
5215
|
unixExternalUpper,
|
|
5212
5216
|
executable,
|
|
5213
|
-
directory
|
|
5217
|
+
directory,
|
|
5214
5218
|
zipCrypto: fileEntry.encrypted && !fileEntry.extraFieldAES
|
|
5215
5219
|
});
|
|
5216
5220
|
const entry = new Entry(fileEntry);
|
|
@@ -5266,10 +5270,10 @@ class ZipReader {
|
|
|
5266
5270
|
const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
|
|
5267
5271
|
const splitZipSignatureLength = (checkAmbiguity || extractPrependedData) && filesLength &&
|
|
5268
5272
|
startOffset == SPLIT_ZIP_FILE_SIGNATURE_LENGTH && await startsWithSplitZipMarker(reader) ? SPLIT_ZIP_FILE_SIGNATURE_LENGTH : 0;
|
|
5269
|
-
if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > splitZipSignatureLength))) {
|
|
5273
|
+
if (checkAmbiguity && (prependedDataLength > 0 || (filesLength && startOffset > splitZipSignatureLength))) {
|
|
5270
5274
|
throwAmbiguousArchive(WARNING_PREPENDED_DATA);
|
|
5271
5275
|
}
|
|
5272
|
-
if (prependedDataLength || (filesLength && startOffset > SPLIT_ZIP_FILE_SIGNATURE_LENGTH)) {
|
|
5276
|
+
if (prependedDataLength > 0 || (filesLength && startOffset > SPLIT_ZIP_FILE_SIGNATURE_LENGTH)) {
|
|
5273
5277
|
addWarning(warnings, WARNING_PREPENDED_DATA);
|
|
5274
5278
|
}
|
|
5275
5279
|
if (prependedCentralDirectory) {
|
|
@@ -5429,6 +5433,9 @@ class ZipEntry {
|
|
|
5429
5433
|
|
|
5430
5434
|
async getData(writer, fileEntry, readRanges, options = {}) {
|
|
5431
5435
|
const zipEntry = this;
|
|
5436
|
+
if (zipEntry.zip64ExtraFieldMissing) {
|
|
5437
|
+
throw new Error(ERR_EXTRAFIELD_ZIP64_NOT_FOUND);
|
|
5438
|
+
}
|
|
5432
5439
|
const config = getConfiguration();
|
|
5433
5440
|
const {
|
|
5434
5441
|
reader,
|
|
@@ -5573,7 +5580,6 @@ class ZipEntry {
|
|
|
5573
5580
|
encrypted,
|
|
5574
5581
|
useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
|
|
5575
5582
|
useCompressionStream,
|
|
5576
|
-
transferStreams: getOptionValue$1(zipEntry, options, OPTION_TRANSFER_STREAMS),
|
|
5577
5583
|
deflate64,
|
|
5578
5584
|
format: registeredCodec ? registeredCodec.format : UNDEFINED_VALUE,
|
|
5579
5585
|
codecURI: registeredCodec ? registeredCodec.codecURI : UNDEFINED_VALUE,
|
|
@@ -5667,6 +5673,30 @@ function getWrappedFilesLength(directoryView, directoryArray, offset) {
|
|
|
5667
5673
|
return wrappedFilesLength % (MAX_16_BITS + 1) ? 0 : wrappedFilesLength;
|
|
5668
5674
|
}
|
|
5669
5675
|
|
|
5676
|
+
function pointsAtDirectory(reader, offset) {
|
|
5677
|
+
return startsWithSignature(reader, offset, CENTRAL_FILE_HEADER_SIGNATURE);
|
|
5678
|
+
}
|
|
5679
|
+
|
|
5680
|
+
async function startsWithSignature(reader, offset, signature) {
|
|
5681
|
+
if (offset < 0 || offset + 4 > reader.size) {
|
|
5682
|
+
return false;
|
|
5683
|
+
}
|
|
5684
|
+
const signatureArray = await readUint8Array(reader, offset, 4);
|
|
5685
|
+
return getUint32$1(getDataView(signatureArray), 0) == signature;
|
|
5686
|
+
}
|
|
5687
|
+
|
|
5688
|
+
async function findDigitalSignatureRecordOffset(reader, endOffset) {
|
|
5689
|
+
const startOffset = Math.max(0, endOffset - (6 + MAX_16_BITS));
|
|
5690
|
+
const tailArray = await readUint8Array(reader, startOffset, endOffset - startOffset);
|
|
5691
|
+
const tailView = getDataView(tailArray);
|
|
5692
|
+
for (let indexByte = tailArray.length - 6; indexByte >= 0; indexByte--) {
|
|
5693
|
+
if (getUint32$1(tailView, indexByte) == DIGITAL_SIGNATURE_RECORD_SIGNATURE &&
|
|
5694
|
+
indexByte + 6 + getUint16$1(tailView, indexByte + 4) == tailArray.length) {
|
|
5695
|
+
return startOffset + indexByte;
|
|
5696
|
+
}
|
|
5697
|
+
}
|
|
5698
|
+
}
|
|
5699
|
+
|
|
5670
5700
|
function readDigitalSignature(signatureRecordArray) {
|
|
5671
5701
|
if (signatureRecordArray.length >= 6) {
|
|
5672
5702
|
const signatureRecordView = getDataView(signatureRecordArray);
|
|
@@ -5798,29 +5828,27 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5798
5828
|
readExtraFieldUnixDates(extraFieldUnixType1, directory);
|
|
5799
5829
|
directory.extraFieldUnixType1 = extraFieldUnixType1;
|
|
5800
5830
|
}
|
|
5831
|
+
const extraFieldExtendedTimestamp = extraField.get(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
5832
|
+
if (extraFieldExtendedTimestamp) {
|
|
5833
|
+
readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory, localDirectory);
|
|
5834
|
+
directory.extraFieldExtendedTimestamp = extraFieldExtendedTimestamp;
|
|
5835
|
+
}
|
|
5801
5836
|
const extraFieldNTFS = extraField.get(EXTRAFIELD_TYPE_NTFS);
|
|
5802
5837
|
if (extraFieldNTFS) {
|
|
5803
5838
|
readExtraFieldNTFS(extraFieldNTFS, directory);
|
|
5804
5839
|
directory.extraFieldNTFS = extraFieldNTFS;
|
|
5805
5840
|
}
|
|
5806
|
-
const
|
|
5841
|
+
const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
|
|
5807
5842
|
let unixIdsRead;
|
|
5843
|
+
if (extraFieldInfoZip) {
|
|
5844
|
+
unixIdsRead = readExtraFieldUnix(extraFieldInfoZip, directory, true);
|
|
5845
|
+
directory.extraFieldInfoZip = extraFieldInfoZip;
|
|
5846
|
+
}
|
|
5847
|
+
const extraFieldUnix = extraField.get(EXTRAFIELD_TYPE_UNIX);
|
|
5808
5848
|
if (extraFieldUnix) {
|
|
5809
|
-
|
|
5849
|
+
readExtraFieldUnix(extraFieldUnix, unixIdsRead ? {} : directory, false);
|
|
5810
5850
|
directory.extraFieldUnix = extraFieldUnix;
|
|
5811
5851
|
}
|
|
5812
|
-
if (!unixIdsRead) {
|
|
5813
|
-
const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
|
|
5814
|
-
if (extraFieldInfoZip) {
|
|
5815
|
-
readExtraFieldUnix(extraFieldInfoZip, directory, true);
|
|
5816
|
-
directory.extraFieldInfoZip = extraFieldInfoZip;
|
|
5817
|
-
}
|
|
5818
|
-
}
|
|
5819
|
-
const extraFieldExtendedTimestamp = extraField.get(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
5820
|
-
if (extraFieldExtendedTimestamp) {
|
|
5821
|
-
readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory, localDirectory);
|
|
5822
|
-
directory.extraFieldExtendedTimestamp = extraFieldExtendedTimestamp;
|
|
5823
|
-
}
|
|
5824
5852
|
const extraFieldUSDZ = extraField.get(EXTRAFIELD_TYPE_USDZ);
|
|
5825
5853
|
if (extraFieldUSDZ) {
|
|
5826
5854
|
directory.extraFieldUSDZ = extraFieldUSDZ;
|
|
@@ -6459,11 +6487,13 @@ var zipReader = /*#__PURE__*/Object.freeze({
|
|
|
6459
6487
|
WARNING_COMPRESSED_PATCHED_DATA: WARNING_COMPRESSED_PATCHED_DATA,
|
|
6460
6488
|
WARNING_DUPLICATE_FILENAME: WARNING_DUPLICATE_FILENAME,
|
|
6461
6489
|
WARNING_MALFORMED_EXTRA_FIELD: WARNING_MALFORMED_EXTRA_FIELD,
|
|
6490
|
+
WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET: WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET,
|
|
6462
6491
|
WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG: WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG,
|
|
6463
6492
|
WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD: WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD,
|
|
6464
6493
|
WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES: WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES,
|
|
6465
6494
|
WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME: WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME,
|
|
6466
6495
|
WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY: WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY,
|
|
6496
|
+
WARNING_MISSING_ZIP64_EXTRA_FIELD: WARNING_MISSING_ZIP64_EXTRA_FIELD,
|
|
6467
6497
|
WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY: WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY,
|
|
6468
6498
|
WARNING_PREPENDED_CENTRAL_DIRECTORY: WARNING_PREPENDED_CENTRAL_DIRECTORY,
|
|
6469
6499
|
WARNING_PREPENDED_DATA: WARNING_PREPENDED_DATA,
|
|
@@ -6596,13 +6626,14 @@ class ZipWriter {
|
|
|
6596
6626
|
return watchPromiseError(this, prependZipEntries(this, reader));
|
|
6597
6627
|
}
|
|
6598
6628
|
|
|
6599
|
-
appendZip(reader) {
|
|
6600
|
-
return watchPromiseError(this, this.appendZipEntries(reader));
|
|
6629
|
+
appendZip(reader, options = {}) {
|
|
6630
|
+
return watchPromiseError(this, this.appendZipEntries(reader, options));
|
|
6601
6631
|
}
|
|
6602
6632
|
|
|
6603
|
-
async appendZipEntries(reader) {
|
|
6633
|
+
async appendZipEntries(reader, options = {}) {
|
|
6604
6634
|
const zipWriter = this;
|
|
6605
6635
|
const { pendingAddFileCalls, filenames, fileEntries } = zipWriter;
|
|
6636
|
+
const filter = checkFunctionOption(options.filter);
|
|
6606
6637
|
while (pendingAddFileCalls.size) {
|
|
6607
6638
|
await Promise.allSettled(Array.from(pendingAddFileCalls));
|
|
6608
6639
|
}
|
|
@@ -6621,10 +6652,16 @@ class ZipWriter {
|
|
|
6621
6652
|
const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
|
|
6622
6653
|
const zipReader$1 = new ZipReader(reader);
|
|
6623
6654
|
const entries = await zipReader$1.getEntries();
|
|
6655
|
+
const keptEntries = [];
|
|
6656
|
+
for (const entry of entries) {
|
|
6657
|
+
if (!filter || await filter(entry)) {
|
|
6658
|
+
keptEntries.push(entry);
|
|
6659
|
+
}
|
|
6660
|
+
}
|
|
6624
6661
|
await zipReader$1.close();
|
|
6625
6662
|
await initStream(zipWriter.writer);
|
|
6626
6663
|
const { directoryOffset } = zipReader$1;
|
|
6627
|
-
|
|
6664
|
+
keptEntries.forEach(({ filename }) => {
|
|
6628
6665
|
if (filenames.has(filename)) {
|
|
6629
6666
|
throw new Error(ERR_DUPLICATED_NAME);
|
|
6630
6667
|
}
|
|
@@ -6645,8 +6682,8 @@ class ZipWriter {
|
|
|
6645
6682
|
zipWriter.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6646
6683
|
}
|
|
6647
6684
|
}
|
|
6648
|
-
const entryPositions = await copyZipData(zipWriter, reader, entries, directoryOffset);
|
|
6649
|
-
|
|
6685
|
+
const entryPositions = await copyZipData(zipWriter, reader, entries, keptEntries, directoryOffset, Boolean(filter));
|
|
6686
|
+
keptEntries.forEach(entry => {
|
|
6650
6687
|
const {
|
|
6651
6688
|
version,
|
|
6652
6689
|
rawLastModDate,
|
|
@@ -6702,6 +6739,7 @@ class ZipWriter {
|
|
|
6702
6739
|
rawExtraFieldExtendedTimestamp: EMPTY_UINT8_ARRAY,
|
|
6703
6740
|
rawExtraFieldNTFS: EMPTY_UINT8_ARRAY,
|
|
6704
6741
|
rawExtraFieldUnix: EMPTY_UINT8_ARRAY,
|
|
6742
|
+
rawCentralExtraFieldUnix: EMPTY_UINT8_ARRAY,
|
|
6705
6743
|
rawExtraField,
|
|
6706
6744
|
rawCentralExtraField: EMPTY_UINT8_ARRAY,
|
|
6707
6745
|
headerArray,
|
|
@@ -7270,7 +7308,6 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
7270
7308
|
const ntfsTimestamp = getOptionValue(zipWriter, options, OPTION_NTFS_TIMESTAMP);
|
|
7271
7309
|
const keepOrder = getOptionValue(zipWriter, options, OPTION_KEEP_ORDER, true);
|
|
7272
7310
|
const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
|
|
7273
|
-
const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS);
|
|
7274
7311
|
const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
|
|
7275
7312
|
const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
|
|
7276
7313
|
const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
|
|
@@ -7336,7 +7373,6 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
7336
7373
|
ntfsTimestamp,
|
|
7337
7374
|
keepOrder,
|
|
7338
7375
|
useWebWorkers,
|
|
7339
|
-
transferStreams,
|
|
7340
7376
|
bufferedWrite,
|
|
7341
7377
|
createTempStream,
|
|
7342
7378
|
dataDescriptorSignature,
|
|
@@ -7395,7 +7431,7 @@ async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, op
|
|
|
7395
7431
|
if (reader) {
|
|
7396
7432
|
reader = new GenericReader(reader);
|
|
7397
7433
|
await initStream(reader);
|
|
7398
|
-
if (!reader.
|
|
7434
|
+
if (!reader.readUint8Array && !reader.readable) {
|
|
7399
7435
|
throw new Error(ERR_INVALID_READER);
|
|
7400
7436
|
}
|
|
7401
7437
|
({ size: contentSize } = reader);
|
|
@@ -7658,6 +7694,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7658
7694
|
extraFieldExtendedTimestampTime,
|
|
7659
7695
|
rawExtraFieldNTFS,
|
|
7660
7696
|
rawExtraFieldUnix,
|
|
7697
|
+
rawCentralExtraFieldUnix,
|
|
7661
7698
|
rawExtraFieldAES,
|
|
7662
7699
|
} = headerInfo;
|
|
7663
7700
|
const { dataDescriptorArray } = dataDescriptorInfo;
|
|
@@ -7682,7 +7719,6 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7682
7719
|
rawExtraField,
|
|
7683
7720
|
rawCentralExtraField,
|
|
7684
7721
|
useWebWorkers,
|
|
7685
|
-
transferStreams,
|
|
7686
7722
|
onstart,
|
|
7687
7723
|
onprogress,
|
|
7688
7724
|
onend,
|
|
@@ -7724,6 +7760,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7724
7760
|
rawExtraFieldExtendedTimestamp,
|
|
7725
7761
|
rawExtraFieldNTFS,
|
|
7726
7762
|
rawExtraFieldUnix,
|
|
7763
|
+
rawCentralExtraFieldUnix,
|
|
7727
7764
|
rawExtraFieldAES,
|
|
7728
7765
|
rawExtraField,
|
|
7729
7766
|
rawCentralExtraField,
|
|
@@ -7770,7 +7807,6 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7770
7807
|
encrypted: encrypted && !passThroughEncryption,
|
|
7771
7808
|
useWebWorkers,
|
|
7772
7809
|
useCompressionStream,
|
|
7773
|
-
transferStreams,
|
|
7774
7810
|
format,
|
|
7775
7811
|
codecURI,
|
|
7776
7812
|
compressionMethod
|
|
@@ -7948,6 +7984,7 @@ function getHeaderInfo(options) {
|
|
|
7948
7984
|
rawExtraFieldNTFS = rawExtraFieldExtendedTimestamp = EMPTY_UINT8_ARRAY;
|
|
7949
7985
|
}
|
|
7950
7986
|
let rawExtraFieldUnix;
|
|
7987
|
+
let rawCentralExtraFieldUnix;
|
|
7951
7988
|
try {
|
|
7952
7989
|
const { uid, gid, unixExtraFieldType } = options;
|
|
7953
7990
|
if (unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
@@ -7962,7 +7999,7 @@ function getHeaderInfo(options) {
|
|
|
7962
7999
|
extraFieldUnix.writeBytes(uidBytes);
|
|
7963
8000
|
extraFieldUnix.writeUint8(gidBytes.length);
|
|
7964
8001
|
extraFieldUnix.writeBytes(gidBytes);
|
|
7965
|
-
rawExtraFieldUnix = extraFieldUnix.array;
|
|
8002
|
+
rawExtraFieldUnix = rawCentralExtraFieldUnix = extraFieldUnix.array;
|
|
7966
8003
|
} else if (unixExtraFieldType == UNIX_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
7967
8004
|
const extraFieldUnix = createRecordWriter(8);
|
|
7968
8005
|
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_UNIX);
|
|
@@ -7970,11 +8007,15 @@ function getHeaderInfo(options) {
|
|
|
7970
8007
|
extraFieldUnix.writeUint16((uid === UNDEFINED_VALUE ? 0 : uid) & MAX_16_BITS);
|
|
7971
8008
|
extraFieldUnix.writeUint16((gid === UNDEFINED_VALUE ? 0 : gid) & MAX_16_BITS);
|
|
7972
8009
|
rawExtraFieldUnix = extraFieldUnix.array;
|
|
8010
|
+
const centralExtraFieldUnix = createRecordWriter(4);
|
|
8011
|
+
centralExtraFieldUnix.writeUint16(EXTRAFIELD_TYPE_UNIX);
|
|
8012
|
+
centralExtraFieldUnix.writeUint16(0);
|
|
8013
|
+
rawCentralExtraFieldUnix = centralExtraFieldUnix.array;
|
|
7973
8014
|
} else {
|
|
7974
|
-
rawExtraFieldUnix = EMPTY_UINT8_ARRAY;
|
|
8015
|
+
rawExtraFieldUnix = rawCentralExtraFieldUnix = EMPTY_UINT8_ARRAY;
|
|
7975
8016
|
}
|
|
7976
8017
|
} catch {
|
|
7977
|
-
rawExtraFieldUnix = EMPTY_UINT8_ARRAY;
|
|
8018
|
+
rawExtraFieldUnix = rawCentralExtraFieldUnix = EMPTY_UINT8_ARRAY;
|
|
7978
8019
|
}
|
|
7979
8020
|
if (compressionMethod === UNDEFINED_VALUE) {
|
|
7980
8021
|
compressionMethod = compressed ? COMPRESSION_METHOD_DEFLATE : COMPRESSION_METHOD_STORE;
|
|
@@ -8066,6 +8107,7 @@ function getHeaderInfo(options) {
|
|
|
8066
8107
|
rawExtraFieldExtendedTimestamp,
|
|
8067
8108
|
rawExtraFieldNTFS,
|
|
8068
8109
|
rawExtraFieldUnix,
|
|
8110
|
+
rawCentralExtraFieldUnix,
|
|
8069
8111
|
rawExtraFieldAES,
|
|
8070
8112
|
extraFieldLength
|
|
8071
8113
|
};
|
|
@@ -8241,7 +8283,7 @@ function createDirectoryRecords(files) {
|
|
|
8241
8283
|
rawExtraFieldAES,
|
|
8242
8284
|
rawComment,
|
|
8243
8285
|
rawExtraFieldNTFS,
|
|
8244
|
-
|
|
8286
|
+
rawCentralExtraFieldUnix,
|
|
8245
8287
|
rawExtraField,
|
|
8246
8288
|
rawCentralExtraField,
|
|
8247
8289
|
extraFieldExtendedTimestampFlag,
|
|
@@ -8303,7 +8345,7 @@ function createDirectoryRecords(files) {
|
|
|
8303
8345
|
rawExtraFieldZip64,
|
|
8304
8346
|
rawExtraFieldAES,
|
|
8305
8347
|
rawExtraFieldNTFS,
|
|
8306
|
-
|
|
8348
|
+
rawCentralExtraFieldUnix,
|
|
8307
8349
|
rawExtraFieldTimestamp,
|
|
8308
8350
|
rawExtraField,
|
|
8309
8351
|
rawCentralExtraField);
|
|
@@ -8332,7 +8374,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
8332
8374
|
rawExtraFieldAES,
|
|
8333
8375
|
rawExtraFieldExtendedTimestamp,
|
|
8334
8376
|
rawExtraFieldNTFS,
|
|
8335
|
-
|
|
8377
|
+
rawCentralExtraFieldUnix,
|
|
8336
8378
|
rawExtraField,
|
|
8337
8379
|
rawCentralExtraField,
|
|
8338
8380
|
rawComment,
|
|
@@ -8349,7 +8391,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
8349
8391
|
uncompressedSize,
|
|
8350
8392
|
compressedSize
|
|
8351
8393
|
} = fileEntry;
|
|
8352
|
-
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS,
|
|
8394
|
+
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawCentralExtraFieldUnix, rawExtraField, rawCentralExtraField);
|
|
8353
8395
|
const directoryRecordLength = CENTRAL_FILE_HEADER_LENGTH + getLength(rawFilename, rawComment) + extraFieldLength;
|
|
8354
8396
|
if (exceedsAvailableSize(writer, offset + directoryRecordLength - directoryDiskOffset)) {
|
|
8355
8397
|
await writeData(writer, directoryArray.slice(directoryDiskOffset, offset));
|
|
@@ -8385,7 +8427,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
8385
8427
|
directoryRecord.writeBytes(rawExtraFieldAES);
|
|
8386
8428
|
directoryRecord.writeBytes(rawExtraFieldExtendedTimestamp);
|
|
8387
8429
|
directoryRecord.writeBytes(rawExtraFieldNTFS);
|
|
8388
|
-
directoryRecord.writeBytes(
|
|
8430
|
+
directoryRecord.writeBytes(rawCentralExtraFieldUnix);
|
|
8389
8431
|
directoryRecord.writeBytes(rawExtraField);
|
|
8390
8432
|
directoryRecord.writeBytes(rawCentralExtraField);
|
|
8391
8433
|
directoryRecord.writeBytes(rawComment);
|
|
@@ -8554,26 +8596,42 @@ function removeExtraFieldZip64(rawExtraField) {
|
|
|
8554
8596
|
return rawExtraField;
|
|
8555
8597
|
}
|
|
8556
8598
|
|
|
8557
|
-
async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
8599
|
+
async function copyZipData(zipWriter, reader, entries, keptEntries, directoryOffset, compact) {
|
|
8558
8600
|
const { writer } = zipWriter;
|
|
8559
8601
|
const entryPositions = new Map();
|
|
8560
|
-
if (writer.closeDisk) {
|
|
8602
|
+
if (writer.closeDisk || compact) {
|
|
8561
8603
|
const sortedEntries = Array.from(entries).sort((firstEntry, secondEntry) =>
|
|
8562
8604
|
getSourceOffset(reader, firstEntry) - getSourceOffset(reader, secondEntry));
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
|
|
8574
|
-
|
|
8605
|
+
const regionEnds = getRegionEnds(reader, sortedEntries, directoryOffset);
|
|
8606
|
+
const keptEntrySet = new Set(keptEntries);
|
|
8607
|
+
let copiedOffset = 0;
|
|
8608
|
+
let lastPosition;
|
|
8609
|
+
for (let indexEntry = 0; indexEntry < sortedEntries.length; indexEntry++) {
|
|
8610
|
+
const entry = sortedEntries[indexEntry];
|
|
8611
|
+
if (keptEntrySet.has(entry)) {
|
|
8612
|
+
const sourceOffset = getSourceOffset(reader, entry);
|
|
8613
|
+
if (sourceOffset < copiedOffset) {
|
|
8614
|
+
entryPositions.set(entry, lastPosition);
|
|
8615
|
+
} else {
|
|
8616
|
+
if (!compact) {
|
|
8617
|
+
await copyData(zipWriter, reader, copiedOffset, sourceOffset - copiedOffset);
|
|
8618
|
+
}
|
|
8619
|
+
if (writer.closeDisk && exceedsAvailableSize(writer, await getLocalHeaderLength(reader, sourceOffset))) {
|
|
8620
|
+
await writer.closeDisk();
|
|
8621
|
+
}
|
|
8622
|
+
lastPosition = {
|
|
8623
|
+
offset: getSegmentOffset(zipWriter, writer),
|
|
8624
|
+
diskNumberStart: getDiskNumber(writer)
|
|
8625
|
+
};
|
|
8626
|
+
entryPositions.set(entry, lastPosition);
|
|
8627
|
+
await copyData(zipWriter, reader, sourceOffset, regionEnds[indexEntry] - sourceOffset);
|
|
8628
|
+
copiedOffset = regionEnds[indexEntry];
|
|
8629
|
+
}
|
|
8630
|
+
}
|
|
8631
|
+
}
|
|
8632
|
+
if (!compact) {
|
|
8633
|
+
await copyData(zipWriter, reader, copiedOffset, directoryOffset - copiedOffset);
|
|
8575
8634
|
}
|
|
8576
|
-
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
8577
8635
|
} else {
|
|
8578
8636
|
const baseOffset = zipWriter.offset;
|
|
8579
8637
|
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
@@ -8585,6 +8643,20 @@ async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
|
8585
8643
|
return entryPositions;
|
|
8586
8644
|
}
|
|
8587
8645
|
|
|
8646
|
+
function getRegionEnds(reader, sortedEntries, directoryOffset) {
|
|
8647
|
+
const regionEnds = new Array(sortedEntries.length);
|
|
8648
|
+
let regionEnd = directoryOffset;
|
|
8649
|
+
for (let indexEntry = sortedEntries.length - 1; indexEntry >= 0; indexEntry--) {
|
|
8650
|
+
const sourceOffset = getSourceOffset(reader, sortedEntries[indexEntry]);
|
|
8651
|
+
const nextEntry = sortedEntries[indexEntry + 1];
|
|
8652
|
+
if (nextEntry && getSourceOffset(reader, nextEntry) > sourceOffset) {
|
|
8653
|
+
regionEnd = getSourceOffset(reader, nextEntry);
|
|
8654
|
+
}
|
|
8655
|
+
regionEnds[indexEntry] = regionEnd;
|
|
8656
|
+
}
|
|
8657
|
+
return regionEnds;
|
|
8658
|
+
}
|
|
8659
|
+
|
|
8588
8660
|
async function copyData(zipWriter, reader, offset, size) {
|
|
8589
8661
|
if (size > 0) {
|
|
8590
8662
|
const { writer } = zipWriter;
|
|
@@ -8962,7 +9034,7 @@ function formatSupported(StreamClass, format) {
|
|
|
8962
9034
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8963
9035
|
*/
|
|
8964
9036
|
|
|
8965
|
-
const VERSION = "2.
|
|
9037
|
+
const VERSION = "2.20.0";
|
|
8966
9038
|
|
|
8967
9039
|
/*
|
|
8968
9040
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9967,4 +10039,4 @@ async function terminateWorkersAndModule() {
|
|
|
9967
10039
|
|
|
9968
10040
|
configureExternalAssets();
|
|
9969
10041
|
|
|
9970
|
-
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_CODEC_OUT_OF_MEMORY, 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_HTTP_STATUS, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_BASE_URI, 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, 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_VALUE, ERR_INVALID_READER, ERR_INVALID_SIGNAL, 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_URI, 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_CRC32, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, 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_SPLIT_USDZ, ERR_UNSUPPORTED_UINT64, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_WRITER_SIZE_NOT_WRITABLE, ERR_ZIP_CRYPTO_LAST_MOD_DATE, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, VERSION, WARNING_APPENDED_DATA, WARNING_CLAMPED_LAST_MODIFICATION_DATE, WARNING_COMPRESSED_PATCHED_DATA, WARNING_COMPRESSION_UNAVAILABLE, 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_LOCAL_FILE_HEADER_FILENAME, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY, WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY, WARNING_PREPENDED_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 };
|
|
10042
|
+
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_CODEC_OUT_OF_MEMORY, 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_HTTP_STATUS, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_BASE_URI, 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, 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_VALUE, ERR_INVALID_READER, ERR_INVALID_SIGNAL, 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_URI, 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_CRC32, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, 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_SPLIT_USDZ, ERR_UNSUPPORTED_UINT64, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_WRITER_SIZE_NOT_WRITABLE, ERR_ZIP_CRYPTO_LAST_MOD_DATE, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, VERSION, WARNING_APPENDED_DATA, WARNING_CLAMPED_LAST_MODIFICATION_DATE, WARNING_COMPRESSED_PATCHED_DATA, WARNING_COMPRESSION_UNAVAILABLE, WARNING_DUPLICATE_FILENAME, WARNING_MALFORMED_EXTRA_FIELD, WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET, WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG, WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD, WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES, WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY, WARNING_MISSING_ZIP64_EXTRA_FIELD, WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY, WARNING_PREPENDED_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 };
|