@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-legacy.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() {
|
|
@@ -3350,8 +3347,10 @@
|
|
|
3350
3347
|
async pull(controller) {
|
|
3351
3348
|
const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
|
|
3352
3349
|
const data = await readUint8Array(reader, offset + chunkOffset, dataSize);
|
|
3353
|
-
|
|
3354
|
-
|
|
3350
|
+
if (data.length) {
|
|
3351
|
+
controller.enqueue(data);
|
|
3352
|
+
}
|
|
3353
|
+
if ((chunkOffset + chunkSize >= size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
|
|
3355
3354
|
controller.close();
|
|
3356
3355
|
} else {
|
|
3357
3356
|
chunkOffset += chunkSize;
|
|
@@ -3429,6 +3428,7 @@
|
|
|
3429
3428
|
constructor(contentType) {
|
|
3430
3429
|
super();
|
|
3431
3430
|
Object.assign(this, {
|
|
3431
|
+
contentType,
|
|
3432
3432
|
data: "data:" + (contentType || "") + ";base64,",
|
|
3433
3433
|
pending: []
|
|
3434
3434
|
});
|
|
@@ -3530,6 +3530,7 @@
|
|
|
3530
3530
|
return transformStream.writable;
|
|
3531
3531
|
}
|
|
3532
3532
|
});
|
|
3533
|
+
writer.contentType = contentType;
|
|
3533
3534
|
writer.blob = streamToBlob(transformStream.readable, contentType);
|
|
3534
3535
|
writer.blob.catch(() => { });
|
|
3535
3536
|
}
|
|
@@ -4209,6 +4210,10 @@
|
|
|
4209
4210
|
}
|
|
4210
4211
|
}
|
|
4211
4212
|
|
|
4213
|
+
function ownsWritable(writer) {
|
|
4214
|
+
return Boolean(writer && writer.getData);
|
|
4215
|
+
}
|
|
4216
|
+
|
|
4212
4217
|
function isHttpFamily(url) {
|
|
4213
4218
|
const { baseURI } = getConfiguration();
|
|
4214
4219
|
const { protocol } = new URL(url, baseURI);
|
|
@@ -4353,6 +4358,8 @@
|
|
|
4353
4358
|
const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
|
|
4354
4359
|
const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES = "internalFileAttributes";
|
|
4355
4360
|
const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttributes";
|
|
4361
|
+
const PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES = "internalFileAttribute";
|
|
4362
|
+
const PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttribute";
|
|
4356
4363
|
const PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW = "msdosAttributesRaw";
|
|
4357
4364
|
const PROPERTY_NAME_MSDOS_ATTRIBUTES = "msdosAttributes";
|
|
4358
4365
|
const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
|
|
@@ -4363,6 +4370,7 @@
|
|
|
4363
4370
|
const PROPERTY_NAME_ZIPCRYPTO = "zipCrypto";
|
|
4364
4371
|
const PROPERTY_NAME_DIRECTORY = "directory";
|
|
4365
4372
|
const PROPERTY_NAME_EXECUTABLE = "executable";
|
|
4373
|
+
const PROPERTY_NAME_SYMLINK = "symlink";
|
|
4366
4374
|
const PROPERTY_NAME_COMPRESSION_METHOD = "compressionMethod";
|
|
4367
4375
|
const PROPERTY_NAME_SIGNATURE = "signature";
|
|
4368
4376
|
const PROPERTY_NAME_CRC32 = "crc32";
|
|
@@ -4406,6 +4414,8 @@
|
|
|
4406
4414
|
PROPERTY_NAME_DISK_NUMBER_START,
|
|
4407
4415
|
PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES,
|
|
4408
4416
|
PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES,
|
|
4417
|
+
PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES,
|
|
4418
|
+
PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES,
|
|
4409
4419
|
PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW,
|
|
4410
4420
|
PROPERTY_NAME_MSDOS_ATTRIBUTES,
|
|
4411
4421
|
PROPERTY_NAME_MS_DOS_COMPATIBLE,
|
|
@@ -4416,6 +4426,7 @@
|
|
|
4416
4426
|
PROPERTY_NAME_ZIPCRYPTO,
|
|
4417
4427
|
PROPERTY_NAME_DIRECTORY,
|
|
4418
4428
|
PROPERTY_NAME_EXECUTABLE,
|
|
4429
|
+
PROPERTY_NAME_SYMLINK,
|
|
4419
4430
|
PROPERTY_NAME_COMPRESSION_METHOD,
|
|
4420
4431
|
PROPERTY_NAME_SIGNATURE,
|
|
4421
4432
|
PROPERTY_NAME_CRC32,
|
|
@@ -4878,15 +4889,18 @@
|
|
|
4878
4889
|
const setuid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETUID_MASK);
|
|
4879
4890
|
const setgid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETGID_MASK);
|
|
4880
4891
|
const sticky = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_STICKY_MASK);
|
|
4881
|
-
const
|
|
4892
|
+
const unixType = fileEntry.unixMode === UNDEFINED_VALUE ? unixExternalUpper : fileEntry.unixMode;
|
|
4893
|
+
const symlink = (unixType & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK;
|
|
4894
|
+
const executable = !symlink && ((fileEntry.unixMode !== UNDEFINED_VALUE)
|
|
4882
4895
|
? ((fileEntry.unixMode & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)
|
|
4883
|
-
: (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0));
|
|
4896
|
+
: (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)));
|
|
4884
4897
|
const modeIsDir = fileEntry.unixMode !== UNDEFINED_VALUE && ((fileEntry.unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
|
|
4885
4898
|
const upperIsDir = ((unixExternalUpper & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
|
|
4886
4899
|
Object.assign(fileEntry, {
|
|
4887
4900
|
setuid,
|
|
4888
4901
|
setgid,
|
|
4889
4902
|
sticky,
|
|
4903
|
+
symlink,
|
|
4890
4904
|
unixExternalUpper,
|
|
4891
4905
|
internalFileAttribute: fileEntry.internalFileAttributes,
|
|
4892
4906
|
externalFileAttribute: fileEntry.externalFileAttributes,
|
|
@@ -4952,6 +4966,10 @@
|
|
|
4952
4966
|
}
|
|
4953
4967
|
|
|
4954
4968
|
async close() {
|
|
4969
|
+
const { reader } = this;
|
|
4970
|
+
if (!reader.readUint8Array && reader.readable && !reader.readable.locked) {
|
|
4971
|
+
await reader.readable.cancel();
|
|
4972
|
+
}
|
|
4955
4973
|
}
|
|
4956
4974
|
}
|
|
4957
4975
|
|
|
@@ -5176,7 +5194,7 @@
|
|
|
5176
5194
|
throw error;
|
|
5177
5195
|
}
|
|
5178
5196
|
} finally {
|
|
5179
|
-
const preventClose = getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
|
|
5197
|
+
const preventClose = !ownsWritable(writer) && getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
|
|
5180
5198
|
if (!preventClose && writable && !writable.locked) {
|
|
5181
5199
|
const writableWriter = writable.getWriter();
|
|
5182
5200
|
if (abortError) {
|
|
@@ -5420,8 +5438,8 @@
|
|
|
5420
5438
|
return;
|
|
5421
5439
|
}
|
|
5422
5440
|
const extraFieldView = getDataView(extraField.data);
|
|
5423
|
-
const lastAccessDate = new Date(getUint32(extraFieldView, 0) * 1000);
|
|
5424
|
-
const lastModDate = new Date(getUint32(extraFieldView, 4) * 1000);
|
|
5441
|
+
const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
|
|
5442
|
+
const lastModDate = new Date((getUint32(extraFieldView, 4) | 0) * 1000);
|
|
5425
5443
|
const extraFieldData = { lastAccessDate, lastModDate };
|
|
5426
5444
|
if (extraField.data.length >= 12) {
|
|
5427
5445
|
extraFieldData.uid = getUint16(extraFieldView, 8);
|
|
@@ -5852,6 +5870,7 @@
|
|
|
5852
5870
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
5853
5871
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
5854
5872
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
5873
|
+
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
5855
5874
|
const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
|
|
5856
5875
|
const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
|
|
5857
5876
|
const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
|
|
@@ -5861,6 +5880,7 @@
|
|
|
5861
5880
|
const MAX_NTFS_TIME = BigInt("0x7fffffffffffffff");
|
|
5862
5881
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
|
|
5863
5882
|
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
5883
|
+
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
5864
5884
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
5865
5885
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
5866
5886
|
const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
|
|
@@ -6068,7 +6088,7 @@
|
|
|
6068
6088
|
await Promise.allSettled(Array.from(pendingAddFileCalls));
|
|
6069
6089
|
}
|
|
6070
6090
|
await closeFile(zipWriter, comment, options);
|
|
6071
|
-
const preventClose = getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
|
|
6091
|
+
const preventClose = !ownsWritable(writer) && getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
|
|
6072
6092
|
if (!preventClose) {
|
|
6073
6093
|
await writable.getWriter().close();
|
|
6074
6094
|
}
|
|
@@ -6227,7 +6247,7 @@
|
|
|
6227
6247
|
if (versionMadeBy > MAX_16_BITS) {
|
|
6228
6248
|
throw new Error(ERR_INVALID_VERSION);
|
|
6229
6249
|
}
|
|
6230
|
-
let externalFileAttributes =
|
|
6250
|
+
let externalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES);
|
|
6231
6251
|
const externalFileAttributesProvided = externalFileAttributes !== UNDEFINED_VALUE;
|
|
6232
6252
|
if (!externalFileAttributesProvided) {
|
|
6233
6253
|
externalFileAttributes = 0;
|
|
@@ -6275,7 +6295,9 @@
|
|
|
6275
6295
|
}
|
|
6276
6296
|
if (!externalFileAttributesProvided || unixModeProvided) {
|
|
6277
6297
|
if (directory) {
|
|
6278
|
-
unixMode
|
|
6298
|
+
unixMode = (unixMode & ~FILE_ATTR_UNIX_TYPE_MASK) | FILE_ATTR_UNIX_TYPE_DIR;
|
|
6299
|
+
} else if (!(unixMode & FILE_ATTR_UNIX_TYPE_MASK)) {
|
|
6300
|
+
unixMode |= FILE_ATTR_UNIX_TYPE_FILE;
|
|
6279
6301
|
}
|
|
6280
6302
|
externalFileAttributes = ((unixMode & MAX_16_BITS) << 16) | (externalFileAttributes & MAX_16_BITS);
|
|
6281
6303
|
}
|
|
@@ -6328,15 +6350,12 @@
|
|
|
6328
6350
|
const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
|
|
6329
6351
|
const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
6330
6352
|
const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
6331
|
-
const internalFileAttributes =
|
|
6353
|
+
const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
|
|
6332
6354
|
const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
6338
|
-
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
6339
|
-
}
|
|
6355
|
+
const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
6356
|
+
const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
6357
|
+
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
6358
|
+
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
6340
6359
|
}
|
|
6341
6360
|
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
6342
6361
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
@@ -6449,14 +6468,24 @@
|
|
|
6449
6468
|
}
|
|
6450
6469
|
|
|
6451
6470
|
async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, options) {
|
|
6471
|
+
if (metadata.passThrough && !reader && !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY)) {
|
|
6472
|
+
throw new Error(ERR_UNDEFINED_READER);
|
|
6473
|
+
}
|
|
6474
|
+
let contentSize;
|
|
6475
|
+
if (reader) {
|
|
6476
|
+
reader = new GenericReader(reader);
|
|
6477
|
+
await initStream(reader);
|
|
6478
|
+
({ size: contentSize } = reader);
|
|
6479
|
+
}
|
|
6480
|
+
return Object.assign({ reader }, resolveEntrySizes(zipWriter, Boolean(reader), contentSize, metadata, options));
|
|
6481
|
+
}
|
|
6482
|
+
|
|
6483
|
+
function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options) {
|
|
6452
6484
|
const { passThrough, zipCrypto, password, rawPassword, encryptionStrength } = metadata;
|
|
6453
6485
|
let { dataDescriptor, zip64, level, compressionMethod } = metadata;
|
|
6454
6486
|
let maximumCompressedSize = 0;
|
|
6455
6487
|
let uncompressedSize = 0;
|
|
6456
|
-
if (passThrough) {
|
|
6457
|
-
if (!reader) {
|
|
6458
|
-
throw new Error(ERR_UNDEFINED_READER);
|
|
6459
|
-
}
|
|
6488
|
+
if (passThrough && hasContent) {
|
|
6460
6489
|
uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
|
|
6461
6490
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
6462
6491
|
throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
|
|
@@ -6464,29 +6493,30 @@
|
|
|
6464
6493
|
}
|
|
6465
6494
|
const zip64Enabled = zip64 === true;
|
|
6466
6495
|
const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
|
|
6467
|
-
|
|
6468
|
-
|
|
6496
|
+
if (hasContent && passThrough && !encrypted && getLength(password, rawPassword)) {
|
|
6497
|
+
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH);
|
|
6498
|
+
}
|
|
6499
|
+
const encryptedEntry = hasContent && (Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted));
|
|
6500
|
+
if (!hasContent) {
|
|
6469
6501
|
level = 0;
|
|
6470
6502
|
compressionMethod = COMPRESSION_METHOD_STORE;
|
|
6471
6503
|
}
|
|
6472
6504
|
const encryptionOverhead = encryptedEntry ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
|
|
6473
|
-
if (
|
|
6474
|
-
reader = new GenericReader(reader);
|
|
6475
|
-
await initStream(reader);
|
|
6505
|
+
if (hasContent) {
|
|
6476
6506
|
if (!passThrough) {
|
|
6477
|
-
if (
|
|
6507
|
+
if (contentSize === UNDEFINED_VALUE) {
|
|
6478
6508
|
dataDescriptor = true;
|
|
6479
6509
|
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
6480
6510
|
zip64 = true;
|
|
6481
6511
|
uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
|
|
6482
6512
|
}
|
|
6483
6513
|
} else {
|
|
6484
|
-
options.uncompressedSize = uncompressedSize =
|
|
6485
|
-
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize) + encryptionOverhead;
|
|
6514
|
+
options.uncompressedSize = uncompressedSize = contentSize;
|
|
6515
|
+
maximumCompressedSize = (isCompressed(compressionMethod, level) ? getMaximumCompressedSize(uncompressedSize) : uncompressedSize) + encryptionOverhead;
|
|
6486
6516
|
}
|
|
6487
6517
|
} else {
|
|
6488
6518
|
options.uncompressedSize = uncompressedSize;
|
|
6489
|
-
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize) + encryptionOverhead;
|
|
6519
|
+
maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
|
|
6490
6520
|
}
|
|
6491
6521
|
}
|
|
6492
6522
|
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
@@ -6500,7 +6530,7 @@
|
|
|
6500
6530
|
}
|
|
6501
6531
|
zip64 = zip64 || false;
|
|
6502
6532
|
return {
|
|
6503
|
-
|
|
6533
|
+
maximumCompressedSize,
|
|
6504
6534
|
resolvedOptions: {
|
|
6505
6535
|
dataDescriptor,
|
|
6506
6536
|
zip64,
|
|
@@ -6885,9 +6915,7 @@
|
|
|
6885
6915
|
crc32
|
|
6886
6916
|
} = options;
|
|
6887
6917
|
let { version, compressionMethod } = options;
|
|
6888
|
-
const compressed = !directory && (compressionMethod
|
|
6889
|
-
? (level === UNDEFINED_VALUE || level > 0)
|
|
6890
|
-
: compressionMethod !== COMPRESSION_METHOD_STORE);
|
|
6918
|
+
const compressed = !directory && isCompressed(compressionMethod, level);
|
|
6891
6919
|
let rawLocalExtraFieldZip64;
|
|
6892
6920
|
const uncompressedFile = passThrough || !compressed;
|
|
6893
6921
|
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
|
|
@@ -7574,6 +7602,16 @@
|
|
|
7574
7602
|
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
7575
7603
|
}
|
|
7576
7604
|
|
|
7605
|
+
function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
|
|
7606
|
+
const value = getAliasedValue(options, name, deprecatedName);
|
|
7607
|
+
const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
|
|
7608
|
+
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
7609
|
+
}
|
|
7610
|
+
|
|
7611
|
+
function getAliasedValue(options, name, deprecatedName) {
|
|
7612
|
+
return options[name] === UNDEFINED_VALUE ? options[deprecatedName] : options[name];
|
|
7613
|
+
}
|
|
7614
|
+
|
|
7577
7615
|
function getNumberOptionValue(zipWriter, options, name, defaultValue) {
|
|
7578
7616
|
return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
|
|
7579
7617
|
}
|
|
@@ -7586,6 +7624,12 @@
|
|
|
7586
7624
|
return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
|
|
7587
7625
|
}
|
|
7588
7626
|
|
|
7627
|
+
function isCompressed(compressionMethod, level) {
|
|
7628
|
+
return compressionMethod === UNDEFINED_VALUE
|
|
7629
|
+
? (level === UNDEFINED_VALUE || level > 0)
|
|
7630
|
+
: compressionMethod !== COMPRESSION_METHOD_STORE;
|
|
7631
|
+
}
|
|
7632
|
+
|
|
7589
7633
|
function setUint8(view, offset, value) {
|
|
7590
7634
|
view.setUint8(offset, value);
|
|
7591
7635
|
}
|
|
@@ -8246,11 +8290,13 @@
|
|
|
8246
8290
|
exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
|
|
8247
8291
|
exports.ERR_UNDEFINED_READER = ERR_UNDEFINED_READER;
|
|
8248
8292
|
exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
|
|
8293
|
+
exports.ERR_UNDETERMINED_SIZE = ERR_UNDETERMINED_SIZE;
|
|
8249
8294
|
exports.ERR_UNSAFE_FILENAME = ERR_UNSAFE_FILENAME;
|
|
8250
8295
|
exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION$1;
|
|
8251
8296
|
exports.ERR_UNSUPPORTED_CONTEXT = ERR_UNSUPPORTED_CONTEXT;
|
|
8252
8297
|
exports.ERR_UNSUPPORTED_CRYPTO_API = ERR_UNSUPPORTED_CRYPTO_API;
|
|
8253
8298
|
exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
|
|
8299
|
+
exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
|
|
8254
8300
|
exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
|
|
8255
8301
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
8256
8302
|
exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
|