@zip.js/zip.js 2.8.21 → 2.8.23
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/deno.json +1 -1
- package/dist/README.md +4 -0
- package/dist/zip-core.js +39 -94
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core.js +39 -94
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-native.js +39 -94
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +39 -94
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +39 -94
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +39 -94
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +39 -94
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +39 -94
- package/index-native.min.js +1 -1
- package/index.cjs +39 -94
- package/index.d.ts +1 -2
- package/index.min.js +1 -1
- package/lib/core/zip-writer.js +39 -94
- package/package.json +4 -4
package/index-native.cjs
CHANGED
|
@@ -4368,7 +4368,7 @@ const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
|
4368
4368
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
4369
4369
|
const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
|
|
4370
4370
|
const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
|
|
4371
|
-
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (
|
|
4371
|
+
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
|
|
4372
4372
|
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
4373
4373
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
4374
4374
|
const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
|
|
@@ -4784,14 +4784,11 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
4784
4784
|
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
|
|
4785
4785
|
}
|
|
4786
4786
|
}
|
|
4787
|
-
const { diskOffset, diskNumber
|
|
4787
|
+
const { diskOffset, diskNumber } = zipWriter.writer;
|
|
4788
4788
|
const zip64UncompressedSize = zip64Enabled || uncompressedSize > MAX_32_BITS;
|
|
4789
4789
|
const zip64CompressedSize = zip64Enabled || maximumCompressedSize > MAX_32_BITS;
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
const zip64DiskNumberStart = (supportZip64SplitFile && zip64Enabled) || diskNumber + Math.ceil(zipWriter.pendingEntriesSize / maxSize) > MAX_16_BITS;
|
|
4793
|
-
if (zip64Offset || zip64UncompressedSize || zip64CompressedSize || zip64DiskNumberStart) {
|
|
4794
|
-
if (zip64 === false || !keepOrder) {
|
|
4790
|
+
if (zip64UncompressedSize || zip64CompressedSize) {
|
|
4791
|
+
if (zip64 === false) {
|
|
4795
4792
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
4796
4793
|
} else {
|
|
4797
4794
|
zip64 = true;
|
|
@@ -4811,8 +4808,6 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
4811
4808
|
zip64,
|
|
4812
4809
|
zip64UncompressedSize,
|
|
4813
4810
|
zip64CompressedSize,
|
|
4814
|
-
zip64Offset,
|
|
4815
|
-
zip64DiskNumberStart,
|
|
4816
4811
|
password,
|
|
4817
4812
|
rawPassword,
|
|
4818
4813
|
level,
|
|
@@ -4898,7 +4893,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
4898
4893
|
lockPreviousFileEntry = previousFileEntry && previousFileEntry.lock;
|
|
4899
4894
|
requestLockCurrentFileEntry();
|
|
4900
4895
|
}
|
|
4901
|
-
if ((options.bufferedWrite || zipWriter.writerLocked ||
|
|
4896
|
+
if ((options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) && !usdz) {
|
|
4902
4897
|
if (options.createTempStream) {
|
|
4903
4898
|
fileWriter = await options.createTempStream();
|
|
4904
4899
|
} else {
|
|
@@ -4940,7 +4935,6 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
4940
4935
|
await writeData(fileWriter, localHeaderArray);
|
|
4941
4936
|
}
|
|
4942
4937
|
fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, zipWriter.config, options);
|
|
4943
|
-
const { zip64 } = fileEntry;
|
|
4944
4938
|
if (!bufferedWrite) {
|
|
4945
4939
|
writingEntryData = false;
|
|
4946
4940
|
}
|
|
@@ -4952,9 +4946,6 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
4952
4946
|
writingBufferedEntryData = true;
|
|
4953
4947
|
fileEntry.diskNumberStart = writer.diskNumber;
|
|
4954
4948
|
fileEntry.offset = zipWriter.offset - writer.diskOffset;
|
|
4955
|
-
if (zip64) {
|
|
4956
|
-
updateZip64ExtraField(fileEntry);
|
|
4957
|
-
}
|
|
4958
4949
|
updateLocalHeader(fileEntry, localHeaderView, options);
|
|
4959
4950
|
await skipDiskIfNeeded(writable);
|
|
4960
4951
|
await writeData(writer, localHeaderArray);
|
|
@@ -4963,12 +4954,6 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
4963
4954
|
writingBufferedEntryData = false;
|
|
4964
4955
|
} else {
|
|
4965
4956
|
fileEntry.offset = zipWriter.offset - diskOffset;
|
|
4966
|
-
if (zip64) {
|
|
4967
|
-
updateZip64ExtraField(fileEntry);
|
|
4968
|
-
}
|
|
4969
|
-
}
|
|
4970
|
-
if (fileEntry.offset > MAX_32_BITS && !zip64) {
|
|
4971
|
-
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
4972
4957
|
}
|
|
4973
4958
|
zipWriter.offset += fileEntry.size;
|
|
4974
4959
|
return fileEntry;
|
|
@@ -5058,8 +5043,6 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
5058
5043
|
zip64,
|
|
5059
5044
|
zip64UncompressedSize,
|
|
5060
5045
|
zip64CompressedSize,
|
|
5061
|
-
zip64Offset,
|
|
5062
|
-
zip64DiskNumberStart,
|
|
5063
5046
|
zipCrypto,
|
|
5064
5047
|
dataDescriptor,
|
|
5065
5048
|
directory,
|
|
@@ -5197,9 +5180,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
5197
5180
|
signature,
|
|
5198
5181
|
extraFieldExtendedTimestampFlag,
|
|
5199
5182
|
zip64UncompressedSize,
|
|
5200
|
-
zip64CompressedSize
|
|
5201
|
-
zip64Offset,
|
|
5202
|
-
zip64DiskNumberStart
|
|
5183
|
+
zip64CompressedSize
|
|
5203
5184
|
});
|
|
5204
5185
|
return fileEntry;
|
|
5205
5186
|
}
|
|
@@ -5223,74 +5204,41 @@ function getHeaderInfo(options) {
|
|
|
5223
5204
|
encrypted,
|
|
5224
5205
|
zip64UncompressedSize,
|
|
5225
5206
|
zip64CompressedSize,
|
|
5226
|
-
|
|
5227
|
-
zip64DiskNumberStart,
|
|
5228
|
-
uncompressedSize,
|
|
5229
|
-
offset,
|
|
5230
|
-
diskNumberStart
|
|
5207
|
+
uncompressedSize
|
|
5231
5208
|
} = options;
|
|
5232
5209
|
let { version, compressionMethod } = options;
|
|
5233
5210
|
const compressed = !directory && (level > 0 || (level === UNDEFINED_VALUE && compressionMethod !== 0));
|
|
5234
|
-
let rawExtraFieldZip64;
|
|
5235
5211
|
let rawLocalExtraFieldZip64;
|
|
5236
5212
|
const uncompressedFile = passThrough || !compressed;
|
|
5237
5213
|
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
|
|
5238
5214
|
if (zip64) {
|
|
5239
|
-
let rawExtraFieldZip64Length = 4;
|
|
5240
5215
|
let rawLocalExtraFieldZip64Length = 4;
|
|
5241
5216
|
if (zip64UncompressedSize) {
|
|
5242
|
-
rawExtraFieldZip64Length += 8;
|
|
5243
5217
|
rawLocalExtraFieldZip64Length += 8;
|
|
5244
5218
|
}
|
|
5245
5219
|
if (zip64CompressedSize) {
|
|
5246
|
-
rawExtraFieldZip64Length += 8;
|
|
5247
5220
|
rawLocalExtraFieldZip64Length += 8;
|
|
5248
5221
|
}
|
|
5249
|
-
if (zip64Offset) {
|
|
5250
|
-
rawExtraFieldZip64Length += 8;
|
|
5251
|
-
}
|
|
5252
|
-
if (zip64DiskNumberStart) {
|
|
5253
|
-
rawExtraFieldZip64Length += 4;
|
|
5254
|
-
}
|
|
5255
|
-
rawExtraFieldZip64 = new Uint8Array(rawExtraFieldZip64Length);
|
|
5256
|
-
const rawExtraFieldZip64View = getDataView(rawExtraFieldZip64);
|
|
5257
5222
|
rawLocalExtraFieldZip64 = new Uint8Array(rawLocalExtraFieldZip64Length);
|
|
5258
5223
|
const rawLocalExtraFieldZip64View = getDataView(rawLocalExtraFieldZip64);
|
|
5259
|
-
setUint16(rawExtraFieldZip64View, 0, EXTRAFIELD_TYPE_ZIP64);
|
|
5260
|
-
setUint16(rawExtraFieldZip64View, 2, getLength(rawExtraFieldZip64) - 4);
|
|
5261
5224
|
setUint16(rawLocalExtraFieldZip64View, 0, EXTRAFIELD_TYPE_ZIP64);
|
|
5262
5225
|
setUint16(rawLocalExtraFieldZip64View, 2, getLength(rawLocalExtraFieldZip64) - 4);
|
|
5263
5226
|
if (zip64ExtraFieldComplete) {
|
|
5264
|
-
const rawExtraFieldZip64View = getDataView(rawExtraFieldZip64);
|
|
5265
5227
|
const rawLocalExtraFieldZip64View = getDataView(rawLocalExtraFieldZip64);
|
|
5266
|
-
let rawExtraFieldZip64Offset = 4;
|
|
5267
5228
|
let rawLocalExtraFieldZip64Offset = 4;
|
|
5268
5229
|
if (zip64UncompressedSize) {
|
|
5269
|
-
setBigUint64(rawExtraFieldZip64View, rawExtraFieldZip64Offset, BigInt(uncompressedSize));
|
|
5270
|
-
rawExtraFieldZip64Offset += 8;
|
|
5271
5230
|
setBigUint64(rawLocalExtraFieldZip64View, rawLocalExtraFieldZip64Offset, BigInt(uncompressedSize));
|
|
5272
5231
|
rawLocalExtraFieldZip64Offset += 8;
|
|
5273
5232
|
}
|
|
5274
5233
|
if (zip64CompressedSize && uncompressedFile) {
|
|
5275
|
-
setBigUint64(rawExtraFieldZip64View, rawExtraFieldZip64Offset, BigInt(uncompressedSize));
|
|
5276
|
-
rawExtraFieldZip64Offset += 8;
|
|
5277
5234
|
setBigUint64(rawLocalExtraFieldZip64View, rawLocalExtraFieldZip64Offset, BigInt(uncompressedSize));
|
|
5278
5235
|
rawLocalExtraFieldZip64Offset += 8;
|
|
5279
5236
|
}
|
|
5280
|
-
if (zip64Offset) {
|
|
5281
|
-
setBigUint64(rawExtraFieldZip64View, rawExtraFieldZip64Offset, BigInt(offset));
|
|
5282
|
-
rawExtraFieldZip64Offset += 8;
|
|
5283
|
-
}
|
|
5284
|
-
if (zip64DiskNumberStart) {
|
|
5285
|
-
setUint32(rawExtraFieldZip64View, rawExtraFieldZip64Offset, diskNumberStart);
|
|
5286
|
-
rawExtraFieldZip64Offset += 4;
|
|
5287
|
-
}
|
|
5288
5237
|
if (rawLocalExtraFieldZip64Offset == 4) {
|
|
5289
5238
|
rawLocalExtraFieldZip64 = new Uint8Array();
|
|
5290
5239
|
}
|
|
5291
5240
|
}
|
|
5292
5241
|
} else {
|
|
5293
|
-
rawExtraFieldZip64 = new Uint8Array();
|
|
5294
5242
|
rawLocalExtraFieldZip64 = new Uint8Array();
|
|
5295
5243
|
}
|
|
5296
5244
|
let rawExtraFieldAES;
|
|
@@ -5447,7 +5395,7 @@ function getHeaderInfo(options) {
|
|
|
5447
5395
|
version,
|
|
5448
5396
|
compressionMethod,
|
|
5449
5397
|
extraFieldExtendedTimestampFlag,
|
|
5450
|
-
rawExtraFieldZip64,
|
|
5398
|
+
rawExtraFieldZip64: new Uint8Array(),
|
|
5451
5399
|
localExtraFieldZip64Length,
|
|
5452
5400
|
rawExtraFieldExtendedTimestamp,
|
|
5453
5401
|
rawExtraFieldNTFS,
|
|
@@ -5619,35 +5567,6 @@ function updateLocalHeader({
|
|
|
5619
5567
|
}
|
|
5620
5568
|
}
|
|
5621
5569
|
|
|
5622
|
-
function updateZip64ExtraField({
|
|
5623
|
-
compressedSize,
|
|
5624
|
-
uncompressedSize,
|
|
5625
|
-
offset,
|
|
5626
|
-
diskNumberStart,
|
|
5627
|
-
zip64UncompressedSize,
|
|
5628
|
-
zip64CompressedSize,
|
|
5629
|
-
zip64Offset,
|
|
5630
|
-
zip64DiskNumberStart,
|
|
5631
|
-
rawExtraFieldZip64
|
|
5632
|
-
}) {
|
|
5633
|
-
const rawExtraFieldZip64View = getDataView(rawExtraFieldZip64);
|
|
5634
|
-
let rawExtraFieldZip64Offset = 4;
|
|
5635
|
-
if (zip64UncompressedSize) {
|
|
5636
|
-
setBigUint64(rawExtraFieldZip64View, rawExtraFieldZip64Offset, BigInt(uncompressedSize));
|
|
5637
|
-
rawExtraFieldZip64Offset += 8;
|
|
5638
|
-
}
|
|
5639
|
-
if (zip64CompressedSize) {
|
|
5640
|
-
setBigUint64(rawExtraFieldZip64View, rawExtraFieldZip64Offset, BigInt(compressedSize));
|
|
5641
|
-
rawExtraFieldZip64Offset += 8;
|
|
5642
|
-
}
|
|
5643
|
-
if (zip64Offset) {
|
|
5644
|
-
setBigUint64(rawExtraFieldZip64View, rawExtraFieldZip64Offset, BigInt(offset));
|
|
5645
|
-
rawExtraFieldZip64Offset += 8;
|
|
5646
|
-
}
|
|
5647
|
-
if (zip64DiskNumberStart) {
|
|
5648
|
-
setUint32(rawExtraFieldZip64View, rawExtraFieldZip64Offset, diskNumberStart);
|
|
5649
|
-
}
|
|
5650
|
-
}
|
|
5651
5570
|
|
|
5652
5571
|
async function closeFile(zipWriter, comment, options) {
|
|
5653
5572
|
const { files, writer } = zipWriter;
|
|
@@ -5660,7 +5579,6 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
5660
5579
|
for (const [, fileEntry] of files) {
|
|
5661
5580
|
const {
|
|
5662
5581
|
rawFilename,
|
|
5663
|
-
rawExtraFieldZip64,
|
|
5664
5582
|
rawExtraFieldAES,
|
|
5665
5583
|
rawComment,
|
|
5666
5584
|
rawExtraFieldNTFS,
|
|
@@ -5668,8 +5586,36 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
5668
5586
|
rawExtraField,
|
|
5669
5587
|
extendedTimestamp,
|
|
5670
5588
|
extraFieldExtendedTimestampFlag,
|
|
5671
|
-
lastModDate
|
|
5589
|
+
lastModDate,
|
|
5590
|
+
zip64UncompressedSize,
|
|
5591
|
+
zip64CompressedSize,
|
|
5592
|
+
uncompressedSize,
|
|
5593
|
+
compressedSize
|
|
5672
5594
|
} = fileEntry;
|
|
5595
|
+
const zip64Offset = fileEntry.offset > MAX_32_BITS;
|
|
5596
|
+
const zip64DiskNumberStart = fileEntry.diskNumberStart > MAX_16_BITS;
|
|
5597
|
+
let rawExtraFieldZip64;
|
|
5598
|
+
if (zip64Offset || zip64DiskNumberStart || zip64UncompressedSize || zip64CompressedSize) {
|
|
5599
|
+
let length = 4;
|
|
5600
|
+
if (zip64UncompressedSize) length += 8;
|
|
5601
|
+
if (zip64CompressedSize) length += 8;
|
|
5602
|
+
if (zip64Offset) length += 8;
|
|
5603
|
+
if (zip64DiskNumberStart) length += 4;
|
|
5604
|
+
rawExtraFieldZip64 = new Uint8Array(length);
|
|
5605
|
+
const zip64View = getDataView(rawExtraFieldZip64);
|
|
5606
|
+
setUint16(zip64View, 0, EXTRAFIELD_TYPE_ZIP64);
|
|
5607
|
+
setUint16(zip64View, 2, length - 4);
|
|
5608
|
+
let zip64FieldOffset = 4;
|
|
5609
|
+
if (zip64UncompressedSize) { setBigUint64(zip64View, zip64FieldOffset, BigInt(uncompressedSize)); zip64FieldOffset += 8; }
|
|
5610
|
+
if (zip64CompressedSize) { setBigUint64(zip64View, zip64FieldOffset, BigInt(compressedSize)); zip64FieldOffset += 8; }
|
|
5611
|
+
if (zip64Offset) { setBigUint64(zip64View, zip64FieldOffset, BigInt(fileEntry.offset)); zip64FieldOffset += 8; }
|
|
5612
|
+
if (zip64DiskNumberStart) { setUint32(zip64View, zip64FieldOffset, fileEntry.diskNumberStart); }
|
|
5613
|
+
} else {
|
|
5614
|
+
rawExtraFieldZip64 = new Uint8Array();
|
|
5615
|
+
}
|
|
5616
|
+
fileEntry.rawExtraFieldZip64 = rawExtraFieldZip64;
|
|
5617
|
+
fileEntry.zip64Offset = zip64Offset;
|
|
5618
|
+
fileEntry.zip64DiskNumberStart = zip64DiskNumberStart;
|
|
5673
5619
|
let rawExtraFieldTimestamp;
|
|
5674
5620
|
if (extendedTimestamp) {
|
|
5675
5621
|
rawExtraFieldTimestamp = new Uint8Array(9);
|
|
@@ -5711,7 +5657,6 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
5711
5657
|
versionMadeBy,
|
|
5712
5658
|
headerArray,
|
|
5713
5659
|
headerView,
|
|
5714
|
-
zip64,
|
|
5715
5660
|
zip64UncompressedSize,
|
|
5716
5661
|
zip64CompressedSize,
|
|
5717
5662
|
zip64DiskNumberStart,
|
|
@@ -5737,7 +5682,7 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
5737
5682
|
directoryOffset += 2;
|
|
5738
5683
|
setUint16(directoryView, directoryOffset, getLength(rawComment));
|
|
5739
5684
|
directoryOffset += 2;
|
|
5740
|
-
setUint16(directoryView, directoryOffset,
|
|
5685
|
+
setUint16(directoryView, directoryOffset, zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
|
|
5741
5686
|
directoryOffset += 2;
|
|
5742
5687
|
setUint16(directoryView, directoryOffset, internalFileAttributes);
|
|
5743
5688
|
directoryOffset += 2;
|
|
@@ -5745,7 +5690,7 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
5745
5690
|
setUint32(directoryView, directoryOffset, externalFileAttributes);
|
|
5746
5691
|
}
|
|
5747
5692
|
directoryOffset += 4;
|
|
5748
|
-
setUint32(directoryView, directoryOffset,
|
|
5693
|
+
setUint32(directoryView, directoryOffset, zip64Offset ? MAX_32_BITS : fileEntryOffset);
|
|
5749
5694
|
directoryOffset += 4;
|
|
5750
5695
|
arraySet(directoryArray, rawFilename, directoryOffset);
|
|
5751
5696
|
directoryOffset += getLength(rawFilename);
|