@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/index.cjs
CHANGED
|
@@ -9539,6 +9539,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
9539
9539
|
const dataView = getDataView$1(dataArray);
|
|
9540
9540
|
let password = getOptionValue$1(zipEntry, options, "password");
|
|
9541
9541
|
let rawPassword = getOptionValue$1(zipEntry, options, "rawPassword");
|
|
9542
|
+
const passThrough = getOptionValue$1(zipEntry, options, "passThrough");
|
|
9542
9543
|
password = password && password.length && password;
|
|
9543
9544
|
rawPassword = rawPassword && rawPassword.length && rawPassword;
|
|
9544
9545
|
if (extraFieldAES) {
|
|
@@ -9546,7 +9547,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
9546
9547
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
9547
9548
|
}
|
|
9548
9549
|
}
|
|
9549
|
-
if (compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE) {
|
|
9550
|
+
if ((compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE) && !passThrough) {
|
|
9550
9551
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
9551
9552
|
}
|
|
9552
9553
|
if (getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
|
|
@@ -9561,7 +9562,6 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
9561
9562
|
lastAccessDate: localDirectory.lastAccessDate,
|
|
9562
9563
|
creationDate: localDirectory.creationDate
|
|
9563
9564
|
});
|
|
9564
|
-
const passThrough = getOptionValue$1(zipEntry, options, "passThrough");
|
|
9565
9565
|
const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
|
|
9566
9566
|
const zipCrypto = encrypted && !extraFieldAES;
|
|
9567
9567
|
if (!passThrough) {
|
|
@@ -9588,7 +9588,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
9588
9588
|
writer = new WritableStream();
|
|
9589
9589
|
}
|
|
9590
9590
|
writer = initWriter(writer);
|
|
9591
|
-
await initStream(writer, uncompressedSize);
|
|
9591
|
+
await initStream(writer, passThrough ? compressedSize : uncompressedSize);
|
|
9592
9592
|
const { writable } = writer;
|
|
9593
9593
|
const { onstart, onprogress, onend } = options;
|
|
9594
9594
|
const workerOptions = {
|
|
@@ -10091,6 +10091,7 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
10091
10091
|
const signal = getOptionValue(zipWriter, options, "signal");
|
|
10092
10092
|
const useUnicodeFileNames = getOptionValue(zipWriter, options, "useUnicodeFileNames", true);
|
|
10093
10093
|
const useCompressionStream = getOptionValue(zipWriter, options, "useCompressionStream");
|
|
10094
|
+
const compressionMethod = getOptionValue(zipWriter, options, "compressionMethod");
|
|
10094
10095
|
let dataDescriptor = getOptionValue(zipWriter, options, "dataDescriptor", true);
|
|
10095
10096
|
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
10096
10097
|
if (!zipCrypto && (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && !(encryptionStrength >= 1 && encryptionStrength <= 3)) {
|
|
@@ -10193,7 +10194,8 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
10193
10194
|
useCompressionStream,
|
|
10194
10195
|
passThrough,
|
|
10195
10196
|
encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
|
|
10196
|
-
signature
|
|
10197
|
+
signature,
|
|
10198
|
+
compressionMethod
|
|
10197
10199
|
});
|
|
10198
10200
|
const headerInfo = getHeaderInfo(options);
|
|
10199
10201
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -10541,7 +10543,7 @@ function getHeaderInfo(options) {
|
|
|
10541
10543
|
encrypted
|
|
10542
10544
|
} = options;
|
|
10543
10545
|
const compressed = level !== 0 && !directory;
|
|
10544
|
-
let version = options
|
|
10546
|
+
let { version, compressionMethod } = options;
|
|
10545
10547
|
let rawExtraFieldAES;
|
|
10546
10548
|
if (encrypted && !zipCrypto) {
|
|
10547
10549
|
rawExtraFieldAES = new Uint8Array(getLength(EXTRAFIELD_DATA_AES) + 2);
|
|
@@ -10596,9 +10598,10 @@ function getHeaderInfo(options) {
|
|
|
10596
10598
|
if (dataDescriptor) {
|
|
10597
10599
|
bitFlag = bitFlag | BITFLAG_DATA_DESCRIPTOR;
|
|
10598
10600
|
}
|
|
10599
|
-
|
|
10601
|
+
if (compressionMethod === UNDEFINED_VALUE) {
|
|
10602
|
+
compressionMethod = compressed ? COMPRESSION_METHOD_DEFLATE : COMPRESSION_METHOD_STORE;
|
|
10603
|
+
}
|
|
10600
10604
|
if (compressed) {
|
|
10601
|
-
compressionMethod = COMPRESSION_METHOD_DEFLATE;
|
|
10602
10605
|
if (level >= 1 && level < 3) {
|
|
10603
10606
|
bitFlag = bitFlag | 0b110;
|
|
10604
10607
|
}
|
|
@@ -10616,10 +10619,8 @@ function getHeaderInfo(options) {
|
|
|
10616
10619
|
bitFlag = bitFlag | BITFLAG_ENCRYPTED;
|
|
10617
10620
|
if (!zipCrypto) {
|
|
10618
10621
|
version = version > VERSION_AES ? version : VERSION_AES;
|
|
10622
|
+
rawExtraFieldAES[9] = compressionMethod;
|
|
10619
10623
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
10620
|
-
if (compressed) {
|
|
10621
|
-
rawExtraFieldAES[9] = COMPRESSION_METHOD_DEFLATE;
|
|
10622
|
-
}
|
|
10623
10624
|
}
|
|
10624
10625
|
}
|
|
10625
10626
|
const headerArray = new Uint8Array(26);
|
|
@@ -11762,13 +11763,6 @@ async function exportZip(zipWriter, entry, totalSize, options) {
|
|
|
11762
11763
|
compressionMethod,
|
|
11763
11764
|
extraFieldAES
|
|
11764
11765
|
} = child.data;
|
|
11765
|
-
let level, encryptionStrength;
|
|
11766
|
-
if (compressionMethod === 0) {
|
|
11767
|
-
level = 0;
|
|
11768
|
-
}
|
|
11769
|
-
if (extraFieldAES) {
|
|
11770
|
-
encryptionStrength = extraFieldAES.strength;
|
|
11771
|
-
}
|
|
11772
11766
|
zipEntryOptions = {
|
|
11773
11767
|
externalFileAttribute,
|
|
11774
11768
|
versionMadeBy,
|
|
@@ -11778,6 +11772,13 @@ async function exportZip(zipWriter, entry, totalSize, options) {
|
|
|
11778
11772
|
lastAccessDate
|
|
11779
11773
|
};
|
|
11780
11774
|
if (child.passThrough) {
|
|
11775
|
+
let level, encryptionStrength;
|
|
11776
|
+
if (compressionMethod === 0) {
|
|
11777
|
+
level = 0;
|
|
11778
|
+
}
|
|
11779
|
+
if (extraFieldAES) {
|
|
11780
|
+
encryptionStrength = extraFieldAES.strength;
|
|
11781
|
+
}
|
|
11781
11782
|
zipEntryOptions = Object.assign(zipEntryOptions, {
|
|
11782
11783
|
passThrough: true,
|
|
11783
11784
|
encrypted,
|
|
@@ -11785,7 +11786,8 @@ async function exportZip(zipWriter, entry, totalSize, options) {
|
|
|
11785
11786
|
signature,
|
|
11786
11787
|
uncompressedSize,
|
|
11787
11788
|
level,
|
|
11788
|
-
encryptionStrength
|
|
11789
|
+
encryptionStrength,
|
|
11790
|
+
compressionMethod
|
|
11789
11791
|
});
|
|
11790
11792
|
}
|
|
11791
11793
|
}
|
package/index.d.ts
CHANGED
|
@@ -407,7 +407,7 @@ export class HttpReader extends Reader<URLString> {
|
|
|
407
407
|
* @param url The URL of the data.
|
|
408
408
|
* @param options The options.
|
|
409
409
|
*/
|
|
410
|
-
constructor(url: URLString, options?: HttpOptions);
|
|
410
|
+
constructor(url: URLString | URL, options?: HttpOptions);
|
|
411
411
|
}
|
|
412
412
|
|
|
413
413
|
/**
|
|
@@ -420,7 +420,7 @@ export class HttpRangeReader extends HttpReader {
|
|
|
420
420
|
* @param url The URL of the data.
|
|
421
421
|
* @param options The options.
|
|
422
422
|
*/
|
|
423
|
-
constructor(url: URLString, options?: HttpRangeOptions);
|
|
423
|
+
constructor(url: URLString | URL, options?: HttpRangeOptions);
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
/**
|
|
@@ -806,7 +806,7 @@ export interface ZipReaderOptions {
|
|
|
806
806
|
*
|
|
807
807
|
* @defaultValue false
|
|
808
808
|
*/
|
|
809
|
-
checkPasswordOnly
|
|
809
|
+
checkPasswordOnly?: boolean;
|
|
810
810
|
/**
|
|
811
811
|
* `true` to check the signature of the entry.
|
|
812
812
|
*
|
|
@@ -959,6 +959,10 @@ export interface EntryMetaData {
|
|
|
959
959
|
* The number of the disk where the entry data starts.
|
|
960
960
|
*/
|
|
961
961
|
diskNumberStart: number;
|
|
962
|
+
/**
|
|
963
|
+
* The compression method.
|
|
964
|
+
*/
|
|
965
|
+
compressionMethod: number;
|
|
962
966
|
}
|
|
963
967
|
|
|
964
968
|
/**
|
|
@@ -1376,6 +1380,10 @@ export interface ZipWriterConstructorOptions {
|
|
|
1376
1380
|
* The offset of the first entry in the zip file.
|
|
1377
1381
|
*/
|
|
1378
1382
|
offset?: number;
|
|
1383
|
+
/**
|
|
1384
|
+
* The compression method (e.g. 8 for DEFLATE, 0 for STORE).
|
|
1385
|
+
*/
|
|
1386
|
+
compressionMethod?: number
|
|
1379
1387
|
/**
|
|
1380
1388
|
* Encode the filename and the comment of the entry.
|
|
1381
1389
|
*
|