@zip.js/zip.js 2.7.55 → 2.7.57

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/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,9 @@ 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;
4281
+ const FILE_ATTR_UNIX_DEFAULT_MASK = 0o644;
4287
4282
 
4288
4283
  const VERSION_DEFLATE = 0x14;
4289
4284
  const VERSION_ZIP64 = 0x2D;
@@ -4384,7 +4379,8 @@ try {
4384
4379
  if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
4385
4380
  maxWorkers = navigator.hardwareConcurrency;
4386
4381
  }
4387
- } catch (_error) {
4382
+ // eslint-disable-next-line no-unused-vars
4383
+ } catch (_) {
4388
4384
  // ignored
4389
4385
  }
4390
4386
  const DEFAULT_CONFIGURATION = {
@@ -7390,7 +7386,8 @@ async function importKey(format, password, algorithm, extractable, keyUsages) {
7390
7386
  if (IMPORT_KEY_SUPPORTED) {
7391
7387
  try {
7392
7388
  return await subtle.importKey(format, password, algorithm, extractable, keyUsages);
7393
- } catch (_error) {
7389
+ // eslint-disable-next-line no-unused-vars
7390
+ } catch (_) {
7394
7391
  IMPORT_KEY_SUPPORTED = false;
7395
7392
  return misc.importKey(password);
7396
7393
  }
@@ -7403,7 +7400,8 @@ async function deriveBits(algorithm, baseKey, length) {
7403
7400
  if (DERIVE_BITS_SUPPORTED) {
7404
7401
  try {
7405
7402
  return await subtle.deriveBits(algorithm, baseKey, length);
7406
- } catch (_error) {
7403
+ // eslint-disable-next-line no-unused-vars
7404
+ } catch (_) {
7407
7405
  DERIVE_BITS_SUPPORTED = false;
7408
7406
  return misc.pbkdf2(baseKey, algorithm.salt, DERIVED_BITS_ALGORITHM.iterations, length);
7409
7407
  }
@@ -7721,11 +7719,13 @@ function pipeThroughCommpressionStream(readable, useCompressionStream, options,
7721
7719
  try {
7722
7720
  const CompressionStream = useCompressionStream && CodecStreamNative ? CodecStreamNative : CodecStream;
7723
7721
  readable = pipeThrough(readable, new CompressionStream(COMPRESSION_FORMAT, options));
7724
- } catch (_error) {
7722
+ // eslint-disable-next-line no-unused-vars
7723
+ } catch (_) {
7725
7724
  if (useCompressionStream) {
7726
7725
  try {
7727
7726
  readable = pipeThrough(readable, new CodecStream(COMPRESSION_FORMAT, options));
7728
- } catch (_error) {
7727
+ // eslint-disable-next-line no-unused-vars
7728
+ } catch (_) {
7729
7729
  return readable;
7730
7730
  }
7731
7731
  } else {
@@ -7968,7 +7968,8 @@ class ProgressWatcherStream extends TransformStream {
7968
7968
  async function callHandler(handler, ...parameters) {
7969
7969
  try {
7970
7970
  await handler(...parameters);
7971
- } catch (_error) {
7971
+ // eslint-disable-next-line no-unused-vars
7972
+ } catch (_) {
7972
7973
  // ignored
7973
7974
  }
7974
7975
  }
@@ -7985,7 +7986,8 @@ function createWebWorkerInterface(workerData, config) {
7985
7986
  let worker;
7986
7987
  try {
7987
7988
  worker = getWebWorker(workerData.scripts[0], baseURL, workerData);
7988
- } catch (_error) {
7989
+ // eslint-disable-next-line no-unused-vars
7990
+ } catch (_) {
7989
7991
  WEB_WORKERS_SUPPORTED = false;
7990
7992
  return createWorkerInterface(workerData, config);
7991
7993
  }
@@ -8088,13 +8090,15 @@ function getWebWorker(url, baseURL, workerData) {
8088
8090
  }
8089
8091
  try {
8090
8092
  scriptUrl = new URL(url, baseURL);
8091
- } catch (_error) {
8093
+ // eslint-disable-next-line no-unused-vars
8094
+ } catch (_) {
8092
8095
  scriptUrl = url;
8093
8096
  }
8094
8097
  if (classicWorkersSupported) {
8095
8098
  try {
8096
8099
  worker = new Worker(scriptUrl);
8097
- } catch (_error) {
8100
+ // eslint-disable-next-line no-unused-vars
8101
+ } catch (_) {
8098
8102
  classicWorkersSupported = false;
8099
8103
  worker = new Worker(scriptUrl, workerOptions);
8100
8104
  }
@@ -8132,7 +8136,8 @@ function sendMessage(message, { worker, writer, onTaskFinished, transferStreams
8132
8136
  try {
8133
8137
  worker.postMessage(message, transferables);
8134
8138
  return true;
8135
- } catch (_error) {
8139
+ // eslint-disable-next-line no-unused-vars
8140
+ } catch (_) {
8136
8141
  transferStreamsSupported = false;
8137
8142
  message.readable = message.writable = null;
8138
8143
  worker.postMessage(message);
@@ -8275,7 +8280,8 @@ function terminateWorker(workerData, workerOptions) {
8275
8280
  pool = pool.filter(data => data != workerData);
8276
8281
  try {
8277
8282
  await workerData.terminate();
8278
- } catch (_error) {
8283
+ // eslint-disable-next-line no-unused-vars
8284
+ } catch (_) {
8279
8285
  // ignored
8280
8286
  }
8281
8287
  }, terminateWorkerTimeout);
@@ -8680,7 +8686,7 @@ async function initHttpReader(httpReader, sendRequest, getRequestData) {
8680
8686
  combineSizeEocd
8681
8687
  } = httpReader;
8682
8688
  if (isHttpFamily(url) && (useRangeHeader || forceRangeRequests) && (typeof preventHeadRequest == "undefined" || preventHeadRequest)) {
8683
- const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, combineSizeEocd ? -END_OF_CENTRAL_DIR_LENGTH : undefined));
8689
+ const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, combineSizeEocd ? -22 : undefined));
8684
8690
  if (!forceRangeRequests && response.headers.get(HTTP_HEADER_ACCEPT_RANGES) != HTTP_RANGE_UNIT) {
8685
8691
  throw new Error(ERR_HTTP_RANGE);
8686
8692
  } else {
@@ -9203,22 +9209,23 @@ const PROPERTY_NAME_RAW_LAST_ACCESS_DATE = "rawLastAccessDate";
9203
9209
  const PROPERTY_NAME_CREATION_DATE = "creationDate";
9204
9210
  const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
9205
9211
  const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE = "internalFileAttribute";
9212
+ const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES = "internalFileAttributes";
9206
9213
  const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE = "externalFileAttribute";
9214
+ const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttributes";
9207
9215
  const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
9208
9216
  const PROPERTY_NAME_ZIP64 = "zip64";
9209
9217
  const PROPERTY_NAME_ENCRYPTED = "encrypted";
9210
9218
  const PROPERTY_NAME_VERSION = "version";
9211
9219
  const PROPERTY_NAME_VERSION_MADE_BY = "versionMadeBy";
9212
9220
  const PROPERTY_NAME_ZIPCRYPTO = "zipCrypto";
9221
+ const PROPERTY_NAME_DIRECTORY = "directory";
9222
+ const PROPERTY_NAME_EXECUTABLE = "executable";
9213
9223
 
9214
9224
  const PROPERTY_NAMES = [
9215
9225
  PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, PROPERTY_NAME_COMPPRESSED_SIZE, PROPERTY_NAME_UNCOMPPRESSED_SIZE,
9216
9226
  PROPERTY_NAME_LAST_MODIFICATION_DATE, PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT,
9217
9227
  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"];
9228
+ 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, PROPERTY_NAME_DIRECTORY, PROPERTY_NAME_EXECUTABLE, "bitFlag", "signature", "filenameUTF8", "commentUTF8", "compressionMethod", "extraField", "rawExtraField", "extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment", "extraFieldAES", "extraFieldNTFS", "extraFieldExtendedTimestamp"];
9222
9229
 
9223
9230
  class Entry {
9224
9231
 
@@ -9409,14 +9416,20 @@ class ZipReader {
9409
9416
  const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
9410
9417
  const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
9411
9418
  const versionMadeBy = getUint16(directoryView, offset + 4);
9412
- const msDosCompatible = (versionMadeBy & 0) == 0;
9419
+ const msDosCompatible = versionMadeBy >> 8 == 0;
9420
+ const unixCompatible = versionMadeBy >> 8 == 3;
9413
9421
  const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
9414
9422
  const commentLength = getUint16(directoryView, offset + 32);
9415
9423
  const endOffset = commentOffset + commentLength;
9416
9424
  const rawComment = directoryArray.subarray(commentOffset, endOffset);
9417
9425
  const filenameUTF8 = languageEncodingFlag;
9418
9426
  const commentUTF8 = languageEncodingFlag;
9419
- const directory = msDosCompatible && ((getUint8(directoryView, offset + 38) & FILE_ATTR_MSDOS_DIR_MASK) == FILE_ATTR_MSDOS_DIR_MASK);
9427
+ const externalFileAttributes = getUint32(directoryView, offset + 38);
9428
+ const directory =
9429
+ (msDosCompatible && ((getUint8(directoryView, offset + 38) & FILE_ATTR_MSDOS_DIR_MASK) == FILE_ATTR_MSDOS_DIR_MASK)) ||
9430
+ (unixCompatible && (((externalFileAttributes >> 16) & FILE_ATTR_UNIX_DIR_MASK) == FILE_ATTR_UNIX_DIR_MASK)) ||
9431
+ (rawFilename.length && rawFilename[rawFilename.length - 1] == DIRECTORY_SIGNATURE.charCodeAt(0));
9432
+ const executable = (unixCompatible && (((externalFileAttributes >> 16) & FILE_ATTR_UNIX_EXECUTABLE_MASK) == FILE_ATTR_UNIX_EXECUTABLE_MASK));
9420
9433
  const offsetFileEntry = getUint32(directoryView, offset + 42) + prependedDataLength;
9421
9434
  Object.assign(fileEntry, {
9422
9435
  versionMadeBy,
@@ -9427,13 +9440,16 @@ class ZipReader {
9427
9440
  directory,
9428
9441
  offset: offsetFileEntry,
9429
9442
  diskNumberStart: getUint16(directoryView, offset + 34),
9430
- internalFileAttribute: getUint16(directoryView, offset + 36),
9431
- externalFileAttribute: getUint32(directoryView, offset + 38),
9443
+ internalFileAttributes: getUint16(directoryView, offset + 36),
9444
+ externalFileAttributes,
9432
9445
  rawFilename,
9433
9446
  filenameUTF8,
9434
9447
  commentUTF8,
9435
- rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset)
9448
+ rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset),
9449
+ executable
9436
9450
  });
9451
+ fileEntry.internalFileAttribute = fileEntry.internalFileAttributes;
9452
+ fileEntry.externalFileAttribute = fileEntry.externalFileAttributes;
9437
9453
  const decode = getOptionValue$1(zipReader, options, "decodeText") || decodeText;
9438
9454
  const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
9439
9455
  const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
@@ -9461,7 +9477,8 @@ class ZipReader {
9461
9477
  if (onprogress) {
9462
9478
  try {
9463
9479
  await onprogress(indexFile + 1, filesLength, new Entry(fileEntry));
9464
- } catch (_error) {
9480
+ // eslint-disable-next-line no-unused-vars
9481
+ } catch (_) {
9465
9482
  // ignored
9466
9483
  }
9467
9484
  }
@@ -9673,7 +9690,8 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
9673
9690
  });
9674
9691
  offsetExtraField += 4 + size;
9675
9692
  }
9676
- } catch (_error) {
9693
+ // eslint-disable-next-line no-unused-vars
9694
+ } catch (_) {
9677
9695
  // ignored
9678
9696
  }
9679
9697
  const compressionMethod = getUint16(dataView, offset + 4);
@@ -9780,7 +9798,8 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
9780
9798
  }
9781
9799
  offsetExtraField += 4 + attributeSize;
9782
9800
  }
9783
- } catch (_error) {
9801
+ // eslint-disable-next-line no-unused-vars
9802
+ } catch (_) {
9784
9803
  // ignored
9785
9804
  }
9786
9805
  try {
@@ -9801,7 +9820,8 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
9801
9820
  Object.assign(extraFieldNTFS, extraFieldData);
9802
9821
  Object.assign(directory, extraFieldData);
9803
9822
  }
9804
- } catch (_error) {
9823
+ // eslint-disable-next-line no-unused-vars
9824
+ } catch (_) {
9805
9825
  // ignored
9806
9826
  }
9807
9827
  }
@@ -9870,7 +9890,8 @@ function getDate(timeRaw) {
9870
9890
  const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & 0x0000ffff;
9871
9891
  try {
9872
9892
  return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
9873
- } catch (_error) {
9893
+ // eslint-disable-next-line no-unused-vars
9894
+ } catch (_) {
9874
9895
  // ignored
9875
9896
  }
9876
9897
  }
@@ -10049,10 +10070,37 @@ class ZipWriterStream {
10049
10070
 
10050
10071
  async function addFile(zipWriter, name, reader, options) {
10051
10072
  name = name.trim();
10052
- if (options.directory && (!name.endsWith(DIRECTORY_SIGNATURE))) {
10053
- name += DIRECTORY_SIGNATURE;
10054
- } else {
10055
- options.directory = name.endsWith(DIRECTORY_SIGNATURE);
10073
+ const msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
10074
+ const versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? 20 : 768);
10075
+ const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
10076
+ if (versionMadeBy > MAX_16_BITS) {
10077
+ throw new Error(ERR_INVALID_VERSION);
10078
+ }
10079
+ let externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, 0);
10080
+ if (externalFileAttributes === 0) {
10081
+ externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, 0);
10082
+ }
10083
+ if (!options.directory && name.endsWith(DIRECTORY_SIGNATURE)) {
10084
+ options.directory = true;
10085
+ }
10086
+ const directory = getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY);
10087
+ if (directory) {
10088
+ if (!name.endsWith(DIRECTORY_SIGNATURE)) {
10089
+ name += DIRECTORY_SIGNATURE;
10090
+ }
10091
+ if (externalFileAttributes === 0) {
10092
+ if (msDosCompatible) {
10093
+ externalFileAttributes = FILE_ATTR_MSDOS_DIR_MASK;
10094
+ } else {
10095
+ externalFileAttributes = FILE_ATTR_UNIX_DIR_MASK << 16;
10096
+ }
10097
+ }
10098
+ } else if (!msDosCompatible && externalFileAttributes === 0) {
10099
+ if (executable) {
10100
+ externalFileAttributes = (FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_DEFAULT_MASK) << 16;
10101
+ } else {
10102
+ externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
10103
+ }
10056
10104
  }
10057
10105
  const encode = getOptionValue(zipWriter, options, "encodeText", encodeText);
10058
10106
  let rawFilename = encode(name);
@@ -10074,16 +10122,13 @@ async function addFile(zipWriter, name, reader, options) {
10074
10122
  if (version > MAX_16_BITS) {
10075
10123
  throw new Error(ERR_INVALID_VERSION);
10076
10124
  }
10077
- const versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, 20);
10078
- if (versionMadeBy > MAX_16_BITS) {
10079
- throw new Error(ERR_INVALID_VERSION);
10080
- }
10081
10125
  const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
10082
10126
  const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
10083
10127
  const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
10084
- const msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE, true);
10085
- const internalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, 0);
10086
- const externalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, 0);
10128
+ let internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, 0);
10129
+ if (internalFileAttributes === 0) {
10130
+ internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, 0);
10131
+ }
10087
10132
  const passThrough = getOptionValue(zipWriter, options, "passThrough");
