@zip.js/zip.js 2.7.51 → 2.7.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/dist/zip-fs-full.js +20 -18
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +20 -18
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +11 -10
- package/dist/zip-full.min.js +1 -1
- package/dist/zip-no-worker-deflate.min.js +1 -1
- package/dist/zip-no-worker-inflate.min.js +1 -1
- package/dist/zip-no-worker.min.js +1 -1
- package/dist/zip.js +11 -10
- package/dist/zip.min.js +1 -1
- package/index.cjs +20 -18
- package/index.d.ts +11 -3
- package/index.min.js +1 -1
- package/lib/core/zip-fs-core.js +9 -8
- package/lib/core/zip-reader.js +3 -3
- package/lib/core/zip-writer.js +8 -7
- package/package.json +1 -1
package/lib/core/zip-fs-core.js
CHANGED
|
@@ -742,13 +742,6 @@ async function exportZip(zipWriter, entry, totalSize, options) {
|
|
|
742
742
|
compressionMethod,
|
|
743
743
|
extraFieldAES
|
|
744
744
|
} = child.data;
|
|
745
|
-
let level, encryptionStrength;
|
|
746
|
-
if (compressionMethod === 0) {
|
|
747
|
-
level = 0;
|
|
748
|
-
}
|
|
749
|
-
if (extraFieldAES) {
|
|
750
|
-
encryptionStrength = extraFieldAES.strength;
|
|
751
|
-
}
|
|
752
745
|
zipEntryOptions = {
|
|
753
746
|
externalFileAttribute,
|
|
754
747
|
versionMadeBy,
|
|
@@ -758,6 +751,13 @@ async function exportZip(zipWriter, entry, totalSize, options) {
|
|
|
758
751
|
lastAccessDate
|
|
759
752
|
};
|
|
760
753
|
if (child.passThrough) {
|
|
754
|
+
let level, encryptionStrength;
|
|
755
|
+
if (compressionMethod === 0) {
|
|
756
|
+
level = 0;
|
|
757
|
+
}
|
|
758
|
+
if (extraFieldAES) {
|
|
759
|
+
encryptionStrength = extraFieldAES.strength;
|
|
760
|
+
}
|
|
761
761
|
zipEntryOptions = Object.assign(zipEntryOptions, {
|
|
762
762
|
passThrough: true,
|
|
763
763
|
encrypted,
|
|
@@ -765,7 +765,8 @@ async function exportZip(zipWriter, entry, totalSize, options) {
|
|
|
765
765
|
signature,
|
|
766
766
|
uncompressedSize,
|
|
767
767
|
level,
|
|
768
|
-
encryptionStrength
|
|
768
|
+
encryptionStrength,
|
|
769
|
+
compressionMethod
|
|
769
770
|
});
|
|
770
771
|
}
|
|
771
772
|
}
|
package/lib/core/zip-reader.js
CHANGED
|
@@ -407,6 +407,7 @@ class ZipEntry {
|
|
|
407
407
|
const dataView = getDataView(dataArray);
|
|
408
408
|
let password = getOptionValue(zipEntry, options, "password");
|
|
409
409
|
let rawPassword = getOptionValue(zipEntry, options, "rawPassword");
|
|
410
|
+
const passThrough = getOptionValue(zipEntry, options, "passThrough");
|
|
410
411
|
password = password && password.length && password;
|
|
411
412
|
rawPassword = rawPassword && rawPassword.length && rawPassword;
|
|
412
413
|
if (extraFieldAES) {
|
|
@@ -414,7 +415,7 @@ class ZipEntry {
|
|
|
414
415
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
415
416
|
}
|
|
416
417
|
}
|
|
417
|
-
if (compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE) {
|
|
418
|
+
if ((compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE) && !passThrough) {
|
|
418
419
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
419
420
|
}
|
|
420
421
|
if (getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
|
|
@@ -429,7 +430,6 @@ class ZipEntry {
|
|
|
429
430
|
lastAccessDate: localDirectory.lastAccessDate,
|
|
430
431
|
creationDate: localDirectory.creationDate
|
|
431
432
|
});
|
|
432
|
-
const passThrough = getOptionValue(zipEntry, options, "passThrough");
|
|
433
433
|
const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
|
|
434
434
|
const zipCrypto = encrypted && !extraFieldAES;
|
|
435
435
|
if (!passThrough) {
|
|
@@ -456,7 +456,7 @@ class ZipEntry {
|
|
|
456
456
|
writer = new WritableStream();
|
|
457
457
|
}
|
|
458
458
|
writer = initWriter(writer);
|
|
459
|
-
await initStream(writer, uncompressedSize);
|
|
459
|
+
await initStream(writer, passThrough ? compressedSize : uncompressedSize);
|
|
460
460
|
const { writable } = writer;
|
|
461
461
|
const { onstart, onprogress, onend } = options;
|
|
462
462
|
const workerOptions = {
|
package/lib/core/zip-writer.js
CHANGED
|
@@ -277,6 +277,7 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
277
277
|
const signal = getOptionValue(zipWriter, options, "signal");
|
|
278
278
|
const useUnicodeFileNames = getOptionValue(zipWriter, options, "useUnicodeFileNames", true);
|
|
279
279
|
const useCompressionStream = getOptionValue(zipWriter, options, "useCompressionStream");
|
|
280
|
+
const compressionMethod = getOptionValue(zipWriter, options, "compressionMethod");
|
|
280
281
|
let dataDescriptor = getOptionValue(zipWriter, options, "dataDescriptor", true);
|
|
281
282
|
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
282
283
|
if (!zipCrypto && (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && !(encryptionStrength >= 1 && encryptionStrength <= 3)) {
|
|
@@ -379,7 +380,8 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
379
380
|
useCompressionStream,
|
|
380
381
|
passThrough,
|
|
381
382
|
encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
|
|
382
|
-
signature
|
|
383
|
+
signature,
|
|
384
|
+
compressionMethod
|
|
383
385
|
});
|
|
384
386
|
const headerInfo = getHeaderInfo(options);
|
|
385
387
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -727,7 +729,7 @@ function getHeaderInfo(options) {
|
|
|
727
729
|
encrypted
|
|
728
730
|
} = options;
|
|
729
731
|
const compressed = level !== 0 && !directory;
|
|
730
|
-
let version = options
|
|
732
|
+
let { version, compressionMethod } = options;
|
|
731
733
|
let rawExtraFieldAES;
|
|
732
734
|
if (encrypted && !zipCrypto) {
|
|
733
735
|
rawExtraFieldAES = new Uint8Array(getLength(EXTRAFIELD_DATA_AES) + 2);
|
|
@@ -782,9 +784,10 @@ function getHeaderInfo(options) {
|
|
|
782
784
|
if (dataDescriptor) {
|
|
783
785
|
bitFlag = bitFlag | BITFLAG_DATA_DESCRIPTOR;
|
|
784
786
|
}
|
|
785
|
-
|
|
787
|
+
if (compressionMethod === UNDEFINED_VALUE) {
|
|
788
|
+
compressionMethod = compressed ? COMPRESSION_METHOD_DEFLATE : COMPRESSION_METHOD_STORE;
|
|
789
|
+
}
|
|
786
790
|
if (compressed) {
|
|
787
|
-
compressionMethod = COMPRESSION_METHOD_DEFLATE;
|
|
788
791
|
if (level >= 1 && level < 3) {
|
|
789
792
|
bitFlag = bitFlag | 0b110;
|
|
790
793
|
}
|
|
@@ -802,10 +805,8 @@ function getHeaderInfo(options) {
|
|
|
802
805
|
bitFlag = bitFlag | BITFLAG_ENCRYPTED;
|
|
803
806
|
if (!zipCrypto) {
|
|
804
807
|
version = version > VERSION_AES ? version : VERSION_AES;
|
|
808
|
+
rawExtraFieldAES[9] = compressionMethod;
|
|
805
809
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
806
|
-
if (compressed) {
|
|
807
|
-
rawExtraFieldAES[9] = COMPRESSION_METHOD_DEFLATE;
|
|
808
|
-
}
|
|
809
810
|
}
|
|
810
811
|
}
|
|
811
812
|
const headerArray = new Uint8Array(26);
|
package/package.json
CHANGED