@zip.js/zip.js 2.8.50 → 2.8.52
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/README.md +8 -3
- package/deno.json +1 -1
- package/dist/zip-core-external.js +88 -44
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +89 -43
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +460 -171
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +461 -170
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +460 -171
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +463 -170
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +463 -170
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +89 -43
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +89 -43
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +89 -43
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +463 -170
- package/index-native.min.js +1 -1
- package/index.cjs +463 -170
- package/index.d.cts +320 -9
- package/index.d.ts +320 -9
- package/index.min.js +1 -1
- package/lib/core/codec-worker.js +2 -0
- package/lib/core/constants.js +4 -0
- package/lib/core/io.js +32 -2
- package/lib/core/util/compatible-streams.js +3 -8
- package/lib/core/zip-entry.js +8 -0
- package/lib/core/zip-fs.js +289 -131
- package/lib/core/zip-reader.js +15 -6
- package/lib/core/zip-writer.js +135 -29
- package/lib/zip-core-writer.js +2 -0
- package/package.json +5 -5
package/dist/zip-core.js
CHANGED
|
@@ -90,6 +90,8 @@
|
|
|
90
90
|
const FILE_ATTR_MSDOS_ARCHIVE_MASK = 0x20;
|
|
91
91
|
const FILE_ATTR_UNIX_TYPE_MASK = 0o170000;
|
|
92
92
|
const FILE_ATTR_UNIX_TYPE_DIR = 0o040000;
|
|
93
|
+
const FILE_ATTR_UNIX_TYPE_SYMLINK = 0o120000;
|
|
94
|
+
const FILE_ATTR_UNIX_TYPE_FILE = 0o100000;
|
|
93
95
|
const FILE_ATTR_UNIX_EXECUTABLE_MASK = 0o111;
|
|
94
96
|
const FILE_ATTR_UNIX_DEFAULT_MASK = 0o644;
|
|
95
97
|
const FILE_ATTR_UNIX_SETUID_MASK = 0o4000;
|
|
@@ -1779,8 +1781,6 @@
|
|
|
1779
1781
|
*/
|
|
1780
1782
|
|
|
1781
1783
|
|
|
1782
|
-
const HTTP_HEADER_CONTENT_TYPE = "Content-Type";
|
|
1783
|
-
|
|
1784
1784
|
function toCompatibleReadable(readable) {
|
|
1785
1785
|
if (readable instanceof ReadableStream) {
|
|
1786
1786
|
return readable;
|
|
@@ -1803,12 +1803,9 @@
|
|
|
1803
1803
|
|
|
1804
1804
|
function streamToBlob(readable, contentType) {
|
|
1805
1805
|
readable = toCompatibleReadable(readable);
|
|
1806
|
+
const blobOptions = contentType ? { type: contentType } : {};
|
|
1806
1807
|
if (responseSupportsGlobalReadable()) {
|
|
1807
|
-
|
|
1808
|
-
if (contentType) {
|
|
1809
|
-
options.headers = [[HTTP_HEADER_CONTENT_TYPE, contentType]];
|
|
1810
|
-
}
|
|
1811
|
-
return new Response(readable, options).blob();
|
|
1808
|
+
return new Response(readable).blob().then(blob => contentType ? new Blob([blob], blobOptions) : blob);
|
|
1812
1809
|
}
|
|
1813
1810
|
const chunks = [];
|
|
1814
1811
|
return readable
|
|
@@ -1817,7 +1814,7 @@
|
|
|
1817
1814
|
chunks.push(chunk);
|
|
1818
1815
|
}
|
|
1819
1816
|
}))
|
|
1820
|
-
.then(() => new Blob(chunks,
|
|
1817
|
+
.then(() => new Blob(chunks, blobOptions));
|
|
1821
1818
|
}
|
|
1822
1819
|
|
|
1823
1820
|
function responseSupportsGlobalReadable() {
|
|
@@ -3348,8 +3345,10 @@
|
|
|
3348
3345
|
async pull(controller) {
|
|
3349
3346
|
const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
|
|
3350
3347
|
const data = await readUint8Array(reader, offset + chunkOffset, dataSize);
|
|
3351
|
-
|
|
3352
|
-
|
|
3348
|
+
if (data.length) {
|
|
3349
|
+
controller.enqueue(data);
|
|
3350
|
+
}
|
|
3351
|
+
if ((chunkOffset + chunkSize >= size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
|
|
3353
3352
|
controller.close();
|
|
3354
3353
|
} else {
|
|
3355
3354
|
chunkOffset += chunkSize;
|
|
@@ -3427,6 +3426,7 @@
|
|
|
3427
3426
|
constructor(contentType) {
|
|
3428
3427
|
super();
|
|
3429
3428
|
Object.assign(this, {
|
|
3429
|
+
contentType,
|
|
3430
3430
|
data: "data:" + (contentType || "") + ";base64,",
|
|
3431
3431
|
pending: []
|
|
3432
3432
|
});
|
|
@@ -3528,6 +3528,7 @@
|
|
|
3528
3528
|
return transformStream.writable;
|
|
3529
3529
|
}
|
|
3530
3530
|
});
|
|
3531
|
+
writer.contentType = contentType;
|
|
3531
3532
|
writer.blob = streamToBlob(transformStream.readable, contentType);
|
|
3532
3533
|
writer.blob.catch(() => { });
|
|
3533
3534
|
}
|
|
@@ -4207,6 +4208,10 @@
|
|
|
4207
4208
|
}
|
|
4208
4209
|
}
|
|
4209
4210
|
|
|
4211
|
+
function ownsWritable(writer) {
|
|
4212
|
+
return Boolean(writer && writer.getData);
|
|
4213
|
+
}
|
|
4214
|
+
|
|
4210
4215
|
function isHttpFamily(url) {
|
|
4211
4216
|
const { baseURI } = getConfiguration();
|
|
4212
4217
|
const { protocol } = new URL(url, baseURI);
|
|
@@ -4351,6 +4356,8 @@
|
|
|
4351
4356
|
const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
|
|
4352
4357
|
const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES = "internalFileAttributes";
|
|
4353
4358
|
const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttributes";
|
|
4359
|
+
const PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES = "internalFileAttribute";
|
|
4360
|
+
const PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttribute";
|
|
4354
4361
|
const PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW = "msdosAttributesRaw";
|
|
4355
4362
|
const PROPERTY_NAME_MSDOS_ATTRIBUTES = "msdosAttributes";
|
|
4356
4363
|
const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
|
|
@@ -4361,6 +4368,7 @@
|
|
|
4361
4368
|
const PROPERTY_NAME_ZIPCRYPTO = "zipCrypto";
|
|
4362
4369
|
const PROPERTY_NAME_DIRECTORY = "directory";
|
|
4363
4370
|
const PROPERTY_NAME_EXECUTABLE = "executable";
|
|
4371
|
+
const PROPERTY_NAME_SYMLINK = "symlink";
|
|
4364
4372
|
const PROPERTY_NAME_COMPRESSION_METHOD = "compressionMethod";
|
|
4365
4373
|
const PROPERTY_NAME_SIGNATURE = "signature";
|
|
4366
4374
|
const PROPERTY_NAME_CRC32 = "crc32";
|
|
@@ -4404,6 +4412,8 @@
|
|
|
4404
4412
|
PROPERTY_NAME_DISK_NUMBER_START,
|
|
4405
4413
|
PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES,
|
|
4406
4414
|
PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES,
|
|
4415
|
+
PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES,
|
|
4416
|
+
PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES,
|
|
4407
4417
|
PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW,
|
|
4408
4418
|
PROPERTY_NAME_MSDOS_ATTRIBUTES,
|
|
4409
4419
|
PROPERTY_NAME_MS_DOS_COMPATIBLE,
|
|
@@ -4414,6 +4424,7 @@
|
|
|
4414
4424
|
PROPERTY_NAME_ZIPCRYPTO,
|
|
4415
4425
|
PROPERTY_NAME_DIRECTORY,
|
|
4416
4426
|
PROPERTY_NAME_EXECUTABLE,
|
|
4427
|
+
PROPERTY_NAME_SYMLINK,
|
|
4417
4428
|
PROPERTY_NAME_COMPRESSION_METHOD,
|
|
4418
4429
|
PROPERTY_NAME_SIGNATURE,
|
|
4419
4430
|
PROPERTY_NAME_CRC32,
|
|
@@ -4876,15 +4887,18 @@
|
|
|
4876
4887
|
const setuid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETUID_MASK);
|
|
4877
4888
|
const setgid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETGID_MASK);
|
|
4878
4889
|
const sticky = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_STICKY_MASK);
|
|
4879
|
-
const
|
|
4890
|
+
const unixType = fileEntry.unixMode === UNDEFINED_VALUE ? unixExternalUpper : fileEntry.unixMode;
|
|
4891
|
+
const symlink = (unixType & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK;
|
|
4892
|
+
const executable = !symlink && ((fileEntry.unixMode !== UNDEFINED_VALUE)
|
|
4880
4893
|
? ((fileEntry.unixMode & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)
|
|
4881
|
-
: (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0));
|
|
4894
|
+
: (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)));
|
|
4882
4895
|
const modeIsDir = fileEntry.unixMode !== UNDEFINED_VALUE && ((fileEntry.unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
|
|
4883
4896
|
const upperIsDir = ((unixExternalUpper & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
|
|
4884
4897
|
Object.assign(fileEntry, {
|
|
4885
4898
|
setuid,
|
|
4886
4899
|
setgid,
|
|
4887
4900
|
sticky,
|
|
4901
|
+
symlink,
|
|
4888
4902
|
unixExternalUpper,
|
|
4889
4903
|
internalFileAttribute: fileEntry.internalFileAttributes,
|
|
4890
4904
|
externalFileAttribute: fileEntry.externalFileAttributes,
|
|
@@ -4950,6 +4964,10 @@
|
|
|
4950
4964
|
}
|
|
4951
4965
|
|
|
4952
4966
|
async close() {
|
|
4967
|
+
const { reader } = this;
|
|
4968
|
+
if (!reader.readUint8Array && reader.readable && !reader.readable.locked) {
|
|
4969
|
+
await reader.readable.cancel();
|
|
4970
|
+
}
|
|
4953
4971
|
}
|
|
4954
4972
|
}
|
|
4955
4973
|
|
|
@@ -5174,7 +5192,7 @@
|
|
|
5174
5192
|
throw error;
|
|
5175
5193
|
}
|
|
5176
5194
|
} finally {
|
|
5177
|
-
const preventClose = getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
|
|
5195
|
+
const preventClose = !ownsWritable(writer) && getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
|
|
5178
5196
|
if (!preventClose && writable && !writable.locked) {
|
|
5179
5197
|
const writableWriter = writable.getWriter();
|
|
5180
5198
|
if (abortError) {
|
|
@@ -5418,8 +5436,8 @@
|
|
|
5418
5436
|
return;
|
|
5419
5437
|
}
|
|
5420
5438
|
const extraFieldView = getDataView(extraField.data);
|
|
5421
|
-
const lastAccessDate = new Date(getUint32(extraFieldView, 0) * 1000);
|
|
5422
|
-
const lastModDate = new Date(getUint32(extraFieldView, 4) * 1000);
|
|
5439
|
+
const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
|
|
5440
|
+
const lastModDate = new Date((getUint32(extraFieldView, 4) | 0) * 1000);
|
|
5423
5441
|
const extraFieldData = { lastAccessDate, lastModDate };
|
|
5424
5442
|
if (extraField.data.length >= 12) {
|
|
5425
5443
|
extraFieldData.uid = getUint16(extraFieldView, 8);
|
|
@@ -5850,6 +5868,7 @@
|
|
|
5850
5868
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
5851
5869
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
5852
5870
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
5871
|
+
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
5853
5872
|
const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
|
|
5854
5873
|
const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
|
|
5855
5874
|
const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
|
|
@@ -5859,6 +5878,7 @@
|
|
|
5859
5878
|
const MAX_NTFS_TIME = BigInt("0x7fffffffffffffff");
|
|
5860
5879
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
|
|
5861
5880
|
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
5881
|
+
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
5862
5882
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
5863
5883
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
5864
5884
|
const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
|
|
@@ -6066,7 +6086,7 @@
|
|
|
6066
6086
|
await Promise.allSettled(Array.from(pendingAddFileCalls));
|
|
6067
6087
|
}
|
|
6068
6088
|
await closeFile(zipWriter, comment, options);
|
|
6069
|
-
const preventClose = getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
|
|
6089
|
+
const preventClose = !ownsWritable(writer) && getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
|
|
6070
6090
|
if (!preventClose) {
|
|
6071
6091
|
await writable.getWriter().close();
|
|
6072
6092
|
}
|
|
@@ -6225,7 +6245,7 @@
|
|
|
6225
6245
|
if (versionMadeBy > MAX_16_BITS) {
|
|
6226
6246
|
throw new Error(ERR_INVALID_VERSION);
|
|
6227
6247
|
}
|
|
6228
|
-
let externalFileAttributes =
|
|
6248
|
+
let externalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES);
|
|
6229
6249
|
const externalFileAttributesProvided = externalFileAttributes !== UNDEFINED_VALUE;
|
|
6230
6250
|
if (!externalFileAttributesProvided) {
|
|
6231
6251
|
externalFileAttributes = 0;
|
|
@@ -6273,7 +6293,9 @@
|
|
|
6273
6293
|
}
|
|
6274
6294
|
if (!externalFileAttributesProvided || unixModeProvided) {
|
|
6275
6295
|
if (directory) {
|
|
6276
|
-
unixMode
|
|
6296
|
+
unixMode = (unixMode & ~FILE_ATTR_UNIX_TYPE_MASK) | FILE_ATTR_UNIX_TYPE_DIR;
|
|
6297
|
+
} else if (!(unixMode & FILE_ATTR_UNIX_TYPE_MASK)) {
|
|
6298
|
+
unixMode |= FILE_ATTR_UNIX_TYPE_FILE;
|
|
6277
6299
|
}
|
|
6278
6300
|
externalFileAttributes = ((unixMode & MAX_16_BITS) << 16) | (externalFileAttributes & MAX_16_BITS);
|
|
6279
6301
|
}
|
|
@@ -6326,15 +6348,12 @@
|
|
|
6326
6348
|
const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
|
|
6327
6349
|
const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
6328
6350
|
const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
6329
|
-
const internalFileAttributes =
|
|
6351
|
+
const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
|
|
6330
6352
|
const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
6336
|
-
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
6337
|
-
}
|
|
6353
|
+
const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
6354
|
+
const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
6355
|
+
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
6356
|
+
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
6338
6357
|
}
|
|
6339
6358
|
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
6340
6359
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
@@ -6447,14 +6466,24 @@
|
|
|
6447
6466
|
}
|
|
6448
6467
|
|
|
6449
6468
|
async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, options) {
|
|
6469
|
+
if (metadata.passThrough && !reader && !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY)) {
|
|
6470
|
+
throw new Error(ERR_UNDEFINED_READER);
|
|
6471
|
+
}
|
|
6472
|
+
let contentSize;
|
|
6473
|
+
if (reader) {
|
|
6474
|
+
reader = new GenericReader(reader);
|
|
6475
|
+
await initStream(reader);
|
|
6476
|
+
({ size: contentSize } = reader);
|
|
6477
|
+
}
|
|
6478
|
+
return Object.assign({ reader }, resolveEntrySizes(zipWriter, Boolean(reader), contentSize, metadata, options));
|
|
6479
|
+
}
|
|
6480
|
+
|
|
6481
|
+
function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options) {
|
|
6450
6482
|
const { passThrough, zipCrypto, password, rawPassword, encryptionStrength } = metadata;
|
|
6451
6483
|
let { dataDescriptor, zip64, level, compressionMethod } = metadata;
|
|
6452
6484
|
let maximumCompressedSize = 0;
|
|
6453
6485
|
let uncompressedSize = 0;
|
|
6454
|
-
if (passThrough) {
|
|
6455
|
-
if (!reader) {
|
|
6456
|
-
throw new Error(ERR_UNDEFINED_READER);
|
|
6457
|
-
}
|
|
6486
|
+
if (passThrough && hasContent) {
|
|
6458
6487
|
uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
|
|
6459
6488
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
6460
6489
|
throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
|
|
@@ -6462,29 +6491,30 @@
|
|
|
6462
6491
|
}
|
|
6463
6492
|
const zip64Enabled = zip64 === true;
|
|
6464
6493
|
const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
|
|
6465
|
-
|
|
6466
|
-
|
|
6494
|
+
if (hasContent && passThrough && !encrypted && getLength(password, rawPassword)) {
|
|
6495
|
+
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH);
|
|
6496
|
+
}
|
|
6497
|
+
const encryptedEntry = hasContent && (Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted));
|
|
6498
|
+
if (!hasContent) {
|
|
6467
6499
|
level = 0;
|
|
6468
6500
|
compressionMethod = COMPRESSION_METHOD_STORE;
|
|
6469
6501
|
}
|
|
6470
6502
|
const encryptionOverhead = encryptedEntry ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
|
|
6471
|
-
if (
|
|
6472
|
-
reader = new GenericReader(reader);
|
|
6473
|
-
await initStream(reader);
|
|
6503
|
+
if (hasContent) {
|
|
6474
6504
|
if (!passThrough) {
|
|
6475
|
-
if (
|
|
6505
|
+
if (contentSize === UNDEFINED_VALUE) {
|
|
6476
6506
|
dataDescriptor = true;
|
|
6477
6507
|
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
6478
6508
|
zip64 = true;
|
|
6479
6509
|
uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
|
|
6480
6510
|
}
|
|
6481
6511
|
} else {
|
|
6482
|
-
options.uncompressedSize = uncompressedSize =
|
|
6483
|
-
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize) + encryptionOverhead;
|
|
6512
|
+
options.uncompressedSize = uncompressedSize = contentSize;
|
|
6513
|
+
maximumCompressedSize = (isCompressed(compressionMethod, level) ? getMaximumCompressedSize(uncompressedSize) : uncompressedSize) + encryptionOverhead;
|
|
6484
6514
|
}
|
|
6485
6515
|
} else {
|
|
6486
6516
|
options.uncompressedSize = uncompressedSize;
|
|
6487
|
-
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize) + encryptionOverhead;
|
|
6517
|
+
maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
|
|
6488
6518
|
}
|
|
6489
6519
|
}
|
|
6490
6520
|
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
@@ -6498,7 +6528,7 @@
|
|
|
6498
6528
|
}
|
|
6499
6529
|
zip64 = zip64 || false;
|
|
6500
6530
|
return {
|
|
6501
|
-
|
|
6531
|
+
maximumCompressedSize,
|
|
6502
6532
|
resolvedOptions: {
|
|
6503
6533
|
dataDescriptor,
|
|
6504
6534
|
zip64,
|
|
@@ -6883,9 +6913,7 @@
|
|
|
6883
6913
|
crc32
|
|
6884
6914
|
} = options;
|
|
6885
6915
|
let { version, compressionMethod } = options;
|
|
6886
|
-
const compressed = !directory && (compressionMethod
|
|
6887
|
-
? (level === UNDEFINED_VALUE || level > 0)
|
|
6888
|
-
: compressionMethod !== COMPRESSION_METHOD_STORE);
|
|
6916
|
+
const compressed = !directory && isCompressed(compressionMethod, level);
|
|
6889
6917
|
let rawLocalExtraFieldZip64;
|
|
6890
6918
|
const uncompressedFile = passThrough || !compressed;
|
|
6891
6919
|
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
|
|
@@ -7572,6 +7600,16 @@
|
|
|
7572
7600
|
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
7573
7601
|
}
|
|
7574
7602
|
|
|
7603
|
+
function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
|
|
7604
|
+
const value = getAliasedValue(options, name, deprecatedName);
|
|
7605
|
+
const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
|
|
7606
|
+
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
7607
|
+
}
|
|
7608
|
+
|
|
7609
|
+
function getAliasedValue(options, name, deprecatedName) {
|
|
7610
|
+
return options[name] === UNDEFINED_VALUE ? options[deprecatedName] : options[name];
|
|
7611
|
+
}
|
|
7612
|
+
|
|
7575
7613
|
function getNumberOptionValue(zipWriter, options, name, defaultValue) {
|
|
7576
7614
|
return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
|
|
7577
7615
|
}
|
|
@@ -7584,6 +7622,12 @@
|
|
|
7584
7622
|
return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
|
|
7585
7623
|
}
|
|
7586
7624
|
|
|
7625
|
+
function isCompressed(compressionMethod, level) {
|
|
7626
|
+
return compressionMethod === UNDEFINED_VALUE
|
|
7627
|
+
? (level === UNDEFINED_VALUE || level > 0)
|
|
7628
|
+
: compressionMethod !== COMPRESSION_METHOD_STORE;
|
|
7629
|
+
}
|
|
7630
|
+
|
|
7587
7631
|
function setUint8(view, offset, value) {
|
|
7588
7632
|
view.setUint8(offset, value);
|
|
7589
7633
|
}
|
|
@@ -8213,11 +8257,13 @@
|
|
|
8213
8257
|
exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
|
|
8214
8258
|
exports.ERR_UNDEFINED_READER = ERR_UNDEFINED_READER;
|
|
8215
8259
|
exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
|
|
8260
|
+
exports.ERR_UNDETERMINED_SIZE = ERR_UNDETERMINED_SIZE;
|
|
8216
8261
|
exports.ERR_UNSAFE_FILENAME = ERR_UNSAFE_FILENAME;
|
|
8217
8262
|
exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION$1;
|
|
8218
8263
|
exports.ERR_UNSUPPORTED_CONTEXT = ERR_UNSUPPORTED_CONTEXT;
|
|
8219
8264
|
exports.ERR_UNSUPPORTED_CRYPTO_API = ERR_UNSUPPORTED_CRYPTO_API;
|
|
8220
8265
|
exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
|
|
8266
|
+
exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
|
|
8221
8267
|
exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
|
|
8222
8268
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
8223
8269
|
exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
|