@zip.js/zip.js 2.7.54 → 2.7.56
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/zip-fs-full.js +89 -56
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +89 -48
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +81 -51
- 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 +81 -43
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +44 -0
- package/index.cjs +89 -56
- package/index.d.ts +21 -4
- package/index.min.js +1 -1
- package/lib/core/codec-pool.js +2 -1
- package/lib/core/codec-worker.js +10 -5
- package/lib/core/configuration.js +2 -1
- package/lib/core/constants.js +4 -0
- package/lib/core/streams/aes-crypto-stream.js +4 -2
- package/lib/core/streams/codecs/deflate.js +0 -4
- package/lib/core/streams/codecs/inflate.js +0 -4
- package/lib/core/streams/zip-entry-stream.js +4 -2
- package/lib/core/z-worker-core.js +4 -2
- package/lib/core/zip-entry.js +5 -4
- package/lib/core/zip-fs-core.js +8 -5
- package/lib/core/zip-reader.js +27 -11
- package/lib/core/zip-writer.js +30 -17
- package/lib/zip-data-uri.js +2 -1
- package/lib/zip-fs.js +2 -1
- package/lib/zip-full-fflate.js +2 -1
- package/lib/zip-full.js +2 -1
- package/lib/zip.js +2 -1
- package/package.json +87 -84
package/index.cjs
CHANGED
|
@@ -1240,7 +1240,6 @@ function Deflate() {
|
|
|
1240
1240
|
}
|
|
1241
1241
|
|
|
1242
1242
|
// Copy as much as possible from input to output:
|
|
1243
|
-
// eslint-disable-next-line no-constant-condition
|
|
1244
1243
|
while (true) {
|
|
1245
1244
|
// Fill the win as much as possible:
|
|
1246
1245
|
if (lookahead <= 1) {
|
|
@@ -1335,7 +1334,6 @@ function Deflate() {
|
|
|
1335
1334
|
|
|
1336
1335
|
// We check for insufficient lookahead only every 8th comparison;
|
|
1337
1336
|
// the 256th check will be made at strstart+258.
|
|
1338
|
-
// eslint-disable-next-line no-empty
|
|
1339
1337
|
do {
|
|
1340
1338
|
// empty block
|
|
1341
1339
|
} while (win[++scan] == win[++match] && win[++scan] == win[++match] && win[++scan] == win[++match]
|
|
@@ -1371,7 +1369,6 @@ function Deflate() {
|
|
|
1371
1369
|
let hash_head = 0; // head of the hash chain
|
|
1372
1370
|
let bflush; // set if current block must be flushed
|
|
1373
1371
|
|
|
1374
|
-
// eslint-disable-next-line no-constant-condition
|
|
1375
1372
|
while (true) {
|
|
1376
1373
|
// Make sure that we always have enough lookahead, except
|
|
1377
1374
|
// at the end of the input file. We need MAX_MATCH bytes
|
|
@@ -1478,7 +1475,6 @@ function Deflate() {
|
|
|
1478
1475
|
let max_insert;
|
|
1479
1476
|
|
|
1480
1477
|
// Process the input block.
|
|
1481
|
-
// eslint-disable-next-line no-constant-condition
|
|
1482
1478
|
while (true) {
|
|
1483
1479
|
// Make sure that we always have enough lookahead, except
|
|
1484
1480
|
// at the end of the input file. We need MAX_MATCH bytes
|
|
@@ -2828,7 +2824,6 @@ function InfCodes() {
|
|
|
2828
2824
|
m = q < s.read ? s.read - q - 1 : s.end - q;
|
|
2829
2825
|
|
|
2830
2826
|
// process input and output based on current state
|
|
2831
|
-
// eslint-disable-next-line no-constant-condition
|
|
2832
2827
|
while (true) {
|
|
2833
2828
|
switch (mode) {
|
|
2834
2829
|
// waiting for "i:"=input, "o:"=output, "x:"=nothing
|
|
@@ -3319,7 +3314,6 @@ function InfBlocks(z, w) {
|
|
|
3319
3314
|
|
|
3320
3315
|
// process input based on current state
|
|
3321
3316
|
// DEBUG dtree
|
|
3322
|
-
// eslint-disable-next-line no-constant-condition
|
|
3323
3317
|
while (true) {
|
|
3324
3318
|
let bl, bd, tl, td, bl_, bd_, tl_, td_;
|
|
3325
3319
|
switch (mode) {
|
|
@@ -3596,7 +3590,6 @@ function InfBlocks(z, w) {
|
|
|
3596
3590
|
mode = DTREE;
|
|
3597
3591
|
/* falls through */
|
|
3598
3592
|
case DTREE:
|
|
3599
|
-
// eslint-disable-next-line no-constant-condition
|
|
3600
3593
|
while (true) {
|
|
3601
3594
|
t = table;
|
|
3602
3595
|
if (index >= 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) {
|
|
@@ -3904,7 +3897,6 @@ function Inflate() {
|
|
|
3904
3897
|
const istate = z.istate;
|
|
3905
3898
|
f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
|
|
3906
3899
|
r = Z_BUF_ERROR;
|
|
3907
|
-
// eslint-disable-next-line no-constant-condition
|
|
3908
3900
|
while (true) {
|
|
3909
3901
|
switch (istate.mode) {
|
|
3910
3902
|
case METHOD:
|
|
@@ -4284,6 +4276,8 @@ const BITFLAG_LEVEL = 0x06;
|
|
|
4284
4276
|
const BITFLAG_DATA_DESCRIPTOR = 0x0008;
|
|
4285
4277
|
const BITFLAG_LANG_ENCODING_FLAG = 0x0800;
|
|
4286
4278
|
const FILE_ATTR_MSDOS_DIR_MASK = 0x10;
|
|
4279
|
+
const FILE_ATTR_UNIX_DIR_MASK = 0x4000;
|
|
4280
|
+
const FILE_ATTR_UNIX_EXECUTABLE_MASK = 0o111;
|
|
4287
4281
|
|
|
4288
4282
|
const VERSION_DEFLATE = 0x14;
|
|
4289
4283
|
const VERSION_ZIP64 = 0x2D;
|
|
@@ -4384,7 +4378,8 @@ try {
|
|
|
4384
4378
|
if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
|
|
4385
4379
|
maxWorkers = navigator.hardwareConcurrency;
|
|
4386
4380
|
}
|
|
4387
|
-
|
|
4381
|
+
// eslint-disable-next-line no-unused-vars
|
|
4382
|
+
} catch (_) {
|
|
4388
4383
|
// ignored
|
|
4389
4384
|
}
|
|
4390
4385
|
const DEFAULT_CONFIGURATION = {
|
|
@@ -7390,7 +7385,8 @@ async function importKey(format, password, algorithm, extractable, keyUsages) {
|
|
|
7390
7385
|
if (IMPORT_KEY_SUPPORTED) {
|
|
7391
7386
|
try {
|
|
7392
7387
|
return await subtle.importKey(format, password, algorithm, extractable, keyUsages);
|
|
7393
|
-
|
|
7388
|
+
// eslint-disable-next-line no-unused-vars
|
|
7389
|
+
} catch (_) {
|
|
7394
7390
|
IMPORT_KEY_SUPPORTED = false;
|
|
7395
7391
|
return misc.importKey(password);
|
|
7396
7392
|
}
|
|
@@ -7403,7 +7399,8 @@ async function deriveBits(algorithm, baseKey, length) {
|
|
|
7403
7399
|
if (DERIVE_BITS_SUPPORTED) {
|
|
7404
7400
|
try {
|
|
7405
7401
|
return await subtle.deriveBits(algorithm, baseKey, length);
|
|
7406
|
-
|
|
7402
|
+
// eslint-disable-next-line no-unused-vars
|
|
7403
|
+
} catch (_) {
|
|
7407
7404
|
DERIVE_BITS_SUPPORTED = false;
|
|
7408
7405
|
return misc.pbkdf2(baseKey, algorithm.salt, DERIVED_BITS_ALGORITHM.iterations, length);
|
|
7409
7406
|
}
|
|
@@ -7721,11 +7718,13 @@ function pipeThroughCommpressionStream(readable, useCompressionStream, options,
|
|
|
7721
7718
|
try {
|
|
7722
7719
|
const CompressionStream = useCompressionStream && CodecStreamNative ? CodecStreamNative : CodecStream;
|
|
7723
7720
|
readable = pipeThrough(readable, new CompressionStream(COMPRESSION_FORMAT, options));
|
|
7724
|
-
|
|
7721
|
+
// eslint-disable-next-line no-unused-vars
|
|
7722
|
+
} catch (_) {
|
|
7725
7723
|
if (useCompressionStream) {
|
|
7726
7724
|
try {
|
|
7727
7725
|
readable = pipeThrough(readable, new CodecStream(COMPRESSION_FORMAT, options));
|
|
7728
|
-
|
|
7726
|
+
// eslint-disable-next-line no-unused-vars
|
|
7727
|
+
} catch (_) {
|
|
7729
7728
|
return readable;
|
|
7730
7729
|
}
|
|
7731
7730
|
} else {
|
|
@@ -7968,7 +7967,8 @@ class ProgressWatcherStream extends TransformStream {
|
|
|
7968
7967
|
async function callHandler(handler, ...parameters) {
|
|
7969
7968
|
try {
|
|
7970
7969
|
await handler(...parameters);
|
|
7971
|
-
|
|
7970
|
+
// eslint-disable-next-line no-unused-vars
|
|
7971
|
+
} catch (_) {
|
|
7972
7972
|
// ignored
|
|
7973
7973
|
}
|
|
7974
7974
|
}
|
|
@@ -7985,7 +7985,8 @@ function createWebWorkerInterface(workerData, config) {
|
|
|
7985
7985
|
let worker;
|
|
7986
7986
|
try {
|
|
7987
7987
|
worker = getWebWorker(workerData.scripts[0], baseURL, workerData);
|
|
7988
|
-
|
|
7988
|
+
// eslint-disable-next-line no-unused-vars
|
|
7989
|
+
} catch (_) {
|
|
7989
7990
|
WEB_WORKERS_SUPPORTED = false;
|
|
7990
7991
|
return createWorkerInterface(workerData, config);
|
|
7991
7992
|
}
|
|
@@ -8088,13 +8089,15 @@ function getWebWorker(url, baseURL, workerData) {
|
|
|
8088
8089
|
}
|
|
8089
8090
|
try {
|
|
8090
8091
|
scriptUrl = new URL(url, baseURL);
|
|
8091
|
-
|
|
8092
|
+
// eslint-disable-next-line no-unused-vars
|
|
8093
|
+
} catch (_) {
|
|
8092
8094
|
scriptUrl = url;
|
|
8093
8095
|
}
|
|
8094
8096
|
if (classicWorkersSupported) {
|
|
8095
8097
|
try {
|
|
8096
8098
|
worker = new Worker(scriptUrl);
|
|
8097
|
-
|
|
8099
|
+
// eslint-disable-next-line no-unused-vars
|
|
8100
|
+
} catch (_) {
|
|
8098
8101
|
classicWorkersSupported = false;
|
|
8099
8102
|
worker = new Worker(scriptUrl, workerOptions);
|
|
8100
8103
|
}
|
|
@@ -8132,7 +8135,8 @@ function sendMessage(message, { worker, writer, onTaskFinished, transferStreams
|
|
|
8132
8135
|
try {
|
|
8133
8136
|
worker.postMessage(message, transferables);
|
|
8134
8137
|
return true;
|
|
8135
|
-
|
|
8138
|
+
// eslint-disable-next-line no-unused-vars
|
|
8139
|
+
} catch (_) {
|
|
8136
8140
|
transferStreamsSupported = false;
|
|
8137
8141
|
message.readable = message.writable = null;
|
|
8138
8142
|
worker.postMessage(message);
|
|
@@ -8275,7 +8279,8 @@ function terminateWorker(workerData, workerOptions) {
|
|
|
8275
8279
|
pool = pool.filter(data => data != workerData);
|
|
8276
8280
|
try {
|
|
8277
8281
|
await workerData.terminate();
|
|
8278
|
-
|
|
8282
|
+
// eslint-disable-next-line no-unused-vars
|
|
8283
|
+
} catch (_) {
|
|
8279
8284
|
// ignored
|
|
8280
8285
|
}
|
|
8281
8286
|
}, terminateWorkerTimeout);
|
|
@@ -8680,7 +8685,7 @@ async function initHttpReader(httpReader, sendRequest, getRequestData) {
|
|
|
8680
8685
|
combineSizeEocd
|
|
8681
8686
|
} = httpReader;
|
|
8682
8687
|
if (isHttpFamily(url) && (useRangeHeader || forceRangeRequests) && (typeof preventHeadRequest == "undefined" || preventHeadRequest)) {
|
|
8683
|
-
const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, combineSizeEocd ? -
|
|
8688
|
+
const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, combineSizeEocd ? -22 : undefined));
|
|
8684
8689
|
if (!forceRangeRequests && response.headers.get(HTTP_HEADER_ACCEPT_RANGES) != HTTP_RANGE_UNIT) {
|
|
8685
8690
|
throw new Error(ERR_HTTP_RANGE);
|
|
8686
8691
|
} else {
|
|
@@ -9203,7 +9208,9 @@ const PROPERTY_NAME_RAW_LAST_ACCESS_DATE = "rawLastAccessDate";
|
|
|
9203
9208
|
const PROPERTY_NAME_CREATION_DATE = "creationDate";
|
|
9204
9209
|
const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
|
|
9205
9210
|
const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE = "internalFileAttribute";
|
|
9211
|
+
const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES = "internalFileAttributes";
|
|
9206
9212
|
const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE = "externalFileAttribute";
|
|
9213
|
+
const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttributes";
|
|
9207
9214
|
const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
|
|
9208
9215
|
const PROPERTY_NAME_ZIP64 = "zip64";
|
|
9209
9216
|
const PROPERTY_NAME_ENCRYPTED = "encrypted";
|
|
@@ -9215,10 +9222,7 @@ const PROPERTY_NAMES = [
|
|
|
9215
9222
|
PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, PROPERTY_NAME_COMPPRESSED_SIZE, PROPERTY_NAME_UNCOMPPRESSED_SIZE,
|
|
9216
9223
|
PROPERTY_NAME_LAST_MODIFICATION_DATE, PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT,
|
|
9217
9224
|
PROPERTY_NAME_LAST_ACCESS_DATE, PROPERTY_NAME_CREATION_DATE, PROPERTY_NAME_OFFSET, PROPERTY_NAME_DISK_NUMBER_START,
|
|
9218
|
-
PROPERTY_NAME_DISK_NUMBER_START, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE,
|
|
9219
|
-
PROPERTY_NAME_MS_DOS_COMPATIBLE, PROPERTY_NAME_ZIP64, PROPERTY_NAME_ENCRYPTED, PROPERTY_NAME_VERSION, PROPERTY_NAME_VERSION_MADE_BY,
|
|
9220
|
-
PROPERTY_NAME_ZIPCRYPTO, "directory", "bitFlag", "signature", "filenameUTF8", "commentUTF8", "compressionMethod", "extraField", "rawExtraField",
|
|
9221
|
-
"extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment", "extraFieldAES", "extraFieldNTFS", "extraFieldExtendedTimestamp"];
|
|
9225
|
+
PROPERTY_NAME_DISK_NUMBER_START, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_MS_DOS_COMPATIBLE, PROPERTY_NAME_ZIP64, PROPERTY_NAME_ENCRYPTED, PROPERTY_NAME_VERSION, PROPERTY_NAME_VERSION_MADE_BY, PROPERTY_NAME_ZIPCRYPTO, "directory", "executable", "bitFlag", "signature", "filenameUTF8", "commentUTF8", "compressionMethod", "extraField", "rawExtraField", "extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment", "extraFieldAES", "extraFieldNTFS", "extraFieldExtendedTimestamp"];
|
|
9222
9226
|
|
|
9223
9227
|
class Entry {
|
|
9224
9228
|
|
|
@@ -9409,14 +9413,20 @@ class ZipReader {
|
|
|
9409
9413
|
const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
|
|
9410
9414
|
const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
|
|
9411
9415
|
const versionMadeBy = getUint16(directoryView, offset + 4);
|
|
9412
|
-
const msDosCompatible =
|
|
9416
|
+
const msDosCompatible = versionMadeBy >> 8 == 0;
|
|
9417
|
+
const unixCompatible = versionMadeBy >> 8 == 3;
|
|
9413
9418
|
const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
|
|
9414
9419
|
const commentLength = getUint16(directoryView, offset + 32);
|
|
9415
9420
|
const endOffset = commentOffset + commentLength;
|
|
9416
9421
|
const rawComment = directoryArray.subarray(commentOffset, endOffset);
|
|
9417
9422
|
const filenameUTF8 = languageEncodingFlag;
|
|
9418
9423
|
const commentUTF8 = languageEncodingFlag;
|
|
9419
|
-
const
|
|
9424
|
+
const externalFileAttributes = getUint32(directoryView, offset + 38);
|
|
9425
|
+
const directory =
|
|
9426
|
+
(msDosCompatible && ((getUint8(directoryView, offset + 38) & FILE_ATTR_MSDOS_DIR_MASK) == FILE_ATTR_MSDOS_DIR_MASK)) ||
|
|
9427
|
+
(unixCompatible && (((externalFileAttributes >> 16) & FILE_ATTR_UNIX_DIR_MASK) == FILE_ATTR_UNIX_DIR_MASK)) ||
|
|
9428
|
+
(rawFilename.length && rawFilename[rawFilename.length - 1] == DIRECTORY_SIGNATURE.charCodeAt(0));
|
|
9429
|
+
const executable = (unixCompatible && (((externalFileAttributes >> 16) & FILE_ATTR_UNIX_EXECUTABLE_MASK) == FILE_ATTR_UNIX_EXECUTABLE_MASK));
|
|
9420
9430
|
const offsetFileEntry = getUint32(directoryView, offset + 42) + prependedDataLength;
|
|
9421
9431
|
Object.assign(fileEntry, {
|
|
9422
9432
|
versionMadeBy,
|
|
@@ -9427,13 +9437,16 @@ class ZipReader {
|
|
|
9427
9437
|
directory,
|
|
9428
9438
|
offset: offsetFileEntry,
|
|
9429
9439
|
diskNumberStart: getUint16(directoryView, offset + 34),
|
|
9430
|
-
|
|
9431
|
-
|
|
9440
|
+
internalFileAttributes: getUint16(directoryView, offset + 36),
|
|
9441
|
+
externalFileAttributes,
|
|
9432
9442
|
rawFilename,
|
|
9433
9443
|
filenameUTF8,
|
|
9434
9444
|
commentUTF8,
|
|
9435
|
-
rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset)
|
|
9445
|
+
rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset),
|
|
9446
|
+
executable
|
|
9436
9447
|
});
|
|
9448
|
+
fileEntry.internalFileAttribute = fileEntry.internalFileAttributes;
|
|
9449
|
+
fileEntry.externalFileAttribute = fileEntry.externalFileAttributes;
|
|
9437
9450
|
const decode = getOptionValue$1(zipReader, options, "decodeText") || decodeText;
|
|
9438
9451
|
const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
|
|
9439
9452
|
const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
|
|
@@ -9461,7 +9474,8 @@ class ZipReader {
|
|
|
9461
9474
|
if (onprogress) {
|
|
9462
9475
|
try {
|
|
9463
9476
|
await onprogress(indexFile + 1, filesLength, new Entry(fileEntry));
|
|
9464
|
-
|
|
9477
|
+
// eslint-disable-next-line no-unused-vars
|
|
9478
|
+
} catch (_) {
|
|
9465
9479
|
// ignored
|
|
9466
9480
|
}
|
|
9467
9481
|
}
|
|
@@ -9673,7 +9687,8 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
9673
9687
|
});
|
|
9674
9688
|
offsetExtraField += 4 + size;
|
|
9675
9689
|
}
|
|
9676
|
-
|
|
9690
|
+
// eslint-disable-next-line no-unused-vars
|
|
9691
|
+
} catch (_) {
|
|
9677
9692
|
// ignored
|
|
9678
9693
|
}
|
|
9679
9694
|
const compressionMethod = getUint16(dataView, offset + 4);
|
|
@@ -9780,7 +9795,8 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
|
|
|
9780
9795
|
}
|
|
9781
9796
|
offsetExtraField += 4 + attributeSize;
|
|
9782
9797
|
}
|
|
9783
|
-
|
|
9798
|
+
// eslint-disable-next-line no-unused-vars
|
|
9799
|
+
} catch (_) {
|
|
9784
9800
|
// ignored
|
|
9785
9801
|
}
|
|
9786
9802
|
try {
|
|
@@ -9801,7 +9817,8 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
|
|
|
9801
9817
|
Object.assign(extraFieldNTFS, extraFieldData);
|
|
9802
9818
|
Object.assign(directory, extraFieldData);
|
|
9803
9819
|
}
|
|
9804
|
-
|
|
9820
|
+
// eslint-disable-next-line no-unused-vars
|
|
9821
|
+
} catch (_) {
|
|
9805
9822
|
// ignored
|
|
9806
9823
|
}
|
|
9807
9824
|
}
|
|
@@ -9870,7 +9887,8 @@ function getDate(timeRaw) {
|
|
|
9870
9887
|
const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & 0x0000ffff;
|
|
9871
9888
|
try {
|
|
9872
9889
|
return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
|
|
9873
|
-
|
|
9890
|
+
// eslint-disable-next-line no-unused-vars
|
|
9891
|
+
} catch (_) {
|
|
9874
9892
|
// ignored
|
|
9875
9893
|
}
|
|
9876
9894
|
}
|
|
@@ -10082,8 +10100,14 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
10082
10100
|
const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
10083
10101
|
const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
10084
10102
|
const msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE, true);
|
|
10085
|
-
|
|
10086
|
-
|
|
10103
|
+
let internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, 0);
|
|
10104
|
+
if (internalFileAttributes === 0) {
|
|
10105
|
+
internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, 0);
|
|
10106
|
+
}
|
|
10107
|
+
let externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, 0);
|
|
10108
|
+
if (externalFileAttributes === 0) {
|
|
10109
|
+
externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, 0);
|
|
10110
|
+
}
|
|
10087
10111
|
const passThrough = getOptionValue(zipWriter, options, "passThrough");
|
|
10088
10112
|
let password, rawPassword;
|
|
10089
10113
|
if (!passThrough) {
|
|
@@ -10199,8 +10223,10 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
10199
10223
|
dataDescriptorSignature,
|
|
10200
10224
|
signal,
|
|
10201
10225
|
msDosCompatible,
|
|
10202
|
-
internalFileAttribute,
|
|
10203
|
-
|
|
10226
|
+
internalFileAttribute: internalFileAttributes,
|
|
10227
|
+
internalFileAttributes,
|
|
10228
|
+
externalFileAttribute: externalFileAttributes,
|
|
10229
|
+
externalFileAttributes,
|
|
10204
10230
|
useCompressionStream,
|
|
10205
10231
|
passThrough,
|
|
10206
10232
|
encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
|
|
@@ -10321,7 +10347,8 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
10321
10347
|
if (error) {
|
|
10322
10348
|
try {
|
|
10323
10349
|
error.corruptedEntry = true;
|
|
10324
|
-
|
|
10350
|
+
// eslint-disable-next-line no-unused-vars
|
|
10351
|
+
} catch (_) {
|
|
10325
10352
|
// ignored
|
|
10326
10353
|
}
|
|
10327
10354
|
}
|
|
@@ -10414,8 +10441,8 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
10414
10441
|
encryptionStrength,
|
|
10415
10442
|
extendedTimestamp,
|
|
10416
10443
|
msDosCompatible,
|
|
10417
|
-
|
|
10418
|
-
|
|
10444
|
+
internalFileAttributes,
|
|
10445
|
+
externalFileAttributes,
|
|
10419
10446
|
useCompressionStream,
|
|
10420
10447
|
passThrough
|
|
10421
10448
|
} = options;
|
|
@@ -10434,8 +10461,8 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
10434
10461
|
rawExtraField,
|
|
10435
10462
|
extendedTimestamp,
|
|
10436
10463
|
msDosCompatible,
|
|
10437
|
-
|
|
10438
|
-
|
|
10464
|
+
internalFileAttributes,
|
|
10465
|
+
externalFileAttributes,
|
|
10439
10466
|
diskNumberStart
|
|
10440
10467
|
};
|
|
10441
10468
|
let {
|
|
@@ -10595,7 +10622,8 @@ function getHeaderInfo(options) {
|
|
|
10595
10622
|
setBigUint64(extraFieldNTFSView, 12, lastModTimeNTFS);
|
|
10596
10623
|
setBigUint64(extraFieldNTFSView, 20, getTimeNTFS(lastAccessDate) || lastModTimeNTFS);
|
|
10597
10624
|
setBigUint64(extraFieldNTFSView, 28, getTimeNTFS(creationDate) || lastModTimeNTFS);
|
|
10598
|
-
|
|
10625
|
+
// eslint-disable-next-line no-unused-vars
|
|
10626
|
+
} catch (_) {
|
|
10599
10627
|
rawExtraFieldNTFS = new Uint8Array();
|
|
10600
10628
|
}
|
|
10601
10629
|
} else {
|
|
@@ -10890,8 +10918,8 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
10890
10918
|
zip64DiskNumberStart,
|
|
10891
10919
|
zip64Offset,
|
|
10892
10920
|
msDosCompatible,
|
|
10893
|
-
|
|
10894
|
-
|
|
10921
|
+
internalFileAttributes,
|
|
10922
|
+
externalFileAttributes,
|
|
10895
10923
|
diskNumberStart,
|
|
10896
10924
|
uncompressedSize,
|
|
10897
10925
|
compressedSize
|
|
@@ -10910,9 +10938,9 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
10910
10938
|
setUint16(directoryView, offset + 30, extraFieldLength);
|
|
10911
10939
|
setUint16(directoryView, offset + 32, getLength(rawComment));
|
|
10912
10940
|
setUint16(directoryView, offset + 34, zip64 && zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
|
|
10913
|
-
setUint16(directoryView, offset + 36,
|
|
10914
|
-
if (
|
|
10915
|
-
setUint32(directoryView, offset + 38,
|
|
10941
|
+
setUint16(directoryView, offset + 36, internalFileAttributes);
|
|
10942
|
+
if (externalFileAttributes) {
|
|
10943
|
+
setUint32(directoryView, offset + 38, externalFileAttributes);
|
|
10916
10944
|
} else if (directory && msDosCompatible) {
|
|
10917
10945
|
setUint8(directoryView, offset + 38, FILE_ATTR_MSDOS_DIR_MASK);
|
|
10918
10946
|
}
|
|
@@ -10934,7 +10962,8 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
10934
10962
|
if (options.onprogress) {
|
|
10935
10963
|
try {
|
|
10936
10964
|
await options.onprogress(indexFileEntry + 1, files.size, new Entry(fileEntry));
|
|
10937
|
-
|
|
10965
|
+
// eslint-disable-next-line no-unused-vars
|
|
10966
|
+
} catch (_) {
|
|
10938
10967
|
// ignored
|
|
10939
10968
|
}
|
|
10940
10969
|
}
|
|
@@ -11457,7 +11486,8 @@ class ZipDirectoryEntry extends ZipEntry {
|
|
|
11457
11486
|
error.cause = {
|
|
11458
11487
|
entry
|
|
11459
11488
|
};
|
|
11460
|
-
|
|
11489
|
+
// eslint-disable-next-line no-unused-vars
|
|
11490
|
+
} catch (_) {
|
|
11461
11491
|
// ignored
|
|
11462
11492
|
}
|
|
11463
11493
|
throw error;
|
|
@@ -11714,7 +11744,8 @@ async function initReaders(entry, options) {
|
|
|
11714
11744
|
error.cause = {
|
|
11715
11745
|
entry: child
|
|
11716
11746
|
};
|
|
11717
|
-
|
|
11747
|
+
// eslint-disable-next-line no-unused-vars
|
|
11748
|
+
} catch (_) {
|
|
11718
11749
|
// ignored
|
|
11719
11750
|
}
|
|
11720
11751
|
throw error;
|
|
@@ -11760,7 +11791,7 @@ async function exportZip(zipWriter, entry, totalSize, options) {
|
|
|
11760
11791
|
let zipEntryOptions = {};
|
|
11761
11792
|
if (child.data instanceof Entry) {
|
|
11762
11793
|
const {
|
|
11763
|
-
|
|
11794
|
+
externalFileAttributes,
|
|
11764
11795
|
versionMadeBy,
|
|
11765
11796
|
comment,
|
|
11766
11797
|
lastModDate,
|
|
@@ -11774,7 +11805,7 @@ async function exportZip(zipWriter, entry, totalSize, options) {
|
|
|
11774
11805
|
extraFieldAES
|
|
11775
11806
|
} = child.data;
|
|
11776
11807
|
zipEntryOptions = {
|
|
11777
|
-
|
|
11808
|
+
externalFileAttributes,
|
|
11778
11809
|
versionMadeBy,
|
|
11779
11810
|
comment,
|
|
11780
11811
|
lastModDate,
|
|
@@ -11809,7 +11840,8 @@ async function exportZip(zipWriter, entry, totalSize, options) {
|
|
|
11809
11840
|
entryOffsets.set(name, indexProgress);
|
|
11810
11841
|
try {
|
|
11811
11842
|
await options.onprogress(Array.from(entryOffsets.values()).reduce((previousValue, currentValue) => previousValue + currentValue), totalSize);
|
|
11812
|
-
|
|
11843
|
+
// eslint-disable-next-line no-unused-vars
|
|
11844
|
+
} catch (_) {
|
|
11813
11845
|
// ignored
|
|
11814
11846
|
}
|
|
11815
11847
|
}
|
|
@@ -11954,7 +11986,8 @@ function addChild(parent, name, params, directory) {
|
|
|
11954
11986
|
let baseURL;
|
|
11955
11987
|
try {
|
|
11956
11988
|
baseURL = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href));
|
|
11957
|
-
|
|
11989
|
+
// eslint-disable-next-line no-unused-vars
|
|
11990
|
+
} catch (_) {
|
|
11958
11991
|
// ignored
|
|
11959
11992
|
}
|
|
11960
11993
|
configure({ baseURL });
|
package/index.d.ts
CHANGED
|
@@ -866,6 +866,10 @@ export interface EntryMetaData {
|
|
|
866
866
|
* `true` if the entry is a directory.
|
|
867
867
|
*/
|
|
868
868
|
directory: boolean;
|
|
869
|
+
/**
|
|
870
|
+
* `true` if the entry is an executable file
|
|
871
|
+
*/
|
|
872
|
+
executable: boolean;
|
|
869
873
|
/**
|
|
870
874
|
* `true` if the content of the entry is encrypted.
|
|
871
875
|
*/
|
|
@@ -943,15 +947,28 @@ export interface EntryMetaData {
|
|
|
943
947
|
*/
|
|
944
948
|
versionMadeBy: number;
|
|
945
949
|
/**
|
|
946
|
-
* `true` if `
|
|
950
|
+
* `true` if `internalFileAttributes` and `externalFileAttributes` are compatible with MS-DOS format.
|
|
947
951
|
*/
|
|
948
952
|
msDosCompatible: boolean;
|
|
953
|
+
/**
|
|
954
|
+
* The internal file attributes (raw).
|
|
955
|
+
*/
|
|
956
|
+
internalFileAttributes: number;
|
|
957
|
+
/**
|
|
958
|
+
* The external file attributes (raw).
|
|
959
|
+
*/
|
|
960
|
+
externalFileAttributes: number;
|
|
961
|
+
/**
|
|
962
|
+
* The number of the disk where the entry data starts.
|
|
963
|
+
*/
|
|
949
964
|
/**
|
|
950
965
|
* The internal file attribute (raw).
|
|
966
|
+
* @deprecated Use {@link EntryMetaData#internalFileAttributes} instead.
|
|
951
967
|
*/
|
|
952
968
|
internalFileAttribute: number;
|
|
953
969
|
/**
|
|
954
970
|
* The external file attribute (raw).
|
|
971
|
+
* @deprecated Use {@link EntryMetaData#externalFileAttributes} instead.
|
|
955
972
|
*/
|
|
956
973
|
externalFileAttribute: number;
|
|
957
974
|
/**
|
|
@@ -1338,7 +1355,7 @@ export interface ZipWriterConstructorOptions {
|
|
|
1338
1355
|
*/
|
|
1339
1356
|
dataDescriptorSignature?: boolean;
|
|
1340
1357
|
/**
|
|
1341
|
-
* `true` to write {@link EntryMetaData#
|
|
1358
|
+
* `true` to write {@link EntryMetaData#externalFileAttributes} in MS-DOS format for folder entries.
|
|
1342
1359
|
*
|
|
1343
1360
|
* @defaultValue true
|
|
1344
1361
|
*/
|
|
@@ -1348,13 +1365,13 @@ export interface ZipWriterConstructorOptions {
|
|
|
1348
1365
|
*
|
|
1349
1366
|
* @defaultValue 0
|
|
1350
1367
|
*/
|
|
1351
|
-
|
|
1368
|
+
externalFileAttributes?: number;
|
|
1352
1369
|
/**
|
|
1353
1370
|
* The internal file attribute.
|
|
1354
1371
|
*
|
|
1355
1372
|
* @defaultValue 0
|
|
1356
1373
|
*/
|
|
1357
|
-
|
|
1374
|
+
internalFileAttributes?: number;
|
|
1358
1375
|
/**
|
|
1359
1376
|
* `false` to never write disk numbers in zip64 data.
|
|
1360
1377
|
*
|