@zip.js/zip.js 2.6.40 → 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 +54 -32
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +53 -31
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +53 -31
- 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 +53 -31
- package/dist/zip.min.js +1 -1
- package/index.cjs +54 -32
- 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 +24 -13
- package/package.json +3 -2
package/dist/zip-full.js
CHANGED
|
@@ -7342,14 +7342,34 @@
|
|
|
7342
7342
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
7343
7343
|
*/
|
|
7344
7344
|
|
|
7345
|
+
const PROPERTY_NAME_FILENAME = "filename";
|
|
7346
|
+
const PROPERTY_NAME_RAW_FILENAME = "rawFilename";
|
|
7347
|
+
const PROPERTY_NAME_COMMENT = "comment";
|
|
7348
|
+
const PROPERTY_NAME_RAW_COMMENT = "rawComment";
|
|
7349
|
+
const PROPERTY_NAME_UNCOMPPRESSED_SIZE = "uncompressedSize";
|
|
7350
|
+
const PROPERTY_NAME_COMPPRESSED_SIZE = "compressedSize";
|
|
7351
|
+
const PROPERTY_NAME_OFFSET = "offset";
|
|
7352
|
+
const PROPERTY_NAME_DISK_NUMBER_START = "diskNumberStart";
|
|
7353
|
+
const PROPERTY_NAME_LAST_MODIFICATION_DATE = "lastModDate";
|
|
7354
|
+
const PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE = "rawLastModDate";
|
|
7355
|
+
const PROPERTY_NAME_LAST_ACCESS_DATE = "lastAccessDate";
|
|
7356
|
+
const PROPERTY_NAME_RAW_LAST_ACCESS_DATE = "rawLastAccessDate";
|
|
7357
|
+
const PROPERTY_NAME_CREATION_DATE = "creationDate";
|
|
7358
|
+
const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
|
|
7359
|
+
const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE = "internalFileAttribute";
|
|
7360
|
+
const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE = "externalFileAttribute";
|
|
7361
|
+
const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
|
|
7362
|
+
const PROPERTY_NAME_ZIP64 = "zip64";
|
|
7363
|
+
|
|
7345
7364
|
const PROPERTY_NAMES = [
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
"
|
|
7352
|
-
"
|
|
7365
|
+
PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, PROPERTY_NAME_COMPPRESSED_SIZE, PROPERTY_NAME_UNCOMPPRESSED_SIZE,
|
|
7366
|
+
PROPERTY_NAME_LAST_MODIFICATION_DATE, PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT,
|
|
7367
|
+
PROPERTY_NAME_LAST_ACCESS_DATE, PROPERTY_NAME_CREATION_DATE, PROPERTY_NAME_OFFSET, PROPERTY_NAME_DISK_NUMBER_START,
|
|
7368
|
+
PROPERTY_NAME_DISK_NUMBER_START, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE,
|
|
7369
|
+
PROPERTY_NAME_MS_DOS_COMPATIBLE, PROPERTY_NAME_ZIP64,
|
|
7370
|
+
"directory", "bitFlag", "encrypted", "signature", "filenameUTF8", "commentUTF8", "compressionMethod", "version", "versionMadeBy",
|
|
7371
|
+
"extraField", "rawExtraField", "extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment", "extraFieldAES", "extraFieldNTFS",
|
|
7372
|
+
"extraFieldExtendedTimestamp"];
|
|
7353
7373
|
|
|
7354
7374
|
class Entry {
|
|
7355
7375
|
|
|
@@ -7401,10 +7421,10 @@
|
|
|
7401
7421
|
const CHARSET_UTF8 = "utf-8";
|
|
7402
7422
|
const CHARSET_CP437 = "cp437";
|
|
7403
7423
|
const ZIP64_PROPERTIES = [
|
|
7404
|
-
[
|
|
7405
|
-
[
|
|
7406
|
-
[
|
|
7407
|
-
[
|
|
7424
|
+
[PROPERTY_NAME_UNCOMPPRESSED_SIZE, MAX_32_BITS],
|
|
7425
|
+
[PROPERTY_NAME_COMPPRESSED_SIZE, MAX_32_BITS],
|
|
7426
|
+
[PROPERTY_NAME_OFFSET, MAX_32_BITS],
|
|
7427
|
+
[PROPERTY_NAME_DISK_NUMBER_START, MAX_16_BITS]
|
|
7408
7428
|
];
|
|
7409
7429
|
const ZIP64_EXTRACTION = {
|
|
7410
7430
|
[MAX_16_BITS]: {
|
|
@@ -7764,12 +7784,12 @@
|
|
|
7764
7784
|
}
|
|
7765
7785
|
const extraFieldUnicodePath = extraField.get(EXTRAFIELD_TYPE_UNICODE_PATH);
|
|
7766
7786
|
if (extraFieldUnicodePath) {
|
|
7767
|
-
await readExtraFieldUnicode(extraFieldUnicodePath,
|
|
7787
|
+
await readExtraFieldUnicode(extraFieldUnicodePath, PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, directory, fileEntry);
|
|
7768
7788
|
directory.extraFieldUnicodePath = extraFieldUnicodePath;
|
|
7769
7789
|
}
|
|
7770
7790
|
const extraFieldUnicodeComment = extraField.get(EXTRAFIELD_TYPE_UNICODE_COMMENT);
|
|
7771
7791
|
if (extraFieldUnicodeComment) {
|
|
7772
|
-
await readExtraFieldUnicode(extraFieldUnicodeComment,
|
|
7792
|
+
await readExtraFieldUnicode(extraFieldUnicodeComment, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT, directory, fileEntry);
|
|
7773
7793
|
directory.extraFieldUnicodeComment = extraFieldUnicodeComment;
|
|
7774
7794
|
}
|
|
7775
7795
|
const extraFieldAES = extraField.get(EXTRAFIELD_TYPE_AES);
|
|
@@ -7883,16 +7903,16 @@
|
|
|
7883
7903
|
const timeProperties = [];
|
|
7884
7904
|
const timeRawProperties = [];
|
|
7885
7905
|
if ((flags & 0x1) == 0x1) {
|
|
7886
|
-
timeProperties.push(
|
|
7887
|
-
timeRawProperties.push(
|
|
7906
|
+
timeProperties.push(PROPERTY_NAME_LAST_MODIFICATION_DATE);
|
|
7907
|
+
timeRawProperties.push(PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE);
|
|
7888
7908
|
}
|
|
7889
7909
|
if ((flags & 0x2) == 0x2) {
|
|
7890
|
-
timeProperties.push(
|
|
7891
|
-
timeRawProperties.push(
|
|
7910
|
+
timeProperties.push(PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
7911
|
+
timeRawProperties.push(PROPERTY_NAME_RAW_LAST_ACCESS_DATE);
|
|
7892
7912
|
}
|
|
7893
7913
|
if ((flags & 0x4) == 0x4) {
|
|
7894
|
-
timeProperties.push(
|
|
7895
|
-
timeRawProperties.push(
|
|
7914
|
+
timeProperties.push(PROPERTY_NAME_CREATION_DATE);
|
|
7915
|
+
timeRawProperties.push(PROPERTY_NAME_RAW_CREATION_DATE);
|
|
7896
7916
|
}
|
|
7897
7917
|
let offset = 1;
|
|
7898
7918
|
timeProperties.forEach((propertyName, indexProperty) => {
|
|
@@ -8119,9 +8139,9 @@
|
|
|
8119
8139
|
if (versionMadeBy > MAX_16_BITS) {
|
|
8120
8140
|
throw new Error(ERR_INVALID_VERSION);
|
|
8121
8141
|
}
|
|
8122
|
-
const lastModDate = getOptionValue(zipWriter, options,
|
|
8123
|
-
const lastAccessDate = getOptionValue(zipWriter, options,
|
|
8124
|
-
const creationDate = getOptionValue(zipWriter, options,
|
|
8142
|
+
const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE) || new Date();
|
|
8143
|
+
const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
8144
|
+
const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
8125
8145
|
const password = getOptionValue(zipWriter, options, "password");
|
|
8126
8146
|
const encryptionStrength = getOptionValue(zipWriter, options, "encryptionStrength") || 3;
|
|
8127
8147
|
const zipCrypto = getOptionValue(zipWriter, options, "zipCrypto");
|
|
@@ -8159,13 +8179,13 @@
|
|
|
8159
8179
|
keepOrder = true;
|
|
8160
8180
|
}
|
|
8161
8181
|
let uncompressedSize = 0;
|
|
8162
|
-
let msDosCompatible = getOptionValue(zipWriter, options,
|
|
8182
|
+
let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
8163
8183
|
if (msDosCompatible === UNDEFINED_VALUE) {
|
|
8164
8184
|
msDosCompatible = true;
|
|
8165
8185
|
}
|
|
8166
|
-
const internalFileAttribute = getOptionValue(zipWriter, options,
|
|
8167
|
-
const externalFileAttribute = getOptionValue(zipWriter, options,
|
|
8168
|
-
let zip64 = getOptionValue(zipWriter, options,
|
|
8186
|
+
const internalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE) || 0;
|
|
8187
|
+
const externalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE) || 0;
|
|
8188
|
+
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
8169
8189
|
if (reader) {
|
|
8170
8190
|
if (reader instanceof ReadableStream) {
|
|
8171
8191
|
reader = {
|
|
@@ -8184,7 +8204,8 @@
|
|
|
8184
8204
|
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
|
|
8185
8205
|
}
|
|
8186
8206
|
}
|
|
8187
|
-
|
|
8207
|
+
const { diskOffset } = zipWriter.writer;
|
|
8208
|
+
if (zipWriter.offset + zipWriter.pendingEntriesSize - diskOffset >= MAX_32_BITS ||
|
|
8188
8209
|
uncompressedSize >= MAX_32_BITS ||
|
|
8189
8210
|
maximumCompressedSize >= MAX_32_BITS) {
|
|
8190
8211
|
if (zip64 === false || !keepOrder) {
|
|
@@ -8240,8 +8261,9 @@
|
|
|
8240
8261
|
let fileEntry;
|
|
8241
8262
|
try {
|
|
8242
8263
|
fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo }, options);
|
|
8264
|
+
zipWriter.pendingEntriesSize -= maximumEntrySize;
|
|
8243
8265
|
} catch (error) {
|
|
8244
|
-
if (!error.corruptedEntry
|
|
8266
|
+
if (!error.corruptedEntry) {
|
|
8245
8267
|
zipWriter.pendingEntriesSize -= maximumEntrySize;
|
|
8246
8268
|
}
|
|
8247
8269
|
throw error;
|
|
@@ -8291,7 +8313,7 @@
|
|
|
8291
8313
|
if (zipWriter.addSplitZipSignature) {
|
|
8292
8314
|
delete zipWriter.addSplitZipSignature;
|
|
8293
8315
|
const signatureArray = new Uint8Array(4);
|
|
8294
|
-
const signatureArrayView =
|
|
8316
|
+
const signatureArrayView = getDataView(signatureArray);
|
|
8295
8317
|
setUint32(signatureArrayView, 0, SPLIT_ZIP_FILE_SIGNATURE);
|
|
8296
8318
|
await writeData(writable, signatureArray);
|
|
8297
8319
|
zipWriter.offset += 4;
|
|
@@ -8429,9 +8451,9 @@
|
|
|
8429
8451
|
externalFileAttribute,
|
|
8430
8452
|
diskNumberStart
|
|
8431
8453
|
};
|
|
8454
|
+
let compressedSize = 0;
|
|
8432
8455
|
let uncompressedSize = 0;
|
|
8433
8456
|
let signature;
|
|
8434
|
-
let compressedSize = 0;
|
|
8435
8457
|
const { writable } = writer;
|
|
8436
8458
|
if (reader) {
|
|
8437
8459
|
reader.chunkSize = getChunkSize(config);
|
|
@@ -8826,7 +8848,7 @@
|
|
|
8826
8848
|
const endOfdirectoryView = getDataView(endOfdirectoryArray);
|
|
8827
8849
|
let lastDiskNumber = writer.diskNumber;
|
|
8828
8850
|
const { availableSize } = writer;
|
|
8829
|
-
if (availableSize < endOfdirectoryArray
|
|
8851
|
+
if (availableSize < getLength(endOfdirectoryArray)) {
|
|
8830
8852
|
lastDiskNumber++;
|
|
8831
8853
|
}
|
|
8832
8854
|
offset = 0;
|