@zip.js/zip.js 2.7.53 → 2.7.55

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.
Files changed (40) hide show
  1. package/deno.json +1 -1
  2. package/dist/zip-fs-full.js +27 -17
  3. package/dist/zip-fs-full.min.js +1 -1
  4. package/dist/zip-fs.js +27 -17
  5. package/dist/zip-fs.min.js +1 -1
  6. package/dist/zip-full.js +24 -14
  7. package/dist/zip-full.min.js +1 -1
  8. package/dist/zip-no-worker-deflate.min.js +1 -1
  9. package/dist/zip-no-worker-inflate.min.js +1 -1
  10. package/dist/zip-no-worker.min.js +1 -1
  11. package/dist/zip.js +24 -14
  12. package/dist/zip.min.js +1 -1
  13. package/eslint.config.mjs +44 -0
  14. package/index.cjs +27 -17
  15. package/index.d.ts +21 -5
  16. package/index.min.js +1 -1
  17. package/lib/core/codec-pool.js +3 -1
  18. package/lib/core/codec-worker.js +11 -6
  19. package/lib/core/configuration.js +2 -1
  20. package/lib/core/constants.js +4 -0
  21. package/lib/core/streams/aes-crypto-stream.js +4 -2
  22. package/lib/core/streams/codecs/deflate.js +0 -4
  23. package/lib/core/streams/codecs/inflate.js +0 -4
  24. package/lib/core/streams/crc32-stream.js +1 -0
  25. package/lib/core/streams/zip-entry-stream.js +4 -2
  26. package/lib/core/util/encode-text.js +1 -0
  27. package/lib/core/util/mime-type.js +0 -2
  28. package/lib/core/util/stream-codec-shim.js +7 -4
  29. package/lib/core/z-worker-core.js +4 -2
  30. package/lib/core/zip-entry.js +5 -4
  31. package/lib/core/zip-fs-core.js +11 -8
  32. package/lib/core/zip-reader.js +33 -17
  33. package/lib/core/zip-writer.js +31 -18
  34. package/lib/z-worker-inline.js +1 -1
  35. package/lib/zip-data-uri.js +2 -1
  36. package/lib/zip-fs.js +2 -1
  37. package/lib/zip-full-fflate.js +2 -1
  38. package/lib/zip-full.js +2 -1
  39. package/lib/zip.js +2 -1
  40. package/package.json +87 -84
