@zip.js/zip.js 2.6.41 → 2.6.42
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/README.md +6 -5
- package/cli-deno/mc-zip.js +19 -13
- package/dist/zip-fs-full.js +52 -31
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +51 -30
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +51 -30
- 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 +51 -30
- package/dist/zip.min.js +1 -1
- package/index.cjs +52 -31
- package/index.d.ts +54 -29
- package/index.js +1 -1
- package/lib/core/zip-entry.js +45 -7
- package/lib/core/zip-reader.js +29 -13
- package/lib/core/zip-writer.js +22 -12
- package/package.json +3 -2
package/dist/zip-fs.js
CHANGED
|
@@ -3119,14 +3119,34 @@
|
|
|
3119
3119
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3120
3120
|
*/
|
|
3121
3121
|
|
|
3122
|
+
const PROPERTY_NAME_FILENAME = "filename";
|
|
3123
|
+
const PROPERTY_NAME_RAW_FILENAME = "rawFilename";
|
|
3124
|
+
const PROPERTY_NAME_COMMENT = "comment";
|
|
3125
|
+
const PROPERTY_NAME_RAW_COMMENT = "rawComment";
|
|
3126
|
+
const PROPERTY_NAME_UNCOMPPRESSED_SIZE = "uncompressedSize";
|
|
3127
|
+
const PROPERTY_NAME_COMPPRESSED_SIZE = "compressedSize";
|
|
3128
|
+
const PROPERTY_NAME_OFFSET = "offset";
|
|
3129
|
+
const PROPERTY_NAME_DISK_NUMBER_START = "diskNumberStart";
|
|
3130
|
+
const PROPERTY_NAME_LAST_MODIFICATION_DATE = "lastModDate";
|
|
3131
|
+
const PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE = "rawLastModDate";
|
|
3132
|
+
const PROPERTY_NAME_LAST_ACCESS_DATE = "lastAccessDate";
|
|
3133
|
+
const PROPERTY_NAME_RAW_LAST_ACCESS_DATE = "rawLastAccessDate";
|
|
3134
|
+
const PROPERTY_NAME_CREATION_DATE = "creationDate";
|
|
3135
|
+
const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
|
|
3136
|
+
const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE = "internalFileAttribute";
|
|
3137
|
+
const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE = "externalFileAttribute";
|
|
3138
|
+
const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
|
|
3139
|
+
const PROPERTY_NAME_ZIP64 = "zip64";
|
|
3140
|
+
|
|
3122
3141
|
const PROPERTY_NAMES = [
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
"
|
|
3129
|
-
"
|
|
3142
|
+
PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, PROPERTY_NAME_COMPPRESSED_SIZE, PROPERTY_NAME_UNCOMPPRESSED_SIZE,
|
|
3143
|
+
PROPERTY_NAME_LAST_MODIFICATION_DATE, PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT,
|
|
3144
|
+
PROPERTY_NAME_LAST_ACCESS_DATE, PROPERTY_NAME_CREATION_DATE, PROPERTY_NAME_OFFSET, PROPERTY_NAME_DISK_NUMBER_START,
|
|
3145
|
+
PROPERTY_NAME_DISK_NUMBER_START, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE,
|
|
3146
|
+
PROPERTY_NAME_MS_DOS_COMPATIBLE, PROPERTY_NAME_ZIP64,
|
|
3147
|
+
"directory", "bitFlag", "encrypted", "signature", "filenameUTF8", "commentUTF8", "compressionMethod", "version", "versionMadeBy",
|
|
3148
|
+
"extraField", "rawExtraField", "extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment", "extraFieldAES", "extraFieldNTFS",
|
|
3149
|
+
"extraFieldExtendedTimestamp"];
|
|
3130
3150
|
|
|
3131
3151
|
class Entry {
|
|
3132
3152
|
|
|
@@ -3178,10 +3198,10 @@
|
|
|
3178
3198
|
const CHARSET_UTF8 = "utf-8";
|
|
3179
3199
|
const CHARSET_CP437 = "cp437";
|
|
3180
3200
|
const ZIP64_PROPERTIES = [
|
|
3181
|
-
[
|
|
3182
|
-
[
|
|
3183
|
-
[
|
|
3184
|
-
[
|
|
3201
|
+
[PROPERTY_NAME_UNCOMPPRESSED_SIZE, MAX_32_BITS],
|
|
3202
|
+
[PROPERTY_NAME_COMPPRESSED_SIZE, MAX_32_BITS],
|
|
3203
|
+
[PROPERTY_NAME_OFFSET, MAX_32_BITS],
|
|
3204
|
+
[PROPERTY_NAME_DISK_NUMBER_START, MAX_16_BITS]
|
|
3185
3205
|
];
|
|
3186
3206
|
const ZIP64_EXTRACTION = {
|
|
3187
3207
|
[MAX_16_BITS]: {
|
|
@@ -3541,12 +3561,12 @@
|
|
|
3541
3561
|
}
|
|
3542
3562
|
const extraFieldUnicodePath = extraField.get(EXTRAFIELD_TYPE_UNICODE_PATH);
|
|
3543
3563
|
if (extraFieldUnicodePath) {
|
|
3544
|
-
await readExtraFieldUnicode(extraFieldUnicodePath,
|
|
3564
|
+
await readExtraFieldUnicode(extraFieldUnicodePath, PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, directory, fileEntry);
|
|
3545
3565
|
directory.extraFieldUnicodePath = extraFieldUnicodePath;
|
|
3546
3566
|
}
|
|
3547
3567
|
const extraFieldUnicodeComment = extraField.get(EXTRAFIELD_TYPE_UNICODE_COMMENT);
|
|
3548
3568
|
if (extraFieldUnicodeComment) {
|
|
3549
|
-
await readExtraFieldUnicode(extraFieldUnicodeComment,
|
|
3569
|
+
await readExtraFieldUnicode(extraFieldUnicodeComment, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT, directory, fileEntry);
|
|
3550
3570
|
directory.extraFieldUnicodeComment = extraFieldUnicodeComment;
|
|
3551
3571
|
}
|
|
3552
3572
|
const extraFieldAES = extraField.get(EXTRAFIELD_TYPE_AES);
|
|
@@ -3660,16 +3680,16 @@
|
|
|
3660
3680
|
const timeProperties = [];
|
|
3661
3681
|
const timeRawProperties = [];
|
|
3662
3682
|
if ((flags & 0x1) == 0x1) {
|
|
3663
|
-
timeProperties.push(
|
|
3664
|
-
timeRawProperties.push(
|
|
3683
|
+
timeProperties.push(PROPERTY_NAME_LAST_MODIFICATION_DATE);
|
|
3684
|
+
timeRawProperties.push(PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE);
|
|
3665
3685
|
}
|
|
3666
3686
|
if ((flags & 0x2) == 0x2) {
|
|
3667
|
-
timeProperties.push(
|
|
3668
|
-
timeRawProperties.push(
|
|
3687
|
+
timeProperties.push(PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
3688
|
+
timeRawProperties.push(PROPERTY_NAME_RAW_LAST_ACCESS_DATE);
|
|
3669
3689
|
}
|
|
3670
3690
|
if ((flags & 0x4) == 0x4) {
|
|
3671
|
-
timeProperties.push(
|
|
3672
|
-
timeRawProperties.push(
|
|
3691
|
+
timeProperties.push(PROPERTY_NAME_CREATION_DATE);
|
|
3692
|
+
timeRawProperties.push(PROPERTY_NAME_RAW_CREATION_DATE);
|
|
3673
3693
|
}
|
|
3674
3694
|
let offset = 1;
|
|
3675
3695
|
timeProperties.forEach((propertyName, indexProperty) => {
|
|
@@ -3896,9 +3916,9 @@
|
|
|
3896
3916
|
if (versionMadeBy > MAX_16_BITS) {
|
|
3897
3917
|
throw new Error(ERR_INVALID_VERSION);
|
|
3898
3918
|
}
|
|
3899
|
-
const lastModDate = getOptionValue(zipWriter, options,
|
|
3900
|
-
const lastAccessDate = getOptionValue(zipWriter, options,
|
|
3901
|
-
const creationDate = getOptionValue(zipWriter, options,
|
|
3919
|
+
const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE) || new Date();
|
|
3920
|
+
const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
3921
|
+
const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
3902
3922
|
const password = getOptionValue(zipWriter, options, "password");
|
|
3903
3923
|
const encryptionStrength = getOptionValue(zipWriter, options, "encryptionStrength") || 3;
|
|
3904
3924
|
const zipCrypto = getOptionValue(zipWriter, options, "zipCrypto");
|
|
@@ -3936,13 +3956,13 @@
|
|
|
3936
3956
|
keepOrder = true;
|
|
3937
3957
|
}
|
|
3938
3958
|
let uncompressedSize = 0;
|
|
3939
|
-
let msDosCompatible = getOptionValue(zipWriter, options,
|
|
3959
|
+
let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
3940
3960
|
if (msDosCompatible === UNDEFINED_VALUE) {
|
|
3941
3961
|
msDosCompatible = true;
|
|
3942
3962
|
}
|
|
3943
|
-
const internalFileAttribute = getOptionValue(zipWriter, options,
|
|
3944
|
-
const externalFileAttribute = getOptionValue(zipWriter, options,
|
|
3945
|
-
let zip64 = getOptionValue(zipWriter, options,
|
|
3963
|
+
const internalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE) || 0;
|
|
3964
|
+
const externalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE) || 0;
|
|
3965
|
+
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
3946
3966
|
if (reader) {
|
|
3947
3967
|
if (reader instanceof ReadableStream) {
|
|
3948
3968
|
reader = {
|
|
@@ -4018,8 +4038,9 @@
|
|
|
4018
4038
|
let fileEntry;
|
|
4019
4039
|
try {
|
|
4020
4040
|
fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo }, options);
|
|
4041
|
+
zipWriter.pendingEntriesSize -= maximumEntrySize;
|
|
4021
4042
|
} catch (error) {
|
|
4022
|
-
if (!error.corruptedEntry
|
|
4043
|
+
if (!error.corruptedEntry) {
|
|
4023
4044
|
zipWriter.pendingEntriesSize -= maximumEntrySize;
|
|
4024
4045
|
}
|
|
4025
4046
|
throw error;
|
|
@@ -4069,7 +4090,7 @@
|
|
|
4069
4090
|
if (zipWriter.addSplitZipSignature) {
|
|
4070
4091
|
delete zipWriter.addSplitZipSignature;
|
|
4071
4092
|
const signatureArray = new Uint8Array(4);
|
|
4072
|
-
const signatureArrayView =
|
|
4093
|
+
const signatureArrayView = getDataView(signatureArray);
|
|
4073
4094
|
setUint32(signatureArrayView, 0, SPLIT_ZIP_FILE_SIGNATURE);
|
|
4074
4095
|
await writeData(writable, signatureArray);
|
|
4075
4096
|
zipWriter.offset += 4;
|
|
@@ -4207,9 +4228,9 @@
|
|
|
4207
4228
|
externalFileAttribute,
|
|
4208
4229
|
diskNumberStart
|
|
4209
4230
|
};
|
|
4231
|
+
let compressedSize = 0;
|
|
4210
4232
|
let uncompressedSize = 0;
|
|
4211
4233
|
let signature;
|
|
4212
|
-
let compressedSize = 0;
|
|
4213
4234
|
const { writable } = writer;
|
|
4214
4235
|
if (reader) {
|
|
4215
4236
|
reader.chunkSize = getChunkSize(config);
|
|
@@ -4604,7 +4625,7 @@
|
|
|
4604
4625
|
const endOfdirectoryView = getDataView(endOfdirectoryArray);
|
|
4605
4626
|
let lastDiskNumber = writer.diskNumber;
|
|
4606
4627
|
const { availableSize } = writer;
|
|
4607
|
-
if (availableSize < endOfdirectoryArray
|
|
4628
|
+
if (availableSize < getLength(endOfdirectoryArray)) {
|
|
4608
4629
|
lastDiskNumber++;
|
|
4609
4630
|
}
|
|
4610
4631
|
offset = 0;
|