@zip.js/zip.js 2.7.66 → 2.7.67

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.js CHANGED
@@ -38,6 +38,7 @@
38
38
  const MAX_32_BITS = 0xffffffff;
39
39
  const MAX_16_BITS = 0xffff;
40
40
  const COMPRESSION_METHOD_DEFLATE = 0x08;
41
+ const COMPRESSION_METHOD_DEFLATE_64 = 0x09;
41
42
  const COMPRESSION_METHOD_STORE = 0x00;
42
43
  const COMPRESSION_METHOD_AES = 0x63;
43
44
 
@@ -4196,27 +4197,11 @@
4196
4197
  if (this.filenames.size) {
4197
4198
  throw new Error(ERR_ZIP_NOT_EMPTY);
4198
4199
  }
4199
- ({ reader } = new GenericReader(reader));
4200
- const [zipEntriesReader, zipDataReader] = reader.readable.tee();
4201
- const zipReader = new ZipReader(new ReadableStream({
4202
- async start(controller) {
4203
- const reader = zipEntriesReader.getReader();
4204
- await readChunk();
4205
-
4206
- async function readChunk() {
4207
- const { done, value } = await reader.read();
4208
- if (done) {
4209
- controller.close();
4210
- } else {
4211
- controller.enqueue(value);
4212
- await readChunk();
4213
- }
4214
- }
4215
- }
4216
- }));
4200
+ reader = new GenericReader(reader);
4201
+ const zipReader = new ZipReader(reader.readable);
4217
4202
  const entries = await zipReader.getEntries();
4218
4203
  await zipReader.close();
4219
- await zipDataReader.pipeTo(this.writer.writable, { preventClose: true, preventAbort: true });
4204
+ await reader.readable.pipeTo(this.writer.writable, { preventClose: true, preventAbort: true });
4220
4205
  this.writer.size = this.offset = reader.size;
4221
4206
  this.filenames = new Set(entries.map(entry => entry.filename));
4222
4207
  this.files = new Map(entries.map(entry => {
@@ -4256,7 +4241,7 @@
4256
4241
  headerView
4257
4242
  } = getHeaderArrayData({
4258
4243
  version,
4259
- bitFlag: getBitFlag(level, languageEncodingFlag, dataDescriptor, encrypted),
4244
+ bitFlag: getBitFlag(level, languageEncodingFlag, dataDescriptor, encrypted, compressionMethod),
4260
4245
  compressionMethod,
4261
4246
  uncompressedSize,
4262
4247
  compressedSize,
@@ -5042,7 +5027,7 @@
5042
5027
  rawLastModDate
5043
5028
  } = getHeaderArrayData({
5044
5029
  version,
5045
- bitFlag: getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted),
5030
+ bitFlag: getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod),
5046
5031
  compressionMethod,
5047
5032
  uncompressedSize,
5048
5033
  lastModDate: lastModDate < MIN_DATE ? MIN_DATE : lastModDate > MAX_DATE ? MAX_DATE : lastModDate,
@@ -5530,8 +5515,7 @@
5530
5515
  };
5531
5516
  }
5532
5517
 
5533
-
5534
- function getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted) {
5518
+ function getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod) {
5535
5519
  let bitFlag = 0;
5536
5520
  if (useUnicodeFileNames) {
5537
5521
  bitFlag = bitFlag | BITFLAG_LANG_ENCODING_FLAG;
@@ -5539,14 +5523,16 @@
5539
5523
  if (dataDescriptor) {
5540
5524
  bitFlag = bitFlag | BITFLAG_DATA_DESCRIPTOR;
5541
5525
  }
5542
- if (level > 0 && level <= 3) {
5543
- bitFlag = bitFlag | BITFLAG_LEVEL_SUPER_FAST_MASK;
5544
- }
5545
- if (level > 3 && level <= 5) {
5546
- bitFlag = bitFlag | BITFLAG_LEVEL_FAST_MASK;
5547
- }
5548
- if (level == 9) {
5549
- bitFlag = bitFlag | BITFLAG_LEVEL_MAX_MASK;
5526
+ if (compressionMethod == COMPRESSION_METHOD_DEFLATE || compressionMethod == COMPRESSION_METHOD_DEFLATE_64) {
5527
+ if (level >= 0 && level <= 3) {
5528
+ bitFlag = bitFlag | BITFLAG_LEVEL_SUPER_FAST_MASK;
5529
+ }
5530
+ if (level > 3 && level <= 5) {
5531
+ bitFlag = bitFlag | BITFLAG_LEVEL_FAST_MASK;
5532
+ }
5533
+ if (level == 9) {
5534
+ bitFlag = bitFlag | BITFLAG_LEVEL_MAX_MASK;
5535
+ }
5550
5536
  }
5551
5537
  if (encrypted) {
5552
5538
  bitFlag = bitFlag | BITFLAG_ENCRYPTED;