@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-full.js CHANGED
@@ -7913,6 +7913,7 @@
7913
7913
  const dataView = getDataView$1(dataArray);
7914
7914
  let password = getOptionValue$1(zipEntry, options, "password");
7915
7915
  let rawPassword = getOptionValue$1(zipEntry, options, "rawPassword");
7916
+ const passThrough = getOptionValue$1(zipEntry, options, "passThrough");
7916
7917
  password = password && password.length && password;
7917
7918
  rawPassword = rawPassword && rawPassword.length && rawPassword;
7918
7919
  if (extraFieldAES) {
@@ -7920,7 +7921,7 @@
7920
7921
  throw new Error(ERR_UNSUPPORTED_COMPRESSION);
7921
7922
  }
7922
7923
  }
7923
- if (compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE) {
7924
+ if ((compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE) && !passThrough) {
7924
7925
  throw new Error(ERR_UNSUPPORTED_COMPRESSION);
7925
7926
  }
7926
7927
  if (getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
@@ -7935,7 +7936,6 @@
7935
7936
  lastAccessDate: localDirectory.lastAccessDate,
7936
7937
  creationDate: localDirectory.creationDate
7937
7938
  });
7938
- const passThrough = getOptionValue$1(zipEntry, options, "passThrough");
7939
7939
  const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
7940
7940
  const zipCrypto = encrypted && !extraFieldAES;
7941
7941
  if (!passThrough) {
@@ -7962,7 +7962,7 @@
7962
7962
  writer = new WritableStream();
7963
7963
  }
7964
7964
  writer = initWriter(writer);
7965
- await initStream(writer, uncompressedSize);
7965
+ await initStream(writer, passThrough ? compressedSize : uncompressedSize);
7966
7966
  const { writable } = writer;
7967
7967
  const { onstart, onprogress, onend } = options;
7968
7968
  const workerOptions = {
@@ -8465,6 +8465,7 @@
8465
8465
  const signal = getOptionValue(zipWriter, options, "signal");
8466
8466
  const useUnicodeFileNames = getOptionValue(zipWriter, options, "useUnicodeFileNames", true);
8467
8467
  const useCompressionStream = getOptionValue(zipWriter, options, "useCompressionStream");
8468
+ const compressionMethod = getOptionValue(zipWriter, options, "compressionMethod");
8468
8469
  let dataDescriptor = getOptionValue(zipWriter, options, "dataDescriptor", true);
8469
8470
  let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
8470
8471
  if (!zipCrypto && (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && !(encryptionStrength >= 1 && encryptionStrength <= 3)) {
@@ -8567,7 +8568,8 @@
8567
8568
  useCompressionStream,
8568
8569
  passThrough,
8569
8570
  encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
8570
- signature
8571
+ signature,
8572
+ compressionMethod
8571
8573
  });
8572
8574
  const headerInfo = getHeaderInfo(options);
8573
8575
  const dataDescriptorInfo = getDataDescriptorInfo(options);
@@ -8915,7 +8917,7 @@
8915
8917
  encrypted
8916
8918
  } = options;
8917
8919
  const compressed = level !== 0 && !directory;
8918
- let version = options.version;
8920
+ let { version, compressionMethod } = options;
8919
8921
  let rawExtraFieldAES;
8920
8922
  if (encrypted && !zipCrypto) {
8921
8923
  rawExtraFieldAES = new Uint8Array(getLength(EXTRAFIELD_DATA_AES) + 2);
@@ -8970,9 +8972,10 @@
8970
8972
  if (dataDescriptor) {
8971
8973
  bitFlag = bitFlag | BITFLAG_DATA_DESCRIPTOR;
8972
8974
  }
8973
- let compressionMethod = COMPRESSION_METHOD_STORE;
8975
+ if (compressionMethod === UNDEFINED_VALUE) {
8976
+ compressionMethod = compressed ? COMPRESSION_METHOD_DEFLATE : COMPRESSION_METHOD_STORE;
8977
+ }
8974
8978
  if (compressed) {
8975
- compressionMethod = COMPRESSION_METHOD_DEFLATE;
8976
8979
  if (level >= 1 && level < 3) {
8977
8980
  bitFlag = bitFlag | 0b110;
8978
8981
  }
@@ -8990,10 +8993,8 @@
8990
8993
  bitFlag = bitFlag | BITFLAG_ENCRYPTED;
8991
8994
  if (!zipCrypto) {
8992
8995
  version = version > VERSION_AES ? version : VERSION_AES;
8996
+ rawExtraFieldAES[9] = compressionMethod;
8993
8997
  compressionMethod = COMPRESSION_METHOD_AES;
8994
- if (compressed) {
8995
- rawExtraFieldAES[9] = COMPRESSION_METHOD_DEFLATE;
8996
- }
8997
8998
  }
8998
8999
  }
8999
9000
  const headerArray = new Uint8Array(26);