@zip.js/zip.js 2.7.22 → 2.7.24
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 +88 -199
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +76 -58
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +60 -45
- 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 +60 -45
- package/dist/zip.min.js +1 -1
- package/index.cjs +88 -199
- package/index.d.ts +1 -1
- package/index.min.js +1 -1
- package/lib/core/util/mime-type.js +12 -141
- package/lib/core/zip-fs-core.js +16 -13
- package/lib/core/zip-reader.js +18 -13
- package/lib/core/zip-writer.js +42 -32
- package/package.json +1 -1
package/dist/zip-fs.js
CHANGED
|
@@ -3525,7 +3525,7 @@
|
|
|
3525
3525
|
localDirectory.rawExtraField = localDirectory.extraFieldLength ?
|
|
3526
3526
|
await readUint8Array(reader, offset + 30 + localDirectory.filenameLength, localDirectory.extraFieldLength, diskNumberStart) :
|
|
3527
3527
|
new Uint8Array();
|
|
3528
|
-
await readCommonFooter(zipEntry, localDirectory, dataView, 4);
|
|
3528
|
+
await readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
|
|
3529
3529
|
Object.assign(fileEntry, {
|
|
3530
3530
|
lastAccessDate: localDirectory.lastAccessDate,
|
|
3531
3531
|
creationDate: localDirectory.creationDate
|
|
@@ -3612,7 +3612,7 @@
|
|
|
3612
3612
|
});
|
|
3613
3613
|
}
|
|
3614
3614
|
|
|
3615
|
-
async function readCommonFooter(fileEntry, directory, dataView, offset) {
|
|
3615
|
+
async function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory) {
|
|
3616
3616
|
const { rawExtraField } = directory;
|
|
3617
3617
|
const extraField = directory.extraField = new Map();
|
|
3618
3618
|
const rawExtraFieldView = getDataView$1(new Uint8Array(rawExtraField));
|
|
@@ -3665,7 +3665,7 @@
|
|
|
3665
3665
|
}
|
|
3666
3666
|
const extraFieldExtendedTimestamp = extraField.get(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
3667
3667
|
if (extraFieldExtendedTimestamp) {
|
|
3668
|
-
readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory);
|
|
3668
|
+
readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory, localDirectory);
|
|
3669
3669
|
directory.extraFieldExtendedTimestamp = extraFieldExtendedTimestamp;
|
|
3670
3670
|
}
|
|
3671
3671
|
}
|
|
@@ -3756,23 +3756,28 @@
|
|
|
3756
3756
|
}
|
|
3757
3757
|
}
|
|
3758
3758
|
|
|
3759
|
-
function readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory) {
|
|
3759
|
+
function readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory, localDirectory) {
|
|
3760
3760
|
const extraFieldView = getDataView$1(extraFieldExtendedTimestamp.data);
|
|
3761
3761
|
const flags = getUint8(extraFieldView, 0);
|
|
3762
3762
|
const timeProperties = [];
|
|
3763
3763
|
const timeRawProperties = [];
|
|
3764
|
-
if (
|
|
3764
|
+
if (localDirectory) {
|
|
3765
|
+
if ((flags & 0x1) == 0x1) {
|
|
3766
|
+
timeProperties.push(PROPERTY_NAME_LAST_MODIFICATION_DATE);
|
|
3767
|
+
timeRawProperties.push(PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE);
|
|
3768
|
+
}
|
|
3769
|
+
if ((flags & 0x2) == 0x2) {
|
|
3770
|
+
timeProperties.push(PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
3771
|
+
timeRawProperties.push(PROPERTY_NAME_RAW_LAST_ACCESS_DATE);
|
|
3772
|
+
}
|
|
3773
|
+
if ((flags & 0x4) == 0x4) {
|
|
3774
|
+
timeProperties.push(PROPERTY_NAME_CREATION_DATE);
|
|
3775
|
+
timeRawProperties.push(PROPERTY_NAME_RAW_CREATION_DATE);
|
|
3776
|
+
}
|
|
3777
|
+
} else if (extraFieldExtendedTimestamp.data.length >= 5) {
|
|
3765
3778
|
timeProperties.push(PROPERTY_NAME_LAST_MODIFICATION_DATE);
|
|
3766
3779
|
timeRawProperties.push(PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE);
|
|
3767
3780
|
}
|
|
3768
|
-
if ((flags & 0x2) == 0x2) {
|
|
3769
|
-
timeProperties.push(PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
3770
|
-
timeRawProperties.push(PROPERTY_NAME_RAW_LAST_ACCESS_DATE);
|
|
3771
|
-
}
|
|
3772
|
-
if ((flags & 0x4) == 0x4) {
|
|
3773
|
-
timeProperties.push(PROPERTY_NAME_CREATION_DATE);
|
|
3774
|
-
timeRawProperties.push(PROPERTY_NAME_RAW_CREATION_DATE);
|
|
3775
|
-
}
|
|
3776
3781
|
let offset = 1;
|
|
3777
3782
|
timeProperties.forEach((propertyName, indexProperty) => {
|
|
3778
3783
|
if (extraFieldExtendedTimestamp.data.length >= offset + 4) {
|
|
@@ -4255,6 +4260,7 @@
|
|
|
4255
4260
|
version,
|
|
4256
4261
|
compressionMethod,
|
|
4257
4262
|
rawExtraFieldExtendedTimestamp,
|
|
4263
|
+
extraFieldExtendedTimestampFlag,
|
|
4258
4264
|
rawExtraFieldNTFS,
|
|
4259
4265
|
rawExtraFieldAES
|
|
4260
4266
|
} = headerInfo;
|
|
@@ -4386,6 +4392,7 @@
|
|
|
4386
4392
|
headerArray,
|
|
4387
4393
|
signature,
|
|
4388
4394
|
rawExtraFieldZip64,
|
|
4395
|
+
extraFieldExtendedTimestampFlag,
|
|
4389
4396
|
zip64UncompressedSize,
|
|
4390
4397
|
zip64CompressedSize,
|
|
4391
4398
|
zip64Offset,
|
|
@@ -4408,7 +4415,7 @@
|
|
|
4408
4415
|
directory,
|
|
4409
4416
|
rawExtraField,
|
|
4410
4417
|
encryptionStrength,
|
|
4411
|
-
extendedTimestamp
|
|
4418
|
+
extendedTimestamp
|
|
4412
4419
|
} = options;
|
|
4413
4420
|
const compressed = level !== 0 && !directory;
|
|
4414
4421
|
const encrypted = Boolean(password && getLength(password));
|
|
@@ -4425,19 +4432,23 @@
|
|
|
4425
4432
|
}
|
|
4426
4433
|
let rawExtraFieldNTFS;
|
|
4427
4434
|
let rawExtraFieldExtendedTimestamp;
|
|
4435
|
+
let extraFieldExtendedTimestampFlag;
|
|
4428
4436
|
if (extendedTimestamp) {
|
|
4429
4437
|
rawExtraFieldExtendedTimestamp = new Uint8Array(9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0));
|
|
4430
4438
|
const extraFieldExtendedTimestampView = getDataView(rawExtraFieldExtendedTimestamp);
|
|
4431
4439
|
setUint16(extraFieldExtendedTimestampView, 0, EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
4432
4440
|
setUint16(extraFieldExtendedTimestampView, 2, getLength(rawExtraFieldExtendedTimestamp) - 4);
|
|
4433
|
-
|
|
4441
|
+
extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
|
|
4434
4442
|
setUint8(extraFieldExtendedTimestampView, 4, extraFieldExtendedTimestampFlag);
|
|
4435
|
-
|
|
4443
|
+
let offset = 5;
|
|
4444
|
+
setUint32(extraFieldExtendedTimestampView, offset, Math.floor(lastModDate.getTime() / 1000));
|
|
4445
|
+
offset += 4;
|
|
4436
4446
|
if (lastAccessDate) {
|
|
4437
|
-
setUint32(extraFieldExtendedTimestampView,
|
|
4447
|
+
setUint32(extraFieldExtendedTimestampView, offset, Math.floor(lastAccessDate.getTime() / 1000));
|
|
4448
|
+
offset += 4;
|
|
4438
4449
|
}
|
|
4439
4450
|
if (creationDate) {
|
|
4440
|
-
setUint32(extraFieldExtendedTimestampView,
|
|
4451
|
+
setUint32(extraFieldExtendedTimestampView, offset, Math.floor(creationDate.getTime() / 1000));
|
|
4441
4452
|
}
|
|
4442
4453
|
try {
|
|
4443
4454
|
rawExtraFieldNTFS = new Uint8Array(36);
|
|
@@ -4518,6 +4529,7 @@
|
|
|
4518
4529
|
compressed,
|
|
4519
4530
|
version,
|
|
4520
4531
|
compressionMethod,
|
|
4532
|
+
extraFieldExtendedTimestampFlag,
|
|
4521
4533
|
rawExtraFieldExtendedTimestamp,
|
|
4522
4534
|
rawExtraFieldNTFS,
|
|
4523
4535
|
rawExtraFieldAES
|
|
@@ -4654,23 +4666,38 @@
|
|
|
4654
4666
|
let directoryDataLength = 0;
|
|
4655
4667
|
let directoryOffset = zipWriter.offset - diskOffset;
|
|
4656
4668
|
let filesLength = files.size;
|
|
4657
|
-
for (const [, {
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4669
|
+
for (const [, fileEntry] of files) {
|
|
4670
|
+
const {
|
|
4671
|
+
rawFilename,
|
|
4672
|
+
rawExtraFieldZip64,
|
|
4673
|
+
rawExtraFieldAES,
|
|
4674
|
+
rawComment,
|
|
4675
|
+
rawExtraFieldNTFS,
|
|
4676
|
+
rawExtraField,
|
|
4677
|
+
extendedTimestamp,
|
|
4678
|
+
extraFieldExtendedTimestampFlag,
|
|
4679
|
+
lastModDate
|
|
4680
|
+
} = fileEntry;
|
|
4681
|
+
let rawExtraFieldTimestamp;
|
|
4682
|
+
if (extendedTimestamp) {
|
|
4683
|
+
rawExtraFieldTimestamp = new Uint8Array(9);
|
|
4684
|
+
const extraFieldExtendedTimestampView = getDataView(rawExtraFieldTimestamp);
|
|
4685
|
+
setUint16(extraFieldExtendedTimestampView, 0, EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
4686
|
+
setUint16(extraFieldExtendedTimestampView, 2, 5);
|
|
4687
|
+
setUint8(extraFieldExtendedTimestampView, 4, extraFieldExtendedTimestampFlag);
|
|
4688
|
+
setUint32(extraFieldExtendedTimestampView, 5, Math.floor(lastModDate.getTime() / 1000));
|
|
4689
|
+
} else {
|
|
4690
|
+
rawExtraFieldTimestamp = new Uint8Array();
|
|
4691
|
+
}
|
|
4692
|
+
fileEntry.rawExtraFieldCDExtendedTimestamp = rawExtraFieldTimestamp;
|
|
4666
4693
|
directoryDataLength += 46 +
|
|
4667
4694
|
getLength(
|
|
4668
4695
|
rawFilename,
|
|
4669
4696
|
rawComment,
|
|
4670
4697
|
rawExtraFieldZip64,
|
|
4671
4698
|
rawExtraFieldAES,
|
|
4672
|
-
rawExtraFieldExtendedTimestamp,
|
|
4673
4699
|
rawExtraFieldNTFS,
|
|
4700
|
+
rawExtraFieldTimestamp,
|
|
4674
4701
|
rawExtraField);
|
|
4675
4702
|
}
|
|
4676
4703
|
const directoryArray = new Uint8Array(directoryDataLength);
|
|
@@ -4683,6 +4710,7 @@
|
|
|
4683
4710
|
rawFilename,
|
|
4684
4711
|
rawExtraFieldZip64,
|
|
4685
4712
|
rawExtraFieldAES,
|
|
4713
|
+
rawExtraFieldCDExtendedTimestamp,
|
|
4686
4714
|
rawExtraFieldNTFS,
|
|
4687
4715
|
rawExtraField,
|
|
4688
4716
|
rawComment,
|
|
@@ -4697,24 +4725,11 @@
|
|
|
4697
4725
|
msDosCompatible,
|
|
4698
4726
|
internalFileAttribute,
|
|
4699
4727
|
externalFileAttribute,
|
|
4700
|
-
extendedTimestamp,
|
|
4701
|
-
lastModDate,
|
|
4702
4728
|
diskNumberStart,
|
|
4703
4729
|
uncompressedSize,
|
|
4704
4730
|
compressedSize
|
|
4705
4731
|
} = fileEntry;
|
|
4706
|
-
|
|
4707
|
-
if (extendedTimestamp) {
|
|
4708
|
-
rawExtraFieldExtendedTimestamp = new Uint8Array(9);
|
|
4709
|
-
const extraFieldExtendedTimestampView = getDataView(rawExtraFieldExtendedTimestamp);
|
|
4710
|
-
setUint16(extraFieldExtendedTimestampView, 0, EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
4711
|
-
setUint16(extraFieldExtendedTimestampView, 2, getLength(rawExtraFieldExtendedTimestamp) - 4);
|
|
4712
|
-
setUint8(extraFieldExtendedTimestampView, 4, 0x1);
|
|
4713
|
-
setUint32(extraFieldExtendedTimestampView, 5, Math.floor(lastModDate.getTime() / 1000));
|
|
4714
|
-
} else {
|
|
4715
|
-
rawExtraFieldExtendedTimestamp = new Uint8Array();
|
|
4716
|
-
}
|
|
4717
|
-
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraField);
|
|
4732
|
+
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldCDExtendedTimestamp, rawExtraFieldNTFS, rawExtraField);
|
|
4718
4733
|
setUint32(directoryView, offset, CENTRAL_FILE_HEADER_SIGNATURE);
|
|
4719
4734
|
setUint16(directoryView, offset + 4, versionMadeBy);
|
|
4720
4735
|
const headerView = getDataView(headerArray);
|
|
@@ -4738,9 +4753,9 @@
|
|
|
4738
4753
|
arraySet(directoryArray, rawFilename, offset + 46);
|
|
4739
4754
|
arraySet(directoryArray, rawExtraFieldZip64, offset + 46 + getLength(rawFilename));
|
|
4740
4755
|
arraySet(directoryArray, rawExtraFieldAES, offset + 46 + getLength(rawFilename, rawExtraFieldZip64));
|
|
4741
|
-
arraySet(directoryArray,
|
|
4742
|
-
arraySet(directoryArray, rawExtraFieldNTFS, offset + 46 + getLength(rawFilename, rawExtraFieldZip64, rawExtraFieldAES,
|
|
4743
|
-
arraySet(directoryArray, rawExtraField, offset + 46 + getLength(rawFilename, rawExtraFieldZip64, rawExtraFieldAES,
|
|
4756
|
+
arraySet(directoryArray, rawExtraFieldCDExtendedTimestamp, offset + 46 + getLength(rawFilename, rawExtraFieldZip64, rawExtraFieldAES));
|
|
4757
|
+
arraySet(directoryArray, rawExtraFieldNTFS, offset + 46 + getLength(rawFilename, rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldCDExtendedTimestamp));
|
|
4758
|
+
arraySet(directoryArray, rawExtraField, offset + 46 + getLength(rawFilename, rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldCDExtendedTimestamp, rawExtraFieldNTFS));
|
|
4744
4759
|
arraySet(directoryArray, rawComment, offset + 46 + getLength(rawFilename) + extraFieldLength);
|
|
4745
4760
|
const directoryEntryLength = 46 + getLength(rawFilename, rawComment) + extraFieldLength;
|
|
4746
4761
|
if (offset - directoryDiskOffset > writer.availableSize) {
|
|
@@ -5561,26 +5576,29 @@
|
|
|
5561
5576
|
|
|
5562
5577
|
async function processChild(child) {
|
|
5563
5578
|
const name = options.relativePath ? child.getRelativeName(selectedEntry) : child.getFullname();
|
|
5564
|
-
let externalFileAttribute;
|
|
5565
|
-
let versionMadeBy;
|
|
5566
|
-
let comment;
|
|
5567
|
-
let lastModDate;
|
|
5568
5579
|
let childOptions = child.options || {};
|
|
5580
|
+
let zipEntryOptions = {};
|
|
5569
5581
|
if (child.data instanceof Entry) {
|
|
5570
|
-
|
|
5582
|
+
const {
|
|
5583
|
+
externalFileAttribute,
|
|
5584
|
+
versionMadeBy,
|
|
5585
|
+
comment,
|
|
5586
|
+
lastModDate,
|
|
5587
|
+
creationDate,
|
|
5588
|
+
lastAccessDate
|
|
5589
|
+
} = child.data;
|
|
5590
|
+
zipEntryOptions = {
|
|
5571
5591
|
externalFileAttribute,
|
|
5572
5592
|
versionMadeBy,
|
|
5573
5593
|
comment,
|
|
5574
|
-
lastModDate
|
|
5575
|
-
|
|
5594
|
+
lastModDate,
|
|
5595
|
+
creationDate,
|
|
5596
|
+
lastAccessDate
|
|
5597
|
+
};
|
|
5576
5598
|
}
|
|
5577
5599
|
await zipWriter.add(name, child.reader, Object.assign({
|
|
5578
5600
|
directory: child.directory
|
|
5579
|
-
}, Object.assign({}, options, {
|
|
5580
|
-
externalFileAttribute,
|
|
5581
|
-
versionMadeBy,
|
|
5582
|
-
comment,
|
|
5583
|
-
lastModDate,
|
|
5601
|
+
}, Object.assign({}, options, zipEntryOptions, childOptions, {
|
|
5584
5602
|
onprogress: async indexProgress => {
|
|
5585
5603
|
if (options.onprogress) {
|
|
5586
5604
|
entryOffsets.set(name, indexProgress);
|
|
@@ -5591,7 +5609,7 @@
|
|
|
5591
5609
|
}
|
|
5592
5610
|
}
|
|
5593
5611
|
}
|
|
5594
|
-
}
|
|
5612
|
+
})));
|
|
5595
5613
|
await process(zipWriter, child);
|
|
5596
5614
|
}
|
|
5597
5615
|
}
|