10088
10133
  let password, rawPassword;
10089
10134
  if (!passThrough) {
@@ -10199,8 +10244,10 @@ async function addFile(zipWriter, name, reader, options) {
10199
10244
  dataDescriptorSignature,
10200
10245
  signal,
10201
10246
  msDosCompatible,
10202
- internalFileAttribute,
10203
- externalFileAttribute,
10247
+ internalFileAttribute: internalFileAttributes,
10248
+ internalFileAttributes,
10249
+ externalFileAttribute: externalFileAttributes,
10250
+ externalFileAttributes,
10204
10251
  useCompressionStream,
10205
10252
  passThrough,
10206
10253
  encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
@@ -10321,7 +10368,8 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
10321
10368
  if (error) {
10322
10369
  try {
10323
10370
  error.corruptedEntry = true;
10324
- } catch (_error) {
10371
+ // eslint-disable-next-line no-unused-vars
10372
+ } catch (_) {
10325
10373
  // ignored
10326
10374
  }
10327
10375
  }
@@ -10403,6 +10451,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
10403
10451
  zipCrypto,
10404
10452
  dataDescriptor,
10405
10453
  directory,
10454
+ executable,
10406
10455
  versionMadeBy,
10407
10456
  rawComment,
10408
10457
  rawExtraField,
@@ -10414,8 +10463,8 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
10414
10463
  encryptionStrength,
10415
10464
  extendedTimestamp,
10416
10465
  msDosCompatible,
10417
- internalFileAttribute,
10418
- externalFileAttribute,
10466
+ internalFileAttributes,
10467
+ externalFileAttributes,
10419
10468
  useCompressionStream,
10420
10469
  passThrough
10421
10470
  } = options;
@@ -10424,6 +10473,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
10424
10473
  versionMadeBy,
10425
10474
  zip64,
10426
10475
  directory: Boolean(directory),
10476
+ executable: Boolean(executable),
10427
10477
  filenameUTF8: true,
10428
10478
  rawFilename,
10429
10479
  commentUTF8: true,
@@ -10434,8 +10484,8 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
10434
10484
  rawExtraField,
10435
10485
  extendedTimestamp,
10436
10486
  msDosCompatible,
10437
- internalFileAttribute,
10438
- externalFileAttribute,
10487
+ internalFileAttributes,
10488
+ externalFileAttributes,
10439
10489
  diskNumberStart
10440
10490
  };
