@zip.js/zip.js 2.8.11 → 2.8.14

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/index-native.cjs CHANGED
@@ -5185,15 +5185,19 @@ function getHeaderInfo(options) {
5185
5185
  let { version, compressionMethod } = options;
5186
5186
  const compressed = !directory && (level > 0 || (level === UNDEFINED_VALUE && compressionMethod !== 0));
5187
5187
  let rawExtraFieldZip64;
5188
+ let rawLocalExtraFieldZip64;
5188
5189
  const uncompressedFile = passThrough || !compressed;
5189
5190
  const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
5190
5191
  if (zip64) {
5191
5192
  let rawExtraFieldZip64Length = 4;
5193
+ let rawLocalExtraFieldZip64Length = 4;
5192
5194
  if (zip64UncompressedSize) {
5193
5195
  rawExtraFieldZip64Length += 8;
5196
+ rawLocalExtraFieldZip64Length += 8;
5194
5197
  }
5195
5198
  if (zip64CompressedSize) {
5196
5199
  rawExtraFieldZip64Length += 8;
5200
+ rawLocalExtraFieldZip64Length += 8;
5197
5201
  }
5198
5202
  if (zip64Offset) {
5199
5203
  rawExtraFieldZip64Length += 8;
@@ -5203,18 +5207,28 @@ function getHeaderInfo(options) {
5203
5207
  }
5204
5208
  rawExtraFieldZip64 = new Uint8Array(rawExtraFieldZip64Length);
5205
5209
  const rawExtraFieldZip64View = getDataView(rawExtraFieldZip64);
5210
+ rawLocalExtraFieldZip64 = new Uint8Array(rawLocalExtraFieldZip64Length);
5211
+ const rawLocalExtraFieldZip64View = getDataView(rawLocalExtraFieldZip64);
5206
5212
  setUint16(rawExtraFieldZip64View, 0, EXTRAFIELD_TYPE_ZIP64);
5207
5213
  setUint16(rawExtraFieldZip64View, 2, getLength(rawExtraFieldZip64) - 4);
5214
+ setUint16(rawLocalExtraFieldZip64View, 0, EXTRAFIELD_TYPE_ZIP64);
5215
+ setUint16(rawLocalExtraFieldZip64View, 2, getLength(rawLocalExtraFieldZip64) - 4);
5208
5216
  if (zip64ExtraFieldComplete) {
5209
5217
  const rawExtraFieldZip64View = getDataView(rawExtraFieldZip64);
5218
+ const rawLocalExtraFieldZip64View = getDataView(rawLocalExtraFieldZip64);
5210
5219
  let rawExtraFieldZip64Offset = 4;
5220
+ let rawLocalExtraFieldZip64Offset = 4;
5211
5221
  if (zip64UncompressedSize) {
5212
5222
  setBigUint64(rawExtraFieldZip64View, rawExtraFieldZip64Offset, BigInt(uncompressedSize));
5213
5223
  rawExtraFieldZip64Offset += 8;
5224
+ setBigUint64(rawLocalExtraFieldZip64View, rawLocalExtraFieldZip64Offset, BigInt(uncompressedSize));
5225
+ rawLocalExtraFieldZip64Offset += 8;
5214
5226
  }
5215
5227
  if (zip64CompressedSize && uncompressedFile) {
5216
5228
  setBigUint64(rawExtraFieldZip64View, rawExtraFieldZip64Offset, BigInt(uncompressedSize));
5217
5229
  rawExtraFieldZip64Offset += 8;
5230
+ setBigUint64(rawLocalExtraFieldZip64View, rawLocalExtraFieldZip64Offset, BigInt(uncompressedSize));
5231
+ rawLocalExtraFieldZip64Offset += 8;
5218
5232
  }
5219
5233
  if (zip64Offset) {
5220
5234
  setBigUint64(rawExtraFieldZip64View, rawExtraFieldZip64Offset, BigInt(offset));
@@ -5224,9 +5238,13 @@ function getHeaderInfo(options) {
5224
5238
  setUint32(rawExtraFieldZip64View, rawExtraFieldZip64Offset, diskNumberStart);
5225
5239
  rawExtraFieldZip64Offset += 4;
5226
5240
  }
5241
+ if (rawLocalExtraFieldZip64Offset == 4) {
5242
+ rawLocalExtraFieldZip64 = new Uint8Array();
5243
+ }
5227
5244
  }
5228
5245
  } else {
5229
5246
  rawExtraFieldZip64 = new Uint8Array();
5247
+ rawLocalExtraFieldZip64 = new Uint8Array();
5230
5248
  }
5231
5249
  let rawExtraFieldAES;
5232
5250
  if (encrypted && !zipCrypto) {
@@ -5329,7 +5347,7 @@ function getHeaderInfo(options) {
5329
5347
  rawExtraFieldAES[9] = compressionMethod;
5330
5348
  compressionMethod = COMPRESSION_METHOD_AES;
5331
5349
  }
5332
- const localExtraFieldZip64Length = zip64ExtraFieldComplete ? getLength(rawExtraFieldZip64) : 0;
5350
+ const localExtraFieldZip64Length = zip64ExtraFieldComplete ? getLength(rawLocalExtraFieldZip64) : 0;
5333
5351
  const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
5334
5352
  const {
5335
5353
  headerArray,
@@ -5354,7 +5372,7 @@ function getHeaderInfo(options) {
5354
5372
  arraySet(localHeaderArray, rawFilename, localHeaderOffset);
5355
5373
  localHeaderOffset += getLength(rawFilename);
5356
5374
  if (zip64ExtraFieldComplete) {
5357
- arraySet(localHeaderArray, rawExtraFieldZip64, localHeaderOffset);
5375
+ arraySet(localHeaderArray, rawLocalExtraFieldZip64, localHeaderOffset);
5358
5376
  }
5359
5377
  localHeaderOffset += localExtraFieldZip64Length;
5360
5378
  arraySet(localHeaderArray, rawExtraFieldAES, localHeaderOffset);
@@ -5527,40 +5545,29 @@ function updateLocalHeader({
5527
5545
  signature,
5528
5546
  compressedSize,
5529
5547
  uncompressedSize,
5530
- offset,
5531
- diskNumberStart,
5532
5548
  zip64UncompressedSize,
5533
- zip64CompressedSize,
5534
- zip64Offset,
5535
- zip64DiskNumberStart
5549
+ zip64CompressedSize
5536
5550
  }, localHeaderView, { dataDescriptor }) {
5537
5551
  if (!dataDescriptor) {
5538
5552
  if (!encrypted) {
5539
5553
  setUint32(localHeaderView, HEADER_OFFSET_SIGNATURE + 4, signature);
5540
5554
  }
5541
- if (!zip64) {
5555
+ if (!zip64CompressedSize) {
5542
5556
  setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + 4, compressedSize);
5557
+ }
5558
+ if (!zip64UncompressedSize) {
5543
5559
  setUint32(localHeaderView, HEADER_OFFSET_UNCOMPRESSED_SIZE + 4, uncompressedSize);
5544
5560
  }
5545
5561
  }
5546
- if (zip64) {
5547
- if (localExtraFieldZip64Length) {
5548
- let localHeaderOffset = HEADER_SIZE + getLength(rawFilename) + 4;
5549
- if (zip64UncompressedSize) {
5550
- setBigUint64(localHeaderView, localHeaderOffset, BigInt(uncompressedSize));
5551
- localHeaderOffset += 8;
5552
- }
5553
- if (zip64CompressedSize) {
5554
- setBigUint64(localHeaderView, localHeaderOffset, BigInt(compressedSize));
5555
- localHeaderOffset += 8;
5556
- }
5557
- if (zip64Offset) {
5558
- setBigUint64(localHeaderView, localHeaderOffset, BigInt(offset));
5559
- localHeaderOffset += 8;
5560
- }
5561
- if (zip64DiskNumberStart) {
5562
- setUint32(localHeaderView, localHeaderOffset, diskNumberStart);
5563
- }
5562
+ if (zip64 && localExtraFieldZip64Length) {
5563
+ let localHeaderOffset = HEADER_SIZE + getLength(rawFilename) + 4;
5564
+ if (zip64UncompressedSize) {
5565
+ setBigUint64(localHeaderView, localHeaderOffset, BigInt(uncompressedSize));
5566
+ localHeaderOffset += 8;
5567
+ }
5568
+ if (zip64CompressedSize) {
5569
+ setBigUint64(localHeaderView, localHeaderOffset, BigInt(compressedSize));
5570
+ localHeaderOffset += 8;
5564
5571
  }
5565
5572
  }
5566
5573
  }