@@ -64,6 +64,7 @@ async function runWorker(stream, workerOptions) {
64
64
  options.useCompressionStream = useCompressionStream || (useCompressionStream === UNDEFINED_VALUE && config.useCompressionStream);
65
65
  return (await getWorker()).run();
66
66
 
67
+ // deno-lint-ignore require-await
67
68
  async function getWorker() {
68
69
  const workerData = pool.find(workerData => !workerData.busy);
69
70
  if (workerData) {
@@ -103,7 +104,8 @@ function terminateWorker(workerData, workerOptions) {
103
104
  pool = pool.filter(data => data != workerData);
104
105
  try {
105
106
  await workerData.terminate();
106
- } catch (_error) {
107
+ // eslint-disable-next-line no-unused-vars
108
+ } catch (_) {
107
109
  // ignored
108
110
  }
109
111
  }, terminateWorkerTimeout);
@@ -125,7 +125,8 @@ class ProgressWatcherStream extends TransformStream {
125
125
  async function callHandler(handler, ...parameters) {
126
126
  try {
127
127
  await handler(...parameters);
128
- } catch (_error) {
128
+ // eslint-disable-next-line no-unused-vars
129
+ } catch (_) {
129
130
  // ignored
130
131
  }
131
132
  }
@@ -142,7 +143,8 @@ function createWebWorkerInterface(workerData, config) {
142
143
  let worker;
143
144
  try {
144
145
  worker = getWebWorker(workerData.scripts[0], baseURL, workerData);
145
- } catch (error) {
146
+ // eslint-disable-next-line no-unused-vars
147
+ } catch (_) {
146
148
  WEB_WORKERS_SUPPORTED = false;
147
149
  return createWorkerInterface(workerData, config);
148
150
  }
@@ -245,13 +247,15 @@ function getWebWorker(url, baseURL, workerData) {
245
247
  }
246
248
  try {
247
249
  scriptUrl = new URL(url, baseURL);
248
- } catch (_error) {
250
+ // eslint-disable-next-line no-unused-vars
251
+ } catch (_) {
249
252
  scriptUrl = url;
250
253
  }
251
254
  if (classicWorkersSupported) {
252
255
  try {
253
256
  worker = new Worker(scriptUrl);
254
- } catch (_error) {
257
+ // eslint-disable-next-line no-unused-vars
258
+ } catch (_) {
255
259
  classicWorkersSupported = false;
256
260
  worker = new Worker(scriptUrl, workerOptions);
257
261
  }
@@ -264,7 +268,7 @@ function getWebWorker(url, baseURL, workerData) {
264
268
 
265
269
  function sendMessage(message, { worker, writer, onTaskFinished, transferStreams }) {
266
270
  try {
267
- let { value, readable, writable } = message;
271
+ const { value, readable, writable } = message;
268
272
  const transferables = [];
269
273
  if (value) {
270
274
  if (value.byteLength < value.buffer.byteLength) {
@@ -289,7 +293,8 @@ function sendMessage(message, { worker, writer, onTaskFinished, transferStreams
289
293
  try {
290
294
  worker.postMessage(message, transferables);
291
295
  return true;
292
- } catch (_error) {
296
+ // eslint-disable-next-line no-unused-vars
297
+ } catch (_) {
293
298
  transferStreamsSupported = false;
294
299
  message.readable = message.writable = null;
295
300
  worker.postMessage(message);
@@ -40,7 +40,8 @@ try {
40
40
  if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
41
41
  maxWorkers = navigator.hardwareConcurrency;
42
42
  }
43
- } catch (_error) {
43
+ // eslint-disable-next-line no-unused-vars
44
+ } catch (_) {
44
45
  // ignored
45
46
  }
46
47
  const DEFAULT_CONFIGURATION = {
@@ -58,6 +58,8 @@ const BITFLAG_LEVEL = 0x06;
58
58
  const BITFLAG_DATA_DESCRIPTOR = 0x0008;
59
59
  const BITFLAG_LANG_ENCODING_FLAG = 0x0800;
60
60
  const FILE_ATTR_MSDOS_DIR_MASK = 0x10;
61
+ const FILE_ATTR_UNIX_DIR_MASK = 0x4000;
62
+ const FILE_ATTR_UNIX_EXECUTABLE_MASK = 0o111;
61
63
 
62
64
  const VERSION_DEFLATE = 0x14;
63
65
  const VERSION_ZIP64 = 0x2D;
@@ -102,6 +104,8 @@ export {
102
104
  BITFLAG_DATA_DESCRIPTOR,
103
105
  BITFLAG_LANG_ENCODING_FLAG,
104
106
  FILE_ATTR_MSDOS_DIR_MASK,
107
+ FILE_ATTR_UNIX_DIR_MASK,
108
+ FILE_ATTR_UNIX_EXECUTABLE_MASK,
105
109
  VERSION_DEFLATE,
106
110
  VERSION_ZIP64,
107
111
  VERSION_AES,
@@ -265,7 +265,8 @@ async function importKey(format, password, algorithm, extractable, keyUsages) {
265
265
  if (IMPORT_KEY_SUPPORTED) {
266
266
  try {
267
267
  return await subtle.importKey(format, password, algorithm, extractable, keyUsages);
268
- } catch (_error) {
268
+ // eslint-disable-next-line no-unused-vars
269
+ } catch (_) {
269
270
  IMPORT_KEY_SUPPORTED = false;
270
271
  return misc.importKey(password);
271
272
  }
@@ -278,7 +279,8 @@ async function deriveBits(algorithm, baseKey, length) {
278
279
  if (DERIVE_BITS_SUPPORTED) {
279
280
  try {
280
281
  return await subtle.deriveBits(algorithm, baseKey, length);
281
- } catch (_error) {
282
+ // eslint-disable-next-line no-unused-vars
283
+ } catch (_) {
282
284
  DERIVE_BITS_SUPPORTED = false;
283
285
  return misc.pbkdf2(baseKey, algorithm.salt, DERIVED_BITS_ALGORITHM.iterations, length);
284
286
  }
@@ -1237,7 +1237,6 @@ function Deflate() {
1237
1237
  }
1238
1238
 
1239
1239
  // Copy as much as possible from input to output:
1240
- // eslint-disable-next-line no-constant-condition
1241
1240
  while (true) {
1242
1241
  // Fill the win as much as possible:
1243
1242
  if (lookahead <= 1) {
@@ -1332,7 +1331,6 @@ function Deflate() {
1332
1331
 
1333
1332
  // We check for insufficient lookahead only every 8th comparison;
1334
1333
  // the 256th check will be made at strstart+258.
1335
- // eslint-disable-next-line no-empty
1336
1334
  do {
1337
1335
  // empty block
1338
1336
  } while (win[++scan] == win[++match] && win[++scan] == win[++match] && win[++scan] == win[++match]
@@ -1368,7 +1366,6 @@ function Deflate() {
1368
1366
  let hash_head = 0; // head of the hash chain
1369
1367
  let bflush; // set if current block must be flushed
1370
1368
 
1371
- // eslint-disable-next-line no-constant-condition
1372
1369
  while (true) {
1373
1370
  // Make sure that we always have enough lookahead, except
1374
1371
  // at the end of the input file. We need MAX_MATCH bytes
@@ -1475,7 +1472,6 @@ function Deflate() {
1475
1472
  let max_insert;
1476
1473
 
1477
1474
  // Process the input block.
1478
- // eslint-disable-next-line no-constant-condition
1479
1475
  while (true) {
1480
1476
  // Make sure that we always have enough lookahead, except
1481
1477
  // at the end of the input file. We need MAX_MATCH bytes
@@ -766,7 +766,6 @@ function InfCodes() {
766
766
  m = q < s.read ? s.read - q - 1 : s.end - q;
767
767
 
768
768
  // process input and output based on current state
769
- // eslint-disable-next-line no-constant-condition
770
769
  while (true) {
771
770
  switch (mode) {
772
771
  // waiting for "i:"=input, "o:"=output, "x:"=nothing
@@ -1257,7 +1256,6 @@ function InfBlocks(z, w) {
1257
1256
 
1258
1257
  // process input based on current state
1259
1258
  // DEBUG dtree
1260
- // eslint-disable-next-line no-constant-condition
1261
1259
  while (true) {
1262
1260
  let bl, bd, tl, td, bl_, bd_, tl_, td_;
1263
1261
  switch (mode) {
@@ -1534,7 +1532,6 @@ function InfBlocks(z, w) {
1534
1532
  mode = DTREE;
1535
1533
  /* falls through */
1536
1534
  case DTREE:
1537
- // eslint-disable-next-line no-constant-condition
1538
1535
  while (true) {
1539
1536
  t = table;
1540
1537
  if (index >= 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) {
@@ -1842,7 +1839,6 @@ function Inflate() {
1842
1839
  const istate = z.istate;
1843
1840
  f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
1844
1841
  r = Z_BUF_ERROR;
1845
- // eslint-disable-next-line no-constant-condition
1846
1842
  while (true) {
1847
1843
  switch (istate.mode) {
1848
1844
  case METHOD:
@@ -33,6 +33,7 @@ import { Crc32 } from "./codecs/crc32.js";
33
33
  class Crc32Stream extends TransformStream {
34
34
 
35
35
  constructor() {
36
+ // deno-lint-ignore prefer-const
36
37
  let stream;
37
38
  const crc32 = new Crc32();
38
39
  super({
@@ -146,11 +146,13 @@ function pipeThroughCommpressionStream(readable, useCompressionStream, options,
146
146
  try {
147
147
  const CompressionStream = useCompressionStream && CodecStreamNative ? CodecStreamNative : CodecStream;
148
148
  readable = pipeThrough(readable, new CompressionStream(COMPRESSION_FORMAT, options));
149
- } catch (error) {
149
+ // eslint-disable-next-line no-unused-vars
150
+ } catch (_) {
150
151
  if (useCompressionStream) {
151
152
  try {
152
153
  readable = pipeThrough(readable, new CodecStream(COMPRESSION_FORMAT, options));
153
- } catch (error) {
154
+ // eslint-disable-next-line no-unused-vars
155
+ } catch (_) {
154
156
  return readable;
155
157
  }
156
158
  } else {
@@ -35,6 +35,7 @@ export {
35
35
  };
36
36
 
37
37
  function encodeText(value) {
38
+ // deno-lint-ignore valid-typeof
38
39
  if (typeof TextEncoder == UNDEFINED_TYPE) {
39
40
  value = unescape(encodeURIComponent(value));
40
41
  const result = new Uint8Array(value.length);
@@ -26,8 +26,6 @@
26
26
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
27
  */
28
28
 
29
- // deno-lint-ignore-file no-prototype-builtins
30
-
31
29
  import { getMimeType as getDefaultMimeType } from "./default-mime-type.js";
32
30
 
33
31
  const table = {
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-prototype-builtins */
1
2
 
2
3
  /*
3
4
  Copyright (c) 2022 Gildas Lormeau. All rights reserved.
@@ -27,8 +28,6 @@
27
28
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29
  */
29
30
 
30
- // deno-lint-ignore-file no-this-alias
31
-
32
31
  import { FUNCTION_TYPE, UNDEFINED_VALUE } from "../constants.js";
33
32
 
34
33
  export {
@@ -43,14 +42,18 @@ function initShimAsyncCodec(library, options = {}, registerDataHandler) {
43
42
  }
44
43
 
45
44
  function objectHasOwn(object, propertyName) {
46
- // eslint-disable-next-line no-prototype-builtins
47
- return typeof Object.hasOwn === FUNCTION_TYPE ? Object.hasOwn(object, propertyName) : object.hasOwnProperty(propertyName);
45
+ // deno-lint-ignore valid-typeof
46
+ return typeof Object.hasOwn === FUNCTION_TYPE ?
47
+ Object.hasOwn(object, propertyName) :
48
+ // deno-lint-ignore no-prototype-builtins
49
+ object.hasOwnProperty(propertyName);
48
50
  }
49
51
 
50
52
  function createCodecClass(constructor, constructorOptions, registerDataHandler) {
51
53
  return class {
52
54
 
53
55
  constructor(options) {
56
+ // deno-lint-ignore no-this-alias
54
57
  const codecAdapter = this;
55
58
  const onData = data => {
56
59
  if (codecAdapter.pendingData) {
@@ -80,7 +80,8 @@ async function init(message) {
80
80
  } else {
81
81
  await imporModuleScripts(scripts);
82
82
  }
83
- } catch (error) {
83
+ // eslint-disable-next-line no-unused-vars
84
+ } catch (_) {
84
85
  importScriptSupported = false;
85
86
  await imporModuleScripts(scripts);
86
87
  }
@@ -159,7 +160,8 @@ function sendMessage(message) {
159
160
  value = new Uint8Array(value);
160
161
  message.value = value.buffer;
161
162
  postMessage(message, [message.value]);
162
- } catch (_error) {
163
+ // eslint-disable-next-line no-unused-vars
164
+ } catch (_) {
163
165
  postMessage(message);
164
166
  }
165
167
  } else {
@@ -41,7 +41,9 @@ const PROPERTY_NAME_RAW_LAST_ACCESS_DATE = "rawLastAccessDate";
41
41
  const PROPERTY_NAME_CREATION_DATE = "creationDate";
42
42
  const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
43
43
  const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE = "internalFileAttribute";
44
+ const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES = "internalFileAttributes";
44
45
  const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE = "externalFileAttribute";
46
+ const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttributes";
45
47
  const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
46
48
  const PROPERTY_NAME_ZIP64 = "zip64";
47
49
  const PROPERTY_NAME_ENCRYPTED = "encrypted";
@@ -53,10 +55,7 @@ const PROPERTY_NAMES = [
53
55
  PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, PROPERTY_NAME_COMPPRESSED_SIZE, PROPERTY_NAME_UNCOMPPRESSED_SIZE,
54
56
  PROPERTY_NAME_LAST_MODIFICATION_DATE, PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT,
55
57
  PROPERTY_NAME_LAST_ACCESS_DATE, PROPERTY_NAME_CREATION_DATE, PROPERTY_NAME_OFFSET, PROPERTY_NAME_DISK_NUMBER_START,
56
- PROPERTY_NAME_DISK_NUMBER_START, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE,
57
- PROPERTY_NAME_MS_DOS_COMPATIBLE, PROPERTY_NAME_ZIP64, PROPERTY_NAME_ENCRYPTED, PROPERTY_NAME_VERSION, PROPERTY_NAME_VERSION_MADE_BY,
58
- PROPERTY_NAME_ZIPCRYPTO, "directory", "bitFlag", "signature", "filenameUTF8", "commentUTF8", "compressionMethod", "extraField", "rawExtraField",
59
- "extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment", "extraFieldAES", "extraFieldNTFS", "extraFieldExtendedTimestamp"];
58
+ 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"];
60
59
 
61
60
  class Entry {
62
61
 
@@ -82,7 +81,9 @@ export {
82
81
  PROPERTY_NAME_CREATION_DATE,
83
82
  PROPERTY_NAME_RAW_CREATION_DATE,
84
83
  PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE,
84
+ PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES,
85
85
  PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE,
86
+ PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES,
86
87
  PROPERTY_NAME_MS_DOS_COMPATIBLE,
87
88
  PROPERTY_NAME_ZIP64,
88
89
  PROPERTY_NAME_ENCRYPTED,
@@ -425,7 +425,8 @@ class ZipDirectoryEntry extends ZipEntry {
425
425
  error.cause = {
426
426
  entry
427
427
  };
428
- } catch (_error) {
428
+ // eslint-disable-next-line no-unused-vars
429
+ } catch (_) {
429
430
  // ignored
430
431
  }
431
432
  throw error;
@@ -623,7 +624,7 @@ class FS {
623
624
  return this.root.isPasswordProtected();
624
625
  }
625
626
 
626
- async checkPassword(password, options) {
627
+ checkPassword(password, options) {
627
628
  return this.root.checkPassword(password, options);
628
629
  }
629
630
  }
@@ -683,7 +684,8 @@ async function initReaders(entry, options) {
683
684
  error.cause = {
684
685
  entry: child
685
686
  };
686
- } catch (_error) {
687
+ // eslint-disable-next-line no-unused-vars
688
+ } catch (_) {
687
689
  // ignored
688
690
  }
689
691
  throw error;
@@ -725,11 +727,11 @@ async function exportZip(zipWriter, entry, totalSize, options) {
725
727
 
726
728
  async function processChild(child) {
727
729
  const name = options.relativePath ? child.getRelativeName(selectedEntry) : child.getFullname();
728
- let childOptions = child.options || {};
730
+ const childOptions = child.options || {};
729
731
  let zipEntryOptions = {};
730
732
  if (child.data instanceof Entry) {
731
733
  const {
732
- externalFileAttribute,
734
+ externalFileAttributes,
733
735
  versionMadeBy,
734
736
  comment,
735
737
  lastModDate,
@@ -743,7 +745,7 @@ async function exportZip(zipWriter, entry, totalSize, options) {
743
745
  extraFieldAES
744
746
  } = child.data;
745
747
  zipEntryOptions = {
746
- externalFileAttribute,
748
+ externalFileAttributes,
747
749
  versionMadeBy,
748
750
  comment,
749
751
  lastModDate,
@@ -778,7 +780,8 @@ async function exportZip(zipWriter, entry, totalSize, options) {
778
780
  entryOffsets.set(name, indexProgress);
779
781
  try {
780
782
  await options.onprogress(Array.from(entryOffsets.values()).reduce((previousValue, currentValue) => previousValue + currentValue), totalSize);
781
- } catch (_error) {
783
+ // eslint-disable-next-line no-unused-vars
784
+ } catch (_) {
782
785
  // ignored
783
786
  }
784
787
  }
@@ -789,7 +792,7 @@ async function exportZip(zipWriter, entry, totalSize, options) {
789
792
  }
790
793
  }
791
794
 
792
- async function addFileSystemHandle(zipEntry, handle, options) {
795
+ function addFileSystemHandle(zipEntry, handle, options) {
793
796
  return addFile(zipEntry, handle, []);
794
797
 
795
798
  async function addFile(parentEntry, handle, addedEntries) {
@@ -26,7 +26,7 @@
26
26
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
27
  */
28
28
 
29
- /* global BigInt, Response, WritableStream, ReadableStream, TransformStream */
29
+ /* global Response, WritableStream, ReadableStream, TransformStream */
30
30
  // deno-lint-ignore-file no-this-alias
31
31
 
32
32
  import {
@@ -57,6 +57,8 @@ import {
57
57
  BITFLAG_DATA_DESCRIPTOR,
58
58
  BITFLAG_LANG_ENCODING_FLAG,
59
59
  FILE_ATTR_MSDOS_DIR_MASK,
60
+ FILE_ATTR_UNIX_DIR_MASK,
61
+ FILE_ATTR_UNIX_EXECUTABLE_MASK,
60
62
  DIRECTORY_SIGNATURE,
61
63
  UNDEFINED_VALUE
62
64
  } from "./constants.js";
@@ -250,14 +252,20 @@ class ZipReader {
250
252
  const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
251
253
  const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
252
254
  const versionMadeBy = getUint16(directoryView, offset + 4);
253
- const msDosCompatible = (versionMadeBy & 0) == 0;
255
+ const msDosCompatible = versionMadeBy >> 8 == 0;
256
+ const unixCompatible = versionMadeBy >> 8 == 3;
254
257
  const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
255
258
  const commentLength = getUint16(directoryView, offset + 32);
256
259
  const endOffset = commentOffset + commentLength;
257
260
  const rawComment = directoryArray.subarray(commentOffset, endOffset);
258
261
  const filenameUTF8 = languageEncodingFlag;
259
262
  const commentUTF8 = languageEncodingFlag;
260
- const directory = msDosCompatible && ((getUint8(directoryView, offset + 38) & FILE_ATTR_MSDOS_DIR_MASK) == FILE_ATTR_MSDOS_DIR_MASK);
263
+ const externalFileAttributes = getUint32(directoryView, offset + 38);
264
+ const directory =
265
+ (msDosCompatible && ((getUint8(directoryView, offset + 38) & FILE_ATTR_MSDOS_DIR_MASK) == FILE_ATTR_MSDOS_DIR_MASK)) ||
266
+ (unixCompatible && (((externalFileAttributes >> 16) & FILE_ATTR_UNIX_DIR_MASK) == FILE_ATTR_UNIX_DIR_MASK)) ||
267
+ (rawFilename.length && rawFilename[rawFilename.length - 1] == DIRECTORY_SIGNATURE.charCodeAt(0));
268
+ const executable = (unixCompatible && (((externalFileAttributes >> 16) & FILE_ATTR_UNIX_EXECUTABLE_MASK) == FILE_ATTR_UNIX_EXECUTABLE_MASK));
261
269
  const offsetFileEntry = getUint32(directoryView, offset + 42) + prependedDataLength;
262
270
  Object.assign(fileEntry, {
263
271
  versionMadeBy,
@@ -268,13 +276,16 @@ class ZipReader {
268
276
  directory,
269
277
  offset: offsetFileEntry,
270
278
  diskNumberStart: getUint16(directoryView, offset + 34),
271
- internalFileAttribute: getUint16(directoryView, offset + 36),
272
- externalFileAttribute: getUint32(directoryView, offset + 38),
279
+ internalFileAttributes: getUint16(directoryView, offset + 36),
280
+ externalFileAttributes,
273
281
  rawFilename,
274
282
  filenameUTF8,
275
283
  commentUTF8,
276
- rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset)
284
+ rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset),
285
+ executable
277
286
  });
287
+ fileEntry.internalFileAttribute = fileEntry.internalFileAttributes;
288
+ fileEntry.externalFileAttribute = fileEntry.externalFileAttributes;
278
289
  const decode = getOptionValue(zipReader, options, "decodeText") || decodeText;
279
290
  const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
280
291
  const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
@@ -293,7 +304,7 @@ class ZipReader {
293
304
  directory: directory || filename.endsWith(DIRECTORY_SIGNATURE)
294
305
  });
295
306
  startOffset = Math.max(offsetFileEntry, startOffset);
296
- await readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6);
307
+ readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6);
297
308
  fileEntry.zipCrypto = fileEntry.encrypted && !fileEntry.extraFieldAES;
298
309
  const entry = new Entry(fileEntry);
299
310
  entry.getData = (writer, options) => fileEntry.getData(writer, entry, options);
@@ -302,7 +313,8 @@ class ZipReader {
302
313
  if (onprogress) {
303
314
  try {
304
315
  await onprogress(indexFile + 1, filesLength, new Entry(fileEntry));
305
- } catch (_error) {
316
+ // eslint-disable-next-line no-unused-vars
317
+ } catch (_) {
306
318
  // ignored
307
319
  }
308
320
  }
@@ -425,7 +437,7 @@ class ZipEntry {
425
437
  localDirectory.rawExtraField = localDirectory.extraFieldLength ?
426
438
  await readUint8Array(reader, offset + 30 + localDirectory.filenameLength, localDirectory.extraFieldLength, diskNumberStart) :
427
439
  new Uint8Array();
428
- await readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
440
+ readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
429
441
  Object.assign(fileEntry, {
430
442
  lastAccessDate: localDirectory.lastAccessDate,
431
443
  creationDate: localDirectory.creationDate
@@ -516,7 +528,7 @@ function readCommonHeader(directory, dataView, offset) {
516
528
  });
517
529
  }
518
530
 
519
- async function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory) {
531
+ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory) {
520
532
  const { rawExtraField } = directory;
521
533
  const extraField = directory.extraField = new Map();
522
534
  const rawExtraFieldView = getDataView(new Uint8Array(rawExtraField));
@@ -531,7 +543,8 @@ async function readCommonFooter(fileEntry, directory, dataView, offset, localDir
531
543
  });
532
544
  offsetExtraField += 4 + size;
533
545
  }
534
- } catch (_error) {
546
+ // eslint-disable-next-line no-unused-vars
547
+ } catch (_) {
535
548
  // ignored
536
549
  }
537
550
  const compressionMethod = getUint16(dataView, offset + 4);
@@ -547,12 +560,12 @@ async function readCommonFooter(fileEntry, directory, dataView, offset, localDir
547
560
  }
548
561
  const extraFieldUnicodePath = extraField.get(EXTRAFIELD_TYPE_UNICODE_PATH);
549
562
  if (extraFieldUnicodePath) {
550
- await readExtraFieldUnicode(extraFieldUnicodePath, PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, directory, fileEntry);
563
+ readExtraFieldUnicode(extraFieldUnicodePath, PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, directory, fileEntry);
551
564
  directory.extraFieldUnicodePath = extraFieldUnicodePath;
552
565
  }
553
566
  const extraFieldUnicodeComment = extraField.get(EXTRAFIELD_TYPE_UNICODE_COMMENT);
554
567
  if (extraFieldUnicodeComment) {
555
- await readExtraFieldUnicode(extraFieldUnicodeComment, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT, directory, fileEntry);
568
+ readExtraFieldUnicode(extraFieldUnicodeComment, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT, directory, fileEntry);
556
569
  directory.extraFieldUnicodeComment = extraFieldUnicodeComment;
557
570
  }
558
571
  const extraFieldAES = extraField.get(EXTRAFIELD_TYPE_AES);
@@ -594,7 +607,7 @@ function readExtraFieldZip64(extraFieldZip64, directory) {
594
607
  }
595
608
  }
596
609
 
597
- async function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName, directory, fileEntry) {
610
+ function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName, directory, fileEntry) {
598
611
  const extraFieldView = getDataView(extraFieldUnicode.data);
599
612
  const crc32 = new Crc32();
600
613
  crc32.append(fileEntry[rawPropertyName]);
@@ -638,7 +651,8 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
638
651
  }
639
652
  offsetExtraField += 4 + attributeSize;
640
653
  }
641
- } catch (_error) {
654
+ // eslint-disable-next-line no-unused-vars
655
+ } catch (_) {
642
656
  // ignored
643
657
  }
644
658
  try {
@@ -659,7 +673,8 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
659
673
  Object.assign(extraFieldNTFS, extraFieldData);
660
674
  Object.assign(directory, extraFieldData);
661
675
  }
662
- } catch (_error) {
676
+ // eslint-disable-next-line no-unused-vars
677
+ } catch (_) {
663
678
  // ignored
664
679
  }
665
680
  }
@@ -728,7 +743,8 @@ function getDate(timeRaw) {
728
743
  const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & 0x0000ffff;
729
744
  try {
730
745
  return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
731
- } catch (_error) {
746
+ // eslint-disable-next-line no-unused-vars
747
+ } catch (_) {
732
748
  // ignored
733
749
  }
734
750
  }