10441
10491
  let {
@@ -10595,7 +10645,8 @@ function getHeaderInfo(options) {
10595
10645
  setBigUint64(extraFieldNTFSView, 12, lastModTimeNTFS);
10596
10646
  setBigUint64(extraFieldNTFSView, 20, getTimeNTFS(lastAccessDate) || lastModTimeNTFS);
10597
10647
  setBigUint64(extraFieldNTFSView, 28, getTimeNTFS(creationDate) || lastModTimeNTFS);
10598
- } catch (_error) {
10648
+ // eslint-disable-next-line no-unused-vars
10649
+ } catch (_) {
10599
10650
  rawExtraFieldNTFS = new Uint8Array();
10600
10651
  }
10601
10652
  } else {
@@ -10883,15 +10934,13 @@ async function closeFile(zipWriter, comment, options) {
10883
10934
  rawComment,
10884
10935
  versionMadeBy,
10885
10936
  headerArray,
10886
- directory,
10887
10937
  zip64,
10888
10938
  zip64UncompressedSize,
10889
10939
  zip64CompressedSize,
10890
10940
  zip64DiskNumberStart,
10891
10941
  zip64Offset,
10892
- msDosCompatible,
10893
- internalFileAttribute,
10894
- externalFileAttribute,
10942
+ internalFileAttributes,
10943
+ externalFileAttributes,
10895
10944
  diskNumberStart,
10896
10945
  uncompressedSize,
10897
10946
  compressedSize
@@ -10910,11 +10959,9 @@ async function closeFile(zipWriter, comment, options) {
10910
10959
  setUint16(directoryView, offset + 30, extraFieldLength);
10911
10960
  setUint16(directoryView, offset + 32, getLength(rawComment));
10912
10961
  setUint16(directoryView, offset + 34, zip64 && zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
10913
- setUint16(directoryView, offset + 36, internalFileAttribute);
10914
- if (externalFileAttribute) {
10915
- setUint32(directoryView, offset + 38, externalFileAttribute);
10916
- } else if (directory && msDosCompatible) {
10917
- setUint8(directoryView, offset + 38, FILE_ATTR_MSDOS_DIR_MASK);
10962
+ setUint16(directoryView, offset + 36, internalFileAttributes);
10963
+ if (externalFileAttributes) {
10964
+ setUint32(directoryView, offset + 38, externalFileAttributes);
10918
10965
  }
10919
10966
  setUint32(directoryView, offset + 42, zip64 && zip64Offset ? MAX_32_BITS : fileEntryOffset);
10920
10967
  arraySet(directoryArray, rawFilename, offset + 46);
@@ -10934,7 +10981,8 @@ async function closeFile(zipWriter, comment, options) {
10934
10981
  if (options.onprogress) {
10935
10982
  try {
10936
10983
  await options.onprogress(indexFileEntry + 1, files.size, new Entry(fileEntry));
10937
- } catch (_error) {
10984
+ // eslint-disable-next-line no-unused-vars
10985
+ } catch (_) {
10938
10986
  // ignored
10939
10987
  }
10940
10988
  }
@@ -11457,7 +11505,8 @@ class ZipDirectoryEntry extends ZipEntry {
11457
11505
  error.cause = {
11458
11506
  entry
11459
11507
  };
11460
- } catch (_error) {
11508
+ // eslint-disable-next-line no-unused-vars
11509
+ } catch (_) {
11461
11510
  // ignored
11462
11511
  }
11463
11512
  throw error;
@@ -11714,7 +11763,8 @@ async function initReaders(entry, options) {
11714
11763
  error.cause = {
11715
11764
  entry: child
11716
11765
  };
11717
- } catch (_error) {
11766
+ // eslint-disable-next-line no-unused-vars
11767
+ } catch (_) {
11718
11768
  // ignored
11719
11769
  }
11720
11770
  throw error;
@@ -11760,7 +11810,7 @@ async function exportZip(zipWriter, entry, totalSize, options) {
11760
11810
  let zipEntryOptions = {};
11761
11811
  if (child.data instanceof Entry) {
11762
11812
  const {
11763
- externalFileAttribute,
11813
+ externalFileAttributes,
11764
11814
  versionMadeBy,
11765
11815
  comment,
11766
11816
  lastModDate,
@@ -11774,7 +11824,7 @@ async function exportZip(zipWriter, entry, totalSize, options) {
11774
11824
  extraFieldAES
11775
11825
  } = child.data;
11776
11826
  zipEntryOptions = {
11777
- externalFileAttribute,
11827
+ externalFileAttributes,
11778
11828
  versionMadeBy,
11779
11829
  comment,
11780
11830
  lastModDate,
@@ -11809,7 +11859,8 @@ async function exportZip(zipWriter, entry, totalSize, options) {
11809
11859
  entryOffsets.set(name, indexProgress);
11810
11860
  try {
11811
11861
  await options.onprogress(Array.from(entryOffsets.values()).reduce((previousValue, currentValue) => previousValue + currentValue), totalSize);
11812
- } catch (_error) {
11862
+ // eslint-disable-next-line no-unused-vars
11863
+ } catch (_) {
11813
11864
  // ignored
11814
11865
  }
11815
11866
  }
@@ -11954,7 +12005,8 @@ function addChild(parent, name, params, directory) {
11954
12005
  let baseURL;
11955
12006
  try {
11956
12007
  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
- } catch (_error) {
12008
+ // eslint-disable-next-line no-unused-vars
12009
+ } catch (_) {
11958
12010
  // ignored
11959
12011
  }
11960
12012
  configure({ baseURL });
package/index.d.ts CHANGED
@@ -1187,6 +1187,12 @@ export interface ZipWriterAddDataOptions
1187
1187
  * @defaultValue false
1188
1188
  */
1189
1189
  directory?: boolean;
1190
+ /**
1191
+ * `true` if the entry is an executable file.
1192
+ *
1193
+ * @defaultValue false
1194
+ */
1195
+ executable?: boolean;
1190
1196
  /**
1191
1197
  * The comment of the entry.
1192
1198
  */
@@ -1357,7 +1363,7 @@ export interface ZipWriterConstructorOptions {
1357
1363
  /**
1358
1364
  * `true` to write {@link EntryMetaData#externalFileAttributes} in MS-DOS format for folder entries.
1359
1365
  *
1360
- * @defaultValue true
1366
+ * @defaultValue false
1361
1367
  */
1362
1368
  msDosCompatible?: boolean;
1363
1369
  /**