@zip.js/zip.js 2.8.51 → 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 +408 -148
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +408 -147
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +408 -148
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +410 -147
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +410 -147
- 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 +410 -147
- package/index-native.min.js +1 -1
- package/index.cjs +410 -147
- package/index.d.cts +278 -10
- package/index.d.ts +278 -10
- 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 +236 -107
- 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.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;
|
|
@@ -1781,8 +1783,6 @@
|
|
|
1781
1783
|
*/
|
|
1782
1784
|
|
|
1783
1785
|
|
|
1784
|
-
const HTTP_HEADER_CONTENT_TYPE = "Content-Type";
|
|
1785
|
-
|
|
1786
1786
|
function toCompatibleReadable(readable) {
|
|
1787
1787
|
if (readable instanceof ReadableStream) {
|
|
1788
1788
|
return readable;
|
|
@@ -1805,12 +1805,9 @@
|
|
|
1805
1805
|
|
|
1806
1806
|
function streamToBlob(readable, contentType) {
|
|
1807
1807
|
readable = toCompatibleReadable(readable);
|
|
1808
|
+
const blobOptions = contentType ? { type: contentType } : {};
|
|
1808
1809
|
if (responseSupportsGlobalReadable()) {
|
|
1809
|
-
|
|
1810
|
-
if (contentType) {
|
|
1811
|
-
options.headers = [[HTTP_HEADER_CONTENT_TYPE, contentType]];
|
|
1812
|
-
}
|
|
1813
|
-
return new Response(readable, options).blob();
|
|
1810
|
+
return new Response(readable).blob().then(blob => contentType ? new Blob([blob], blobOptions) : blob);
|
|
1814
1811
|
}
|
|
1815
1812
|
const chunks = [];
|
|
1816
1813
|
return readable
|
|
@@ -1819,7 +1816,7 @@
|
|
|
1819
1816
|
chunks.push(chunk);
|
|
1820
1817
|
}
|
|
1821
1818
|
}))
|
|
1822
|
-
.then(() => new Blob(chunks,
|
|
1819
|
+
.then(() => new Blob(chunks, blobOptions));
|
|
1823
1820
|
}
|
|
1824
1821
|
|
|
1825
1822
|
function responseSupportsGlobalReadable() {
|
|
@@ -3354,8 +3351,10 @@
|
|
|
3354
3351
|
async pull(controller) {
|
|
3355
3352
|
const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
|
|
3356
3353
|
const data = await readUint8Array(reader, offset + chunkOffset, dataSize);
|
|
3357
|
-
|
|
3358
|
-
|
|
3354
|
+
if (data.length) {
|
|
3355
|
+
controller.enqueue(data);
|
|
3356
|
+
}
|
|
3357
|
+
if ((chunkOffset + chunkSize >= size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
|
|
3359
3358
|
controller.close();
|
|
3360
3359
|
} else {
|
|
3361
3360
|
chunkOffset += chunkSize;
|
|
@@ -3433,6 +3432,7 @@
|
|
|
3433
3432
|
constructor(contentType) {
|
|
3434
3433
|
super();
|
|
3435
3434
|
Object.assign(this, {
|
|
3435
|
+
contentType,
|
|
3436
3436
|
data: "data:" + (contentType || "") + ";base64,",
|
|
3437
3437
|
pending: []
|
|
3438
3438
|
});
|
|
@@ -3534,6 +3534,7 @@
|
|
|
3534
3534
|
return transformStream.writable;
|
|
3535
3535
|
}
|
|
3536
3536
|
});
|
|
3537
|
+
writer.contentType = contentType;
|
|
3537
3538
|
writer.blob = streamToBlob(transformStream.readable, contentType);
|
|
3538
3539
|
writer.blob.catch(() => { });
|
|
3539
3540
|
}
|
|
@@ -4213,6 +4214,10 @@
|
|
|
4213
4214
|
}
|
|
4214
4215
|
}
|
|
4215
4216
|
|
|
4217
|
+
function ownsWritable(writer) {
|
|
4218
|
+
return Boolean(writer && writer.getData);
|
|
4219
|
+
}
|
|
4220
|
+
|
|
4216
4221
|
function isHttpFamily(url) {
|
|
4217
4222
|
const { baseURI } = getConfiguration();
|
|
4218
4223
|
const { protocol } = new URL(url, baseURI);
|
|
@@ -4357,6 +4362,8 @@
|
|
|
4357
4362
|
const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
|
|
4358
4363
|
const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES = "internalFileAttributes";
|
|
4359
4364
|
const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttributes";
|
|
4365
|
+
const PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES = "internalFileAttribute";
|
|
4366
|
+
const PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttribute";
|
|
4360
4367
|
const PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW = "msdosAttributesRaw";
|
|
4361
4368
|
const PROPERTY_NAME_MSDOS_ATTRIBUTES = "msdosAttributes";
|
|
4362
4369
|
const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
|
|
@@ -4367,6 +4374,7 @@
|
|
|
4367
4374
|
const PROPERTY_NAME_ZIPCRYPTO = "zipCrypto";
|
|
4368
4375
|
const PROPERTY_NAME_DIRECTORY = "directory";
|
|
4369
4376
|
const PROPERTY_NAME_EXECUTABLE = "executable";
|
|
4377
|
+
const PROPERTY_NAME_SYMLINK = "symlink";
|
|
4370
4378
|
const PROPERTY_NAME_COMPRESSION_METHOD = "compressionMethod";
|
|
4371
4379
|
const PROPERTY_NAME_SIGNATURE = "signature";
|
|
4372
4380
|
const PROPERTY_NAME_CRC32 = "crc32";
|
|
@@ -4410,6 +4418,8 @@
|
|
|
4410
4418
|
PROPERTY_NAME_DISK_NUMBER_START,
|
|
4411
4419
|
PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES,
|
|
4412
4420
|
PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES,
|
|
4421
|
+
PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES,
|
|
4422
|
+
PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES,
|
|
4413
4423
|
PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW,
|
|
4414
4424
|
PROPERTY_NAME_MSDOS_ATTRIBUTES,
|
|
4415
4425
|
PROPERTY_NAME_MS_DOS_COMPATIBLE,
|
|
@@ -4420,6 +4430,7 @@
|
|
|
4420
4430
|
PROPERTY_NAME_ZIPCRYPTO,
|
|
4421
4431
|
PROPERTY_NAME_DIRECTORY,
|
|
4422
4432
|
PROPERTY_NAME_EXECUTABLE,
|
|
4433
|
+
PROPERTY_NAME_SYMLINK,
|
|
4423
4434
|
PROPERTY_NAME_COMPRESSION_METHOD,
|
|
4424
4435
|
PROPERTY_NAME_SIGNATURE,
|
|
4425
4436
|
PROPERTY_NAME_CRC32,
|
|
@@ -4882,15 +4893,18 @@
|
|
|
4882
4893
|
const setuid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETUID_MASK);
|
|
4883
4894
|
const setgid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETGID_MASK);
|
|
4884
4895
|
const sticky = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_STICKY_MASK);
|
|
4885
|
-
const
|
|
4896
|
+
const unixType = fileEntry.unixMode === UNDEFINED_VALUE ? unixExternalUpper : fileEntry.unixMode;
|
|
4897
|
+
const symlink = (unixType & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK;
|
|
4898
|
+
const executable = !symlink && ((fileEntry.unixMode !== UNDEFINED_VALUE)
|
|
4886
4899
|
? ((fileEntry.unixMode & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)
|
|
4887
|
-
: (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0));
|
|
4900
|
+
: (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)));
|
|
4888
4901
|
const modeIsDir = fileEntry.unixMode !== UNDEFINED_VALUE && ((fileEntry.unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
|
|
4889
4902
|
const upperIsDir = ((unixExternalUpper & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
|
|
4890
4903
|
Object.assign(fileEntry, {
|
|
4891
4904
|
setuid,
|
|
4892
4905
|
setgid,
|
|
4893
4906
|
sticky,
|
|
4907
|
+
symlink,
|
|
4894
4908
|
unixExternalUpper,
|
|
4895
4909
|
internalFileAttribute: fileEntry.internalFileAttributes,
|
|
4896
4910
|
externalFileAttribute: fileEntry.externalFileAttributes,
|
|
@@ -4956,6 +4970,10 @@
|
|
|
4956
4970
|
}
|
|
4957
4971
|
|
|
4958
4972
|
async close() {
|
|
4973
|
+
const { reader } = this;
|
|
4974
|
+
if (!reader.readUint8Array && reader.readable && !reader.readable.locked) {
|
|
4975
|
+
await reader.readable.cancel();
|
|
4976
|
+
}
|
|
4959
4977
|
}
|
|
4960
4978
|
}
|
|
4961
4979
|
|
|
@@ -5180,7 +5198,7 @@
|
|
|
5180
5198
|
throw error;
|
|
5181
5199
|
}
|
|
5182
5200
|
} finally {
|
|
5183
|
-
const preventClose = getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
|
|
5201
|
+
const preventClose = !ownsWritable(writer) && getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
|
|
5184
5202
|
if (!preventClose && writable && !writable.locked) {
|
|
5185
5203
|
const writableWriter = writable.getWriter();
|
|
5186
5204
|
if (abortError) {
|
|
@@ -5424,8 +5442,8 @@
|
|
|
5424
5442
|
return;
|
|
5425
5443
|
}
|
|
5426
5444
|
const extraFieldView = getDataView(extraField.data);
|
|
5427
|
-
const lastAccessDate = new Date(getUint32(extraFieldView, 0) * 1000);
|
|
5428
|
-
const lastModDate = new Date(getUint32(extraFieldView, 4) * 1000);
|
|
5445
|
+
const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
|
|
5446
|
+
const lastModDate = new Date((getUint32(extraFieldView, 4) | 0) * 1000);
|
|
5429
5447
|
const extraFieldData = { lastAccessDate, lastModDate };
|
|
5430
5448
|
if (extraField.data.length >= 12) {
|
|
5431
5449
|
extraFieldData.uid = getUint16(extraFieldView, 8);
|
|
@@ -5856,6 +5874,7 @@
|
|
|
5856
5874
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
5857
5875
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
5858
5876
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
5877
|
+
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
5859
5878
|
const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
|
|
5860
5879
|
const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
|
|
5861
5880
|
const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
|
|
@@ -5865,6 +5884,7 @@
|
|
|
5865
5884
|
const MAX_NTFS_TIME = BigInt("0x7fffffffffffffff");
|
|
5866
5885
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
|
|
5867
5886
|
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
5887
|
+
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
5868
5888
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
5869
5889
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
5870
5890
|
const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
|
|
@@ -6072,7 +6092,7 @@
|
|
|
6072
6092
|
await Promise.allSettled(Array.from(pendingAddFileCalls));
|
|
6073
6093
|
}
|
|
6074
6094
|
await closeFile(zipWriter, comment, options);
|
|
6075
|
-
const preventClose = getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
|
|
6095
|
+
const preventClose = !ownsWritable(writer) && getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
|
|
6076
6096
|
if (!preventClose) {
|
|
6077
6097
|
await writable.getWriter().close();
|
|
6078
6098
|
}
|
|
@@ -6231,7 +6251,7 @@
|
|
|
6231
6251
|
if (versionMadeBy > MAX_16_BITS) {
|
|
6232
6252
|
throw new Error(ERR_INVALID_VERSION);
|
|
6233
6253
|
}
|
|
6234
|
-
let externalFileAttributes =
|
|
6254
|
+
let externalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES);
|
|
6235
6255
|
const externalFileAttributesProvided = externalFileAttributes !== UNDEFINED_VALUE;
|
|
6236
6256
|
if (!externalFileAttributesProvided) {
|
|
6237
6257
|
externalFileAttributes = 0;
|
|
@@ -6279,7 +6299,9 @@
|
|
|
6279
6299
|
}
|
|
6280
6300
|
if (!externalFileAttributesProvided || unixModeProvided) {
|
|
6281
6301
|
if (directory) {
|
|
6282
|
-
unixMode
|
|
6302
|
+
unixMode = (unixMode & ~FILE_ATTR_UNIX_TYPE_MASK) | FILE_ATTR_UNIX_TYPE_DIR;
|
|
6303
|
+
} else if (!(unixMode & FILE_ATTR_UNIX_TYPE_MASK)) {
|
|
6304
|
+
unixMode |= FILE_ATTR_UNIX_TYPE_FILE;
|
|
6283
6305
|
}
|
|
6284
6306
|
externalFileAttributes = ((unixMode & MAX_16_BITS) << 16) | (externalFileAttributes & MAX_16_BITS);
|
|
6285
6307
|
}
|
|
@@ -6332,15 +6354,12 @@
|
|
|
6332
6354
|
const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
|
|
6333
6355
|
const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
6334
6356
|
const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
6335
|
-
const internalFileAttributes =
|
|
6357
|
+
const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
|
|
6336
6358
|
const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
6342
|
-
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
6343
|
-
}
|
|
6359
|
+
const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
6360
|
+
const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
6361
|
+
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
6362
|
+
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
6344
6363
|
}
|
|
6345
6364
|
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
6346
6365
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
@@ -6453,14 +6472,24 @@
|
|
|
6453
6472
|
}
|
|
6454
6473
|
|
|
6455
6474
|
async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, options) {
|
|
6475
|
+
if (metadata.passThrough && !reader && !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY)) {
|
|
6476
|
+
throw new Error(ERR_UNDEFINED_READER);
|
|
6477
|
+
}
|
|
6478
|
+
let contentSize;
|
|
6479
|
+
if (reader) {
|
|
6480
|
+
reader = new GenericReader(reader);
|
|
6481
|
+
await initStream(reader);
|
|
6482
|
+
({ size: contentSize } = reader);
|
|
6483
|
+
}
|
|
6484
|
+
return Object.assign({ reader }, resolveEntrySizes(zipWriter, Boolean(reader), contentSize, metadata, options));
|
|
6485
|
+
}
|
|
6486
|
+
|
|
6487
|
+
function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options) {
|
|
6456
6488
|
const { passThrough, zipCrypto, password, rawPassword, encryptionStrength } = metadata;
|
|
6457
6489
|
let { dataDescriptor, zip64, level, compressionMethod } = metadata;
|
|
6458
6490
|
let maximumCompressedSize = 0;
|
|
6459
6491
|
let uncompressedSize = 0;
|
|
6460
|
-
if (passThrough) {
|
|
6461
|
-
if (!reader) {
|
|
6462
|
-
throw new Error(ERR_UNDEFINED_READER);
|
|
6463
|
-
}
|
|
6492
|
+
if (passThrough && hasContent) {
|
|
6464
6493
|
uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
|
|
6465
6494
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
6466
6495
|
throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
|
|
@@ -6468,29 +6497,30 @@
|
|
|
6468
6497
|
}
|
|
6469
6498
|
const zip64Enabled = zip64 === true;
|
|
6470
6499
|
const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
|
|
6471
|
-
|
|
6472
|
-
|
|
6500
|
+
if (hasContent && passThrough && !encrypted && getLength(password, rawPassword)) {
|
|
6501
|
+
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH);
|
|
6502
|
+
}
|
|
6503
|
+
const encryptedEntry = hasContent && (Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted));
|
|
6504
|
+
if (!hasContent) {
|
|
6473
6505
|
level = 0;
|
|
6474
6506
|
compressionMethod = COMPRESSION_METHOD_STORE;
|
|
6475
6507
|
}
|
|
6476
6508
|
const encryptionOverhead = encryptedEntry ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
|
|
6477
|
-
if (
|
|
6478
|
-
reader = new GenericReader(reader);
|
|
6479
|
-
await initStream(reader);
|
|
6509
|
+
if (hasContent) {
|
|
6480
6510
|
if (!passThrough) {
|
|
6481
|
-
if (
|
|
6511
|
+
if (contentSize === UNDEFINED_VALUE) {
|
|
6482
6512
|
dataDescriptor = true;
|
|
6483
6513
|
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
6484
6514
|
zip64 = true;
|
|
6485
6515
|
uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
|
|
6486
6516
|
}
|
|
6487
6517
|
} else {
|
|
6488
|
-
options.uncompressedSize = uncompressedSize =
|
|
6489
|
-
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize) + encryptionOverhead;
|
|
6518
|
+
options.uncompressedSize = uncompressedSize = contentSize;
|
|
6519
|
+
maximumCompressedSize = (isCompressed(compressionMethod, level) ? getMaximumCompressedSize(uncompressedSize) : uncompressedSize) + encryptionOverhead;
|
|
6490
6520
|
}
|
|
6491
6521
|
} else {
|
|
6492
6522
|
options.uncompressedSize = uncompressedSize;
|
|
6493
|
-
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize) + encryptionOverhead;
|
|
6523
|
+
maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
|
|
6494
6524
|
}
|
|
6495
6525
|
}
|
|
6496
6526
|
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
@@ -6504,7 +6534,7 @@
|
|
|
6504
6534
|
}
|
|
6505
6535
|
zip64 = zip64 || false;
|
|
6506
6536
|
return {
|
|
6507
|
-
|
|
6537
|
+
maximumCompressedSize,
|
|
6508
6538
|
resolvedOptions: {
|
|
6509
6539
|
dataDescriptor,
|
|
6510
6540
|
zip64,
|
|
@@ -6889,9 +6919,7 @@
|
|
|
6889
6919
|
crc32
|
|
6890
6920
|
} = options;
|
|
6891
6921
|
let { version, compressionMethod } = options;
|
|
6892
|
-
const compressed = !directory && (compressionMethod
|
|
6893
|
-
? (level === UNDEFINED_VALUE || level > 0)
|
|
6894
|
-
: compressionMethod !== COMPRESSION_METHOD_STORE);
|
|
6922
|
+
const compressed = !directory && isCompressed(compressionMethod, level);
|
|
6895
6923
|
let rawLocalExtraFieldZip64;
|
|
6896
6924
|
const uncompressedFile = passThrough || !compressed;
|
|
6897
6925
|
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
|
|
@@ -7578,6 +7606,16 @@
|
|
|
7578
7606
|
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
7579
7607
|
}
|
|
7580
7608
|
|
|
7609
|
+
function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
|
|
7610
|
+
const value = getAliasedValue(options, name, deprecatedName);
|
|
7611
|
+
const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
|
|
7612
|
+
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
7613
|
+
}
|
|
7614
|
+
|
|
7615
|
+
function getAliasedValue(options, name, deprecatedName) {
|
|
7616
|
+
return options[name] === UNDEFINED_VALUE ? options[deprecatedName] : options[name];
|
|
7617
|
+
}
|
|
7618
|
+
|
|
7581
7619
|
function getNumberOptionValue(zipWriter, options, name, defaultValue) {
|
|
7582
7620
|
return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
|
|
7583
7621
|
}
|
|
@@ -7590,6 +7628,12 @@
|
|
|
7590
7628
|
return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
|
|
7591
7629
|
}
|
|
7592
7630
|
|
|
7631
|
+
function isCompressed(compressionMethod, level) {
|
|
7632
|
+
return compressionMethod === UNDEFINED_VALUE
|
|
7633
|
+
? (level === UNDEFINED_VALUE || level > 0)
|
|
7634
|
+
: compressionMethod !== COMPRESSION_METHOD_STORE;
|
|
7635
|
+
}
|
|
7636
|
+
|
|
7593
7637
|
function setUint8(view, offset, value) {
|
|
7594
7638
|
view.setUint8(offset, value);
|
|
7595
7639
|
}
|
|
@@ -8653,11 +8697,13 @@
|
|
|
8653
8697
|
exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
|
|
8654
8698
|
exports.ERR_UNDEFINED_READER = ERR_UNDEFINED_READER;
|
|
8655
8699
|
exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
|
|
8700
|
+
exports.ERR_UNDETERMINED_SIZE = ERR_UNDETERMINED_SIZE;
|
|
8656
8701
|
exports.ERR_UNSAFE_FILENAME = ERR_UNSAFE_FILENAME;
|
|
8657
8702
|
exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION$1;
|
|
8658
8703
|
exports.ERR_UNSUPPORTED_CONTEXT = ERR_UNSUPPORTED_CONTEXT;
|
|
8659
8704
|
exports.ERR_UNSUPPORTED_CRYPTO_API = ERR_UNSUPPORTED_CRYPTO_API;
|
|
8660
8705
|
exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
|
|
8706
|
+
exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
|
|
8661
8707
|
exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
|
|
8662
8708
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
8663
8709
|
exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
|