@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));
|
|
@@ -4865,6 +4834,8 @@ const WARNING_APPENDED_DATA = "appended data";
|
|
|
4865
4834
|
const WARNING_PREPENDED_DATA = "prepended data";
|
|
4866
4835
|
const WARNING_PREPENDED_CENTRAL_DIRECTORY = "prepended central directory";
|
|
4867
4836
|
const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA = "trailing central directory data";
|
|
4837
|
+
const WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET = "mismatched central directory offset";
|
|
4838
|
+
const WARNING_MISSING_ZIP64_EXTRA_FIELD = "missing zip64 extra field";
|
|
4868
4839
|
const WARNING_DUPLICATE_FILENAME = "duplicate filename";
|
|
4869
4840
|
const WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY = "mismatched zip64 end of central directory record";
|
|
4870
4841
|
const WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY = "multiple end of central directory records";
|
|
@@ -5027,6 +4998,8 @@ class ZipReader {
|
|
|
5027
4998
|
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY);
|
|
5028
4999
|
}
|
|
5029
5000
|
directoryDataOffset = getDiskOffset$1(reader, diskNumber) + getBigUint64(endOfDirectoryView, 48) + prependedDataLength;
|
|
5001
|
+
} else if (directoryDataOffset == MAX_32_BITS || directoryDataLength == MAX_32_BITS || diskNumber == MAX_16_BITS) {
|
|
5002
|
+
throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
|
|
5030
5003
|
}
|
|
5031
5004
|
}
|
|
5032
5005
|
let declaredDirectoryDataLength = directoryDataLength;
|
|
@@ -5049,25 +5022,44 @@ class ZipReader {
|
|
|
5049
5022
|
if (directoryArray.length < 4) {
|
|
5050
5023
|
throw new Error(ERR_BAD_FORMAT);
|
|
5051
5024
|
}
|
|
5052
|
-
|
|
5025
|
+
let expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
|
|
5053
5026
|
if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
|
|
5054
5027
|
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE ||
|
|
5055
5028
|
Boolean(directoryEncryptionInfo && directoryEncryptionInfo.compressedSize) ||
|
|
5056
5029
|
detectEncryptedCentralDirectory(directoryView);
|
|
5057
5030
|
let reconcile = !storedPointsAtDirectory;
|
|
5058
|
-
if (
|
|
5059
|
-
const
|
|
5060
|
-
|
|
5031
|
+
if (expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
|
|
5032
|
+
const expectedPointsAtDirectory = await pointsAtDirectory(reader, expectedDirectoryDataOffset);
|
|
5033
|
+
if (storedPointsAtDirectory) {
|
|
5034
|
+
reconcile = expectedPointsAtDirectory;
|
|
5035
|
+
} else if (!expectedPointsAtDirectory) {
|
|
5036
|
+
const signatureRecordOffset = await findDigitalSignatureRecordOffset(reader, centralDirectoryEndOffset);
|
|
5037
|
+
const signedDirectoryDataOffset = signatureRecordOffset - directoryDataLength;
|
|
5038
|
+
if (signatureRecordOffset !== UNDEFINED_VALUE && signedDirectoryDataOffset >= 0 &&
|
|
5039
|
+
await pointsAtDirectory(reader, signedDirectoryDataOffset)) {
|
|
5040
|
+
expectedDirectoryDataOffset = signedDirectoryDataOffset;
|
|
5041
|
+
}
|
|
5042
|
+
}
|
|
5061
5043
|
}
|
|
5062
5044
|
if (reconcile) {
|
|
5063
5045
|
const originalDirectoryDataOffset = directoryDataOffset;
|
|
5064
5046
|
directoryDataOffset = expectedDirectoryDataOffset;
|
|
5047
|
+
directoryArray = await readUint8Array(reader, directoryDataOffset, directoryDataLength);
|
|
5048
|
+
directoryView = getDataView(directoryArray);
|
|
5065
5049
|
if (directoryDataOffset > originalDirectoryDataOffset) {
|
|
5066
5050
|
prependedDataLength += directoryDataOffset - originalDirectoryDataOffset;
|
|
5067
5051
|
prependedCentralDirectory = storedPointsAtDirectory;
|
|
5052
|
+
} else {
|
|
5053
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET);
|
|
5054
|
+
const offsetDelta = directoryDataOffset - originalDirectoryDataOffset;
|
|
5055
|
+
if (directoryArray.length >= CENTRAL_FILE_HEADER_LENGTH) {
|
|
5056
|
+
const localHeaderOffset = getUint32$1(directoryView, 42);
|
|
5057
|
+
if (!await startsWithSignature(reader, localHeaderOffset, LOCAL_FILE_HEADER_SIGNATURE) &&
|
|
5058
|
+
await startsWithSignature(reader, localHeaderOffset + offsetDelta, LOCAL_FILE_HEADER_SIGNATURE)) {
|
|
5059
|
+
prependedDataLength += offsetDelta;
|
|
5060
|
+
}
|
|
5061
|
+
}
|
|
5068
5062
|
}
|
|
5069
|
-
directoryArray = await readUint8Array(reader, directoryDataOffset, directoryDataLength);
|
|
5070
|
-
directoryView = getDataView(directoryArray);
|
|
5071
5063
|
}
|
|
5072
5064
|
}
|
|
5073
5065
|
}
|
|
@@ -5151,17 +5143,6 @@ class ZipReader {
|
|
|
5151
5143
|
if (filename === UNDEFINED_VALUE) {
|
|
5152
5144
|
filename = decodeText(rawFilename, rawFilenameEncoding);
|
|
5153
5145
|
}
|
|
5154
|
-
if (normalizeFilename) {
|
|
5155
|
-
const normalizedFilename = normalizeFilename(filename);
|
|
5156
|
-
if (normalizedFilename !== UNDEFINED_VALUE) {
|
|
5157
|
-
filename = normalizedFilename;
|
|
5158
|
-
}
|
|
5159
|
-
}
|
|
5160
|
-
if (isUnsafeFilename(filename, filenameValidation)) {
|
|
5161
|
-
const error = new Error(ERR_UNSAFE_FILENAME);
|
|
5162
|
-
error.filename = filename;
|
|
5163
|
-
throw error;
|
|
5164
|
-
}
|
|
5165
5146
|
let comment = decode(rawComment, rawCommentEncoding, TEXT_TYPE_COMMENT);
|
|
5166
5147
|
if (comment === UNDEFINED_VALUE) {
|
|
5167
5148
|
comment = decodeText(rawComment, rawCommentEncoding);
|
|
@@ -5189,7 +5170,29 @@ class ZipReader {
|
|
|
5189
5170
|
filename,
|
|
5190
5171
|
comment
|
|
5191
5172
|
});
|
|
5192
|
-
|
|
5173
|
+
let malformedExtraField;
|
|
5174
|
+
try {
|
|
5175
|
+
malformedExtraField = readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6);
|
|
5176
|
+
} catch (error) {
|
|
5177
|
+
if (checkAmbiguity || error.message != ERR_EXTRAFIELD_ZIP64_NOT_FOUND) {
|
|
5178
|
+
throw error;
|
|
5179
|
+
}
|
|
5180
|
+
fileEntry.zip64ExtraFieldMissing = true;
|
|
5181
|
+
addWarning(warnings, WARNING_MISSING_ZIP64_EXTRA_FIELD, fileEntry.filename);
|
|
5182
|
+
}
|
|
5183
|
+
filename = fileEntry.filename;
|
|
5184
|
+
if (normalizeFilename) {
|
|
5185
|
+
const normalizedFilename = normalizeFilename(filename);
|
|
5186
|
+
if (normalizedFilename !== UNDEFINED_VALUE) {
|
|
5187
|
+
filename = fileEntry.filename = normalizedFilename;
|
|
5188
|
+
}
|
|
5189
|
+
}
|
|
5190
|
+
if (isUnsafeFilename(filename, filenameValidation)) {
|
|
5191
|
+
const error = new Error(ERR_UNSAFE_FILENAME);
|
|
5192
|
+
error.filename = filename;
|
|
5193
|
+
throw error;
|
|
5194
|
+
}
|
|
5195
|
+
if (malformedExtraField) {
|
|
5193
5196
|
addWarning(warnings, WARNING_MALFORMED_EXTRA_FIELD, filename);
|
|
5194
5197
|
}
|
|
5195
5198
|
fileEntry.offset += prependedDataLength;
|
|
@@ -5218,11 +5221,12 @@ class ZipReader {
|
|
|
5218
5221
|
const sticky = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_STICKY_MASK);
|
|
5219
5222
|
const unixType = fileEntry.unixMode === UNDEFINED_VALUE ? unixExternalUpper : fileEntry.unixMode;
|
|
5220
5223
|
const symlink = (unixType & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK;
|
|
5221
|
-
const executable = !symlink && ((fileEntry.unixMode !== UNDEFINED_VALUE)
|
|
5222
|
-
? ((fileEntry.unixMode & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)
|
|
5223
|
-
: (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)));
|
|
5224
5224
|
const modeIsDir = fileEntry.unixMode !== UNDEFINED_VALUE && ((fileEntry.unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
|
|
5225
5225
|
const upperIsDir = ((unixExternalUpper & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
|
|
5226
|
+
const directory = modeIsDir || upperIsDir || (msDosCompatible && msdosAttributes.directory) || fileEntry.filename.endsWith(DIRECTORY_SIGNATURE);
|
|
5227
|
+
const executable = !symlink && !directory && ((fileEntry.unixMode !== UNDEFINED_VALUE)
|
|
5228
|
+
? ((fileEntry.unixMode & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)
|
|
5229
|
+
: (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)));
|
|
5226
5230
|
Object.assign(fileEntry, {
|
|
5227
5231
|
setuid,
|
|
5228
5232
|
setgid,
|
|
@@ -5230,7 +5234,7 @@ class ZipReader {
|
|
|
5230
5234
|
symlink,
|
|
5231
5235
|
unixExternalUpper,
|
|
5232
5236
|
executable,
|
|
5233
|
-
directory
|
|
5237
|
+
directory,
|
|
5234
5238
|
zipCrypto: fileEntry.encrypted && !fileEntry.extraFieldAES
|
|
5235
5239
|
});
|
|
5236
5240
|
const entry = new Entry(fileEntry);
|
|
@@ -5286,10 +5290,10 @@ class ZipReader {
|
|
|
5286
5290
|
const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
|
|
5287
5291
|
const splitZipSignatureLength = (checkAmbiguity || extractPrependedData) && filesLength &&
|
|
5288
5292
|
startOffset == SPLIT_ZIP_FILE_SIGNATURE_LENGTH && await startsWithSplitZipMarker(reader) ? SPLIT_ZIP_FILE_SIGNATURE_LENGTH : 0;
|
|
5289
|
-
if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > splitZipSignatureLength))) {
|
|
5293
|
+
if (checkAmbiguity && (prependedDataLength > 0 || (filesLength && startOffset > splitZipSignatureLength))) {
|
|
5290
5294
|
throwAmbiguousArchive(WARNING_PREPENDED_DATA);
|
|
5291
5295
|
}
|
|
5292
|
-
if (prependedDataLength || (filesLength && startOffset > SPLIT_ZIP_FILE_SIGNATURE_LENGTH)) {
|
|
5296
|
+
if (prependedDataLength > 0 || (filesLength && startOffset > SPLIT_ZIP_FILE_SIGNATURE_LENGTH)) {
|
|
5293
5297
|
addWarning(warnings, WARNING_PREPENDED_DATA);
|
|
5294
5298
|
}
|
|
5295
5299
|
if (prependedCentralDirectory) {
|
|
@@ -5449,6 +5453,9 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5449
5453
|
|
|
5450
5454
|
async getData(writer, fileEntry, readRanges, options = {}) {
|
|
5451
5455
|
const zipEntry = this;
|
|
5456
|
+
if (zipEntry.zip64ExtraFieldMissing) {
|
|
5457
|
+
throw new Error(ERR_EXTRAFIELD_ZIP64_NOT_FOUND);
|
|
5458
|
+
}
|
|
5452
5459
|
const config = getConfiguration();
|
|
5453
5460
|
const {
|
|
5454
5461
|
reader,
|
|
@@ -5593,7 +5600,6 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5593
5600
|
encrypted,
|
|
5594
5601
|
useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
|
|
5595
5602
|
useCompressionStream,
|
|
5596
|
-
transferStreams: getOptionValue$1(zipEntry, options, OPTION_TRANSFER_STREAMS),
|
|
5597
5603
|
deflate64,
|
|
5598
5604
|
format: registeredCodec ? registeredCodec.format : UNDEFINED_VALUE,
|
|
5599
5605
|
codecURI: registeredCodec ? registeredCodec.codecURI : UNDEFINED_VALUE,
|
|
@@ -5687,6 +5693,30 @@ function getWrappedFilesLength(directoryView, directoryArray, offset) {
|
|
|
5687
5693
|
return wrappedFilesLength % (MAX_16_BITS + 1) ? 0 : wrappedFilesLength;
|
|
5688
5694
|
}
|
|
5689
5695
|
|
|
5696
|
+
function pointsAtDirectory(reader, offset) {
|
|
5697
|
+
return startsWithSignature(reader, offset, CENTRAL_FILE_HEADER_SIGNATURE);
|
|
5698
|
+
}
|
|
5699
|
+
|
|
5700
|
+
async function startsWithSignature(reader, offset, signature) {
|
|
5701
|
+
if (offset < 0 || offset + 4 > reader.size) {
|
|
5702
|
+
return false;
|
|
5703
|
+
}
|
|
5704
|
+
const signatureArray = await readUint8Array(reader, offset, 4);
|
|
5705
|
+
return getUint32$1(getDataView(signatureArray), 0) == signature;
|
|
5706
|
+
}
|
|
5707
|
+
|
|
5708
|
+
async function findDigitalSignatureRecordOffset(reader, endOffset) {
|
|
5709
|
+
const startOffset = Math.max(0, endOffset - (6 + MAX_16_BITS));
|
|
5710
|
+
const tailArray = await readUint8Array(reader, startOffset, endOffset - startOffset);
|
|
5711
|
+
const tailView = getDataView(tailArray);
|
|
5712
|
+
for (let indexByte = tailArray.length - 6; indexByte >= 0; indexByte--) {
|
|
5713
|
+
if (getUint32$1(tailView, indexByte) == DIGITAL_SIGNATURE_RECORD_SIGNATURE &&
|
|
5714
|
+
indexByte + 6 + getUint16$1(tailView, indexByte + 4) == tailArray.length) {
|
|
5715
|
+
return startOffset + indexByte;
|
|
5716
|
+
}
|
|
5717
|
+
}
|
|
5718
|
+
}
|
|
5719
|
+
|
|
5690
5720
|
function readDigitalSignature(signatureRecordArray) {
|
|
5691
5721
|
if (signatureRecordArray.length >= 6) {
|
|
5692
5722
|
const signatureRecordView = getDataView(signatureRecordArray);
|
|
@@ -5818,29 +5848,27 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5818
5848
|
readExtraFieldUnixDates(extraFieldUnixType1, directory);
|
|
5819
5849
|
directory.extraFieldUnixType1 = extraFieldUnixType1;
|
|
5820
5850
|
}
|
|
5851
|
+
const extraFieldExtendedTimestamp = extraField.get(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
5852
|
+
if (extraFieldExtendedTimestamp) {
|
|
5853
|
+
readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory, localDirectory);
|
|
5854
|
+
directory.extraFieldExtendedTimestamp = extraFieldExtendedTimestamp;
|
|
5855
|
+
}
|
|
5821
5856
|
const extraFieldNTFS = extraField.get(EXTRAFIELD_TYPE_NTFS);
|
|
5822
5857
|
if (extraFieldNTFS) {
|
|
5823
5858
|
readExtraFieldNTFS(extraFieldNTFS, directory);
|
|
5824
5859
|
directory.extraFieldNTFS = extraFieldNTFS;
|
|
5825
5860
|
}
|
|
5826
|
-
const
|
|
5861
|
+
const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
|
|
5827
5862
|
let unixIdsRead;
|
|
5863
|
+
if (extraFieldInfoZip) {
|
|
5864
|
+
unixIdsRead = readExtraFieldUnix(extraFieldInfoZip, directory, true);
|
|
5865
|
+
directory.extraFieldInfoZip = extraFieldInfoZip;
|
|
5866
|
+
}
|
|
5867
|
+
const extraFieldUnix = extraField.get(EXTRAFIELD_TYPE_UNIX);
|
|
5828
5868
|
if (extraFieldUnix) {
|
|
5829
|
-
|
|
5869
|
+
readExtraFieldUnix(extraFieldUnix, unixIdsRead ? {} : directory, false);
|
|
5830
5870
|
directory.extraFieldUnix = extraFieldUnix;
|
|
5831
5871
|
}
|
|
5832
|
-
if (!unixIdsRead) {
|
|
5833
|
-
const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
|
|
5834
|
-
if (extraFieldInfoZip) {
|
|
5835
|
-
readExtraFieldUnix(extraFieldInfoZip, directory, true);
|
|
5836
|
-
directory.extraFieldInfoZip = extraFieldInfoZip;
|
|
5837
|
-
}
|
|
5838
|
-
}
|
|
5839
|
-
const extraFieldExtendedTimestamp = extraField.get(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
5840
|
-
if (extraFieldExtendedTimestamp) {
|
|
5841
|
-
readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory, localDirectory);
|
|
5842
|
-
directory.extraFieldExtendedTimestamp = extraFieldExtendedTimestamp;
|
|
5843
|
-
}
|
|
5844
5872
|
const extraFieldUSDZ = extraField.get(EXTRAFIELD_TYPE_USDZ);
|
|
5845
5873
|
if (extraFieldUSDZ) {
|
|
5846
5874
|
directory.extraFieldUSDZ = extraFieldUSDZ;
|
|
@@ -6479,11 +6507,13 @@ var zipReader = /*#__PURE__*/Object.freeze({
|
|
|
6479
6507
|
WARNING_COMPRESSED_PATCHED_DATA: WARNING_COMPRESSED_PATCHED_DATA,
|
|
6480
6508
|
WARNING_DUPLICATE_FILENAME: WARNING_DUPLICATE_FILENAME,
|
|
6481
6509
|
WARNING_MALFORMED_EXTRA_FIELD: WARNING_MALFORMED_EXTRA_FIELD,
|
|
6510
|
+
WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET: WARNING_MISMATCHED_CENTRAL_DIRECTORY_OFFSET,
|
|
6482
6511
|
WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG: WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG,
|
|
6483
6512
|
WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD: WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD,
|
|
6484
6513
|
WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES: WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES,
|
|
6485
6514
|
WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME: WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME,
|
|
6486
6515
|
WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY: WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY,
|
|
6516
|
+
WARNING_MISSING_ZIP64_EXTRA_FIELD: WARNING_MISSING_ZIP64_EXTRA_FIELD,
|
|
6487
6517
|
WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY: WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY,
|
|
6488
6518
|
WARNING_PREPENDED_CENTRAL_DIRECTORY: WARNING_PREPENDED_CENTRAL_DIRECTORY,
|
|
6489
6519
|
WARNING_PREPENDED_DATA: WARNING_PREPENDED_DATA,
|
|
@@ -6616,13 +6646,14 @@ class ZipWriter {
|
|
|
6616
6646
|
return watchPromiseError(this, prependZipEntries(this, reader));
|
|
6617
6647
|
}
|
|
6618
6648
|
|
|
6619
|
-
appendZip(reader) {
|
|
6620
|
-
return watchPromiseError(this, this.appendZipEntries(reader));
|
|
6649
|
+
appendZip(reader, options = {}) {
|
|
6650
|
+
return watchPromiseError(this, this.appendZipEntries(reader, options));
|
|
6621
6651
|
}
|
|
6622
6652
|
|
|
6623
|
-
async appendZipEntries(reader) {
|
|
6653
|
+
async appendZipEntries(reader, options = {}) {
|
|
6624
6654
|
const zipWriter = this;
|
|
6625
6655
|
const { pendingAddFileCalls, filenames, fileEntries } = zipWriter;
|
|
6656
|
+
const filter = checkFunctionOption(options.filter);
|
|
6626
6657
|
while (pendingAddFileCalls.size) {
|
|
6627
6658
|
await Promise.allSettled(Array.from(pendingAddFileCalls));
|
|
6628
6659
|
}
|
|
@@ -6641,10 +6672,16 @@ class ZipWriter {
|
|
|
6641
6672
|
const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
|
|
6642
6673
|
const zipReader$1 = new ZipReader(reader);
|
|
6643
6674
|
const entries = await zipReader$1.getEntries();
|
|
6675
|
+
const keptEntries = [];
|
|
6676
|
+
for (const entry of entries) {
|
|
6677
|
+
if (!filter || await filter(entry)) {
|
|
6678
|
+
keptEntries.push(entry);
|
|
6679
|
+
}
|
|
6680
|
+
}
|
|
6644
6681
|
await zipReader$1.close();
|
|
6645
6682
|
await initStream(zipWriter.writer);
|
|
6646
6683
|
const { directoryOffset } = zipReader$1;
|
|
6647
|
-
|
|
6684
|
+
keptEntries.forEach(({ filename }) => {
|
|
6648
6685
|
if (filenames.has(filename)) {
|
|
6649
6686
|
throw new Error(ERR_DUPLICATED_NAME);
|
|
6650
6687
|
}
|
|
@@ -6665,8 +6702,8 @@ class ZipWriter {
|
|
|
6665
6702
|
zipWriter.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6666
6703
|
}
|
|
6667
6704
|
}
|
|
6668
|
-
const entryPositions = await copyZipData(zipWriter, reader, entries, directoryOffset);
|
|
6669
|
-
|
|
6705
|
+
const entryPositions = await copyZipData(zipWriter, reader, entries, keptEntries, directoryOffset, Boolean(filter));
|
|
6706
|
+
keptEntries.forEach(entry => {
|
|
6670
6707
|
const {
|
|
6671
6708
|
version,
|
|
6672
6709
|
rawLastModDate,
|
|
@@ -6722,6 +6759,7 @@ class ZipWriter {
|
|
|
6722
6759
|
rawExtraFieldExtendedTimestamp: EMPTY_UINT8_ARRAY,
|
|
6723
6760
|
rawExtraFieldNTFS: EMPTY_UINT8_ARRAY,
|
|
6724
6761
|
rawExtraFieldUnix: EMPTY_UINT8_ARRAY,
|
|
6762
|
+
rawCentralExtraFieldUnix: EMPTY_UINT8_ARRAY,
|
|
6725
6763
|
rawExtraField,
|
|
6726
6764
|
rawCentralExtraField: EMPTY_UINT8_ARRAY,
|
|
6727
6765
|
headerArray,
|
|
@@ -7290,7 +7328,6 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
7290
7328
|
const ntfsTimestamp = getOptionValue(zipWriter, options, OPTION_NTFS_TIMESTAMP);
|
|
7291
7329
|
const keepOrder = getOptionValue(zipWriter, options, OPTION_KEEP_ORDER, true);
|
|
7292
7330
|
const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
|
|
7293
|
-
const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS);
|
|
7294
7331
|
const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
|
|
7295
7332
|
const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
|
|
7296
7333
|
const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
|
|
@@ -7356,7 +7393,6 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
7356
7393
|
ntfsTimestamp,
|
|
7357
7394
|
keepOrder,
|
|
7358
7395
|
useWebWorkers,
|
|
7359
|
-
transferStreams,
|
|
7360
7396
|
bufferedWrite,
|
|
7361
7397
|
createTempStream,
|
|
7362
7398
|
dataDescriptorSignature,
|
|
@@ -7415,7 +7451,7 @@ async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, op
|
|
|
7415
7451
|
if (reader) {
|
|
7416
7452
|
reader = new GenericReader(reader);
|
|
7417
7453
|
await initStream(reader);
|
|
7418
|
-
if (!reader.
|
|
7454
|
+
if (!reader.readUint8Array && !reader.readable) {
|
|
7419
7455
|
throw new Error(ERR_INVALID_READER);
|
|
7420
7456
|
}
|
|
7421
7457
|
({ size: contentSize } = reader);
|
|
@@ -7776,6 +7812,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7776
7812
|
extraFieldExtendedTimestampTime,
|
|
7777
7813
|
rawExtraFieldNTFS,
|
|
7778
7814
|
rawExtraFieldUnix,
|
|
7815
|
+
rawCentralExtraFieldUnix,
|
|
7779
7816
|
rawExtraFieldAES,
|
|
7780
7817
|
} = headerInfo;
|
|
7781
7818
|
const { dataDescriptorArray } = dataDescriptorInfo;
|
|
@@ -7800,7 +7837,6 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7800
7837
|
rawExtraField,
|
|
7801
7838
|
rawCentralExtraField,
|
|
7802
7839
|
useWebWorkers,
|
|
7803
|
-
transferStreams,
|
|
7804
7840
|
onstart,
|
|
7805
7841
|
onprogress,
|
|
7806
7842
|
onend,
|
|
@@ -7842,6 +7878,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7842
7878
|
rawExtraFieldExtendedTimestamp,
|
|
7843
7879
|
rawExtraFieldNTFS,
|
|
7844
7880
|
rawExtraFieldUnix,
|
|
7881
|
+
rawCentralExtraFieldUnix,
|
|
7845
7882
|
rawExtraFieldAES,
|
|
7846
7883
|
rawExtraField,
|
|
7847
7884
|
rawCentralExtraField,
|
|
@@ -7888,7 +7925,6 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7888
7925
|
encrypted: encrypted && !passThroughEncryption,
|
|
7889
7926
|
useWebWorkers,
|
|
7890
7927
|
useCompressionStream,
|
|
7891
|
-
transferStreams,
|
|
7892
7928
|
format,
|
|
7893
7929
|
codecURI,
|
|
7894
7930
|
compressionMethod
|
|
@@ -8066,6 +8102,7 @@ function getHeaderInfo(options) {
|
|
|
8066
8102
|
rawExtraFieldNTFS = rawExtraFieldExtendedTimestamp = EMPTY_UINT8_ARRAY;
|
|
8067
8103
|
}
|
|
8068
8104
|
let rawExtraFieldUnix;
|
|
8105
|
+
let rawCentralExtraFieldUnix;
|
|
8069
8106
|
try {
|
|
8070
8107
|
const { uid, gid, unixExtraFieldType } = options;
|
|
8071
8108
|
if (unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
@@ -8080,7 +8117,7 @@ function getHeaderInfo(options) {
|
|
|
8080
8117
|
extraFieldUnix.writeBytes(uidBytes);
|
|
8081
8118
|
extraFieldUnix.writeUint8(gidBytes.length);
|
|
8082
8119
|
extraFieldUnix.writeBytes(gidBytes);
|
|
8083
|
-
rawExtraFieldUnix = extraFieldUnix.array;
|
|
8120
|
+
rawExtraFieldUnix = rawCentralExtraFieldUnix = extraFieldUnix.array;
|
|
8084
8121
|
} else if (unixExtraFieldType == UNIX_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
8085
8122
|
const extraFieldUnix = createRecordWriter(8);
|
|
8086
8123
|
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_UNIX);
|
|
@@ -8088,11 +8125,15 @@ function getHeaderInfo(options) {
|
|
|
8088
8125
|
extraFieldUnix.writeUint16((uid === UNDEFINED_VALUE ? 0 : uid) & MAX_16_BITS);
|
|
8089
8126
|
extraFieldUnix.writeUint16((gid === UNDEFINED_VALUE ? 0 : gid) & MAX_16_BITS);
|
|
8090
8127
|
rawExtraFieldUnix = extraFieldUnix.array;
|
|
8128
|
+
const centralExtraFieldUnix = createRecordWriter(4);
|
|
8129
|
+
centralExtraFieldUnix.writeUint16(EXTRAFIELD_TYPE_UNIX);
|
|
8130
|
+
centralExtraFieldUnix.writeUint16(0);
|
|
8131
|
+
rawCentralExtraFieldUnix = centralExtraFieldUnix.array;
|
|
8091
8132
|
} else {
|
|
8092
|
-
rawExtraFieldUnix = EMPTY_UINT8_ARRAY;
|
|
8133
|
+
rawExtraFieldUnix = rawCentralExtraFieldUnix = EMPTY_UINT8_ARRAY;
|
|
8093
8134
|
}
|
|
8094
8135
|
} catch {
|
|
8095
|
-
rawExtraFieldUnix = EMPTY_UINT8_ARRAY;
|
|
8136
|
+
rawExtraFieldUnix = rawCentralExtraFieldUnix = EMPTY_UINT8_ARRAY;
|
|
8096
8137
|
}
|
|
8097
8138
|
if (compressionMethod === UNDEFINED_VALUE) {
|
|
8098
8139
|
compressionMethod = compressed ? COMPRESSION_METHOD_DEFLATE : COMPRESSION_METHOD_STORE;
|
|
@@ -8184,6 +8225,7 @@ function getHeaderInfo(options) {
|
|
|
8184
8225
|
rawExtraFieldExtendedTimestamp,
|
|
8185
8226
|
rawExtraFieldNTFS,
|
|
8186
8227
|
rawExtraFieldUnix,
|
|
8228
|
+
rawCentralExtraFieldUnix,
|
|
8187
8229
|
rawExtraFieldAES,
|
|
8188
8230
|
extraFieldLength
|
|
8189
8231
|
};
|
|
@@ -8359,7 +8401,7 @@ function createDirectoryRecords(files) {
|
|
|
8359
8401
|
rawExtraFieldAES,
|
|
8360
8402
|
rawComment,
|
|
8361
8403
|
rawExtraFieldNTFS,
|
|
8362
|
-
|
|
8404
|
+
rawCentralExtraFieldUnix,
|
|
8363
8405
|
rawExtraField,
|
|
8364
8406
|
rawCentralExtraField,
|
|
8365
8407
|
extraFieldExtendedTimestampFlag,
|
|
@@ -8421,7 +8463,7 @@ function createDirectoryRecords(files) {
|
|
|
8421
8463
|
rawExtraFieldZip64,
|
|
8422
8464
|
rawExtraFieldAES,
|
|
8423
8465
|
rawExtraFieldNTFS,
|
|
8424
|
-
|
|
8466
|
+
rawCentralExtraFieldUnix,
|
|
8425
8467
|
rawExtraFieldTimestamp,
|
|
8426
8468
|
rawExtraField,
|
|
8427
8469
|
rawCentralExtraField);
|
|
@@ -8450,7 +8492,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
8450
8492
|
rawExtraFieldAES,
|
|
8451
8493
|
rawExtraFieldExtendedTimestamp,
|
|
8452
8494
|
rawExtraFieldNTFS,
|
|
8453
|
-
|
|
8495
|
+
rawCentralExtraFieldUnix,
|
|
8454
8496
|
rawExtraField,
|
|
8455
8497
|
rawCentralExtraField,
|
|
8456
8498
|
rawComment,
|
|
@@ -8467,7 +8509,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
8467
8509
|
uncompressedSize,
|
|
8468
8510
|
compressedSize
|
|
8469
8511
|
} = fileEntry;
|
|
8470
|
-
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS,
|
|
8512
|
+
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawCentralExtraFieldUnix, rawExtraField, rawCentralExtraField);
|
|
8471
8513
|
const directoryRecordLength = CENTRAL_FILE_HEADER_LENGTH + getLength(rawFilename, rawComment) + extraFieldLength;
|
|
8472
8514
|
if (exceedsAvailableSize(writer, offset + directoryRecordLength - directoryDiskOffset)) {
|
|
8473
8515
|
await writeData(writer, directoryArray.slice(directoryDiskOffset, offset));
|
|
@@ -8503,7 +8545,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
8503
8545
|
directoryRecord.writeBytes(rawExtraFieldAES);
|
|
8504
8546
|
directoryRecord.writeBytes(rawExtraFieldExtendedTimestamp);
|
|
8505
8547
|
directoryRecord.writeBytes(rawExtraFieldNTFS);
|
|
8506
|
-
directoryRecord.writeBytes(
|
|
8548
|
+
directoryRecord.writeBytes(rawCentralExtraFieldUnix);
|
|
8507
8549
|
directoryRecord.writeBytes(rawExtraField);
|
|
8508
8550
|
directoryRecord.writeBytes(rawCentralExtraField);
|
|
8509
8551
|
directoryRecord.writeBytes(rawComment);
|
|
@@ -8672,26 +8714,42 @@ function removeExtraFieldZip64(rawExtraField) {
|
|
|
8672
8714
|
return rawExtraField;
|
|
8673
8715
|
}
|
|
8674
8716
|
|
|
8675
|
-
async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
8717
|
+
async function copyZipData(zipWriter, reader, entries, keptEntries, directoryOffset, compact) {
|
|
8676
8718
|
const { writer } = zipWriter;
|
|
8677
8719
|
const entryPositions = new Map();
|
|
8678
|
-
if (writer.closeDisk) {
|
|
8720
|
+
if (writer.closeDisk || compact) {
|
|
8679
8721
|
const sortedEntries = Array.from(entries).sort((firstEntry, secondEntry) =>
|
|
8680
8722
|
getSourceOffset(reader, firstEntry) - getSourceOffset(reader, secondEntry));
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8723
|
+
const regionEnds = getRegionEnds(reader, sortedEntries, directoryOffset);
|
|
8724
|
+
const keptEntrySet = new Set(keptEntries);
|
|
8725
|
+
let copiedOffset = 0;
|
|
8726
|
+
let lastPosition;
|
|
8727
|
+
for (let indexEntry = 0; indexEntry < sortedEntries.length; indexEntry++) {
|
|
8728
|
+
const entry = sortedEntries[indexEntry];
|
|
8729
|
+
if (keptEntrySet.has(entry)) {
|
|
8730
|
+
const sourceOffset = getSourceOffset(reader, entry);
|
|
8731
|
+
if (sourceOffset < copiedOffset) {
|
|
8732
|
+
entryPositions.set(entry, lastPosition);
|
|
8733
|
+
} else {
|
|
8734
|
+
if (!compact) {
|
|
8735
|
+
await copyData(zipWriter, reader, copiedOffset, sourceOffset - copiedOffset);
|
|
8736
|
+
}
|
|
8737
|
+
if (writer.closeDisk && exceedsAvailableSize(writer, await getLocalHeaderLength(reader, sourceOffset))) {
|
|
8738
|
+
await writer.closeDisk();
|
|
8739
|
+
}
|
|
8740
|
+
lastPosition = {
|
|
8741
|
+
offset: getSegmentOffset(zipWriter, writer),
|
|
8742
|
+
diskNumberStart: getDiskNumber(writer)
|
|
8743
|
+
};
|
|
8744
|
+
entryPositions.set(entry, lastPosition);
|
|
8745
|
+
await copyData(zipWriter, reader, sourceOffset, regionEnds[indexEntry] - sourceOffset);
|
|
8746
|
+
copiedOffset = regionEnds[indexEntry];
|
|
8747
|
+
}
|
|
8748
|
+
}
|
|
8749
|
+
}
|
|
8750
|
+
if (!compact) {
|
|
8751
|
+
await copyData(zipWriter, reader, copiedOffset, directoryOffset - copiedOffset);
|
|
8693
8752
|
}
|
|
8694
|
-
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
8695
8753
|
} else {
|
|
8696
8754
|
const baseOffset = zipWriter.offset;
|
|
8697
8755
|
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
@@ -8703,6 +8761,20 @@ async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
|
8703
8761
|
return entryPositions;
|
|
8704
8762
|
}
|
|
8705
8763
|
|
|
8764
|
+
function getRegionEnds(reader, sortedEntries, directoryOffset) {
|
|
8765
|
+
const regionEnds = new Array(sortedEntries.length);
|
|
8766
|
+
let regionEnd = directoryOffset;
|
|
8767
|
+
for (let indexEntry = sortedEntries.length - 1; indexEntry >= 0; indexEntry--) {
|
|
8768
|
+
const sourceOffset = getSourceOffset(reader, sortedEntries[indexEntry]);
|
|
8769
|
+
const nextEntry = sortedEntries[indexEntry + 1];
|
|
8770
|
+
if (nextEntry && getSourceOffset(reader, nextEntry) > sourceOffset) {
|
|
8771
|
+
regionEnd = getSourceOffset(reader, nextEntry);
|
|
8772
|
+
}
|
|
8773
|
+
regionEnds[indexEntry] = regionEnd;
|
|
8774
|
+
}
|
|
8775
|
+
return regionEnds;
|
|
8776
|
+
}
|
|
8777
|
+
|
|
8706
8778
|
async function copyData(zipWriter, reader, offset, size) {
|
|
8707
8779
|
if (size > 0) {
|
|
8708
8780
|
const { writer } = zipWriter;
|
|
@@ -9080,7 +9152,7 @@ function formatSupported(StreamClass, format) {
|
|
|
9080
9152
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9081
9153
|
*/
|
|
9082
9154
|
|
|
9083
|
-
const VERSION = "2.
|
|
9155
|
+
const VERSION = "2.20.0";
|
|
9084
9156
|
|
|
9085
9157
|
/*
|
|
9086
9158
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -11584,4 +11656,4 @@ function getPathParent(parent, path, movedEntry) {
|
|
|
11584
11656
|
return parent;
|
|
11585
11657
|
}
|
|
11586
11658
|
|
|
11587
|
-
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, ERR_AMBIGUOUS_ARCHIVE, ERR_ANCESTOR_ENTRY, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_CODEC_OUT_OF_MEMORY, ERR_DUPLICATED_NAME, ERR_DUPLICATE_IMPORTED_ENTRY, 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_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_DUPLICATES, 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_PASSWORDS, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_PASS_THROUGH, ERR_INVALID_PASS_THROUGH_VALUE, ERR_INVALID_READER, ERR_INVALID_READER_OPTIONS, ERR_INVALID_REQUEST_PASSWORD, 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_PARENT_NOT_DIRECTORY, ERR_READABLE_CONSUMED, ERR_RESERVED_COMPRESSION_METHOD, ERR_ROOT_DIRECTORY_NOT_MOVABLE, ERR_SPLIT_ZIP_FILE, ERR_TARGET_NOT_DIRECTORY, 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_PASS_THROUGH_VALUE, 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, ZipDirectoryEntry, ZipEntry, ZipFS, ZipFileEntry, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, getRegisteredCodecs, getSupportedCompressionMethods, isZipFile, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|
|
11659
|
+
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, ERR_AMBIGUOUS_ARCHIVE, ERR_ANCESTOR_ENTRY, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_CODEC_OUT_OF_MEMORY, ERR_DUPLICATED_NAME, ERR_DUPLICATE_IMPORTED_ENTRY, 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_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_DUPLICATES, 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_PASSWORDS, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_PASS_THROUGH, ERR_INVALID_PASS_THROUGH_VALUE, ERR_INVALID_READER, ERR_INVALID_READER_OPTIONS, ERR_INVALID_REQUEST_PASSWORD, 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_PARENT_NOT_DIRECTORY, ERR_READABLE_CONSUMED, ERR_RESERVED_COMPRESSION_METHOD, ERR_ROOT_DIRECTORY_NOT_MOVABLE, ERR_SPLIT_ZIP_FILE, ERR_TARGET_NOT_DIRECTORY, 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_PASS_THROUGH_VALUE, 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, ZipDirectoryEntry, ZipEntry, ZipFS, ZipFileEntry, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, getRegisteredCodecs, getSupportedCompressionMethods, isZipFile, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|